u
This commit is contained in:
1 parent
e99a9fb274
commit
0be0b0767a
788 files changed
+112023
-14941
No files matched your search
@@ -1,5 +1,20 @@
|
||||
import { expect, test } from '@playwright/test'
|
||||
|
||||
test.describe('Checkbox', () => {
|
||||
test('选中与未选中状态在同一行保持垂直对齐', async ({ page }) => {
|
||||
await page.goto('/')
|
||||
|
||||
const checked = page.locator('.g3-checkbox.is-checked').filter({ hasText: '已选中' })
|
||||
const unchecked = page.locator('.g3-checkbox').filter({ hasText: '未选中' })
|
||||
const checkedBox = await checked.locator('.g3-checkbox__box').boundingBox()
|
||||
const uncheckedBox = await unchecked.locator('.g3-checkbox__box').boundingBox()
|
||||
|
||||
expect(checkedBox).not.toBeNull()
|
||||
expect(uncheckedBox).not.toBeNull()
|
||||
expect(Math.abs(checkedBox!.y - uncheckedBox!.y)).toBeLessThanOrEqual(1)
|
||||
})
|
||||
})
|
||||
|
||||
/**
|
||||
* 组件细节回归 —— 每一条都对应一个真实报障,之前全部漏测。
|
||||
*
|
||||
@@ -116,13 +131,47 @@ test.describe('Tree', () => {
|
||||
expect(bg, `选中底色不应为透明:${bg}`).not.toBe('rgba(0, 0, 0, 0)')
|
||||
})
|
||||
|
||||
test('整层都是叶子时不渲染展开箭头占位', async ({ page }) => {
|
||||
test('叶子保留隐藏的箭头占位列(缩进对齐,曾整块跳过箭头列)', async ({ page }) => {
|
||||
await page.goto('/')
|
||||
// 扁平树:两个节点都没有子节点
|
||||
const flatTree = page.locator('.g3-tree').filter({ hasText: '节点一(无子节点)' }).first()
|
||||
|
||||
await expect(flatTree.locator('.g3-tree-node')).toHaveCount(2)
|
||||
await expect(flatTree.locator('.g3-tree-node__switcher')).toHaveCount(0)
|
||||
// 占位列仍渲染(保留宽度),但不可见
|
||||
const switchers = flatTree.locator('.g3-tree-node__switcher')
|
||||
await expect(switchers).toHaveCount(2)
|
||||
await expect(switchers.first()).toHaveCSS('visibility', 'hidden')
|
||||
})
|
||||
|
||||
test('子节点相对父节点缩进一个层级(子节点曾落到父节点文字左侧)', async ({ page }) => {
|
||||
await page.goto('/')
|
||||
const tree = page.getByTestId('tree')
|
||||
const box = async (text: string) =>
|
||||
(await tree.locator('.g3-tree-node__title').filter({ hasText: new RegExp(`^${text}$`) }).boundingBox())!
|
||||
|
||||
// default-expand-all:父「前端」下挂子「Vue」
|
||||
const parent = await box('前端')
|
||||
const child = await box('Vue')
|
||||
|
||||
// 子节点文字必须在父节点文字右侧,且大致缩进一个层级(indent 默认 18px)
|
||||
expect(child.x).toBeGreaterThan(parent.x)
|
||||
expect(child.x - parent.x).toBeGreaterThanOrEqual(16)
|
||||
expect(child.x - parent.x).toBeLessThanOrEqual(20)
|
||||
})
|
||||
|
||||
test('相邻节点行之间留有间距(曾贴在一起)', async ({ page }) => {
|
||||
await page.goto('/')
|
||||
const tree = page.getByTestId('tree')
|
||||
const rows = tree.locator('.g3-tree-node')
|
||||
|
||||
// DOM 顺序:前端 → Vue(前端首个子节点)→ …
|
||||
const first = (await rows.nth(0).boundingBox())!
|
||||
const second = (await rows.nth(1).boundingBox())!
|
||||
|
||||
const gap = second.y - (first.y + first.height)
|
||||
// 默认 gap 6px;给 4~10 的容差(亚像素 / 缩放)
|
||||
expect(gap).toBeGreaterThanOrEqual(4)
|
||||
expect(gap).toBeLessThanOrEqual(10)
|
||||
})
|
||||
|
||||
test('拖拽需要长按武装:直接拖动不会产生落点', async ({ page }) => {
|
||||
|
||||
Reference in new issue
Block a user