ForgeFlow-ERP/frontend/src/App.test.js

32 lines
1.5 KiB
JavaScript

import assert from "node:assert/strict";
import { describe, it } from "node:test";
import { readFileSync } from "node:fs";
import { dirname, join } from "node:path";
import { fileURLToPath } from "node:url";
const __dirname = dirname(fileURLToPath(import.meta.url));
const source = readFileSync(join(__dirname, "App.vue"), "utf8");
describe("App reset password account picker", () => {
it("uses a searchable system-user select instead of free text input", () => {
assert.match(source, /<select[\s\S]*?v-model="resetPasswordForm\.username"[\s\S]*?required[\s\S]*?>/);
assert.doesNotMatch(source, /placeholder="请输入需要重置密码的账号"/);
});
it("loads reset password account options from system permission users", () => {
assert.match(source, /fetchResource\("\/system-permissions\/users", \[\]\)/);
assert.match(source, /resetPasswordUserOptions/);
assert.match(source, /formatResetPasswordUserLabel\(user\)/);
});
});
describe("App user menu interactions", () => {
it("closes the avatar menu when the user clicks outside the menu shell", () => {
assert.match(source, /ref="userMenuShellRef"/);
assert.match(source, /function handleUserMenuOutsidePointerDown\(event\)/);
assert.match(source, /userMenuShellRef\.value\?\.contains\(event\.target\)/);
assert.match(source, /document\.addEventListener\("pointerdown", handleUserMenuOutsidePointerDown\)/);
assert.match(source, /document\.removeEventListener\("pointerdown", handleUserMenuOutsidePointerDown\)/);
});
});