-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
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
[test] Migrate CircularProgress and Collapse to testing-library #20789
[test] Migrate CircularProgress and Collapse to testing-library #20789
Conversation
Details of bundle changes.Comparing: beabed8...fffc9e7 Details of page changes
|
The linter gives problem with tree item 😕 +++ b/packages/material-ui-lab/src/TreeItem/TreeItem.test.js
@@ -735,6 +735,36 @@ describe('<TreeItem />', () => {
fireEvent.keyDown(document.activeElement, { key: 'v', shiftKey: true });
expect(getByTestId('apple')).toHaveFocus();
});
+
+ it('should not throw when an item is removed', () => {
+ function TestComponent() {
+ const [hide, setState] = React.useState(false);
+ return (
+ <React.Fragment>
+ <button type="button" onClick={() => setState(true)}>
+ Hide
+ </button>
+ <TreeView>
+ {!hide && <TreeItem nodeId="hide" label="ab" />}
+ <TreeItem nodeId="keyDown" data-testid="keyDown" />
+ <TreeItem nodeId="navTo" data-testid="navTo" label="ac" />
+ </TreeView>
+ </React.Fragment>
+ );
+ }
+
+ const { getByText, getByTestId } = render(<TestComponent />);
+ fireEvent.click(getByText('Hide'));
+ const navTreeItem = getByTestId('navTo');
+ expect(navTreeItem).not.to.have.focus;
+
+ expect(() => {
+ fireEvent.keyDown(getByTestId('keyDown'), { key: 'a' });
+ }).not.to.throw();
+
+ expect(navTreeItem).to.have.focus;
+ expect(navTreeItem).to.have.attribute('tabindex', '0');
+ });
});
The line where where he check's the focus must call the function not.to.have.focus() to.have.focus() |
This branch seems outdated. We now lint against |
Yes i know for the branch |
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.
I don't see the Collapse tests. Did you forget to push them? Please push them even if they fail so that we can look together what's wrong.
@eps1lon Do you know why with testing-library fake timer dons't work well? |
Could you push the code so that I can take a look? |
Yes of course |
f109f50
to
fffc9e7
Compare
@marcosvega91 The key difference between the previous test and your new one is around how the cleanup logic is run. Both unmounts the component |
You are totally right @oliviertassinari |
@marcosvega91 Very nice, thanks! |
I'm not good like you @eps1lon @oliviertassinari 😭 |
Not at all. That's totally normal that PRs don't work on the first push. This is what review is for. |
@eps1lon @oliviertassinari for the collapse component there is the problem with react strict.
How we can do? The problem is the Transition component