Skip to content

Commit f7d2248

Browse files
committed
test(grid): add grid UI E2E test case
1 parent 17e5aba commit f7d2248

File tree

53 files changed

+365
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+365
-0
lines changed

tests/grid/xdesign/align.spec.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { expect, test } from '@playwright/test'
2+
3+
test.describe('grid 组件表格对齐xdesign规范', () => {
4+
test('表头对齐--UI截图', async ({ page }) => {
5+
page.on('pageerror', (exception) => expect(exception).toBeNull())
6+
await page.goto('grid-align#align-header-align')
7+
const demo = page.locator('#align-header-align .pc-demo')
8+
9+
await expect(demo).toBeInViewport()
10+
await expect(demo).toHaveScreenshot('header-align.png')
11+
})
12+
13+
test('表尾对齐--UI截图', async ({ page }) => {
14+
page.on('pageerror', (exception) => expect(exception).toBeNull())
15+
await page.goto('grid-align#align-footer-align')
16+
const demo = page.locator('#align-footer-align .pc-demo')
17+
18+
await expect(demo).toBeInViewport()
19+
await expect(demo).toHaveScreenshot('footer-align.png')
20+
})
21+
22+
test('表格对齐--UI截图', async ({ page }) => {
23+
page.on('pageerror', (exception) => expect(exception).toBeNull())
24+
await page.goto('grid-align#align-grid-align')
25+
const demo = page.locator('#align-grid-align .pc-demo')
26+
27+
await expect(demo).toBeInViewport()
28+
await expect(demo).toHaveScreenshot('grid-align.png')
29+
})
30+
31+
})

tests/grid/xdesign/appearance.spec.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { expect, test } from '@playwright/test'
2+
3+
test.describe('grid 组件外观设置xdesign规范', () => {
4+
test('边框--UI截图', async ({ page }) => {
5+
page.on('pageerror', (exception) => expect(exception).toBeNull())
6+
await page.goto('grid-appearance-settings#appearance-settings-grid-border')
7+
const demo = page.locator('#appearance-settings-grid-border .pc-demo')
8+
9+
await expect(demo).toBeInViewport()
10+
await expect(demo).toHaveScreenshot('border.png')
11+
12+
// 带边框的hover
13+
const firstRow = demo.locator('.tiny-grid-body__row').first()
14+
await firstRow.hover()
15+
await expect(demo).toHaveScreenshot('border-hover.png')
16+
})
17+
18+
test('斑马纹--UI截图', async ({ page }) => {
19+
page.on('pageerror', (exception) => expect(exception).toBeNull())
20+
await page.goto('grid-appearance-settings#appearance-settings-stripe')
21+
const demo = page.locator('#appearance-settings-stripe .pc-demo')
22+
23+
await expect(demo).toBeInViewport()
24+
await expect(demo).toHaveScreenshot('stripe.png')
25+
26+
// 斑马纹的hover
27+
const secondRow = demo.locator('.tiny-grid-body__row').nth(1)
28+
await secondRow.hover()
29+
await expect(demo).toHaveScreenshot('stripe-hover.png')
30+
// 斑马纹选中
31+
await secondRow.locator('.tiny-grid-checkbox__icon').click()
32+
await expect(demo).toHaveScreenshot('stripe-select.png')
33+
})
34+
35+
})

tests/grid/xdesign/edit.spec.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { expect, test } from '@playwright/test'
2+
3+
test.describe('grid 组件编辑xdesign规范', () => {
4+
test('编辑--UI截图', async ({ page }) => {
5+
page.on('pageerror', (exception) => expect(exception).toBeNull())
6+
await page.goto('grid-editor#editor-inner-editor')
7+
const demo = page.locator('#editor-inner-editor .pc-demo')
8+
9+
await expect(demo).toBeInViewport()
10+
await expect(demo).toHaveScreenshot('edit.png')
11+
12+
// 编辑态
13+
const firstRow = demo.locator('.tiny-grid-body__row').first()
14+
await firstRow.locator('.tiny-grid-cell').filter({ hasText: 'GFD科技YX公司' }).click()
15+
await expect(demo).toHaveScreenshot('edit-active.png')
16+
})
17+
})

tests/grid/xdesign/empty.spec.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { expect, test } from '@playwright/test'
2+
3+
test.describe('grid 组件空数据xdesign规范', () => {
4+
test('空数据--UI截图', async ({ page }) => {
5+
6+
await page.goto('grid-empty#empty-empty-data-default-tip')
7+
const demo = page.locator('#empty-empty-data-default-tip .pc-demo')
8+
9+
await expect(demo).toBeInViewport()
10+
await expect(demo).toHaveScreenshot('empty.png')
11+
})
12+
13+
test('空数据居中--UI截图', async ({ page }) => {
14+
15+
await page.goto('grid-empty#empty-empty-data-iscenter')
16+
const demo = page.locator('#empty-empty-data-iscenter .pc-demo')
17+
18+
await expect(demo).toBeInViewport()
19+
await expect(demo).toHaveScreenshot('center-empty.png')
20+
21+
})
22+
})

tests/grid/xdesign/expand.spec.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { expect, test } from '@playwright/test'
2+
3+
test.describe('grid 组件展开行xdesign规范', () => {
4+
test('展开行--UI截图', async ({ page }) => {
5+
page.on('pageerror', (exception) => expect(exception).toBeNull())
6+
await page.goto('grid-expand#expand-has-row-expand')
7+
const demo = page.locator('#expand-has-row-expand .pc-demo')
8+
9+
await expect(demo).toBeInViewport()
10+
await expect(demo).toHaveScreenshot('expand.png')
11+
12+
// 展开态
13+
const firstRow = demo.locator('.tiny-grid-body__row').first()
14+
await firstRow.locator('.tiny-grid__expanded').click()
15+
await expect(demo).toHaveScreenshot('expand-active.png')
16+
})
17+
18+
test('嵌套表格--UI截图', async ({ page }) => {
19+
page.on('pageerror', (exception) => expect(exception).toBeNull())
20+
await page.goto('grid-expand#expand-nested-grid')
21+
const demo = page.locator('#expand-nested-grid .pc-demo')
22+
23+
await expect(demo).toBeInViewport()
24+
25+
// 展开态
26+
const firstRow = demo.locator('.tiny-grid-body__row').first()
27+
await firstRow.locator('.tiny-grid__expanded').click()
28+
await expect(demo).toHaveScreenshot('nest-grid.png')
29+
})
30+
})

tests/grid/xdesign/filter.spec.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { expect, test } from '@playwright/test'
2+
3+
test.describe('grid 组件过滤xdesign规范', () => {
4+
test('过滤--UI截图', async ({ page }) => {
5+
page.on('pageerror', (exception) => expect(exception).toBeNull())
6+
await page.goto('grid-filter#filter-default-filter')
7+
const demo = page.locator('#filter-default-filter .pc-demo')
8+
9+
await expect(demo).toBeInViewport()
10+
await expect(demo).toHaveScreenshot('filter.png')
11+
12+
// 编辑态
13+
const header = demo.locator('.tiny-grid-header__row').first()
14+
await header.locator('.tiny-grid-cell').filter({ hasText: '城市' }).locator('.tiny-grid-filter-wrapper').click()
15+
await page.locator('.tiny-grid__filter-option').filter({ hasText: '中山' }).locator('svg').click()
16+
await expect(demo).toHaveScreenshot('filter-active.png')
17+
})
18+
})

tests/grid/xdesign/fixed.spec.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { expect, test } from '@playwright/test'
2+
3+
test.describe('grid 组件冻结xdesign规范', () => {
4+
test('左冻结--UI截图', async ({ page }) => {
5+
page.on('pageerror', (exception) => expect(exception).toBeNull())
6+
await page.goto('grid-fixed#fixed-left-fixed')
7+
const demo = page.locator('#fixed-left-fixed .pc-demo')
8+
9+
await expect(demo).toBeInViewport()
10+
11+
// 滚动到右边
12+
const firstRow = demo.locator('.tiny-grid-body__row').first()
13+
await firstRow.click()
14+
await page.mouse.wheel(2000, 0)
15+
await expect(demo).toHaveScreenshot('left-fixed.png')
16+
})
17+
18+
test('右冻结--UI截图', async ({ page }) => {
19+
page.on('pageerror', (exception) => expect(exception).toBeNull())
20+
await page.goto('grid-fixed#fixed-right-fixed')
21+
const demo = page.locator('#fixed-right-fixed .pc-demo')
22+
23+
await expect(demo).toBeInViewport()
24+
await expect(demo).toHaveScreenshot('right-fixed.png')
25+
})
26+
27+
test('分组表头冻结--UI截图', async ({ page }) => {
28+
page.on('pageerror', (exception) => expect(exception).toBeNull())
29+
await page.goto('grid-fixed#group-header-fixed')
30+
const demo = page.locator('#group-header-fixed .pc-demo')
31+
32+
await expect(demo).toBeInViewport()
33+
await expect(demo).toHaveScreenshot('group-fixed.png')
34+
})
35+
})

tests/grid/xdesign/loading.spec.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { expect, test } from '@playwright/test'
2+
3+
test.describe('grid 组件加载中xdesign规范', () => {
4+
test('加载中--UI截图', async ({ page }) => {
5+
page.on('pageerror', (exception) => expect(exception).toBeNull())
6+
await page.goto('grid-loading#loading-grid-loading-tip')
7+
const demo = page.locator('#loading-grid-loading-tip .pc-demo')
8+
9+
await expect(demo).toHaveScreenshot('loading.png')
10+
})
11+
})

tests/grid/xdesign/pager.spec.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { expect, test } from '@playwright/test'
2+
3+
test.describe('grid 组件分页xdesign规范', () => {
4+
test('分页--UI截图', async ({ page }) => {
5+
page.on('pageerror', (exception) => expect(exception).toBeNull())
6+
await page.goto('grid-pager#pager-inner-default-pager')
7+
const demo = page.locator('#pager-inner-default-pager .pc-demo')
8+
9+
await expect(demo).toBeInViewport()
10+
await expect(demo).toHaveScreenshot('pager.png')
11+
12+
})
13+
})

tests/grid/xdesign/select-row.spec.ts

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import { expect, test } from '@playwright/test'
2+
3+
test.describe('grid 组件选中行xdesign规范', () => {
4+
test('基本用法--UI截图', async ({ page }) => {
5+
page.on('pageerror', (exception) => expect(exception).toBeNull())
6+
await page.goto('grid-operation-column#operation-column-selection-operation')
7+
const demo = page.locator('#operation-column-selection-operation .pc-demo')
8+
await expect(demo).toBeInViewport()
9+
await expect(demo).toHaveScreenshot('basic-usage.png')
10+
11+
// 表格行悬浮
12+
const firstRow = demo.locator('.tiny-grid-body__row').first()
13+
await firstRow.hover()
14+
await expect(demo).toHaveScreenshot('row-hover.png')
15+
16+
// 选中某一行
17+
await firstRow.locator('.tiny-grid-checkbox__icon').click()
18+
await expect(demo).toHaveScreenshot('selection.png')
19+
20+
// 全部选中
21+
await demo.locator('.tiny-grid-header__row .tiny-grid-checkbox__icon').click()
22+
await expect(demo).toHaveScreenshot('all-selection.png')
23+
})
24+
25+
26+
test('单选--UI截图', async ({ page }) => {
27+
page.on('pageerror', (exception) => expect(exception).toBeNull())
28+
29+
await page.goto('grid-operation-column#operation-column-clear-and-set-radio-row')
30+
const demo = page.locator('#operation-column-clear-and-set-radio-row .pc-demo')
31+
await expect(demo).toBeInViewport()
32+
await expect(demo).toHaveScreenshot('radio.png')
33+
// 单选行悬浮
34+
const firstRow = demo.locator('.tiny-grid-body__row').first()
35+
await firstRow.hover()
36+
await expect(demo).toHaveScreenshot('radio-hover.png')
37+
38+
// 单选选中某一行
39+
await firstRow.locator('.tiny-grid-radio').click()
40+
await expect(demo).toHaveScreenshot('radio.png')
41+
})
42+
})

tests/grid/xdesign/size.spec.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { expect, test } from '@playwright/test'
2+
3+
test.describe('grid 组件尺寸xdesign规范', () => {
4+
test('尺寸--UI截图', async ({ page }) => {
5+
page.on('pageerror', (exception) => expect(exception).toBeNull())
6+
await page.goto('grid-size#size-grid-size')
7+
const demo = page.locator('#size-grid-size .pc-demo')
8+
9+
await expect(demo).toBeInViewport()
10+
await demo.locator('.tiny-tabs__item__title').filter({ hasText: 'mini' }).click()
11+
12+
const miniGrid = demo.locator('.tiny-grid__wrapper.size__mini')
13+
await expect(miniGrid).toHaveScreenshot('mini.png')
14+
})
15+
})

tests/grid/xdesign/sort.spec.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { expect, test } from '@playwright/test'
2+
3+
test.describe('grid 组件排序xdesign规范', () => {
4+
test('排序--UI截图', async ({ page }) => {
5+
page.on('pageerror', (exception) => expect(exception).toBeNull())
6+
await page.goto('grid-sort#sort-default-sort')
7+
const demo = page.locator('#sort-default-sort .pc-demo')
8+
9+
await expect(demo).toBeInViewport()
10+
await expect(demo).toHaveScreenshot('sort.png')
11+
12+
// 编辑态
13+
const header = demo.locator('.tiny-grid-header__row').first()
14+
await header.locator('.tiny-grid-cell').filter({ hasText: '员工数排序点击表头排序,可以通过配置 trigger 设置触发源' }).locator('svg').click()
15+
await expect(demo).toHaveScreenshot('sort-active.png')
16+
})
17+
})

tests/grid/xdesign/toolbar.spec.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { expect, test } from '@playwright/test'
2+
3+
test.describe('grid 组件工具栏xdesign规范', () => {
4+
test('工具栏--UI截图', async ({ page }) => {
5+
page.on('pageerror', (exception) => expect(exception).toBeNull())
6+
await page.goto('grid-toolbar#toolbar-insert-delete-update')
7+
const demo = page.locator('#toolbar-insert-delete-update .pc-demo')
8+
9+
await expect(demo).toBeInViewport()
10+
await expect(demo).toHaveScreenshot('toolbar.png')
11+
})
12+
13+
test('大工具栏--UI截图', async ({ page }) => {
14+
page.on('pageerror', (exception) => expect(exception).toBeNull())
15+
await page.goto('grid-toolbar#toolbar-copy-row-data')
16+
const demo = page.locator('#toolbar-copy-row-data .pc-demo')
17+
18+
await expect(demo).toBeInViewport()
19+
await expect(demo).toHaveScreenshot('large.png')
20+
})
21+
22+
test('两行工具栏--UI截图', async ({ page }) => {
23+
page.on('pageerror', (exception) => expect(exception).toBeNull())
24+
await page.goto('grid-toolbar#toolbar-custom-toolbar')
25+
const demo = page.locator('#toolbar-custom-toolbar .pc-demo')
26+
27+
await expect(demo).toBeInViewport()
28+
await expect(demo).toHaveScreenshot('two-row.png')
29+
})
30+
})

tests/grid/xdesign/tree.spec.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { expect, test } from '@playwright/test'
2+
3+
test.describe('grid 组件树表xdesign规范', () => {
4+
test('树表--UI截图', async ({ page }) => {
5+
page.on('pageerror', (exception) => expect(exception).toBeNull())
6+
await page.goto('grid-tree-table#tree-table-set-tree-expansion')
7+
const demo = page.locator('#tree-table-set-tree-expansion .pc-demo')
8+
const grid = demo.locator('.tiny-grid.tiny-grid__wrapper')
9+
10+
await page.setViewportSize({
11+
width: 1400,
12+
height: 1200
13+
})
14+
15+
await expect(grid).toBeInViewport()
16+
await expect(grid).toHaveScreenshot('tree.png')
17+
18+
// 展开态
19+
await demo.locator('button').filter({ hasText: '展开所有树节点' }).click()
20+
await expect(grid).toHaveScreenshot('tree-expand.png')
21+
})
22+
})

tests/grid/xdesign/validate.spec.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { expect, test } from '@playwright/test'
2+
3+
test.describe('grid 组件校验xdesign规范', () => {
4+
test('气泡提示校验--UI截图', async ({ page }) => {
5+
page.on('pageerror', (exception) => expect(exception).toBeNull())
6+
await page.goto('grid-validation#validation-editing-validation')
7+
const demo = page.locator('#validation-editing-validation .pc-demo')
8+
9+
await expect(demo).toBeInViewport()
10+
const second = demo.locator('.tiny-grid-body__row').nth(1)
11+
await second.locator('.tiny-grid-cell').filter({ hasText: 'WWW科技YX公司' }).click()
12+
await second.locator('input').fill('')
13+
await expect(demo).toHaveScreenshot('validate.png')
14+
})
15+
16+
test('行内提示校验--UI截图', async ({ page }) => {
17+
page.on('pageerror', (exception) => expect(exception).toBeNull())
18+
await page.goto('grid-validation#valid-config')
19+
const demo = page.locator('#valid-config .pc-demo')
20+
21+
await expect(demo).toBeInViewport()
22+
// 编辑态
23+
const firstRow = demo.locator('.tiny-grid-body__row').first()
24+
await firstRow.locator('td').nth(3).click()
25+
await expect(demo).toHaveScreenshot('inline-validate.png')
26+
})
27+
})

0 commit comments

Comments
 (0)