Skip to content

Commit 1ff72e7

Browse files
committed
Refactor connect complete
1 parent 516141a commit 1ff72e7

52 files changed

Lines changed: 986 additions & 2159 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

packages/tests-e2e/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,11 @@ echo $JWT
5656
The first segment of the script contains all the information that must be extracted from the backend deployment.
5757

5858
As evident in the script, the token is valid for around 34 days. The token is intended to be renewed monthly using this script. For rewnewal, it is not necessary to extract all the information in the first segment.
59+
60+
## Authoring rules (connect2)
61+
62+
- Knowledge about page structure lives in `/models` only. Scenarios call model methods, not raw selectors.
63+
- All passkey authenticator interactions flow through `VirtualAuthenticator`.
64+
- All TOTP authenticator interactions flow through `AuthenticatorApp`.
65+
- Scenarios set up app state via navigation helpers and avoid duplicating UI logic.
66+
- Prefer explicit `awaitPage/visible` checks when changing screens.

packages/tests-e2e/playwright.config.connect.ts

Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { defineConfig } from '@playwright/test';
22
import dotenv from 'dotenv';
33
import path from 'path';
44

5-
import { operationTimeout, totalTimeout } from './src/connect/utils/Constants';
5+
const operationTimeout = 5000;
66

77
if (process.env.CI) {
88
dotenv.config({ path: path.resolve(__dirname, '.env.connect.ci'), override: true });
@@ -11,35 +11,16 @@ if (process.env.CI) {
1111
}
1212

1313
export default defineConfig({
14-
testDir: './src/connect2',
15-
// fullyParallel: true,
14+
testDir: './src/connect',
1615
forbidOnly: !!process.env.CI,
1716
retries: 4,
1817
workers: process.env.CI
1918
? process.env.PLAYWRIGHT_NUM_CORES
2019
? parseInt(process.env.PLAYWRIGHT_NUM_CORES, 10) - 1
2120
: undefined
2221
: undefined,
23-
reporter: [
24-
// [
25-
// '../../node_modules/playwright-slack-report/dist/src/SlackReporter.js',
26-
// {
27-
// channels: ['corbado-tests'],
28-
// sendResults: 'always',
29-
// showInThread: true,
30-
// meta: [
31-
// {
32-
// key: 'Test Run Info',
33-
// value: `https://github.com/corbado/javascript/actions/runs/${process.env.GITHUB_RUN_ID}`,
34-
// },
35-
// { key: 'branch', value: `${process.env.GITHUB_BRANCH_NAME}` },
36-
// ],
37-
// },
38-
// ],
39-
['html'],
40-
['junit', { outputFile: 'test-results/results.xml' }],
41-
],
42-
timeout: totalTimeout, // default: 30000ms
22+
reporter: [['html'], ['junit', { outputFile: 'test-results/results.xml' }]],
23+
timeout: 120000, // default: 30000ms
4324
expect: {
4425
timeout: operationTimeout, // default: 5000ms
4526
},
@@ -48,16 +29,23 @@ export default defineConfig({
4829
'Mozilla/5.0 (Macintosh; Intel Mac OS X 15.3.2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36',
4930
actionTimeout: operationTimeout, // default: none
5031
navigationTimeout: operationTimeout, // default: none
51-
// baseURL: process.env.PLAYWRIGHT_TEST_URL,
5232
screenshot: 'only-on-failure',
5333
video: 'retain-on-failure',
5434
trace: 'retain-on-failure',
5535
},
5636
projects: [
5737
{
58-
name: 'append-component',
38+
name: 'append',
5939
testMatch: ['scenarios/append.spec.ts'],
6040
},
41+
{
42+
name: 'login',
43+
testMatch: ['scenarios/login.spec.ts'],
44+
},
45+
{
46+
name: 'network-blocking',
47+
testMatch: ['scenarios/network-blocking.spec.ts'],
48+
},
6149
],
6250
globalSetup: 'src/connect/utils/Playground.ts',
6351
});

packages/tests-e2e/src/connect/fixtures/BaseTest.ts

Lines changed: 0 additions & 24 deletions
This file was deleted.

packages/tests-e2e/src/connect/models/AppendModel.ts

Lines changed: 0 additions & 38 deletions
This file was deleted.

packages/tests-e2e/src/connect/models/BaseModel.ts

Lines changed: 0 additions & 79 deletions
This file was deleted.

packages/tests-e2e/src/connect2/models/BasePage.ts renamed to packages/tests-e2e/src/connect/models/BasePage.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ export abstract class BasePage {
1717
return this.page.getByRole('link', { name: label }).click();
1818
}
1919

20+
clickText(text: string): Promise<void> {
21+
return this.page.getByText(text).click();
22+
}
23+
2024
async waitForHeading(text: string): Promise<boolean> {
2125
try {
2226
await this.page.getByRole('heading', { name: text }).waitFor({ state: 'visible', timeout: 10000 });
@@ -56,4 +60,20 @@ export abstract class BasePage {
5660
expectText(text: string): Promise<void> {
5761
return this.page.getByText(text).waitFor({ state: 'visible' });
5862
}
63+
64+
// client-state
65+
async clearProcessState(): Promise<void> {
66+
return this.localStorageClearByPrefix('cbo_connect_process');
67+
}
68+
69+
private localStorageClearByPrefix(prefix: string): Promise<void> {
70+
return this.page.evaluate(prefix => {
71+
for (let i = localStorage.length - 1; i >= 0; i--) {
72+
const key = localStorage.key(i);
73+
if (key && key.startsWith(prefix)) {
74+
localStorage.removeItem(key);
75+
}
76+
}
77+
}, prefix);
78+
}
5979
}

packages/tests-e2e/src/connect/models/HomeModel.ts

Lines changed: 0 additions & 17 deletions
This file was deleted.

packages/tests-e2e/src/connect/models/LoginModel.ts

Lines changed: 0 additions & 69 deletions
This file was deleted.

0 commit comments

Comments
 (0)