Scert/frontend/src/views/PasswordReset/PasswordReset.test.js
xuans 6f702cdc36 完成公网密码重置安全阻断
关闭公开密码重置流程,统一显示运维协助提示,保留本机受保护重置方向,并更新前端回归测试与整改清单。
2026-10-04 13:01:52 +08:00

27 lines
1.2 KiB
JavaScript

import assert from "node:assert/strict";
import { readFileSync } from "node:fs";
import test from "node:test";
import { baseParse } from "@vue/compiler-dom";
import { parse } from "@vue/compiler-sfc";
function template(path) {
const source = readFileSync(new URL(path, import.meta.url), "utf8");
return baseParse(parse(source).descriptor.template.content);
}
function elements(node, predicate, matches = []) {
if (predicate(node)) matches.push(node);
for (const child of node.children || []) elements(child, predicate, matches);
return matches;
}
test("公开密码重置页面只显示安全阻断提示", () => {
const root = template("./PasswordReset.vue");
const source = readFileSync(new URL("./PasswordReset.vue", import.meta.url), "utf8");
assert.match(source, /当前方式无法使用/);
assert.match(source, /请联系运维人员辅助解决/);
assert.doesNotMatch(source, /fetch\(|password-reset\/resolve|systemctl|scert-admin/iu);
assert.equal(elements(root, (node) => node.tag === "form").length, 0);
assert.equal(elements(root, (node) => node.tag === "input").length, 0);
assert.equal(elements(root, (node) => node.tag === "button").length, 0);
});