@linzjs/step-ag-grid 32.7.1 → 33.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/gridFilter/GridFilterColumnsMultiSelect.d.ts +6 -25
- package/dist/step-ag-grid.cjs +117 -186
- package/dist/step-ag-grid.cjs.map +1 -1
- package/dist/step-ag-grid.esm.js +117 -186
- 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/gridFilter/GridFilterColumnsMultiSelect.tsx +110 -199
- package/src/components/gridHook/useGridRangeSelection.ts +8 -6
- package/src/react-menu3/components/ControlledMenu.tsx +5 -3
- package/src/react-menu3/components/MenuList.tsx +6 -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 +42 -35
- 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 +81 -79
- 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/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';
|
|
@@ -14,12 +10,6 @@ import {
|
|
|
14
10
|
GridPopoverEditBearingEditorParams,
|
|
15
11
|
} from '../../..';
|
|
16
12
|
|
|
17
|
-
export default {
|
|
18
|
-
title: 'GridForm / Interactions',
|
|
19
|
-
component: GridFormEditBearing,
|
|
20
|
-
args: {},
|
|
21
|
-
};
|
|
22
|
-
|
|
23
13
|
const updateValue = fn();
|
|
24
14
|
|
|
25
15
|
const Template: StoryFn<typeof GridFormEditBearing> = (props: GridFormEditBearingProps<any>) => {
|
|
@@ -51,51 +41,61 @@ const Template: StoryFn<typeof GridFormEditBearing> = (props: GridFormEditBearin
|
|
|
51
41
|
);
|
|
52
42
|
};
|
|
53
43
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
44
|
+
const meta: Meta<typeof Template> = {
|
|
45
|
+
title: 'GridForm / Interactions',
|
|
46
|
+
component: Template,
|
|
47
|
+
args: {},
|
|
48
|
+
};
|
|
49
|
+
export default meta;
|
|
50
|
+
|
|
51
|
+
type Story = StoryObj<typeof meta>;
|
|
52
|
+
|
|
53
|
+
export const GridFormEditBearingInteractions_: Story = {
|
|
54
|
+
play: async ({ canvasElement }) => {
|
|
55
|
+
const canvas = within(canvasElement);
|
|
56
|
+
|
|
57
|
+
await expect(await canvas.findByText('Press enter or tab to save')).toBeInTheDocument();
|
|
58
|
+
|
|
59
|
+
const inputField = canvas.getByPlaceholderText('Enter bearing');
|
|
60
|
+
|
|
61
|
+
// Test formatting null
|
|
62
|
+
await expect(await canvas.findByText('–')).toBeInTheDocument();
|
|
63
|
+
|
|
64
|
+
// Test formatting a bearing
|
|
65
|
+
await expect(inputField).toBeInTheDocument();
|
|
66
|
+
await userEvent.type(inputField, '1.2345');
|
|
67
|
+
await expect(await canvas.findByText('1° 23\' 45"')).toBeInTheDocument();
|
|
68
|
+
|
|
69
|
+
// Test enter to save
|
|
70
|
+
updateValue.mockClear();
|
|
71
|
+
await userEvent.type(inputField, '{Enter}');
|
|
72
|
+
await expect(updateValue).toHaveBeenCalledWith(expect.anything(), 0); // 0 = Enter
|
|
73
|
+
|
|
74
|
+
// Test tab to save
|
|
75
|
+
updateValue.mockClear();
|
|
76
|
+
await userEvent.tab();
|
|
77
|
+
await expect(updateValue).toHaveBeenCalledWith(expect.anything(), 1); // 1 = Tab
|
|
78
|
+
|
|
79
|
+
// Test shift+tab to save
|
|
80
|
+
updateValue.mockClear();
|
|
81
|
+
await userEvent.tab({ shift: true });
|
|
82
|
+
await expect(updateValue).toHaveBeenCalledWith(expect.anything(), -1); // -1 = Shift + tab
|
|
83
|
+
|
|
84
|
+
// Test escape not to save
|
|
85
|
+
updateValue.mockClear();
|
|
86
|
+
await userEvent.type(inputField, '{Escape}');
|
|
87
|
+
await expect(updateValue).toHaveBeenCalledWith(expect.anything(), 0);
|
|
88
|
+
|
|
89
|
+
// Test invalid value doesn't save
|
|
90
|
+
updateValue.mockClear();
|
|
91
|
+
await userEvent.type(inputField, 'xxx');
|
|
92
|
+
await expect(await canvas.findByText('?')).toBeInTheDocument();
|
|
93
|
+
await expect(canvas.getByText('Bearing must be a number in D.MMSSS format')).toBeInTheDocument();
|
|
94
|
+
await userEvent.type(inputField, '{Enter}');
|
|
95
|
+
await expect(updateValue).not.toHaveBeenCalled();
|
|
96
|
+
await userEvent.tab();
|
|
97
|
+
await expect(updateValue).not.toHaveBeenCalled();
|
|
98
|
+
await userEvent.tab({ shift: true });
|
|
99
|
+
await expect(updateValue).not.toHaveBeenCalled();
|
|
100
|
+
},
|
|
101
101
|
};
|
|
@@ -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, waitFor, within } from 'storybook/test';
|
|
@@ -14,12 +10,6 @@ import {
|
|
|
14
10
|
MultiSelectGridOption,
|
|
15
11
|
} from '../../..';
|
|
16
12
|
|
|
17
|
-
export default {
|
|
18
|
-
title: 'GridForm / Interactions',
|
|
19
|
-
component: GridFormMultiSelectGrid,
|
|
20
|
-
args: {},
|
|
21
|
-
};
|
|
22
|
-
|
|
23
13
|
const updateValue = fn((saveFn: (selectedRows: any[]) => Promise<boolean>, _tabDirection: 1 | 0 | -1) => saveFn([]));
|
|
24
14
|
|
|
25
15
|
// eslint-disable-next-line @typescript-eslint/require-await
|
|
@@ -70,55 +60,65 @@ const Template: StoryFn<typeof GridFormMultiSelectGrid> = (props: GridFormMultiS
|
|
|
70
60
|
);
|
|
71
61
|
};
|
|
72
62
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
const
|
|
94
|
-
expect(
|
|
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
|
-
|
|
63
|
+
const meta: Meta<typeof Template> = {
|
|
64
|
+
title: 'GridForm / Interactions',
|
|
65
|
+
component: Template,
|
|
66
|
+
args: {},
|
|
67
|
+
};
|
|
68
|
+
export default meta;
|
|
69
|
+
|
|
70
|
+
type Story = StoryObj<typeof meta>;
|
|
71
|
+
|
|
72
|
+
export const GridFormMultiSelectGridInteractions_: Story = {
|
|
73
|
+
play: async ({ canvasElement }) => {
|
|
74
|
+
updateValue.mockClear();
|
|
75
|
+
onSave.mockClear();
|
|
76
|
+
onSelectFilter.mockClear();
|
|
77
|
+
|
|
78
|
+
const canvas = within(canvasElement);
|
|
79
|
+
|
|
80
|
+
const getOption = (name: RegExp | string) => canvas.findByRole('menuitem', { name });
|
|
81
|
+
|
|
82
|
+
// Check enabled menu handles click
|
|
83
|
+
const zeroMenuOption = await getOption(/Zero/);
|
|
84
|
+
await expect(zeroMenuOption).toBeInTheDocument();
|
|
85
|
+
|
|
86
|
+
await userEvent.click(zeroMenuOption);
|
|
87
|
+
await userEvent.keyboard('{Tab}');
|
|
88
|
+
await expect(updateValue).toHaveBeenCalled();
|
|
89
|
+
await waitFor(() => expect(onSave).toHaveBeenCalledWith({ selectedRows: [], addValues: [0], removeValues: [] }));
|
|
90
|
+
|
|
91
|
+
const check = async (label: string) => {
|
|
92
|
+
const activeCell = canvasElement.ownerDocument.activeElement as HTMLElement | null;
|
|
93
|
+
await expect(activeCell?.innerText).toBe(label);
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
// Test left/right arrow
|
|
97
|
+
await userEvent.keyboard('{ArrowRight}');
|
|
98
|
+
await check('Three');
|
|
99
|
+
await userEvent.keyboard('{ArrowRight}');
|
|
100
|
+
await check('Zero');
|
|
101
|
+
await userEvent.keyboard('{ArrowLeft}');
|
|
102
|
+
await check('Three');
|
|
103
|
+
await userEvent.keyboard('{ArrowLeft}');
|
|
104
|
+
await check('Zero');
|
|
105
|
+
|
|
106
|
+
// Test tab to save
|
|
107
|
+
updateValue.mockClear();
|
|
108
|
+
onSave.mockClear();
|
|
109
|
+
await userEvent.tab();
|
|
110
|
+
await expect(updateValue).toHaveBeenCalledWith(expect.anything(), 1); // 1 = Tab
|
|
111
|
+
await expect(onSave).toHaveBeenCalledWith({
|
|
112
|
+
selectedRows: [],
|
|
113
|
+
addValues: [0],
|
|
114
|
+
removeValues: [],
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
// Test shift+tab to save
|
|
118
|
+
updateValue.mockClear();
|
|
119
|
+
onSave.mockClear();
|
|
120
|
+
await userEvent.tab({ shift: true });
|
|
121
|
+
await expect(updateValue).toHaveBeenCalledWith(expect.anything(), -1); // -1 = Shift + tab
|
|
122
|
+
await expect(onSave).toHaveBeenCalled();
|
|
123
|
+
},
|
|
124
124
|
};
|
|
@@ -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
|
};
|