@@ -269,22 +269,31 @@ describe('NoteDialog', () => {
269269 } )
270270
271271 describe ( 'color swatches' , ( ) => {
272- it ( 'renders 16 swatches in both modes ' , ( ) => {
272+ it ( 'renders 17 swatches (no-color + 16 colors) ' , ( ) => {
273273 const wrapper = mount ( NoteDialog , {
274274 props : { open : true , note : makeNote ( ) } ,
275275 } )
276- expect ( wrapper . findAll ( '.note-dialog__swatch' ) ) . toHaveLength ( 16 )
276+ expect ( wrapper . findAll ( '.note-dialog__swatch' ) ) . toHaveLength ( 17 )
277+ } )
278+
279+ it ( 'has no-color swatch active by default when note has no color' , ( ) => {
280+ const wrapper = mount ( NoteDialog , {
281+ props : { open : true , note : makeNote ( { color : null } ) } ,
282+ } )
283+ const noColor = wrapper . find ( '.note-dialog__swatch--none' )
284+ expect ( noColor . classes ( ) ) . toContain ( 'note-dialog__swatch--active' )
277285 } )
278286
279287 it ( 'toggles color on swatch click' , async ( ) => {
280288 const wrapper = mount ( NoteDialog , {
281289 props : { open : true , note : makeNote ( { color : null } ) } ,
282290 } )
283- const swatch = wrapper . find ( '.note-dialog__swatch' )
284- await swatch . trigger ( 'click' )
285- expect ( swatch . classes ( ) ) . toContain ( 'note-dialog__swatch--active' )
286- await swatch . trigger ( 'click' )
287- expect ( swatch . classes ( ) ) . not . toContain ( 'note-dialog__swatch--active' )
291+ // Click a color swatch (skip the first "no color" swatch)
292+ const colorSwatch = wrapper . findAll ( '.note-dialog__swatch' ) . at ( 1 ) !
293+ await colorSwatch . trigger ( 'click' )
294+ expect ( colorSwatch . classes ( ) ) . toContain ( 'note-dialog__swatch--active' )
295+ await colorSwatch . trigger ( 'click' )
296+ expect ( colorSwatch . classes ( ) ) . not . toContain ( 'note-dialog__swatch--active' )
288297 } )
289298
290299 it ( 'saves immediately on color change for existing notes' , async ( ) => {
@@ -328,7 +337,7 @@ describe('NoteDialog', () => {
328337 // Should be in view mode
329338 expect ( wrapper . find ( '.nc-text-area' ) . exists ( ) ) . toBe ( false )
330339 // Swatches still visible
331- expect ( wrapper . findAll ( '.note-dialog__swatch' ) ) . toHaveLength ( 16 )
340+ expect ( wrapper . findAll ( '.note-dialog__swatch' ) ) . toHaveLength ( 17 )
332341 } )
333342 } )
334343} )
0 commit comments