From 65d5cf319452faffa8296fb46688c5888af79fc9 Mon Sep 17 00:00:00 2001 From: kyranjamie Date: Fri, 6 Dec 2024 15:54:33 +0100 Subject: [PATCH] test: fix broken tests --- .../pages/legacy-account-auth/legacy-account-auth.tsx | 10 +++++----- tests/specs/profile/profile.spec.ts | 5 ++++- tests/specs/transactions/transactions.spec.ts | 8 ++++++-- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/app/pages/legacy-account-auth/legacy-account-auth.tsx b/src/app/pages/legacy-account-auth/legacy-account-auth.tsx index e8bc5a52043..e3a84105f7b 100644 --- a/src/app/pages/legacy-account-auth/legacy-account-auth.tsx +++ b/src/app/pages/legacy-account-auth/legacy-account-auth.tsx @@ -1,9 +1,9 @@ import { closeWindow } from '@shared/utils'; -// import { useCancelAuthRequest } from '@app/common/authentication/use-cancel-auth-request'; +import { useCancelAuthRequest } from '@app/common/authentication/use-cancel-auth-request'; import { useFinishAuthRequest } from '@app/common/authentication/use-finish-auth-request'; import { useAppDetails } from '@app/common/hooks/auth/use-app-details'; -// import { useOnMount } from '@app/common/hooks/use-on-mount'; +import { useOnMount } from '@app/common/hooks/use-on-mount'; import { useSwitchAccountSheet } from '@app/common/switch-account/use-switch-account-sheet-context'; import { openInNewTab } from '@app/common/utils/open-in-new-tab'; import { CurrentAccountDisplayer } from '@app/features/current-account/current-account-displayer'; @@ -20,10 +20,10 @@ export function LegacyAccountAuth() { useOnOriginTabClose(() => closeWindow()); - // const cancelAuthentication = useCancelAuthRequest(); + const cancelAuthentication = useCancelAuthRequest(); - // const handleUnmount = async () => cancelAuthentication(); - // useOnMount(() => window.addEventListener('beforeunload', handleUnmount)); + const handleUnmount = async () => cancelAuthentication(); + useOnMount(() => window.addEventListener('beforeunload', handleUnmount)); if (!url) throw new Error('No app details found'); diff --git a/tests/specs/profile/profile.spec.ts b/tests/specs/profile/profile.spec.ts index a34578f2e2d..ac9637ceb21 100644 --- a/tests/specs/profile/profile.spec.ts +++ b/tests/specs/profile/profile.spec.ts @@ -3,6 +3,8 @@ import { TestAppPage } from '@tests/page-object-models/test-app.page'; import { UpdateProfileRequestPage } from '@tests/page-object-models/update-profile-request.page'; import { OnboardingSelectors } from '@tests/selectors/onboarding.selectors'; +import { delay } from '@leather.io/utils'; + import { test } from '../../fixtures/fixtures'; test.describe.configure({ mode: 'serial' }); @@ -20,7 +22,8 @@ test.describe('Profile updating', () => { const newPagePromise = context.waitForEvent('page'); await testAppPage.page.getByTestId(OnboardingSelectors.SignUpBtn).click(); const accountsPage = await newPagePromise; - await accountsPage.getByTestId('switch-account-item-0').click({ force: true }); + await delay(1000); + await accountsPage.getByRole('button').getByText('Confirm').click({ force: true }); await testAppPage.page.bringToFront(); await testAppPage.page.click('text=Profile', { timeout: 30000, diff --git a/tests/specs/transactions/transactions.spec.ts b/tests/specs/transactions/transactions.spec.ts index c2ecc7c52b9..e2e1118b005 100644 --- a/tests/specs/transactions/transactions.spec.ts +++ b/tests/specs/transactions/transactions.spec.ts @@ -3,10 +3,14 @@ import { TestAppPage } from '@tests/page-object-models/test-app.page'; import { TransactionRequestPage } from '@tests/page-object-models/transaction-request.page'; import { OnboardingSelectors } from '@tests/selectors/onboarding.selectors'; -import { delay, stxToMicroStx } from '@leather.io/utils'; +import { stxToMicroStx } from '@leather.io/utils'; + +import { createDelay } from '@shared/utils'; import { test } from '../../fixtures/fixtures'; +const delayAnimationDuration = createDelay(1200); + test.describe('Transaction signing', () => { let testAppPage: TestAppPage; @@ -50,8 +54,8 @@ test.describe('Transaction signing', () => { const newPagePromise = context.waitForEvent('page'); await testAppPage.page.getByTestId(OnboardingSelectors.SignUpBtn).click(); const accountsPage = await newPagePromise; + await delayAnimationDuration(); await accountsPage.getByRole('button').getByText('Confirm').click({ force: true }); - await delay(2000); await testAppPage.page.bringToFront(); await testAppPage.page.click('text=Debugger', { timeout: 30000,