refactor(Modal): Upgrade Modal component to Antd5 (#31420)

Co-authored-by: Diego Pucci <diegopucci.me@gmail.com>
This commit is contained in:
alexandrusoare
2024-12-19 18:22:11 +02:00
committed by GitHub
parent 7458c4bbd5
commit f362c6f508
45 changed files with 286 additions and 244 deletions

View File

@@ -73,10 +73,10 @@ describe('SaveDatasetModal', () => {
const inputField = screen.getByRole('textbox');
const inputFieldText = screen.getByDisplayValue(/unimportant/i);
expect(saveRadioBtn).toBeVisible();
expect(fieldLabel).toBeVisible();
expect(inputField).toBeVisible();
expect(inputFieldText).toBeVisible();
expect(saveRadioBtn).toBeInTheDocument();
expect(fieldLabel).toBeInTheDocument();
expect(inputField).toBeInTheDocument();
expect(inputFieldText).toBeInTheDocument();
});
it('renders an "Overwrite existing" field', () => {
@@ -89,23 +89,23 @@ describe('SaveDatasetModal', () => {
const inputField = screen.getByRole('combobox');
const placeholderText = screen.getByText(/select or type dataset name/i);
expect(overwriteRadioBtn).toBeVisible();
expect(fieldLabel).toBeVisible();
expect(inputField).toBeVisible();
expect(placeholderText).toBeVisible();
expect(overwriteRadioBtn).toBeInTheDocument();
expect(fieldLabel).toBeInTheDocument();
expect(inputField).toBeInTheDocument();
expect(placeholderText).toBeInTheDocument();
});
it('renders a close button', () => {
render(<SaveDatasetModal {...mockedProps} />, { useRedux: true });
expect(screen.getByRole('button', { name: /close/i })).toBeVisible();
expect(screen.getByRole('button', { name: /close/i })).toBeInTheDocument();
});
it('renders a save button when "Save as new" is selected', () => {
render(<SaveDatasetModal {...mockedProps} />, { useRedux: true });
// "Save as new" is selected when the modal opens by default
expect(screen.getByRole('button', { name: /save/i })).toBeVisible();
expect(screen.getByRole('button', { name: /save/i })).toBeInTheDocument();
});
it('renders an overwrite button when "Overwrite existing" is selected', () => {
@@ -117,7 +117,9 @@ describe('SaveDatasetModal', () => {
});
userEvent.click(overwriteRadioBtn);
expect(screen.getByRole('button', { name: /overwrite/i })).toBeVisible();
expect(
screen.getByRole('button', { name: /overwrite/i }),
).toBeInTheDocument();
});
it('renders the overwrite button as disabled until an existing dataset is selected', async () => {
@@ -181,14 +183,16 @@ describe('SaveDatasetModal', () => {
userEvent.click(overwriteConfirmationBtn);
// Overwrite screen text
expect(screen.getByText(/save or overwrite dataset/i)).toBeVisible();
expect(screen.getByText(/save or overwrite dataset/i)).toBeInTheDocument();
expect(
screen.getByText(/are you sure you want to overwrite this dataset\?/i),
).toBeVisible();
).toBeInTheDocument();
// Overwrite screen buttons
expect(screen.getByRole('button', { name: /close/i })).toBeVisible();
expect(screen.getByRole('button', { name: /back/i })).toBeVisible();
expect(screen.getByRole('button', { name: /overwrite/i })).toBeVisible();
expect(screen.getByRole('button', { name: /close/i })).toBeInTheDocument();
expect(screen.getByRole('button', { name: /back/i })).toBeInTheDocument();
expect(
screen.getByRole('button', { name: /overwrite/i }),
).toBeInTheDocument();
});
it('sends the schema when creating the dataset', async () => {