diff --git a/plugin-operation-audit/ui/src/views/AuditLogList.mobile.spec.ts b/plugin-operation-audit/ui/src/views/AuditLogList.mobile.spec.ts
index 6c143f1..09f2d28 100644
--- a/plugin-operation-audit/ui/src/views/AuditLogList.mobile.spec.ts
+++ b/plugin-operation-audit/ui/src/views/AuditLogList.mobile.spec.ts
@@ -2,12 +2,16 @@ import { readFileSync } from 'node:fs'
import { fileURLToPath } from 'node:url'
import { describe, expect, it } from 'vitest'
-// 移动端适配结构性回归测试:不渲染组件,仅检查 SFC 源码中的窄屏样式。
-// 桌面布局的 9 列筛选行与固定列宽列表(约 61rem)在窄屏下必然溢出:
-// 筛选标签逐字换行、输入框被压扁,数据行右侧被截断(需横向滚动才能看全)。
-// 窄屏(≤1023px:手机横竖屏 / 平板竖屏 / 半屏小窗口)改为——
-// 筛选 2 列(≤480px 单列)、隐藏列题头、entity 行纵向堆叠、分页条换行;
-// ≥1024px 维持桌面布局不变。本测试防止移动端适配被误删或失效。
+// 移动端适配结构性回归测试:不渲染组件,仅检查 SFC 源码。
+// 固定列宽列表合计约 69.5rem,窄屏(≤1023px:手机横竖屏 / 平板竖屏 / 半屏小窗口)
+// 下必然超出视口:题头与数据行置于同一横向滚动容器(.audit-list)整体左右滑动,
+// 列对齐关系与桌面一致;筛选栏窄屏 2 列(≤480px 手机竖屏单列)、分页条允许换行;
+// ≥1024px 维持桌面布局不变。
+// 特别注意:VEntity 是多根 Fragment 组件(tr + 可选 footer tr),其
拿不到
+// 本组件的 scoped 作用域 ID,所有锚定 .audit-row / 行内元素 :deep 的 scoped 规则
+// 永远失配(历史上「隐藏题头 + 数据行纵向堆叠」方案因此整批失效——窄屏下字段
+// 仍按固定列宽横排并被视口截断),行内样式必须锚定自身元素 .audit-list 穿透,
+// 本测试防止该失效方案被重新引入。
const sfc = readFileSync(fileURLToPath(new URL('./AuditLogList.vue', import.meta.url)), 'utf-8')
const MOBILE_QUERY = '@media (max-width: 1023px)'
@@ -34,11 +38,19 @@ function mobileBlock(): string {
/** 在指定文本块内取某选择器的规则体(自 from 起首个匹配)。 */
function ruleIn(block: string, selector: string, from = 0): string {
const start = block.indexOf(`${selector} {`, from)
- expect(start, `窄屏块中缺少 ${selector} 规则`).toBeGreaterThan(-1)
+ expect(start, `块中缺少 ${selector} 规则`).toBeGreaterThan(-1)
const end = block.indexOf('}', start)
return block.slice(start, end)
}
+/** 取全局(非媒体查询)样式中某选择器的规则体。 */
+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('存在 ≤1023px 窄屏断点,且位于桌面规则之后(同特异性按顺序覆盖才生效)', () => {
const mediaStart = sfc.indexOf(MOBILE_QUERY)
@@ -64,40 +76,46 @@ describe('AuditLogList 移动端适配', () => {
)
})
- it('窄屏隐藏固定列宽列题头(堆叠布局下无从对齐)', () => {
- const header = ruleIn(mobileBlock(), '.audit-header')
- expect(header).toMatch(/display:\s*none/)
+ it('题头与数据行置于同一横向滚动容器(.audit-list overflow-x: auto)', () => {
+ // 模板顺序:.audit-list 包裹 .audit-header 与全部 VEntity 数据行,
+ // 滑动时题头与数据列保持对齐
+ const listStart = sfc.indexOf('')
+ expect(listStart, '缺少 .audit-list 滚动容器').toBeGreaterThan(-1)
+ const headerStart = sfc.indexOf('