Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

e2e tests (playwright) #594

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

e2e tests (playwright) #594

wants to merge 3 commits into from

Conversation

vyorkin
Copy link
Contributor

@vyorkin vyorkin commented Aug 19, 2024

No description provided.

@vyorkin vyorkin self-assigned this Aug 19, 2024
@vyorkin vyorkin force-pushed the feature/e2e-playwright branch 2 times, most recently from 4612e7b to b2cfd0a Compare January 27, 2025 09:52
Copy link

github-actions bot commented Jan 27, 2025

📦 build.zip [updated at Feb 17, 5:19:57 PM UTC]

@vyorkin vyorkin marked this pull request as ready for review January 28, 2025 15:51
src/ui/index.tsx Outdated
@@ -70,7 +70,11 @@ async function initializeUI({
try {
await registerServiceWorker();
initializeChannels();
await maybeOpenOnboarding();

if (process.env.NODE_ENV !== 'test') {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure that we need such checks in the code. Or this will create a different behaviour between prod build and test run. May be it is better to provide a predefined config for test like we have some wallets in it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I noticed that it doesn't affect that single test, so I just removed this condition

// Retry on CI only
retries: process.env.CI ? 2 : 0,
// Opt out of parallel tests on CI
workers: process.env.CI ? 1 : undefined,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does this aligns with fullyParallel: true?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as I understand:
fullyParallel: true enables parallel tests inside a single file
workers: process.env.CI ? 1 : undefined ensures only one file runs at a time in CI.
so it kinda limits file-level concurrency in CI but keeps parallelism within file

- name: Run Playwright tests
run: xvfb-run npx playwright test

- name: Upload Playwright report
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this part work?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I renamed the folder to e2e-report

e2e/test.ts Outdated
});
}

export async function takeScreenshot(page: Page, screenshotPath: string) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function is not used anywhere. Do we need it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't added an example that takes screenshots yet so probably yes it's better to remove it for now

@vyorkin vyorkin force-pushed the feature/e2e-playwright branch from 8ad2784 to 40fa30f Compare February 13, 2025 12:00
Comment on lines +4 to +7
export function generateRandomRecoveryPhrase() {
const entropy = randomBytes(16);
return entropyToMnemonic(entropy);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about

import { Wallet as EthersV5Wallet } from '@ethersproject/wallet';

export function generateRandomRecoveryPhrase() {
  return EthersV5Wallet.createRandom().mnemonic.phrase;
}

Is this the same?

return entropyToMnemonic(entropy);
}

export function generateRandomWallet() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should conform to wallets that are being created in src/shared/wallet/create.ts:

Suggested change
export function generateRandomWallet() {
export function generateRandomWallet(): BareWallet {

@@ -0,0 +1,15 @@
import { entropyToMnemonic } from '@ethersproject/hdnode';
import { Wallet, randomBytes } from 'ethers';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

prefer Wallet from '@ethersproject/wallet'?

@vyorkin vyorkin force-pushed the feature/e2e-playwright branch from 82de783 to f6b4e3f Compare February 17, 2025 14:55
@vyorkin vyorkin force-pushed the feature/e2e-playwright branch from f6b4e3f to e523f5b Compare February 17, 2025 14:59
Comment on lines +17 to +21
test('custom padding', () => {
const address = '0x7358B726830A2E222f9b139E90483A37142bcBE5';
const expected = `0x7358${ellipsis}cBE5`;
expect(truncateAddress(address, 4)).toBe(expected);
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's test at least two different padding values?

Comment on lines 140 to 144
// Determine headless mode:
// - in CI: always run headless
// - in dev: use RUN_HEADED_IN_DEV value unless overridden by testConfig
const headless =
!process.env.CI && (testConfig?.headless ?? !RUN_HEADED_IN_DEV);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Contradicts comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants