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


##########
superset-frontend/src/SqlLab/components/QueryStatusBar/QueryStatusBar.test.tsx:
##########
@@ -0,0 +1,161 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import { isValidElement } from 'react';
+import { render, screen } from 'spec/helpers/testing-library';
+import { QueryState, type QueryResponse } from '@superset-ui/core';
+import QueryStatusBar from '.';
+
+jest.mock('../QueryStateLabel', () => ({
+  __esModule: true,
+  default: ({ query }: { query: { state: QueryState } }) => (
+    <div data-test="query-state-label">{query.state}</div>

Review Comment:
   **Suggestion:** The mocked `QueryStateLabel` uses the attribute 
`data-test="query-state-label"` but tests call 
`screen.getByTestId('query-state-label')` which queries the `data-testid` 
attribute; this mismatch will cause the tests that rely on `getByTestId` to 
fail with "Unable to find an element" at runtime. Update the mock to expose 
`data-testid="query-state-label"` so `getByTestId` finds it. [possible bug]
   
   <details>
   <summary><b>Severity Level:</b> Critical 🚨</summary>
   
   ```mdx
   - ❌ Unit tests for QueryStatusBar fail in CI.
   - ⚠️ Multiple test cases referencing query-state-label break.
   - ⚠️ PR CI blocked until tests are fixed.
   ```
   </details>
   
   ```suggestion
       <div data-testid="query-state-label">{query.state}</div>
   ```
   <details>
   <summary><b>Steps of Reproduction ✅ </b></summary>
   
   ```mdx
   1. Run the test file
   
`superset-frontend/src/SqlLab/components/QueryStatusBar/QueryStatusBar.test.tsx`
 with Jest
   (e.g., yarn test). The mock is defined at lines 24-29.
   
   2. The test `renders query state label` at lines 65-70 calls 
render(<QueryStatusBar ...
   />) (line 67) and then calls screen.getByTestId('query-state-label') at line 
68.
   
   3. Because the mock renders a <div data-test="query-state-label"> (lines 
26-28) instead of
   data-testid, getByTestId fails to find the element and Jest throws "Unable 
to find an
   element" (test fails at line 68).
   
   4. Several other tests also rely on getByTestId('query-state-label') (see 
lines 145 and
   151), so they will fail similarly. Updating the mock to use data-testid 
matches the tests'
   queries and fixes the failures.
   ```
   </details>
   <details>
   <summary><b>Prompt for AI Agent 🤖 </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** 
superset-frontend/src/SqlLab/components/QueryStatusBar/QueryStatusBar.test.tsx
   **Line:** 27:27
   **Comment:**
        *Possible Bug: The mocked `QueryStateLabel` uses the attribute 
`data-test="query-state-label"` but tests call 
`screen.getByTestId('query-state-label')` which queries the `data-testid` 
attribute; this mismatch will cause the tests that rely on `getByTestId` to 
fail with "Unable to find an element" at runtime. Update the mock to expose 
`data-testid="query-state-label"` so `getByTestId` finds it.
   
   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.
   ```
   </details>



-- 
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