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 view = readFileSync(join(process.cwd(), "src/views/SalaryProfilesView.vue"), "utf-8");
const css = readFileSync(join(process.cwd(), "src/assets/styles.css"), "utf-8");
assertIncludes(view, "salary-profile-list-tools");
assertIncludes(view, "salary-profile-edit-modal");
assertIncludes(view, "salary-profile-edit-card");
assertIncludes(view, "薪资结构一览");
assertIncludes(view, "编辑薪资");
assertIncludes(view, "
");
assertNotIncludes(view, "salary-profile-card-grid");
assertNotIncludes(view, "salary-profile-form-panel");
assertBefore(view, "薪资结构一览", "salary-profile-edit-modal");
assertIncludes(css, ".salary-profile-list-tools");
assertIncludes(css, ".salary-profile-table");
assertIncludes(css, ".salary-profile-edit-modal");
assertIncludes(css, ".salary-profile-edit-card");
function assertIncludes(content: string, expected: string): void {
if (!content.includes(expected)) {
throw new Error(`期望包含 ${expected}`);
}
}
function assertNotIncludes(content: string, unexpected: string): void {
if (content.includes(unexpected)) {
throw new Error(`不应包含 ${unexpected}`);
}
}
function assertBefore(content: string, earlier: string, later: string): void {
const earlierIndex = content.indexOf(earlier);
const laterIndex = content.indexOf(later);
if (earlierIndex === -1 || laterIndex === -1 || earlierIndex >= laterIndex) {
throw new Error(`期望 ${earlier} 出现在 ${later} 之前`);
}
}