diff --git a/tests/unit/quota-card-grid-compact-layout-8916.test.ts b/tests/unit/quota-card-grid-compact-layout-8916.test.ts new file mode 100644 index 0000000000..bfb445b0f8 --- /dev/null +++ b/tests/unit/quota-card-grid-compact-layout-8916.test.ts @@ -0,0 +1,166 @@ +// PR #8916 — Provider quota compact layout mode. +// +// #8916 added a `compact` prop to QuotaCardGrid and ProviderQuotaWidget that +// forces a flat multi-column card grid instead of the upstream 3.8.49 +// provider-group sidebar layout. This guard verifies the compact mode's +// grid-rendering code survives mechanical edits and refactors. +// +// Three structural assertions: +// +// 1. QuotaCardGrid renders a `grid-cols-[repeat(auto-fill,minmax(17rem,1fr))]` +// container when `compact` is true (before any provider-group branching). +// 2. ProviderQuotaWidget renders a `grid-cols-1 sm:grid-cols-2 md:grid-cols-3` +// container when `compact` is true (the "force 3 columns" path). +// 3. The `compact` prop appears in the Props interface of both components. + +import { test } from "node:test"; +import assert from "node:assert/strict"; +import fs from "node:fs"; +import path from "node:path"; +import ts from "typescript"; + +const COMPONENTS = { + quotaCardGrid: path.resolve( + import.meta.dirname, + "../../src/app/(dashboard)/dashboard/usage/components/ProviderLimits/QuotaCardGrid.tsx" + ), + providerQuotaWidget: path.resolve( + import.meta.dirname, + "../../src/app/(dashboard)/home/ProviderQuotaWidget.tsx" + ), +}; + +/** + * Render a TSX/TS source file into an AST and return the full node tree. + */ +function parseSource(sourcePath: string): ts.SourceFile { + const sourceText = fs.readFileSync(sourcePath, "utf8"); + return ts.createSourceFile( + sourcePath, + sourceText, + ts.ScriptTarget.Latest, + true, + ts.ScriptKind.TSX + ); +} + +/** + * Collect all string-literal className values from `