@linzjs/step-ag-grid 32.7.1 → 34.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/components/PostSortRowsHook.test.d.ts +1 -0
- package/dist/src/components/gridFilter/GridFilterColumnsMultiSelect.d.ts +6 -25
- package/dist/src/components/gridForm/GridFormTextInput.d.ts +2 -1
- package/dist/src/utils/__tests__/storybookTestUtil.ts +1 -1
- package/dist/step-ag-grid.cjs +190 -206
- package/dist/step-ag-grid.cjs.map +1 -1
- package/dist/step-ag-grid.esm.js +190 -206
- package/dist/step-ag-grid.esm.js.map +1 -1
- package/package.json +17 -17
- package/src/components/Grid.tsx +8 -10
- package/src/components/PostSortRowsHook.test.ts +300 -0
- package/src/components/PostSortRowsHook.ts +127 -24
- package/src/components/gridFilter/GridFilterColumnsMultiSelect.tsx +110 -199
- package/src/components/gridForm/GridFormTextInput.tsx +2 -1
- package/src/components/gridHook/useGridRangeSelection.ts +8 -6
- package/src/contexts/GridContextProvider.tsx +5 -9
- package/src/react-menu3/components/ControlledMenu.tsx +5 -3
- package/src/react-menu3/components/MenuList.tsx +7 -3
- package/src/react-menu3/hooks/useItems.ts +1 -1
- package/src/stories/components/ActionButton.stories.tsx +12 -11
- package/src/stories/decorators/withOpenInPanelDecorator.tsx +35 -0
- package/src/stories/grid/GridCopy.stories.tsx +38 -35
- package/src/stories/grid/GridDragRow.stories.tsx +41 -36
- package/src/stories/grid/GridFilterButtons.stories.tsx +25 -19
- package/src/stories/grid/GridFilterColumnsMultiSelect.stories.tsx +42 -37
- package/src/stories/grid/GridInlineText.stories.tsx +62 -49
- package/src/stories/grid/GridNoRowsOverlay.stories.tsx +28 -23
- package/src/stories/grid/GridNonEditableRow.stories.tsx +30 -24
- package/src/stories/grid/GridPinnedRow.stories.tsx +37 -31
- package/src/stories/grid/GridPopoutContextMenu.stories.tsx +29 -24
- package/src/stories/grid/GridPopoutEditBoolean.stories.tsx +89 -82
- package/src/stories/grid/GridPopoutEditGeneric.stories.tsx +27 -22
- package/src/stories/grid/GridPopoutEditGenericTextArea.stories.tsx +29 -24
- package/src/stories/grid/GridPopoverEditBearing.stories.tsx +30 -25
- package/src/stories/grid/GridPopoverEditDropDown.stories.tsx +29 -24
- package/src/stories/grid/GridPopoverEditMultiSelect.stories.tsx +29 -24
- package/src/stories/grid/GridPopoverEditMultiSelectGrid.stories.tsx +28 -24
- package/src/stories/grid/GridReadOnly.stories.tsx +56 -52
- package/src/stories/grid/GridSorting.stories.tsx +498 -86
- package/src/stories/grid/GridViewList.stories.tsx +31 -26
- package/src/stories/grid/GridViewSelectableList.stories.tsx +31 -26
- package/src/stories/grid/gridAutosize/GridAutoSize.stories.tsx +41 -37
- package/src/stories/grid/gridAutosize/GridFitSize.stories.tsx +40 -36
- package/src/stories/grid/gridAutosize/GridFitSizeFlex.stories.tsx +40 -36
- package/src/stories/grid/gridAutosize/ShowPanelResizingAgGrid/ShowPanelResizingStepAgGrid.tsx +14 -6
- package/src/stories/grid/gridFormInteraction/GridFormDropDownInteraction.stories.tsx +74 -74
- package/src/stories/grid/gridFormInteraction/GridFormEditBearingCorrectionInteraction.stories.tsx +59 -59
- package/src/stories/grid/gridFormInteraction/GridFormEditBearingInteraction.stories.tsx +58 -58
- package/src/stories/grid/gridFormInteraction/GridFormMultiSelectGridInteraction.stories.tsx +62 -62
- package/src/stories/grid/gridFormInteraction/GridFormMultiSelectInteraction.stories.tsx +118 -118
- package/src/stories/grid/gridFormInteraction/GridFormPopoverMenuInteraction.stories.tsx +107 -105
- package/src/stories/grid/gridFormInteraction/GridFormTextAreaInteraction.stories.tsx +72 -64
- package/src/stories/grid/gridFormInteraction/GridFormTextInputInteraction.stories.tsx +82 -73
- package/src/stories/grid/gridFormStatic/GridFormDropDown.stories.tsx +12 -13
- package/src/stories/grid/gridFormStatic/GridFormEditBearing.stories.tsx +12 -13
- package/src/stories/grid/gridFormStatic/GridFormEditBearingCorrection.stories.tsx +11 -13
- package/src/stories/grid/gridFormStatic/GridFormMessage.stories.tsx +11 -13
- package/src/stories/grid/gridFormStatic/GridFormMultiSelect.stories.tsx +11 -13
- package/src/stories/grid/gridFormStatic/GridFormPopoverMenu.stories.tsx +11 -13
- package/src/stories/grid/gridFormStatic/GridFormTextArea.stories.tsx +11 -13
- package/src/stories/grid/gridFormStatic/GridFormTextInput.stories.tsx +11 -13
- package/src/stories/grid/interactions/GridKeyboardInteractions.stories.tsx +110 -107
- package/src/stories/react-menu/ReactMenu.stories.tsx +70 -73
- package/src/styles/GridLoadableCell.scss +1 -1
- package/src/utils/__tests__/storybookTestUtil.ts +1 -1
- package/src/utils/useSharedInterval.ts +3 -3
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import '
|
|
2
|
-
import '../../../styles/index.scss';
|
|
3
|
-
import '@linzjs/lui/dist/scss/base.scss';
|
|
4
|
-
|
|
5
|
-
import { StoryFn } from '@storybook/react-vite';
|
|
1
|
+
import { Meta, StoryFn, StoryObj } from '@storybook/react-vite';
|
|
6
2
|
import { GridPopoverContext } from '../../../contexts/GridPopoverContext';
|
|
7
3
|
import { useRef } from 'react';
|
|
8
4
|
import { expect, fn, userEvent, within } from 'storybook/test';
|
|
@@ -16,12 +12,6 @@ import {
|
|
|
16
12
|
wait,
|
|
17
13
|
} from '../../..';
|
|
18
14
|
|
|
19
|
-
export default {
|
|
20
|
-
title: 'GridForm / Interactions',
|
|
21
|
-
component: GridFormMultiSelect,
|
|
22
|
-
args: {},
|
|
23
|
-
};
|
|
24
|
-
|
|
25
15
|
const updateValue = fn((saveFn: (selectedRows: any[]) => Promise<boolean>, _tabDirection: 1 | 0 | -1) => saveFn([]));
|
|
26
16
|
|
|
27
17
|
const onSave = fn();
|
|
@@ -76,111 +66,121 @@ const Template: StoryFn<typeof GridFormMultiSelect> = (props: GridFormMultiSelec
|
|
|
76
66
|
);
|
|
77
67
|
};
|
|
78
68
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
69
|
+
const meta: Meta<typeof Template> = {
|
|
70
|
+
title: 'GridForm / Interactions',
|
|
71
|
+
component: Template,
|
|
72
|
+
args: {},
|
|
73
|
+
};
|
|
74
|
+
export default meta;
|
|
75
|
+
|
|
76
|
+
type Story = StoryObj<typeof meta>;
|
|
77
|
+
|
|
78
|
+
export const GridFormMultiSelectInteractions_: Story = {
|
|
79
|
+
play: async ({ canvasElement }) => {
|
|
80
|
+
updateValue.mockClear();
|
|
81
|
+
onSave.mockClear();
|
|
82
|
+
onSelectFilter.mockClear();
|
|
83
|
+
|
|
84
|
+
const canvas = within(canvasElement);
|
|
85
|
+
|
|
86
|
+
const getOption = (name: RegExp | string) => canvas.findByRole('menuitem', { name });
|
|
87
|
+
|
|
88
|
+
// Check enabled menu handles click
|
|
89
|
+
const zeroMenuOption = await getOption(/Zero/);
|
|
90
|
+
await expect(zeroMenuOption).toBeInTheDocument();
|
|
91
|
+
|
|
92
|
+
await userEvent.click(zeroMenuOption);
|
|
93
|
+
await userEvent.keyboard('{Tab}');
|
|
94
|
+
await expect(updateValue).toHaveBeenCalled();
|
|
95
|
+
await expect(onSave).toHaveBeenCalledWith({ selectedOptions: [options[0]], selectedRows: [] });
|
|
96
|
+
|
|
97
|
+
// Check sub menu works
|
|
98
|
+
const subTextInput = await getOption(/Sub component/);
|
|
99
|
+
await expect(subTextInput).toBeInTheDocument();
|
|
100
|
+
|
|
101
|
+
await expect(canvas.queryByPlaceholderText('Text input')).not.toBeInTheDocument();
|
|
102
|
+
|
|
103
|
+
await userEvent.click(subTextInput);
|
|
104
|
+
const textInput = await canvas.findByPlaceholderText('Text input');
|
|
105
|
+
await expect(textInput).toBeInTheDocument();
|
|
106
|
+
await expect(await canvas.findByText('Must not be empty')).toBeInTheDocument();
|
|
107
|
+
|
|
108
|
+
// textInput should be autofocus
|
|
109
|
+
await userEvent.type(textInput, 'Hello');
|
|
110
|
+
await expect(await canvas.findByText('Press enter or tab to save')).toBeInTheDocument();
|
|
111
|
+
|
|
112
|
+
// Test tab to save
|
|
113
|
+
updateValue.mockClear();
|
|
114
|
+
onSave.mockClear();
|
|
115
|
+
await userEvent.tab();
|
|
116
|
+
await expect(updateValue).toHaveBeenCalledWith(expect.anything(), 1); // 1 = Tab
|
|
117
|
+
await expect(onSave).toHaveBeenCalledWith({
|
|
118
|
+
selectedRows: [],
|
|
119
|
+
selectedOptions: [
|
|
120
|
+
{ label: 'Zero', value: 0, checked: true },
|
|
121
|
+
{ label: 'Sub component', value: 2, checked: true, subValue: 'Hello', subComponent: expect.anything() },
|
|
122
|
+
],
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
// Test shift+tab to save
|
|
126
|
+
updateValue.mockClear();
|
|
127
|
+
onSave.mockClear();
|
|
128
|
+
await userEvent.tab({ shift: true });
|
|
129
|
+
await expect(updateValue).toHaveBeenCalledWith(expect.anything(), -1); // -1 = Shift + tab
|
|
130
|
+
await expect(onSave).toHaveBeenCalled();
|
|
131
|
+
|
|
132
|
+
// Test escape to not save
|
|
133
|
+
updateValue.mockClear();
|
|
134
|
+
onSave.mockClear();
|
|
135
|
+
await userEvent.type(textInput, '{Escape}');
|
|
136
|
+
// expect(updateValue).not.toHaveBeenCalled();
|
|
137
|
+
await expect(updateValue).toHaveBeenCalledWith(expect.anything(), 0);
|
|
138
|
+
await expect(onSave).not.toHaveBeenCalled();
|
|
139
|
+
|
|
140
|
+
// Test invalid value doesn't save
|
|
141
|
+
updateValue.mockClear();
|
|
142
|
+
onSave.mockClear();
|
|
143
|
+
await userEvent.clear(textInput);
|
|
144
|
+
await userEvent.type(textInput, '{Enter}');
|
|
145
|
+
await expect(updateValue).not.toHaveBeenCalled();
|
|
146
|
+
await expect(onSave).not.toHaveBeenCalled();
|
|
147
|
+
|
|
148
|
+
// Test filter
|
|
149
|
+
const filterText = await canvas.findByPlaceholderText('Filter...');
|
|
150
|
+
await userEvent.type(filterText, 'o');
|
|
151
|
+
await wait(500);
|
|
152
|
+
await expect(canvas.queryByText('One')).toBeInTheDocument();
|
|
153
|
+
await expect(canvas.queryByText('Other')).toBeInTheDocument();
|
|
154
|
+
await userEvent.type(filterText, 'n');
|
|
155
|
+
await expect(canvas.queryByText('One')).toBeInTheDocument();
|
|
156
|
+
await expect(canvas.queryByText('Zero')).not.toBeInTheDocument();
|
|
157
|
+
await expect(canvas.queryByText('Sub component')).not.toBeInTheDocument();
|
|
158
|
+
await expect(canvas.queryByText('Other')).not.toBeInTheDocument();
|
|
159
|
+
|
|
160
|
+
await userEvent.type(filterText, 'x');
|
|
161
|
+
await expect(canvas.queryByText('One')).not.toBeInTheDocument();
|
|
162
|
+
await expect(canvas.queryByText('No Options')).toBeInTheDocument();
|
|
163
|
+
|
|
164
|
+
// Check enter works to add custom free-text
|
|
165
|
+
await userEvent.type(filterText, '{Enter}');
|
|
166
|
+
await expect(onSelectFilter).toHaveBeenCalledWith({
|
|
167
|
+
filter: 'onx',
|
|
168
|
+
options: [
|
|
169
|
+
{
|
|
170
|
+
...options[0],
|
|
171
|
+
checked: true,
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
...options[1],
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
...options[2],
|
|
178
|
+
checked: true,
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
...options[3],
|
|
182
|
+
},
|
|
183
|
+
],
|
|
184
|
+
});
|
|
185
|
+
},
|
|
186
186
|
};
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import '
|
|
2
|
-
import '../../../styles/index.scss';
|
|
3
|
-
import '@linzjs/lui/dist/scss/base.scss';
|
|
4
|
-
|
|
5
|
-
import { StoryFn } from '@storybook/react-vite';
|
|
1
|
+
import { Meta, StoryFn, StoryObj } from '@storybook/react-vite';
|
|
6
2
|
import { GridPopoverContext } from '../../../contexts/GridPopoverContext';
|
|
7
3
|
import { useRef } from 'react';
|
|
8
4
|
import * as test from 'storybook/test';
|
|
@@ -17,12 +13,6 @@ import {
|
|
|
17
13
|
PopoutMenuSeparator,
|
|
18
14
|
} from '../../..';
|
|
19
15
|
|
|
20
|
-
export default {
|
|
21
|
-
title: 'GridForm / Interactions',
|
|
22
|
-
component: GridFormPopoverMenu,
|
|
23
|
-
args: {},
|
|
24
|
-
};
|
|
25
|
-
|
|
26
16
|
const updateValue = test.fn((saveFn: (selectedRows: any[]) => Promise<boolean>, _tabDirection: 1 | 0 | -1) =>
|
|
27
17
|
saveFn([]),
|
|
28
18
|
);
|
|
@@ -82,93 +72,103 @@ const Template: StoryFn<typeof GridFormPopoverMenu> = (props: GridFormPopoverMen
|
|
|
82
72
|
);
|
|
83
73
|
};
|
|
84
74
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
75
|
+
const meta: Meta<typeof Template> = {
|
|
76
|
+
title: 'GridForm / Interactions',
|
|
77
|
+
component: Template,
|
|
78
|
+
args: {},
|
|
79
|
+
};
|
|
80
|
+
export default meta;
|
|
81
|
+
|
|
82
|
+
type Story = StoryObj<typeof meta>;
|
|
83
|
+
|
|
84
|
+
export const GridFormPopoverMenuInteractions_: Story = {
|
|
85
|
+
play: async ({ canvasElement }) => {
|
|
86
|
+
const canvas = within(canvasElement);
|
|
87
|
+
|
|
88
|
+
const getOption = (name: string) => canvas.findByRole('menuitem', { name });
|
|
89
|
+
|
|
90
|
+
const enabledMenuOption = await getOption('Enabled');
|
|
91
|
+
await expect(enabledMenuOption).toBeInTheDocument();
|
|
92
|
+
await userEvent.click(enabledMenuOption);
|
|
93
|
+
await expect(enabledAction).toHaveBeenCalled();
|
|
94
|
+
|
|
95
|
+
enabledAction.mockClear();
|
|
96
|
+
const disabledMenuOption = await getOption('Disabled');
|
|
97
|
+
await expect(disabledMenuOption).toBeInTheDocument();
|
|
98
|
+
await userEvent.click(disabledMenuOption);
|
|
99
|
+
await expect(disabledAction).not.toHaveBeenCalled();
|
|
100
|
+
|
|
101
|
+
// Sub input tests
|
|
102
|
+
const subTextInput = await getOption('Sub text input');
|
|
103
|
+
await expect(subTextInput).toBeInTheDocument();
|
|
104
|
+
await expect(canvas.queryByPlaceholderText('Text input')).not.toBeInTheDocument();
|
|
105
|
+
|
|
106
|
+
const subTextArea = await getOption('Sub text area');
|
|
107
|
+
await expect(subTextArea).toBeInTheDocument();
|
|
108
|
+
await expect(canvas.queryByPlaceholderText('Text area')).not.toBeInTheDocument();
|
|
109
|
+
|
|
110
|
+
await userEvent.click(subTextInput);
|
|
111
|
+
const textInput = await canvas.findByPlaceholderText('Text input');
|
|
112
|
+
await expect(textInput).toBeInTheDocument();
|
|
113
|
+
await expect(await canvas.findByText('Must not be empty')).toBeInTheDocument();
|
|
114
|
+
await expect(canvas.queryByPlaceholderText('Text area')).not.toBeInTheDocument();
|
|
115
|
+
|
|
116
|
+
await userEvent.type(textInput, 'Hello');
|
|
117
|
+
await expect(await canvas.findByText('Press enter or tab to save')).toBeInTheDocument();
|
|
118
|
+
|
|
119
|
+
// Test tab to save
|
|
120
|
+
updateValue.mockClear();
|
|
121
|
+
await userEvent.tab();
|
|
122
|
+
await expect(updateValue).toHaveBeenCalledWith(expect.anything(), 1); // 1 = Tab
|
|
123
|
+
|
|
124
|
+
// Test shift+tab to save
|
|
125
|
+
updateValue.mockClear();
|
|
126
|
+
await userEvent.tab({ shift: true });
|
|
127
|
+
await expect(updateValue).toHaveBeenCalledWith(expect.anything(), -1); // -1 = Shift + tab
|
|
128
|
+
|
|
129
|
+
// Test escape to not save
|
|
130
|
+
updateValue.mockClear();
|
|
131
|
+
await userEvent.type(textInput, '{Escape}');
|
|
132
|
+
await expect(updateValue).toHaveBeenCalledWith(expect.anything(), 0);
|
|
133
|
+
|
|
134
|
+
// Test invalid value doesn't save
|
|
135
|
+
updateValue.mockClear();
|
|
136
|
+
await userEvent.clear(textInput);
|
|
137
|
+
await userEvent.type(textInput, '{Enter}');
|
|
138
|
+
await expect(updateValue).not.toHaveBeenCalled();
|
|
139
|
+
|
|
140
|
+
// Sub text area tests
|
|
141
|
+
subTextArea.click();
|
|
142
|
+
|
|
143
|
+
const textArea = await canvas.findByPlaceholderText('Text area');
|
|
144
|
+
await expect(textArea).toBeInTheDocument();
|
|
145
|
+
await expect(await canvas.findByText('Must not be empty')).toBeInTheDocument();
|
|
146
|
+
await expect(canvas.queryByPlaceholderText('Text input')).not.toBeInTheDocument();
|
|
147
|
+
|
|
148
|
+
await userEvent.type(textArea, 'Hello');
|
|
149
|
+
await expect(await canvas.findByText('Press tab to save')).toBeInTheDocument();
|
|
150
|
+
|
|
151
|
+
// Test tab to save
|
|
152
|
+
updateValue.mockClear();
|
|
153
|
+
await userEvent.tab();
|
|
154
|
+
await expect(updateValue).toHaveBeenCalledWith(expect.anything(), 1); // 1 = Tab
|
|
155
|
+
|
|
156
|
+
// Test shift+tab to save
|
|
157
|
+
updateValue.mockClear();
|
|
158
|
+
await userEvent.tab({ shift: true });
|
|
159
|
+
await expect(updateValue).toHaveBeenCalledWith(expect.anything(), -1); // -1 = Shift + tab
|
|
160
|
+
|
|
161
|
+
// Test escape to not save
|
|
162
|
+
updateValue.mockClear();
|
|
163
|
+
await userEvent.type(textArea, '{Escape}');
|
|
164
|
+
await expect(updateValue).toHaveBeenCalledWith(expect.anything(), 0);
|
|
165
|
+
|
|
166
|
+
// Test invalid value doesn't save
|
|
167
|
+
updateValue.mockClear();
|
|
168
|
+
await userEvent.clear(textArea);
|
|
169
|
+
await userEvent.type(textArea, '{Enter}');
|
|
170
|
+
await expect(updateValue).not.toHaveBeenCalled();
|
|
171
|
+
},
|
|
172
172
|
};
|
|
173
173
|
|
|
174
174
|
const AllHiddenTemplate: StoryFn<typeof GridFormPopoverMenu> = (props: GridFormPopoverMenuProps<any>) => {
|
|
@@ -209,11 +209,13 @@ const AllHiddenTemplate: StoryFn<typeof GridFormPopoverMenu> = (props: GridFormP
|
|
|
209
209
|
// Regression test: when every option resolves to hidden, the menu must show "No actions"
|
|
210
210
|
// rather than an empty menu body (isEmpty(options) alone doesn't catch this — the array is
|
|
211
211
|
// non-empty, just every item is hidden).
|
|
212
|
-
export const GridFormPopoverMenuAllOptionsHidden_ =
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
212
|
+
export const GridFormPopoverMenuAllOptionsHidden_: Story = {
|
|
213
|
+
render: AllHiddenTemplate,
|
|
214
|
+
play: async ({ canvasElement }) => {
|
|
215
|
+
const canvas = within(canvasElement);
|
|
216
|
+
|
|
217
|
+
await expect(await canvas.findByText('No actions')).toBeInTheDocument();
|
|
218
|
+
await expect(canvas.queryByRole('menuitem', { name: 'Hidden one' })).not.toBeInTheDocument();
|
|
219
|
+
await expect(canvas.queryByRole('menuitem', { name: 'Hidden two' })).not.toBeInTheDocument();
|
|
220
|
+
},
|
|
219
221
|
};
|