Skip to content

Commit

Permalink
fix: e2e
Browse files Browse the repository at this point in the history
  • Loading branch information
sidmorizon committed Dec 25, 2024
1 parent 01345ee commit 220b81f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
20 changes: 12 additions & 8 deletions packages/e2e/tests/connectButton/universal.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,15 @@ test.describe('Connect Button Hack', () => {
} = site;
for (const url of testUrls || urls) {
testCounter++;
test(`${url} (${sitesConfig.findIndex((e) => e.urls.includes(url))}-${testCounter})`, async ({ page }, testInfo) => {
const index = sitesConfig.findIndex((e) => (e.testUrls || e.urls).includes(url));

test(`${url} (${index}-${testCounter})`, async ({ page }, testInfo) => {
const { project: { name }, } = testInfo;
const index = sitesConfig.findIndex((e) => e.urls.includes(url));
// @ts-ignore
testInfo['index'] = index;
testInfo['siteIndex'] = index;
// @ts-ignore
testInfo['siteUrl'] = url;

const device = name.includes('Mobile') ? 'mobile' : 'desktop';
if (typeof skip === 'object' && skip !== null && skip[device] === true) {
return;
Expand Down Expand Up @@ -104,18 +108,18 @@ test.describe('Connect Button Hack', () => {
}
}
//@ts-ignore
test.afterEach(async ({ page }, { project: { name }, status, index }) => {
test.afterEach(async ({ page }, { project: { name }, status, siteIndex, siteUrl }) => {
const isMobile = name.includes('Mobile');
const url = page.url() || 'unknown-url';
let hostname = url;
// const url = page.url() || 'unknown-url';
let hostname = siteUrl as string;
try {
hostname = new URL(url).hostname;
hostname = new URL(siteUrl as string).hostname;
} catch (error) {
console.error('Failed to parse URL:', error);
}

// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
const screenshotPath = `test-results/screenshots/connectButton/universal/${status}/${index}-${hostname}-${isMobile ? 'mobile' : 'desktop'}-${status}.png`
const screenshotPath = `test-results/screenshots/connectButton/universal/${status}/${siteIndex}-${hostname}-${isMobile ? 'mobile' : 'desktop'}-${status}.png`

await page.screenshot({
path: screenshotPath,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,8 @@ export type WalletInfo = {
skip?: boolean | ((page: Page) => Promise<boolean>) | { mobile?: boolean; desktop?: boolean };
};
export type SitesInfo = {
urls: string[];
urls: string[]; // www.ankr.com
testUrls?: string[]; // url for e2e testing, like: www.ankr.com/staking/stake/
walletsForProvider: {
[k in IInjectedProviderNames]?: WalletInfo[];
};
Expand All @@ -170,7 +171,6 @@ export type SitesInfo = {
* path for connect wallet modal used for testing
*/
testPath?: string[] | { mobile?: string[]; desktop?: string[] } | ((page: Page) => Promise<void>);
testUrls?: string[];
only?: boolean;
skip?: boolean | { mobile?: boolean; desktop?: boolean };
};
Expand Down

0 comments on commit 220b81f

Please sign in to comment.