forked from jiaoly/financial_system
89 lines
2.9 KiB
TypeScript
89 lines
2.9 KiB
TypeScript
declare const process: { cwd(): string };
|
|
declare function require(name: string): {
|
|
readFileSync?: (path: string, encoding: string) => string;
|
|
join?: (...parts: string[]) => string;
|
|
};
|
|
|
|
const { readFileSync } = require("node:fs");
|
|
const { join } = require("node:path");
|
|
|
|
if (!readFileSync || !join) {
|
|
throw new Error("测试运行环境缺少文件读取能力");
|
|
}
|
|
|
|
const root = process.cwd();
|
|
|
|
const pages = [
|
|
"RealtimeAttendanceView.vue",
|
|
"ConfigCenterView.vue",
|
|
"ReportsView.vue",
|
|
"OperationLogsView.vue",
|
|
"UsersView.vue",
|
|
"CommissionsView.vue",
|
|
"MonthlyPayrollView.vue",
|
|
"EmployeesView.vue",
|
|
"SalaryProfilesView.vue",
|
|
"OrganizationView.vue",
|
|
];
|
|
|
|
for (const page of pages) {
|
|
const content = readFileSync(join(root, "src/views", page), "utf-8");
|
|
assertNotIncludes(content, "<span>刷新</span>", `${page} 不应展示无业务含义的刷新按钮`);
|
|
}
|
|
|
|
const realtimeView = readView("RealtimeAttendanceView.vue");
|
|
assertIncludes(realtimeView, "同步钉钉");
|
|
assertIncludes(realtimeView, "@change=\"loadTodayAttendance\"");
|
|
assertNotIncludes(realtimeView, "RefreshCw");
|
|
|
|
const reportsView = readView("ReportsView.vue");
|
|
assertIncludes(reportsView, "查询");
|
|
assertIncludes(reportsView, "@submit.prevent=\"loadReport\"");
|
|
assertNotIncludes(reportsView, "RefreshCw");
|
|
|
|
const configView = readView("ConfigCenterView.vue");
|
|
assertIncludes(configView, "恢复默认规则");
|
|
assertIncludes(configView, "保存");
|
|
assertNotIncludes(configView, "RefreshCw");
|
|
|
|
const commissionView = readView("CommissionsView.vue");
|
|
assertIncludes(commissionView, "导入Excel");
|
|
assertIncludes(commissionView, "新增提成");
|
|
assertNotIncludes(commissionView, "RefreshCw");
|
|
|
|
const monthlyView = readView("MonthlyPayrollView.vue");
|
|
assertIncludes(monthlyView, "同步钉钉核算");
|
|
assertIncludes(monthlyView, "导入 Excel 核算");
|
|
assertNotIncludes(monthlyView, "RefreshCw");
|
|
|
|
const employeesView = readView("EmployeesView.vue");
|
|
assertIncludes(employeesView, "新增员工");
|
|
assertIncludes(employeesView, "在职员工");
|
|
assertNotIncludes(employeesView, "RefreshCw");
|
|
|
|
const salaryProfilesView = readView("SalaryProfilesView.vue");
|
|
assertIncludes(salaryProfilesView, "薪资档案");
|
|
assertIncludes(salaryProfilesView, "编辑");
|
|
assertNotIncludes(salaryProfilesView, "RefreshCw");
|
|
|
|
const organizationView = readView("OrganizationView.vue");
|
|
assertIncludes(organizationView, "新增部门");
|
|
assertIncludes(organizationView, "新增岗位");
|
|
assertNotIncludes(organizationView, "RefreshCw");
|
|
|
|
function readView(filename: string): string {
|
|
return readFileSync(join(root, "src/views", filename), "utf-8");
|
|
}
|
|
|
|
function assertIncludes(content: string, expected: string): void {
|
|
if (!content.includes(expected)) {
|
|
throw new Error(`期望包含 ${expected}`);
|
|
}
|
|
}
|
|
|
|
function assertNotIncludes(content: string, unexpected: string, message?: string): void {
|
|
if (content.includes(unexpected)) {
|
|
throw new Error(message || `不应包含 ${unexpected}`);
|
|
}
|
|
}
|