test(desktop): match the switch and disclosure labels to what they render

These assert the accessible name, and the name now states the action rather
than the word toggle: an enabled toolset offers "Turn X toolset off", a
collapsed project offers "Show X sessions".
This commit is contained in:
Brooklyn Nicholson 2026-07-30 04:18:17 -05:00
parent 640056704c
commit 7996ec66cd
2 changed files with 8 additions and 6 deletions

View file

@ -17,7 +17,7 @@ vi.mock('@/i18n', () => ({
projects: {
enter: (label: string) => `Enter ${label}`,
reorder: (label: string) => `Reorder ${label}`,
toggle: (label: string) => `Toggle ${label} sessions`
toggle: (label: string, open: boolean) => `${open ? 'Show' : 'Hide'} ${label} sessions`
}
}
}
@ -60,14 +60,15 @@ describe('ProjectOverviewRow', () => {
/>
)
const button = screen.getByRole('button', { name: 'Toggle Test D sessions' })
// Collapsed by default, so the disclosure offers to show the sessions.
const button = screen.getByRole('button', { name: 'Show Test D sessions' })
expect(tipTrigger(button)).toBeTruthy()
})
it('does not render the disclosure toggle when there is nothing to preview', () => {
render(<ProjectOverviewRow project={project} />)
expect(screen.queryByRole('button', { name: 'Toggle Test D sessions' })).toBeNull()
expect(screen.queryByRole('button', { name: 'Show Test D sessions' })).toBeNull()
})
it('drops the "new session" add button on Home, which has no folder to start in', () => {

View file

@ -94,7 +94,8 @@ describe('SkillsView toolset management', () => {
it('renders a switch for each toolset and toggles it off', async () => {
await renderSkills()
const sw = await screen.findByRole('switch', { name: 'Toggle Web Search toolset' })
// The switch names the action, so an enabled toolset offers to turn it off.
const sw = await screen.findByRole('switch', { name: 'Turn Web Search toolset off' })
expect(sw.getAttribute('aria-checked')).toBe('true')
await act(async () => {
@ -112,7 +113,7 @@ describe('SkillsView toolset management', () => {
// The label renders in both the row and the auto-selected detail header, so
// assert via the switch's (emoji-stripped) accessible name and the absence
// of the emoji rather than a single-match text lookup.
await screen.findByRole('switch', { name: 'Toggle Cron Jobs toolset' })
await screen.findByRole('switch', { name: 'Turn Cron Jobs toolset off' })
expect(screen.queryByText(/⏰/)).toBeNull()
})
@ -122,7 +123,7 @@ describe('SkillsView toolset management', () => {
// and renders its config panel directly, which fetches on mount.
await renderSkills()
await screen.findByRole('switch', { name: 'Toggle Web Search toolset' })
await screen.findByRole('switch', { name: 'Turn Web Search toolset off' })
await waitFor(() => expect(getToolsetConfig).toHaveBeenCalledWith('web'))
})