Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

chore: files changed app/src/components/ui/Alert.test.tsx

Steven Enamakel28108a63fff6
diff --git a/app/src/components/ui/Alert.test.tsx b/app/src/components/ui/Alert.test.tsx
index efb08d3dd3..6f974d32d9 100644
--- a/app/src/components/ui/Alert.test.tsx
+++ b/app/src/components/ui/Alert.test.tsx
@@ -144,6 +144,146 @@ describe('Alert', () => {
expect(cls).not.toContain('rounded-xl');
});
+ describe('density', () => {
+ it.each(VARIANTS)(
+ 'renders %s identically with no density prop and with density="default"',
+ variant => {
+ // The guarantee the density variant was added under: every call site
+ // that predates it keeps its exact class attribute.
+ render(
+ <Alert variant={variant} data-testid="implicit">
+ Body
+ </Alert>
+ );
+ render(
+ <Alert variant={variant} density="default" data-testid="explicit">
+ Body
+ </Alert>
+ );
+
+ const implicit = screen.getByTestId('implicit');
+ expect(implicit.className).toBe(screen.getByTestId('explicit').className);
+ // …and that attribute is still what the cva base emits, unreordered.
+ expect(implicit.className).toBe(alertVariants({ variant }));
+ for (const utility of BASE_GEOMETRY) expect(implicit.className).toContain(utility);
+ for (const utility of COMPACT_GEOMETRY) expect(implicit.className).not.toContain(utility);
+ }
+ );
+
+ it.each(VARIANTS)('gives %s the dense geometry at density="compact"', variant => {
+ render(
+ <Alert variant={variant} density="compact" data-testid="alert">
+ Body
+ </Alert>
+ );
+
+ const cls = screen.getByTestId('alert').className;
+ for (const utility of COMPACT_GEOMETRY) expect(cls).toContain(utility);
+ // tailwind-merge must have dropped the base geometry, not stacked on it —
+ // two competing paddings in one attribute is how the hand-rolled notices
+ // ended up at four different sizes.
+ for (const utility of BASE_GEOMETRY) expect(cls).not.toContain(utility);
+ });
+
+ it('keeps the tone classes when compacted', () => {
+ render(
+ <Alert variant="destructive" density="compact" data-testid="alert">
+ Body
+ </Alert>
+ );
+
+ const cls = screen.getByTestId('alert').className;
+ expect(cls).toContain('border-coral-200');
+ expect(cls).toContain('bg-coral-50');
+ expect(cls).toContain('text-coral-600');
+ expect(screen.getByTestId('alert')).toHaveAttribute('role', 'alert');
+ });
+
+ it('lets a caller className win over the compact geometry too', () => {
+ render(
+ <Alert density="compact" className="px-6" data-testid="alert">
+ Body
+ </Alert>
+ );
+
+ const cls = screen.getByTestId('alert').className;
+ expect(cls).toContain('px-6');
+ expect(cls).not.toContain('px-3');
+ expect(cls).toContain('py-2');
+ });
+
+ it('shrinks the description with the box', () => {
+ render(
+ <Alert density="compact" data-testid="alert">
+ <AlertTitle data-testid="title">Title</AlertTitle>
+ <AlertDescription data-testid="description">Description</AlertDescription>
+ </Alert>
+ );
+
+ const description = screen.getByTestId('description');
+ expect(description.className).toContain('text-xs');
+ expect(description.className).not.toContain('text-sm');
+ expect(description.className).toContain('leading-relaxed');
+ });
+
+ it('leaves the description at text-sm inside a default alert', () => {
+ render(
+ <Alert data-testid="alert">
+ <AlertDescription data-testid="description">Description</AlertDescription>
+ </Alert>
+ );
+
+ expect(screen.getByTestId('description').className).toContain('text-sm');
+ });
+
+ it('leaves a standalone description at text-sm', () => {
+ render(<AlertDescription data-testid="description">Description</AlertDescription>);
+
+ expect(screen.getByTestId('description').className).toContain('text-sm');
+ });
+
+ it('lets a description className win over the inherited density', () => {
+ render(
+ <Alert density="compact" data-testid="alert">
+ <AlertDescription className="text-base" data-testid="description">
+ Description
+ </AlertDescription>
+ </Alert>
+ );
+
+ const cls = screen.getByTestId('description').className;
+ expect(cls).toContain('text-base');
+ expect(cls).not.toContain('text-xs');
+ });
+
+ it('does not change the role derivation', () => {
+ render(
+ <Alert variant="info" density="compact" data-testid="info">
+ Body
+ </Alert>
+ );
+ render(
+ <Alert variant="warning" density="compact" data-testid="warning">
+ Body
+ </Alert>
+ );
+
+ expect(screen.getByTestId('info')).not.toHaveAttribute('role');
+ expect(screen.getByTestId('warning')).toHaveAttribute('role', 'alert');
+ });
+
+ it.each(VARIANTS)('keeps %s on design tokens when compacted', variant => {
+ render(
+ <Alert variant={variant} density="compact" data-testid="alert">
+ <AlertDescription data-testid="description">Description</AlertDescription>
+ </Alert>
+ );
+
+ expect(screen.getByTestId('alert').className).not.toMatch(RAW_PALETTE);
+ expect(screen.getByTestId('description').className).not.toMatch(RAW_PALETTE);
+ });
+ });
+
it.each(VARIANTS)('resolves %s to design tokens, never a raw palette class', variant => {
render(
<Alert variant={variant} data-testid="alert">