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

fix(divider): [divider] modify e2e test cases for the divider component #2766

Merged
merged 2 commits into from
Jan 9, 2025

Conversation

James-9696
Copy link
Collaborator

@James-9696 James-9696 commented Jan 8, 2025

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:
    modify e2e test cases for the divider component

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

Release Notes

  • Tests

    • Added new test cases for Divider component functionality
      • Verified basic usage and default styles
      • Tested different divider types (solid, dashed, dotted)
      • Checked divider text positioning and content
      • Validated vertical divider properties
      • Examined different divider status states (default, success, error, warning, info)
  • Documentation

    • Updated test case names to more descriptive Chinese titles

The release focuses on comprehensive testing of the Divider component across various configurations and visual properties.

Copy link

coderabbitai bot commented Jan 8, 2025

Walkthrough

This pull request involves updating test cases for the Divider component across multiple specification files. The changes focus on modifying test case names, removing previous interaction-based tests, and introducing new assertions that verify text content, CSS properties, and visual characteristics of divider elements. The tests now emphasize direct validation of divider components' attributes using Playwright's testing framework, with a shift towards more precise and targeted testing approaches.

Changes

File Change Summary
examples/sites/demos/pc/app/divider/basic-usage.spec.ts Added new test case '基本用法' verifying divider's default border color
examples/sites/demos/pc/app/divider/content-position.spec.ts Renamed test to '分割线文案位置', replaced click interactions with CSS property assertions
examples/sites/demos/pc/app/divider/custom-style.spec.ts Renamed test to '自定义样式', added text content assertions for divider elements
examples/sites/demos/pc/app/divider/direction.spec.ts Renamed test to '垂直分割线', added vertical divider CSS property verification
examples/sites/demos/pc/app/divider/divider-type.spec.ts Added new test '分割线类型' checking divider type CSS border styles
examples/sites/demos/pc/app/divider/status.spec.ts Added new test '分割线状态' verifying status of divider components

Possibly related PRs

Suggested labels

e2e-test

Suggested reviewers

  • zzcr

Poem

🐰 Dividers dance, tests take flight,
CSS properties shining bright,
From clicks to checks, our code grows wise,
Playwright guides with eagle eyes,
A rabbit's test of pure delight! 🧪

Finishing Touches

  • 📝 Generate Docstrings

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 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.

@github-actions github-actions bot added the bug Something isn't working label Jan 8, 2025
Copy link

Walkthrough

This PR modifies the end-to-end (e2e) test cases for the divider component in the Tiny Vue project. The changes involve updating test descriptions and assertions to verify CSS properties and text content, ensuring the divider component behaves as expected in various scenarios.

Changes

File Summary
basic-usage.spec.ts, divider-type.spec.ts, status.spec.ts Added new test cases to verify CSS properties and text content for divider components.
content-position.spec.ts, custom-style.spec.ts, direction.spec.ts Updated existing test cases to use CSS property assertions instead of click actions.

import { test, expect } from '@playwright/test'

test('基本用法', async ({ page }) => {
page.on('pageerror', (exception) => expect(exception).toBeNull())

Choose a reason for hiding this comment

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

Ensure that the page error listener is correctly handling exceptions. If any exceptions are expected, they should be explicitly handled or documented.

@@ -1,12 +1,10 @@
import { test, expect } from '@playwright/test'

test('Divider 文案位置', async ({ page }) => {
test('分割线文案位置', async ({ page }) => {
page.on('pageerror', (exception) => expect(exception).toBeNull())

Choose a reason for hiding this comment

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

Ensure that the page error listener is correctly handling exceptions. If any exceptions are expected, they should be explicitly handled or documented.

@@ -1,19 +1,12 @@
// divider#custom-style
import { test, expect } from '@playwright/test'

test('Divider 样式', async ({ page }) => {
test('自定义样式', async ({ page }) => {
page.on('pageerror', (exception) => expect(exception).toBeNull())

Choose a reason for hiding this comment

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

Ensure that the page error listener is correctly handling exceptions. If any exceptions are expected, they should be explicitly handled or documented.

@@ -1,12 +1,10 @@
// divider#custom-style
import { test, expect } from '@playwright/test'

test('Divider 分隔线', async ({ page }) => {
test('垂直分割线', async ({ page }) => {
page.on('pageerror', (exception) => expect(exception).toBeNull())

Choose a reason for hiding this comment

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

Ensure that the page error listener is correctly handling exceptions. If any exceptions are expected, they should be explicitly handled or documented.

import { test, expect } from '@playwright/test'

test('分割线类型', async ({ page }) => {
page.on('pageerror', (exception) => expect(exception).toBeNull())

Choose a reason for hiding this comment

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

Ensure that the page error listener is correctly handling exceptions. If any exceptions are expected, they should be explicitly handled or documented.

import { test, expect } from '@playwright/test'

test('分割线状态', async ({ page }) => {
page.on('pageerror', (exception) => expect(exception).toBeNull())

Choose a reason for hiding this comment

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

Ensure that the page error listener is correctly handling exceptions. If any exceptions are expected, they should be explicitly handled or documented.

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: 4

🧹 Nitpick comments (6)
examples/sites/demos/pc/app/divider/basic-usage.spec.ts (2)

6-6: Simplify the CSS selector for better maintainability

The current selector .tiny-divider .tiny-divider--default, .tiny-divider.tiny-divider--default is complex and could be fragile. Consider using a more specific and simpler selector.

-  const dividerCss = page.locator('.tiny-divider .tiny-divider--default, .tiny-divider.tiny-divider--default')
+  const dividerCss = page.locator('.tiny-divider--default')

3-8: Consider adding more test cases for basic usage

The current test only verifies the border color. Consider adding tests for:

  • Height/width of the divider
  • Margin/padding
  • Visibility/display properties
examples/sites/demos/pc/app/divider/direction.spec.ts (1)

4-10: Enhance vertical divider test coverage

While the current test checks basic properties, consider adding:

  1. Height verification
  2. Tests for multiple vertical dividers
  3. Spacing between vertical dividers
  4. Responsive behavior tests
examples/sites/demos/pc/app/divider/divider-type.spec.ts (1)

1-1: Overall feedback on the e2e test implementation

While the tests provide basic coverage for the divider component, there are several areas for improvement:

  1. Avoid hardcoded pixel values in position tests
  2. Add comprehensive style verification
  3. Include responsive layout testing
  4. Enhance test coverage for different scenarios

Additionally, consider adding test cases for:

  • Edge cases (very long text, empty text)
  • Accessibility testing
  • Different viewport sizes
  • RTL support

Would you like me to provide example implementations for any of these suggestions?

examples/sites/demos/pc/app/divider/custom-style.spec.ts (1)

8-11: Consider using test.describe for better organization.

The assertions could be grouped logically using test.describe blocks for better readability and maintenance.

Example structure:

test.describe('Custom Style Divider', () => {
  test('should display correct text labels', async ({ page }) => {
    // existing text assertions
  })
  
  test('should apply custom styles correctly', async ({ page }) => {
    // new style assertions
  })
})
examples/sites/demos/pc/app/divider/status.spec.ts (1)

7-11: Consider data-driven test approach.

The repetitive assertions could be simplified using a data-driven approach.

Refactor using test.each:

const statusTests = [
  { index: 0, text: 'default', color: 'rgb(220, 223, 230)' },
  { index: 1, text: 'success', color: 'rgb(103, 194, 58)' },
  { index: 2, text: 'error', color: 'rgb(245, 108, 108)' },
  { index: 3, text: 'warning', color: 'rgb(230, 162, 60)' },
  { index: 4, text: 'info', color: 'rgb(144, 147, 153)' }
]

test.describe('Divider Status', () => {
  for (const { index, text, color } of statusTests) {
    test(`should render ${text} status correctly`, async ({ page }) => {
      await page.goto('divider#status')
      const dividerText = page.locator('.tiny-divider__text').nth(index)
      const divider = page.locator('.tiny-divider').nth(index)
      
      await expect(dividerText).toHaveText(text)
      await expect(divider).toHaveCSS('border-color', color)
      await expect(divider).toHaveAttribute('role', 'separator')
    })
  }
})
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between f617f42 and e584722.

📒 Files selected for processing (6)
  • examples/sites/demos/pc/app/divider/basic-usage.spec.ts (1 hunks)
  • examples/sites/demos/pc/app/divider/content-position.spec.ts (1 hunks)
  • examples/sites/demos/pc/app/divider/custom-style.spec.ts (1 hunks)
  • examples/sites/demos/pc/app/divider/direction.spec.ts (1 hunks)
  • examples/sites/demos/pc/app/divider/divider-type.spec.ts (1 hunks)
  • examples/sites/demos/pc/app/divider/status.spec.ts (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: PR E2E Test (pnpm test:e2e3)

Comment on lines 7 to 9
await expect(left.first()).toHaveCSS('left', '133px')
await expect(left.nth(1)).toHaveCSS('left', '304.5px')
await expect(left.nth(2)).toHaveCSS('right', '80px')
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Avoid hardcoded pixel values in position tests

Using fixed pixel values (133px, 304.5px, 80px) makes the tests brittle and susceptible to failure with different viewport sizes or styling changes. Consider:

  1. Testing relative positioning instead
  2. Using viewport-relative calculations
  3. Adding viewport size setup in the test

Example approach:

test('分割线文案位置', async ({ page }) => {
  await page.setViewportSize({ width: 800, height: 600 });
  // ... rest of the test
  await expect(left.first()).toHaveCSS('position', 'absolute');
  await expect(left.first()).toHaveCSS('text-align', 'left');
  // ... similar checks for center and right
});

Comment on lines 3 to 10
test('分割线类型', async ({ page }) => {
page.on('pageerror', (exception) => expect(exception).toBeNull())
await page.goto('divider#divider-type')
const dividerText = page.locator('.tiny-divider__text')
await expect(dividerText.first()).toHaveText('solid线')
await expect(dividerText.nth(1)).toHaveText('dashed线')
await expect(dividerText.nth(2)).toHaveText('dotted线')
})
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add style verification for different divider types

The test only verifies text content but doesn't check the actual line styles. Add assertions for:

  1. Border styles (solid, dashed, dotted)
  2. Line thickness
  3. Color consistency

Example additions:

const divider = page.locator('.tiny-divider').first();
await expect(divider).toHaveCSS('border-style', 'solid');

const dashedDivider = page.locator('.tiny-divider').nth(1);
await expect(dashedDivider).toHaveCSS('border-style', 'dashed');

const dottedDivider = page.locator('.tiny-divider').nth(2);
await expect(dottedDivider).toHaveCSS('border-style', 'dotted');

Comment on lines +4 to +7
test('自定义样式', async ({ page }) => {
page.on('pageerror', (exception) => expect(exception).toBeNull())
await page.goto('divider#custom-style')
await page.getByText('自定义分隔线颜色').click()
await page.locator('.tiny-divider').first().click()
await page.getByText('自定义分隔线的样式').click()
await page.locator('.pc-demo > div:nth-child(4)').click()
await page.getByText('自定义文案的颜色').click()
await page
.locator('div')
.filter({ hasText: /^文案$/ })
.first()
.click()
await page.getByText('文案的背景颜色', { exact: true }).click()
await page.getByText('文案', { exact: true }).nth(1).click()
const dividerText = page.locator('.tiny-divider__text')
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Consider adding visual validation for custom styles.

While validating text content is good, this test for custom styles should also verify the actual CSS properties being customized (font color, background, font size, height, and margins).

Add visual validation, for example:

 test('自定义样式', async ({ page }) => {
   page.on('pageerror', (exception) => expect(exception).toBeNull())
   await page.goto('divider#custom-style')
   const dividerText = page.locator('.tiny-divider__text')
+  // Verify custom font color
+  await expect(dividerText.first()).toHaveCSS('color', 'rgb(64, 158, 255)')
+  // Verify custom background
+  await expect(dividerText.nth(1)).toHaveCSS('background-color', 'rgb(240, 249, 235)')
+  // Verify custom font size
+  await expect(dividerText.nth(2)).toHaveCSS('font-size', '20px')
+  // Verify custom height and margin
+  const divider = page.locator('.tiny-divider').nth(3)
+  await expect(divider).toHaveCSS('margin', '32px 0')
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
test('自定义样式', async ({ page }) => {
page.on('pageerror', (exception) => expect(exception).toBeNull())
await page.goto('divider#custom-style')
await page.getByText('自定义分隔线颜色').click()
await page.locator('.tiny-divider').first().click()
await page.getByText('自定义分隔线的样式').click()
await page.locator('.pc-demo > div:nth-child(4)').click()
await page.getByText('自定义文案的颜色').click()
await page
.locator('div')
.filter({ hasText: /^文案$/ })
.first()
.click()
await page.getByText('文案的背景颜色', { exact: true }).click()
await page.getByText('文案', { exact: true }).nth(1).click()
const dividerText = page.locator('.tiny-divider__text')
test('自定义样式', async ({ page }) => {
page.on('pageerror', (exception) => expect(exception).toBeNull())
await page.goto('divider#custom-style')
const dividerText = page.locator('.tiny-divider__text')
// Verify custom font color
await expect(dividerText.first()).toHaveCSS('color', 'rgb(64, 158, 255)')
// Verify custom background
await expect(dividerText.nth(1)).toHaveCSS('background-color', 'rgb(240, 249, 235)')
// Verify custom font size
await expect(dividerText.nth(2)).toHaveCSS('font-size', '20px')
// Verify custom height and margin
const divider = page.locator('.tiny-divider').nth(3)
await expect(divider).toHaveCSS('margin', '32px 0')

Comment on lines 3 to 6
test('分割线状态', async ({ page }) => {
page.on('pageerror', (exception) => expect(exception).toBeNull())
await page.goto('divider#status')
const dividerText = page.locator('.tiny-divider__text')
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add validation for status-specific styles and accessibility.

The test only verifies text content but should also validate status-specific visual styles and accessibility attributes.

Add style and accessibility validation:

 test('分割线状态', async ({ page }) => {
   page.on('pageerror', (exception) => expect(exception).toBeNull())
   await page.goto('divider#status')
   const dividerText = page.locator('.tiny-divider__text')
+  const dividers = page.locator('.tiny-divider')
+
+  // Status-specific color validation
+  await expect(dividers.nth(1)).toHaveCSS('border-color', 'rgb(103, 194, 58)') // success
+  await expect(dividers.nth(2)).toHaveCSS('border-color', 'rgb(245, 108, 108)') // error
+  await expect(dividers.nth(3)).toHaveCSS('border-color', 'rgb(230, 162, 60)') // warning
+  await expect(dividers.nth(4)).toHaveCSS('border-color', 'rgb(144, 147, 153)') // info
+
+  // Accessibility validation
+  for (let i = 0; i < 5; i++) {
+    await expect(dividers.nth(i)).toHaveAttribute('role', 'separator')
+  }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
test('分割线状态', async ({ page }) => {
page.on('pageerror', (exception) => expect(exception).toBeNull())
await page.goto('divider#status')
const dividerText = page.locator('.tiny-divider__text')
test('分割线状态', async ({ page }) => {
page.on('pageerror', (exception) => expect(exception).toBeNull())
await page.goto('divider#status')
const dividerText = page.locator('.tiny-divider__text')
const dividers = page.locator('.tiny-divider')
// Status-specific color validation
await expect(dividers.nth(1)).toHaveCSS('border-color', 'rgb(103, 194, 58)') // success
await expect(dividers.nth(2)).toHaveCSS('border-color', 'rgb(245, 108, 108)') // error
await expect(dividers.nth(3)).toHaveCSS('border-color', 'rgb(230, 162, 60)') // warning
await expect(dividers.nth(4)).toHaveCSS('border-color', 'rgb(144, 147, 153)') // info
// Accessibility validation
for (let i = 0; i < 5; i++) {
await expect(dividers.nth(i)).toHaveAttribute('role', 'separator')
}

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 (1)
examples/sites/demos/pc/app/divider/content-position.spec.ts (1)

3-3: Add JSDoc documentation for the test case.

Since documentation updates are marked as incomplete in the PR objectives, consider adding JSDoc documentation to describe the test's purpose and expectations.

+/**
+ * Tests the text positioning functionality of the divider component.
+ * Validates:
+ * - Left-aligned text with 20% offset
+ * - Center-aligned text
+ * - Right-aligned text
+ */
 test('分割线文案位置', async ({ page }) => {
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between e584722 and bc9bc47.

📒 Files selected for processing (4)
  • examples/sites/demos/pc/app/divider/content-position.spec.ts (1 hunks)
  • examples/sites/demos/pc/app/divider/custom-style.spec.ts (1 hunks)
  • examples/sites/demos/pc/app/divider/divider-type.spec.ts (1 hunks)
  • examples/sites/demos/pc/app/divider/status.spec.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • examples/sites/demos/pc/app/divider/status.spec.ts
  • examples/sites/demos/pc/app/divider/custom-style.spec.ts
  • examples/sites/demos/pc/app/divider/divider-type.spec.ts
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: PR Unit Test
  • GitHub Check: PR E2E Test (pnpm test:e2e3)
🔇 Additional comments (2)
examples/sites/demos/pc/app/divider/content-position.spec.ts (2)

4-4: Enhance error handling in the page error listener.

The current error handler silently expects all exceptions to be null. This makes debugging test failures more difficult.


3-5: 🛠️ Refactor suggestion

Add viewport setup for consistent testing.

The test lacks viewport size configuration, which could lead to inconsistent results across different test environments.

Add viewport setup before navigation:

 test('分割线文案位置', async ({ page }) => {
+  await page.setViewportSize({ width: 1280, height: 720 })
   page.on('pageerror', (exception) => expect(exception).toBeNull())
   await page.goto('divider#content-position')

Likely invalid or redundant comment.

Comment on lines +6 to +9
const left = page.locator('.tiny-divider__text')
await expect(left.first()).toHaveText('左侧且偏移20%')
await expect(left.nth(1)).toHaveText('中间')
await expect(left.nth(2)).toHaveCSS('right', '80px')
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Improve test robustness and consistency.

Several issues need attention:

  1. The locator is too generic and could match unintended elements
  2. Hardcoded pixel values make the test brittle
  3. Inconsistent validation approach between elements

Consider this more robust approach:

-  const left = page.locator('.tiny-divider__text')
-  await expect(left.first()).toHaveText('左侧且偏移20%')
-  await expect(left.nth(1)).toHaveText('中间')
-  await expect(left.nth(2)).toHaveCSS('right', '80px')
+  // More specific locators
+  const leftDivider = page.locator('.tiny-divider__text[style*="left"]')
+  const centerDivider = page.locator('.tiny-divider__text[style*="center"]')
+  const rightDivider = page.locator('.tiny-divider__text[style*="right"]')
+
+  // Validate text content
+  await expect(leftDivider).toHaveText('左侧且偏移20%')
+  await expect(centerDivider).toHaveText('中间')
+
+  // Validate positioning
+  await expect(leftDivider).toHaveCSS('position', 'absolute')
+  await expect(leftDivider).toHaveCSS('left', '20%')
+  await expect(centerDivider).toHaveCSS('position', 'absolute')
+  await expect(centerDivider).toHaveCSS('left', '50%')
+  await expect(rightDivider).toHaveCSS('position', 'absolute')
+  await expect(rightDivider).toHaveCSS('right', expect.stringMatching(/\d+%/))
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const left = page.locator('.tiny-divider__text')
await expect(left.first()).toHaveText('左侧且偏移20%')
await expect(left.nth(1)).toHaveText('中间')
await expect(left.nth(2)).toHaveCSS('right', '80px')
// More specific locators
const leftDivider = page.locator('.tiny-divider__text[style*="left"]')
const centerDivider = page.locator('.tiny-divider__text[style*="center"]')
const rightDivider = page.locator('.tiny-divider__text[style*="right"]')
// Validate text content
await expect(leftDivider).toHaveText('左侧且偏移20%')
await expect(centerDivider).toHaveText('中间')
// Validate positioning
await expect(leftDivider).toHaveCSS('position', 'absolute')
await expect(leftDivider).toHaveCSS('left', '20%')
await expect(centerDivider).toHaveCSS('position', 'absolute')
await expect(centerDivider).toHaveCSS('left', '50%')
await expect(rightDivider).toHaveCSS('position', 'absolute')
await expect(rightDivider).toHaveCSS('right', expect.stringMatching(/\d+%/))

@zzcr zzcr merged commit 6eb80f1 into dev Jan 9, 2025
7 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants