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

feat(e2e): Finished onboarding tests migration #16828

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from

Conversation

HajekOndrej
Copy link
Contributor

Description

Migrate the rest of Onboarding tests.
The mocked firmware update was not working in cypress, so I have decided to just create an issue for that: #16807

Related Issue

Resolve

Screenshots:

@HajekOndrej HajekOndrej requested a review from Vere-Grey February 4, 2025 17:52
Copy link

coderabbitai bot commented Feb 4, 2025

Walkthrough

This pull request introduces two new end-to-end test suites in the desktop core repository. The first suite, located in analytics-consent.test.ts, simulates the onboarding analytics consent flow by navigating to the /accounts route, verifying the visibility of the analytics consent screen, and interacting with various UI elements including continue and exit buttons. It also incorporates conditional checks for device authenticity and onboarding model validations. The second suite, located in transport.test.ts, focuses on the transport aspect by ensuring that the WebUSB option is prominently available on the web interface and that UI elements such as a collapsible box behave as expected. Additionally, the pull request removes several similar test files from the web repository, including tests for analytics consent, firmware updates, wallet creation for T3T1 devices, and transport, streamlining the overall test coverage.

Possibly related issues

  • E2E Test coverage for Firmware update #16807: The changes in this PR include the introduction of new test suites that may help address the need for comprehensive end-to-end test coverage for firmware updates, as mentioned in the issue.

Suggested labels

no-project

Suggested reviewers

  • mroz22
  • vdovhanych
✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Migrated previously, but was not deleted.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No working in Cypress - I have created a new issue to do this properly #16807

await analyticsPage.continueButton.click();
await expect(page.getByTestId('@webusb-button')).toBeVisible();
await page.getByTestId('@connect-device-prompt/no-device-detected').click();
await expect(page.getByTestId('@collapsible-box/body')).toHaveAttribute(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Seemed proper to add some checking

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (5)
packages/suite-desktop-core/e2e/tests/onboarding/transport.test.ts (2)

9-9: Make the test title more descriptive.

Consider renaming the test to better describe the complete test flow, e.g., "Should display webusb as primary choice and expand options when no device detected".


10-12: Add error handling for click actions.

Consider wrapping click actions in try-catch blocks to handle potential interaction failures gracefully.

-            await analyticsPage.continueButton.click();
-            await expect(page.getByTestId('@webusb-button')).toBeVisible();
-            await page.getByTestId('@connect-device-prompt/no-device-detected').click();
+            try {
+                await analyticsPage.continueButton.click();
+                await expect(page.getByTestId('@webusb-button')).toBeVisible();
+                await page.getByTestId('@connect-device-prompt/no-device-detected').click();
+            } catch (error) {
+                throw new Error(`Failed to interact with transport options: ${error.message}`);
+            }
packages/suite-desktop-core/e2e/tests/onboarding/analytics-consent.test.ts (3)

14-14: Improve test title formatting and clarity.

The current test title is verbose and uses sentence case. Consider using a more concise title in Title Case, e.g., "Should Show Analytics Consent When Visiting /accounts Route".


19-22: Consider parameterizing the route and adding more test cases.

The route is hardcoded and only tests the happy path. Consider:

  1. Parameterizing the route to test multiple entry points
  2. Adding test cases for analytics consent rejection

Example of parameterized test:

const routes = ['/accounts', '/settings', '/'] as const;
for (const route of routes) {
    test(`Should Show Analytics Consent When Visiting ${route} Route`, async ({
        page,
        analyticsPage,
        onboardingPage,
    }) => {
        page.goto(route);
        // ... rest of the test
    });
}

28-31: Consider adding timeout for visibility checks.

Add appropriate timeouts for visibility checks to handle potential delays in UI updates.

-            await expect(page.getByTestId('@suite-layout/body')).toBeVisible();
+            await expect(page.getByTestId('@suite-layout/body')).toBeVisible({ timeout: 5000 });
-            await page.getByTestId('@account-menu/btc/normal/0').click();
-            await expect(page.getByTestId('@wallet/menu/wallet-send')).toBeVisible();
+            await page.getByTestId('@account-menu/btc/normal/0').click();
+            await expect(page.getByTestId('@wallet/menu/wallet-send')).toBeVisible({ timeout: 5000 });
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 59d8906 and bc09b19.

📒 Files selected for processing (6)
  • packages/suite-desktop-core/e2e/tests/onboarding/analytics-consent.test.ts (1 hunks)
  • packages/suite-desktop-core/e2e/tests/onboarding/transport.test.ts (1 hunks)
  • packages/suite-web/e2e/tests/onboarding/analytics-consent.test.ts (0 hunks)
  • packages/suite-web/e2e/tests/onboarding/firmware-update.test.ts (0 hunks)
  • packages/suite-web/e2e/tests/onboarding/t3t1/t3t1-create-wallet.test.ts (0 hunks)
  • packages/suite-web/e2e/tests/onboarding/transport.test.ts (0 hunks)
💤 Files with no reviewable changes (4)
  • packages/suite-web/e2e/tests/onboarding/analytics-consent.test.ts
  • packages/suite-web/e2e/tests/onboarding/firmware-update.test.ts
  • packages/suite-web/e2e/tests/onboarding/transport.test.ts
  • packages/suite-web/e2e/tests/onboarding/t3t1/t3t1-create-wallet.test.ts
⏰ Context from checks skipped due to timeout of 90000ms (8)
  • GitHub Check: run-desktop-tests (@group=wallet, trezor-user-env-unix bitcoin-regtest)
  • GitHub Check: run-desktop-tests (@group=settings, trezor-user-env-unix bitcoin-regtest)
  • GitHub Check: run-desktop-tests (@group=device-management, trezor-user-env-unix)
  • GitHub Check: build-web
  • GitHub Check: run-desktop-tests (@group=suite, trezor-user-env-unix)
  • GitHub Check: build-web
  • GitHub Check: Setup and Cache Dependencies
  • GitHub Check: Analyze with CodeQL (javascript)
🔇 Additional comments (2)
packages/suite-desktop-core/e2e/tests/onboarding/transport.test.ts (1)

9-17: Consider adding more test coverage.

The test suite focuses only on the webusb option. Consider adding test cases for:

  • Bridge transport option
  • Error scenarios (e.g., webusb not supported)
  • Device connection timeout scenarios

Would you like me to help generate additional test cases to improve coverage?

packages/suite-desktop-core/e2e/tests/onboarding/analytics-consent.test.ts (1)

24-26: Add assertions for secure element check.

The secure element check lacks assertions to verify the check was successful.

 if (onboardingPage.isModelWithSecureElement()) {
     await onboardingPage.passThroughAuthenticityCheck();
+    await expect(page.getByTestId('@authenticity/success-screen')).toBeVisible();
 }


test.describe(
'Onboarding - transport webusb/bridge',
{ tag: ['@group=device-management', '@webOnly'] },
Copy link
Contributor

Choose a reason for hiding this comment

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

This one has the grouping problem too.

@HajekOndrej HajekOndrej force-pushed the migrate-onboarding branch 2 times, most recently from f2c1bd3 to 5d18350 Compare February 6, 2025 16:14
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
packages/suite-desktop-core/e2e/tests/onboarding/analytics-consent.test.ts (2)

11-11: Consider a more descriptive test title.

The current title "analytics consent appears on any route that is visited initially. this time /accounts" is verbose and could be more concise. Consider something like "analytics consent screen is shown when visiting /accounts route".


11-30: Add test coverage for analytics consent rejection.

The test only covers the happy path where the user accepts analytics consent. Consider adding another test case to verify the behavior when the user rejects analytics consent.

Would you like me to help generate a test case for the analytics consent rejection scenario?

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f2c1bd3 and 5d18350.

📒 Files selected for processing (2)
  • .github/workflows/test-suite-web-e2e-pw.yml (1 hunks)
  • packages/suite-desktop-core/e2e/tests/onboarding/analytics-consent.test.ts (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (13)
  • GitHub Check: Releases revision Checks
  • GitHub Check: Build libs for publishing
  • GitHub Check: Other Checks
  • GitHub Check: Unit Tests
  • GitHub Check: Linting and formatting
  • GitHub Check: Type Checking
  • GitHub Check: run-desktop-tests (@group=wallet, trezor-user-env-unix bitcoin-regtest)
  • GitHub Check: run-desktop-tests (@group=settings, trezor-user-env-unix bitcoin-regtest)
  • GitHub Check: run-desktop-tests (@group=device-management, trezor-user-env-unix)
  • GitHub Check: build-web
  • GitHub Check: build-web
  • GitHub Check: run-desktop-tests (@group=suite, trezor-user-env-unix)
  • GitHub Check: Analyze with CodeQL (javascript)
🔇 Additional comments (2)
packages/suite-desktop-core/e2e/tests/onboarding/analytics-consent.test.ts (1)

1-10: LGTM!

The test suite setup is well-structured with appropriate tags and necessary test preparation in the beforeEach hook.

.github/workflows/test-suite-web-e2e-pw.yml (1)

107-108: LGTM!

The addition of the device management test group to the matrix is correctly configured and aligns with the new test file.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
packages/suite-desktop-core/e2e/tests/onboarding/transport.test.ts (1)

15-23: Consider enhancing test robustness and clarity.

While the test flow is logical, consider these improvements:

  1. Add pre-condition assertions before clicking buttons
  2. Make the test name more descriptive about verifying collapsible box behavior

Example enhancement:

-        test('Offer webusb as primary choice on web', async ({ page, analyticsPage }) => {
+        test('Should expand collapsible box when no device detected', async ({ page, analyticsPage }) => {
+            await expect(analyticsPage.continueButton).toBeVisible();
             await analyticsPage.continueButton.click();
+
             await expect(page.getByTestId('@webusb-button')).toBeVisible();
+
+            await expect(page.getByTestId('@connect-device-prompt/no-device-detected')).toBeVisible();
             await page.getByTestId('@connect-device-prompt/no-device-detected').click();
+
             await expect(page.getByTestId('@collapsible-box/body')).toHaveAttribute(
                 'aria-expanded',
                 'true',
             );
         });
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b8e04c5 and 856bfa7.

📒 Files selected for processing (2)
  • packages/suite-desktop-core/e2e/tests/onboarding/analytics-consent.test.ts (1 hunks)
  • packages/suite-desktop-core/e2e/tests/onboarding/transport.test.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/suite-desktop-core/e2e/tests/onboarding/analytics-consent.test.ts
⏰ Context from checks skipped due to timeout of 90000ms (9)
  • GitHub Check: run-desktop-tests (@group=wallet, trezor-user-env-unix bitcoin-regtest)
  • GitHub Check: run-desktop-tests (@group=other, trezor-user-env-unix)
  • GitHub Check: run-desktop-tests (@group=settings, trezor-user-env-unix bitcoin-regtest)
  • GitHub Check: run-desktop-tests (@group=device-management, trezor-user-env-unix)
  • GitHub Check: build-web
  • GitHub Check: build-web
  • GitHub Check: Analyze with CodeQL (javascript)
  • GitHub Check: run-desktop-tests (@group=suite, trezor-user-env-unix)
  • GitHub Check: Setup and Cache Dependencies
🔇 Additional comments (3)
packages/suite-desktop-core/e2e/tests/onboarding/transport.test.ts (3)

1-8: LGTM!

The test suite is well-structured with appropriate tags and configuration for transport testing.


9-13: LGTM!

The beforeEach hook ensures a clean state by properly managing the bridge and emulator lifecycle.


25-29: LGTM!

The afterEach hook properly cleans up the bridge state after each test.

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.

2 participants