Skip to content

Commit

Permalink
fix testing - not found metamask window in assets-transactions-evm.sp…
Browse files Browse the repository at this point in the history
…ec.ts (#835)

* fix as not found metamask window

* extends timeout from 12s to 25s
  • Loading branch information
sirius651 committed Jun 20, 2023
1 parent c5d2413 commit ea8f8e7
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 13 deletions.
2 changes: 1 addition & 1 deletion tests/assets-transactions-evm.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ test.describe('account panel', () => {
await page.locator('.btn--account').click();
await page.locator('.wrapper--modal-drawer .modal-close').first().click();
await page.getByText('MetaMask').click();
await signInMetamask(context);
await signInMetamask(page, context);

//transfer test (from evm to native)
await page.goto('/custom-node/assets/transfer?token=astr&mode=local');
Expand Down
2 changes: 1 addition & 1 deletion tests/chopsticks/start-playwright.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ async function run(nodeName, networkInfo, args) {

// MEMO: for debugging specific test case
// result = await spawn(
// `BASE_URL=\'${args[0]}\' ENDPOINT=\'${endpoint}\' npx playwright test tests/assets-transactions.spec.ts --project=chromium --debug`
// `BASE_URL=\'${args[0]}\' ENDPOINT=\'${endpoint}\' npx playwright test tests/assets-transactions-evm.spec.ts --project=chromium --debug`
// );

return result?.includes('failed') ? 0 : 1;
Expand Down
21 changes: 12 additions & 9 deletions tests/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,18 @@ export const createMetamaskAccount = async (
await page.getByRole('button').nth(1).click();
};

export const signInMetamask = async (context: BrowserContext): Promise<void> => {
const extensionWindow = await getWindow('MetaMask', context);
await extensionWindow.waitForLoadState('load');
await extensionWindow.locator('data-testid=unlock-password').fill('Test1234');
await extensionWindow.locator('data-testid=unlock-submit').click();
await extensionWindow.locator('data-testid=onboarding-complete-done').click();
await extensionWindow.locator('data-testid=pin-extension-next').click();
await extensionWindow.locator('data-testid=pin-extension-done').click();
await extensionWindow.locator('data-testid=popover-close').click();
export const signInMetamask = async (page: Page, context: BrowserContext): Promise<void> => {
await page.goto(
'chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/home.html#onboarding/unlock'
);
// const extensionWindow = await getWindow('MetaMask', context);
await page.waitForLoadState('load');
await page.locator('data-testid=unlock-password').fill('Test1234');
await page.locator('data-testid=unlock-submit').click();
await page.locator('data-testid=onboarding-complete-done').click();
await page.locator('data-testid=pin-extension-next').click();
await page.locator('data-testid=pin-extension-done').click();
await page.locator('data-testid=popover-close').click();
};

export const connectWithEVM = async (page: Page, context: BrowserContext): Promise<void> => {
Expand Down
4 changes: 2 additions & 2 deletions tests/fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ export const getWindow = async (title: string, context: BrowserContext): Promise
return new Promise((resolve, reject) => {
context.on('page', async (target) => {
const pageTitle = await target.title();
// console.log('pageTitle', pageTitle);
console.log('pageTitle', pageTitle);
if (pageTitle === title) {
resolve(target);
}
});
setTimeout(() => {
reject(`${title} window not found.`);
}, 12000);
}, 25000);
});
};

0 comments on commit ea8f8e7

Please sign in to comment.