bito-code-review[bot] commented on code in PR #44850:
URL: https://github.com/apache/superset/pull/44850#discussion_r4167659626


##########
superset-frontend/src/explore/components/controls/ViewQueryModalFooter.test.tsx:
##########
@@ -0,0 +1,107 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import { SupersetClient } from '@superset-ui/core';
+import {
+  fireEvent,
+  render,
+  screen,
+  userEvent,
+} from 'spec/helpers/testing-library';
+import ViewQueryModalFooter from './ViewQueryModalFooter';
+
+const datasource = { id: '7', type: 'table', sql: 'SELECT 1' };
+
+const setup = () => {
+  const closeModal = jest.fn();
+  const changeDatasource = jest.fn();
+  render(
+    <ViewQueryModalFooter
+      closeModal={closeModal}
+      changeDatasource={changeDatasource}
+      datasource={datasource}
+    />,
+    { useRouter: true },
+  );
+  return { closeModal, changeDatasource };
+};
+
+beforeEach(() => {
+  window.history.replaceState(null, '', '/explore/');
+});
+
+afterEach(() => {
+  jest.restoreAllMocks();
+});
+
+test('renders the footer actions', () => {
+  setup();
+  expect(screen.getByRole('button', { name: 'Close' })).toBeInTheDocument();
+  expect(
+    screen.getByRole('button', { name: 'Save as Dataset' }),
+  ).toBeInTheDocument();
+  expect(
+    screen.getByRole('button', { name: 'Open in SQL Lab' }),
+  ).toBeInTheDocument();
+});
+
+test('Open in SQL Lab navigates in-app with the requested query', async () => {
+  const postForm = jest
+    .spyOn(SupersetClient, 'postForm')
+    .mockResolvedValue(undefined);
+  setup();
+  await userEvent.click(
+    screen.getByRole('button', { name: 'Open in SQL Lab' }),
+  );
+  expect(window.location.pathname).toBe('/sqllab');
+  expect(window.history.state.state).toEqual({

Review Comment:
   <!-- Bito Reply -->
   The reviewer's suggestion to avoid asserting on `window.history.state.state` 
is correct. As you noted, relying on the internal serialization of the history 
library is fragile, and using `useLocation` is the recommended approach for 
accessing router state in React Router. Since you have already updated the 
implementation to use `useLocation`, the suggestion is effectively addressed.



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

Reply via email to