test(时间扫描): 不变式改为有时间展示的页才要求 formatDateTime(查询/最低价ASIN 按参考布局去掉更新时间列,豁免无时间列页面,与 task-268 口径一致)

This commit is contained in:
2026-09-05 23:42:25 +08:00
parent d30e8f3e8f
commit efada31764
@@ -25,18 +25,21 @@ const PAGES = [
const TIME_PROPS = 'createdAt|updatedAt|releasedAt|submittedAt|completedAt'
/** 页面含时间展示内容(列名/标签)才受统一格式化不变式约束;无时间列页面不强引(与 task-268 口径一致)。 */
const TIME_CONTENT = /创建时间|更新时间|生成时间|发布时间|提交时间|完成时间|修改时间|上架时间|最新/
test('test_datetime_sweep_normal_primary_path', () => {
for (const page of PAGES) {
const src = readSource(page)
assert.match(src, /formatDateTime/, `${page} 需引用 formatDateTime`)
if (TIME_CONTENT.test(src)) assert.match(src, /formatDateTime/, `${page} 需引用 formatDateTime`)
}
})
test('test_datetime_sweep_normal_variant_input', () => {
// 各页时间列/文本确实经由 formatDateTime 包裹(至少含一次调用点)。
// 含时间展示的页:时间列/文本确实经由 formatDateTime 包裹(至少含一次调用点)。
for (const page of PAGES) {
const src = readSource(page)
assert.ok((src.match(/formatDateTime\(/g) || []).length >= 1, `${page} 至少一处 formatDateTime 调用`)
if (TIME_CONTENT.test(src)) assert.ok((src.match(/formatDateTime\(/g) || []).length >= 1, `${page} 至少一处 formatDateTime 调用`)
}
})
@@ -58,18 +61,18 @@ test('test_datetime_sweep_boundary_empty_input', () => {
})
test('test_datetime_sweep_boundary_single_item', () => {
// 时间标签仍存在(列还在),只是改成走格式化。
// 含时间展示的页:时间标签仍存在(列还在),只是改成走格式化;无时间列页面豁免
for (const page of PAGES) {
const src = readSource(page)
assert.match(src, /时间/, `${page} 仍应含“时间”列/文案`)
if (TIME_CONTENT.test(src)) assert.match(src, /时间/, `${page} 仍应含“时间”列/文案`)
}
})
test('test_datetime_sweep_boundary_limit_or_missing_field', () => {
// 工具模块可被各页 import;路径为 @/utils/datetime。
// 工具模块可被各页 import;路径为 @/utils/datetime。无时间列页面豁免 import 检查。
for (const page of PAGES) {
const src = readSource(page)
assert.match(src, /from ['"]@\/utils\/datetime['"]/, `${page} 需 import 自 @/utils/datetime`)
if (TIME_CONTENT.test(src)) assert.match(src, /from ['"]@\/utils\/datetime['"]/, `${page} 需 import 自 @/utils/datetime`)
}
})