import { expect, test } from "../support/browser/strict-browser-test.ts"; // 08-04. Tailwind's preflight resets every heading to the body size and // weight, so a section title read like a paragraph. Each level must stand // apart from the next one and from body copy. test("steps heading size and weight down from h2 to body copy", async ({ page, }) => { // Section titles (h2) and card titles (h3) on the platform overview. await page.goto("/examples/platform"); await expect(page.getByRole("heading", { level: 1 })).toBeVisible(); const scale = await page.evaluate(() => { const read = (element: Element | null) => { if (!element) throw new Error("missing element"); const style = getComputedStyle(element); return { size: Number.parseFloat(style.fontSize), weight: Number.parseFloat(style.fontWeight), }; }; const main = document.querySelector("main"); return { h2: read(main?.querySelector("h2") ?? null), h3: read(main?.querySelector("h3") ?? null), body: read(document.body), }; }); expect(scale.h2.size).toBeGreaterThan(scale.h3.size); expect(scale.h3.size).toBeGreaterThan(scale.body.size); expect(scale.h2.weight).toBeGreaterThan(scale.body.weight); expect(scale.h3.weight).toBeGreaterThan(scale.body.weight); }); // 08-06. The browser default breaks Korean between any two syllables, so a // button read "로그 / 인". Korean text breaks between words; a single word // longer than its box still wraps instead of overflowing. test("breaks Korean text between words, not inside them", async ({ page }) => { await page.goto("/"); await expect(page.locator("html")).toHaveAttribute("lang", "ko-KR"); const wrapping = await page.locator("body").evaluate((body) => { const style = getComputedStyle(body); return { wordBreak: style.wordBreak, overflowWrap: style.overflowWrap }; }); expect(wrapping).toEqual({ wordBreak: "keep-all", overflowWrap: "break-word" }); });