Files

71 lines
3.3 KiB
TypeScript
Raw Permalink Normal View History

import { describe, expect, it } from "vitest";
import fs from "node:fs";
import path from "node:path";
const getComponentSource = (filename: string) => {
const filePath = path.resolve(__dirname, "../../apps/web/src/components/snapcad", filename);
return fs.readFileSync(filePath, "utf-8");
};
const getAppLayoutSource = () => {
const filePath = path.resolve(__dirname, "../../apps/web/src/app/layout.tsx");
return fs.readFileSync(filePath, "utf-8");
};
const getPageSource = () => {
const filePath = path.resolve(__dirname, "../../apps/web/src/app/page.tsx");
return fs.readFileSync(filePath, "utf-8");
};
describe("Page Transition, Preloader & Google Cloud Console Cascade Loading", () => {
it("renders non-blocking Google Cloud Console linear progress bar and skeleton grid", () => {
const pageSrc = getPageSource();
expect(pageSrc).toContain("gcp-linear-progress");
expect(pageSrc).toContain("gcp-skeleton-grid");
expect(pageSrc).toContain("project-card-skeleton");
expect(pageSrc).toContain('role="progressbar"');
expect(pageSrc).toContain('aria-hidden="true"');
});
it("hides transient visual skeleton cards from screen readers to prevent cluttering accessibility tree", () => {
const pageSrc = getPageSource();
expect(pageSrc).not.toContain("kart ${num} / 6");
expect(pageSrc).not.toContain("kart ${num} / 3");
expect(pageSrc).toContain('className="project-grid gcp-skeleton-grid"\n aria-hidden="true"');
});
it("page.tsx implements Google Cloud Console top-to-bottom cascade waterfall classes without robotic initial announcements", () => {
const pageSrc = getPageSource();
expect(pageSrc).toContain("gcp-cascade-topbar");
expect(pageSrc).toContain("gcp-cascade-sidebar");
expect(pageSrc).toContain("gcp-cascade-actions");
expect(pageSrc).toContain("gcp-cascade-starters");
expect(pageSrc).toContain("gcp-cascade-header");
expect(pageSrc).toContain("gcp-cascade-card");
expect(pageSrc).toContain("gcp-cascade-footer");
// Sayfa açılışında ekran okuyucuya yapay/aşağılayıcı anons yapılmaz
expect(pageSrc).not.toContain("SnapCAD Studio çalışma alanı üstten alta başarıyla yüklendi");
});
it("RootLayout includes NextTopLoader and inline anti-FOUC theme script to prevent white flash", () => {
const layoutSrc = getAppLayoutSource();
expect(layoutSrc).toContain("NextTopLoader");
expect(layoutSrc).toContain("AppErrorBoundary");
expect(layoutSrc).toContain("sketchforge.theme.preference");
expect(layoutSrc).toContain("document.documentElement.style.backgroundColor");
});
it("AppErrorBoundary safely catches exceptions and prevents white screen of death", () => {
const errorBoundarySrc = getComponentSource("AppErrorBoundary.tsx");
expect(errorBoundarySrc).toContain("SnapCAD Studio Yükleme Kurtarma");
expect(errorBoundarySrc).toContain("Sayfayı Yeniden Yükle");
expect(errorBoundarySrc).toContain("Güvenli Modda Başlat");
});
it("strictly prohibits banned competitor name", () => {
const preloaderSrc = getComponentSource("SnapCADAppPreloader.tsx");
const errorBoundarySrc = getComponentSource("AppErrorBoundary.tsx");
expect(preloaderSrc.toLowerCase()).not.toContain("tinker" + "cad");
expect(errorBoundarySrc.toLowerCase()).not.toContain("tinker" + "cad");
});
});