bito-code-review[bot] commented on code in PR #33946:
URL: https://github.com/apache/superset/pull/33946#discussion_r3238334535
##########
superset-frontend/src/pages/Home/Home.test.tsx:
##########
@@ -220,6 +239,31 @@ test('Without sql role - calls api methods in parallel on
page load', async () =
expect(fetchMock.callHistory.calls(dashboardsEndpoint)).toHaveLength(2);
});
+test('Without chart role - renders', async () => {
+ /*
+ We ignore the ts error here because the type does not recognize the absence
of a role entry
+ */
+ // @ts-ignore-next-line
+ await renderWelcome(mockedPropsWithoutChartWriteRole);
+ expect(await screen.findByText('Dashboards')).toBeInTheDocument();
+});
+
+test('Without chart role - renders all panels on the page on page load', async
() => {
+ // @ts-ignore-next-line
+ await renderWelcome(mockedPropsWithoutChartWriteRole);
+ const panels = await screen.findAllByText(/Dashboards|Recents|Saved
queries/);
+ expect(panels).toHaveLength(3);
+});
+
+test('Without chart role - calls api methods in parallel on page load', async
() => {
+ // @ts-ignore-next-line
+ await renderWelcome(mockedPropsWithoutChartWriteRole);
+ expect(fetchMock.calls(chartsEndpoint)).toHaveLength(0);
+ expect(fetchMock.calls(recentActivityEndpoint)).toHaveLength(1);
+ expect(fetchMock.calls(savedQueryEndpoint)).toHaveLength(1);
+ expect(fetchMock.calls(dashboardsEndpoint)).toHaveLength(2);
+});
Review Comment:
<div>
<div id="suggestion">
<div id="issue"><b>Incorrect fetch-mock API usage</b></div>
<div id="fix">
The test assertions use fetchMock.calls(), which is not a valid API method
in fetch-mock v12.6.0. The correct method is fetchMock.callHistory.calls(), as
documented in the official fetch-mock API. This will cause the test to fail
with a TypeError since fetchMock.calls is undefined.
</div>
<details>
<summary>
<b>Code suggestion</b>
</summary>
<blockquote>Check the AI-generated fix before applying</blockquote>
<div id="code">
````suggestion
test('Without chart role - calls api methods in parallel on page load',
async () => {
// @ts-ignore-next-line
await renderWelcome(mockedPropsWithoutChartWriteRole);
expect(fetchMock.callHistory.calls(chartsEndpoint)).toHaveLength(0);
expect(fetchMock.callHistory.calls(recentActivityEndpoint)).toHaveLength(1);
expect(fetchMock.callHistory.calls(savedQueryEndpoint)).toHaveLength(1);
expect(fetchMock.callHistory.calls(dashboardsEndpoint)).toHaveLength(2);
});
````
</div>
</details>
</div>
<small><i>Code Review Run #ec8eb3</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]