feat:日志敏感信息过滤
build / task (16.x, npm, macOS-latest) (push) Canceled after 0s
build / task (16.x, npm, ubuntu-latest) (push) Canceled after 0s
build / task (16.x, npm, windows-latest) (push) Canceled after 0s
build / task (16.x, pnpm, macOS-latest) (push) Canceled after 0s
build / task (16.x, pnpm, ubuntu-latest) (push) Canceled after 0s
build / task (16.x, pnpm, windows-latest) (push) Canceled after 0s
build / task (16.x, yarn, macOS-latest) (push) Canceled after 0s
build / task (16.x, yarn, ubuntu-latest) (push) Canceled after 0s
build / task (16.x, yarn, windows-latest) (push) Canceled after 0s
build / task (18.x, npm, macOS-latest) (push) Canceled after 0s
build / task (18.x, npm, ubuntu-latest) (push) Canceled after 0s
build / task (18.x, npm, windows-latest) (push) Canceled after 0s
build / task (18.x, pnpm, macOS-latest) (push) Canceled after 0s
build / task (18.x, pnpm, ubuntu-latest) (push) Canceled after 0s
build / task (18.x, pnpm, windows-latest) (push) Canceled after 0s
build / task (18.x, yarn, macOS-latest) (push) Canceled after 0s
build / task (18.x, yarn, ubuntu-latest) (push) Canceled after 0s
build / task (18.x, yarn, windows-latest) (push) Canceled after 0s
build / task (20.x, npm, macOS-latest) (push) Canceled after 0s
build / task (20.x, npm, ubuntu-latest) (push) Canceled after 0s
build / task (20.x, npm, windows-latest) (push) Canceled after 0s
build / task (20.x, pnpm, macOS-latest) (push) Canceled after 0s
build / task (20.x, pnpm, ubuntu-latest) (push) Canceled after 0s
build / task (20.x, pnpm, windows-latest) (push) Canceled after 0s
build / task (20.x, yarn, macOS-latest) (push) Canceled after 0s
build / task (20.x, yarn, ubuntu-latest) (push) Canceled after 0s
build / task (20.x, yarn, windows-latest) (push) Canceled after 0s

This commit is contained in:
dzc committed 2026-10-29 15:46:24 +08:00
1 parent 3e744b63f1
commit 1fa2f11057
10 files changed
+362 -14

No files matched your search

+58 -6
View File
@@ -36,6 +36,8 @@ function setup() {
assert.deepEqual(compileTemplate({ source: descriptor.template.content, filename: "log.vue", id: "log" }).errors, [])
const page = load(compileScript(descriptor, { id: "log" }).content, {
vue, "/@/api/admin/log": api,
dayjs: { default: require("dayjs") },
"dayjs/plugin/customParseFormat": { default: require("dayjs/plugin/customParseFormat") },
"/@/components/AsyncTaskProgress.vue": {}, "/@/hooks/batchExport": hook,
"vue-i18n": { useI18n: () => ({ t: key => key }) },
"/@/hooks/table": { useTable: () => ({ getDataList() {}, tableStyle: {} }) },
@@ -79,15 +81,65 @@ test("日志异步导出固定类型、时间和应用筛选,重复点击继
assert.deepEqual(downloads, [["/admin/sys-file/oss/file?fileName=logs.xlsx", "操作日志.xlsx"]])
})
test("未选择或清空日志时间时提交空数组,任务失败后可以重新导出", async () => {
test("未选择、清空或只选择一端时间时提示补全,不提交导出任务", async () => {
for (const range of ["", null, [], [null, null], ["2026-10-29 00:00:00"], ["2026-10-29 00:00:00", null]]) {
const { state, requests, errors, progress } = setup()
state.state.queryForm.createTime = range
state.showSearch.value = false
await state.exportExcel()
assert.equal(requests.length, 0)
assert.deepEqual(progress, [])
assert.deepEqual(errors, ["导出前请选择完整的日志创建时间范围"])
assert.equal(state.showSearch.value, true)
}
})
test("时间范围按自然月限制,跨月、月底和闰年边界与后端一致", async () => {
for (const range of [
["2026-01-31 08:30:00", "2026-02-28 08:30:00"],
["2024-01-31 08:30:00", "2024-02-29 08:30:00"],
["2026-10-01 00:00:00", "2026-11-01 00:00:00"],
["2026-10-29 00:00:00", "2026-10-29 00:00:00"],
]) {
const { state, requests, errors } = setup()
state.state.queryForm.createTime = range
await state.exportExcel()
assert.deepEqual(errors, [])
assert.equal(requests.length, 1)
assert.deepEqual(requests[0].data.createTime, range)
}
for (const range of [
["2026-01-31 08:30:00", "2026-02-28 08:30:01"],
["2024-01-31 08:30:00", "2024-02-29 08:30:01"],
["2026-10-01 00:00:00", "2026-11-01 00:00:01"],
]) {
const { state, requests, errors } = setup()
state.state.queryForm.createTime = range
await state.exportExcel()
assert.equal(requests.length, 0)
assert.deepEqual(errors, ["日志导出时间范围不能超过一个月"])
}
})
test("无效日期和倒序日期不提交,后台任务失败后可以修改条件重试", async () => {
const { state, requests, errors } = setup()
state.state.queryForm.createTime = ["2026-02-30 00:00:00", "2026-03-01 00:00:00"]
await state.exportExcel()
assert.deepEqual(requests[0].data, { logType: "", createTime: [], serviceId: "" })
assert.equal(state.state.queryForm.createTime, "")
state.handleExportFailure({ message: "当前筛选条件没有可导出的日志" })
assert.deepEqual(errors, ["当前筛选条件没有可导出的日志"])
assert.equal(requests.length, 0)
assert.equal(errors.at(-1), "请选择有效的日志创建时间范围")
state.state.queryForm.createTime = ["2026-10-30 00:00:00", "2026-10-29 00:00:00"]
await state.exportExcel()
assert.equal(requests.length, 0)
assert.equal(errors.at(-1), "日志创建时间的开始时间不能晚于结束时间")
state.state.queryForm.createTime = ["2026-10-29 00:00:00", "2026-10-30 00:00:00"]
await state.exportExcel()
assert.equal(requests.length, 1)
state.state.queryForm.createTime = null
await state.exportExcel()
assert.equal(requests.length, 1, "执行中的任务继续查看进度,不受新筛选条件影响")
state.handleExportFailure({ message: "当前筛选条件没有可导出的日志" })
assert.equal(errors.at(-1), "当前筛选条件没有可导出的日志")
state.state.queryForm.createTime = ["2026-10-28 00:00:00", "2026-10-29 00:00:00"]
await state.exportExcel()
assert.equal(requests.length, 2)
assert.deepEqual(requests[1].data.createTime, [])
})