codeant-ai-for-open-source[bot] commented on code in PR #44850:
URL: https://github.com/apache/superset/pull/44850#discussion_r4150672830


##########
superset-frontend/src/explore/components/controls/MapViewControl/MapViewControl.test.tsx:
##########
@@ -0,0 +1,134 @@
+/**
+ * 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 {
+  fireEvent,
+  render,
+  screen,
+  userEvent,
+} from 'spec/helpers/testing-library';
+import MapViewControl from './MapViewControl';
+import { MapViewConfigs } from './types';
+
+const makeValue = (
+  overrides: Partial<MapViewConfigs> = {},
+): MapViewConfigs => ({
+  mode: 'CUSTOM',
+  zoom: 7,
+  latitude: 48.5,
+  longitude: 9.25,
+  fixedZoom: 4,
+  fixedLatitude: 10,
+  fixedLongitude: 20,
+  ...overrides,
+});
+
+const setup = (value?: MapViewConfigs) => {
+  const onChange = jest.fn();
+  render(
+    <MapViewControl
+      name="map_view"
+      label="Extent"
+      value={value}
+      onChange={onChange}
+    />,
+  );
+  return { onChange };
+};
+
+test('renders the label and the two extent modes', () => {
+  setup(makeValue({ mode: 'FIT_DATA' }));
+  expect(screen.getByText('Extent')).toBeInTheDocument();
+  expect(screen.getByRole('radio', { name: 'Fit data' })).toBeChecked();
+  expect(screen.getByRole('radio', { name: 'Custom' })).not.toBeChecked();
+});
+
+test('hides the extent tag and button in fit data mode', () => {
+  setup(makeValue({ mode: 'FIT_DATA' }));
+  expect(screen.queryByText(/Lat:/)).not.toBeInTheDocument();
+  expect(
+    screen.queryByRole('button', { name: 'Use current extent' }),
+  ).not.toBeInTheDocument();
+});
+
+test('shows the fixed extent in custom mode', () => {
+  setup(makeValue());
+  expect(screen.getByText(/Zoom: 4/)).toHaveTextContent(
+    'Zoom: 4 | Lat: 10.000000 | Lon: 20.000000',
+  );
+  expect(
+    screen.getByRole('button', { name: 'Use current extent' }),
+  ).toBeInTheDocument();
+});
+
+test('shows unset for missing extent values', () => {
+  // Saved configs may omit the fixed extent entirely, which the type forbids.
+  setup({
+    ...makeValue(),
+    fixedZoom: undefined,
+    fixedLatitude: undefined,
+    fixedLongitude: undefined,
+  } as unknown as MapViewConfigs);
+  expect(screen.getByText(/Zoom:/)).toHaveTextContent(
+    'Zoom: unset | Lat: unset | Lon: unset',
+  );

Review Comment:
   **Suggestion:** The test covers only undefined values, so valid zero extents 
can still render as unset without this suite detecting the boundary-value bug.
   
   **Assessment:** ๐ŸŸ  `Major` ยท ๐Ÿ” `Occurrence: Sometimes` ยท ๐Ÿท๏ธ `Possible bug`
   
   [![Use CodeAnt 
Skill](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/use-codeant-skill-flat-v2.svg)](https://docs.codeant.ai/cli/resolve-pr-comments-skill)
 [![Fix in 
Cursor](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-cursor-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=08a25258ce5a4df7b260bf52dcb4b26a&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
 [![Fix in VSCode 
Claude](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-vscode-claude-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=08a25258ce5a4df7b260bf52dcb4b26a&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   <details>
   <summary><b>Prompt for AI Agent ๐Ÿค– </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** 
superset-frontend/src/explore/components/controls/MapViewControl/MapViewControl.test.tsx
   **Line:** 81:89
   **Comment:**
        *Possible Bug: The test covers only undefined values, so valid zero 
extents can still render as unset without this suite detecting the 
boundary-value bug.
   
   Validate the correctness of the flagged issue. If correct, How can I resolve 
this? If you propose a fix, implement it and please make it concise.
   Once fix is implemented, also check other comments on the same PR, and ask 
user if the user wants to fix the rest of the comments as well. if said yes, 
then fetch all the comments validate the correctness and implement a minimal fix
   ```
   </details>
   <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F44850&comment_hash=c89c67f4722b8760c9f77cd1fd6cefbdcd012ea50c0ee66bf3f3624a832c851b&reaction=like'>๐Ÿ‘</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F44850&comment_hash=c89c67f4722b8760c9f77cd1fd6cefbdcd012ea50c0ee66bf3f3624a832c851b&reaction=dislike'>๐Ÿ‘Ž</a>



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