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


##########
superset-frontend/src/embedded/index.test.tsx:
##########
@@ -16,26 +16,104 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-import { setupAGGridModules } from 
'@superset-ui/core/components/ThemedAgGridReact';
+// Mark this file as a module so its top-level declarations stay file-scoped
+// (the file has no imports; modules are loaded via require() inside tests).
+export {};
+
+// Stable mock references so they survive jest.resetModules() between tests
+// (a factory-created jest.fn() would otherwise be replaced on each reset,
+// leaving these imported handles pointing at a stale instance).
+const mockSetupAGGridModules = jest.fn();
+const mockLogging = { debug: jest.fn(), warn: jest.fn(), error: jest.fn() };
 
 jest.mock('src/public-path', () => ({}));
 
 jest.mock('query-string', () => ({}));
 
 jest.mock('@superset-ui/core/components/ThemedAgGridReact', () => ({
-  setupAGGridModules: jest.fn(),
+  setupAGGridModules: mockSetupAGGridModules,
 }));
 
-jest.mock('src/preamble', () => jest.fn().mockResolvedValue(true));
+jest.mock('@apache-superset/core/utils', () => ({
+  logging: mockLogging,
+}));
 
-jest.mock('src/setup/setupPlugins', () => jest.fn(), { virtual: true });
+// setupPlugins is driven per-test so the retry path can force a rejection.
+const mockSetupPlugins = jest.fn();
+jest.mock('src/setup/setupPlugins', () => mockSetupPlugins, { virtual: true });
 
 jest.mock('src/setup/setupCodeOverrides', () => jest.fn(), { virtual: true });
 
+jest.mock('src/preamble', () => jest.fn().mockResolvedValue(true));
+
+// makeApi returns a callable that resolves with the current user roles.
+const mockGetMeWithRole = jest.fn();
+jest.mock('@superset-ui/core', () => ({
+  ...jest.requireActual('@superset-ui/core'),
+  makeApi: () => mockGetMeWithRole,
+}));
+
+jest.mock('src/components/UiConfigContext', () => ({
+  useUiConfig: () => ({}),
+}));
+
+// Capture the guestToken handler that start() is wired to, so tests can
+// re-trigger the handshake and assert the retry behavior.
+const mockSwitchboard = {
+  handler: undefined as ((arg: { guestToken: string }) => void) | undefined,
+};
+jest.mock('@superset-ui/switchboard', () => ({
+  __esModule: true,
+  default: {
+    init: jest.fn(),
+    start: jest.fn(),
+    defineMethod: (name: string, fn: (...args: any[]) => any) => {
+      if (name === 'guestToken') {

Review Comment:
   **Suggestion:** Replace the `any`-typed switchboard callback signature with 
a concrete function type that matches the mocked method contract. [custom_rule]
   
   **Severity Level:** Minor ⚠️
   <details>
   <summary><b>Why it matters? 🤔 </b></summary>
   
   The final file still contains a new TypeScript callback typed with `any[]` 
and `any`, which directly violates the no-any-types rule for changed TypeScript 
code.
   </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=4650f8d16e124b308526ce2aa3b7ee01&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=4650f8d16e124b308526ce2aa3b7ee01&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/src/embedded/index.test.tsx
   **Line:** 69:71
   **Comment:**
        *Custom Rule: Replace the `any`-typed switchboard callback signature 
with a concrete function type that matches the mocked method contract.
   
   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%2F41491&comment_hash=3c4b9f2a1ea18f66a2223fe6a47e26592b622bffe7334afb0bc2cba23f4cee75&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41491&comment_hash=3c4b9f2a1ea18f66a2223fe6a47e26592b622bffe7334afb0bc2cba23f4cee75&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