|
3 | 3 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
4 | 4 |
|
5 | 5 | import { expect, test } from '../../lib/fixtures/standard'; |
6 | | -import { syncDesktopOAuthQueryParams } from '../../lib/query-params'; |
| 6 | +import { relayDesktopOAuthQueryParams, syncDesktopOAuthQueryParams } from '../../lib/query-params'; |
7 | 7 | import { getTotpCode } from '../../lib/totp'; |
8 | 8 |
|
9 | 9 | test.describe('severity-1 #smoke', () => { |
@@ -730,42 +730,88 @@ test.describe('severity-1 #smoke', () => { |
730 | 730 |
|
731 | 731 | test.describe('severity-2', () => { |
732 | 732 | test.describe('Passwordless authentication - Cached login', () => { |
733 | | - test('passwordless account navigating to content server redirects to OTP (not cached login)', async ({ |
| 733 | + test('passwordless account with cached session navigating to content server sees cached signin', async ({ |
734 | 734 | target, |
735 | | - pages: { page, signin, relier, signinPasswordlessCode, settings }, |
| 735 | + pages: { page, signin, relier, signinPasswordlessCode }, |
736 | 736 | testAccountTracker, |
737 | 737 | }) => { |
738 | | - // Create passwordless account via 123done |
739 | 738 | const { email } = |
740 | 739 | testAccountTracker.generatePasswordlessAccountDetails(); |
741 | 740 |
|
742 | 741 | await relier.goto('force_passwordless=true'); |
743 | 742 | await relier.clickEmailFirst(); |
744 | 743 | await signin.fillOutEmailFirstForm(email); |
745 | 744 |
|
746 | | - // Should redirect to passwordless code page |
747 | 745 | await expect(page).toHaveURL(/signin_passwordless_code/); |
748 | 746 |
|
749 | | - // Get OTP code from email |
750 | 747 | const code = await target.emailClient.getPasswordlessSignupCode(email); |
751 | 748 | await signinPasswordlessCode.fillOutCodeForm(code); |
752 | 749 |
|
753 | | - // Should complete OAuth and redirect to RP |
754 | 750 | expect(await relier.isLoggedIn()).toBe(true); |
755 | 751 |
|
756 | | - // Navigate to content server — passwordless accounts are always |
757 | | - // redirected to OTP verification (container.tsx checks hasPassword=false |
758 | | - // && passwordlessSupported=true and redirects before cached UI renders) |
| 752 | + // Navigate to / — cached session should show signin, not OTP |
759 | 753 | await page.goto(target.contentServerUrl); |
760 | 754 |
|
| 755 | + await expect(page).not.toHaveURL(/signin_passwordless_code/); |
| 756 | + await expect(signin.cachedSigninHeading).toBeVisible(); |
| 757 | + }); |
| 758 | + |
| 759 | + test('passwordless account with cached session navigating to /signin sees cached signin page', async ({ |
| 760 | + target, |
| 761 | + pages: { page, signin, relier, signinPasswordlessCode }, |
| 762 | + testAccountTracker, |
| 763 | + }) => { |
| 764 | + const { email } = |
| 765 | + testAccountTracker.generatePasswordlessAccountDetails(); |
| 766 | + |
| 767 | + await relier.goto('force_passwordless=true'); |
| 768 | + await relier.clickEmailFirst(); |
| 769 | + await signin.fillOutEmailFirstForm(email); |
| 770 | + |
761 | 771 | await expect(page).toHaveURL(/signin_passwordless_code/); |
762 | | - await expect(signinPasswordlessCode.heading).toBeVisible(); |
| 772 | + const code = await target.emailClient.getPasswordlessSignupCode(email); |
| 773 | + await signinPasswordlessCode.fillOutCodeForm(code); |
763 | 774 |
|
764 | | - // Complete OTP flow to reach settings |
765 | | - const signinCode = await target.emailClient.getPasswordlessSigninCode(email); |
766 | | - await signinPasswordlessCode.fillOutCodeForm(signinCode); |
| 775 | + expect(await relier.isLoggedIn()).toBe(true); |
| 776 | + |
| 777 | + // Navigate to / — cached session should show signin, not OTP |
| 778 | + await page.goto(target.contentServerUrl); |
| 779 | + |
| 780 | + await expect(page).not.toHaveURL(/signin_passwordless_code/); |
| 781 | + await expect(signin.cachedSigninHeading).toBeVisible(); |
| 782 | + |
| 783 | + // Navigate to /signin directly — same behavior |
| 784 | + await page.goto( |
| 785 | + `${target.contentServerUrl}/signin?email=${email}` |
| 786 | + ); |
| 787 | + await expect(page).not.toHaveURL(/signin_passwordless_code/); |
| 788 | + await expect(signin.cachedSigninHeading).toBeVisible(); |
| 789 | + }); |
| 790 | + |
| 791 | + test('passwordless signup via Settings then navigating to / shows cached signin (not OTP)', async ({ |
| 792 | + target, |
| 793 | + pages: { page, signin, signinPasswordlessCode, settings }, |
| 794 | + testAccountTracker, |
| 795 | + }) => { |
| 796 | + const { email } = |
| 797 | + testAccountTracker.generatePasswordlessAccountDetails(); |
| 798 | + |
| 799 | + await page.goto( |
| 800 | + `${target.contentServerUrl}/?force_passwordless=true` |
| 801 | + ); |
| 802 | + await signin.fillOutEmailFirstForm(email); |
| 803 | + |
| 804 | + await expect(page).toHaveURL(/signin_passwordless_code/); |
| 805 | + |
| 806 | + const code = await target.emailClient.getPasswordlessSignupCode(email); |
| 807 | + await signinPasswordlessCode.fillOutCodeForm(code); |
767 | 808 |
|
768 | 809 | await expect(settings.settingsHeading).toBeVisible(); |
| 810 | + |
| 811 | + // Navigate to / — cached session should show signin, not OTP |
| 812 | + await page.goto(target.contentServerUrl); |
| 813 | + await expect(page).not.toHaveURL(/signin_passwordless_code/); |
| 814 | + await expect(signin.cachedSigninHeading).toBeVisible(); |
769 | 815 | }); |
770 | 816 | }); |
771 | 817 |
|
@@ -992,6 +1038,29 @@ test.describe('severity-2', () => { |
992 | 1038 | // flow since webchannel state from first login is stale. |
993 | 1039 | }); |
994 | 1040 | }); |
995 | | -}); |
996 | 1041 |
|
| 1042 | +test.describe('Passwordless authentication - Browser Service (Relay)', () => { |
| 1043 | + test('passwordless signin via Relay OAuth flow', async ({ |
| 1044 | + target, |
| 1045 | + pages: { page, signin, signinPasswordlessCode }, |
| 1046 | + testAccountTracker, |
| 1047 | + }) => { |
| 1048 | + const { email } = await testAccountTracker.signUpPasswordless(); |
| 1049 | + |
| 1050 | + const params = new URLSearchParams(relayDesktopOAuthQueryParams); |
| 1051 | + await signin.goto('/authorization', params); |
| 1052 | + |
| 1053 | + await signin.fillOutEmailFirstForm(email); |
| 1054 | + |
| 1055 | + await expect(page).toHaveURL(/signin_passwordless_code/); |
| 1056 | + await expect(signinPasswordlessCode.heading).toBeVisible(); |
| 1057 | + |
| 1058 | + const code = await target.emailClient.getPasswordlessSigninCode(email); |
| 1059 | + await signinPasswordlessCode.fillOutCodeForm(code); |
997 | 1060 |
|
| 1061 | + // After OTP, the flow either redirects to set_password or |
| 1062 | + // completes the OAuth flow — verify we left the OTP page |
| 1063 | + await expect(page).not.toHaveURL(/signin_passwordless_code/); |
| 1064 | + }); |
| 1065 | +}); |
| 1066 | +}); |
0 commit comments