|
1 | | -import React from 'react'; |
2 | 1 | import { http, HttpResponse } from 'msw'; |
3 | 2 | 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'; |
4 | 7 | import ContentExplorer from '../../ContentExplorer'; |
5 | 8 | import { DEFAULT_HOSTNAME_API } from '../../../../constants'; |
6 | 9 | import { mockMetadata, mockSchema } from '../../../common/__mocks__/mockMetadata'; |
@@ -71,26 +74,62 @@ export const metadataView: Story = { |
71 | 74 | }, |
72 | 75 | }; |
73 | 76 |
|
| 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 | + |
74 | 91 | export const metadataViewV2: Story = { |
| 92 | + args: metadataViewV2ElementProps, |
| 93 | +}; |
| 94 | + |
| 95 | +export const metadataViewV2WithCustomActions: Story = { |
75 | 96 | args: { |
| 97 | + ...metadataViewV2ElementProps, |
76 | 98 | metadataViewProps: { |
77 | 99 | 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 | + ], |
85 | 122 | }, |
86 | 123 | }, |
87 | 124 | }, |
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); |
94 | 133 | }, |
95 | 134 | }; |
96 | 135 |
|
|
0 commit comments