AAfghahi commented on a change in pull request #13630:
URL: https://github.com/apache/superset/pull/13630#discussion_r595204336



##########
File path: superset-frontend/spec/javascripts/sqllab/ShareSqlLabQuery_spec.jsx
##########
@@ -145,37 +99,42 @@ describe('ShareSqlLabQuery', () => {
       isFeatureEnabledMock.restore();
     });
 
-    it('does not call storeQuery() with the query when getCopyUrl() is 
called', () => {
+    it('does not call storeQuery() with the query when getCopyUrl() is called 
and feature is not enabled', async () => {
+      await act(async () => {
+        render(
+          <ThemeProvider theme={supersetTheme}>
+            <Provider store={store}>
+              <ShareSqlLabQuery {...defaultProps} />
+            </Provider>
+          </ThemeProvider>,
+        );
+      });
       const storeQuerySpy = jest.spyOn(utils, 'storeQuery');
-
-      const wrapper = setup();
-      const instance = wrapper.instance();
-
-      instance.getCopyUrl(clipboardSpy);
-
+      const button = screen.getByRole('button');
+      userEvent.click(button);
       expect(storeQuerySpy.mock.calls).toHaveLength(0);
-      expect(fetchMock.calls(storeQueryUrl)).toHaveLength(0);
-      expect(clipboardSpy).toHaveBeenCalledWith(
-        expect.stringContaining('savedQueryId'),
-      );
-
       storeQuerySpy.mockRestore();
     });
 
-    it('shows a request to save the query when the query is not yet saved', () 
=> {
-      const wrapper = setup({
+    it('button is disabled and there is a request to save the query', async () 
=> {
+      const updatedProps = {
         queryEditor: {
           ...defaultProps.queryEditor,
           remoteId: undefined,
         },
+      };
+      await act(async () => {
+        render(
+          <ThemeProvider theme={supersetTheme}>
+            <Provider store={store}>
+              <ShareSqlLabQuery {...updatedProps} />
+            </Provider>
+          </ThemeProvider>,

Review comment:
       Thank you, this looks a lot more elegant. 




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to