codeant-ai-for-open-source[bot] commented on code in PR #41281:
URL: https://github.com/apache/superset/pull/41281#discussion_r3451004172
##########
superset-frontend/src/SqlLab/reducers/sqlLab.test.ts:
##########
@@ -21,13 +21,53 @@ 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', () => {
+ describe('Database actions', () => {
+ 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:** Avoid casting `state` to `any`; declare `state` with the
proper reducer state type so the reducer call remains fully type-checked.
[custom_rule]
**Severity Level:** Minor ⚠️
<details>
<summary><b>Why it matters? 🤔 </b></summary>
This modified TypeScript test line casts `state` to `any`, which directly
violates the rule against using `any` in new or changed TS/TSX code. The
suggestion is therefore valid.
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=024fd0636abe4466bedac1c42c14ad90&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=024fd0636abe4466bedac1c42c14ad90&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:** 57:57
**Comment:**
*Custom Rule: Avoid casting `state` to `any`; declare `state` with the
proper reducer state type so the reducer call remains fully type-checked.
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=37cbf1bcd31df8079dc9f28276105de779c08fbfd3494f2bf816c26c76d336dd&reaction=like'>👍</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41281&comment_hash=37cbf1bcd31df8079dc9f28276105de779c08fbfd3494f2bf816c26c76d336dd&reaction=dislike'>👎</a>
##########
superset-frontend/src/SqlLab/reducers/sqlLab.test.ts:
##########
@@ -21,13 +21,53 @@ 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', () => {
+ describe('Database actions', () => {
+ 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:** Remove the `any` cast on the `setDatabases` payload and type
it using the action creator's expected argument type (or a specific database
DTO type) so the test validates real compile-time contracts. [custom_rule]
**Severity Level:** Minor ⚠️
<details>
<summary><b>Why it matters? 🤔 </b></summary>
This is TypeScript code in a modified test file, and it uses `as any` on the
`setDatabases` payload. The custom rule explicitly forbids new or modified
TypeScript/TSX code from using `any`, so this is a real violation.
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=9eeaabf9a4de42f7b8c74863f21deee5&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=9eeaabf9a4de42f7b8c74863f21deee5&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:** 50:55
**Comment:**
*Custom Rule: Remove the `any` cast on the `setDatabases` payload and
type it using the action creator's expected argument type (or a specific
database DTO type) so the test validates real compile-time contracts.
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=48a95d2c38dd648433e073c2e4c2fb65f62b067a2cbdb96da65fce3168e8d9ec&reaction=like'>👍</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41281&comment_hash=48a95d2c38dd648433e073c2e4c2fb65f62b067a2cbdb96da65fce3168e8d9ec&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]