import { readFileSync } from 'node:fs' import { fileURLToPath } from 'node:url' import { describe, expect, it } from 'vitest' // 结构性回归测试:不渲染组件,仅检查 SFC 源码中的页面布局样式。 // 控制台内容区默认为灰底,操作审计页需整体铺白(flex: 1 撑满 main-content 剩余高度), // 使筛选栏、数据列表、分页条之间的间隙不再露出灰色;同时分页条两端需向内留白, // 不贴白色区域边缘。历史上这两处曾分别为灰底间隙与贴边分页,本测试防止回归。 const sfc = readFileSync(fileURLToPath(new URL('./AuditLogList.vue', import.meta.url)), 'utf-8') function styleRule(selector: string): string { const start = sfc.indexOf(`${selector} {`) expect(start, `缺少 ${selector} 样式规则`).toBeGreaterThan(-1) const end = sfc.indexOf('}', start) return sfc.slice(start, end) } describe('AuditLogList 页面铺白', () => { it('.audit-page 撑满控制台内容区剩余高度并使用白色背景', () => { const rule = styleRule('.audit-page') expect(rule).toMatch(/flex:\s*1/) expect(rule).toMatch(/background:\s*#fff/) }) it('.audit-pagination 左右向内留白,两端不贴白色区域边缘', () => { const rule = styleRule('.audit-pagination') expect(rule).toMatch(/padding:\s*0\s+1rem\s+1rem/) }) })