Skip to content

Commit

Permalink
test: bypass sign in step, faster
Browse files Browse the repository at this point in the history
  • Loading branch information
kyranjamie committed May 23, 2024
1 parent 632a32d commit 722d504
Showing 1 changed file with 31 additions and 13 deletions.
44 changes: 31 additions & 13 deletions tests/page-object-models/onboarding.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { OnboardingSelectors } from '@tests/selectors/onboarding.selectors';
import type { SupportedBlockchains } from '@shared/constants';
import { RouteUrls } from '@shared/route-urls';

import { test } from '../fixtures/fixtures';
import { createCounter } from '@app/common/utils/counter';

const TEST_ACCOUNT_SECRET_KEY = process.env.TEST_ACCOUNT_SECRET_KEY ?? '';

Expand Down Expand Up @@ -281,21 +281,39 @@ export class OnboardingPage {
* account
*/
async signInWithTestAccount(id: string) {
const isUnlockPage = async () => await this.page.getByText('Enter your password').isVisible();
while (!(await isUnlockPage())) {
const testAccountDerivedKey =
'd904f412b8d116540017c302f3f7033813c95902af5a067c7befcc34fa5e5290709f157f80548603a1e4f8edc2c0d5d7';

const isSignedIn = async () => {
const { encryptionKey } = await this.page.evaluate(async () =>
chrome.storage.session.get(['encryptionKey'])
);
const hasSessionKey = encryptionKey === testAccountDerivedKey;
const hasAssetsTab = this.page.getByText('Assets');
const hasActivityTab = this.page.getByText('Activity');

return hasSessionKey && hasAssetsTab && hasActivityTab;
};

const iterationCounter = createCounter();

do {
if (iterationCounter.getValue() > 5) throw new Error('Unable to initialised wallet state');

await this.page.evaluate(
async walletState => await chrome.storage.local.set({ 'persist:root': walletState }),
async walletState => chrome.storage.local.set({ 'persist:root': walletState }),
testSoftwareAccountDefaultWalletState
);
await this.page.goto(`chrome-extension://${id}/index.html`, {
waitUntil: 'networkidle',
});
}
await test.expect(this.page.getByText('Enter your password')).toBeVisible();
await this.page.getByRole('textbox').fill(TEST_PASSWORD);
await this.page.getByRole('button', { name: 'Continue' }).click();
await this.page.waitForURL('**' + RouteUrls.Home);
await this.page.locator('text="Account 1"').waitFor();

await this.page.evaluate(
async encryptionKey => chrome.storage.session.set({ encryptionKey }),
testAccountDerivedKey
);

await this.page.goto(`chrome-extension://${id}/index.html`, { waitUntil: 'networkidle' });

Check failure on line 313 in tests/page-object-models/onboarding.page.ts

View workflow job for this annotation

GitHub Actions / Shard 7 of 10

[chromium] › specs/rpc-stacks-transaction/transaction-signing.spec.ts:48:3 › Transaction signing › that transaction details are the same after signing multi-signature STX transfer

1) [chromium] › specs/rpc-stacks-transaction/transaction-signing.spec.ts:48:3 › Transaction signing › that transaction details are the same after signing multi-signature STX transfer Retry #1 ─────────────────────────────────────────────────────────────────────────────────────── Error: page.goto: Target page, context or browser has been closed Call log: - navigating to "chrome-extension://ecglnfnhimaihdkpolkogpngodkkjhdm/index.html", waiting until "networkidle" at page-object-models/onboarding.page.ts:313 311 | ); 312 | > 313 | await this.page.goto(`chrome-extension://${id}/index.html`, { waitUntil: 'networkidle' }); | ^ 314 | 315 | iterationCounter.increment(); 316 | } while (!(await isSignedIn())); at OnboardingPage.signInWithTestAccount (/home/runner/work/extension/extension/tests/page-object-models/onboarding.page.ts:313:23) at /home/runner/work/extension/extension/tests/specs/rpc-stacks-transaction/transaction-signing.spec.ts:16:5

Check failure on line 313 in tests/page-object-models/onboarding.page.ts

View workflow job for this annotation

GitHub Actions / Shard 8 of 10

[chromium] › specs/send/send-stx.spec.ts:27:3 › send stx: tests on testnet › that send max button sets available balance minus fee

1) [chromium] › specs/send/send-stx.spec.ts:27:3 › send stx: tests on testnet › that send max button sets available balance minus fee Retry #1 ─────────────────────────────────────────────────────────────────────────────────────── Error: page.goto: Target page, context or browser has been closed Call log: - navigating to "chrome-extension://ecglnfnhimaihdkpolkogpngodkkjhdm/index.html", waiting until "networkidle" at page-object-models/onboarding.page.ts:313 311 | ); 312 | > 313 | await this.page.goto(`chrome-extension://${id}/index.html`, { waitUntil: 'networkidle' }); | ^ 314 | 315 | iterationCounter.increment(); 316 | } while (!(await isSignedIn())); at OnboardingPage.signInWithTestAccount (/home/runner/work/extension/extension/tests/page-object-models/onboarding.page.ts:313:23) at /home/runner/work/extension/extension/tests/specs/send/send-stx.spec.ts:21:5

iterationCounter.increment();
} while (!(await isSignedIn()));
}

/**
Expand Down

0 comments on commit 722d504

Please sign in to comment.