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 21:39:14 UTC

[superset] branch master updated: test: Fixes act errors in ReportModal test (#21420)

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 741d1d78c6 test: Fixes act errors in ReportModal test (#21420)
741d1d78c6 is described below

commit 741d1d78c61854322184244d08aff3b530064b56
Author: Michael S. Molina <70...@users.noreply.github.com>
AuthorDate: Fri Sep 9 18:39:00 2022 -0300

    test: Fixes act errors in ReportModal test (#21420)
---
 .../components/ReportModal/ReportModal.test.tsx    | 23 +++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/superset-frontend/src/components/ReportModal/ReportModal.test.tsx b/superset-frontend/src/components/ReportModal/ReportModal.test.tsx
index 1db3aa0fd6..d33d7d62e1 100644
--- a/superset-frontend/src/components/ReportModal/ReportModal.test.tsx
+++ b/superset-frontend/src/components/ReportModal/ReportModal.test.tsx
@@ -20,7 +20,7 @@ import * as React from 'react';
 import userEvent from '@testing-library/user-event';
 import sinon from 'sinon';
 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 actions from 'src/reports/actions/reports';
 import { FeatureFlag } from '@superset-ui/core';
@@ -33,6 +33,8 @@ fetchMock.get(REPORT_ENDPOINT, {});
 
 const NOOP = () => {};
 
+jest.mock('src/components/Icons/Icon', () => () => <span />);
+
 const defaultProps = {
   addDangerToast: NOOP,
   addSuccessToast: NOOP,
@@ -156,7 +158,7 @@ describe('Email Report Modal', () => {
 
       // Click "Add" button to create a new email report
       const addButton = screen.getByRole('button', { name: /add/i });
-      userEvent.click(addButton);
+      await waitFor(() => userEvent.click(addButton));
 
       // Mock addReport from Redux
       const makeRequest = () => {
@@ -164,16 +166,15 @@ describe('Email Report Modal', () => {
         return request(dispatch);
       };
 
-      return makeRequest().then(() => {
-        // 🐞 ----- There are 2 POST calls at this point ----- 🐞
+      await makeRequest();
+
+      // 🐞 ----- 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);
-      });
+      // addReport's mocked POST return should match the mocked values
+      expect(fetchMock.lastOptions()?.body).toEqual(stringyReportValues);
+      expect(dispatch.callCount).toBe(2);
+      const reportCalls = fetchMock.calls(REPORT_ENDPOINT);
+      expect(reportCalls).toHaveLength(2);
     });
   });
 });