@patternfly/react-core 4.240.0 → 4.241.1
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/CHANGELOG.md +22 -0
- package/dist/esm/components/OverflowMenu/OverflowMenu.d.ts +1 -0
- package/dist/esm/components/OverflowMenu/OverflowMenu.d.ts.map +1 -1
- package/dist/esm/components/OverflowMenu/OverflowMenu.js +3 -2
- package/dist/esm/components/OverflowMenu/OverflowMenu.js.map +1 -1
- package/dist/esm/components/Tabs/Tabs.js +2 -2
- package/dist/esm/components/Tabs/Tabs.js.map +1 -1
- package/dist/esm/helpers/Popper/FindRefWrapper.d.ts +1 -1
- package/dist/esm/next/components/Wizard/Wizard.d.ts +4 -2
- package/dist/esm/next/components/Wizard/Wizard.d.ts.map +1 -1
- package/dist/esm/next/components/Wizard/Wizard.js +9 -18
- package/dist/esm/next/components/Wizard/Wizard.js.map +1 -1
- package/dist/esm/next/components/Wizard/WizardBody.d.ts +1 -1
- package/dist/esm/next/components/Wizard/WizardBody.d.ts.map +1 -1
- package/dist/esm/next/components/Wizard/WizardContext.d.ts +3 -3
- package/dist/esm/next/components/Wizard/WizardContext.d.ts.map +1 -1
- package/dist/esm/next/components/Wizard/WizardContext.js +12 -2
- package/dist/esm/next/components/Wizard/WizardContext.js.map +1 -1
- package/dist/esm/next/components/Wizard/WizardNav.d.ts +1 -1
- package/dist/esm/next/components/Wizard/WizardNav.d.ts.map +1 -1
- package/dist/esm/next/components/Wizard/WizardNav.js +2 -2
- package/dist/esm/next/components/Wizard/WizardNav.js.map +1 -1
- package/dist/esm/next/components/Wizard/WizardNavItem.d.ts.map +1 -1
- package/dist/esm/next/components/Wizard/WizardNavItem.js +4 -1
- package/dist/esm/next/components/Wizard/WizardNavItem.js.map +1 -1
- package/dist/esm/next/components/Wizard/WizardStep.d.ts +3 -3
- package/dist/esm/next/components/Wizard/WizardStep.d.ts.map +1 -1
- package/dist/esm/next/components/Wizard/WizardStep.js +1 -1
- package/dist/esm/next/components/Wizard/WizardStep.js.map +1 -1
- package/dist/esm/next/components/Wizard/WizardToggle.d.ts +17 -8
- package/dist/esm/next/components/Wizard/WizardToggle.d.ts.map +1 -1
- package/dist/esm/next/components/Wizard/WizardToggle.js +29 -24
- package/dist/esm/next/components/Wizard/WizardToggle.js.map +1 -1
- package/dist/esm/next/components/Wizard/hooks/useWizardFooter.d.ts +2 -1
- package/dist/esm/next/components/Wizard/hooks/useWizardFooter.d.ts.map +1 -1
- package/dist/esm/next/components/Wizard/hooks/useWizardFooter.js.map +1 -1
- package/dist/esm/next/components/Wizard/types.d.ts +7 -1
- package/dist/esm/next/components/Wizard/types.d.ts.map +1 -1
- package/dist/esm/next/components/Wizard/types.js.map +1 -1
- package/dist/esm/next/components/Wizard/utils.d.ts.map +1 -1
- package/dist/esm/next/components/Wizard/utils.js +16 -18
- package/dist/esm/next/components/Wizard/utils.js.map +1 -1
- package/dist/js/components/OverflowMenu/OverflowMenu.d.ts +1 -0
- package/dist/js/components/OverflowMenu/OverflowMenu.d.ts.map +1 -1
- package/dist/js/components/OverflowMenu/OverflowMenu.js +3 -2
- package/dist/js/components/OverflowMenu/OverflowMenu.js.map +1 -1
- package/dist/js/components/Tabs/Tabs.js +2 -2
- package/dist/js/components/Tabs/Tabs.js.map +1 -1
- package/dist/js/helpers/Popper/FindRefWrapper.d.ts +1 -1
- package/dist/js/next/components/Wizard/Wizard.d.ts +4 -2
- package/dist/js/next/components/Wizard/Wizard.d.ts.map +1 -1
- package/dist/js/next/components/Wizard/Wizard.js +6 -15
- package/dist/js/next/components/Wizard/Wizard.js.map +1 -1
- package/dist/js/next/components/Wizard/WizardBody.d.ts +1 -1
- package/dist/js/next/components/Wizard/WizardBody.d.ts.map +1 -1
- package/dist/js/next/components/Wizard/WizardContext.d.ts +3 -3
- package/dist/js/next/components/Wizard/WizardContext.d.ts.map +1 -1
- package/dist/js/next/components/Wizard/WizardContext.js +12 -2
- package/dist/js/next/components/Wizard/WizardContext.js.map +1 -1
- package/dist/js/next/components/Wizard/WizardNav.d.ts +1 -1
- package/dist/js/next/components/Wizard/WizardNav.d.ts.map +1 -1
- package/dist/js/next/components/Wizard/WizardNav.js +2 -2
- package/dist/js/next/components/Wizard/WizardNav.js.map +1 -1
- package/dist/js/next/components/Wizard/WizardNavItem.d.ts.map +1 -1
- package/dist/js/next/components/Wizard/WizardNavItem.js +4 -1
- package/dist/js/next/components/Wizard/WizardNavItem.js.map +1 -1
- package/dist/js/next/components/Wizard/WizardStep.d.ts +3 -3
- package/dist/js/next/components/Wizard/WizardStep.d.ts.map +1 -1
- package/dist/js/next/components/Wizard/WizardStep.js +1 -1
- package/dist/js/next/components/Wizard/WizardStep.js.map +1 -1
- package/dist/js/next/components/Wizard/WizardToggle.d.ts +17 -8
- package/dist/js/next/components/Wizard/WizardToggle.d.ts.map +1 -1
- package/dist/js/next/components/Wizard/WizardToggle.js +32 -26
- package/dist/js/next/components/Wizard/WizardToggle.js.map +1 -1
- package/dist/js/next/components/Wizard/hooks/useWizardFooter.d.ts +2 -1
- package/dist/js/next/components/Wizard/hooks/useWizardFooter.d.ts.map +1 -1
- package/dist/js/next/components/Wizard/hooks/useWizardFooter.js.map +1 -1
- package/dist/js/next/components/Wizard/types.d.ts +7 -1
- package/dist/js/next/components/Wizard/types.d.ts.map +1 -1
- package/dist/js/next/components/Wizard/types.js.map +1 -1
- package/dist/js/next/components/Wizard/utils.d.ts.map +1 -1
- package/dist/js/next/components/Wizard/utils.js +16 -18
- package/dist/js/next/components/Wizard/utils.js.map +1 -1
- package/dist/umd/react-core.min.css +32 -32
- package/dist/umd/react-core.min.js +1 -1
- package/package.json +7 -7
- package/src/components/AlertGroup/examples/AlertGroupSingularDynamic.tsx +3 -3
- package/src/components/AlertGroup/examples/AlertGroupSingularDynamicOverflow.tsx +3 -3
- package/src/components/OverflowMenu/OverflowMenu.tsx +4 -2
- package/src/components/Tabs/Tabs.tsx +2 -2
- package/src/components/Tabs/__tests__/Tabs.test.tsx +19 -0
- package/src/components/Tabs/__tests__/__snapshots__/Tabs.test.tsx.snap +0 -546
- package/src/components/Title/examples/Title.md +4 -50
- package/src/components/Title/examples/TitleCustomSizes.tsx +25 -0
- package/src/components/Title/examples/TitleDefaultSizes.tsx +13 -0
- package/src/next/components/Wizard/Wizard.tsx +34 -47
- package/src/next/components/Wizard/WizardBody.tsx +1 -1
- package/src/next/components/Wizard/WizardContext.tsx +29 -5
- package/src/next/components/Wizard/WizardNav.tsx +3 -3
- package/src/next/components/Wizard/WizardNavItem.tsx +4 -1
- package/src/next/components/Wizard/WizardStep.tsx +4 -4
- package/src/next/components/Wizard/WizardToggle.tsx +74 -49
- package/src/next/components/Wizard/__tests__/Wizard.test.tsx +316 -298
- package/src/next/components/Wizard/__tests__/WizardBody.test.tsx +41 -0
- package/src/next/components/Wizard/__tests__/WizardFooter.test.tsx +93 -0
- package/src/next/components/Wizard/__tests__/WizardStep.test.tsx +33 -0
- package/src/next/components/Wizard/__tests__/WizardToggle.test.tsx +113 -0
- package/src/next/components/Wizard/__tests__/utils.test.tsx +66 -0
- package/src/next/components/Wizard/examples/Wizard.md +3 -5
- package/src/next/components/Wizard/examples/WizardCustomNav.tsx +2 -2
- package/src/next/components/Wizard/examples/WizardKitchenSink.tsx +3 -11
- package/src/next/components/Wizard/hooks/__tests__/useWizardFooter.test.tsx +51 -0
- package/src/next/components/Wizard/hooks/useWizardFooter.tsx +3 -1
- package/src/next/components/Wizard/types.tsx +7 -1
- package/src/next/components/Wizard/utils.ts +23 -21
|
@@ -3,302 +3,320 @@ import React from 'react';
|
|
|
3
3
|
import { render, screen } from '@testing-library/react';
|
|
4
4
|
import userEvent from '@testing-library/user-event';
|
|
5
5
|
|
|
6
|
-
import { DefaultWizardNavProps,
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
<
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
<
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
<
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
<
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
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
|
-
|
|
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
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
6
|
+
import { DefaultWizardNavProps, DefaultWizardFooterProps } from '../types';
|
|
7
|
+
import { Wizard, WizardStep } from '../';
|
|
8
|
+
|
|
9
|
+
test('renders step when child is of type WizardStep', () => {
|
|
10
|
+
render(
|
|
11
|
+
<Wizard>
|
|
12
|
+
<WizardStep id="test-step" name="Test step">
|
|
13
|
+
Step content
|
|
14
|
+
</WizardStep>
|
|
15
|
+
</Wizard>
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
expect(screen.getByRole('button', { name: 'Test step' })).toBeVisible();
|
|
19
|
+
expect(screen.getByText('Step content')).toBeVisible();
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
test('renders step when child has required props; name, id, children', () => {
|
|
23
|
+
const CustomStep = props => <div {...props} />;
|
|
24
|
+
|
|
25
|
+
render(
|
|
26
|
+
<Wizard>
|
|
27
|
+
<CustomStep id="test-step" name="Test step">
|
|
28
|
+
Custom step content
|
|
29
|
+
</CustomStep>
|
|
30
|
+
</Wizard>
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
expect(screen.getByRole('button', { name: 'Test step' })).toBeVisible();
|
|
34
|
+
expect(screen.getByText('Custom step content')).toBeVisible();
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
test('renders a header when specified', () => {
|
|
38
|
+
render(
|
|
39
|
+
<Wizard header="Some header">
|
|
40
|
+
<WizardStep id="test-step" name="Test step" />
|
|
41
|
+
</Wizard>
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
expect(screen.getByText('Some header')).toBeVisible();
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
test('renders default footer without specifying the footer prop', () => {
|
|
48
|
+
render(
|
|
49
|
+
<Wizard>
|
|
50
|
+
<WizardStep id="test-step" name="Test step" />
|
|
51
|
+
</Wizard>
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
expect(screen.getByRole('button', { name: 'Next' })).toBeVisible();
|
|
55
|
+
expect(screen.getByRole('button', { name: 'Back' })).toBeVisible();
|
|
56
|
+
expect(screen.getByRole('button', { name: 'Cancel' })).toBeVisible();
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
test('renders default footer with custom props', () => {
|
|
60
|
+
const footer: DefaultWizardFooterProps = {
|
|
61
|
+
nextButtonText: <>Proceed with caution</>,
|
|
62
|
+
backButtonText: 'Turn back!',
|
|
63
|
+
cancelButtonText: 'Leave now!'
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
render(
|
|
67
|
+
<Wizard footer={footer}>
|
|
68
|
+
<WizardStep id="test-step" name="Test step" />
|
|
69
|
+
</Wizard>
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
expect(screen.getByRole('button', { name: 'Proceed with caution' })).toBeVisible();
|
|
73
|
+
expect(screen.getByRole('button', { name: 'Turn back!' })).toBeVisible();
|
|
74
|
+
expect(screen.getByRole('button', { name: 'Leave now!' })).toBeVisible();
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
test('renders custom footer', () => {
|
|
78
|
+
render(
|
|
79
|
+
<Wizard footer={<>Some footer</>}>
|
|
80
|
+
<WizardStep id="test-step" name="Test step" />
|
|
81
|
+
</Wizard>
|
|
82
|
+
);
|
|
83
|
+
|
|
84
|
+
expect(screen.getByText('Some footer')).toBeVisible();
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
test('renders default nav without specifying the nav prop', () => {
|
|
88
|
+
render(
|
|
89
|
+
<Wizard>
|
|
90
|
+
<WizardStep id="test-step" name="Test step" />
|
|
91
|
+
</Wizard>
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
expect(screen.getByRole('navigation')).toBeVisible();
|
|
95
|
+
expect(screen.getByRole('button', { name: 'Test step' })).toBeVisible();
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
test('renders default nav with custom props', () => {
|
|
99
|
+
const nav: DefaultWizardNavProps = {
|
|
100
|
+
isExpandable: true,
|
|
101
|
+
ariaLabel: 'Some nav label',
|
|
102
|
+
ariaLabelledBy: 'wizard-id',
|
|
103
|
+
forceStepVisit: true
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
render(
|
|
107
|
+
<Wizard id="wizard-id" nav={nav}>
|
|
108
|
+
<WizardStep id="step-1" name="Test step 1" steps={[<WizardStep id="nested-step" name="Nested step" />]} />
|
|
109
|
+
<WizardStep id="step-2" name="Test step 2" />
|
|
110
|
+
</Wizard>
|
|
111
|
+
);
|
|
112
|
+
|
|
113
|
+
const navElement = screen.getByLabelText('Some nav label');
|
|
114
|
+
|
|
115
|
+
expect(navElement).toBeVisible();
|
|
116
|
+
expect(navElement).toHaveAttribute('aria-labelledby', 'wizard-id');
|
|
117
|
+
expect(screen.getByRole('button', { name: 'Test step 1' }).parentElement).toHaveClass('pf-m-expandable');
|
|
118
|
+
expect(screen.getByRole('button', { name: 'Test step 2' })).toHaveAttribute('disabled');
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
test('renders custom nav', () => {
|
|
122
|
+
const customNav = <nav>Some custom nav</nav>;
|
|
123
|
+
|
|
124
|
+
render(
|
|
125
|
+
<Wizard nav={customNav}>
|
|
126
|
+
<WizardStep id="test-step" name="Test step" />
|
|
127
|
+
</Wizard>
|
|
128
|
+
);
|
|
129
|
+
|
|
130
|
+
expect(screen.getByRole('navigation')).toBeVisible();
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
test('starts at the first step as the active one by default', () => {
|
|
134
|
+
render(
|
|
135
|
+
<Wizard>
|
|
136
|
+
<WizardStep id="step-1" name="Test step 1">
|
|
137
|
+
Step 1 content
|
|
138
|
+
</WizardStep>
|
|
139
|
+
<WizardStep id="step-2" name="Test step 2" />
|
|
140
|
+
</Wizard>
|
|
141
|
+
);
|
|
142
|
+
|
|
143
|
+
expect(screen.getByText('Step 1 content')).toBeVisible();
|
|
144
|
+
expect(screen.getByRole('button', { name: 'Test step 1' })).toHaveClass('pf-m-current');
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
test(`can start at a step that isn't the first by specifying 'startIndex'`, () => {
|
|
148
|
+
render(
|
|
149
|
+
<Wizard startIndex={2}>
|
|
150
|
+
<WizardStep id="step-1" name="Test step 1" />
|
|
151
|
+
<WizardStep id="step-2" name="Test step 2">
|
|
152
|
+
Step 2 content
|
|
153
|
+
</WizardStep>
|
|
154
|
+
</Wizard>
|
|
155
|
+
);
|
|
156
|
+
|
|
157
|
+
expect(screen.getByText('Step 2 content')).toBeVisible();
|
|
158
|
+
expect(screen.getByRole('button', { name: 'Test step 2' })).toHaveClass('pf-m-current');
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
test(`can use custom classNames and spread other props into the wizard's div`, () => {
|
|
162
|
+
render(
|
|
163
|
+
<Wizard className="some-class" data-testid="wizard-id">
|
|
164
|
+
<WizardStep id="test-step" name="Test step" />
|
|
165
|
+
</Wizard>
|
|
166
|
+
);
|
|
167
|
+
|
|
168
|
+
expect(screen.getByTestId('wizard-id')).toHaveClass('some-class');
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
test(`can customize the wizard's height and width`, () => {
|
|
172
|
+
render(
|
|
173
|
+
<Wizard height={500} width={500} data-testid="wizard-id">
|
|
174
|
+
<WizardStep id="test-step" name="Test step" />
|
|
175
|
+
</Wizard>
|
|
176
|
+
);
|
|
177
|
+
|
|
178
|
+
const wizard = screen.getByTestId('wizard-id');
|
|
179
|
+
|
|
180
|
+
expect(wizard).toHaveStyle('height: 500px');
|
|
181
|
+
expect(wizard).toHaveStyle('width: 500px');
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
test('calls onNavByIndex on nav item click', async () => {
|
|
185
|
+
const user = userEvent.setup();
|
|
186
|
+
const onNavByIndex = jest.fn();
|
|
187
|
+
|
|
188
|
+
render(
|
|
189
|
+
<Wizard onNavByIndex={onNavByIndex}>
|
|
190
|
+
<WizardStep id="step-1" name="Test step 1" />
|
|
191
|
+
<WizardStep id="step-2" name="Test step 2" />
|
|
192
|
+
</Wizard>
|
|
193
|
+
);
|
|
194
|
+
|
|
195
|
+
await user.click(screen.getByRole('button', { name: 'Test step 2' }));
|
|
196
|
+
expect(onNavByIndex).toHaveBeenCalled();
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
test('calls onNext and not onSave on next button click when not on the last step', async () => {
|
|
200
|
+
const user = userEvent.setup();
|
|
201
|
+
const onNext = jest.fn();
|
|
202
|
+
const onSave = jest.fn();
|
|
203
|
+
|
|
204
|
+
render(
|
|
205
|
+
<Wizard onNext={onNext} onSave={onSave}>
|
|
206
|
+
<WizardStep id="step-1" name="Test step 1" />
|
|
207
|
+
<WizardStep id="step-2" name="Test step 2" />
|
|
208
|
+
</Wizard>
|
|
209
|
+
);
|
|
210
|
+
|
|
211
|
+
await user.click(screen.getByRole('button', { name: 'Next' }));
|
|
212
|
+
|
|
213
|
+
expect(onNext).toHaveBeenCalled();
|
|
214
|
+
expect(onSave).not.toHaveBeenCalled();
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
test('calls onBack on back button click', async () => {
|
|
218
|
+
const user = userEvent.setup();
|
|
219
|
+
const onBack = jest.fn();
|
|
220
|
+
|
|
221
|
+
render(
|
|
222
|
+
<Wizard onBack={onBack}>
|
|
223
|
+
<WizardStep id="step-1" name="Test step 1" />
|
|
224
|
+
<WizardStep id="step-2" name="Test step 2" />
|
|
225
|
+
</Wizard>
|
|
226
|
+
);
|
|
227
|
+
|
|
228
|
+
await user.click(screen.getByRole('button', { name: 'Test step 2' }));
|
|
229
|
+
await user.click(screen.getByRole('button', { name: 'Back' }));
|
|
230
|
+
|
|
231
|
+
expect(onBack).toHaveBeenCalled();
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
test('calls onSave and not onClose on next button click when on the last step', async () => {
|
|
235
|
+
const user = userEvent.setup();
|
|
236
|
+
const onSave = jest.fn();
|
|
237
|
+
const onClose = jest.fn();
|
|
238
|
+
|
|
239
|
+
render(
|
|
240
|
+
<Wizard onSave={onSave} onClose={onClose}>
|
|
241
|
+
<WizardStep id="step-1" name="Test step 1" />
|
|
242
|
+
<WizardStep id="step-2" name="Test step 2" />
|
|
243
|
+
</Wizard>
|
|
244
|
+
);
|
|
245
|
+
|
|
246
|
+
await user.click(screen.getByRole('button', { name: 'Test step 2' }));
|
|
247
|
+
await user.click(screen.getByRole('button', { name: 'Next' }));
|
|
248
|
+
|
|
249
|
+
expect(onSave).toHaveBeenCalled();
|
|
250
|
+
expect(onClose).not.toHaveBeenCalled();
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
test('calls onClose when onSave is not specified on next button click when on the last step', async () => {
|
|
254
|
+
const user = userEvent.setup();
|
|
255
|
+
const onClose = jest.fn();
|
|
256
|
+
|
|
257
|
+
render(
|
|
258
|
+
<Wizard onClose={onClose}>
|
|
259
|
+
<WizardStep id="step-1" name="Test step 1" />
|
|
260
|
+
<WizardStep id="step-2" name="Test step 2" />
|
|
261
|
+
</Wizard>
|
|
262
|
+
);
|
|
263
|
+
|
|
264
|
+
await user.click(screen.getByRole('button', { name: 'Test step 2' }));
|
|
265
|
+
await user.click(screen.getByRole('button', { name: 'Next' }));
|
|
266
|
+
|
|
267
|
+
expect(onClose).toHaveBeenCalled();
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
test('calls onClose on cancel link click', async () => {
|
|
271
|
+
const user = userEvent.setup();
|
|
272
|
+
const onClose = jest.fn();
|
|
273
|
+
|
|
274
|
+
render(
|
|
275
|
+
<Wizard onClose={onClose}>
|
|
276
|
+
<WizardStep id="test-step" name="Test step" />
|
|
277
|
+
</Wizard>
|
|
278
|
+
);
|
|
279
|
+
|
|
280
|
+
await user.click(screen.getByRole('button', { name: 'Cancel' }));
|
|
281
|
+
expect(onClose).toHaveBeenCalled();
|
|
282
|
+
});
|
|
283
|
+
|
|
284
|
+
test('unmounts inactive steps by default', async () => {
|
|
285
|
+
const user = userEvent.setup();
|
|
286
|
+
|
|
287
|
+
render(
|
|
288
|
+
<Wizard>
|
|
289
|
+
<WizardStep id="step-1" name="Test step 1">
|
|
290
|
+
Step 1 content
|
|
291
|
+
</WizardStep>
|
|
292
|
+
<WizardStep id="step-2" name="Test step 2">
|
|
293
|
+
Step 2 content
|
|
294
|
+
</WizardStep>
|
|
295
|
+
</Wizard>
|
|
296
|
+
);
|
|
297
|
+
|
|
298
|
+
await user.click(screen.getByRole('button', { name: 'Test step 2' }));
|
|
299
|
+
|
|
300
|
+
expect(screen.queryByText('Step 1 content')).toBeNull();
|
|
301
|
+
expect(screen.getByText('Step 2 content')).toBeVisible();
|
|
302
|
+
});
|
|
303
|
+
|
|
304
|
+
test('keeps inactive steps mounted when unmountInactiveSteps is enabled', async () => {
|
|
305
|
+
const user = userEvent.setup();
|
|
306
|
+
|
|
307
|
+
render(
|
|
308
|
+
<Wizard unmountInactiveSteps={false}>
|
|
309
|
+
<WizardStep id="step-1" name="Test step 1">
|
|
310
|
+
Step 1 content
|
|
311
|
+
</WizardStep>
|
|
312
|
+
<WizardStep id="step-2" name="Test step 2">
|
|
313
|
+
Step 2 content
|
|
314
|
+
</WizardStep>
|
|
315
|
+
</Wizard>
|
|
316
|
+
);
|
|
317
|
+
|
|
318
|
+
await user.click(screen.getByRole('button', { name: 'Test step 2' }));
|
|
319
|
+
|
|
320
|
+
expect(screen.getByText('Step 1 content')).toBeInTheDocument();
|
|
321
|
+
expect(screen.getByText('Step 2 content')).toBeVisible();
|
|
304
322
|
});
|