codeant-ai-for-open-source[bot] commented on code in PR #41281:
URL: https://github.com/apache/superset/pull/41281#discussion_r3496953236
##########
superset-frontend/src/SqlLab/reducers/sqlLab.test.ts:
##########
@@ -21,13 +21,51 @@ 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];
+ const incomingDb = databases.result[1];
+
+ const state = {
+ ...initialState,
+ databases: {
+ [existingDb.id]: {
+ ...existingDb,
+ extra_json: {},
+ },
+ },
+ };
+
+ const action = actions.setDatabases([
+ {
+ ...incomingDb,
+ extra: '{}',
+ },
+ ] as any);
Review Comment:
**Suggestion:** Replace the `any` cast on the `setDatabases` payload with
the correct action payload type so the test remains fully type-safe.
[custom_rule]
**Severity Level:** Minor ⚠️
<details>
<summary><b>Why it matters? 🤔 </b></summary>
The test introduces a TypeScript `any` cast in the new `setDatabases` call.
This directly matches the custom rule forbidding new or changed TypeScript code
from using `any`, so the violation is real.
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=d6e99700a5904c5d97d3331460fc5438&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
[](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=d6e99700a5904c5d97d3331460fc5438&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:** 49:54
**Comment:**
*Custom Rule: Replace the `any` cast on the `setDatabases` payload with
the correct action payload type so the test remains fully type-safe.
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=b18c1e56fb14ddd438641938cb3c63177f90414f53ad5b4f2390c6b30394b7b9&reaction=like'>👍</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41281&comment_hash=b18c1e56fb14ddd438641938cb3c63177f90414f53ad5b4f2390c6b30394b7b9&reaction=dislike'>👎</a>
##########
superset-frontend/src/SqlLab/reducers/sqlLab.test.ts:
##########
@@ -21,13 +21,51 @@ 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];
+ const incomingDb = databases.result[1];
+
+ const state = {
+ ...initialState,
+ databases: {
+ [existingDb.id]: {
+ ...existingDb,
+ extra_json: {},
+ },
+ },
+ };
+
+ const action = actions.setDatabases([
+ {
+ ...incomingDb,
+ extra: '{}',
+ },
+ ] as any);
+
+ const newState = sqlLabReducer(state as any, action);
Review Comment:
**Suggestion:** Remove the `any` cast from the reducer state argument by
typing the test state to the reducer’s expected state type. [custom_rule]
**Severity Level:** Minor ⚠️
<details>
<summary><b>Why it matters? 🤔 </b></summary>
The added reducer invocation casts `state` to `any`, which is exactly the
kind of TypeScript `any` usage the rule forbids in changed code. This is a
genuine violation.
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=be26b0f983e24523aaae4c716d3face8&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
[](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=be26b0f983e24523aaae4c716d3face8&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:** 56:56
**Comment:**
*Custom Rule: Remove the `any` cast from the reducer state argument by
typing the test state to the reducer’s expected state type.
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=5edb0bdb9f1fff633c334a4716e965e459a326cbb88e39ff4593ee9654c0c622&reaction=like'>👍</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41281&comment_hash=5edb0bdb9f1fff633c334a4716e965e459a326cbb88e39ff4593ee9654c0c622&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]