Files
halo-ops-audit/plugin-operation-audit/ui/src/views/AuditLogList.pagination.spec.ts
T

31 lines
1.4 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { readFileSync } from 'node:fs'
import { fileURLToPath } from 'node:url'
import { describe, expect, it } from 'vitest'
// 结构性回归测试:不渲染组件,仅检查 SFC 源码中 VPagination 的绑定形态。
// Halo @halo-dev/components 的 VPagination 默认文案即 Halo 控制台风格:
// totalLabel = `共 ${total} 项数据`、pageLabel = `页`、sizeLabel = `条 / 页`。
// 历史上这里覆盖为「页码 / 每页条数 / 共 N 条」,导致分页行与控制台其他页面不一致,
// 本测试防止该覆盖回归。
const sfc = readFileSync(fileURLToPath(new URL('./AuditLogList.vue', import.meta.url)), 'utf-8')
describe('AuditLogList 分页文案', () => {
it('使用 VPagination 默认文案(不覆盖 pageLabel / sizeLabel / totalLabel)', () => {
expect(sfc).toContain('<VPagination')
expect(sfc).not.toMatch(/page-label|pageLabel/)
expect(sfc).not.toMatch(/size-label|sizeLabel/)
expect(sfc).not.toMatch(/total-label|totalLabel/)
})
it('不再出现旧文案(页码 / 每页条数 / 共 N 条)', () => {
expect(sfc).not.toContain('页码')
expect(sfc).not.toContain('每页条数')
expect(sfc).not.toMatch(/共 \$\{total\} 条/)
})
it('分页控件仍在 total > 0 时渲染,且保留每页条数选项', () => {
expect(sfc).toMatch(/v-if="total > 0" class="audit-pagination"/)
expect(sfc).toMatch(/:size-options="\[10, 20, 50\]"/)
})
})