bito-code-review[bot] commented on code in PR #41052:
URL: https://github.com/apache/superset/pull/41052#discussion_r3413985036
##########
superset-frontend/src/SqlLab/components/SqlEditorTabHeader/SqlEditorTabHeader.test.tsx:
##########
@@ -133,16 +133,22 @@ describe('SqlEditorTabHeader', () => {
);
});
- test('should dispatch queryEditorSetTitle action', async () => {
+ test('should open rename modal and dispatch queryEditorSetTitle on save',
async () => {
await waitFor(() =>
-
expect(screen.getByTestId('close-tab-menu-option')).toBeInTheDocument(),
+
expect(screen.getByTestId('rename-tab-menu-option')).toBeInTheDocument(),
);
- const expectedTitle = 'typed text';
- const mockPrompt = jest
- .spyOn(window, 'prompt')
- .mockImplementation(() => expectedTitle);
+
fireEvent.click(screen.getByTestId('rename-tab-menu-option'));
+ const input = await screen.findByTestId('rename-tab-input');
+ expect(input).toBeInTheDocument();
+
+ const expectedTitle = 'typed text';
+ fireEvent.change(input, { target: { value: expectedTitle } });
+
+ const saveButton = screen.getByRole('button', { name: /save/i });
Review Comment:
<div>
<div id="suggestion">
<div id="issue"><b>CWE-436: Incorrect Button Query</b></div>
<div id="fix">
The test queries for a button with `name: /save/i`, but `StandardModal`
defaults to `'Add'` when `isEditMode` is not set (`StandardModal.tsx` line
120). Since `SqlEditorTabHeader/index.tsx` uses the modal without `isEditMode`,
the test will fail to find the button. (See also:
[CWE-436](https://cwe.mitre.org/data/definitions/436.html))
</div>
<details>
<summary>
<b>Code suggestion</b>
</summary>
<blockquote>Check the AI-generated fix before applying</blockquote>
<div id="code">
```
---
a/superset-frontend/src/SqlLab/components/SqlEditorTabHeader/SqlEditorTabHeader.test.tsx
+++
b/superset-frontend/src/SqlLab/components/SqlEditorTabHeader/SqlEditorTabHeader.test.tsx
@@ -149,5 +149,5 @@
const expectedTitle = 'typed text';
fireEvent.change(input, { target: { value: expectedTitle } });
- const saveButton = screen.getByRole('button', { name: /save/i });
- fireEvent.click(saveButton);
+ const addButton = screen.getByRole('button', { name: /add/i });
+ fireEvent.click(addButton);
```
</div>
</details>
</div>
<small><i>Code Review Run #2ead21</i></small>
</div>
---
Should Bito avoid suggestions like this for future reviews? (<a
href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
- [ ] Yes, avoid them
--
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]