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

test(e2e): add guide UI e2e test #70

Merged
merged 1 commit into from
Sep 29, 2024
Merged

test(e2e): add guide UI e2e test #70

merged 1 commit into from
Sep 29, 2024

Conversation

zzcr
Copy link
Member

@zzcr zzcr commented Sep 29, 2024

PR

PR Checklist

Please check if your PR fulfills the following requirements:

  • The commit message follows our Commit Message Guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

What is the current behavior?

Issue Number: N/A

What is the new behavior?

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

Summary by CodeRabbit

  • Tests
    • Introduced a new test suite for the guide component, focusing on the xdesign specifications.
    • Implemented end-to-end tests that verify the default UI functionality and various interactions within the guide.

@github-actions github-actions bot added the e2e playwright label Sep 29, 2024
Copy link

coderabbitai bot commented Sep 29, 2024

Walkthrough

A new test suite has been added for the guide component, focusing on the xdesign specifications. This suite employs Playwright for end-to-end testing and includes tests for the default UI screenshot functionality. It verifies user interactions with the guide, capturing screenshots for visual validation of the guide element, the close button, and the "下一步" button during hover states.

Changes

File Change Summary
tests/guide/xdesign.spec.ts Introduced a new test suite for the guide component using Playwright, including tests for UI screenshot functionality and hover states.

Possibly related PRs

  • test: add milestone UI e2e test #44: The test suite for the milestone component includes a test that verifies the default UI screenshot functionality, similar to the main PR's focus on the guide component's UI screenshot functionality.
  • test: add progress UI e2e test #57: The progress component's test also verifies the default UI screenshot functionality, aligning with the main PR's objective of ensuring visual consistency through screenshot validation.

Suggested reviewers

  • zzcr

🐰 In the guide where the bunnies play,
New tests hop in to save the day!
With screenshots bright, they check the scene,
Hovering close, and buttons keen.
Playwright's magic, a joyful sight,
Ensures our guide is just right! 🌟


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 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 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: 0

🧹 Outside diff range and nitpick comments (3)
tests/guide/xdesign.spec.ts (3)

1-3: Consider using English for test descriptions

The test suite description is currently in Chinese. For better international collaboration and maintainability, consider using English for all test descriptions and comments.

-test.describe('guide组件xdesign规范', () => {
+test.describe('Guide component xdesign specifications', () => {

4-24: Good test coverage, with some suggestions for improvement

The test case covers important interactions and visual states of the guide component, which is great. Here are some suggestions to enhance the test:

  1. Add a cleanup step at the end of the test to close the guide.
  2. Use constants for repeated selectors to improve maintainability.
  3. Add comments in English to explain the purpose of each section.

Here's a refactored version of the test incorporating these suggestions:

test('Default--UI screenshot', async ({ page }) => {
  // Constants for selectors
  const GUIDE_SELECTOR = '.tiny-guide.shepherd-element';
  const CLOSE_ICON_SELECTOR = '.shepherd-cancel-icon span';

  // Error handling
  page.on('pageerror', (exception) => expect(exception).toBeNull());

  // Navigate to the basic usage example
  await page.goto('guide#basic-usage');
  const demo = page.locator('#basic-usage .pc-demo');

  // Start the guide
  await demo.getByRole('button', { name: '开始引导' }).click();
  const guide = page.locator(GUIDE_SELECTOR);

  // Check basic usage state
  await expect(guide).toBeInViewport();
  await expect(guide).toHaveScreenshot('basic-usage.png');

  // Check close button hover state
  const closeIcon = guide.locator(CLOSE_ICON_SELECTOR);
  await closeIcon.hover();
  await expect(guide).toBeInViewport();
  await expect(guide).toHaveScreenshot('hover-icon.png');

  // Check next button hover state
  const nextBtn = guide.getByRole('button', { name: '下一步' });
  await nextBtn.hover();
  await expect(guide).toBeInViewport();
  await expect(guide).toHaveScreenshot('hover-btn.png');

  // Cleanup: Close the guide
  await closeIcon.click();
  await expect(guide).not.toBeVisible();
});

This refactored version improves readability, maintainability, and adds a cleanup step.


1-25: Summary: Good addition of e2e tests with room for improvement

This new file adds valuable end-to-end tests for the guide UI component, which aligns well with the PR objectives. The test covers basic functionality and visual states, enhancing the overall test coverage of the project.

However, to fully comply with the project's contribution guidelines, please ensure that:

  1. The commit message is properly formatted.
  2. Any necessary documentation updates are made.
  3. The PR description is updated with more details about the changes and their impact.

Additionally, consider implementing the suggested improvements to enhance the test's readability, maintainability, and robustness.

To further improve the testing architecture:

  1. Consider creating a separate configuration file for test constants and selectors.
  2. Implement helper functions for common operations like starting and closing the guide.
  3. If more tests are added in the future, consider organizing them into separate files based on functionality.
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 44a73ed and e655b3c.

⛔ Files ignored due to path filters (3)
  • tests/guide/xdesign.spec.ts-snapshots/basic-usage-chromium-win32.png is excluded by !**/*.png
  • tests/guide/xdesign.spec.ts-snapshots/hover-btn-chromium-win32.png is excluded by !**/*.png
  • tests/guide/xdesign.spec.ts-snapshots/hover-icon-chromium-win32.png is excluded by !**/*.png
📒 Files selected for processing (1)
  • tests/guide/xdesign.spec.ts (1 hunks)

@zzcr zzcr merged commit 9e4f2c5 into dev Sep 29, 2024
2 checks passed
@coderabbitai coderabbitai bot mentioned this pull request Sep 30, 2024
13 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
e2e playwright
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant