Skip to content

Commit 9809252

Browse files
committed
Improve e2e tests robustness with added content script checks and extended timeouts, update Playwright version, and refine popup interaction flows.
1 parent 56a20ba commit 9809252

10 files changed

Lines changed: 67 additions & 120 deletions

File tree

.github/workflows/e2e-onboarding-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
timeout-minutes: 60
1212
runs-on: ubuntu-latest
1313
container:
14-
image: mcr.microsoft.com/playwright:v1.39.0-jammy
14+
image: mcr.microsoft.com/playwright:v1.56.1-jammy
1515

1616
steps:
1717
- uses: actions/checkout@v4

.github/workflows/e2e-popup-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
timeout-minutes: 60
1212
runs-on: ubuntu-latest
1313
container:
14-
image: mcr.microsoft.com/playwright:v1.39.0-jammy
14+
image: mcr.microsoft.com/playwright:v1.56.1-jammy
1515

1616
steps:
1717
- uses: actions/checkout@v4

e2e-tests/constants.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Page } from '@playwright/test';
22
import path from 'path';
33

4+
45
export const newPassword = 'this is new password';
56
export const vaultPassword = '3hQqzYn4C7Y8rEZTVEZb';
67
export const twentyFourWordsSecretPhrase =
@@ -127,8 +128,8 @@ export const VALIDATOR_FOR_UNDELEGATE = {
127128

128129
export const NEW_VALIDATOR_FOR_STAKE = {
129130
publicKey:
130-
'01c8be540a643e6c9df283dd2d2d6be67748f69a3c7bb6cf34471c899b8e858c9a',
131-
truncatedPublicKey: '01c8...8c9a'
131+
'0106ca7c39cd272dbf21a86eeb3b36b7c26e2e9b94af64292419f7862936bca2ca',
132+
truncatedPublicKey: '0106...a2ca'
132133
};
133134

134135
export const URLS = {

e2e-tests/fixtures.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,9 +277,16 @@ export const popup = test.extend<{
277277
connectAccounts: async ({ page, unlockVault, context }, use) => {
278278
const connectAccounts = async () => {
279279
await page.goto(PLAYGROUND_URL);
280+
await page.waitForLoadState('networkidle');
281+
// Wait for the extension content script to inject
282+
await page.waitForFunction(
283+
() => typeof (window as any).CasperWalletProvider !== 'undefined',
284+
null,
285+
{ timeout: 10000 }
286+
);
280287

281288
const [connectAccountPage] = await Promise.all([
282-
context.waitForEvent('page'),
289+
context.waitForEvent('page', { timeout: 15000 }),
283290
page.getByRole('button', { name: 'Connect', exact: true }).click()
284291
]);
285292

e2e-tests/onboarding-flow/confirm-secret-phrase-flow.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ onboarding.describe('Onboarding UI: confirm secret phrase flow', () => {
4040
await page.getByText('No NFT tokens')
4141
).toBeVisible();
4242

43-
await page.getByText('Deploys').click();
43+
await page.getByText('Activity').click();
4444

4545
await onboardingExpect(await page.getByText('No activity')).toBeVisible();
4646
}

e2e-tests/popup/buy-cspr/buy-cspr.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,9 @@ popup.describe('Popup UI: buy cspr', () => {
9999

100100
await popupPage
101101
.getByPlaceholder('Search', { exact: true })
102-
.fill('Ukraine');
102+
.fill('Poland');
103103

104-
await popupPage.getByText('Ukraine').click();
104+
await popupPage.getByText('Poland').click();
105105

106106
// wait until a modal window closed
107107
await new Promise(r => setTimeout(r, 2000));

e2e-tests/popup/connect-account/connect-account.spec.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,15 @@ popup.describe('Popup UI: connect account', () => {
88

99
popup.beforeEach(async ({ page, context, unlockVault }) => {
1010
await page.goto(PLAYGROUND_URL);
11+
await page.waitForLoadState('networkidle');
12+
await page.waitForFunction(
13+
() => typeof (window as any).CasperWalletProvider !== 'undefined',
14+
null,
15+
{ timeout: 10000 }
16+
);
1117

1218
[connectAccountPage] = await Promise.all([
13-
context.waitForEvent('page'),
19+
context.waitForEvent('page', { timeout: 15000 }),
1420
page.getByRole('button', { name: 'Connect', exact: true }).click()
1521
]);
1622

e2e-tests/popup/contacts/contacts.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ popup.describe('Popup UI: contacts', () => {
116116

117117
await popupExpect(
118118
popupPage.getByText(
119-
'You’ve already got a contact with this name. Please find a new name for this one'
119+
'You’ve already got an account / contact with this name. Please find a new name for this one'
120120
)
121121
).toBeVisible();
122122
await popupExpect(

e2e-tests/popup/signature-request-scenarios/signature-request-scenarios.spec.ts

Lines changed: 39 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
11
import {
22
DEFAULT_FIRST_ACCOUNT,
3-
NEW_VALIDATOR_FOR_SIGNATURE_REQUEST,
43
PLAYGROUND_URL,
54
VALIDATOR_FOR_SIGNATURE_REQUEST
65
} from '../../constants';
76
import { popup, popupExpect } from '../../fixtures';
87

8+
const waitForContentScript = async (page: any) => {
9+
await page.waitForLoadState('networkidle');
10+
await page.waitForFunction(
11+
() => typeof (window as any).CasperWalletProvider !== 'undefined',
12+
null,
13+
{ timeout: 10000 }
14+
);
15+
};
16+
917
popup.describe('Popup UI: signature request scenarios', () => {
1018
popup.beforeEach(async ({ connectAccounts, page }) => {
1119
await connectAccounts();
@@ -15,34 +23,24 @@ popup.describe('Popup UI: signature request scenarios', () => {
1523

1624
popup('should signing the transfer deploy', async ({ page, context }) => {
1725
await page.goto(PLAYGROUND_URL);
26+
await waitForContentScript(page);
1827

1928
const [signatureRequestPage] = await Promise.all([
20-
context.waitForEvent('page'),
29+
context.waitForEvent('page', { timeout: 15000 }),
2130
page.getByRole('button', { name: 'Transfer' }).first().click()
2231
]);
2332

33+
await page.waitForTimeout(2000);
34+
2435
await popupExpect(
2536
signatureRequestPage.getByRole('heading', { name: 'Signature Request' })
2637
).toBeVisible();
2738

28-
await signatureRequestPage.getByText('Transfer Data').click();
29-
30-
await popupExpect(
31-
signatureRequestPage.getByText('Transfer Call')
32-
).toBeVisible();
39+
await popupExpect(signatureRequestPage.getByText('Transfer')).toBeVisible();
3340

41+
await popupExpect(signatureRequestPage.getByText('0.1 CSPR')).toBeVisible();
3442
await popupExpect(
35-
signatureRequestPage.getByText('Recipient (Key)')
36-
).toBeVisible();
37-
await popupExpect(
38-
signatureRequestPage.getByText(
39-
VALIDATOR_FOR_SIGNATURE_REQUEST.truncatedPublicKey
40-
)
41-
).toBeVisible();
42-
await popupExpect(signatureRequestPage.getByText('Amount')).toBeVisible();
43-
await popupExpect(signatureRequestPage.getByText('2.5 CSPR')).toBeVisible();
44-
await popupExpect(
45-
signatureRequestPage.getByText('Transfer ID')
43+
signatureRequestPage.getByText('Transaction ID')
4644
).toBeVisible();
4745
await popupExpect(signatureRequestPage.getByText('1234')).toBeVisible();
4846

@@ -56,45 +54,28 @@ popup.describe('Popup UI: signature request scenarios', () => {
5654

5755
popup('should signing the delegate deploy', async ({ page, context }) => {
5856
await page.goto(PLAYGROUND_URL);
59-
await page.waitForLoadState('networkidle');
57+
await waitForContentScript(page);
6058

6159
const [signatureRequestPage] = await Promise.all([
62-
context.waitForEvent('page'),
60+
context.waitForEvent('page', { timeout: 15000 }),
6361
page.getByRole('button', { name: 'Delegate', exact: true }).click()
6462
]);
6563

66-
await popupExpect(
67-
signatureRequestPage.getByRole('heading', { name: 'Signature Request' })
68-
).toBeVisible();
69-
70-
await signatureRequestPage.getByText('Contract arguments').click();
64+
await page.waitForTimeout(2000);
7165

7266
await popupExpect(
73-
signatureRequestPage.getByText('Contract Call')
67+
signatureRequestPage.getByRole('heading', { name: 'Signature Request' })
7468
).toBeVisible();
7569

76-
await popupExpect(signatureRequestPage.getByText('delegate')).toBeVisible();
70+
await popupExpect(signatureRequestPage.getByText('Delegate')).toBeVisible();
7771

78-
await popupExpect(
79-
signatureRequestPage.getByText('Delegator')
80-
).toBeVisible();
81-
await popupExpect(
82-
signatureRequestPage
83-
.getByText(DEFAULT_FIRST_ACCOUNT.truncatedPublicKey)
84-
.nth(2)
85-
).toBeVisible();
86-
await popupExpect(
87-
signatureRequestPage.getByText(VALIDATOR_FOR_SIGNATURE_REQUEST.name)
88-
).toBeVisible();
8972
await popupExpect(
9073
signatureRequestPage.getByText(
9174
VALIDATOR_FOR_SIGNATURE_REQUEST.truncatedPublicKey
9275
)
9376
).toBeVisible();
94-
await popupExpect(signatureRequestPage.getByText('Amount')).toBeVisible();
95-
await popupExpect(
96-
signatureRequestPage.getByText('2.5 CSPR').nth(1)
97-
).toBeVisible();
77+
78+
await popupExpect(signatureRequestPage.getByText('2.5 CSPR')).toBeVisible();
9879

9980
page.on('dialog', async dialog => {
10081
popupExpect(dialog.message()).toContain('Sign successful');
@@ -106,48 +87,31 @@ popup.describe('Popup UI: signature request scenarios', () => {
10687

10788
popup('should signing the undelegate deploy', async ({ page, context }) => {
10889
await page.goto(PLAYGROUND_URL);
109-
await page.waitForLoadState('networkidle');
90+
await waitForContentScript(page);
11091

11192
const [signatureRequestPage] = await Promise.all([
112-
context.waitForEvent('page'),
93+
context.waitForEvent('page', { timeout: 15000 }),
11394
page.getByRole('button', { name: 'Undelegate', exact: true }).click()
11495
]);
11596

116-
await popupExpect(
117-
signatureRequestPage.getByRole('heading', { name: 'Signature Request' })
118-
).toBeVisible();
119-
120-
await signatureRequestPage.getByText('Contract arguments').click();
97+
await page.waitForTimeout(2000);
12198

12299
await popupExpect(
123-
signatureRequestPage.getByText('Contract Call')
100+
signatureRequestPage.getByRole('heading', { name: 'Signature Request' })
124101
).toBeVisible();
125102

126103
await popupExpect(
127-
signatureRequestPage.getByText('undelegate')
104+
signatureRequestPage.getByText('Undelegate')
128105
).toBeVisible();
129106

130-
await popupExpect(
131-
signatureRequestPage.getByText('Delegator')
132-
).toBeVisible();
133107
await popupExpect(
134108
signatureRequestPage
135109
.getByText(DEFAULT_FIRST_ACCOUNT.truncatedPublicKey)
136-
.nth(2)
137-
).toBeVisible();
138-
await popupExpect(
139-
signatureRequestPage.getByText(VALIDATOR_FOR_SIGNATURE_REQUEST.name)
140-
).toBeVisible();
141-
await popupExpect(
142-
signatureRequestPage.getByText(
143-
VALIDATOR_FOR_SIGNATURE_REQUEST.truncatedPublicKey
144-
)
145-
).toBeVisible();
146-
await popupExpect(signatureRequestPage.getByText('Amount')).toBeVisible();
147-
await popupExpect(
148-
signatureRequestPage.getByText('2.5 CSPR').first()
110+
.first()
149111
).toBeVisible();
150112

113+
await popupExpect(signatureRequestPage.getByText('2.5 CSPR')).toBeVisible();
114+
151115
page.on('dialog', async dialog => {
152116
popupExpect(dialog.message()).toContain('Sign successful');
153117
await dialog.accept();
@@ -158,57 +122,24 @@ popup.describe('Popup UI: signature request scenarios', () => {
158122

159123
popup('should signing the redelegate deploy', async ({ page, context }) => {
160124
await page.goto(PLAYGROUND_URL);
161-
await page.waitForLoadState('networkidle');
125+
await waitForContentScript(page);
162126

163127
const [signatureRequestPage] = await Promise.all([
164-
context.waitForEvent('page'),
128+
context.waitForEvent('page', { timeout: 15000 }),
165129
page.getByRole('button', { name: 'Redelegate', exact: true }).click()
166130
]);
167131

168-
await popupExpect(
169-
signatureRequestPage.getByRole('heading', { name: 'Signature Request' })
170-
).toBeVisible();
171-
172-
await signatureRequestPage.getByText('Contract arguments').click();
132+
await page.waitForTimeout(2000);
173133

174134
await popupExpect(
175-
signatureRequestPage.getByText('Contract Call')
135+
signatureRequestPage.getByRole('heading', { name: 'Signature Request' })
176136
).toBeVisible();
177137

178138
await popupExpect(
179-
signatureRequestPage.getByText('redelegate')
139+
signatureRequestPage.getByText('Redelegate')
180140
).toBeVisible();
181141

182-
await popupExpect(
183-
signatureRequestPage.getByText('Delegator')
184-
).toBeVisible();
185-
await popupExpect(
186-
signatureRequestPage
187-
.getByText(DEFAULT_FIRST_ACCOUNT.truncatedPublicKey)
188-
.nth(2)
189-
).toBeVisible();
190-
await popupExpect(
191-
signatureRequestPage.getByText(VALIDATOR_FOR_SIGNATURE_REQUEST.name, {
192-
exact: true
193-
})
194-
).toBeVisible();
195-
await popupExpect(
196-
signatureRequestPage.getByText(
197-
VALIDATOR_FOR_SIGNATURE_REQUEST.truncatedPublicKey
198-
)
199-
).toBeVisible();
200-
await popupExpect(signatureRequestPage.getByText('Amount')).toBeVisible();
201-
await popupExpect(
202-
signatureRequestPage.getByText('2.5 CSPR').first()
203-
).toBeVisible();
204-
await popupExpect(
205-
signatureRequestPage.getByText(NEW_VALIDATOR_FOR_SIGNATURE_REQUEST.name)
206-
).toBeVisible();
207-
await popupExpect(
208-
signatureRequestPage.getByText(
209-
NEW_VALIDATOR_FOR_SIGNATURE_REQUEST.truncatedPublicKey
210-
)
211-
).toBeVisible();
142+
await popupExpect(signatureRequestPage.getByText('2.5 CSPR')).toBeVisible();
212143

213144
page.on('dialog', async dialog => {
214145
popupExpect(dialog.message()).toContain('Sign successful');
@@ -220,11 +151,10 @@ popup.describe('Popup UI: signature request scenarios', () => {
220151

221152
popup('should cancel the signing process', async ({ page, context }) => {
222153
await page.goto(PLAYGROUND_URL);
223-
await page.waitForLoadState('networkidle');
224-
await page.waitForTimeout(500);
154+
await waitForContentScript(page);
225155

226156
const [signatureRequestPage] = await Promise.all([
227-
context.waitForEvent('page'),
157+
context.waitForEvent('page', { timeout: 15000 }),
228158
page.getByRole('button', { name: 'Transfer' }).first().click()
229159
]);
230160
await signatureRequestPage.waitForLoadState('domcontentloaded');

e2e-tests/popup/transfers/nft-transfer.spec.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ popup.describe('Popup UI: NFT Transfer', () => {
1717

1818
await new Promise(r => setTimeout(r, 2000));
1919

20-
await popupPage.getByTestId('nft-token-card').click();
20+
await popupPage
21+
.getByTestId('nft-token-card')
22+
.filter({ hasText: 'west' })
23+
.click();
2124

2225
await popupExpect(
2326
popupPage.getByRole('heading', { name: 'west' })

0 commit comments

Comments
 (0)