Skip to content

Commit 4e1d49a

Browse files
[test] update WidgetSelectButton tests for semantic tokens
Update test expectations to use semantic color tokens instead of hard-coded classes: - bg-white → bg-interface-menu-component-surface-selected - text-neutral-900 → text-primary/text-secondary - hover:bg-zinc-200/50 → hover:bg-interface-menu-component-surface-hovered
1 parent 20015cc commit 4e1d49a

File tree

1 file changed

+45
-17
lines changed

1 file changed

+45
-17
lines changed

src/renderer/extensions/vueNodes/widgets/components/WidgetSelectButton.test.ts

Lines changed: 45 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,14 @@ describe('WidgetSelectButton Button Selection', () => {
107107
const selectedButton = buttons[1] // 'banana'
108108
const unselectedButton = buttons[0] // 'apple'
109109

110-
expect(selectedButton.classes()).toContain('bg-white')
111-
expect(selectedButton.classes()).toContain('text-neutral-900')
112-
expect(unselectedButton.classes()).not.toContain('bg-white')
113-
expect(unselectedButton.classes()).not.toContain('text-neutral-900')
110+
expect(selectedButton.classes()).toContain(
111+
'bg-interface-menu-component-surface-selected'
112+
)
113+
expect(selectedButton.classes()).toContain('text-primary')
114+
expect(unselectedButton.classes()).not.toContain(
115+
'bg-interface-menu-component-surface-selected'
116+
)
117+
expect(unselectedButton.classes()).toContain('text-secondary')
114118
})
115119

116120
it('handles no selection gracefully', () => {
@@ -120,8 +124,10 @@ describe('WidgetSelectButton Button Selection', () => {
120124

121125
const buttons = wrapper.findAll('button')
122126
buttons.forEach((button) => {
123-
expect(button.classes()).not.toContain('bg-white')
124-
expect(button.classes()).not.toContain('text-neutral-900')
127+
expect(button.classes()).not.toContain(
128+
'bg-interface-menu-component-surface-selected'
129+
)
130+
expect(button.classes()).toContain('text-secondary')
125131
})
126132
})
127133

@@ -134,13 +140,19 @@ describe('WidgetSelectButton Button Selection', () => {
134140

135141
// Initially 'first' is selected
136142
let buttons = wrapper.findAll('button')
137-
expect(buttons[0].classes()).toContain('bg-white')
143+
expect(buttons[0].classes()).toContain(
144+
'bg-interface-menu-component-surface-selected'
145+
)
138146

139147
// Update to 'second'
140148
await wrapper.setProps({ modelValue: 'second' })
141149
buttons = wrapper.findAll('button')
142-
expect(buttons[0].classes()).not.toContain('bg-white')
143-
expect(buttons[1].classes()).toContain('bg-white')
150+
expect(buttons[0].classes()).not.toContain(
151+
'bg-interface-menu-component-surface-selected'
152+
)
153+
expect(buttons[1].classes()).toContain(
154+
'bg-interface-menu-component-surface-selected'
155+
)
144156
})
145157
})
146158

@@ -222,7 +234,9 @@ describe('WidgetSelectButton Button Selection', () => {
222234
expect(buttons[2].text()).toBe('3')
223235

224236
// The selected button should be the one with '2'
225-
expect(buttons[1].classes()).toContain('bg-white')
237+
expect(buttons[1].classes()).toContain(
238+
'bg-interface-menu-component-surface-selected'
239+
)
226240
})
227241

228242
it('handles object options with label and value', () => {
@@ -240,7 +254,9 @@ describe('WidgetSelectButton Button Selection', () => {
240254
expect(buttons[2].text()).toBe('Third Option')
241255

242256
// 'second' should be selected
243-
expect(buttons[1].classes()).toContain('bg-white')
257+
expect(buttons[1].classes()).toContain(
258+
'bg-interface-menu-component-surface-selected'
259+
)
244260
})
245261

246262
it('emits correct values for object options', async () => {
@@ -277,7 +293,9 @@ describe('WidgetSelectButton Button Selection', () => {
277293

278294
const buttons = wrapper.findAll('button')
279295
expect(buttons).toHaveLength(4)
280-
expect(buttons[0].classes()).toContain('bg-white') // Empty string is selected
296+
expect(buttons[0].classes()).toContain(
297+
'bg-interface-menu-component-surface-selected'
298+
) // Empty string is selected
281299
})
282300

283301
it('handles null/undefined in options', () => {
@@ -292,7 +310,9 @@ describe('WidgetSelectButton Button Selection', () => {
292310

293311
const buttons = wrapper.findAll('button')
294312
expect(buttons).toHaveLength(4)
295-
expect(buttons[0].classes()).toContain('bg-white')
313+
expect(buttons[0].classes()).toContain(
314+
'bg-interface-menu-component-surface-selected'
315+
)
296316
})
297317

298318
it('handles very long option text', () => {
@@ -313,7 +333,9 @@ describe('WidgetSelectButton Button Selection', () => {
313333

314334
const buttons = wrapper.findAll('button')
315335
expect(buttons).toHaveLength(20)
316-
expect(buttons[4].classes()).toContain('bg-white') // option5 is at index 4
336+
expect(buttons[4].classes()).toContain(
337+
'bg-interface-menu-component-surface-selected'
338+
) // option5 is at index 4
317339
})
318340

319341
it('handles duplicate options', () => {
@@ -324,8 +346,12 @@ describe('WidgetSelectButton Button Selection', () => {
324346
const buttons = wrapper.findAll('button')
325347
expect(buttons).toHaveLength(4)
326348
// Both 'duplicate' buttons should be highlighted (due to value matching)
327-
expect(buttons[0].classes()).toContain('bg-white')
328-
expect(buttons[2].classes()).toContain('bg-white')
349+
expect(buttons[0].classes()).toContain(
350+
'bg-interface-menu-component-surface-selected'
351+
)
352+
expect(buttons[2].classes()).toContain(
353+
'bg-interface-menu-component-surface-selected'
354+
)
329355
})
330356
})
331357

@@ -354,7 +380,9 @@ describe('WidgetSelectButton Button Selection', () => {
354380
const buttons = wrapper.findAll('button')
355381
const unselectedButton = buttons[1] // 'option2'
356382

357-
expect(unselectedButton.classes()).toContain('hover:bg-zinc-200/50')
383+
expect(unselectedButton.classes()).toContain(
384+
'hover:bg-interface-menu-component-surface-hovered'
385+
)
358386
expect(unselectedButton.classes()).toContain('cursor-pointer')
359387
})
360388
})

0 commit comments

Comments
 (0)