Skip to content
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] Use describeTreeView for keyboard navigation tests on disabled items #13184

Merged
merged 2 commits into from
May 24, 2024

Conversation

flaviendelangle
Copy link
Member

Part of #12433

I added a few tests and did a bug fix

Unverified

This user has not yet uploaded their public signing key.
… items
@@ -32,7 +32,27 @@ export const getPreviousNavigableItem = (
return itemMeta.parentId;
}

let currentItemId: string = siblings[itemIndex - 1];
// Finds the previous navigable sibling.
Copy link
Member Author

Choose a reason for hiding this comment

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

If the previous sibling was disabled it was all broken

Copy link
Member

Choose a reason for hiding this comment

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

Nice fix. 👍
These are situations where you appreciate the effort put into writing tests. 👏 🎉

@flaviendelangle flaviendelangle added test core Infrastructure work going on behind the scenes component: tree view TreeView, TreeItem. This is the name of the generic UI component, not the React module! labels May 20, 2024
@flaviendelangle flaviendelangle self-assigned this May 20, 2024
@mui-bot
Copy link

mui-bot commented May 20, 2024

Deploy preview: https://deploy-preview-13184--material-ui-x.netlify.app/

Generated by 🚫 dangerJS against f88ce31

Fix

Unverified

This user has not yet uploaded their public signing key.
@@ -22,7 +22,7 @@ const getLastNavigableItemInArray = (
export const getPreviousNavigableItem = (
Copy link
Member Author

Choose a reason for hiding this comment

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

Side note: Would be awesome if we could strongly battle test those methods to avoid bugs
Because we probably don't want 30 tests on ArrowDown, 30 tests on ArrowUp etc... to check edge-cases of this method.

@flaviendelangle flaviendelangle marked this pull request as ready for review May 20, 2024 11:23
Copy link
Member

@LukasTy LukasTy left a comment

Choose a reason for hiding this comment

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

LGTM. 👍
The tests seem that they could be abstracted, but I'm not sure if it's necessary and would bring enough benefits doing that. 🤔

@@ -32,7 +32,27 @@ export const getPreviousNavigableItem = (
return itemMeta.parentId;
}

let currentItemId: string = siblings[itemIndex - 1];
// Finds the previous navigable sibling.
Copy link
Member

Choose a reason for hiding this comment

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

Nice fix. 👍
These are situations where you appreciate the effort put into writing tests. 👏 🎉

@flaviendelangle
Copy link
Member Author

The tests seem that they could be abstracted

Could you explain what you mean by abstracted here?

@LukasTy
Copy link
Member

LukasTy commented May 24, 2024

Could you explain what you mean by abstracted here?

I meant that it seems like a lot of those tests are doing almost the same thing, testing what happens when you click ArrowUp or ArrowDown.
But in practice, it is much more readable having a longer more explicit wall of text. 👌

@flaviendelangle
Copy link
Member Author

Oh you meant maybe something like we do on the fields with a testKeyPress utility that shorten the tests?

I propose we stick with the raw tests like today, but instead of adding dozens of new ones to handle edge cases, we test the utility methods, and those tests will be shorter.

@flaviendelangle flaviendelangle merged commit 426738c into mui:master May 24, 2024
17 checks passed
@flaviendelangle flaviendelangle deleted the disabled-selection-test branch May 24, 2024 10:07
@LukasTy
Copy link
Member

LukasTy commented May 24, 2024

Oh you meant maybe something like we do on the fields with a testKeyPress utility that shorten the tests?

Yes, that's what I had in mind. 👌

I propose we stick with the raw tests like today, but instead of adding dozens of new ones to handle edge cases, we test the utility methods, and those tests will be shorter.

Completely agree on this one, especially for now. 👍

DungTiger pushed a commit to DungTiger/mui-x that referenced this pull request Jul 23, 2024

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
…ed items (mui#13184)
thomasmoon pushed a commit to thomasmoon/mui-x that referenced this pull request Sep 9, 2024

Partially verified

This commit is signed with the committer’s verified signature. The key has expired.
thomasmoon’s contribution has been verified via GPG key.
We cannot verify signatures from co-authors, and some of the co-authors attributed to this commit require their commits to be signed.
…ed items (mui#13184)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: tree view TreeView, TreeItem. This is the name of the generic UI component, not the React module! core Infrastructure work going on behind the scenes test
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants