mirror of
https://github.com/apache/superset.git
synced 2024-09-07 06:17:45 -04:00
test: Fixes act errors in ReportModal test (#21420)
This commit is contained in:
parent
c3527da362
commit
741d1d78c6
@ -20,7 +20,7 @@ import * as React from 'react';
|
|||||||
import userEvent from '@testing-library/user-event';
|
import userEvent from '@testing-library/user-event';
|
||||||
import sinon from 'sinon';
|
import sinon from 'sinon';
|
||||||
import fetchMock from 'fetch-mock';
|
import fetchMock from 'fetch-mock';
|
||||||
import { render, screen } from 'spec/helpers/testing-library';
|
import { render, screen, waitFor } from 'spec/helpers/testing-library';
|
||||||
import * as featureFlags from 'src/featureFlags';
|
import * as featureFlags from 'src/featureFlags';
|
||||||
import * as actions from 'src/reports/actions/reports';
|
import * as actions from 'src/reports/actions/reports';
|
||||||
import { FeatureFlag } from '@superset-ui/core';
|
import { FeatureFlag } from '@superset-ui/core';
|
||||||
@ -33,6 +33,8 @@ fetchMock.get(REPORT_ENDPOINT, {});
|
|||||||
|
|
||||||
const NOOP = () => {};
|
const NOOP = () => {};
|
||||||
|
|
||||||
|
jest.mock('src/components/Icons/Icon', () => () => <span />);
|
||||||
|
|
||||||
const defaultProps = {
|
const defaultProps = {
|
||||||
addDangerToast: NOOP,
|
addDangerToast: NOOP,
|
||||||
addSuccessToast: NOOP,
|
addSuccessToast: NOOP,
|
||||||
@ -156,7 +158,7 @@ describe('Email Report Modal', () => {
|
|||||||
|
|
||||||
// Click "Add" button to create a new email report
|
// Click "Add" button to create a new email report
|
||||||
const addButton = screen.getByRole('button', { name: /add/i });
|
const addButton = screen.getByRole('button', { name: /add/i });
|
||||||
userEvent.click(addButton);
|
await waitFor(() => userEvent.click(addButton));
|
||||||
|
|
||||||
// Mock addReport from Redux
|
// Mock addReport from Redux
|
||||||
const makeRequest = () => {
|
const makeRequest = () => {
|
||||||
@ -164,16 +166,15 @@ describe('Email Report Modal', () => {
|
|||||||
return request(dispatch);
|
return request(dispatch);
|
||||||
};
|
};
|
||||||
|
|
||||||
return makeRequest().then(() => {
|
await makeRequest();
|
||||||
// 🐞 ----- There are 2 POST calls at this point ----- 🐞
|
|
||||||
|
|
||||||
// addReport's mocked POST return should match the mocked values
|
// 🐞 ----- There are 2 POST calls at this point ----- 🐞
|
||||||
expect(fetchMock.lastOptions()?.body).toEqual(stringyReportValues);
|
|
||||||
// Dispatch should be called once for addReport
|
// addReport's mocked POST return should match the mocked values
|
||||||
expect(dispatch.callCount).toBe(2);
|
expect(fetchMock.lastOptions()?.body).toEqual(stringyReportValues);
|
||||||
const reportCalls = fetchMock.calls(REPORT_ENDPOINT);
|
expect(dispatch.callCount).toBe(2);
|
||||||
expect(reportCalls).toHaveLength(2);
|
const reportCalls = fetchMock.calls(REPORT_ENDPOINT);
|
||||||
});
|
expect(reportCalls).toHaveLength(2);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user