|
| 1 | +/* This Source Code Form is subject to the terms of the Mozilla Public |
| 2 | + * License, v. 2.0. If a copy of the MPL was not distributed with this |
| 3 | + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
| 4 | + |
| 5 | +import { FirefoxCommand } from '../../lib/channels'; |
| 6 | +import { expect, test } from '../../lib/fixtures/standard'; |
| 7 | +import { smartWindowDesktopOAuthQueryParams } from '../../lib/query-params'; |
| 8 | +import { getTotpCode } from '../../lib/totp'; |
| 9 | + |
| 10 | +test.describe('smart window integration', () => { |
| 11 | + test('signup with SmartWindow desktop', async ({ |
| 12 | + target, |
| 13 | + syncOAuthBrowserPages: { confirmSignupCode, page, signup }, |
| 14 | + testAccountTracker, |
| 15 | + }) => { |
| 16 | + const { email, password } = |
| 17 | + testAccountTracker.generateSignupAccountDetails(); |
| 18 | + |
| 19 | + await signup.goto('/authorization', smartWindowDesktopOAuthQueryParams); |
| 20 | + |
| 21 | + await expect( |
| 22 | + signup.page.getByText('Firefox Smart Window', { exact: false }) |
| 23 | + ).toBeVisible(); |
| 24 | + |
| 25 | + await signup.emailTextbox.fill(email); |
| 26 | + await signup.submitButton.click(); |
| 27 | + |
| 28 | + await page.waitForURL(/signup/); |
| 29 | + |
| 30 | + await signup.passwordTextbox.fill(password); |
| 31 | + await signup.createAccountButton.click(); |
| 32 | + |
| 33 | + await page.waitForURL(/confirm_signup_code/); |
| 34 | + |
| 35 | + const code = await target.emailClient.getVerifyShortCode(email); |
| 36 | + await confirmSignupCode.fillOutCodeForm(code); |
| 37 | + |
| 38 | + await page.waitForURL(/settings/); |
| 39 | + |
| 40 | + await signup.checkWebChannelMessage(FirefoxCommand.OAuthLogin); |
| 41 | + await signup.checkWebChannelMessageServices(FirefoxCommand.Login, { |
| 42 | + smartwindow: {}, |
| 43 | + }); |
| 44 | + }); |
| 45 | + |
| 46 | + test('signin with SmartWindow desktop', async ({ |
| 47 | + syncOAuthBrowserPages: { page, signin }, |
| 48 | + testAccountTracker, |
| 49 | + }) => { |
| 50 | + const { email, password } = await testAccountTracker.signUp(); |
| 51 | + |
| 52 | + await signin.goto('/authorization', smartWindowDesktopOAuthQueryParams); |
| 53 | + |
| 54 | + await expect( |
| 55 | + signin.page.getByText('Firefox Smart Window', { exact: false }) |
| 56 | + ).toBeVisible(); |
| 57 | + |
| 58 | + await signin.fillOutEmailFirstForm(email); |
| 59 | + |
| 60 | + await signin.fillOutPasswordForm(password); |
| 61 | + |
| 62 | + await page.waitForURL(/settings/); |
| 63 | + |
| 64 | + await signin.checkWebChannelMessage(FirefoxCommand.OAuthLogin); |
| 65 | + await signin.checkWebChannelMessageServices(FirefoxCommand.Login, { |
| 66 | + smartwindow: {}, |
| 67 | + }); |
| 68 | + }); |
| 69 | + |
| 70 | + test('signin with SmartWindow desktop - with confirm email', async ({ |
| 71 | + target, |
| 72 | + syncOAuthBrowserPages: { signinTokenCode, page, signin }, |
| 73 | + testAccountTracker, |
| 74 | + }) => { |
| 75 | + const { email, password } = await testAccountTracker.signUpSync(); |
| 76 | + |
| 77 | + await signin.goto('/authorization', smartWindowDesktopOAuthQueryParams); |
| 78 | + |
| 79 | + await expect( |
| 80 | + signin.page.getByText('Firefox Smart Window', { exact: false }) |
| 81 | + ).toBeVisible(); |
| 82 | + |
| 83 | + await signin.fillOutEmailFirstForm(email); |
| 84 | + |
| 85 | + await signin.fillOutPasswordForm(password); |
| 86 | + |
| 87 | + await page.waitForURL(/signin_token_code/); |
| 88 | + const code = await target.emailClient.getVerifyLoginCode(email); |
| 89 | + await signinTokenCode.fillOutCodeForm(code); |
| 90 | + |
| 91 | + await page.waitForURL(/settings/); |
| 92 | + |
| 93 | + await signin.checkWebChannelMessage(FirefoxCommand.OAuthLogin); |
| 94 | + await signin.checkWebChannelMessageServices(FirefoxCommand.Login, { |
| 95 | + smartwindow: {}, |
| 96 | + }); |
| 97 | + }); |
| 98 | + |
| 99 | + test('signin with SmartWindow desktop - with 2FA', async ({ |
| 100 | + target, |
| 101 | + syncOAuthBrowserPages: { signinTotpCode, totp, page, signin, settings }, |
| 102 | + testAccountTracker, |
| 103 | + }) => { |
| 104 | + const credentials = await testAccountTracker.signUp(); |
| 105 | + const { email, password } = credentials; |
| 106 | + |
| 107 | + // Sign-in without Sync, otw you will get prompted to create a recovery key |
| 108 | + await page.goto(target.contentServerUrl, { waitUntil: 'load' }); |
| 109 | + |
| 110 | + await signin.fillOutEmailFirstForm(email); |
| 111 | + await signin.fillOutPasswordForm(password); |
| 112 | + |
| 113 | + await expect(settings.settingsHeading).toBeVisible(); |
| 114 | + await settings.totp.addButton.click(); |
| 115 | + await settings.confirmMfaGuard(email); |
| 116 | + const { secret } = |
| 117 | + await totp.setUpTwoStepAuthWithQrAndBackupCodesChoice(credentials); |
| 118 | + await expect(settings.totp.status).toHaveText('Enabled'); |
| 119 | + await settings.signOut(); |
| 120 | + |
| 121 | + await signin.goto('/authorization', smartWindowDesktopOAuthQueryParams); |
| 122 | + |
| 123 | + await expect( |
| 124 | + signin.page.getByText('Firefox Smart Window', { exact: false }) |
| 125 | + ).toBeVisible(); |
| 126 | + |
| 127 | + await signin.fillOutEmailFirstForm(email); |
| 128 | + |
| 129 | + await signin.fillOutPasswordForm(password); |
| 130 | + |
| 131 | + await page.waitForURL(/signin_totp_code/); |
| 132 | + |
| 133 | + const totpCode = await getTotpCode(secret); |
| 134 | + await signinTotpCode.fillOutCodeForm(totpCode); |
| 135 | + |
| 136 | + await page.waitForURL(/settings/); |
| 137 | + |
| 138 | + await signin.checkWebChannelMessage(FirefoxCommand.OAuthLogin); |
| 139 | + await signin.checkWebChannelMessageServices(FirefoxCommand.Login, { |
| 140 | + smartwindow: {}, |
| 141 | + }); |
| 142 | + }); |
| 143 | +}); |
0 commit comments