Skip to content

Commit

Permalink
fix: wait for account change
Browse files Browse the repository at this point in the history
  • Loading branch information
arthurgeron committed Nov 11, 2024
1 parent 47a1b69 commit d3828b0
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions packages/app/playwright/crx/crx.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -873,20 +873,19 @@ test.describe('FuelWallet Extension', () => {
// delay to avoid the page to listen the event from above swithAccount wrong event
await delay(1000);

const onChangeAccountPromise = blankPage.evaluate(() => {
// Watch for result
const currentAccountEventResult = blankPage.evaluate(() => {
return new Promise((resolve) => {
window.fuel.on(window.fuel.events.currentAccount, (account) => {
resolve(account);
});
});
});

// Switch to account 1
const currentAccount = await switchAccount(popupPage, 'Account 1');

// Check result
const currentAccountEventResult = await onChangeAccountPromise;
expect(currentAccountEventResult).toEqual(currentAccount.address);
expect(await currentAccountEventResult).toEqual(currentAccount.address);
});

await test.step('window.fuel.on("currentAccount") should be null when not connected', async () => {
Expand Down

0 comments on commit d3828b0

Please sign in to comment.