AAfghahi commented on a change in pull request #18131:
URL: https://github.com/apache/superset/pull/18131#discussion_r803130374
##########
File path: superset-frontend/src/dashboard/components/Header/Header.test.tsx
##########
@@ -323,171 +319,3 @@ test('should refresh the charts', async () => {
userEvent.click(screen.getByText('Refresh dashboard'));
expect(mockedProps.onRefresh).toHaveBeenCalledTimes(1);
});
-
-describe('Email Report Modal', () => {
- let isFeatureEnabledMock: any;
- let dispatch: any;
-
- beforeEach(async () => {
- isFeatureEnabledMock = jest
- .spyOn(featureFlags, 'isFeatureEnabled')
- .mockImplementation(() => true);
- dispatch = sinon.spy();
- });
-
- afterAll(() => {
- isFeatureEnabledMock.mockRestore();
- });
-
- it('creates a new email report', async () => {
- // ---------- Render/value setup ----------
- const mockedProps = createProps();
- setup(mockedProps);
-
- const reportValues = {
- id: 1,
- result: {
- active: true,
- creation_method: 'dashboards',
- crontab: '0 12 * * 1',
- dashboard: mockedProps.dashboardInfo.id,
- name: 'Weekly Report',
- owners: [mockedProps.user.userId],
- recipients: [
- {
- recipient_config_json: {
- target: mockedProps.user.email,
- },
- type: 'Email',
- },
- ],
- type: 'Report',
- },
- };
- // This is needed to structure the reportValues to match the fetchMock
return
- const stringyReportValues =
`{"id":1,"result":{"active":true,"creation_method":"dashboards","crontab":"0 12
* * 1","dashboard":${mockedProps.dashboardInfo.id},"name":"Weekly
Report","owners":[${mockedProps.user.userId}],"recipients":[{"recipient_config_json":{"target":"${mockedProps.user.email}"},"type":"Email"}],"type":"Report"}}`;
- // Watch for report POST
- fetchMock.post(REPORT_ENDPOINT, reportValues);
-
- screen.logTestingPlaygroundURL();
- // ---------- Begin tests ----------
- // Click calendar icon to open email report modal
- const emailReportModalButton = screen.getByRole('button', {
- name: /schedule email report/i,
- });
- userEvent.click(emailReportModalButton);
-
- // Click "Add" button to create a new email report
- const addButton = screen.getByRole('button', { name: /add/i });
- userEvent.click(addButton);
-
- // Mock addReport from Redux
- const makeRequest = () => {
- const request = actions.addReport(reportValues);
- return request(dispatch);
- };
-
- return makeRequest().then(() => {
- // 🐞 ----- There are 2 POST calls at this point ----- 🐞
-
- // addReport's mocked POST return should match the mocked values
- expect(fetchMock.lastOptions()?.body).toEqual(stringyReportValues);
- // Dispatch should be called once for addReport
- expect(dispatch.callCount).toBe(2);
- const reportCalls = fetchMock.calls(REPORT_ENDPOINT);
- expect(reportCalls).toHaveLength(2);
- });
- });
-
- it('edits an existing email report', async () => {
- // TODO (lyndsiWilliams): This currently does not work, see TODOs below
- // The modal does appear with the edit title, but the PUT call is not
registering
-
- // ---------- Render/value setup ----------
- const mockedProps = createProps();
- const editedReportValues = {
- active: true,
- creation_method: 'dashboards',
- crontab: '0 12 * * 1',
- dashboard: mockedProps.dashboardInfo.id,
- name: 'Weekly Report edit',
- owners: [mockedProps.user.userId],
- recipients: [
- {
- recipient_config_json: {
- target: mockedProps.user.email,
- },
- type: 'Email',
- },
- ],
- type: 'Report',
- };
-
- // getMockStore({ reports: reportValues });
- setup(mockedProps, mockState);
- // TODO (lyndsiWilliams): currently fetchMock detects this PUT
- // address as 'glob:*/api/v1/report/undefined', is not detected
- // on fetchMock.calls()
- fetchMock.put(`glob:*/api/v1/report*`, editedReportValues);
-
- // Mock fetchUISpecificReport from Redux
Review comment:
wait, this is removed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]