You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by di...@apache.org on 2024/12/19 13:16:52 UTC
(superset) branch alexandrusoare/refactor/antd5-modal created (now 81f66ef2d1)
This is an automated email from the ASF dual-hosted git repository.
diegopucci pushed a change to branch alexandrusoare/refactor/antd5-modal
in repository https://gitbox.apache.org/repos/asf/superset.git
at 81f66ef2d1 fix(unittests): fixing unittests
This branch includes the following new commits:
new 81f66ef2d1 fix(unittests): fixing unittests
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(superset) 01/01: fix(unittests): fixing unittests
Posted by di...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
diegopucci pushed a commit to branch alexandrusoare/refactor/antd5-modal
in repository https://gitbox.apache.org/repos/asf/superset.git
commit 81f66ef2d1f279635e36ccb4eadc739f9569b9a4
Author: alexandrusoare <al...@gmail.com>
AuthorDate: Mon Dec 16 15:14:50 2024 +0200
fix(unittests): fixing unittests
---
superset-frontend/src/GlobalStyles.tsx | 4 +++
.../SaveDatasetModal/SaveDatasetModal.test.tsx | 36 ++++++++++++----------
.../DrillDetail/DrillDetailMenuItems.test.tsx | 2 +-
.../components/DeleteModal/DeleteModal.test.tsx | 4 +--
.../components/RefreshIntervalModal.test.tsx | 2 +-
.../ScopingModal/ScopingModal.test.tsx | 2 +-
.../nativeFilters/FilterCard/FilterCard.test.tsx | 2 +-
.../ExploreChartHeader/ExploreChartHeader.test.tsx | 4 ++-
.../PropertiesModal/PropertiesModal.test.tsx | 20 ++++++------
.../DatasourceControl/DatasourceControl.test.tsx | 10 +++---
.../databases/DatabaseModal/index.test.tsx | 32 +++++++++----------
11 files changed, 64 insertions(+), 54 deletions(-)
diff --git a/superset-frontend/src/GlobalStyles.tsx b/superset-frontend/src/GlobalStyles.tsx
index 282ca33bd0..4a42c9bfb5 100644
--- a/superset-frontend/src/GlobalStyles.tsx
+++ b/superset-frontend/src/GlobalStyles.tsx
@@ -39,6 +39,10 @@ export const GlobalStyles = () => (
.echarts-tooltip[style*='visibility: hidden'] {
display: none !important;
}
+ .antd5-dropdown,
+ .ant-dropdown {
+ z-index: ${theme.zIndex.max};
+ }
// TODO: Remove when buttons have been upgraded to Ant Design 5.
// Check src/components/Modal for more info.
.ant-modal-confirm {
diff --git a/superset-frontend/src/SqlLab/components/SaveDatasetModal/SaveDatasetModal.test.tsx b/superset-frontend/src/SqlLab/components/SaveDatasetModal/SaveDatasetModal.test.tsx
index de22d0db40..19f8e6316b 100644
--- a/superset-frontend/src/SqlLab/components/SaveDatasetModal/SaveDatasetModal.test.tsx
+++ b/superset-frontend/src/SqlLab/components/SaveDatasetModal/SaveDatasetModal.test.tsx
@@ -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 () => {
diff --git a/superset-frontend/src/components/Chart/DrillDetail/DrillDetailMenuItems.test.tsx b/superset-frontend/src/components/Chart/DrillDetail/DrillDetailMenuItems.test.tsx
index c64ed30e81..184d3865b2 100644
--- a/superset-frontend/src/components/Chart/DrillDetail/DrillDetailMenuItems.test.tsx
+++ b/superset-frontend/src/components/Chart/DrillDetail/DrillDetailMenuItems.test.tsx
@@ -122,7 +122,7 @@ const expectDrillToDetailModal = async (
name: `Drill to detail: ${chartName}`,
});
- expect(modal).toBeVisible();
+ expect(modal).toBeInTheDocument();
expect(screen.getByTestId('modal-filters')).toHaveTextContent(
JSON.stringify(filters),
);
diff --git a/superset-frontend/src/components/DeleteModal/DeleteModal.test.tsx b/superset-frontend/src/components/DeleteModal/DeleteModal.test.tsx
index 3db4cd4f21..9b5316a698 100644
--- a/superset-frontend/src/components/DeleteModal/DeleteModal.test.tsx
+++ b/superset-frontend/src/components/DeleteModal/DeleteModal.test.tsx
@@ -30,9 +30,9 @@ test('Must display title and content', () => {
};
render(<DeleteModal {...props} />);
expect(screen.getByTestId('test-title')).toBeInTheDocument();
- expect(screen.getByTestId('test-title')).toBeVisible();
+ expect(screen.getByTestId('test-title')).toBeInTheDocument();
+ expect(screen.getByTestId('test-description')).toBeInTheDocument();
expect(screen.getByTestId('test-description')).toBeInTheDocument();
- expect(screen.getByTestId('test-description')).toBeVisible();
});
test('Calling "onHide"', () => {
diff --git a/superset-frontend/src/dashboard/components/RefreshIntervalModal.test.tsx b/superset-frontend/src/dashboard/components/RefreshIntervalModal.test.tsx
index a8aac270d7..af66763375 100644
--- a/superset-frontend/src/dashboard/components/RefreshIntervalModal.test.tsx
+++ b/superset-frontend/src/dashboard/components/RefreshIntervalModal.test.tsx
@@ -121,7 +121,7 @@ test('renders refresh interval modal', async () => {
await openRefreshIntervalModal();
// Assert that modal exists by checking for the modal title
- expect(screen.getByText('Refresh interval')).toBeVisible();
+ expect(screen.getByText('Refresh interval')).toBeInTheDocument();
});
test('renders refresh interval options', async () => {
diff --git a/superset-frontend/src/dashboard/components/nativeFilters/FilterBar/CrossFilters/ScopingModal/ScopingModal.test.tsx b/superset-frontend/src/dashboard/components/nativeFilters/FilterBar/CrossFilters/ScopingModal/ScopingModal.test.tsx
index 8914398c54..9530de516b 100644
--- a/superset-frontend/src/dashboard/components/nativeFilters/FilterBar/CrossFilters/ScopingModal/ScopingModal.test.tsx
+++ b/superset-frontend/src/dashboard/components/nativeFilters/FilterBar/CrossFilters/ScopingModal/ScopingModal.test.tsx
@@ -160,7 +160,7 @@ afterEach(() => {
it('renders modal', () => {
setup();
- expect(screen.getByRole('dialog')).toBeVisible();
+ expect(screen.getByRole('dialog')).toBeInTheDocument();
expect(screen.getByTestId('scoping-tree-panel')).toBeInTheDocument();
expect(screen.getByTestId('scoping-list-panel')).toBeInTheDocument();
});
diff --git a/superset-frontend/src/dashboard/components/nativeFilters/FilterCard/FilterCard.test.tsx b/superset-frontend/src/dashboard/components/nativeFilters/FilterCard/FilterCard.test.tsx
index e1ded0035e..b1727fab0b 100644
--- a/superset-frontend/src/dashboard/components/nativeFilters/FilterCard/FilterCard.test.tsx
+++ b/superset-frontend/src/dashboard/components/nativeFilters/FilterCard/FilterCard.test.tsx
@@ -328,5 +328,5 @@ test('open modal on edit filter button click', async () => {
userEvent.click(editButton);
expect(
await screen.findByRole('dialog', { name: /add and edit filters/i }),
- ).toBeVisible();
+ ).toBeInTheDocument();
});
diff --git a/superset-frontend/src/explore/components/ExploreChartHeader/ExploreChartHeader.test.tsx b/superset-frontend/src/explore/components/ExploreChartHeader/ExploreChartHeader.test.tsx
index bba5504e1a..42d8153b48 100644
--- a/superset-frontend/src/explore/components/ExploreChartHeader/ExploreChartHeader.test.tsx
+++ b/superset-frontend/src/explore/components/ExploreChartHeader/ExploreChartHeader.test.tsx
@@ -299,7 +299,9 @@ describe('Additional actions tests', () => {
userEvent.click(
screen.getByRole('menuitem', { name: 'Edit chart properties' }),
);
- expect(await screen.findByText('Edit Chart Properties')).toBeVisible();
+ expect(
+ await screen.findByText('Edit Chart Properties'),
+ ).toBeInTheDocument();
});
test('Should call getChartDataRequest when click on "View query"', async () => {
diff --git a/superset-frontend/src/explore/components/PropertiesModal/PropertiesModal.test.tsx b/superset-frontend/src/explore/components/PropertiesModal/PropertiesModal.test.tsx
index 7e03f843ab..4d9b554746 100644
--- a/superset-frontend/src/explore/components/PropertiesModal/PropertiesModal.test.tsx
+++ b/superset-frontend/src/explore/components/PropertiesModal/PropertiesModal.test.tsx
@@ -191,23 +191,23 @@ test('Should render all elements inside modal', async () => {
expect(screen.getByRole('combobox')).toBeInTheDocument();
expect(
screen.getByRole('heading', { name: 'Basic information' }),
- ).toBeVisible();
- expect(screen.getByText('Name')).toBeVisible();
- expect(screen.getByText('Description')).toBeVisible();
+ ).toBeInTheDocument();
+ expect(screen.getByText('Name')).toBeInTheDocument();
+ expect(screen.getByText('Description')).toBeInTheDocument();
expect(
screen.getByRole('heading', { name: 'Configuration' }),
- ).toBeVisible();
- expect(screen.getByText('Cache timeout')).toBeVisible();
+ ).toBeInTheDocument();
+ expect(screen.getByText('Cache timeout')).toBeInTheDocument();
- expect(screen.getByRole('heading', { name: 'Access' })).toBeVisible();
- expect(screen.getByText('Owners')).toBeVisible();
+ expect(screen.getByRole('heading', { name: 'Access' })).toBeInTheDocument();
+ expect(screen.getByText('Owners')).toBeInTheDocument();
expect(
screen.getByRole('heading', { name: 'Configuration' }),
- ).toBeVisible();
- expect(screen.getByText('Certified by')).toBeVisible();
- expect(screen.getByText('Certification details')).toBeVisible();
+ ).toBeInTheDocument();
+ expect(screen.getByText('Certified by')).toBeInTheDocument();
+ expect(screen.getByText('Certification details')).toBeInTheDocument();
});
});
diff --git a/superset-frontend/src/explore/components/controls/DatasourceControl/DatasourceControl.test.tsx b/superset-frontend/src/explore/components/controls/DatasourceControl/DatasourceControl.test.tsx
index 4227ff2f1d..7b3c22179d 100644
--- a/superset-frontend/src/explore/components/controls/DatasourceControl/DatasourceControl.test.tsx
+++ b/superset-frontend/src/explore/components/controls/DatasourceControl/DatasourceControl.test.tsx
@@ -324,11 +324,11 @@ test('Click on Save as dataset', async () => {
name: /overwrite existing/i,
});
const dropdownField = screen.getByText(/select or type dataset name/i);
- expect(saveRadioBtn).toBeVisible();
- expect(overwriteRadioBtn).toBeVisible();
- expect(screen.getByRole('button', { name: /save/i })).toBeVisible();
- expect(screen.getByRole('button', { name: /close/i })).toBeVisible();
- expect(dropdownField).toBeVisible();
+ expect(saveRadioBtn).toBeInTheDocument();
+ expect(overwriteRadioBtn).toBeInTheDocument();
+ expect(screen.getByRole('button', { name: /save/i })).toBeInTheDocument();
+ expect(screen.getByRole('button', { name: /close/i })).toBeInTheDocument();
+ expect(dropdownField).toBeInTheDocument();
});
test('should set the default temporal column', async () => {
diff --git a/superset-frontend/src/features/databases/DatabaseModal/index.test.tsx b/superset-frontend/src/features/databases/DatabaseModal/index.test.tsx
index 7326df4aa6..2f8eafeb7b 100644
--- a/superset-frontend/src/features/databases/DatabaseModal/index.test.tsx
+++ b/superset-frontend/src/features/databases/DatabaseModal/index.test.tsx
@@ -415,7 +415,7 @@ describe('DatabaseModal', () => {
];
visibleComponents.forEach(component => {
- expect(component).toBeInTheDocument();
+ expect(component).toBeVisible();
});
// there should be a footer but it should not have any buttons in it
expect(footer[0]).toBeEmptyDOMElement();
@@ -437,7 +437,7 @@ describe('DatabaseModal', () => {
const basicHeader = screen.getByRole('heading', {
name: /connect a database/i,
});
- expect(basicHeader).toBeInTheDocument();
+ expect(basicHeader).toBeVisible();
// <ModalHeader> - Connection header
const basicHelper = screen.getByText(/step 2 of 2/i);
@@ -525,7 +525,7 @@ describe('DatabaseModal', () => {
];
visibleComponents.forEach(component => {
- expect(component).toBeInTheDocument();
+ expect(component).toBeVisible();
});
});
@@ -1015,7 +1015,7 @@ describe('DatabaseModal', () => {
// ---------- Assertions ----------
visibleComponents.forEach(component => {
- expect(component).toBeInTheDocument();
+ expect(component).toBeVisible();
});
invisibleComponents.forEach(component => {
expect(component).not.toBeVisible();
@@ -1120,7 +1120,7 @@ describe('DatabaseModal', () => {
// Dynamic form has 3 steps, seeing this text means the dynamic form is present
const dynamicFormStepText = screen.getByText(/step 2 of 3/i);
- expect(dynamicFormStepText).toBeInTheDocument();
+ expect(dynamicFormStepText).toBeVisible();
// ---------- SQL Alchemy example (2-step form)
// Click the back button to go back to step 1,
@@ -1137,7 +1137,7 @@ describe('DatabaseModal', () => {
expect(await screen.findByText(/step 2 of 2/i)).toBeInTheDocument();
const sqlAlchemyFormStepText = screen.getByText(/step 2 of 2/i);
- expect(sqlAlchemyFormStepText).toBeInTheDocument();
+ expect(sqlAlchemyFormStepText).toBeVisible();
});
describe('SQL Alchemy form flow', () => {
@@ -1360,7 +1360,7 @@ describe('DatabaseModal', () => {
expect(await screen.findByText(/step 2 of 3/i)).toBeInTheDocument();
const step2of3text = screen.getByText(/step 2 of 3/i);
- expect(step2of3text).toBeInTheDocument();
+ expect(step2of3text).toBeVisible();
});
test('enters form credentials and runs fetchResource when "Connect" is clicked', async () => {
@@ -1411,7 +1411,7 @@ describe('DatabaseModal', () => {
) as HTMLInputElement;
importDbButton.type = 'file';
importDbButton.files = {} as FileList;
- expect(importDbButton).toBeInTheDocument();
+ expect(importDbButton).toBeVisible();
const testFile = new File([new ArrayBuffer(1)], 'model_export.zip');
@@ -1442,7 +1442,7 @@ describe('DatabaseModal', () => {
test('enters step 2 of 3 when proper database is selected', () => {
const step2of3text = screen.getByText(/step 2 of 3/i);
- expect(step2of3text).toBeInTheDocument();
+ expect(step2of3text).toBeVisible();
});
});
@@ -1468,7 +1468,7 @@ describe('DatabaseModal', () => {
it('enters step 2 of 2 when proper database is selected', () => {
const step2of2text = screen.getByText(/step 2 of 2/i);
- expect(step2of2text).toBeInTheDocument();
+ expect(step2of2text).toBeVisible();
});
it('renders the "Advanced" - SECURITY tab without Allow File Upload Checkbox', async () => {
@@ -1502,7 +1502,7 @@ describe('DatabaseModal', () => {
// ---------- Assertions ----------
visibleComponents.forEach(component => {
- expect(component).toBeInTheDocument();
+ expect(component).toBeVisible();
});
invisibleComponents.forEach(component => {
expect(component).not.toBeVisible();
@@ -1556,8 +1556,8 @@ describe('DatabaseModal', () => {
test('Error displays when it is an object', async () => {
const step2of3text = screen.getByText(/step 2 of 3/i);
const errorSection = screen.getByText(/Database Creation Error/i);
- expect(step2of3text).toBeInTheDocument();
- expect(errorSection).toBeInTheDocument();
+ expect(step2of3text).toBeVisible();
+ expect(errorSection).toBeVisible();
});
});
@@ -1604,11 +1604,11 @@ describe('DatabaseModal', () => {
const button = screen.getByText('See more');
userEvent.click(button);
const errorMessage = screen.getByText(/Test Error With String/i);
- expect(errorMessage).toBeInTheDocument();
+ expect(errorMessage).toBeVisible();
const closeButton = screen.getByText('Close');
userEvent.click(closeButton);
- expect(step2of3text).toBeInTheDocument();
- expect(errorTitleMessage).toBeInTheDocument();
+ expect(step2of3text).toBeVisible();
+ expect(errorTitleMessage).toBeVisible();
});
});