Skip to content

[test] Fix flaky data source aggregation test (take 3) #17316

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/x-charts/src/internals/animation/useAnimate.test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createRenderer, screen, waitFor } from '@mui/internal-test-utils';
import { createRenderer, reactMajor, screen, waitFor } from '@mui/internal-test-utils';
import { expect } from 'chai';
import * as React from 'react';
import { useAnimateInternal } from '@mui/x-charts/internals/animation/useAnimateInternal';
Expand Down Expand Up @@ -351,7 +351,7 @@ describe('useAnimate', () => {
await waitTwoFrames();

// Clicking the button is async, so at most one more call could have happened
expect(calls).to.lessThanOrEqual(numCallsBeforeUnmount + 1);
expect(calls).to.lessThanOrEqual(numCallsBeforeUnmount + (reactMajor > 18 ? 1 : 2));
});

it('stops animation when the hook is unmounted', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,26 @@ describeSkipIf(isJSDOM)('<DataGridPremium /> - Data source aggregation', () => {
}

it('should show aggregation option in the column menu', async () => {
const { user } = render(<TestDataSourceAggregation />);
const dataSource = {
getRows: async () => {
fetchRowsSpy();
return {
rows: [{ id: 123 }],
rowCount: 1,
aggregateRow: {},
};
},
getAggregatedValue: () => 'Agg value',
};
const { user } = render(
<TestDataSourceAggregation dataSource={dataSource} columns={[{ field: 'id' }]} />,
);
await waitFor(() => {
expect(fetchRowsSpy.callCount).to.be.greaterThan(0);
});
await user.click(within(getColumnHeaderCell(0)).getByLabelText('id column menu'));
// wait for the column menu to be open first
await screen.findByRole('menu', { name: 'id column menu' });
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What a nasty test to fix 😅
Do you think this will make any difference?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm no longer sure... 🤷
It's hard to debug it when locally it's impossible to get a failure. 🙈

But at least on Pickers, I often tend to first assert that a Popper has been attached and only then do the actual assertion. 🤔

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The popper tests are extremely frustrating to test. There is no exact reason why they fail as far as I could tell

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And it failed once again... 🤷

await screen.findByLabelText('Aggregation');
});

Expand Down