import { describe, expect, test } from "bun:test";
import { readFileSync } from "node:fs";

const read = (path: string) => readFileSync(path, "utf8");

describe("legacy design migration", () => {
	test("global styles remove obsolete glass helpers once console surfaces take over", () => {
		const source = read("src/app/globals.css");

		expect(source).not.toContain(".glass-surface");
		expect(source).not.toContain(".glass-panel");
		expect(source).not.toContain(".glass-subtle");
		expect(source).not.toContain(".glass-card");
		expect(source).not.toContain(".glass-strong");
	});

	test("layout metadata and toast surface use redesign language", () => {
		const layout = read("src/app/layout.tsx");
		const manifest = read("src/app/manifest.ts");

		expect(layout).not.toContain("Local iCal");
		expect(layout).not.toContain("editor for calendar events");
		expect(layout).not.toContain("glass-strong");
		expect(layout).toContain('defaultTheme="light"');
		expect(layout).toContain("enableColorScheme");
		expect(manifest).not.toContain("local-ical");
		expect(manifest).not.toContain("Local iCal editor");
		expect(manifest).toContain('theme_color: "#ffffff"');
	});

	test("auth screens use console surfaces instead of old glass cards", () => {
		const signIn = read("src/app/auth/signin/sign-in-form.tsx");
		const signOut = read("src/app/auth/signout/page.tsx");
		const errorPage = read("src/app/auth/error/page.tsx");

		expect(signIn).not.toContain("glass-strong");
		expect(signOut).not.toContain("glass-strong");
		expect(errorPage).not.toContain("glass-strong");
		expect(signIn).not.toContain("rounded-2xl");
		expect(signOut).not.toContain("rounded-2xl");
		expect(errorPage).not.toContain("rounded-2xl");
	});

	test("auth and app copy use timeline-first language", () => {
		const signIn = read("src/app/auth/signin/sign-in-form.tsx");
		const errorPage = read("src/app/auth/error/page.tsx");
		const settings = read("src/components/settings-panel.tsx");

		expect(signIn).not.toContain("Local iCal");
		expect(signIn).not.toContain("event creation");
		expect(errorPage).not.toContain("Homepage");
		expect(settings).not.toContain("review modal");
	});

	test("overlay surfaces use console framing instead of blur-heavy legacy treatments", () => {
		const autocomplete = read("src/components/location-autocomplete.tsx");
		const dragDrop = read("src/components/drag-drop-container.tsx");

		expect(autocomplete).not.toContain("backdrop-blur-sm");
		expect(autocomplete).toContain("rounded-[10px]");
		expect(dragDrop).not.toContain("rounded-xl");
		expect(dragDrop).not.toContain("backdrop-blur-sm");
		expect(dragDrop).toContain("rounded-[10px]");
	});

	test("settings internal rows drop the old bordered mini-card treatment", () => {
		const settings = read("src/components/settings-panel.tsx");

		expect(settings).not.toContain("rounded-xl border border-border/60 bg-muted/35");
	});
});
