Skip to content

Commit

Permalink
test: fix broken tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kyranjamie committed Dec 11, 2024
1 parent 5153b22 commit c525f91
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
10 changes: 5 additions & 5 deletions src/app/pages/legacy-account-auth/legacy-account-auth.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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');

Expand Down
8 changes: 7 additions & 1 deletion tests/specs/profile/profile.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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' });
Expand All @@ -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(2000);
await accountsPage.getByRole('button').getByText('Confirm').click({ force: true });
await testAppPage.page.bringToFront();
await testAppPage.page.click('text=Profile', {
timeout: 30000,
Expand Down Expand Up @@ -51,7 +54,10 @@ test.describe('Gaia profile request', () => {
const newPagePromise = context.waitForEvent('page');
await testAppPage.page.getByTestId(OnboardingSelectors.SignUpBtn).click();
const accountsPage = await newPagePromise;
await delay(2000);
await accountsPage.getByTestId('switch-account-item-0').click({ force: true });
await accountsPage.getByTestId('switch-account-item-1').click({ force: true });
await accountsPage.getByRole('button').getByText('Confirm').click({ force: true });
await testAppPage.page.bringToFront();
await testAppPage.page.click('text=Profile', {
timeout: 30000,
Expand Down
11 changes: 9 additions & 2 deletions tests/specs/transactions/transactions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(2000);

test.describe('Transaction signing', () => {
let testAppPage: TestAppPage;

Expand All @@ -28,7 +32,9 @@ test.describe('Transaction signing', () => {
const accountsPage = await newPagePromise;
await accountsPage.getByTestId('switch-account-item-0').click({ force: true });
await accountsPage.getByTestId('switch-account-item-1').click({ force: true });
await delayAnimationDuration();
await accountsPage.getByRole('button').getByText('Confirm').click({ force: true });
await delayAnimationDuration();
await testAppPage.page.bringToFront();
await testAppPage.page.click('text=Debugger', {
timeout: 30000,
Expand All @@ -50,8 +56,9 @@ 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 delayAnimationDuration();
await testAppPage.page.bringToFront();
await testAppPage.page.click('text=Debugger', {
timeout: 30000,
Expand Down

0 comments on commit c525f91

Please sign in to comment.