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


##########
superset-frontend/src/SqlLab/actions/sqlLab.test.ts:
##########
@@ -734,7 +734,7 @@ describe('async actions', () => {
   // eslint-disable-next-line no-restricted-globals -- TODO: Migrate from 
describe blocks
   describe('popSavedQuery', () => {
     const supersetClientGetSpy = jest.spyOn(SupersetClient, 'get');
-    const store = mockStore({});
+    const store = mockStore(initialState);

Review Comment:
   **Suggestion:** `store` is created once at `describe` scope and reused 
across tests, so dispatched actions accumulate between test cases. This makes 
the new error-path assertion flaky/false-positive because `ADD_QUERY_EDITOR` 
may come from a previous test rather than the current request. Create a fresh 
store per test (or clear actions in `beforeEach`) to isolate assertions. [logic 
error]
   
   <details>
   <summary><b>Severity Level:</b> Major ⚠️</summary>
   
   ```mdx
   - ⚠️ SQL Lab saved-query tests can pass with broken fallbacks.
   - ⚠️ Future refactors may remove error dispatches unnoticed.
   - ⚠️ Cross-test leakage makes debugging test failures harder.
   ```
   </details>
   <details>
   <summary><b>Steps of Reproduction ✅ </b></summary>
   
   ```mdx
   1. Open `superset-frontend/src/SqlLab/actions/sqlLab.test.ts` and locate the
   `describe('popSavedQuery', () => { ... })` block starting around line 734, 
where `const
   store = mockStore(initialState);` is declared at line 737 in the `describe` 
scope.
   
   2. Within the same `describe` block, observe the existing success-path test 
around lines
   815–825 (`test` that calls `await makeRequest(1);` and then inspects 
`store.getActions()`
   for an `ADD_QUERY_EDITOR` action), which dispatches actions into the shared 
`store`
   instance.
   
   3. Still in that `describe`, observe the newly added error-path test at 
lines 828–844
   (`test('should dispatch addDangerToast and addNewQueryEditor on API error', 
...)`) which
   also calls `await makeRequest(1);` and then calls `store.getActions()` to 
search for both
   `ADD_TOAST` and `ADD_QUERY_EDITOR`.
   
   4. Because `store` is created once at line 737 and never reset or recreated 
in
   `beforeEach`, running the success-path test first populates `store` with an
   `ADD_QUERY_EDITOR` action; when the error-path test runs, 
`store.getActions()` still
   includes this prior `ADD_QUERY_EDITOR`, so 
`expect(addEditorAction).toBeTruthy();` can
   pass even if the error-path implementation stops dispatching 
`ADD_QUERY_EDITOR`, making
   the assertion a false positive due to cross-test leakage.
   ```
   </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=27ba648e028f4ff2a38cfe0078a67499&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=27ba648e028f4ff2a38cfe0078a67499&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/actions/sqlLab.test.ts
   **Line:** 737:737
   **Comment:**
        *Logic Error: `store` is created once at `describe` scope and reused 
across tests, so dispatched actions accumulate between test cases. This makes 
the new error-path assertion flaky/false-positive because `ADD_QUERY_EDITOR` 
may come from a previous test rather than the current request. Create a fresh 
store per test (or clear actions in `beforeEach`) to isolate assertions.
   
   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%2F42241&comment_hash=73dfd821d92015b02b0e2c1b164be5139be482b43def4e6415e167f99e2c1853&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F42241&comment_hash=73dfd821d92015b02b0e2c1b164be5139be482b43def4e6415e167f99e2c1853&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