Skip to content

Commit 88a5187

Browse files
feat(metadata-view): custom actions (#4215)
* feat(metadata-view): custom actions * feat(metadata-view): custom actions Remove demo-specific logic --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
1 parent d8a8fcb commit 88a5187

File tree

1 file changed

+53
-14
lines changed

1 file changed

+53
-14
lines changed

src/elements/content-explorer/stories/tests/MetadataView-visual.stories.tsx

Lines changed: 53 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
import React from 'react';
21
import { http, HttpResponse } from 'msw';
32
import type { Meta, StoryObj } from '@storybook/react';
3+
import { Download, SignMeOthers } from '@box/blueprint-web-assets/icons/Fill/index';
4+
import { Sign } from '@box/blueprint-web-assets/icons/Line';
5+
import { expect, userEvent, waitFor, within } from 'storybook/test';
6+
import noop from 'lodash/noop';
47
import ContentExplorer from '../../ContentExplorer';
58
import { DEFAULT_HOSTNAME_API } from '../../../../constants';
69
import { mockMetadata, mockSchema } from '../../../common/__mocks__/mockMetadata';
@@ -71,26 +74,62 @@ export const metadataView: Story = {
7174
},
7275
};
7376

77+
const metadataViewV2ElementProps = {
78+
metadataViewProps: {
79+
columns,
80+
},
81+
metadataQuery,
82+
fieldsToShow,
83+
defaultView,
84+
features: {
85+
contentExplorer: {
86+
metadataViewV2: true,
87+
},
88+
},
89+
};
90+
7491
export const metadataViewV2: Story = {
92+
args: metadataViewV2ElementProps,
93+
};
94+
95+
export const metadataViewV2WithCustomActions: Story = {
7596
args: {
97+
...metadataViewV2ElementProps,
7698
metadataViewProps: {
7799
columns,
78-
},
79-
metadataQuery,
80-
fieldsToShow,
81-
defaultView,
82-
features: {
83-
contentExplorer: {
84-
metadataViewV2: true,
100+
tableProps: {
101+
isSelectAllEnabled: true,
102+
},
103+
itemActionMenuProps: {
104+
actions: [
105+
{
106+
label: 'Download',
107+
onClick: noop,
108+
icon: Download,
109+
},
110+
],
111+
subMenuTrigger: {
112+
label: 'Sign',
113+
icon: Sign,
114+
},
115+
subMenuActions: [
116+
{
117+
label: 'Request Signature',
118+
onClick: noop,
119+
icon: SignMeOthers,
120+
},
121+
],
85122
},
86123
},
87124
},
88-
render: args => {
89-
return (
90-
<div style={{ padding: '50px' }}>
91-
<ContentExplorer {...args} />
92-
</div>
93-
);
125+
play: async ({ canvas }) => {
126+
await waitFor(() => {
127+
expect(canvas.getByRole('row', { name: /Child 2/i })).toBeInTheDocument();
128+
});
129+
130+
const firstRow = canvas.getByRole('row', { name: /Child 2/i });
131+
const ellipsesButton = within(firstRow).getByRole('button', { name: 'Action menu' });
132+
userEvent.click(ellipsesButton);
94133
},
95134
};
96135

0 commit comments

Comments
 (0)