From 1782026570c649d84f6f0f08053a7b0eea7dd5b1 Mon Sep 17 00:00:00 2001 From: tomiir Date: Wed, 22 May 2024 19:31:02 -0600 Subject: [PATCH] fix: smart account spec issues on disconnect. improve project regex --- apps/laboratory/package.json | 2 +- .../tests/shared/pages/ModalWalletPage.ts | 5 +++- apps/laboratory/tests/shared/utils/project.ts | 23 +++++++++++-------- ...-smart-account.spec.ts => siwe-sa.spec.ts} | 0 apps/laboratory/tests/smart-account.spec.ts | 3 ++- 5 files changed, 20 insertions(+), 13 deletions(-) rename apps/laboratory/tests/{siwe-smart-account.spec.ts => siwe-sa.spec.ts} (100%) diff --git a/apps/laboratory/package.json b/apps/laboratory/package.json index 7265c55341..c289cf6f63 100644 --- a/apps/laboratory/package.json +++ b/apps/laboratory/package.json @@ -15,7 +15,7 @@ "playwright:test:social": "playwright test --grep 'social.spec.ts'", "playwright:test:siwe": "playwright test --grep siwe.spec.ts", "playwright:test:siwe-email": "playwright test --grep siwe-email.spec.ts", - "playwright:test:siwe-sa": "playwright test --grep siwe-smart-account.spec.ts", + "playwright:test:siwe-sa": "playwright test --grep siwe-sa.spec.ts", "playwright:test:sa": "playwright test --grep smart-account.spec.ts", "playwright:test:canary": "playwright test --retries=0 --grep canary.spec.ts --project='Desktop Chrome/wagmi'", "playwright:debug": "npm run playwright:test -- --debug", diff --git a/apps/laboratory/tests/shared/pages/ModalWalletPage.ts b/apps/laboratory/tests/shared/pages/ModalWalletPage.ts index 584cd83fcd..a73aec4c23 100644 --- a/apps/laboratory/tests/shared/pages/ModalWalletPage.ts +++ b/apps/laboratory/tests/shared/pages/ModalWalletPage.ts @@ -22,7 +22,10 @@ export class ModalWalletPage extends ModalPage { } async togglePreferredAccountType() { - await this.page.getByTestId('account-toggle-preferred-account-type').click() + const toggleButton = this.page.getByTestId('account-toggle-preferred-account-type') + await expect(toggleButton, 'Toggle button should be visible').toBeVisible() + await expect(toggleButton, 'Toggle button should be enabled').toBeEnabled() + await toggleButton.click() } override async disconnect(): Promise { diff --git a/apps/laboratory/tests/shared/utils/project.ts b/apps/laboratory/tests/shared/utils/project.ts index 8b9cc0f896..da8d5bdfca 100644 --- a/apps/laboratory/tests/shared/utils/project.ts +++ b/apps/laboratory/tests/shared/utils/project.ts @@ -34,6 +34,12 @@ const braveOptions: UseOptions = { } } +const EMAIL_BASED_PLATFORM_REGEX = + /(?:email\.spec\.ts|smart-account\.spec\.ts|siwe-email\.spec\.ts|siwe-sa\.spec\.ts|social\.spec\.ts).*$/u + +const SOLANA_UNIMPLEMENTED_TESTS_REGEX = + /^(?!.*(?:email\.spec\.ts|siwe\.spec\.ts|canary\.spec\.ts|smart-account\.spec\.ts|social\.spec\.ts|siwe-sa\.spec\.ts|siwe-email\.spec\.ts)).*$/u + const customProjectProperties: CustomProjectProperties = { 'Desktop Chrome/ethers': { testIgnore: /(?:social\.spec\.ts).*$/u @@ -46,31 +52,28 @@ const customProjectProperties: CustomProjectProperties = { testIgnore: /(?:social\.spec\.ts).*$/u }, 'Desktop Brave/wagmi': { - testIgnore: - /(?:email\.spec\.ts|smart-account\.spec\.ts|siwe-email\.spec\.ts|siwe-smart-account\.spec\.ts|social\.spec\.ts).*$/u, + testIgnore: EMAIL_BASED_PLATFORM_REGEX, useOptions: braveOptions }, 'Desktop Chrome/wagmi': { - testIgnore: - /(?:email\.spec\.ts|smart-account\.spec\.ts|siwe-email\.spec\.ts|siwe-smart-account\.spec\.ts|social\.spec\.ts).*$/u + testIgnore: EMAIL_BASED_PLATFORM_REGEX }, 'Desktop Firefox/wagmi': { - testIgnore: - /(?:email\.spec\.ts|smart-account\.spec\.ts|siwe-email\.spec\.ts|siwe-smart-account\.spec\.ts|social\.spec\.ts).*$/u + testIgnore: EMAIL_BASED_PLATFORM_REGEX }, // Exclude social.spec.ts, email.spec.ts, siwe.spec.ts, and canary.spec.ts from solana, not yet implemented 'Desktop Chrome/solana': { - grep: /^(?!.*(?:email\.spec\.ts|siwe\.spec\.ts|canary\.spec\.ts|smart-account\.spec\.ts|social\.spec\.ts)).*$/u + grep: SOLANA_UNIMPLEMENTED_TESTS_REGEX }, 'Desktop Brave/solana': { useOptions: braveOptions, - grep: /^(?!.*(?:email\.spec\.ts|siwe\.spec\.ts|canary\.spec\.ts|smart-account\.spec\.ts|social\.spec\.ts)).*$/u + grep: SOLANA_UNIMPLEMENTED_TESTS_REGEX }, 'Desktop Firefox/solana': { - grep: /^(?!.*(?:email\.spec\.ts|siwe\.spec\.ts|canary\.spec\.ts|smart-account\.spec\.ts|social\.spec\.ts)).*$/u + grep: SOLANA_UNIMPLEMENTED_TESTS_REGEX }, 'Desktop Safari/solana': { - grep: /^(?!.*(?:email\.spec\.ts|siwe\.spec\.ts|canary\.spec\.ts|smart-account\.spec\.ts|social\.spec\.ts)).*$/u + grep: SOLANA_UNIMPLEMENTED_TESTS_REGEX } } diff --git a/apps/laboratory/tests/siwe-smart-account.spec.ts b/apps/laboratory/tests/siwe-sa.spec.ts similarity index 100% rename from apps/laboratory/tests/siwe-smart-account.spec.ts rename to apps/laboratory/tests/siwe-sa.spec.ts diff --git a/apps/laboratory/tests/smart-account.spec.ts b/apps/laboratory/tests/smart-account.spec.ts index b63454438d..ee8835b5a1 100644 --- a/apps/laboratory/tests/smart-account.spec.ts +++ b/apps/laboratory/tests/smart-account.spec.ts @@ -79,8 +79,9 @@ testModalSmartAccount( await walletModalPage.openAccount() await walletModalPage.openSettings() await walletModalPage.togglePreferredAccountType() + await walletModalValidator.expectChangePreferredAccountToShow(EOA) await walletModalPage.disconnect() - await walletModalPage.page.waitForTimeout(500) + await walletModalPage.page.waitForTimeout(1000) await walletModalPage.emailFlow( email.getEmailAddressToUse(parallelIndex, NOT_ENABLED_DOMAIN),