fix(gui-v2): wire AppDialog accessible name + cover close/width in tests

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-16 21:53:04 +02:00
parent c26b281fa7
commit 3685797e18
2 changed files with 79 additions and 31 deletions

View File

@@ -124,13 +124,25 @@ describe('AppDialog', () => {
it('renders the sub text when provided', () => {
const wrapper = mountDialog({ open: true, title: 'Title', sub: 'Helpful subtitle' })
const subEl = wrapper.find('[class*="text-muted"]')
// Check text presence regardless of exact class names
expect(wrapper.text()).toContain('Helpful subtitle')
// Sub element should exist in the DOM
expect(subEl.exists() || wrapper.find('div > div > div').exists()).toBe(true)
// The sub element is the .mt-1 div under the header — assert it actually exists
expect(wrapper.find('.mt-1').exists()).toBe(true)
})
it('passes the width prop through to the Dialog style', () => {
const wrapper = mountDialog({ open: true, width: '400px' })
const dialog = wrapper.findComponent(DialogStub)
expect(dialog.props('style')).toEqual({ width: '400px' })
})
it('applies the default width when no width prop is given', () => {
const wrapper = mountDialog({ open: true })
const dialog = wrapper.findComponent(DialogStub)
expect(dialog.props('style')).toEqual({ width: 'min(680px, 100%)' })
})
// -------------------------------------------------------------------------
@@ -154,24 +166,32 @@ describe('AppDialog', () => {
// 4. Dialog emits update:visible=false → AppDialog emits update:open=false
// -------------------------------------------------------------------------
it('emits update:open=false when Dialog emits update:visible=false', async () => {
it('emits update:open=false AND close when Dialog emits update:visible=false', async () => {
const wrapper = mountDialog({ open: true })
// Simulate PrimeVue Dialog closing (overlay click or Escape)
await wrapper.findComponent(DialogStub).vm.$emit('update:visible', false)
await wrapper.vm.$nextTick()
const emitted = wrapper.emitted('update:open')
const openEvents = wrapper.emitted('update:open')
const closeEvents = wrapper.emitted('close')
expect(emitted).toBeTruthy()
expect(emitted![0]).toEqual([false])
expect(openEvents).toBeTruthy()
expect(openEvents![0]).toEqual([false])
expect(closeEvents).toBeTruthy()
expect(closeEvents![0]).toEqual([])
// Contract: update:open fires before close (JSDoc-documented order)
const order = wrapper.emitted()
const keys = Object.keys(order)
expect(keys.indexOf('update:open')).toBeLessThan(keys.indexOf('close'))
})
// -------------------------------------------------------------------------
// 5. Close button click → emits update:open=false
// -------------------------------------------------------------------------
it('emits update:open=false when the close button is clicked', async () => {
it('emits update:open=false AND close when the close button is clicked', async () => {
const wrapper = mountDialog({ open: true })
const closeBtn = wrapper.find('button[aria-label="Close"]')
@@ -181,10 +201,13 @@ describe('AppDialog', () => {
await closeBtn.trigger('click')
await wrapper.vm.$nextTick()
const emitted = wrapper.emitted('update:open')
const openEvents = wrapper.emitted('update:open')
const closeEvents = wrapper.emitted('close')
expect(emitted).toBeTruthy()
expect(emitted![0]).toEqual([false])
expect(openEvents).toBeTruthy()
expect(openEvents![0]).toEqual([false])
expect(closeEvents).toBeTruthy()
expect(closeEvents![0]).toEqual([])
})
// -------------------------------------------------------------------------