test(ai-toolbar): harden stacked preview regression

This commit is contained in:
2026-04-22 17:39:34 -04:00
parent f5058803b6
commit 8b17d75193

View File

@@ -187,18 +187,18 @@ describe("AI capture redesign", () => {
test("attachment previews stack one per row instead of using a two-column desktop grid", () => { test("attachment previews stack one per row instead of using a two-column desktop grid", () => {
const source = readToolbarSource(); const source = readToolbarSource();
const previewGridClassName = source.match( const previewGridClassNames = [...source.matchAll(
/className="([^"]*\bmt-3\b[^"]*\bgrid\b[^"]*\bgap-2\b[^"]*)"/, /className="([^"]*\bmt-3\b[^"]*\bgrid\b[^"]*\bgap-2\b[^"]*)"/g,
)?.[1]; )].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(source).toContain('"mt-3 grid gap-2"');
expect(previewGridClassName).toBeDefined(); expect(previewGridClassNames).toHaveLength(1);
expect(previewGridClassName).toMatch(/\bmt-3\b/); expect(previewGridClassNames[0]).toMatch(/\bmt-3\b/);
expect(previewGridClassName).toMatch(/\bgrid\b/); expect(previewGridClassNames[0]).toMatch(/\bgrid\b/);
expect(previewGridClassName).toMatch(/\bgap-2\b/); expect(previewGridClassNames[0]).toMatch(/\bgap-2\b/);
expect(previewGridClassName).not.toMatch( expect(previewGridClassNames[0]).not.toMatch(multiColumnPreviewPattern);
/(?:^|\s)(?:[a-z]+:)*grid-cols-(?:\[[^\]]+\]|\S+)/,
);
}); });
}); });