Skip to content

Commit c35953b

Browse files
author
Waleed Latif
committed
test(sidebar): assert the keyboard cursor on a row that isn't selected
Review round 1: the keyboard-positive assertions landed on the current workspace, which carries its own `isActive` fill, so they held whether or not the cursor was painted — the tests could not have caught deleting keyboard-cursor rendering. Navigate with ArrowUp instead, wrapping from the seeded first row to the last, and assert on that row. Verified both directions now: removing the modality gate reddens three tests, removing keyboard painting reddens two.
1 parent fbc6fa1 commit c35953b

1 file changed

Lines changed: 11 additions & 7 deletions

File tree

apps/sim/app/workspace/[workspaceId]/w/components/sidebar/components/workspace-header/workspace-header.test.tsx

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -162,28 +162,32 @@ describe('WorkspaceHeader workspace switcher highlight', () => {
162162
const search = document.querySelector('input[placeholder="Search workspaces..."]')
163163
expect(search).not.toBeNull()
164164
act(() => {
165-
search?.dispatchEvent(new KeyboardEvent('keydown', { key: 'ArrowDown', bubbles: true }))
165+
search?.dispatchEvent(new KeyboardEvent('keydown', { key: 'ArrowUp', bubbles: true }))
166166
})
167167

168-
// ArrowDown from the seeded first row (RVT) lands on the second.
169-
expect(isMarked("Emir's Workspace")).toBe(true)
168+
// ArrowUp from the seeded first row wraps to the last. Asserting on Globex, not on
169+
// the current workspace: the current one carries its own `isActive` fill, so it
170+
// stays marked either way and would prove nothing about the cursor being painted.
171+
expect(isMarked('Globex')).toBe(true)
170172
})
171173

172174
it('drops the keyboard cursor again as soon as the pointer moves', () => {
173175
render()
174176

175177
const search = document.querySelector('input[placeholder="Search workspaces..."]')
176178
act(() => {
177-
search?.dispatchEvent(new KeyboardEvent('keydown', { key: 'ArrowDown', bubbles: true }))
179+
search?.dispatchEvent(new KeyboardEvent('keydown', { key: 'ArrowUp', bubbles: true }))
178180
})
179-
expect(isMarked("Emir's Workspace")).toBe(true)
181+
expect(isMarked('Globex')).toBe(true)
180182

181183
act(() => {
182184
row('Acme').dispatchEvent(new MouseEvent('mousemove', { bubbles: true }))
183185
})
184186

185-
// Back in pointer mode: only the current workspace keeps a persistent mark.
187+
// Back in pointer mode: the cursor is gone and the row just crossed is unmarked,
188+
// leaving only the current workspace's own fill.
189+
expect(isMarked('Globex')).toBe(false)
186190
expect(isMarked('Acme')).toBe(false)
187-
expect(isMarked('RVT')).toBe(false)
191+
expect(isMarked("Emir's Workspace")).toBe(true)
188192
})
189193
})

0 commit comments

Comments
 (0)