feat(extensions): add ZIP installation and unify action dialogs
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
// @vitest-environment happy-dom
|
||||
import { afterEach, expect, it } from 'vitest'
|
||||
import { afterEach, expect, it, vi } from 'vitest'
|
||||
import { mount, type VueWrapper } from '@vue/test-utils'
|
||||
import AppDialog from './AppDialog.vue'
|
||||
const mounted: VueWrapper[] = []
|
||||
@@ -34,3 +34,17 @@ it('does not dismiss permission or busy dialogs through Escape or backdrop', asy
|
||||
await w.get('dialog').trigger('click')
|
||||
expect(w.emitted('close')).toBeUndefined()
|
||||
})
|
||||
|
||||
it('cycles Tab between the first and last visible controls', async () => {
|
||||
const w = mount(AppDialog, {props:{label:'键盘'}, slots:{default:'<section class="modal"><input /><button>取消</button><button disabled>禁用</button></section>'},attachTo:document.body}); mounted.push(w)
|
||||
const input = w.get('input').element
|
||||
const button = w.get('button').element
|
||||
const rects = [new DOMRect(0, 0, 50, 30)] as unknown as DOMRectList
|
||||
const spies = [input, button].map(element => vi.spyOn(element, 'getClientRects').mockReturnValue(rects))
|
||||
input.focus()
|
||||
await w.get('dialog').trigger('keydown', {key:'Tab', shiftKey:true})
|
||||
expect(document.activeElement).toBe(button)
|
||||
await w.get('dialog').trigger('keydown', {key:'Tab'})
|
||||
expect(document.activeElement).toBe(input)
|
||||
spies.forEach(spy => spy.mockRestore())
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user