Skip to content

Commit

Permalink
[test] Fix flaky column pinning tests (mui#16219)
Browse files Browse the repository at this point in the history
  • Loading branch information
cherniavskii authored Jan 17, 2025
1 parent 6ff55f5 commit aca5f0e
Showing 1 changed file with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,9 @@ describe('<DataGridPro /> - Column pinning', () => {
const menuIconButton = columnCell.querySelector('button[aria-label="Menu"]')!;
await user.click(menuIconButton);
await user.click(screen.getByRole('menuitem', { name: 'Pin to left' }));
expect($(`.${gridClasses['cell--pinnedLeft']}[data-field="id"]`)).not.to.equal(null);
await waitFor(() => {
expect($(`.${gridClasses['cell--pinnedLeft']}[data-field="id"]`)).not.to.equal(null);
});
});

it('should pin the column to the right when clicking the "Pin to right" pinning button', async () => {
Expand All @@ -478,7 +480,9 @@ describe('<DataGridPro /> - Column pinning', () => {
const menuIconButton = columnCell.querySelector('button[aria-label="Menu"]')!;
await user.click(menuIconButton);
await user.click(screen.getByRole('menuitem', { name: 'Pin to right' }));
expect($(`.${gridClasses['cell--pinnedRight']}[data-field="id"]`)).not.to.equal(null);
await waitFor(() => {
expect($(`.${gridClasses['cell--pinnedRight']}[data-field="id"]`)).not.to.equal(null);
});
});

it('should allow to invert the side when clicking on "Pin to right" pinning button on a left pinned column', async () => {
Expand All @@ -487,7 +491,9 @@ describe('<DataGridPro /> - Column pinning', () => {
const menuIconButton = columnCell.querySelector('button[aria-label="Menu"]')!;
await user.click(menuIconButton);
await user.click(screen.getByRole('menuitem', { name: 'Pin to right' }));
expect($(`.${gridClasses['cell--pinnedLeft']}[data-field="id"]`)).to.equal(null);
await waitFor(() => {
expect($(`.${gridClasses['cell--pinnedLeft']}[data-field="id"]`)).to.equal(null);
});
expect($(`.${gridClasses['cell--pinnedRight']}[data-field="id"]`)).not.to.equal(null);
});

Expand All @@ -497,7 +503,9 @@ describe('<DataGridPro /> - Column pinning', () => {
const menuIconButton = columnCell.querySelector('button[aria-label="Menu"]')!;
await user.click(menuIconButton);
await user.click(screen.getByRole('menuitem', { name: 'Pin to left' }));
expect($(`.${gridClasses['cell--pinnedRight']}[data-field="id"]`)).to.equal(null);
await waitFor(() => {
expect($(`.${gridClasses['cell--pinnedRight']}[data-field="id"]`)).to.equal(null);
});
expect($(`.${gridClasses['cell--pinnedLeft']}[data-field="id"]`)).not.to.equal(null);
});

Expand Down

0 comments on commit aca5f0e

Please sign in to comment.