Skip to content

Commit

Permalink
add tests for different identity verification configs
Browse files Browse the repository at this point in the history
  • Loading branch information
aehnh committed Jan 30, 2024
1 parent d5f08cc commit 1b81078
Show file tree
Hide file tree
Showing 30 changed files with 411 additions and 44 deletions.
99 changes: 88 additions & 11 deletions packages/tests-e2e/playwright.config.ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,35 +12,112 @@ export default defineConfig({
trace: 'on-first-retry',
},
projects: [
////////////////////////////////////////////
// default configs:
// - doubleOptIn: true
// - signupFlow: PasskeyWithEmailOTPFallback
// - allowUserRegistration: true
// - userFullNameRequired: true
{
name: 'chromium',
name: 'default-setup',
testMatch: ['ui/default/setup.ts'],
},
{
name: 'default-chromium',
use: { ...devices['Desktop Chrome'] },
testMatch: ['ui/**/*.*'],
testMatch: ['ui/default/**/*.*'],
dependencies: ['default-setup'],
},
// {
// name: 'firefox',
// use: { ...devices['Desktop Firefox'] },
// testMatch: ['ui/all-browsers/**/*.*'],
// testMatch: ['ui/default/all-browsers/**/*.*'],
// },
{
name: 'webkit',
name: 'default-webkit',
use: { ...devices['Desktop Safari'] },
testMatch: ['ui/all-browsers/**/*.*'],
testMatch: ['ui/default/all-browsers/**/*.*'],
dependencies: ['default-setup'],
},
{
name: 'Mobile Chrome',
name: 'default-mobileChrome',
use: { ...devices['Pixel 7'] },
testMatch: ['ui/**/*.*'],
testMatch: ['ui/default/**/*.*'],
dependencies: ['default-setup'],
},
{
name: 'Mobile Safari',
name: 'default-mobileSafari',
use: { ...devices['iPhone 14 Pro Max'] },
testMatch: ['ui/all-browsers/**/*.*'],
testMatch: ['ui/default/all-browsers/**/*.*'],
dependencies: ['default-setup'],
},
{
name: 'Microsoft Edge',
name: 'default-msedge',
use: { ...devices['Desktop Edge'], channel: 'msedge' },
testMatch: ['ui/**/*.*'],
testMatch: ['ui/default/**/*.*'],
dependencies: ['default-setup'],
},
////////////////////////////////////////////
// changed config:
// - doubleOptIn: false
{
name: 'noVerification-setup',
testMatch: ['ui/noVerification/setup.ts'],
dependencies: [
'default-chromium',
'default-webkit',
'default-mobileChrome',
'default-mobileSafari',
'default-msedge',
],
},
{
name: 'noVerification-chromium',
use: { ...devices['Desktop Chrome'] },
testMatch: ['ui/noVerification/**/*.*'],
dependencies: ['noVerification-setup'],
},
////////////////////////////////////////////
// changed config:
// - signupFlow: EmailOTPSignup
{
name: 'verificationAtSignup-setup',
testMatch: ['ui/verificationAtSignup/setup.ts'],
dependencies: ['noVerification-chromium'],
},
{
name: 'verificationAtSignup-chromium',
use: { ...devices['Desktop Chrome'] },
testMatch: ['ui/verificationAtSignup/**/*.*'],
dependencies: ['verificationAtSignup-setup'],
},
////////////////////////////////////////////
// changed config:
// - allowUserRegistration: false
{
name: 'noSignup-setup',
testMatch: ['ui/noSignup/setup.ts'],
dependencies: ['verificationAtSignup-chromium'],
},
{
name: 'noSignup-chromium',
use: { ...devices['Desktop Chrome'] },
testMatch: ['ui/noSignup/**/*.*'],
dependencies: ['noSignup-setup'],
},
////////////////////////////////////////////
// changed config:
// - userFullNameRequired: false
{
name: 'noName-setup',
testMatch: ['ui/noName/setup.ts'],
dependencies: ['noSignup-chromium'],
},
{
name: 'noName-chromium',
use: { ...devices['Desktop Chrome'] },
testMatch: ['ui/noName/**/*.*'],
dependencies: ['noName-setup'],
},
],
});
53 changes: 53 additions & 0 deletions packages/tests-e2e/src/models/UILoginFlow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,56 @@ export class UILoginFlow {
return [name, email];
}

// only for "Verification at sign up" config
async createAccountWithVerificationAtSignup(
passkeySupported: boolean,
registerPasskey = true,
): Promise<[name: string, email: string]> {
const name = UserManager.getUserForSignup();
const email = `${name}@corbado.com`;

await this.page.getByPlaceholder('Name').click();
await this.page.getByPlaceholder('Name').fill(name);
await expect(this.page.getByPlaceholder('Name')).toHaveValue(name);

await this.page.getByPlaceholder('Email address').click();
await this.page.getByPlaceholder('Email address').fill(email);
await expect(this.page.getByPlaceholder('Email address')).toHaveValue(email);

await this.page.getByRole('button', { name: 'Continue' }).click();
await this.checkLandedOnScreen(ScreenNames.EnterOtp);

await this.fillOTP();

if (passkeySupported) {
await this.checkLandedOnScreen(ScreenNames.PasskeyAppend);

if (registerPasskey) {
await this.page.getByRole('button', { name: 'Activate' }).click();
await this.inputPasskey(async () => {
await this.checkLandedOnScreen(ScreenNames.PasskeySuccess);
});

await this.page.getByRole('button', { name: 'Continue' }).click();
await this.checkLandedOnScreen(ScreenNames.End);
await this.checkPasskeyRegistered();
} else {
await this.page.getByRole('button', { name: 'Maybe later' }).click();
await this.checkLandedOnScreen(ScreenNames.End);
await this.checkNoPasskeyRegistered();
}

await this.page.getByRole('button', { name: 'Logout' }).click();
} else {
await this.checkLandedOnScreen(ScreenNames.End);
await this.checkNoPasskeyRegistered();
}

await loadAuth(this.page);

return [name, email];
}

async checkPasskeyRegistered() {
await expect(this.page.locator('.cb-passkey-list-card')).toHaveCount(1);
}
Expand All @@ -151,6 +201,9 @@ export class UILoginFlow {
case ScreenNames.EnterOtp:
await expect(this.page.getByRole('heading', { level: 1 })).toContainText('Enter one-time passcode to');
break;
case ScreenNames.PasskeyCreate:
await expect(this.page.getByRole('heading', { level: 1 })).toContainText("Let's get you set up with");
break;
case ScreenNames.PasskeyBenefits:
await expect(this.page.getByRole('heading', { level: 1 })).toHaveText('Passkeys');
break;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { test } from '../../../fixtures/UILoginTest';
import { ScreenNames } from '../../../utils/constants';
import { test } from '../../../../fixtures/UILoginTest';
import { ScreenNames } from '../../../../utils/constants';

test.describe('Login with email OTP proper user behavior', () => {
test('with no passkey support', async ({ loginFlow }) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect, test } from '../../../fixtures/UILoginTest';
import { OtpType, ScreenNames } from '../../../utils/constants';
import { expect, test } from '../../../../fixtures/UILoginTest';
import { OtpType, ScreenNames } from '../../../../utils/constants';

test.describe('EnterOtpScreen unproductive user behavior', () => {
test('go back to Start', async ({ loginFlow, page }) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect, test } from '../../../fixtures/UILoginTest';
import { ScreenNames } from '../../../utils/constants';
import { expect, test } from '../../../../fixtures/UILoginTest';
import { ScreenNames } from '../../../../utils/constants';

test.describe('StartScreen unproductive user behavior', () => {
// TODO: add when bug is fixed
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { test } from '../../../fixtures/UISignupTest';
import { ScreenNames } from '../../../utils/constants';
import { test } from '../../../../fixtures/UISignupTest';
import { ScreenNames } from '../../../../utils/constants';

test.describe('Signup with email OTP proper user behavior', () => {
test('with no passkey support', async ({ signupFlow }) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect, test } from '../../../fixtures/UISignupTest';
import { OtpType, ScreenNames } from '../../../utils/constants';
import { expect, test } from '../../../../fixtures/UISignupTest';
import { OtpType, ScreenNames } from '../../../../utils/constants';

test.describe('EnterOtpScreen unproductive user behavior', () => {
test('go back to InitiateSignup', async ({ signupFlow, page }) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect, test } from '../../../fixtures/UISignupTest';
import { ScreenNames } from '../../../utils/constants';
import { expect, test } from '../../../../fixtures/UISignupTest';
import { ScreenNames } from '../../../../utils/constants';

test.describe('StartScreen unproductive user behavior', () => {
test('with empty name', async ({ signupFlow, page }) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { test } from '../../../fixtures/UILoginTest';
import { ScreenNames } from '../../../utils/constants';
import { test } from '../../../../fixtures/UILoginTest';
import { ScreenNames } from '../../../../utils/constants';

test.describe('Login with email OTP proper user behavior', () => {
test('with passkey support', async ({ loginFlow, page }) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect, test } from '../../../fixtures/UILoginTest';
import { ScreenNames } from '../../../utils/constants';
import { expect, test } from '../../../../fixtures/UILoginTest';
import { ScreenNames } from '../../../../utils/constants';

test.describe('Login with passkey proper user behavior', () => {
test('from Start', async ({ loginFlow, page }) => {
Expand Down Expand Up @@ -40,6 +40,8 @@ test.describe('Login with passkey proper user behavior', () => {
});
});

// TODO: figure out why there's flakiness where conditional UI does not show up
// (almost always fails when running all tests wtf??? but never fails when running alone)
test('from Start with conditional UI', async ({ loginFlow, page, channel }) => {
if (channel) {
test.skip(channel.includes('msedge'), 'Edge does not support conditional UI');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { test } from '../../../fixtures/UILoginTest';
import { ScreenNames } from '../../../utils/constants';
import { test } from '../../../../fixtures/UILoginTest';
import { ScreenNames } from '../../../../utils/constants';

test.describe('PasskeyAppendScreen unproductive user behavior', () => {
test('go to PasskeyBenefits', async ({ loginFlow, page }) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { test } from '../../../fixtures/UILoginTest';
import { ScreenNames } from '../../../utils/constants';
import { test } from '../../../../fixtures/UILoginTest';
import { ScreenNames } from '../../../../utils/constants';

test.describe('PasskeyBenefitsScreen unproductive user behavior', () => {
test('declining goes to LoggedIn', async ({ loginFlow, page }) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { expect, test } from '../../../fixtures/UILoginTest';
import { ScreenNames } from '../../../utils/constants';
import { expect, test } from '../../../../fixtures/UILoginTest';
import { ScreenNames } from '../../../../utils/constants';

test.describe('StartScreen unproductive user behavior', () => {
test('logging in from different device goes to EnterOtp', async ({ loginFlow, page }) => {
// TODO: figure out how to simulate different users (simply adding a different webauthn doesn't work, maybe try adding credentials manually)
test.skip('logging in from different device goes to EnterOtp', async ({ loginFlow, page }) => {
await loginFlow.initializeCDPSession();
await loginFlow.addWebAuthn(true);
await loginFlow.loadAuth();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { test } from '../../../fixtures/UISignupTest';
import { ScreenNames } from '../../../utils/constants';
import { test } from '../../../../fixtures/UISignupTest';
import { ScreenNames } from '../../../../utils/constants';

test.describe('Signup with email OTP proper user behavior', () => {
test('with passkey support', async ({ signupFlow, page }) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { test } from '../../../fixtures/UISignupTest';
import { ScreenNames } from '../../../utils/constants';
import { test } from '../../../../fixtures/UISignupTest';
import { ScreenNames } from '../../../../utils/constants';

test.describe('Signup with passkey proper user behavior', () => {
test('from PasskeySignup', async ({ signupFlow, page }) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { test } from '../../../fixtures/UISignupTest';
import { ScreenNames } from '../../../utils/constants';
import { test } from '../../../../fixtures/UISignupTest';
import { ScreenNames } from '../../../../utils/constants';

test.describe('PasskeyAppendScreen unproductive user behavior', () => {
test('go to PasskeyBenefits', async ({ signupFlow, page }) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { test } from '../../../fixtures/UISignupTest';
import { ScreenNames } from '../../../utils/constants';
import { test } from '../../../../fixtures/UISignupTest';
import { ScreenNames } from '../../../../utils/constants';

test.describe('PasskeyBenefitsScreen unproductive user behavior', () => {
test('skip to OTP method', async ({ signupFlow, page }) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { test } from '../../../fixtures/UISignupTest';
import { ScreenNames } from '../../../utils/constants';
import { test } from '../../../../fixtures/UISignupTest';
import { ScreenNames } from '../../../../utils/constants';

test.describe('PasskeyCreateScreen unproductive user behavior', () => {
test('change to OTP method', async ({ signupFlow, page }) => {
Expand Down
7 changes: 7 additions & 0 deletions packages/tests-e2e/src/ui/default/setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { test as setup } from '@playwright/test';

import { setBackendConfigs } from '../../utils/helperFunctions/setBackendConfigs';

setup('set default configs', async () => {
await setBackendConfigs();
});
7 changes: 7 additions & 0 deletions packages/tests-e2e/src/ui/noName/setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { test as setup } from '@playwright/test';

import { setBackendConfigs } from '../../utils/helperFunctions/setBackendConfigs';

setup('set default configs', async () => {
await setBackendConfigs({ userFullNameRequired: false });
});
7 changes: 7 additions & 0 deletions packages/tests-e2e/src/ui/noSignup/setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { test as setup } from '@playwright/test';

import { setBackendConfigs } from '../../utils/helperFunctions/setBackendConfigs';

setup('set default configs', async () => {
await setBackendConfigs({ allowUserRegistration: false });
});
Loading

0 comments on commit 1b81078

Please sign in to comment.