Skip to content

Commit

Permalink
refactor: enhance wallet notification handling in ForwardEth test suite
Browse files Browse the repository at this point in the history
  • Loading branch information
nelitow committed Jan 10, 2025
1 parent ccc0182 commit 1623c2c
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
hasText,
} from '@fuels/playwright-utils';
import { expect } from '@playwright/test';
import type { Page } from '@playwright/test';
import { bn } from 'fuels';
import type { WalletUnlocked } from 'fuels';

Expand All @@ -18,6 +19,7 @@ import {
checkAddresses,
checkAriaLabelsContainsText,
connect,
waitForWalletNotification,
waitSuccessTransaction,
} from './utils';

Expand Down Expand Up @@ -76,10 +78,8 @@ test.describe('Forward Eth', () => {
await page.waitForTimeout(10000);
console.log('✅ VM wait complete');

console.log('🔍 Getting wallet notification page...');
const walletNotificationPage =
await fuelWalletTestHelper.getWalletPopupPage();
console.log('✅ Wallet notification page ready');
await waitForWalletNotification(fuelWalletTestHelper);

console.log('🔍 Checking asset details...');
checkAriaLabelsContainsText(
Expand Down
38 changes: 37 additions & 1 deletion packages/e2e-contract-tests/playwright/e2e/utils/transaction.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { getByAriaLabel, hasText } from '@fuels/playwright-utils';
import type { FuelWalletTestHelper } from '@fuels/playwright-utils';
import type { Page } from '@playwright/test';
import { expect } from '@playwright/test';
import type { BN } from 'fuels';
Expand All @@ -15,5 +16,40 @@ export const checkFee = async (
};

export const waitSuccessTransaction = async (page: Page) => {
await hasText(page, 'Transaction successful.', 0, 15000);
await expect
.poll(
() =>
hasText(page, 'Transaction successful.')
.then(() => true)
.catch(() => false),
{ timeout: 15000 }
)
.toBeTruthy();
};

export async function waitForWalletNotification(
fuelWalletTestHelper: FuelWalletTestHelper
): Promise<Page> {
console.log('🔍 Getting wallet notification page...');
let walletNotificationPage: Page | null = null;
await expect
.poll(
async () => {
try {
walletNotificationPage =
await fuelWalletTestHelper.getWalletPopupPage();
return true;
} catch {
return false;
}
},
{ timeout: 30000, intervals: [5000] }
)
.toBeTruthy();

if (!walletNotificationPage) {
throw new Error('Failed to get wallet notification page');
}
console.log('✅ Wallet notification page ready');
return walletNotificationPage;
}

0 comments on commit 1623c2c

Please sign in to comment.