From efada31764a57aec1264df1cb176336430e6acb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E8=87=AA=E8=BE=BE?= <980324341@qq.com> Date: Sat, 5 Sep 2026 23:42:25 +0800 Subject: [PATCH] =?UTF-8?q?test(=E6=97=B6=E9=97=B4=E6=89=AB=E6=8F=8F):=20?= =?UTF-8?q?=E4=B8=8D=E5=8F=98=E5=BC=8F=E6=94=B9=E4=B8=BA=E6=9C=89=E6=97=B6?= =?UTF-8?q?=E9=97=B4=E5=B1=95=E7=A4=BA=E7=9A=84=E9=A1=B5=E6=89=8D=E8=A6=81?= =?UTF-8?q?=E6=B1=82=20formatDateTime=EF=BC=88=E6=9F=A5=E8=AF=A2/=E6=9C=80?= =?UTF-8?q?=E4=BD=8E=E4=BB=B7ASIN=20=E6=8C=89=E5=8F=82=E8=80=83=E5=B8=83?= =?UTF-8?q?=E5=B1=80=E5=8E=BB=E6=8E=89=E6=9B=B4=E6=96=B0=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E5=88=97=EF=BC=8C=E8=B1=81=E5=85=8D=E6=97=A0=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E5=88=97=E9=A1=B5=E9=9D=A2=EF=BC=8C=E4=B8=8E=20task-268=20?= =?UTF-8?q?=E5=8F=A3=E5=BE=84=E4=B8=80=E8=87=B4=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- admin-frontend-vue/tests/datetime-sweep.test.ts | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/admin-frontend-vue/tests/datetime-sweep.test.ts b/admin-frontend-vue/tests/datetime-sweep.test.ts index e0f3c082..96b68514 100644 --- a/admin-frontend-vue/tests/datetime-sweep.test.ts +++ b/admin-frontend-vue/tests/datetime-sweep.test.ts @@ -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`) } })