Files

29 lines
1.8 KiB
TypeScript

import test from 'node:test'
import assert from 'node:assert/strict'
import { readSource } from './helpers.ts'
// 用户反馈(round2 像素复刻样办):生成记录页还原旧版交互——「清理数据」为旧版没有的新增入口,从页面移除。
// 契约:页面无清理入口、无二次确认文案;前端适配层不再暴露 clearHistory;后端 DELETE /history 端点保留(非破坏性,供后续需要时再接线)。
test('align_history_clear_removed_from_page', () => {
const page = readSource('src/pages/records/RecordsHistoryPage.vue')
assert.doesNotMatch(page, /清理数据/, '页面不再有「清理数据」按钮')
assert.doesNotMatch(page, /clearAll|clearHistory/, '页面不再调用清理逻辑')
assert.doesNotMatch(page, /确定清空全部生成记录吗/, '无清理二次确认文案')
})
test('align_history_clear_api_no_longer_exposed', () => {
const api = readSource('src/pages/records/history-api.ts')
assert.doesNotMatch(api, /clearHistory/, '前端适配层不再暴露 clearHistory')
})
test('align_history_clear_backend_endpoint_kept', () => {
// 后端契约保留:DELETE /history 端点 + service 清空 + 中文排查日志(从前端摘除入口,不动后端)。
const ctrl = readSource('../backend-java/src/main/java/com/nanri/aiimage/modules/imagehistory/controller/ImageHistoryController.java')
assert.match(ctrl, /@DeleteMapping\("\/history"\)/, '后端有 DELETE /api/admin/history 端点')
assert.match(ctrl, /admin_history/, '清理端点沿用生成记录模块权限')
const service = readSource('../backend-java/src/main/java/com/nanri/aiimage/modules/imagehistory/service/ImageHistoryService.java')
assert.match(service, /clearAllHistory/, 'service 有清空方法')
assert.match(service, /清空生成记录,共清理/, '清空操作留中文排查日志')
})