declare const process: { cwd(): string };
declare function require(name: string): {
  existsSync?: (path: string) => boolean;
  readFileSync?: (path: string, encoding: string) => string;
  join?: (...parts: string[]) => string;
};

const { existsSync, readFileSync } = require("node:fs");
const { join } = require("node:path");

if (!existsSync || !readFileSync || !join) {
  throw new Error("测试运行环境缺少文件读取能力");
}

const root = process.cwd();
const loginView = readFileSync(join(root, "src/views/LoginView.vue"), "utf-8");
const css = readFileSync(join(root, "src/assets/styles.css"), "utf-8");
const backgroundPath = join(root, "src/assets/login-background.png");

assertIncludes(loginView, "login-background-layer");
assertIncludes(css, "url(\"./login-background.png\")");
assertIncludes(css, ".login-background-layer");
assertIncludes(css, ".login-visual::before");
assertIncludes(css, ".login-visual::after");

if (!existsSync(backgroundPath)) {
  throw new Error("登录页背景图资产不存在");
}

function assertIncludes(content: string, expected: string): void {
  if (!content.includes(expected)) {
    throw new Error(`期望包含 ${expected}`);
  }
}
