Skip to content

Commit

Permalink
Remove waitFor in flyout tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Zacqary committed Jan 15, 2025
1 parent fd0a82b commit fb3027e
Showing 1 changed file with 8 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*/

import React from 'react';
import { fireEvent, render, screen, waitFor } from '@testing-library/react';
import { fireEvent, render, screen } from '@testing-library/react';
import { RuleFlyout } from './rule_flyout';
import {
RULE_FORM_PAGE_RULE_DEFINITION_TITLE_SHORT,
Expand Down Expand Up @@ -110,30 +110,22 @@ describe('ruleFlyout', () => {
render(<RuleFlyout onCancel={onCancel} onSave={onSave} />);

fireEvent.click(screen.getByTestId('ruleFlyoutFooterNextStepButton'));
await waitFor(() =>
expect(screen.getByTestId('ruleFlyoutFooterPreviousStepButton')).toBeInTheDocument()
);
expect(await screen.findByTestId('ruleFlyoutFooterPreviousStepButton')).toBeInTheDocument();
fireEvent.click(screen.getByTestId('ruleFlyoutFooterNextStepButton'));
await waitFor(() =>
expect(screen.getByTestId('ruleFlyoutFooterSaveButton')).toBeInTheDocument()
);
expect(await screen.findByTestId('ruleFlyoutFooterSaveButton')).toBeInTheDocument();

fireEvent.click(screen.getByTestId('ruleFlyoutFooterPreviousStepButton'));
await waitFor(() =>
expect(screen.getByTestId('ruleFlyoutFooterNextStepButton')).toBeInTheDocument()
);
expect(await screen.findByTestId('ruleFlyoutFooterNextStepButton')).toBeInTheDocument();
});

test('should call onSave when save button is pressed', async () => {
render(<RuleFlyout onCancel={onCancel} onSave={onSave} />);

fireEvent.click(screen.getByTestId('ruleFlyoutFooterNextStepButton'));
await waitFor(() =>
expect(screen.getByTestId('ruleFlyoutFooterPreviousStepButton')).toBeInTheDocument()
);
expect(await screen.findByTestId('ruleFlyoutFooterPreviousStepButton')).toBeInTheDocument();
fireEvent.click(screen.getByTestId('ruleFlyoutFooterNextStepButton'));
await waitFor(() =>
expect(screen.getByTestId('ruleFlyoutFooterSaveButton')).toBeInTheDocument()
);
expect(await screen.findByTestId('ruleFlyoutFooterSaveButton')).toBeInTheDocument();

fireEvent.click(screen.getByTestId('ruleFlyoutFooterSaveButton'));

expect(onSave).toHaveBeenCalledWith({
Expand Down

0 comments on commit fb3027e

Please sign in to comment.