fix(test): try to resolve flaky label create test, again
This commit is contained in:
parent
57bb0ccd2c
commit
e708beacf4
|
|
@ -368,25 +368,31 @@ describe('LabelCreateDialog Component', () => {
|
|||
|
||||
describe('Loading State', () => {
|
||||
test('should show loading state during submission', async () => {
|
||||
const onSubmit = vi.fn().mockImplementation(() => new Promise(resolve => setTimeout(resolve, 100)));
|
||||
const onSubmit = vi.fn().mockImplementation(() => new Promise(resolve => setTimeout(resolve, 500)));
|
||||
renderLabelCreateDialog({ onSubmit });
|
||||
|
||||
const nameInput = screen.getByLabelText(/label name/i);
|
||||
await user.type(nameInput, 'Test Label');
|
||||
|
||||
const createButton = screen.getByText('Create');
|
||||
|
||||
// Initially button should show "Create"
|
||||
expect(createButton).toHaveTextContent('Create');
|
||||
expect(createButton).not.toBeDisabled();
|
||||
|
||||
await user.click(createButton);
|
||||
|
||||
// Wait for loading state to appear
|
||||
// Wait for loading state to appear - the button text should change to "Saving..."
|
||||
await waitFor(() => {
|
||||
expect(screen.getByText('Saving...')).toBeInTheDocument();
|
||||
});
|
||||
expect(createButton).toHaveTextContent('Saving...');
|
||||
}, { timeout: 2000 });
|
||||
|
||||
expect(createButton).toBeDisabled();
|
||||
|
||||
// Wait for submission to complete
|
||||
await waitFor(() => {
|
||||
expect(screen.queryByText('Saving...')).not.toBeInTheDocument();
|
||||
});
|
||||
expect(createButton).not.toHaveTextContent('Saving...');
|
||||
}, { timeout: 3000 });
|
||||
});
|
||||
|
||||
test('should disable form fields during submission', async () => {
|
||||
|
|
|
|||
Loading…
Reference in New Issue