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


##########
superset-frontend/src/SqlLab/reducers/sqlLab.test.ts:
##########
@@ -21,13 +21,46 @@ import sqlLabReducer from 'src/SqlLab/reducers/sqlLab';
 import * as actions from 'src/SqlLab/actions/sqlLab';
 import type { SqlLabAction } from 'src/SqlLab/actions/sqlLab';
 import type { SqlLabRootState } from 'src/SqlLab/types';
-import { table, initialState as mockState } from '../fixtures';
+import { table, databases, initialState as mockState } from '../fixtures';
 
 type SqlLabState = SqlLabRootState['sqlLab'];
 const initialState = mockState.sqlLab as unknown as SqlLabState;
 
 // eslint-disable-next-line no-restricted-globals -- TODO: Migrate from 
describe blocks
 describe('sqlLabReducer', () => {
+  test('should merge databases instead of replacing existing database state', 
() => {
+    const existingDb = {
+      ...databases.result[0],
+      extra: databases.result[0].extra || '{}',
+    };
+    const existingDbId = Number(existingDb.id);
+
+    const incomingDb = {
+      ...databases.result[0],
+      id: existingDbId + 1,
+      database_name: 'new database',
+      extra: '{}',
+    };
+    const incomingDbId = Number(incomingDb.id);
+
+    const state = {
+      ...initialState,
+      databases: {
+        [existingDbId]: existingDb,
+      },
+    } as any;

Review Comment:
   **Suggestion:** Replace the `any` cast on the reducer state with a concrete 
state type (for example, a properly typed partial or test-specific state 
interface) to preserve type safety. [custom_rule]
   
   **Severity Level:** Minor ⚠️
   <details>
   <summary><b>Why it matters? 🤔 </b></summary>
   
   The rule forbids new or changed TypeScript code from using `any`. This test 
setup explicitly casts the reducer state to `any`, so the violation is real and 
present in the final 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=f1d81619b0c14f2594705931fb580a53&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=f1d81619b0c14f2594705931fb580a53&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/SqlLab/reducers/sqlLab.test.ts
   **Line:** 46:51
   **Comment:**
        *Custom Rule: Replace the `any` cast on the reducer state with a 
concrete state type (for example, a properly typed partial or test-specific 
state interface) to preserve type safety.
   
   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%2F41281&comment_hash=a9a0d40a04560825f22dbd1e08370765b7f453a78964aa87c43123032d77b11a&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41281&comment_hash=a9a0d40a04560825f22dbd1e08370765b7f453a78964aa87c43123032d77b11a&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