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


##########
superset-frontend/plugins/legacy-plugin-chart-country-map/test/countries/iran.test.ts:
##########
@@ -0,0 +1,59 @@
+/**
+ * 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 fs from 'fs';
+import path from 'path';
+
+// The geojson is loaded via fs rather than a normal import because the
+// webpack/jest loaders treat *.geojson as an opaque asset (a URL string in
+// the browser build, an empty mock object under jest), so neither exposes
+// the actual feature data to a unit test.
+const iranGeojsonPath = path.join(
+  __dirname,
+  '..',
+  '..',
+  'src',
+  'countries',
+  'iran.geojson',
+);
+
+type IranFeature = {
+  properties: { ISO: string; NAME_1: string };
+};
+
+const getIranFeatures = (): IranFeature[] =>
+  JSON.parse(fs.readFileSync(iranGeojsonPath, 'utf-8')).features;
+
+test('every province in the Iran map has a unique ISO code', () => {
+  const isoCodes = getIranFeatures().map(feature => feature.properties.ISO);
+  const uniqueIsoCodes = new Set(isoCodes);
+  expect(uniqueIsoCodes.size).toBe(isoCodes.length);
+});

Review Comment:
   **Suggestion:** The assertion only checks that the currently loaded ISO 
values are pairwise distinct; it passes for an empty or incomplete feature 
collection and does not verify that all expected Iranian provinces are present 
or that ISO values are non-empty. Consequently, deleting a province from the 
GeoJSON could go unnoticed. Assert the expected province/code set or at least 
the expected feature count and required fields. [incomplete implementation]
   
   <details>
   <summary><b>Severity Level:</b> Major ⚠️</summary>
   
   ```mdx
   - ⚠️ Missing provinces can pass regression tests.
   - ❌ Deleted provinces disappear from Iran map rendering.
   - ⚠️ ISO-keyed data cannot color absent features.
   ```
   </details>
   <details>
   <summary><b>Steps of Reproduction ✅ </b></summary>
   
   ```mdx
   1. Run the Iran country-map tests, which load
   
`superset-frontend/plugins/legacy-plugin-chart-country-map/src/countries/iran.geojson`
   through `getIranFeatures()` at `iran.test.ts:39-40`.
   
   2. Remove any province feature from the GeoJSON, or replace its `features` 
array with an
   empty array, without changing the test.
   
   3. The assertion at `iran.test.ts:43-45` maps the remaining ISO values and 
compares the
   set size with that same remaining array length; an empty or incomplete 
collection
   therefore still satisfies the equality.
   
   4. The production map consumes each feature's `properties.ISO` for coloring 
at
   
`superset-frontend/plugins/legacy-plugin-chart-country-map/src/CountryMap.ts:129-132`
 and
   data matching at `CountryMap.ts:254`, so a deleted province would be absent 
or uncolorable
   while the regression test remained green. Assert the expected 31-feature 
province set and
   required non-empty `ISO` and `NAME_1` fields.
   ```
   </details>
   
   [![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=5f3fb683abe047328a782c2bc4b1d0bf&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=5f3fb683abe047328a782c2bc4b1d0bf&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   
   *(Use Cmd/Ctrl + Click for best experience)*
   <details>
   <summary><b>Prompt for AI Agent 🤖 </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** 
superset-frontend/plugins/legacy-plugin-chart-country-map/test/countries/iran.test.ts
   **Line:** 42:46
   **Comment:**
        *Incomplete Implementation: The assertion only checks that the 
currently loaded ISO values are pairwise distinct; it passes for an empty or 
incomplete feature collection and does not verify that all expected Iranian 
provinces are present or that ISO values are non-empty. Consequently, deleting 
a province from the GeoJSON could go unnoticed. Assert the expected 
province/code set or at least the expected feature count and required fields.
   
   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%2F42439&comment_hash=9bb5a59ce2ca5618c5a4e61a2604f7cfe06d41f769b837e4fc9bc00cab486301&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F42439&comment_hash=9bb5a59ce2ca5618c5a4e61a2604f7cfe06d41f769b837e4fc9bc00cab486301&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