import { describe, it, expect } from "bun:test";
import app from "../app";
const HOME = "/";
async function fetchHomeHtml(): Promise<string> {
const res = await app.request(HOME);
expect(res.status).toBe(200);
return await res.text();
}
describe("Block U1 — landing hero rebuild", () => {
it("renders exactly two primary CTAs in the main button row", async () => {
const body = await fetchHomeHtml();
const start = body.indexOf('data-testid="hero-primary-ctas"');
expect(start).toBeGreaterThan(-1);
const tail = body.slice(start, start + 2400);
const anchorMatches = tail.match(/<a[^>]*class="btn[^"]*"/g) || [];
expect(anchorMatches.length).toBeGreaterThanOrEqual(2);
expect(tail).toContain('href="/register"');
expect(tail).toContain('href="/gluecron.dxt"');
const primaryRowEnd = tail.indexOf("hero-tertiary-row");
const primaryOnly =
primaryRowEnd > 0 ? tail.slice(0, primaryRowEnd) : tail.slice(0, 800);
expect(primaryOnly).not.toContain('href="/demo"');
expect(primaryOnly).not.toContain('href="/vs-github"');
});
it("renders the tertiary text-link row with demo + vs-github affordances", async () => {
const body = await fetchHomeHtml();
expect(body).toContain('data-testid="hero-tertiary-row"');
expect(body).toContain('data-testid="cta-tertiary-demo"');
expect(body).toContain('data-testid="cta-tertiary-vs"');
expect(body).toContain("Try the live demo");
expect(body).toContain("Compare to GitHub");
});
it("places the install snippet inside a 'For power users' panel below the CTAs", async () => {
const body = await fetchHomeHtml();
const ctas = body.indexOf('data-testid="hero-primary-ctas"');
const installPanel = body.indexOf("Power users install panel");
const installLabel = body.indexOf("For power users");
expect(ctas).toBeGreaterThan(-1);
expect(installPanel).toBeGreaterThan(-1);
expect(installLabel).toBeGreaterThan(-1);
expect(installPanel).toBeGreaterThan(ctas);
});
});
describe("Block U2 — button polish", () => {
it("includes the universal hover-lift transform on .btn", async () => {
const body = await fetchHomeHtml();
expect(body).toMatch(/\.btn:hover\b[\s\S]*?transform:\s*translateY\(-1px\)/);
});
it("uses a soft drop shadow on .btn:hover (not just border)", async () => {
const body = await fetchHomeHtml();
expect(body).toMatch(/\.btn:hover\b[\s\S]*?box-shadow:\s*0\s+4px\s+12px/);
});
it("uses box-shadow (not outline) for the .btn focus ring", async () => {
const body = await fetchHomeHtml();
expect(body).toMatch(
/\.btn:focus-visible\b[\s\S]*?box-shadow:\s*0\s+0\s+0\s+3px\s+rgba\(140,\s*109,\s*255,\s*0\.35\)/
);
expect(body).not.toMatch(/\.btn:focus-visible[^{]*\{\s*outline:\s*2px/);
});
it("disables hover-lift on disabled buttons", async () => {
const body = await fetchHomeHtml();
expect(body).toMatch(/\.btn:disabled[\s\S]*?transform:\s*none/);
expect(body).toMatch(/\.btn:disabled[\s\S]*?opacity:\s*0\.5/);
});
it("shimmers the primary CTA via background-position transition", async () => {
const body = await fetchHomeHtml();
expect(body).toMatch(/\.btn-primary\b[\s\S]*?background-size:\s*200%/);
expect(body).toMatch(
/\.btn-primary\b[\s\S]*?transition:[\s\S]*?background-position\s+600ms/
);
});
});
describe("Block U4 — view transitions", () => {
it("includes the @view-transition opt-in", async () => {
const body = await fetchHomeHtml();
expect(body).toContain("@view-transition");
expect(body).toMatch(/@view-transition\s*\{\s*navigation:\s*auto;?\s*\}/);
});
it("declares both fade-out and fade-in keyframes for ::view-transition-*", async () => {
const body = await fetchHomeHtml();
expect(body).toContain("::view-transition-old(root)");
expect(body).toContain("::view-transition-new(root)");
expect(body).toContain("@keyframes vt-fade-out");
expect(body).toContain("@keyframes vt-fade-in");
});
it("disables the transition under prefers-reduced-motion", async () => {
const body = await fetchHomeHtml();
expect(body).toMatch(
/@media\s*\(prefers-reduced-motion:\s*reduce\)\s*\{[\s\S]*?::view-transition-(old|new)\(root\)[\s\S]*?animation-duration:\s*0s/
);
});
it("attaches view-transition-name: root to body", async () => {
const body = await fetchHomeHtml();
expect(body).toMatch(/\bbody\b\s*\{[^}]*view-transition-name:\s*root/);
});
});
|