u
This commit is contained in:
1 parent
ae3ca3cfa1
commit
7bd5f1dde9
45 files changed
+3414
-229
No files matched your search
@@ -0,0 +1,60 @@
|
||||
import { expect, test } from '@playwright/test'
|
||||
|
||||
/**
|
||||
* 验证去掉分页、默认 1000 行后的 /ocean/booking。
|
||||
*
|
||||
* 注意:ERP 的 Vite dep 缓存可能是旧包(曾实测缓存里没有 G3Table),
|
||||
* 若行编辑相关断言失败,先确认缓存已刷新再判断是页面问题。
|
||||
*/
|
||||
test.describe('/ocean/booking(无分页,1000 行)', () => {
|
||||
test.beforeEach(async ({ page }) => {
|
||||
await page.goto('/ocean/booking')
|
||||
await page.waitForTimeout(1500)
|
||||
})
|
||||
|
||||
test('页面渲染表格,且分页器已移除', async ({ page }) => {
|
||||
await expect(page.locator('.booking__title')).toHaveText('订舱单')
|
||||
await expect(page.locator('.g3-table')).toBeVisible()
|
||||
// 分页器不该再存在
|
||||
await expect(page.locator('.g3-pagination')).toHaveCount(0)
|
||||
// 「每页」选择器也不该存在
|
||||
await expect(page.locator('.booking__field').filter({ hasText: '每页' })).toHaveCount(0)
|
||||
})
|
||||
|
||||
test('数据量选择器默认 1000,且只保留一个下拉', async ({ page }) => {
|
||||
const selects = page.locator('.booking__select')
|
||||
await expect(selects).toHaveCount(1)
|
||||
await expect(selects.first()).toHaveValue('1000')
|
||||
})
|
||||
|
||||
test('1000 行数据:虚拟滚动开启,DOM 行数远少于 1000', async ({ page }) => {
|
||||
const stk = page.locator('.g3-table .stk-table').first()
|
||||
// 库开启虚拟滚动时会加 .virtual 类
|
||||
await expect(stk).toHaveClass(/virtual/)
|
||||
|
||||
const rendered = await page.locator('.stk-tbody-main tr').count()
|
||||
console.log('DOM ROWS (1000 数据): ' + rendered)
|
||||
expect(rendered).toBeGreaterThan(0)
|
||||
expect(rendered).toBeLessThan(200)
|
||||
})
|
||||
|
||||
test('可滚动到底部(数据确实有 1000 行)', async ({ page }) => {
|
||||
const info = await page.locator('.g3-table .stk-table').first().evaluate((el) => {
|
||||
const stk = el as HTMLElement
|
||||
return { scrollH: stk.scrollHeight, clientH: stk.clientHeight }
|
||||
})
|
||||
console.log('SCROLL: ' + JSON.stringify(info))
|
||||
// 1000 行 * 32px 行高 ≈ 32000,远大于视口
|
||||
expect(info.scrollH).toBeGreaterThan(10000)
|
||||
})
|
||||
|
||||
test('切换数据量到 100 行后虚拟滚动关闭(低于阈值)', async ({ page }) => {
|
||||
await page.locator('.booking__select').first().selectOption('100')
|
||||
await page.waitForTimeout(600)
|
||||
|
||||
const stk = page.locator('.g3-table .stk-table').first()
|
||||
await expect(stk).not.toHaveClass(/virtual/)
|
||||
// 100 行全量渲染
|
||||
await expect(page.locator('.stk-tbody-main tr')).toHaveCount(100)
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user