import { mount } from '@vue/test-utils' import { describe, expect, it } from 'vitest' import WellPlate from '../../components/WellPlate.vue' // Shortcuts belong to the plate, never the page (7a): Ctrl/Cmd+A in an // unrelated input must keep selecting text. describe('WellPlate keyboard scope', () => { it('should ignore Ctrl+A pressed outside the plate', () => { const wrapper = mount(WellPlate, { props: { format: 6 }, attachTo: document.body }) document.dispatchEvent(new KeyboardEvent('keydown', { key: 'a', ctrlKey: true, bubbles: true })) expect(wrapper.emitted('selection-change')).toBeUndefined() wrapper.unmount() }) it('should select every well on Ctrl+A pressed inside the plate', async () => { const wrapper = mount(WellPlate, { props: { format: 6 } }) await wrapper.get('[role="gridcell"]').trigger('keydown', { key: 'a', ctrlKey: true }) expect(wrapper.emitted('selection-change')?.[0]?.[0]).toHaveLength(6) }) })