Files
solon/tests/e2e/render.spec.ts
CatoandClaude Opus 5.5 d423d3ccbf feat(site): use cases, the ideas behind Solon, a new era, platform, and a mega menu
Phases B and C of docs/design/2026-09-solon-plan.md, plus George's
2026-09-25 asks (a page per kind of group and one comparing them, network
states, the art and science of governance, how Solon works with OrangeCat
and Loki, a best-in-class menu).

- /for compares companies, villages and towns, associations and co-ops,
  communities and network states side by side; /for/<slug> is one page per
  group (what goes wrong today, how Solon helps, example decisions, the rule
  template, what works today, the detail folded). Network states get the
  verified definition (Srinivasan 2022) and the seven-step path mapped to
  Solon, with a neutral stance and honest statuses.
- /governance/ideas: Solon of Athens, the Landsgemeinde (Glarus as the
  model; Appenzell's 1990 court ruling as the lesson on who counts),
  Condorcet and Arrow, Ostrom, exit and voice, panarchy and Nozick, charter
  cities, the network state — every claim checked against sources, with
  the caveats the sources insist on.
- /governance/new-era: records, money, work, connection, making, energy —
  what changed, what it means, and the limit of each; what technology
  cannot do. SMR status stated as of 2026, not hyped.
- /platform: Solon decides, OrangeCat pays, Loki works; one decision start
  to finish; what works today vs next; "evidence, not authority" folded.
- Mega menu: four panels (use cases, governance, platform, decisions),
  each with summary, every page described in one line, and a featured
  photograph; click to open, Escape/outside/navigation to close; the
  mobile menu and footer render the same map (site-config MENU).
- lib/content/capabilities.ts is the one list of what is available now,
  in development or planned; pages show status from it, never their own.
- Deeper component for progressive disclosure; two new photographs
  (Museum Appenzell painting, public domain; Starlink over Tübingen's town
  hall, CC0), both on /credits.
- New essays are English-first (PENDING_TRANSLATION in the parity test);
  navigation and home stay translated in all five languages.
- CI: a production-shaped smoke runs the standalone server behind a TLS
  proxy header — the combination that 500'd production today while every
  other check was green.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Signed-off-by: Cato <41178744+catomean@users.noreply.github.com>
2026-09-25 13:43:25 +02:00

96 lines
4.1 KiB
TypeScript

import { test, expect, type Page } from "@playwright/test";
import { PRIMARY_NAV, SITE_LINKS } from "../../src/lib/site-config";
import en from "../../messages/en.json";
/**
* What lint, typecheck and unit tests cannot see: how the site actually
* renders. Every check here is a bug that shipped once.
*
* - `.btn-primary` lost its only definition and every page's main action
* rendered as bare text on production for weeks.
* - The header's six menus wrapped onto two lines at 1440px.
* - A table inside a grid pushed the whole phone layout sideways.
* - The mobile menu opened to nothing: a `fixed` panel inside a header with
* backdrop-filter is positioned against the header, not the screen.
*/
const internal = SITE_LINKS.filter((l) => l.href.startsWith("/"));
test.describe("every page renders", () => {
for (const link of [{ href: "/" }, ...internal]) {
test(`${link.href} answers 200`, async ({ page }) => {
const res = await page.goto(link.href, { waitUntil: "domcontentloaded" });
expect(res?.status()).toBe(200);
});
}
});
async function background(page: Page, selector: string): Promise<string> {
return page
.locator(selector)
.first()
.evaluate((el) => getComputedStyle(el).backgroundColor);
}
test("the primary actions are styled", async ({ page }) => {
await page.goto("/", { waitUntil: "domcontentloaded" });
// A class with no CSS behind it renders transparent — the #77 regression.
expect(await background(page, ".btn-frame-accent")).not.toBe("rgba(0, 0, 0, 0)");
await page.goto("/join", { waitUntil: "domcontentloaded" });
const primary = page.locator(".btn-primary");
if ((await primary.count()) > 0) {
expect(await background(page, ".btn-primary")).not.toBe("rgba(0, 0, 0, 0)");
}
});
test("the header fits on one line at 1440px", async ({ page }) => {
await page.setViewportSize({ width: 1440, height: 900 });
await page.goto("/", { waitUntil: "domcontentloaded" });
const { headerHeight, navHeight } = await page.evaluate(() => ({
headerHeight: document.querySelector("header")?.getBoundingClientRect().height ?? 0,
navHeight: parseFloat(
getComputedStyle(document.documentElement).getPropertyValue("--public-nav-height"),
),
}));
expect(headerHeight).toBeGreaterThan(0);
expect(headerHeight).toBeLessThanOrEqual(navHeight + 1);
const header = page.locator("header").first();
for (const item of PRIMARY_NAV) {
const trigger = header.getByRole("button", { name: en.Site.sections[item.key] });
const b = await trigger.boundingBox();
// One line of text: the trigger is 16px of text plus 16px of padding
// (32px); a label wrapped onto a second line adds ~16px.
expect(b?.height ?? 0).toBeLessThan(40);
}
});
test.describe("phones", () => {
test.use({ viewport: { width: 390, height: 844 } });
for (const href of ["/", "/hire", "/security", "/governance", "/proposals", "/dashboard"]) {
test(`${href} does not scroll sideways`, async ({ page }) => {
await page.goto(href, { waitUntil: "domcontentloaded" });
const overflow = await page.evaluate(
() => document.documentElement.scrollWidth - window.innerWidth,
);
expect(overflow).toBeLessThanOrEqual(0);
});
}
test("the menu opens and lists the site", async ({ page }) => {
await page.goto("/", { waitUntil: "domcontentloaded" });
const menu = page.locator("#site-menu");
// The page may not have hydrated yet at domcontentloaded, so a first click
// can land on inert HTML. Click only while the menu is still closed.
await expect(async () => {
if (!(await menu.isVisible())) await page.getByRole("button", { name: "Open menu" }).click();
await expect(menu).toBeVisible({ timeout: 1_000 });
}).toPass({ timeout: 20_000 });
const box = await menu.boundingBox();
// It must cover the screen below the header, not collapse inside it.
expect(box?.height ?? 0).toBeGreaterThan(400);
await expect(menu.getByRole("link", { name: "Hire Solon" }).first()).toBeVisible();
await expect(menu.getByRole("link", { name: "Security" })).toBeVisible();
});
});