fix: update AlertDialog test assertions to check data-closed attribute

After removing conditional guards, base-ui AlertDialog keeps portal
content in DOM during exit transition (transitionend never fires in
JSDOM). Replace not.toBeInTheDocument() with toHaveAttribute('data-closed')
to assert dialog closure state instead of DOM removal.

Made-with: Cursor
This commit is contained in:
yyh
2026-04-14 16:21:42 +08:00
parent 8508647e63
commit b329c4f6f0
2 changed files with 4 additions and 5 deletions

View File

@ -1,5 +1,5 @@
import type { EndpointListItem, PluginDetail } from '../../types'
import { act, fireEvent, render, screen } from '@testing-library/react'
import { act, fireEvent, render, screen, waitFor } from '@testing-library/react'
import { beforeEach, describe, expect, it, vi } from 'vitest'
import EndpointCard from '../endpoint-card'
@ -284,8 +284,7 @@ describe('EndpointCard', () => {
fireEvent.click(screen.getByRole('button', { name: 'common.operation.cancel' }))
// Confirm should be hidden
expect(screen.queryByText('plugin.detailPanel.endpointDisableTip')).not.toBeInTheDocument()
expect(screen.getByRole('alertdialog')).toHaveAttribute('data-closed')
})
it('should hide delete confirm when cancel clicked', () => {
@ -297,7 +296,7 @@ describe('EndpointCard', () => {
fireEvent.click(screen.getByRole('button', { name: 'common.operation.cancel' }))
expect(screen.queryByText('plugin.detailPanel.endpointDeleteTip')).not.toBeInTheDocument()
expect(screen.getByRole('alertdialog')).toHaveAttribute('data-closed')
})
it('should hide edit modal when cancel clicked', () => {

View File

@ -702,7 +702,7 @@ describe('ProviderDetail', () => {
fireEvent.click(screen.getByTestId('edit-remove'))
expect(screen.getByText('tools.createTool.deleteToolConfirmTitle')).toBeInTheDocument()
fireEvent.click(getDeleteCancelButton())
expect(screen.queryByText('tools.createTool.deleteToolConfirmTitle')).not.toBeInTheDocument()
expect(screen.getByRole('alertdialog')).toHaveAttribute('data-closed')
})
})
})