|
9 | 9 | import React, { useRef, useEffect } from 'react'; |
10 | 10 | import { css } from '@emotion/react'; |
11 | 11 | import type { Meta, StoryObj, ReactRenderer } from '@storybook/react'; |
12 | | -import type { PlayFunctionContext } from '@storybook/csf'; |
| 12 | +import { StoryContext } from '@storybook/csf'; |
13 | 13 | import { expect, fireEvent, waitFor } from '@storybook/test'; |
14 | 14 | import { action } from '@storybook/addon-actions'; |
15 | 15 | import { within } from '../../../.storybook/test'; |
@@ -176,7 +176,7 @@ export const DraggableColumns: Story = { |
176 | 176 | ), |
177 | 177 | }, |
178 | 178 | render: (args: EuiDataGridProps) => <StatefulDataGrid {...args} />, |
179 | | - play: async ({ canvasElement }: PlayFunctionContext<ReactRenderer>) => { |
| 179 | + play: async ({ canvasElement }: StoryContext<ReactRenderer>) => { |
180 | 180 | const canvas = within(canvasElement); |
181 | 181 |
|
182 | 182 | await waitFor(async () => { |
@@ -231,9 +231,39 @@ export const ColumnActions: Story = { |
231 | 231 | gridStyle={{ fontSize: 's', cellPadding: 's' }} |
232 | 232 | /> |
233 | 233 | ), |
234 | | - play: async ({ canvasElement }: PlayFunctionContext<ReactRenderer>) => { |
| 234 | + play: async ({ canvasElement }: StoryContext<ReactRenderer>) => { |
235 | 235 | const canvas = within(canvasElement); |
236 | 236 | await canvas.waitForAndClick('dataGridHeaderCellActionButton-account'); |
237 | 237 | await canvas.waitForEuiPopoverVisible(); |
238 | 238 | }, |
239 | 239 | }; |
| 240 | + |
| 241 | +/* TESTING */ |
| 242 | + |
| 243 | +export const VisibleColumns: Story = { |
| 244 | + tags: ['vrt-only'], |
| 245 | + args: { |
| 246 | + ...defaultStorybookArgs, |
| 247 | + columnVisibility: { |
| 248 | + // `visibleColumns` has a different order than `columns` - `visibleColumns` determines the order |
| 249 | + visibleColumns: ['date', 'name', 'email', 'location'], |
| 250 | + setVisibleColumns: action('setVisibleColumns'), |
| 251 | + }, |
| 252 | + // `columns` contains duplicates - only the first occurrence is used |
| 253 | + columns: [ |
| 254 | + { id: 'name', displayAsText: 'Name' }, |
| 255 | + { id: 'email', displayAsText: 'Email' }, |
| 256 | + { id: 'location', displayAsText: 'Location' }, |
| 257 | + { id: 'name', displayAsText: 'Name (duplicate)' }, |
| 258 | + { id: 'email', displayAsText: 'Email (duplicate)' }, |
| 259 | + { id: 'account', displayAsText: 'Account' }, |
| 260 | + { id: 'date', displayAsText: 'Date' }, |
| 261 | + ], |
| 262 | + }, |
| 263 | + render: (args: EuiDataGridProps) => <StatefulDataGrid {...args} />, |
| 264 | + play: async ({ canvasElement }: StoryContext<ReactRenderer>) => { |
| 265 | + const canvas = within(canvasElement); |
| 266 | + await canvas.waitForAndClick('dataGridColumnSelectorButton'); |
| 267 | + await canvas.waitForEuiPopoverVisible(); |
| 268 | + }, |
| 269 | +}; |
0 commit comments