fix(admin): 统一后台筛选控件高度与对齐

This commit is contained in:
2026-11-20 14:19:06 +08:00
parent 51c41b238a
commit 5bdc125b18
12 changed files with 274 additions and 28 deletions
@@ -0,0 +1,58 @@
import { expect, test } from '@playwright/test'
const brandPath = '/admin-vue/asin-center/invalid'
test('品牌数据库:单行筛选控件等高、底边对齐,窄屏可以换行', async ({ page }) => {
await page.goto(brandPath)
const filters = page.locator('.invalid-filter-row')
await expect(filters.getByRole('button', { name: '查询' })).toBeVisible()
const controls = [
filters.getByPlaceholder('输入 ASIN'),
filters.getByPlaceholder('输入品牌'),
filters.locator('.el-select__wrapper'),
filters.getByRole('button', { name: '查询' }),
]
const boxes = await Promise.all(controls.map((control) => control.evaluate((el) => {
const { height, bottom } = el.getBoundingClientRect()
return { height, bottom }
})))
expect(boxes.map((box) => box.height)).toEqual([34, 34, 34, 34])
expect(Math.max(...boxes.map((box) => box.bottom)) - Math.min(...boxes.map((box) => box.bottom))).toBeLessThan(1)
const batchDelete = page.getByRole('button', { name: '批量删除(0)' })
await expect(batchDelete).toBeDisabled()
const batchBox = await batchDelete.boundingBox()
const tableBox = await page.locator('.invalid-asin-table-scroll').boundingBox()
expect(batchBox?.height).toBe(34)
expect(tableBox!.y - batchBox!.y - batchBox!.height).toBeGreaterThanOrEqual(8)
await page.setViewportSize({ width: 680, height: 900 })
await expect.poll(async () => filters.evaluate((row) => {
const first = row.firstElementChild!.getBoundingClientRect()
const last = row.lastElementChild!.getBoundingClientRect()
return last.top >= first.bottom && last.right <= row.getBoundingClientRect().right + 1
})).toBe(true)
})
test('品牌数据库:键盘搜索分组、查询和新增仍可用', async ({ page }) => {
await page.goto(brandPath)
const filters = page.locator('.invalid-filter-row')
await filters.getByPlaceholder('输入品牌').press('Tab')
const group = filters.getByRole('combobox')
await expect(group).toBeFocused()
await group.fill('测试')
await expect(page.getByRole('option', { name: '测试分组' })).toBeVisible()
await expect(page.getByRole('option', { name: '其他分组' })).not.toBeVisible()
await page.getByRole('option', { name: '测试分组' }).click()
await filters.getByPlaceholder('输入 ASIN').fill('B0INVALID1')
const queried = page.waitForRequest((req) => new URL(req.url()).pathname === '/api/admin/invalid-asin-data' && req.url().includes('group_id=1'))
await filters.getByRole('button', { name: '查询' }).click()
const params = new URL((await queried).url()).searchParams
expect(params.get('data_value')).toBe('B0INVALID1')
expect(params.get('page')).toBe('1')
await page.getByRole('button', { name: '新增', exact: true }).click()
const dialog = page.getByRole('dialog')
await expect(dialog.getByRole('button', { name: '保存' })).toBeVisible()
await dialog.getByRole('button', { name: '取消' }).click()
await expect(dialog).not.toBeVisible()
})