@@ -49,4 +49,39 @@ describe('ThemeQuickPresets', () => {
4949 await user . click ( inactiveBtn ) ;
5050 expect ( onThemeChange ) . toHaveBeenCalledWith ( inactiveKey ) ;
5151 } ) ;
52+
53+ it ( 'each button has an aria-label starting with "Apply"' , ( ) => {
54+ render ( < ThemeQuickPresets theme = "dark" onThemeChange = { onThemeChange } /> ) ;
55+ const buttons = screen . getAllByRole ( 'button' ) ;
56+ buttons . forEach ( ( btn ) => {
57+ expect ( btn . getAttribute ( 'aria-label' ) ) . toMatch ( / ^ A p p l y / i) ;
58+ } ) ;
59+ } ) ;
60+
61+ it ( 'renders at least one button for each concrete theme excluding auto and random' , ( ) => {
62+ render ( < ThemeQuickPresets theme = "dark" onThemeChange = { onThemeChange } /> ) ;
63+ validKeys . forEach ( ( key ) => {
64+ const btn = screen . getByRole ( 'button' , {
65+ name : new RegExp ( `apply ${ key } theme` , 'i' ) ,
66+ } ) ;
67+ expect ( btn ) . toBeTruthy ( ) ;
68+ } ) ;
69+ } ) ;
70+
71+ it ( 'switching active theme updates aria-pressed correctly' , ( ) => {
72+ const { rerender } = render ( < ThemeQuickPresets theme = "dark" onThemeChange = { onThemeChange } /> ) ;
73+ const darkBtn = screen . getByRole ( 'button' , { name : / a p p l y d a r k t h e m e / i } ) ;
74+ expect ( darkBtn . getAttribute ( 'aria-pressed' ) ) . toBe ( 'true' ) ;
75+
76+ rerender ( < ThemeQuickPresets theme = "neon" onThemeChange = { onThemeChange } /> ) ;
77+ const neonBtn = screen . getByRole ( 'button' , { name : / a p p l y n e o n t h e m e / i } ) ;
78+ expect ( neonBtn . getAttribute ( 'aria-pressed' ) ) . toBe ( 'true' ) ;
79+ expect ( darkBtn . getAttribute ( 'aria-pressed' ) ) . toBe ( 'false' ) ;
80+ } ) ;
81+
82+ it ( 'does not render buttons for auto or random themes' , ( ) => {
83+ render ( < ThemeQuickPresets theme = "dark" onThemeChange = { onThemeChange } /> ) ;
84+ expect ( screen . queryByRole ( 'button' , { name : / a p p l y a u t o t h e m e / i } ) ) . toBeNull ( ) ;
85+ expect ( screen . queryByRole ( 'button' , { name : / a p p l y r a n d o m t h e m e / i } ) ) . toBeNull ( ) ;
86+ } ) ;
5287} ) ;
0 commit comments