Skip to content

Commit c5861ee

Browse files
test: adapt E2E for simplified "Sign in for dev" flow
Signed-off-by: David Dal Busco <david.dalbusco@outlook.com>
1 parent 6deaf65 commit c5861ee

File tree

8 files changed

+95
-288
lines changed

8 files changed

+95
-288
lines changed

e2e/example.spec.ts

Lines changed: 64 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,100 +1,99 @@
1-
import {testWithII} from '@dfinity/internet-identity-playwright';
2-
import {initTestSuiteWithInternetIdentity, initTestSuiteWithPasskey} from './utils/init.utils';
1+
import {test} from '@playwright/test';
2+
import {initTestSuiteWithInternetIdentity} from './utils/init.utils';
33

4-
testWithII.describe.configure({mode: 'serial'});
4+
test.describe.configure({mode: 'serial'});
55

6-
[
7-
{title: 'With Passkey', initExamplePage: initTestSuiteWithPasskey},
8-
{title: 'With II', initExamplePage: initTestSuiteWithInternetIdentity}
9-
].forEach(({title, initExamplePage}) => {
10-
testWithII.describe(title, () => {
11-
const getExamplePage = initExamplePage();
6+
[{title: 'With Dev', initExamplePage: initTestSuiteWithInternetIdentity}].forEach(
7+
({title, initExamplePage}) => {
8+
test.describe(title, () => {
9+
const getExamplePage = initExamplePage();
1210

13-
testWithII('should sign-in', async () => {
14-
const examplePage = getExamplePage();
11+
test('should sign-in', async () => {
12+
const examplePage = getExamplePage();
1513

16-
await examplePage.assertSignedIn();
17-
});
14+
await examplePage.assertSignedIn();
15+
});
1816

19-
testWithII('should add an entry', async () => {
20-
const examplePage = getExamplePage();
17+
test('should add an entry', async () => {
18+
const examplePage = getExamplePage();
2119

22-
await examplePage.addEntry('My notes.');
23-
});
20+
await examplePage.addEntry('My notes.');
21+
});
2422

25-
testWithII('should add an entry with file', async () => {
26-
const examplePage = getExamplePage();
23+
test('should add an entry with file', async () => {
24+
const examplePage = getExamplePage();
2725

28-
await examplePage.addEntryWithFile({
29-
text: 'My file.',
30-
filePath: 'e2e/data/dog.jpg'
31-
});
26+
await examplePage.addEntryWithFile({
27+
text: 'My file.',
28+
filePath: 'e2e/data/dog.jpg'
29+
});
3230

33-
await examplePage.assertUploadedImage();
34-
});
31+
await examplePage.assertUploadedImage();
32+
});
3533

36-
const lastEntryText = 'My last note.';
34+
const lastEntryText = 'My last note.';
3735

38-
testWithII('should add another entry', async () => {
39-
const examplePage = getExamplePage();
36+
test('should add another entry', async () => {
37+
const examplePage = getExamplePage();
4038

41-
await examplePage.addEntry(lastEntryText);
42-
});
39+
await examplePage.addEntry(lastEntryText);
40+
});
4341

44-
testWithII('should delete entry', async () => {
45-
const examplePage = getExamplePage();
42+
test('should delete entry', async () => {
43+
const examplePage = getExamplePage();
4644

47-
await examplePage.deleteLastEntry();
45+
await examplePage.deleteLastEntry();
4846

49-
await examplePage.assertEntries(2);
50-
});
47+
await examplePage.assertEntries(2);
48+
});
5149

52-
testWithII('should sign-out', async () => {
53-
const examplePage = getExamplePage();
50+
test('should sign-out', async () => {
51+
const examplePage = getExamplePage();
5452

55-
await examplePage.signOut();
53+
await examplePage.signOut();
5654

57-
await examplePage.assertSignedOut();
58-
});
55+
await examplePage.assertSignedOut();
56+
});
5957

60-
// TODO: testWithII does not seem to support setting dark or light mode so for now we just use screenshot of default mode
58+
// TODO: test does not seem to support setting dark or light mode so for now we just use screenshot of default mode
6159

62-
testWithII('match login screenshot', async () => {
63-
const examplePage = getExamplePage();
60+
test('match login screenshot', async () => {
61+
const examplePage = getExamplePage();
6462

65-
await examplePage.assertSignedOut();
63+
await examplePage.assertSignedOut();
6664

67-
await examplePage.assertScreenshot({mode: 'current', name: 'login'});
68-
});
65+
await examplePage.assertScreenshot({mode: 'current', name: 'login'});
66+
});
6967

70-
testWithII('match logged in screenshot', async () => {
71-
const examplePage = getExamplePage();
68+
test('match logged in screenshot', async () => {
69+
const examplePage = getExamplePage();
7270

73-
await examplePage.signIn();
71+
await examplePage.signIn();
7472

75-
await examplePage.assertSignedIn();
73+
await examplePage.assertSignedIn();
7674

77-
await examplePage.assertScreenshot({mode: 'current', name: 'logged-in'});
78-
});
75+
await examplePage.assertScreenshot({mode: 'current', name: 'logged-in'});
76+
});
7977

80-
testWithII('match modal screenshot', async () => {
81-
const examplePage = getExamplePage();
78+
test('match modal screenshot', async () => {
79+
const examplePage = getExamplePage();
8280

83-
await examplePage.openAddEntry();
81+
await examplePage.openAddEntry();
8482

85-
await examplePage.assertScreenshot({mode: 'current', name: 'modal'});
83+
await examplePage.assertScreenshot({mode: 'current', name: 'modal'});
8684

87-
await examplePage.closeAddEntryModal();
88-
});
85+
await examplePage.closeAddEntryModal();
86+
});
8987

90-
testWithII('match logout screenshot', async () => {
91-
const examplePage = getExamplePage();
88+
test('match logout screenshot', async () => {
89+
const examplePage = getExamplePage();
9290

93-
await examplePage.signOut();
91+
await examplePage.signOut();
9492

95-
await examplePage.assertSignedOut();
93+
await examplePage.assertSignedOut();
9694

97-
await examplePage.assertScreenshot({mode: 'current', name: 'logout'});
95+
await examplePage.assertScreenshot({mode: 'current', name: 'logout'});
96+
});
9897
});
99-
});
100-
});
98+
}
99+
);

e2e/page-objects/app.page.ts

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,15 @@ export abstract class AppPage {
1212
protected readonly browser: Browser;
1313

1414
protected readonly callToActions = {
15+
login: 'Sign in for dev',
1516
logout: 'Logout',
1617
add_an_entry: 'Add an entry',
17-
submit: 'Submit',
18-
internet_identity: {
19-
continue: 'Continue with Internet Identity'
20-
},
21-
passkey: {
22-
continue: 'Continue with Passkey',
23-
create: 'Create a new passkey',
24-
create_now: 'Create now',
25-
use: 'Use your Passkey'
26-
}
18+
submit: 'Submit'
2719
};
2820

2921
protected readonly locators = {
3022
open_data: 'a[aria-label="Open data"]',
31-
delete_entry: 'button[aria-label="Delete entry"]',
32-
internet_identity: {
33-
sign_in: `button:has-text("${this.callToActions.internet_identity.continue}")`
34-
}
23+
delete_entry: 'button[aria-label="Delete entry"]'
3524
};
3625

3726
protected constructor({page, context, browser}: AppPageParams) {
@@ -44,8 +33,6 @@ export abstract class AppPage {
4433

4534
cleanUp?(): Promise<void>;
4635

47-
abstract signUp(): Promise<void>;
48-
4936
abstract signIn(): Promise<void>;
5037

5138
async signOut(): Promise<void> {
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import {expect} from '@playwright/test';
2+
import type {AppPageParams} from './app.page';
3+
import {ExamplePage} from './example.page';
4+
5+
export class ExampleInternetIdentityPage extends ExamplePage {
6+
private constructor(params: AppPageParams) {
7+
super(params);
8+
}
9+
10+
static async create(params: AppPageParams): Promise<ExampleInternetIdentityPage> {
11+
return new ExampleInternetIdentityPage(params);
12+
}
13+
14+
override async signIn(): Promise<void> {
15+
const signInButton = this.page.locator('button', {
16+
hasText: this.callToActions.login
17+
});
18+
await expect(signInButton).toBeVisible();
19+
20+
await signInButton.click();
21+
}
22+
}

e2e/page-objects/example.ii.page.ts

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

0 commit comments

Comments
 (0)