Skip to content

Commit b95f6ee

Browse files
test: harden LocateNodeButton propagation and keyboard tests
Propagation test now also asserts locate is emitted in the same interaction, so it would catch a broken handler that stops propagation without emitting. Keyboard test uses explicit .focus() instead of user.tab() to avoid relying on JSDOM implicit tab order. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 916e085 commit b95f6ee

1 file changed

Lines changed: 14 additions & 13 deletions

File tree

src/components/rightSidePanel/errors/LocateNodeButton.test.ts

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,22 +26,10 @@ describe('LocateNodeButton', () => {
2626
expect(emitted().locate).toHaveLength(1)
2727
})
2828

29-
it('emits locate on keyboard activation', async () => {
30-
const user = userEvent.setup()
31-
const { emitted } = render(LocateNodeButton, {
32-
props: { label: 'Locate node on canvas' }
33-
})
34-
35-
await user.tab()
36-
await user.keyboard('{Enter}')
37-
38-
expect(emitted().locate).toHaveLength(1)
39-
})
40-
4129
it('stops click propagation so an ancestor handler does not also fire', async () => {
4230
const user = userEvent.setup()
4331
const onAncestorClick = vi.fn()
44-
render({
32+
const { emitted } = render({
4533
components: { LocateNodeButton },
4634
setup: () => ({ onAncestorClick }),
4735
template:
@@ -53,5 +41,18 @@ describe('LocateNodeButton', () => {
5341
)
5442

5543
expect(onAncestorClick).not.toHaveBeenCalled()
44+
expect(emitted().locate).toHaveLength(1)
45+
})
46+
47+
it('emits locate on keyboard activation without relying on implicit tab order', async () => {
48+
const user = userEvent.setup()
49+
const { emitted } = render(LocateNodeButton, {
50+
props: { label: 'Locate node on canvas' }
51+
})
52+
53+
screen.getByRole('button', { name: 'Locate node on canvas' }).focus()
54+
await user.keyboard('{Enter}')
55+
56+
expect(emitted().locate).toHaveLength(1)
5657
})
5758
})

0 commit comments

Comments
 (0)