-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Rewrite some tests to reduce flakiness: part 1 #3871
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
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
7f3a683
Rewrite scrollToCell tests
amanmahajan7 5f90ce1
Merge branch 'main' into fix-flaky
amanmahajan7 ed175eb
tweak
amanmahajan7 370dbd3
-1
amanmahajan7 b08e391
-1
amanmahajan7 9f4d616
-1
amanmahajan7 2336eda
-1
amanmahajan7 87a273d
-3
amanmahajan7 11e7fc6
-2
amanmahajan7 b1e130e
Revert a few changes
amanmahajan7 aac213d
Fix flaky test
amanmahajan7 be92fc3
Fix types
amanmahajan7 a8bc927
Add new utils
amanmahajan7 7157e11
Fix one test
amanmahajan7 5bb3da2
check focus and selection
amanmahajan7 d601c43
Revert 1 change
amanmahajan7 16077fe
tweak
amanmahajan7 2719e2b
Check column order
amanmahajan7 01df2aa
Check exact text
amanmahajan7 1fd1584
format
amanmahajan7 f90009c
Tweak 1 test
amanmahajan7 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
import { useMemo, useState } from 'react'; | ||
import { createPortal } from 'react-dom'; | ||
import { page, userEvent } from '@vitest/browser/context'; | ||
import { commands, page, userEvent } from '@vitest/browser/context'; | ||
|
||
import { DataGrid } from '../../../src'; | ||
import type { Column, DataGridProps } from '../../../src'; | ||
import { getCellsAtRowIndex, getGrid, getSelectedCell, scrollGrid } from '../utils'; | ||
import { getCell, getCellsAtRowIndex, getGrid, getSelectedCell, scrollGrid } from '../utils'; | ||
|
||
interface Row { | ||
col1: number; | ||
|
@@ -258,20 +258,19 @@ describe('Editor', () => { | |
it('should not steal focus back to the cell if the editor is not in the viewport and another cell is clicked', async () => { | ||
const rows: Row[] = []; | ||
for (let i = 0; i < 99; i++) { | ||
rows.push({ col1: i, col2: `${i}` }); | ||
rows.push({ col1: i, col2: `name${i}` }); | ||
} | ||
|
||
page.render(<EditorTest gridRows={rows} />); | ||
|
||
await userEvent.dblClick(getCellsAtRowIndex(0)[1]); | ||
await userEvent.dblClick(getCell('name0')); | ||
await userEvent.keyboard('abc'); | ||
|
||
await scrollGrid({ scrollTop: 1500 }); | ||
expect(getCellsAtRowIndex(40)[1]).toHaveTextContent(/^40$/); | ||
await userEvent.click(getCellsAtRowIndex(40)[1]); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This can still fail when the grid is properly scrolled. Using locators fixes it |
||
await expect.element(getSelectedCell()).toHaveTextContent(/^40$/); | ||
await scrollGrid({ scrollTop: 0 }); | ||
expect(getCellsAtRowIndex(0)[1]).toHaveTextContent(/^0abc$/); | ||
await commands.scrollGrid({ scrollTop: 1500 }); | ||
await userEvent.click(getCell('name43')); | ||
await expect.element(getSelectedCell()).toHaveTextContent(/^name43$/); | ||
await commands.scrollGrid({ scrollTop: 0 }); | ||
await expect.element(getCell('name0abc')).toBeVisible(); | ||
}); | ||
|
||
it('should not steal focus back to the cell after being closed by clicking outside the grid', async () => { | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For some reason current scrolling logic is flaky in FF
https://github.com/Comcast/react-data-grid/actions/runs/17952854675/job/51056628087
Hopefully the new
commands.scrollGrid
will help