You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by mi...@apache.org on 2022/09/09 11:31:46 UTC
[superset] branch master updated: test: Fix act errors in ExploreChartHeader test (#21402)
This is an automated email from the ASF dual-hosted git repository.
michaelsmolina pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/superset.git
The following commit(s) were added to refs/heads/master by this push:
new d635566c16 test: Fix act errors in ExploreChartHeader test (#21402)
d635566c16 is described below
commit d635566c16e2bf86461a5f9b8c5b2abb127a7160
Author: Lyndsi Kay Williams <55...@users.noreply.github.com>
AuthorDate: Fri Sep 9 06:31:33 2022 -0500
test: Fix act errors in ExploreChartHeader test (#21402)
---
.../ExploreChartHeader/ExploreChartHeader.test.tsx | 31 +++++++++++++++-------
1 file changed, 21 insertions(+), 10 deletions(-)
diff --git a/superset-frontend/src/explore/components/ExploreChartHeader/ExploreChartHeader.test.tsx b/superset-frontend/src/explore/components/ExploreChartHeader/ExploreChartHeader.test.tsx
index 2f55db6129..6ac8f91bee 100644
--- a/superset-frontend/src/explore/components/ExploreChartHeader/ExploreChartHeader.test.tsx
+++ b/superset-frontend/src/explore/components/ExploreChartHeader/ExploreChartHeader.test.tsx
@@ -120,16 +120,19 @@ fetchMock.post(
},
);
-test('Cancelling changes to the properties should reset previous properties', () => {
+test('Cancelling changes to the properties should reset previous properties', async () => {
const props = createProps();
render(<ExploreHeader {...props} />, { useRedux: true });
const newChartName = 'New chart name';
const prevChartName = props.slice_name;
+ expect(
+ await screen.findByText(/add the name of the chart/i),
+ ).toBeInTheDocument();
userEvent.click(screen.getByLabelText('Menu actions trigger'));
userEvent.click(screen.getByText('Edit chart properties'));
- const nameInput = screen.getByRole('textbox', { name: 'Name' });
+ const nameInput = await screen.findByRole('textbox', { name: 'Name' });
userEvent.clear(nameInput);
userEvent.type(nameInput, newChartName);
@@ -141,31 +144,35 @@ test('Cancelling changes to the properties should reset previous properties', ()
userEvent.click(screen.getByLabelText('Menu actions trigger'));
userEvent.click(screen.getByText('Edit chart properties'));
- expect(screen.getByDisplayValue(prevChartName)).toBeInTheDocument();
+ expect(await screen.findByDisplayValue(prevChartName)).toBeInTheDocument();
});
-test('Save chart', () => {
+test('Save chart', async () => {
const props = createProps();
render(<ExploreHeader {...props} />, { useRedux: true });
+ expect(await screen.findByText('Save')).toBeInTheDocument();
userEvent.click(screen.getByText('Save'));
expect(props.onSaveChart).toHaveBeenCalled();
});
-test('Save disabled', () => {
+test('Save disabled', async () => {
const props = createProps();
render(<ExploreHeader {...props} saveDisabled />, { useRedux: true });
+ expect(await screen.findByText('Save')).toBeInTheDocument();
userEvent.click(screen.getByText('Save'));
expect(props.onSaveChart).not.toHaveBeenCalled();
});
describe('Additional actions tests', () => {
- test('Should render a button', () => {
+ test('Should render a button', async () => {
const props = createProps();
render(<ExploreHeader {...props} />, { useRedux: true });
- expect(screen.getByLabelText('Menu actions trigger')).toBeInTheDocument();
+ expect(
+ await screen.findByLabelText('Menu actions trigger'),
+ ).toBeInTheDocument();
});
- test('Should open a menu', () => {
+ test('Should open a menu', async () => {
const props = createProps();
render(<ExploreHeader {...props} />, {
useRedux: true,
@@ -173,7 +180,9 @@ describe('Additional actions tests', () => {
userEvent.click(screen.getByLabelText('Menu actions trigger'));
- expect(screen.getByText('Edit chart properties')).toBeInTheDocument();
+ expect(
+ await screen.findByText('Edit chart properties'),
+ ).toBeInTheDocument();
expect(screen.getByText('Download')).toBeInTheDocument();
expect(screen.getByText('Share')).toBeInTheDocument();
expect(screen.getByText('View query')).toBeInTheDocument();
@@ -257,11 +266,12 @@ describe('Additional actions tests', () => {
await waitFor(() => expect(getChartDataRequest).toBeCalledTimes(1));
});
- test('Should call onOpenInEditor when click on "Run in SQL Lab"', () => {
+ test('Should call onOpenInEditor when click on "Run in SQL Lab"', async () => {
const props = createProps();
render(<ExploreHeader {...props} />, {
useRedux: true,
});
+ expect(await screen.findByText('Save')).toBeInTheDocument();
expect(props.actions.redirectSQLLab).toBeCalledTimes(0);
userEvent.click(screen.getByLabelText('Menu actions trigger'));
@@ -283,6 +293,7 @@ describe('Additional actions tests', () => {
spyDownloadAsImage.restore();
spyExportChart.restore();
});
+
test('Should call downloadAsImage when click on "Download as image"', async () => {
const props = createProps();
const spy = jest.spyOn(downloadAsImage, 'default');