From 207cc1cd523f0484f51aee4c937c7ce1a747df2e Mon Sep 17 00:00:00 2001 From: Fini Date: Sat, 9 May 2026 21:32:00 +0800 Subject: [PATCH] test(ai): integration coverage for text-effect + mixed-sibling-padding MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Why: 3abdfcf9 added integration tests for 4 of the 6 new aesthetic detectors (rotation / text-cornerRadius / text-stroke / mixed-sibling- cornerRadius). text-effect (7aef1b14) and mixed-sibling-padding (ad025c95) landed without integration coverage of the detect → applyFixes → store mutation chain. What: 2 more it() cases mirroring the existing pattern: - text-effect: text node with shadow effects → effects cleared - mixed-sibling-padding: 3 cards with padding 16/16/20 → outlier rewritten to scalar 16 (collapsed from the 4-tuple modal because all sides are equal — locks in the scalar-collapse code path) 13 / 13 tests in design-pre-validation.test.ts pass (was 11; +2). 1088 / 1088 AI tests overall (was 1086; +2). --- .../__tests__/design-pre-validation.test.ts | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/apps/web/src/services/ai/__tests__/design-pre-validation.test.ts b/apps/web/src/services/ai/__tests__/design-pre-validation.test.ts index e920b1f8c..570da4fc2 100644 --- a/apps/web/src/services/ai/__tests__/design-pre-validation.test.ts +++ b/apps/web/src/services/ai/__tests__/design-pre-validation.test.ts @@ -363,4 +363,51 @@ describe('design-pre-validation (baseline)', () => { }; expect(c3?.cornerRadius).toBe(8); }); + + it('text-effect: clears effects array on a text node', () => { + loadDocument( + makeDoc([ + { + id: 'parent', + type: 'frame', + children: [ + { + id: 'shadowed-text', + type: 'text', + content: 'hi', + fontSize: 14, + effects: [{ type: 'shadow', color: '#000', offsetX: 0, offsetY: 4, radius: 8 }], + } as unknown as PenNode, + ], + } as unknown as PenNode, + ]), + ); + expect(runPreValidationFixes()).toBeGreaterThanOrEqual(1); + const text = useDocumentStore.getState().getNodeById('shadowed-text') as PenNode & { + effects?: unknown; + }; + expect(text?.effects).toBeUndefined(); + }); + + it('mixed-sibling-padding: rewrites the padding outlier to the modal value', () => { + loadDocument( + makeDoc([ + { + id: 'parent', + type: 'frame', + children: [ + { id: 'c1', type: 'frame', role: 'card', padding: 16, children: [] }, + { id: 'c2', type: 'frame', role: 'card', padding: 16, children: [] }, + { id: 'c3', type: 'frame', role: 'card', padding: 20, children: [] }, + ], + } as unknown as PenNode, + ]), + ); + expect(runPreValidationFixes()).toBeGreaterThanOrEqual(1); + const c3 = useDocumentStore.getState().getNodeById('c3') as PenNode & { + padding?: unknown; + }; + // Modal collapsed back to scalar 16 (all 4 sides equal) + expect(c3?.padding).toBe(16); + }); });