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


##########
superset-frontend/plugins/legacy-preset-chart-nvd3/test/TimePivot/controlPanel.test.ts:
##########
@@ -0,0 +1,57 @@
+/**
+ * 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 { SqlaFormData } from '@superset-ui/core';
+import * as ChartControls from '@superset-ui/chart-controls';
+import controlPanel from '../../src/TimePivot/controlPanel';
+
+const { __mockShiftMetric } = ChartControls as typeof ChartControls & {
+  __mockShiftMetric: jest.Mock;
+};
+
+jest.mock('@superset-ui/core', () => ({
+  ...jest.requireActual('@superset-ui/core'),
+  t: (str: string) => str,
+}));
+
+jest.mock('@superset-ui/chart-controls', () => {
+  const original = jest.requireActual('@superset-ui/chart-controls');
+  const mockShiftMetric = jest.fn(() => 'shiftedMetric');
+  return {
+    ...original,
+    getStandardizedControls: () => ({
+      shiftMetric: mockShiftMetric,
+    }),
+    __mockShiftMetric: mockShiftMetric,
+  };
+});
+
+describe('TimePivot Control Panel Config', () => {
+  test('should override formData metric using getStandardizedControls', () => {
+    const dummyFormData = { someProp: 'test' } as unknown as SqlaFormData;
+    const newFormData = controlPanel.formDataOverrides!(dummyFormData);
+
+    // The original properties are spread correctly.
+    expect(newFormData.someProp).toBe('test');
+    // The metric property should be replaced by the output of shiftMetric.
+    expect(newFormData.metric).toBe('shiftedMetric');
+
+    // Ensure that the mockShiftMetric function was called.
+    expect(__mockShiftMetric).toHaveBeenCalled();
+  });
+});

Review Comment:
   **Suggestion:** Remove the unnecessary suite wrapper and keep this as a 
single top-level test case since only one assertion flow is being tested. 
[custom_rule]
   
   **Severity Level:** Minor ⚠️
   <details>
   <summary><b>Why it matters? 🤔 </b></summary>
   
   This new test file contains only one test case inside a single `describe()` 
wrapper, so the suggestion correctly identifies the rule violation targeted by 
llmcfg-use-test-instead-of-describe.
   </details>
   <details>
   <summary><b>Rule source 📖 </b></summary>
   
   .github/copilot-instructions.md (line 43)
   </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=2a74f0814bf142328af323c1d7ffa41c&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=2a74f0814bf142328af323c1d7ffa41c&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-preset-chart-nvd3/test/TimePivot/controlPanel.test.ts
   **Line:** 44:57
   **Comment:**
        *Custom Rule: Remove the unnecessary suite wrapper and keep this as a 
single top-level test case since only one assertion flow is being tested.
   
   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%2F41916&comment_hash=d2ac7602dc53a42558a64257b9bf7f5db77c74b43e80ad2fd693e25e7af3313d&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41916&comment_hash=d2ac7602dc53a42558a64257b9bf7f5db77c74b43e80ad2fd693e25e7af3313d&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