fix flaky ui test
Some checks failed
Chromatic / Run Chromatic (push) Has been cancelled
Test NextUI / Test next-ui (push) Has been cancelled

This commit is contained in:
Gauthier Roebroeck 2026-07-30 18:21:28 +08:00
parent 9ae3c8def7
commit aab40c2d04

View file

@ -45,7 +45,17 @@ export const MatchingPasswords: Story = {
await userEvent.click(password2)
await userEvent.type(password2, 'abc')
await waitFor(() => expect(canvas.queryByText(/must be identical/i)).not.toBeInTheDocument())
await waitFor(() => {
const errorMessage = canvas.queryByText(/must be identical/i)
if (errorMessage) {
// If the UI library kept it in the DOM, assert that it is hidden via CSS
void expect(errorMessage).not.toBeVisible()
} else {
// If it was completely removed from the DOM, assert it is null
void expect(errorMessage).toBeNull()
}
})
},
}