Skip to content

Commit 23930e2

Browse files
authored
test: fix flaky SecurityConfigDialog tab/content races (#8101)
Tab buttons and tab content only mount after security_get_status resolves, but the dialog title renders during the loading spinner phase. Replace synchronous getByRole/getByText for post-load elements with findBy* so they retry until the loading state clears.
1 parent 57304c6 commit 23930e2

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

web-app/src/containers/dialogs/__tests__/SecurityConfigDialog.test.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ describe('SecurityConfigDialog', () => {
5757
expect(hoisted.invoke).toHaveBeenCalledWith('security_get_status')
5858
)
5959
expect(await screen.findByText('Security Settings')).toBeInTheDocument()
60-
expect(screen.getByText('Current Status')).toBeInTheDocument()
60+
expect(await screen.findByText('Current Status')).toBeInTheDocument()
6161
})
6262

6363
it('shows an error toast if status fetch fails', async () => {
@@ -96,7 +96,7 @@ describe('SecurityConfigDialog', () => {
9696
})
9797
render(<SecurityConfigDialog isOpen={true} onClose={vi.fn()} />)
9898
await screen.findByText('Security Settings')
99-
fireEvent.click(screen.getByRole('button', { name: /devices/i }))
99+
fireEvent.click(await screen.findByRole('button', { name: /devices/i }))
100100
await waitFor(() =>
101101
expect(hoisted.invoke).toHaveBeenCalledWith('security_get_devices')
102102
)
@@ -187,7 +187,7 @@ describe('SecurityConfigDialog', () => {
187187
})
188188
render(<SecurityConfigDialog isOpen={true} onClose={vi.fn()} />)
189189
await screen.findByText('Security Settings')
190-
fireEvent.click(screen.getByRole('button', { name: /devices/i }))
190+
fireEvent.click(await screen.findByRole('button', { name: /devices/i }))
191191
await screen.findByText('Require Device Pairing')
192192
// Radix Switch exposes role="switch"
193193
const sw = screen.getByRole('switch')

0 commit comments

Comments
 (0)