Skip to content

Commit 716e96d

Browse files
committed
adding failed test due to no funds
1 parent 6f7964f commit 716e96d

File tree

2 files changed

+45
-1
lines changed

2 files changed

+45
-1
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+
// Get the first default wallet address from Anvil (0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266)
23+
const walletAddress = (await node.getAccounts())[0];
24+
console.log('[test] Using default Anvil wallet address:', walletAddress);
25+
26+
// Set wallet balance to 0 using the node fixture
27+
await node.setBalance(walletAddress, 0n);
28+
console.log('[test] Set wallet balance to 0');
29+
30+
// Common preparation steps
31+
const { mainPage } = await prepareBasenameFlow(page, metamask);
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+
});

0 commit comments

Comments
 (0)