import assert from "node:assert/strict";
import { describe, it } from "node:test";
import { readFileSync } from "node:fs";
import { dirname, join, resolve } from "node:path";
import { fileURLToPath } from "node:url";

const __dirname = dirname(fileURLToPath(import.meta.url));
const source = readFileSync(join(__dirname, "LoginView.vue"), "utf8");
const mainCss = readFileSync(resolve(__dirname, "../styles/main.css"), "utf8");

describe("LoginView industrial technology redesign", () => {
  it("renders a separated production line and right-side login console without visual overlap", () => {
    assert.match(source, /class="[^"]*login-industrial-stage/);
    assert.match(source, /class="[^"]*login-production-layout/);
    assert.match(source, /class="login-kinetic-field"/);
    assert.match(source, /class="login-production-cockpit"/);
    assert.match(source, /class="login-line-area"/);
    assert.match(source, /class="login-line-brand"/);
    assert.match(source, /class="login-production-line"/);
    assert.match(source, /class="login-line-machine"/);
    assert.match(source, /class="[^"]*login-forge-beam/);
    assert.match(source, /class="login-press-aura"/);
    assert.match(source, /class="login-part-runner"/);
    assert.match(source, /class="[^"]*login-heat-column/);
    assert.match(source, /class="login-conveyor-label"/);
    assert.match(source, /class="login-console-link"/);
    assert.match(source, /class="login-console-dock"/);
    assert.match(source, /class="[^"]*login-dock-rail/);
    assert.match(source, /class="login-dock-floor"/);
    assert.match(source, /class="login-console-frame"/);
    assert.match(source, /class="login-control-console"/);
    assert.doesNotMatch(source, /class="login-holo-press"/);
    assert.doesNotMatch(source, /class="login-flow-ribbon"/);
    assert.doesNotMatch(source, /class="login-flow-chip"/);
    assert.doesNotMatch(source, /class="login-photo-bg"/);
    assert.doesNotMatch(source, /class="login-command-deck"/);
    assert.doesNotMatch(source, /class="login-auth-card"/);
    assert.doesNotMatch(source, /class="login-process-node/);
    assert.doesNotMatch(source, /class="login-hero-copy"/);
    assert.doesNotMatch(source, /ForgeFlow ERP/);
    assert.doesNotMatch(source, /五金产线接入中/);
    assert.doesNotMatch(source, /库存批次 \/ 生产台账 \/ 成本追溯/);
    assert.doesNotMatch(source, /SECURE ACCESS/);
    assert.doesNotMatch(source, /以材料批次为线索/);
    assert.doesNotMatch(source, /系统账号、角色与菜单权限/);
    assert.match(source, /class="login-input-shell"/);
  });

  it("uses premium line icons for the industrial login affordances", () => {
    assert.match(source, /<AppIcon name="warehouseFinished"/);
    assert.match(source, /<AppIcon name="production"/);
    assert.match(source, /<AppIcon name="quality"/);
    assert.match(source, /<AppIcon name="material"/);
    assert.match(source, /<AppIcon name="employee"/);
    assert.match(source, /<AppIcon name="permissions"/);
  });

  it("adds a responsive industrial visual system with restrained motion", () => {
    assert.match(mainCss, /--login-forge-blue:/);
    assert.match(mainCss, /\.login-industrial-stage/);
    assert.match(mainCss, /\.login-production-layout/);
    assert.match(mainCss, /\.login-production-cockpit/);
    assert.match(mainCss, /\.login-line-area/);
    assert.match(mainCss, /\.login-production-line/);
    assert.match(mainCss, /\.login-forge-beam/);
    assert.match(mainCss, /\.login-press-aura/);
    assert.match(mainCss, /\.login-part-runner/);
    assert.match(mainCss, /\.login-heat-column/);
    assert.match(mainCss, /\.login-console-link/);
    assert.match(mainCss, /\.login-console-dock/);
    assert.match(mainCss, /\.login-dock-rail/);
    assert.match(mainCss, /\.login-dock-floor/);
    assert.match(mainCss, /\.login-console-frame/);
    assert.match(mainCss, /\.login-kinetic-field/);
    assert.match(mainCss, /\.login-control-console/);
    assert.match(mainCss, /\.login-press-hammer/);
    assert.doesNotMatch(mainCss, /0 38px 110px rgba\(0, 0, 0, 0\.42\)/);
    assert.doesNotMatch(mainCss, /jiaheng-office-bg\.jpg/);
    assert.match(mainCss, /@keyframes loginScanSweep/);
    assert.match(mainCss, /@keyframes loginMetalTravel/);
    assert.match(mainCss, /@keyframes loginPressStamp/);
    assert.match(mainCss, /@keyframes loginSteelPulse/);
    assert.match(mainCss, /@keyframes loginForgeBeam/);
    assert.match(mainCss, /@keyframes loginPartRun/);
    assert.match(mainCss, /@keyframes loginHeatRise/);
    assert.match(mainCss, /@keyframes loginDockSignal/);
    assert.match(mainCss, /@keyframes loginDockBreathe/);
    assert.match(mainCss, /@keyframes loginFactoryDepth/);
    assert.match(mainCss, /@media \(prefers-reduced-motion: reduce\)[\s\S]*loginScanSweep/);
    assert.match(mainCss, /@media \(max-width: 900px\)[\s\S]*\.login-production-cockpit/);
  });
});
