@@ -262,7 +262,9 @@ test("Palette repository owns active project swatches without mutating invalid p
262262 ] ) ) ;
263263
264264 expect ( repository . addSwatch ( { symbol : "H" , hex : "#654321" , name : "Other" } ) . ok ) . toBe ( false ) ;
265- expect ( repository . addSwatch ( { symbol : "O" , hex : "#654321" , name : "Hero Blue" } ) . ok ) . toBe ( false ) ;
265+ const duplicateNameResult = repository . addSwatch ( { symbol : "O" , hex : "#654321" , name : "Hero Blue" } ) ;
266+ expect ( duplicateNameResult . ok ) . toBe ( false ) ;
267+ expect ( duplicateNameResult . issues . map ( ( issue ) => issue . label ) ) . toContain ( "Duplicate Name" ) ;
266268 expect ( repository . addSwatch ( { symbol : "O" , hex : "#123456" , name : "Other" } ) . ok ) . toBe ( false ) ;
267269
268270 const updateResult = repository . updateSelectedSwatch ( {
@@ -331,8 +333,45 @@ test("Palette repository owns active project swatches without mutating invalid p
331333 expect ( harmonySwatch ) . toMatchObject ( { source : "harmony" , tags : [ ] } ) ;
332334 const duplicateHarmonyResult = repository . addHarmonySuggestions ( [ harmonySuggestion ] ) ;
333335 expect ( duplicateHarmonyResult . ok ) . toBe ( false ) ;
336+ expect ( duplicateHarmonyResult . issues ) . toEqual ( [ ] ) ;
334337 expect ( repository . listSwatches ( ) . filter ( ( swatch ) => swatch . name === harmonySuggestion . name ) ) . toHaveLength ( 1 ) ;
335338
339+ const harmonyRepository = createProjectWorkspacePaletteRepository ( { sourcePaletteRows } ) ;
340+ expect ( harmonyRepository . addSwatch ( { symbol : "A" , hex : "#112233" , name : "Base One" } ) . ok ) . toBe ( true ) ;
341+ expect ( harmonyRepository . addSwatch ( { symbol : "B" , hex : "#445566" , name : "Base Two" } ) . ok ) . toBe ( true ) ;
342+ const firstComplementary = harmonyRepository . createHarmonySuggestions ( harmonyRepository . findSwatch ( "A" ) , {
343+ matchSource : "calculated" ,
344+ schemeId : "complementary"
345+ } ) [ 0 ] ;
346+ const secondComplementary = harmonyRepository . createHarmonySuggestions ( harmonyRepository . findSwatch ( "B" ) , {
347+ matchSource : "calculated" ,
348+ schemeId : "complementary"
349+ } ) [ 0 ] ;
350+ expect ( firstComplementary . name ) . toBe ( "Complementary 1" ) ;
351+ expect ( secondComplementary . name ) . toBe ( "Complementary 1" ) ;
352+ expect ( harmonyRepository . addHarmonySuggestion ( firstComplementary ) . ok ) . toBe ( true ) ;
353+ expect ( harmonyRepository . addHarmonySuggestion ( secondComplementary ) . ok ) . toBe ( true ) ;
354+ expect ( harmonyRepository . listSwatches ( ) . filter ( ( swatch ) => swatch . source === "harmony" ) . map ( ( swatch ) => swatch . name ) ) . toEqual ( [
355+ "Complementary 1" ,
356+ "Complementary 2"
357+ ] ) ;
358+ const triadicSuggestions = harmonyRepository . createHarmonySuggestions ( harmonyRepository . findSwatch ( "A" ) , {
359+ matchSource : "calculated" ,
360+ schemeId : "triadic"
361+ } ) ;
362+ const triadicAddAllResult = harmonyRepository . addHarmonySuggestions ( triadicSuggestions ) ;
363+ expect ( triadicAddAllResult . ok ) . toBe ( true ) ;
364+ expect ( triadicAddAllResult . message ) . toBe ( "Harmony add complete: 2 added, 0 skipped." ) ;
365+ expect ( harmonyRepository . listSwatches ( ) . filter ( ( swatch ) => swatch . name . startsWith ( "Triadic " ) ) . map ( ( swatch ) => swatch . name ) ) . toEqual ( [
366+ "Triadic 1" ,
367+ "Triadic 2"
368+ ] ) ;
369+ const repeatTriadicResult = harmonyRepository . addHarmonySuggestions ( triadicSuggestions ) ;
370+ expect ( repeatTriadicResult . ok ) . toBe ( false ) ;
371+ expect ( repeatTriadicResult . message ) . toBe ( "Harmony add complete: 0 added, 2 skipped." ) ;
372+ expect ( repeatTriadicResult . issues ) . toEqual ( [ ] ) ;
373+ expect ( harmonyRepository . listSwatches ( ) . filter ( ( swatch ) => swatch . name . startsWith ( "Triadic " ) ) ) . toHaveLength ( 2 ) ;
374+
336375 repository . selectSwatch ( "R" ) ;
337376 repository . recordSwatchUsage ( { assetId : "asset.color.red" , symbol : "R" , toolId : "assets" } ) ;
338377 const blockedRemoval = repository . removeSelectedSwatch ( ) ;
0 commit comments