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): Migrated suite tests #16934

Merged
merged 1 commit into from
Feb 11, 2025
Merged

feat(e2e): Migrated suite tests #16934

merged 1 commit into from
Feb 11, 2025

Conversation

HajekOndrej
Copy link
Contributor

Description

Migrated the tests in suite subfolder, that were not related to passphrase.

Related Issue

Resolve

Screenshots:

Copy link

coderabbitai bot commented Feb 11, 2025

Walkthrough

The pull request introduces several updates across desktop and web packages. In the desktop core, new public properties and methods have been added to various classes to support interactions with additional UI elements, such as toggle switches, log buttons, guide-related elements, and safety check controls. Additionally, multiple end-to-end test suites have been created to validate functionality around the Bridge page, bug report forms, guide interactions, application initial run behavior, safety checks warnings, and version page verification. Conversely, corresponding test files in the web package have been removed, eliminating tests for similar functionalities in that environment. The changes include new test setup hooks to manage environment conditions—such as stopping emulators and resetting settings—and the introduction of assertions to ensure expected UI behavior and state management across the application.


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between f7333cf and 684d8ae.

📒 Files selected for processing (15)
  • packages/suite-desktop-core/e2e/support/pageActions/analyticsActions.ts (1 hunks)
  • packages/suite-desktop-core/e2e/support/pageActions/settings/settingsActions.ts (3 hunks)
  • packages/suite-desktop-core/e2e/support/pageActions/suiteGuideActions.ts (2 hunks)
  • packages/suite-desktop-core/e2e/tests/suite/bridge.test.ts (1 hunks)
  • packages/suite-desktop-core/e2e/tests/suite/bug-report-form.test.ts (1 hunks)
  • packages/suite-desktop-core/e2e/tests/suite/guide.test.ts (1 hunks)
  • packages/suite-desktop-core/e2e/tests/suite/initial-run.test.ts (1 hunks)
  • packages/suite-desktop-core/e2e/tests/suite/safety-checks-warning.test.ts (1 hunks)
  • packages/suite-desktop-core/e2e/tests/suite/version-page.test.ts (1 hunks)
  • packages/suite-web/e2e/tests/suite/bridge.test.ts (0 hunks)
  • packages/suite-web/e2e/tests/suite/bug-report-form.test.ts (0 hunks)
  • packages/suite-web/e2e/tests/suite/guide.test.ts (0 hunks)
  • packages/suite-web/e2e/tests/suite/initial-run.test.ts (0 hunks)
  • packages/suite-web/e2e/tests/suite/safety-checks-warning.test.ts (0 hunks)
  • packages/suite-web/e2e/tests/suite/version-page.test.ts (0 hunks)
💤 Files with no reviewable changes (6)
  • packages/suite-web/e2e/tests/suite/version-page.test.ts
  • packages/suite-web/e2e/tests/suite/guide.test.ts
  • packages/suite-web/e2e/tests/suite/bridge.test.ts
  • packages/suite-web/e2e/tests/suite/initial-run.test.ts
  • packages/suite-web/e2e/tests/suite/bug-report-form.test.ts
  • packages/suite-web/e2e/tests/suite/safety-checks-warning.test.ts
🚧 Files skipped from review as they are similar to previous changes (8)
  • packages/suite-desktop-core/e2e/support/pageActions/analyticsActions.ts
  • packages/suite-desktop-core/e2e/support/pageActions/settings/settingsActions.ts
  • packages/suite-desktop-core/e2e/tests/suite/bridge.test.ts
  • packages/suite-desktop-core/e2e/tests/suite/bug-report-form.test.ts
  • packages/suite-desktop-core/e2e/tests/suite/version-page.test.ts
  • packages/suite-desktop-core/e2e/support/pageActions/suiteGuideActions.ts
  • packages/suite-desktop-core/e2e/tests/suite/safety-checks-warning.test.ts
  • packages/suite-desktop-core/e2e/tests/suite/initial-run.test.ts
⏰ Context from checks skipped due to timeout of 90000ms (9)
  • GitHub Check: build-web
  • 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: Analyze with CodeQL (javascript)
  • GitHub Check: Setup and Cache Dependencies
  • GitHub Check: run-desktop-tests (@group=suite, trezor-user-env-unix)
🔇 Additional comments (2)
packages/suite-desktop-core/e2e/tests/suite/guide.test.ts (2)

1-8: LGTM! Well-structured test setup.

The test suite configuration follows best practices with proper test isolation, clear tagging, and appropriate test configuration.


46-63: LGTM! Well-structured test case.

The test is well-focused with a clear scope, proper setup, and appropriate assertions for testing the guide functionality during device onboarding.

✨ 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

@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: 1

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

10-18: Consider adding negative test cases.

While the happy path is covered, consider adding test cases for:

  • WebUSB not supported
  • Bridge installation required
packages/suite-desktop-core/e2e/tests/suite/version-page.test.ts (1)

12-17: Consider enhancing version verification.

The test verifies the version number display but could be enhanced:

  1. Verify other version page elements
  2. Add error cases (e.g., version mismatch)
  3. Consider removing or documenting the purpose of the screenshot
packages/suite-desktop-core/e2e/tests/suite/bug-report-form.test.ts (2)

8-11: Consider parameterizing test data.

The test data could be moved to a separate fixture or data provider to:

  1. Test multiple feedback categories
  2. Test various report content lengths

13-18: Add error handling test cases.

While the happy path is covered, consider adding test cases for:

  1. Empty report submission
  2. Network failures
  3. Rate limiting
packages/suite-desktop-core/e2e/tests/suite/initial-run.test.ts (2)

8-21: Improve test name clarity and coverage.

The test name "Until user passed through initial run, it will be there after reload" could be more descriptive. Consider renaming to better reflect the test's purpose of verifying analytics toggle visibility and persistence.

-    test('Until user passed through initial run, it will be there after reload', async ({
+    test('Analytics toggle remains visible after reload until user confirms choice', async ({

Additionally, consider adding a test to verify that the analytics toggle state (enabled/disabled) persists after reload.


23-32: Fix typo in test name.

The test name contains a typo: "trough" should be "through".

-    test('Once user passed trough, skips initial run and shows connect-device modal', async ({
+    test('Once user passed through, skips initial run and shows connect-device modal', async ({
packages/suite-desktop-core/e2e/tests/suite/safety-checks-warning.test.ts (2)

4-8: Consider improving test isolation.

The beforeEach hook modifies global state by completing onboarding and changing safety check levels. Consider resetting the state after each test to ensure test isolation.

Add an afterEach hook to reset safety checks to default:

test.afterEach(async ({ settingsPage }) => {
    await settingsPage.changeSafetyChecksLevel('strict'); // Reset to default
});

10-13: Add assertion for warning message content.

The test verifies the visibility of warning elements but doesn't check the actual warning message content.

Add an assertion to verify the warning message:

await expect(page.getByTestId('@banner/safety-checks/message')).toHaveText(/Safety checks are set to prompt/);
packages/suite-desktop-core/e2e/tests/suite/guide.test.ts (2)

24-27: Add error handling test for feedback form.

The feedback form is only tested for the success case. Consider adding tests for error scenarios.

Add test cases for:

  • Empty feedback submission
  • Network failure during submission
  • Rate limiting

37-42: Extract search test data to constants.

The search terms "trezor" and "meow-wuf-nonsense" are hardcoded. Consider extracting these to test constants for better maintainability.

const TEST_DATA = {
    VALID_SEARCH: 'trezor',
    INVALID_SEARCH: 'meow-wuf-nonsense'
} as const;
packages/suite-desktop-core/e2e/support/pageActions/suiteGuideActions.ts (2)

30-32: Add JSDoc comments for new properties.

The new properties lack documentation explaining their purpose and usage.

+    /** Locator for guide navigation nodes */
     readonly guideNodes: Locator;
+    /** Locator for guide section label */
     readonly guideLabel: Locator;
+    /** Locator for empty search results message */
     readonly searchNoResults: Locator;

71-78: Improve error handling in sendBugReport method.

The method should handle potential failures during bug report submission.

     @step()
     async sendBugReport(args: { location: FeedbackCategory; report: string }) {
+        try {
             await this.bugFormButton.click();
             await this.selectBugLocation(args.location);
             // stability necessity
             await this.page.waitForTimeout(250);
             await this.bugInputTextField.fill(args.report);
             await this.submitButton.click();
+            await expect(this.feedbackSuccessToast).toBeVisible({ timeout: 10000 });
+        } catch (error) {
+            throw new Error(`Failed to send bug report: ${error.message}`);
+        }
     }
packages/suite-desktop-core/e2e/support/pageActions/settings/settingsActions.ts (1)

206-214: Add error handling and success verification.

The method implementation is good but could be enhanced with:

  1. Error handling for device confirmation
  2. Success notification verification (similar to other methods)
  3. JSDoc documentation for better maintainability
+/**
+ * Changes the safety checks level on the device
+ * @param level - The safety checks level to set ('strict' or 'prompt')
+ * @throws {Error} If device confirmation fails
+ */
 @step()
 async changeSafetyChecksLevel(level: 'strict' | 'prompt') {
     await this.navigateTo('device');
     await this.page.getByTestId('@settings/device/safety-checks-button').click();
     await this.page.getByTestId(`@radio-button-${level}`).click();
     await this.page.getByTestId('@safety-checks-apply').click();
     await expect(this.confirmOnDevicePrompt).toBeVisible();
     await TrezorUserEnvLinkProxy.pressYes();
+    await this.confirmOnDevicePrompt.waitFor({ state: 'detached' });
+    await expect(this.notificationSuccessToast).toBeVisible();
 }
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 246db18 and f7333cf.

📒 Files selected for processing (15)
  • packages/suite-desktop-core/e2e/support/pageActions/analyticsActions.ts (1 hunks)
  • packages/suite-desktop-core/e2e/support/pageActions/settings/settingsActions.ts (3 hunks)
  • packages/suite-desktop-core/e2e/support/pageActions/suiteGuideActions.ts (2 hunks)
  • packages/suite-desktop-core/e2e/tests/suite/bridge.test.ts (1 hunks)
  • packages/suite-desktop-core/e2e/tests/suite/bug-report-form.test.ts (1 hunks)
  • packages/suite-desktop-core/e2e/tests/suite/guide.test.ts (1 hunks)
  • packages/suite-desktop-core/e2e/tests/suite/initial-run.test.ts (1 hunks)
  • packages/suite-desktop-core/e2e/tests/suite/safety-checks-warning.test.ts (1 hunks)
  • packages/suite-desktop-core/e2e/tests/suite/version-page.test.ts (1 hunks)
  • packages/suite-web/e2e/tests/suite/bridge.test.ts (0 hunks)
  • packages/suite-web/e2e/tests/suite/bug-report-form.test.ts (0 hunks)
  • packages/suite-web/e2e/tests/suite/guide.test.ts (0 hunks)
  • packages/suite-web/e2e/tests/suite/initial-run.test.ts (0 hunks)
  • packages/suite-web/e2e/tests/suite/safety-checks-warning.test.ts (0 hunks)
  • packages/suite-web/e2e/tests/suite/version-page.test.ts (0 hunks)
💤 Files with no reviewable changes (6)
  • packages/suite-web/e2e/tests/suite/bug-report-form.test.ts
  • packages/suite-web/e2e/tests/suite/safety-checks-warning.test.ts
  • packages/suite-web/e2e/tests/suite/version-page.test.ts
  • packages/suite-web/e2e/tests/suite/guide.test.ts
  • packages/suite-web/e2e/tests/suite/bridge.test.ts
  • packages/suite-web/e2e/tests/suite/initial-run.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: build-web
  • GitHub Check: run-desktop-tests (@group=device-management, trezor-user-env-unix)
  • GitHub Check: Analyze with CodeQL (javascript)
  • GitHub Check: Setup and Cache Dependencies
  • GitHub Check: run-desktop-tests (@group=suite, trezor-user-env-unix)
  • GitHub Check: build-web
🔇 Additional comments (3)
packages/suite-desktop-core/e2e/support/pageActions/analyticsActions.ts (1)

8-8: LGTM! Well-structured addition of the toggle switch locator.

The new toggleSwitch property follows the established patterns for test IDs and locator initialization.

Also applies to: 13-13

packages/suite-desktop-core/e2e/tests/suite/bridge.test.ts (1)

4-9: LGTM! Proper test setup with clean environment.

The beforeEach hook ensures a clean test environment by stopping both emulator and bridge.

packages/suite-desktop-core/e2e/support/pageActions/settings/settingsActions.ts (1)

69-69: LGTM!

The showLogButton property follows the established patterns for locator properties in the class, with consistent naming and test ID conventions.

Also applies to: 104-104

@HajekOndrej HajekOndrej merged commit 1516375 into develop Feb 11, 2025
29 checks passed
@HajekOndrej HajekOndrej deleted the migrate-suite branch February 11, 2025 17:15
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