From 8b17d751934adf675c1e31dc726ad981d6ba2143 Mon Sep 17 00:00:00 2001 From: Dmytro Stanchiev Date: Wed, 22 Apr 2026 17:39:34 -0400 Subject: [PATCH] test(ai-toolbar): harden stacked preview regression --- tests/ai-toolbar.test.ts | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/tests/ai-toolbar.test.ts b/tests/ai-toolbar.test.ts index 0aebabe..930809f 100644 --- a/tests/ai-toolbar.test.ts +++ b/tests/ai-toolbar.test.ts @@ -187,18 +187,18 @@ describe("AI capture redesign", () => { test("attachment previews stack one per row instead of using a two-column desktop grid", () => { const source = readToolbarSource(); - const previewGridClassName = source.match( - /className="([^"]*\bmt-3\b[^"]*\bgrid\b[^"]*\bgap-2\b[^"]*)"/, - )?.[1]; + const previewGridClassNames = [...source.matchAll( + /className="([^"]*\bmt-3\b[^"]*\bgrid\b[^"]*\bgap-2\b[^"]*)"/g, + )].map(([, className]) => className); + const multiColumnPreviewPattern = + /(?:^|\s)(?:[a-z]+:)*(?:grid-cols-(?:\[[^\]]+\]|\S+)|grid-flow-col|auto-cols-(?:\[[^\]]+\]|\S+)|columns-(?:\[[^\]]+\]|\S+))/; expect(source).toContain('"mt-3 grid gap-2"'); - expect(previewGridClassName).toBeDefined(); - expect(previewGridClassName).toMatch(/\bmt-3\b/); - expect(previewGridClassName).toMatch(/\bgrid\b/); - expect(previewGridClassName).toMatch(/\bgap-2\b/); - expect(previewGridClassName).not.toMatch( - /(?:^|\s)(?:[a-z]+:)*grid-cols-(?:\[[^\]]+\]|\S+)/, - ); + expect(previewGridClassNames).toHaveLength(1); + expect(previewGridClassNames[0]).toMatch(/\bmt-3\b/); + expect(previewGridClassNames[0]).toMatch(/\bgrid\b/); + expect(previewGridClassNames[0]).toMatch(/\bgap-2\b/); + expect(previewGridClassNames[0]).not.toMatch(multiColumnPreviewPattern); }); });