Skip to content

Commit f1ea11d

Browse files
committed
test: add vrt test story
- visually confirms correct column render
1 parent 1711632 commit f1ea11d

File tree

3 files changed

+33
-3
lines changed

3 files changed

+33
-3
lines changed
108 KB
Loading
110 KB
Loading

packages/eui/src/components/datagrid/data_grid.stories.tsx

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import React, { useRef, useEffect } from 'react';
1010
import { css } from '@emotion/react';
1111
import type { Meta, StoryObj, ReactRenderer } from '@storybook/react';
12-
import type { PlayFunctionContext } from '@storybook/csf';
12+
import { StoryContext } from '@storybook/csf';
1313
import { expect, fireEvent, waitFor } from '@storybook/test';
1414
import { action } from '@storybook/addon-actions';
1515
import { within } from '../../../.storybook/test';
@@ -176,7 +176,7 @@ export const DraggableColumns: Story = {
176176
),
177177
},
178178
render: (args: EuiDataGridProps) => <StatefulDataGrid {...args} />,
179-
play: async ({ canvasElement }: PlayFunctionContext<ReactRenderer>) => {
179+
play: async ({ canvasElement }: StoryContext<ReactRenderer>) => {
180180
const canvas = within(canvasElement);
181181

182182
await waitFor(async () => {
@@ -231,9 +231,39 @@ export const ColumnActions: Story = {
231231
gridStyle={{ fontSize: 's', cellPadding: 's' }}
232232
/>
233233
),
234-
play: async ({ canvasElement }: PlayFunctionContext<ReactRenderer>) => {
234+
play: async ({ canvasElement }: StoryContext<ReactRenderer>) => {
235235
const canvas = within(canvasElement);
236236
await canvas.waitForAndClick('dataGridHeaderCellActionButton-account');
237237
await canvas.waitForEuiPopoverVisible();
238238
},
239239
};
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

Comments
 (0)