@madie/madie-design-system 1.2.55 → 1.2.57
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/MadieAlert/index.jsx +323 -168
- package/components/MadieDeleteDialog/MadieDeleteDialog.stories.js +24 -0
- package/components/MadieDeleteDialog/index.jsx +6 -4
- package/components/RichTextEditor/index.jsx +3 -3
- package/dist/browser.js +1 -1
- package/dist/index.js +1 -1
- package/dist/react/index.js +2 -2
- package/dist/react/index.js.map +1 -1
- package/package.json +1 -1
- package/styles/components/_madie-alert.scss +4 -1
- package/styles/components/_rich-text-editor.scss +160 -158
- package/styles/qppds/components/_rich-text-editor.scss +160 -159
- package/test/components/MadieAlert.test.js +312 -23
- package/test/components/MadieDeleteDialog.test.js +27 -0
|
@@ -99,7 +99,7 @@ Row: 6, Col:0: VSAC: 0:87 | Request failed with status code 404 for oid = 1.16.8
|
|
|
99
99
|
});
|
|
100
100
|
it("renders with copy button and copies text correctly with a non-array in children", async () => {
|
|
101
101
|
const expectedReturn = `Following test case(s) were imported successfully, but the measure populations do not match the populations in the import file. The Test Case has been imported, but no expected values have been set.
|
|
102
|
-
9ccff643-5ec1-4875-910e-4f602c174455
|
|
102
|
+
9ccff643-5ec1-4875-910e-4f602c174455
|
|
103
103
|
21b8a225-7cd5-4b4b-bc08-b25100e6346c`;
|
|
104
104
|
const onClose = jest.fn();
|
|
105
105
|
const mockedWriteText = jest.fn();
|
|
@@ -230,28 +230,29 @@ Row: 6, Col:0: VSAC: 0:87 | Request failed with status code 404 for oid = 1.16.8
|
|
|
230
230
|
});
|
|
231
231
|
|
|
232
232
|
it("hides alert when minimize button is clicked", async () => {
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
233
|
+
const { getByTestId, queryByTestId } = render(
|
|
234
|
+
<MadieAlert
|
|
235
|
+
type="warning"
|
|
236
|
+
visible={true}
|
|
237
|
+
canClose={false}
|
|
238
|
+
minimizeAlerts={true}
|
|
239
|
+
content={<h1>Test content</h1>}
|
|
240
|
+
alertProps={{
|
|
241
|
+
"data-testid": "alert-dialog",
|
|
242
|
+
}}
|
|
243
|
+
/>
|
|
244
|
+
);
|
|
245
|
+
|
|
246
|
+
expect(getByTestId("alert-dialog")).toBeInTheDocument();
|
|
247
|
+
// Update to use the index-specific button ID
|
|
248
|
+
const minimizeButton = getByTestId("minimize-button-0");
|
|
249
|
+
|
|
250
|
+
fireEvent.click(minimizeButton);
|
|
251
|
+
|
|
252
|
+
// After clicking minimize, the alert should not be in the document
|
|
253
|
+
await waitFor(() => {
|
|
254
|
+
expect(queryByTestId("alert-dialog")).not.toBeInTheDocument();
|
|
255
|
+
});
|
|
255
256
|
});
|
|
256
257
|
|
|
257
258
|
it("does not render minimize button when minimizeAlerts is false", () => {
|
|
@@ -271,4 +272,292 @@ Row: 6, Col:0: VSAC: 0:87 | Request failed with status code 404 for oid = 1.16.8
|
|
|
271
272
|
expect(getByTestId("alert-dialog")).toBeInTheDocument();
|
|
272
273
|
expect(queryByTestId("FullscreenExitRoundedIcon")).toBeNull();
|
|
273
274
|
});
|
|
275
|
+
|
|
276
|
+
it("renders multiple alerts using the alerts array prop", () => {
|
|
277
|
+
const { getAllByRole, queryAllByRole } = render(
|
|
278
|
+
<MadieAlert
|
|
279
|
+
minimizeAlerts={true}
|
|
280
|
+
alerts={[
|
|
281
|
+
{
|
|
282
|
+
type: "error",
|
|
283
|
+
content: <h2>Error message</h2>,
|
|
284
|
+
canClose: false
|
|
285
|
+
},
|
|
286
|
+
{
|
|
287
|
+
type: "warning",
|
|
288
|
+
content: <h2>Warning message</h2>,
|
|
289
|
+
canClose: false
|
|
290
|
+
}
|
|
291
|
+
]}
|
|
292
|
+
/>
|
|
293
|
+
);
|
|
294
|
+
|
|
295
|
+
// Should find two heading elements (one from each alert)
|
|
296
|
+
const headings = getAllByRole('heading', { level: 2 });
|
|
297
|
+
expect(headings).toHaveLength(2);
|
|
298
|
+
expect(headings[0]).toHaveTextContent('Error message');
|
|
299
|
+
expect(headings[1]).toHaveTextContent('Warning message');
|
|
300
|
+
});
|
|
301
|
+
|
|
302
|
+
it("minimizes individual alert when its minimize button is clicked", async () => {
|
|
303
|
+
const { getAllByTestId, queryByTestId, getByTestId } = render(
|
|
304
|
+
<MadieAlert
|
|
305
|
+
minimizeAlerts={true}
|
|
306
|
+
alerts={[
|
|
307
|
+
{
|
|
308
|
+
type: "error",
|
|
309
|
+
content: <h2>Error message</h2>,
|
|
310
|
+
alertProps: { "data-testid": "alert-dialog-1" }
|
|
311
|
+
},
|
|
312
|
+
{
|
|
313
|
+
type: "warning",
|
|
314
|
+
content: <h2>Warning message</h2>,
|
|
315
|
+
alertProps: { "data-testid": "alert-dialog-2" }
|
|
316
|
+
}
|
|
317
|
+
]}
|
|
318
|
+
/>
|
|
319
|
+
);
|
|
320
|
+
|
|
321
|
+
// Both alerts should be visible
|
|
322
|
+
const alerts = getAllByTestId(/alert-dialog-\d/);
|
|
323
|
+
expect(alerts).toHaveLength(2);
|
|
324
|
+
|
|
325
|
+
// Minimize the first alert
|
|
326
|
+
const minimizeButton = getByTestId("minimize-button-0");
|
|
327
|
+
fireEvent.click(minimizeButton);
|
|
328
|
+
|
|
329
|
+
// First alert should be hidden, second alert should still be visible
|
|
330
|
+
await waitFor(() => {
|
|
331
|
+
expect(queryByTestId("alert-dialog-1")).not.toBeInTheDocument();
|
|
332
|
+
expect(queryByTestId("alert-dialog-2")).toBeInTheDocument();
|
|
333
|
+
expect(getByTestId("minimized-alert")).toBeInTheDocument();
|
|
334
|
+
});
|
|
335
|
+
|
|
336
|
+
// Now minimize the second alert
|
|
337
|
+
const minimizeButton2 = getByTestId("minimize-button-1");
|
|
338
|
+
fireEvent.click(minimizeButton2);
|
|
339
|
+
|
|
340
|
+
// Now both alerts should be hidden
|
|
341
|
+
await waitFor(() => {
|
|
342
|
+
expect(queryByTestId("alert-dialog-1")).not.toBeInTheDocument();
|
|
343
|
+
expect(queryByTestId("alert-dialog-2")).not.toBeInTheDocument();
|
|
344
|
+
});
|
|
345
|
+
});
|
|
346
|
+
|
|
347
|
+
it("restores all alerts when the minimized alert is clicked", async () => {
|
|
348
|
+
const { getAllByTestId, queryAllByTestId, getByTestId } = render(
|
|
349
|
+
<MadieAlert
|
|
350
|
+
minimizeAlerts={true}
|
|
351
|
+
alerts={[
|
|
352
|
+
{
|
|
353
|
+
type: "error",
|
|
354
|
+
content: <h2>Error message</h2>,
|
|
355
|
+
alertProps: { "data-testid": "alert-dialog-1" }
|
|
356
|
+
},
|
|
357
|
+
{
|
|
358
|
+
type: "warning",
|
|
359
|
+
content: <h2>Warning message</h2>,
|
|
360
|
+
alertProps: { "data-testid": "alert-dialog-2" }
|
|
361
|
+
}
|
|
362
|
+
]}
|
|
363
|
+
/>
|
|
364
|
+
);
|
|
365
|
+
|
|
366
|
+
// Minimize alerts - update to use the index-specific button ID
|
|
367
|
+
const minimizeButton = getByTestId("minimize-button-0");
|
|
368
|
+
fireEvent.click(minimizeButton);
|
|
369
|
+
|
|
370
|
+
// Wait for minimized alert to appear
|
|
371
|
+
await waitFor(() => {
|
|
372
|
+
expect(getByTestId("minimized-alert")).toBeInTheDocument();
|
|
373
|
+
});
|
|
374
|
+
|
|
375
|
+
// Click minimized alert to restore
|
|
376
|
+
const minimizedAlert = getByTestId("minimized-alert");
|
|
377
|
+
fireEvent.click(minimizedAlert);
|
|
378
|
+
|
|
379
|
+
// Both alerts should be visible again
|
|
380
|
+
await waitFor(() => {
|
|
381
|
+
const alerts = getAllByTestId(/alert-dialog-\d/);
|
|
382
|
+
expect(alerts).toHaveLength(2);
|
|
383
|
+
expect(queryAllByTestId("minimized-alert")).toHaveLength(0);
|
|
384
|
+
});
|
|
385
|
+
});
|
|
386
|
+
|
|
387
|
+
it("aggregates error counts from multiple alerts", async () => {
|
|
388
|
+
const { getByTestId, getAllByTestId } = render(
|
|
389
|
+
<MadieAlert
|
|
390
|
+
minimizeAlerts={true}
|
|
391
|
+
alerts={[
|
|
392
|
+
{
|
|
393
|
+
type: "error",
|
|
394
|
+
content: (
|
|
395
|
+
<div>
|
|
396
|
+
<ul>
|
|
397
|
+
<li>Error 1</li>
|
|
398
|
+
<li>Error 2</li>
|
|
399
|
+
</ul>
|
|
400
|
+
</div>
|
|
401
|
+
),
|
|
402
|
+
alertProps: { "data-testid": "alert-dialog-1" }
|
|
403
|
+
},
|
|
404
|
+
{
|
|
405
|
+
type: "warning",
|
|
406
|
+
content: (
|
|
407
|
+
<div>
|
|
408
|
+
<ul>
|
|
409
|
+
<li>Warning 1</li>
|
|
410
|
+
</ul>
|
|
411
|
+
</div>
|
|
412
|
+
),
|
|
413
|
+
alertProps: { "data-testid": "alert-dialog-2" }
|
|
414
|
+
}
|
|
415
|
+
]}
|
|
416
|
+
/>
|
|
417
|
+
);
|
|
418
|
+
|
|
419
|
+
// Update to use the index-specific button ID
|
|
420
|
+
const minimizeButton = getByTestId("minimize-button-0");
|
|
421
|
+
fireEvent.click(minimizeButton);
|
|
422
|
+
|
|
423
|
+
// Since only the first alert with 2 errors is minimized,
|
|
424
|
+
// check for a count of 2 instead of 3
|
|
425
|
+
await waitFor(() => {
|
|
426
|
+
expect(getByTestId("minimized-alert-text")).toHaveTextContent("Display Alerts (2)");
|
|
427
|
+
});
|
|
428
|
+
|
|
429
|
+
// Also minimize the second alert
|
|
430
|
+
const minimizeButton2 = getByTestId("minimize-button-1");
|
|
431
|
+
fireEvent.click(minimizeButton2);
|
|
432
|
+
|
|
433
|
+
// Now both alerts are minimized, check for a count of 3
|
|
434
|
+
await waitFor(() => {
|
|
435
|
+
expect(getByTestId("minimized-alert-text")).toHaveTextContent("Display Alerts (3)");
|
|
436
|
+
});
|
|
437
|
+
});
|
|
438
|
+
|
|
439
|
+
it("copies content from all alerts with copyButton enabled", async () => {
|
|
440
|
+
const mockedWriteText = jest.fn();
|
|
441
|
+
navigator.clipboard = {
|
|
442
|
+
writeText: mockedWriteText,
|
|
443
|
+
};
|
|
444
|
+
|
|
445
|
+
const { getAllByTestId } = render(
|
|
446
|
+
<MadieAlert
|
|
447
|
+
minimizeAlerts={true}
|
|
448
|
+
alerts={[
|
|
449
|
+
{
|
|
450
|
+
type: "error",
|
|
451
|
+
content: (
|
|
452
|
+
<div>
|
|
453
|
+
<ul>
|
|
454
|
+
<li>Error 1</li>
|
|
455
|
+
<li>Error 2</li>
|
|
456
|
+
</ul>
|
|
457
|
+
</div>
|
|
458
|
+
),
|
|
459
|
+
copyButton: true,
|
|
460
|
+
alertProps: { "data-testid": "alert-dialog-1" }
|
|
461
|
+
},
|
|
462
|
+
{
|
|
463
|
+
type: "warning",
|
|
464
|
+
content: (
|
|
465
|
+
<div>
|
|
466
|
+
<ul>
|
|
467
|
+
<li>Warning 1</li>
|
|
468
|
+
</ul>
|
|
469
|
+
</div>
|
|
470
|
+
),
|
|
471
|
+
copyButton: true,
|
|
472
|
+
alertProps: { "data-testid": "alert-dialog-2" }
|
|
473
|
+
}
|
|
474
|
+
]}
|
|
475
|
+
/>
|
|
476
|
+
);
|
|
477
|
+
|
|
478
|
+
// Get the first copy button and click it
|
|
479
|
+
const copyButtons = getAllByTestId("ContentCopyIcon");
|
|
480
|
+
expect(copyButtons).toHaveLength(2);
|
|
481
|
+
fireEvent.click(copyButtons[0]);
|
|
482
|
+
|
|
483
|
+
// Check that the combined text was copied
|
|
484
|
+
await waitFor(() => {
|
|
485
|
+
expect(mockedWriteText).toHaveBeenCalledTimes(1);
|
|
486
|
+
expect(mockedWriteText).toHaveBeenCalledWith(expect.stringContaining("Error"));
|
|
487
|
+
});
|
|
488
|
+
});
|
|
489
|
+
|
|
490
|
+
it("maintains backward compatibility with original style of alert", () => {
|
|
491
|
+
const { getByTestId } = render(
|
|
492
|
+
<MadieAlert
|
|
493
|
+
type="error"
|
|
494
|
+
visible={true}
|
|
495
|
+
canClose={false}
|
|
496
|
+
content={<h1>Old Alert</h1>}
|
|
497
|
+
alertProps={{
|
|
498
|
+
"data-testid": "old-alert",
|
|
499
|
+
}}
|
|
500
|
+
/>
|
|
501
|
+
);
|
|
502
|
+
|
|
503
|
+
expect(getByTestId("old-alert")).toBeInTheDocument();
|
|
504
|
+
expect(getByTestId("old-alert")).toHaveClass("error");
|
|
505
|
+
});
|
|
506
|
+
|
|
507
|
+
it("shows error count in minimized alert when errors are present", async () => {
|
|
508
|
+
const { getByTestId } = render(
|
|
509
|
+
<MadieAlert
|
|
510
|
+
type="warning"
|
|
511
|
+
visible={true}
|
|
512
|
+
canClose={false}
|
|
513
|
+
minimizeAlerts={true}
|
|
514
|
+
content={
|
|
515
|
+
<div>
|
|
516
|
+
<ul>
|
|
517
|
+
<li>Error 1</li>
|
|
518
|
+
<li>Error 2</li>
|
|
519
|
+
<li>Error 3</li>
|
|
520
|
+
</ul>
|
|
521
|
+
</div>
|
|
522
|
+
}
|
|
523
|
+
alertProps={{
|
|
524
|
+
"data-testid": "alert-dialog",
|
|
525
|
+
}}
|
|
526
|
+
/>
|
|
527
|
+
);
|
|
528
|
+
|
|
529
|
+
// Update to use the index-specific button ID
|
|
530
|
+
const minimizeButton = getByTestId("minimize-button-0");
|
|
531
|
+
fireEvent.click(minimizeButton);
|
|
532
|
+
|
|
533
|
+
// Check for error count in minimized alert
|
|
534
|
+
await waitFor(() => {
|
|
535
|
+
expect(getByTestId("minimized-alert-text")).toHaveTextContent("Display Alerts (3)");
|
|
536
|
+
});
|
|
537
|
+
});
|
|
538
|
+
|
|
539
|
+
it("does not show error count when there are no errors", async () => {
|
|
540
|
+
const { getByTestId } = render(
|
|
541
|
+
<MadieAlert
|
|
542
|
+
type="warning"
|
|
543
|
+
visible={true}
|
|
544
|
+
canClose={false}
|
|
545
|
+
minimizeAlerts={true}
|
|
546
|
+
content={<div>Simple message with no errors</div>}
|
|
547
|
+
alertProps={{
|
|
548
|
+
"data-testid": "alert-dialog",
|
|
549
|
+
}}
|
|
550
|
+
/>
|
|
551
|
+
);
|
|
552
|
+
|
|
553
|
+
// Update to use the index-specific button ID
|
|
554
|
+
const minimizeButton = getByTestId("minimize-button-0");
|
|
555
|
+
fireEvent.click(minimizeButton);
|
|
556
|
+
|
|
557
|
+
// Check that there's no error count
|
|
558
|
+
await waitFor(() => {
|
|
559
|
+
expect(getByTestId("minimized-alert-text")).toHaveTextContent("Display Alerts");
|
|
560
|
+
expect(getByTestId("minimized-alert-text")).not.toHaveTextContent("Display Alerts (");
|
|
561
|
+
});
|
|
562
|
+
});
|
|
274
563
|
});
|
|
@@ -39,6 +39,9 @@ describe("MadieDeleteDialog", () => {
|
|
|
39
39
|
expect(
|
|
40
40
|
queryByText("Are you sure you want to delete ?")
|
|
41
41
|
).toBeVisible();
|
|
42
|
+
expect(
|
|
43
|
+
queryByText("This Action cannot be undone.")
|
|
44
|
+
).toBeVisible();
|
|
42
45
|
});
|
|
43
46
|
});
|
|
44
47
|
});
|
|
@@ -81,4 +84,28 @@ describe("MadieDeleteDialog", () => {
|
|
|
81
84
|
});
|
|
82
85
|
});
|
|
83
86
|
});
|
|
87
|
+
|
|
88
|
+
test("Dialog has not warning text", async () => {
|
|
89
|
+
await act(async () => {
|
|
90
|
+
const { getByTestId, queryByText } = await render(
|
|
91
|
+
<MadieDeleteDialog
|
|
92
|
+
open={true}
|
|
93
|
+
onClose={() => setDialogOpen(false)}
|
|
94
|
+
onContinue={() => setDialogOpen(false)}
|
|
95
|
+
hideWarning={true}
|
|
96
|
+
/>
|
|
97
|
+
);
|
|
98
|
+
|
|
99
|
+
const deleteDialog = await getByTestId("delete-dialog");
|
|
100
|
+
expect(deleteDialog).toBeInTheDocument();
|
|
101
|
+
await waitFor(() => {
|
|
102
|
+
expect(
|
|
103
|
+
queryByText("Are you sure you want to delete ?")
|
|
104
|
+
).toBeVisible();
|
|
105
|
+
expect(
|
|
106
|
+
queryByText("This Action cannot be undone.")
|
|
107
|
+
).not.toBeInTheDocument();
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
});
|
|
84
111
|
});
|