fix(test): try to resolve flaky label create test, again

This commit is contained in:
perf3ct 2025-06-27 18:53:42 +00:00
parent 60dee61f16
commit 1af971b3da
No known key found for this signature in database
GPG Key ID: 569C4EEC436F5232
1 changed files with 12 additions and 6 deletions

View File

@ -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 () => {