@madie/madie-design-system 1.2.52 → 1.2.53
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/components/MadieDialog/MadieDialog.stories.js +52 -0
- package/components/MadieDialog/index.jsx +17 -9
- package/dist/browser.js +1 -1
- package/dist/index.js +1 -1
- package/dist/react/index.js +1 -1
- package/dist/react/index.js.map +1 -1
- package/package.json +1 -1
- package/test/components/MadieDialog.test.js +208 -0
package/package.json
CHANGED
|
@@ -176,4 +176,212 @@ describe("Madie Dialog", () => {
|
|
|
176
176
|
expect(cancelButton).toBeInTheDocument();
|
|
177
177
|
expect(submitButton).not.toBeInTheDocument();
|
|
178
178
|
});
|
|
179
|
+
|
|
180
|
+
it("It renders of type form with required components and tooltips for continue button when it's disabled", async () => {
|
|
181
|
+
const { getByTestId, queryByText, queryByTestId } = render(
|
|
182
|
+
<div>
|
|
183
|
+
<MadieDialog
|
|
184
|
+
form={true}
|
|
185
|
+
title="Basic Form"
|
|
186
|
+
dialogProps={{
|
|
187
|
+
open: true,
|
|
188
|
+
onClose: onFormCancel,
|
|
189
|
+
onSubmit: onFormSubmit,
|
|
190
|
+
maxWidth: "sm",
|
|
191
|
+
showRequiredFieldMessage: true,
|
|
192
|
+
}}
|
|
193
|
+
cancelButtonProps={{
|
|
194
|
+
id: "cancelBtn",
|
|
195
|
+
"data-testid": "form-cancel-button",
|
|
196
|
+
variant: "secondary",
|
|
197
|
+
cancelText: "Cancel",
|
|
198
|
+
}}
|
|
199
|
+
continueButtonProps={{
|
|
200
|
+
type: "submit",
|
|
201
|
+
"data-testid": "form-continue-button",
|
|
202
|
+
disabled: true,
|
|
203
|
+
continueText: "Continue",
|
|
204
|
+
tooltipText: "Continue button is disabled",
|
|
205
|
+
}}
|
|
206
|
+
>
|
|
207
|
+
<div>this is a form message</div>
|
|
208
|
+
</MadieDialog>
|
|
209
|
+
</div>
|
|
210
|
+
);
|
|
211
|
+
expect(getByTestId("dialog-form")).toBeInTheDocument();
|
|
212
|
+
expect(queryByText("Indicates required field")).toBeInTheDocument();
|
|
213
|
+
const cancelButton = getByTestId("close-button");
|
|
214
|
+
const submitButton = queryByTestId("form-continue-button");
|
|
215
|
+
expect(cancelButton).toBeInTheDocument();
|
|
216
|
+
expect(submitButton).toBeInTheDocument();
|
|
217
|
+
|
|
218
|
+
fireEvent.mouseOver(submitButton);
|
|
219
|
+
await waitFor(() => {
|
|
220
|
+
expect(
|
|
221
|
+
queryByText("Continue button is disabled")
|
|
222
|
+
).toBeInTheDocument();
|
|
223
|
+
});
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
it("It does not show tooltips for continue button when it's enabled", async () => {
|
|
227
|
+
const { getByTestId, queryByText, queryByTestId } = render(
|
|
228
|
+
<div>
|
|
229
|
+
<MadieDialog
|
|
230
|
+
form={true}
|
|
231
|
+
title="Basic Form"
|
|
232
|
+
dialogProps={{
|
|
233
|
+
open: true,
|
|
234
|
+
onClose: onFormCancel,
|
|
235
|
+
onSubmit: onFormSubmit,
|
|
236
|
+
maxWidth: "sm",
|
|
237
|
+
showRequiredFieldMessage: true,
|
|
238
|
+
}}
|
|
239
|
+
cancelButtonProps={{
|
|
240
|
+
id: "cancelBtn",
|
|
241
|
+
"data-testid": "form-cancel-button",
|
|
242
|
+
variant: "secondary",
|
|
243
|
+
cancelText: "Cancel",
|
|
244
|
+
}}
|
|
245
|
+
continueButtonProps={{
|
|
246
|
+
type: "submit",
|
|
247
|
+
"data-testid": "form-continue-button",
|
|
248
|
+
disabled: false,
|
|
249
|
+
continueText: "Continue",
|
|
250
|
+
tooltipText: "Continue button is disabled",
|
|
251
|
+
}}
|
|
252
|
+
>
|
|
253
|
+
<div>this is a form message</div>
|
|
254
|
+
</MadieDialog>
|
|
255
|
+
</div>
|
|
256
|
+
);
|
|
257
|
+
expect(getByTestId("dialog-form")).toBeInTheDocument();
|
|
258
|
+
expect(queryByText("Indicates required field")).toBeInTheDocument();
|
|
259
|
+
const cancelButton = getByTestId("close-button");
|
|
260
|
+
const submitButton = queryByTestId("form-continue-button");
|
|
261
|
+
expect(cancelButton).toBeInTheDocument();
|
|
262
|
+
expect(submitButton).toBeInTheDocument();
|
|
263
|
+
|
|
264
|
+
fireEvent.mouseOver(submitButton);
|
|
265
|
+
await waitFor(() => {
|
|
266
|
+
expect(
|
|
267
|
+
queryByText("Continue button is disabled")
|
|
268
|
+
).not.toBeInTheDocument();
|
|
269
|
+
});
|
|
270
|
+
});
|
|
271
|
+
|
|
272
|
+
it("It does not show tooltips for continue button when there is no tooltip text", async () => {
|
|
273
|
+
const { getByTestId, queryByText, queryByTestId } = render(
|
|
274
|
+
<div>
|
|
275
|
+
<MadieDialog
|
|
276
|
+
form={true}
|
|
277
|
+
title="Basic Form"
|
|
278
|
+
dialogProps={{
|
|
279
|
+
open: true,
|
|
280
|
+
onClose: onFormCancel,
|
|
281
|
+
onSubmit: onFormSubmit,
|
|
282
|
+
maxWidth: "sm",
|
|
283
|
+
showRequiredFieldMessage: true,
|
|
284
|
+
}}
|
|
285
|
+
cancelButtonProps={{
|
|
286
|
+
id: "cancelBtn",
|
|
287
|
+
"data-testid": "form-cancel-button",
|
|
288
|
+
variant: "secondary",
|
|
289
|
+
cancelText: "Cancel",
|
|
290
|
+
}}
|
|
291
|
+
continueButtonProps={{
|
|
292
|
+
type: "submit",
|
|
293
|
+
"data-testid": "form-continue-button",
|
|
294
|
+
continueText: "Continue",
|
|
295
|
+
}}
|
|
296
|
+
>
|
|
297
|
+
<div>this is a form message</div>
|
|
298
|
+
</MadieDialog>
|
|
299
|
+
</div>
|
|
300
|
+
);
|
|
301
|
+
expect(getByTestId("dialog-form")).toBeInTheDocument();
|
|
302
|
+
expect(queryByText("Indicates required field")).toBeInTheDocument();
|
|
303
|
+
const cancelButton = getByTestId("close-button");
|
|
304
|
+
const submitButton = queryByTestId("form-continue-button");
|
|
305
|
+
expect(cancelButton).toBeInTheDocument();
|
|
306
|
+
expect(submitButton).toBeInTheDocument();
|
|
307
|
+
|
|
308
|
+
fireEvent.mouseOver(submitButton);
|
|
309
|
+
await waitFor(() => {
|
|
310
|
+
expect(
|
|
311
|
+
queryByText("Continue button is disabled")
|
|
312
|
+
).not.toBeInTheDocument();
|
|
313
|
+
});
|
|
314
|
+
});
|
|
315
|
+
|
|
316
|
+
it("It renders popover button", async () => {
|
|
317
|
+
const onClose = jest.fn();
|
|
318
|
+
const open = true;
|
|
319
|
+
const setOpen = jest.fn();
|
|
320
|
+
const { getByTestId, queryByText } = render(
|
|
321
|
+
<div>
|
|
322
|
+
<MadieDialog
|
|
323
|
+
form={true}
|
|
324
|
+
title="Basic Form"
|
|
325
|
+
dialogProps={{
|
|
326
|
+
onClose,
|
|
327
|
+
open,
|
|
328
|
+
maxWidth: "lg",
|
|
329
|
+
fullWidth: true,
|
|
330
|
+
onSubmit: () => {
|
|
331
|
+
console.log("Submitted");
|
|
332
|
+
setOpen(false);
|
|
333
|
+
},
|
|
334
|
+
}}
|
|
335
|
+
cancelButtonProps={{
|
|
336
|
+
variant: "secondary",
|
|
337
|
+
cancelText: "Cancel",
|
|
338
|
+
"data-testid": "cancel-button",
|
|
339
|
+
}}
|
|
340
|
+
continueButtonProps={{
|
|
341
|
+
variant: "cyan",
|
|
342
|
+
type: "submit",
|
|
343
|
+
"data-testid": "continue-button",
|
|
344
|
+
continueText: "Continue",
|
|
345
|
+
popoverOptions: [
|
|
346
|
+
{
|
|
347
|
+
label: "Export",
|
|
348
|
+
dataTestId: "export-option",
|
|
349
|
+
toImplementFunction: () =>
|
|
350
|
+
console.log("Export clicked"),
|
|
351
|
+
},
|
|
352
|
+
{
|
|
353
|
+
label: "Export for Publishing",
|
|
354
|
+
dataTestId: "export-publishing-option",
|
|
355
|
+
toImplementFunction: () =>
|
|
356
|
+
console.log(
|
|
357
|
+
"Export for Publishing clicked"
|
|
358
|
+
),
|
|
359
|
+
},
|
|
360
|
+
],
|
|
361
|
+
}}
|
|
362
|
+
>
|
|
363
|
+
<div>this is a form message</div>
|
|
364
|
+
</MadieDialog>
|
|
365
|
+
</div>
|
|
366
|
+
);
|
|
367
|
+
|
|
368
|
+
const cancelButton = getByTestId("cancel-button");
|
|
369
|
+
const submitButton = getByTestId("continue-button");
|
|
370
|
+
expect(cancelButton).toBeInTheDocument();
|
|
371
|
+
expect(submitButton).toBeInTheDocument();
|
|
372
|
+
|
|
373
|
+
fireEvent.click(submitButton);
|
|
374
|
+
await waitFor(() => {
|
|
375
|
+
expect(queryByText("Export")).toBeInTheDocument();
|
|
376
|
+
expect(queryByText("Export for Publishing")).toBeInTheDocument();
|
|
377
|
+
});
|
|
378
|
+
const exportOption = getByTestId("export-option");
|
|
379
|
+
const exportPublishingOption = getByTestId("export-publishing-option");
|
|
380
|
+
expect(exportOption).toBeInTheDocument();
|
|
381
|
+
expect(exportPublishingOption).toBeInTheDocument();
|
|
382
|
+
fireEvent.click(exportOption);
|
|
383
|
+
await waitFor(() => {
|
|
384
|
+
expect(setOpen).toHaveBeenCalledTimes(1);
|
|
385
|
+
});
|
|
386
|
+
});
|
|
179
387
|
});
|