/** * tests/unit/quota-share-layout-v2.test.ts * * Task 4 — source-level assertions for the "all groups" default, * stacked group sections, and 3-column card grid in QuotaSharePageClient. * * Pattern mirrors tests/unit/quota-groups-ui.test.ts (source-scan). * Node.js native test runner — no DOM setup required. */ import test from "node:test"; import assert from "node:assert/strict"; import { readFileSync } from "node:fs"; import { join, dirname } from "node:path"; import { fileURLToPath } from "node:url"; const ROOT = join(dirname(fileURLToPath(import.meta.url)), "..", ".."); const PAGE_CLIENT_PATH = join( ROOT, "src/app/(dashboard)/dashboard/costs/quota-share/QuotaSharePageClient.tsx" ); const EN_PATH = join(ROOT, "src/i18n/messages/en.json"); const PT_PATH = join(ROOT, "src/i18n/messages/pt-BR.json"); const pageSrc = readFileSync(PAGE_CLIENT_PATH, "utf8"); // ── 1. Default state is "all" ──────────────────────────────────────────────── test('QuotaSharePageClient: selectedGroupId defaults to "all"', () => { assert.ok( pageSrc.includes('useState("all")'), 'QuotaSharePageClient must default selectedGroupId to "all" via useState("all")' ); }); // ── 2. "All groups" option in has an option with value="all" using t("allGroups")', () => { assert.ok( pageSrc.includes('value="all"'), 'QuotaSharePageClient