import { describe, it, expect } from "vitest";
import { readFileSync } from "node:fs";
import { resolve } from "node:path";

describe("Equipment Detail Page (prototype port)", () => {
  const pagePath = resolve(__dirname, "../../pages/mietkatalog/[id].vue");
  const content = readFileSync(pagePath, "utf-8");

  it("should have breadcrumb navigation back to mietkatalog", () => {
    expect(content).toContain("Zurück zum Katalog");
    expect(content).toContain("/mietkatalog");
  });

  it("should display equipment name", () => {
    expect(content).toContain("item.name");
  });

  it("should display item code", () => {
    expect(content).toContain("item.code");
    expect(content).toContain("Artikelnummer");
  });

  it("should display brand", () => {
    expect(content).toContain("item.brand");
    expect(content).toContain("Marke");
  });

  it("should display description", () => {
    expect(content).toContain("item.description");
  });

  it("should display specs table", () => {
    expect(content).toContain("item.specs");
    expect(content).toContain("Technische Daten");
  });

  it("should display image with placeholder fallback", () => {
    expect(content).toContain("item.image");
    expect(content).toContain("📦");
    expect(content).toContain("Kein Bild verfügbar");
  });

  it("should have Mietanfrage section", () => {
    expect(content).toContain("Mietanfrage");
    expect(content).toContain("Mietbeginn");
    expect(content).toContain("Mietende");
  });

  it("should have quantity selector", () => {
    expect(content).toContain("quantity");
    expect(content).toContain("Anzahl");
  });

  it("should have add to cart button", () => {
    expect(content).toContain("Zur Mietanfrage hinzufügen");
    expect(content).toContain("hms-btn-primary");
  });

  it("should show ErrorState for non-existent ID", () => {
    expect(content).toContain("ErrorState");
    expect(content).toContain("nicht gefunden");
  });

  it("should have related items section", () => {
    expect(content).toContain("relatedItems");
    expect(content).toContain("Ähnliche Geräte");
    expect(content).toContain("EquipmentCard");
  });

  it("should use loading skeleton", () => {
    expect(content).toContain("hms-skeleton");
    expect(content).toContain("loading");
  });

  it("should use TypeScript with lang=ts", () => {
    expect(content).toContain('<script setup lang="ts">');
  });

  it("should have 18 equipment items in data", () => {
    expect(content).toContain("L-Acoustics K2");
    expect(content).toContain("Sennheiser EW-DX 835");
  });
});
