codeant-ai-for-open-source[bot] commented on code in PR #36936: URL: https://github.com/apache/superset/pull/36936#discussion_r2666834867
########## 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` component sets a `data-test` attribute but the tests call `getByTestId(...)` which queries `data-testid`. This mismatch will cause the `getByTestId('query-state-label')` assertions to fail because the mock doesn't expose `data-testid`. [possible bug] **Severity Level:** Critical 🚨 ```suggestion <div data-testid="query-state-label">{query.state}</div> ``` <details> <summary><b>Why it matters? ⭐ </b></summary> This is a valid, actionable bugfix. The test file queries by test id using getByTestId('query-state-label'), which looks for data-testid. The mock currently renders data-test, so the selector will not find the element and tests that rely on getByTestId will fail. Switching the mock to data-testid directly fixes the failing selector with minimal, localized change. </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` component sets a `data-test` attribute but the tests call `getByTestId(...)` which queries `data-testid`. This mismatch will cause the `getByTestId('query-state-label')` assertions to fail because the mock doesn't expose `data-testid`. 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]
