Skip to content

Commit 6eb80f1

Browse files
authored
fix(divider): [divider] modify e2e test cases for the divider component (#2766)
* fix: modify e2e test cases for the divider component * fix: modify e2e test cases for the divider component
1 parent f617f42 commit 6eb80f1

File tree

6 files changed

+48
-26
lines changed

6 files changed

+48
-26
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { test, expect } from '@playwright/test'
2+
3+
test('基本用法', async ({ page }) => {
4+
page.on('pageerror', (exception) => expect(exception).toBeNull())
5+
await page.goto('divider#basic-usage')
6+
const dividerCss = page.locator('.tiny-divider .tiny-divider--default, .tiny-divider.tiny-divider--default')
7+
await expect(dividerCss).toHaveCSS('border-color', 'rgb(219, 219, 219)')
8+
})
Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
import { test, expect } from '@playwright/test'
22

3-
test('Divider 文案位置', async ({ page }) => {
3+
test('分割线文案位置', async ({ page }) => {
44
page.on('pageerror', (exception) => expect(exception).toBeNull())
55
await page.goto('divider#content-position')
6-
await page.getByText('文案在左侧').click()
7-
await page.getByText('文案', { exact: true }).first().click()
8-
await page.getByText('文案在中间').click()
9-
await page.getByText('文案', { exact: true }).nth(1).click()
10-
await page.getByText('文案在右侧').click()
11-
await page.getByText('文案', { exact: true }).nth(2).click()
6+
const left = page.locator('.tiny-divider__text')
7+
await expect(left.first()).toHaveText('左侧且偏移20%')
8+
await expect(left.nth(1)).toHaveText('中间')
9+
await expect(left.nth(2)).toHaveCSS('right', '80px')
1210
})
Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,15 @@
11
// divider#custom-style
22
import { test, expect } from '@playwright/test'
33

4-
test('Divider 样式', async ({ page }) => {
4+
test('自定义样式', async ({ page }) => {
55
page.on('pageerror', (exception) => expect(exception).toBeNull())
66
await page.goto('divider#custom-style')
7-
await page.getByText('自定义分隔线颜色').click()
8-
await page.locator('.tiny-divider').first().click()
9-
await page.getByText('自定义分隔线的样式').click()
10-
await page.locator('.pc-demo > div:nth-child(4)').click()
11-
await page.getByText('自定义文案的颜色').click()
12-
await page
13-
.locator('div')
14-
.filter({ hasText: /^$/ })
15-
.first()
16-
.click()
17-
await page.getByText('文案的背景颜色', { exact: true }).click()
18-
await page.getByText('文案', { exact: true }).nth(1).click()
7+
const dividerText = page.locator('.tiny-divider__text')
8+
const dividerMargin = page.locator('.tiny-divider')
9+
const dividerLine = page.locator('.tiny-divider-line').first()
10+
await expect(dividerLine.first()).toHaveCSS('border-color', 'rgb(20, 118, 255)')
11+
await expect(dividerText.first()).toHaveCSS('color', 'rgb(20, 118, 255)')
12+
await expect(dividerText.nth(1)).toHaveCSS('background-color', 'rgb(20, 118, 255)')
13+
await expect(dividerText.nth(2)).toHaveCSS('font-size', '16px')
14+
await expect(dividerMargin.nth(4)).toHaveCSS('height', '40px')
1915
})
Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
// divider#custom-style
22
import { test, expect } from '@playwright/test'
33

4-
test('Divider 分隔线', async ({ page }) => {
4+
test('垂直分割线', async ({ page }) => {
55
page.on('pageerror', (exception) => expect(exception).toBeNull())
66
await page.goto('divider#direction')
7-
await page.getByText('分隔线', { exact: true }).first().click()
8-
await page.locator('.tiny-divider').first().click()
9-
await page.getByText('分隔线', { exact: true }).nth(1).click()
10-
await page.locator('.pc-demo > div:nth-child(4)').click()
11-
await page.getByText('分隔线', { exact: true }).nth(2).click()
7+
const dividerCss = page.locator('.tiny-divider--vertical')
8+
await expect(dividerCss.first()).toHaveCSS('vertical-align', 'middle')
9+
await expect(dividerCss.first()).toHaveCSS('border-left', '1px solid rgb(219, 219, 219)')
1210
})
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { test, expect } from '@playwright/test'
2+
3+
test('分割线类型', async ({ page }) => {
4+
page.on('pageerror', (exception) => expect(exception).toBeNull())
5+
await page.goto('divider#divider-type')
6+
const dividerText = page.locator('.tiny-divider--default')
7+
await expect(dividerText.first()).toHaveCSS('border-top-style', 'solid')
8+
await expect(dividerText.nth(1)).toHaveCSS('border-top-style', 'dashed')
9+
await expect(dividerText.nth(2)).toHaveCSS('border-top-style', 'dotted')
10+
})
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { test, expect } from '@playwright/test'
2+
3+
test('分割线状态', async ({ page }) => {
4+
page.on('pageerror', (exception) => expect(exception).toBeNull())
5+
await page.goto('divider#status')
6+
const dividerText = page.locator('.tiny-divider-line')
7+
await expect(dividerText.first()).toHaveClass(/tiny-divider--default/)
8+
await expect(dividerText.nth(1)).toHaveClass(/tiny-divider--success/)
9+
await expect(dividerText.nth(2)).toHaveClass(/tiny-divider--error/)
10+
await expect(dividerText.nth(3)).toHaveClass(/tiny-divider--warning/)
11+
await expect(dividerText.nth(4)).toHaveClass(/tiny-divider--info/)
12+
})

0 commit comments

Comments
 (0)