Skip to content

Commit

Permalink
TabPanel: Refactor unit tests in prep for controlled component updates (
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronrobertshaw authored Feb 27, 2023
1 parent 4b4b4ca commit 37dd03a
Show file tree
Hide file tree
Showing 3 changed files with 836 additions and 262 deletions.
1 change: 1 addition & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
### Internal

- `CircularOptionPicker`: Convert to TypeScript ([#47937](https://github.com/WordPress/gutenberg/pull/47937)).
- `TabPanel`: Improve unit test in preparation for controlled component updates ([#48086](https://github.com/WordPress/gutenberg/pull/48086)).

## 23.4.0 (2023-02-15)

Expand Down
41 changes: 41 additions & 0 deletions packages/components/src/tab-panel/stories/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,25 @@
*/
import type { ComponentMeta, ComponentStory } from '@storybook/react';

/**
* WordPress dependencies
*/
import { link, more, wordpress } from '@wordpress/icons';

/**
* Internal dependencies
*/
import TabPanel from '..';
import Popover from '../../popover';
import { Provider as SlotFillProvider } from '../../slot-fill';

const meta: ComponentMeta< typeof TabPanel > = {
title: 'Components/TabPanel',
component: TabPanel,
parameters: {
actions: { argTypesRegex: '^on.*' },
controls: { expanded: true },
docs: { source: { state: 'open' } },
},
};
export default meta;
Expand Down Expand Up @@ -55,3 +64,35 @@ DisabledTab.args = {
},
],
};

const SlotFillTemplate: ComponentStory< typeof TabPanel > = ( props ) => {
return (
<SlotFillProvider>
<TabPanel { ...props } />
{ /* @ts-expect-error The 'Slot' component hasn't been typed yet. */ }
<Popover.Slot />
</SlotFillProvider>
);
};

export const WithTabIconsAndTooltips = SlotFillTemplate.bind( {} );
WithTabIconsAndTooltips.args = {
children: ( tab ) => <p>Selected tab: { tab.title }</p>,
tabs: [
{
name: 'tab1',
title: 'Tab 1',
icon: wordpress,
},
{
name: 'tab2',
title: 'Tab 2',
icon: link,
},
{
name: 'tab3',
title: 'Tab 3',
icon: more,
},
],
};
Loading

1 comment on commit 37dd03a

@github-actions
Copy link

Choose a reason for hiding this comment

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

Flaky tests detected in 37dd03a.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/4279521368
📝 Reported issues:

Please sign in to comment.