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

[core] Use describeTreeView for icons tests #12672

Merged

Conversation

flaviendelangle
Copy link
Member

@flaviendelangle flaviendelangle commented Apr 4, 2024

Part of #12433
Part of #12434

The new tests are a lot more detailed but the idea remains the same

@flaviendelangle flaviendelangle added 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 Apr 4, 2024
@flaviendelangle flaviendelangle self-assigned this Apr 4, 2024
@@ -35,7 +35,11 @@ export interface RichTreeViewSlots extends DefaultTreeViewPluginSlots {
export interface RichTreeViewSlotProps<R extends {}, Multiple extends boolean | undefined>
extends DefaultTreeViewPluginSlotProps {
root?: SlotComponentProps<'ul', {}, RichTreeViewProps<R, Multiple>>;
item?: SlotComponentProps<typeof TreeItem, {}, RichTreeViewItemSlotOwnerState>;
item?: SlotComponentPropsFromProps<
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 had some typing issues while writing those tests so I improved the typing of this slot.

SlotComponentPropsFromProps allows us to skip the typeof TreeItem which can be expensive.
I also added TreeItem2Props which was completely missing

@@ -157,6 +157,10 @@ const useUtilityClasses = (ownerState: TreeItem2OwnerState) => {
return composeClasses(slots, getTreeItemUtilityClass, classes);
};

type TreeItem2Component = ((
Copy link
Member Author

Choose a reason for hiding this comment

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

Forgot to have this one for consistency

@@ -14,15 +14,15 @@ import {
DescribeTreeViewItem,
} from './describeTreeView.types';

const innerDescribeTreeView = <TPlugin extends TreeViewAnyPluginSignature>(
const innerDescribeTreeView = <TPlugins extends TreeViewAnyPluginSignature[]>(
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 now pass an array of plugins. I needed it to access defaultExpandedItems in useTreeIcons.test.tsx

@flaviendelangle flaviendelangle changed the title [core] Use describeTreeView for icons tests [core] Use describeTreeView for icons tests Apr 4, 2024
@mui-bot
Copy link

mui-bot commented Apr 4, 2024

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

Generated by 🚫 dangerJS against 748972f

Copy link
Contributor

@noraleonte noraleonte left a comment

Choose a reason for hiding this comment

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

Nice work! 🎉

Left a super small comment 👌

flaviendelangle and others added 2 commits April 8, 2024 13:50
…eTreeViewIcons.test.tsx

Co-authored-by: Nora <72460825+noraleonte@users.noreply.github.com>
Signed-off-by: Flavien DELANGLE <flaviendelangle@gmail.com>
@flaviendelangle flaviendelangle merged commit acd41a2 into mui:master Apr 8, 2024
15 checks passed
@flaviendelangle flaviendelangle deleted the useTreeIcons-describeTreeView branch April 8, 2024 12:09
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants