Skip to content

Commit 3871f74

Browse files
committed
adding failed test due to no funds
1 parent 6f7964f commit 3871f74

File tree

3 files changed

+46
-2
lines changed

3 files changed

+46
-2
lines changed

.github/workflows/e2e-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,4 @@ jobs:
5454
run: yarn build
5555

5656
- name: Run E2E tests
57-
run: xvfb-run --auto-servernum --server-args="-screen 0 1920x1080x24" yarn test:e2e
57+
run: xvfb-run --auto-servernum --server-args="-screen 0 1920x1080x24" yarn test:e2e registration-failed.spec.ts
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import { test } from '../testFixture';
2+
import { expect } from '@playwright/test';
3+
import { prepareBasenameFlow, handleTransaction } from '../appSession';
4+
import { initiateRegistration } from '../basenameHelpers';
5+
import { ActionApprovalType } from '@coinbase/onchaintestkit';
6+
7+
test.describe('Basename Registration', () => {
8+
test('should fail registration when wallet has insufficient funds', async ({
9+
page,
10+
metamask,
11+
node,
12+
}) => {
13+
// Validate prerequisites
14+
if (!metamask) {
15+
throw new Error('MetaMask is not defined');
16+
}
17+
18+
if (!node) {
19+
throw new Error('Node fixture is not defined');
20+
}
21+
22+
// Common preparation steps (wallet needs funds to connect)
23+
const { mainPage } = await prepareBasenameFlow(page, metamask);
24+
25+
// Get the first default wallet address from Anvil (0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266)
26+
const walletAddress = (await node.getAccounts())[0];
27+
console.log('[test] Using default Anvil wallet address:', walletAddress);
28+
29+
// NOW set wallet balance to 0 after connection is established
30+
await node.setBalance(walletAddress, 0n);
31+
console.log('[test] Set wallet balance to 0');
32+
33+
// Attempt registration with no funds
34+
await initiateRegistration(mainPage);
35+
await page.waitForLoadState('networkidle');
36+
37+
// Approve the transaction (it should fail due to insufficient funds)
38+
await handleTransaction(metamask, ActionApprovalType.APPROVE);
39+
await page.waitForLoadState('networkidle');
40+
41+
// Look for failure message
42+
await expect(page.getByText(/failed|rejected|insufficient/i)).toBeVisible({ timeout: 30000 });
43+
});
44+
});

apps/web/playwright.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ export default defineConfig({
9090
webServer: {
9191
command: 'cd ../.. && yarn workspace @app/web dev',
9292
url: baseURL,
93-
timeout: 60 * 1000,
93+
timeout: 120 * 1000,
9494
reuseExistingServer: !process.env.CI,
9595
},
9696
});

0 commit comments

Comments
 (0)