@madie/madie-design-system 1.2.62 → 2.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/.eslintrc.js +1 -1
- package/.storybook/.babelrc +2 -1
- package/.storybook/main.js +3 -11
- package/components/AutoComplete/AutoComplete.jsx +1 -1
- package/components/Button/Button.stories.js +0 -2
- package/components/DateField/DateField.jsx +1 -1
- package/components/DateField/DateField.stories.jsx +23 -10
- package/components/DateTimeField/DateTimeField.jsx +6 -2
- package/components/DateTimeField/DateTimeField.stories.jsx +29 -19
- package/components/Instant/Instant.stories.js +14 -6
- package/components/MadieAlert/MadieAlert.stories.js +35 -29
- package/components/MadieAlert/index.jsx +5 -5
- package/components/MadieConfirmDialog/MadieConfirmDialog.stories.js +17 -27
- package/components/MadieDeleteDialog/MadieDeleteDialog.stories.js +9 -18
- package/components/MadieDialog/MadieDialog.stories.js +45 -116
- package/components/MadieDialog/index.jsx +4 -2
- package/components/MadieDiscardDialog/MadieDiscardDialog.stories.js +5 -7
- package/components/MadieSpinner/MadieSpinner.stories.js +1 -3
- package/components/MadieTooltip/MadieTooltip.stories.js +7 -2
- package/components/Modal/Modal.stories.js +18 -89
- package/components/NotificationBanner/NotificationBanner.stories.js +17 -11
- package/components/NotificationBanner/index.js +3 -3
- package/components/NumberInput/NumberInput.stories.js +51 -63
- package/components/Popover/Popover.stories.js +6 -14
- package/components/Popover/index.js +2 -2
- package/components/RadioButton/RadioButton.jsx +4 -2
- package/components/RadioButton/RadioButton.stories.jsx +6 -2
- package/components/ReadOnlyTextField/ReadOnlyTextField.stories.js +4 -3
- package/components/ReadOnlyTextField/index.jsx +1 -1
- package/components/RichTextEditor/RichTextEditor.stories.js +10 -8
- package/components/RichTextEditor/index.jsx +14 -15
- package/components/Search/Search.stories.js +2 -4
- package/components/Select/Select.stories.js +59 -160
- package/components/Select/index.jsx +1 -1
- package/components/Tabs/Tabs.stories.js +78 -210
- package/components/TextArea/TextArea.stories.js +88 -108
- package/components/TextArea/index.jsx +1 -1
- package/components/TextField/TextField.stories.js +101 -124
- package/components/TextField/index.jsx +1 -1
- package/components/TimeField/TimeField.stories.js +18 -8
- package/components/Toast/Toast.stories.js +42 -102
- package/components/TruncateText/TruncateText.stories.js +22 -17
- package/components/hooks/useGetConfig.js +2 -2
- package/components/index.js +0 -24
- package/dist/browser.js +1 -1
- package/dist/index.js +1 -1
- package/dist/react/index.js +182 -51
- package/dist/react/index.js.LICENSE.txt +27 -24
- package/dist/react/index.js.map +1 -1
- package/eslint.config.js +56 -0
- package/index.js +7 -9
- package/package.json +43 -75
- package/test/components/Accordion.test.js +1 -1
- package/test/components/AutoComplete.test.js +11 -6
- package/test/components/Button.test.js +7 -3
- package/test/components/DateField.test.js +25 -29
- package/test/components/DateTimeField.test.js +21 -25
- package/test/components/Instant.test.js +1 -1
- package/test/components/MadieAlert.test.js +22 -22
- package/test/components/MadieConfirmDialog.test.js +42 -64
- package/test/components/MadieDeleteDialog.test.js +51 -69
- package/test/components/MadieDialog.test.js +13 -13
- package/test/components/MadieDiscardDialog.test.js +28 -45
- package/test/components/MadieSpinner.test.js +12 -17
- package/test/components/Modal.test.js +115 -0
- package/test/components/Pagination.test.js +2 -2
- package/test/components/RadioButton.test.js +7 -7
- package/test/components/ReadOnlyTextField.test.js +4 -2
- package/test/components/RichTextEditor.test.js +90 -6
- package/test/components/Search.test.js +75 -0
- package/test/components/Select.test.js +97 -107
- package/test/components/Tabs.test.js +22 -24
- package/test/components/TextArea.test.js +78 -92
- package/test/components/TextField.test.js +128 -147
- package/test/components/Toast.test.js +67 -78
- package/test/components/TruncateText.test.js +75 -0
- package/test/components/index.test.js +23 -0
- package/webpack.config.js +0 -1
- package/.eslintignore +0 -5
- package/components/Alert/Alert.stories.js +0 -70
- package/components/Alert/index.js +0 -55
- package/components/Breadcrumb/Breadcrumb.md +0 -28
- package/components/Breadcrumb/Breadcrumb.stories.js +0 -76
- package/components/Breadcrumb/index.js +0 -92
- package/components/CalloutBox/CalloutBox.stories.js +0 -94
- package/components/CalloutBox/index.js +0 -109
- package/components/Card/Card.stories.js +0 -163
- package/components/Card/index.js +0 -144
- package/components/Dropdown/Dropdown.stories.js +0 -94
- package/components/Dropdown/index.js +0 -85
- package/components/Error/Collapsible.jsx +0 -93
- package/components/Error/ErrorUI.jsx +0 -31
- package/components/Error/error.js +0 -26
- package/components/FlashNotification/FlashNotificationUI.jsx +0 -91
- package/components/FlashNotification/index.js +0 -30
- package/components/Footer/Footer.stories.js +0 -20
- package/components/Footer/FooterUI.jsx +0 -137
- package/components/Footer/LegacyFooterUI.jsx +0 -204
- package/components/Footer/SocialLinks.jsx +0 -63
- package/components/Footer/Subscribe.jsx +0 -34
- package/components/Footer/footer.js +0 -30
- package/components/Infotip/Infotip.jsx +0 -75
- package/components/Infotip/Infotip.stories.js +0 -52
- package/components/Infotip/InfotipIcon.jsx +0 -41
- package/components/Infotip/index.js +0 -3
- package/components/Link/Link.stories.js +0 -82
- package/components/Link/index.js +0 -61
- package/components/Spinner/index.js +0 -9
- package/components/TextInput/TextInput.stories.js +0 -118
- package/components/TextInput/index.js +0 -137
- package/components/Tooltip/Tooltip.jsx +0 -88
- package/components/Tooltip/Tooltip.stories.js +0 -80
- package/components/Tooltip/index.js +0 -3
- package/components/Tooltip/position.js +0 -76
- package/test/components/ErrorUI.test.js +0 -32
- package/test/components/FooterUI.test.js +0 -122
- package/test/components/Infotip.test.js +0 -76
- package/test/components/Tooltip.test.js +0 -147
|
@@ -19,7 +19,7 @@ describe("Madie Alert", () => {
|
|
|
19
19
|
onClick: onClose,
|
|
20
20
|
"data-testid": "close-button",
|
|
21
21
|
}}
|
|
22
|
-
|
|
22
|
+
/>,
|
|
23
23
|
);
|
|
24
24
|
expect(getByTestId("alert-dialog")).toBeInTheDocument();
|
|
25
25
|
expect(getByTestId("close-button")).toBeInTheDocument();
|
|
@@ -85,7 +85,7 @@ Row: 6, Col:0: VSAC: 0:87 | Request failed with status code 404 for oid = 1.16.8
|
|
|
85
85
|
onClick: onClose,
|
|
86
86
|
"data-testid": "close-button",
|
|
87
87
|
}}
|
|
88
|
-
|
|
88
|
+
/>,
|
|
89
89
|
);
|
|
90
90
|
expect(getByTestId("alert-dialog")).toBeInTheDocument();
|
|
91
91
|
expect(getByTestId("ContentCopyIcon")).toBeInTheDocument();
|
|
@@ -140,7 +140,7 @@ Row: 6, Col:0: VSAC: 0:87 | Request failed with status code 404 for oid = 1.16.8
|
|
|
140
140
|
onClick: onClose,
|
|
141
141
|
"data-testid": "close-button",
|
|
142
142
|
}}
|
|
143
|
-
|
|
143
|
+
/>,
|
|
144
144
|
);
|
|
145
145
|
expect(getByTestId("alert-dialog")).toBeInTheDocument();
|
|
146
146
|
expect(getByTestId("ContentCopyIcon")).toBeInTheDocument();
|
|
@@ -174,7 +174,7 @@ Row: 6, Col:0: VSAC: 0:87 | Request failed with status code 404 for oid = 1.16.8
|
|
|
174
174
|
onClick: onClose,
|
|
175
175
|
"data-testid": "close-button",
|
|
176
176
|
}}
|
|
177
|
-
|
|
177
|
+
/>,
|
|
178
178
|
);
|
|
179
179
|
expect(getByTestId("alert-dialog")).toBeInTheDocument();
|
|
180
180
|
expect(getByTestId("ContentCopyIcon")).toBeInTheDocument();
|
|
@@ -204,7 +204,7 @@ Row: 6, Col:0: VSAC: 0:87 | Request failed with status code 404 for oid = 1.16.8
|
|
|
204
204
|
closeButtonProps={{
|
|
205
205
|
"data-testid": "close-button",
|
|
206
206
|
}}
|
|
207
|
-
|
|
207
|
+
/>,
|
|
208
208
|
);
|
|
209
209
|
await waitFor(() => {
|
|
210
210
|
expect(screen.queryByTestId("alert-dialog")).toBeNull();
|
|
@@ -222,7 +222,7 @@ Row: 6, Col:0: VSAC: 0:87 | Request failed with status code 404 for oid = 1.16.8
|
|
|
222
222
|
alertProps={{
|
|
223
223
|
"data-testid": "alert-dialog",
|
|
224
224
|
}}
|
|
225
|
-
|
|
225
|
+
/>,
|
|
226
226
|
);
|
|
227
227
|
|
|
228
228
|
expect(getByTestId("alert-dialog")).toBeInTheDocument();
|
|
@@ -240,7 +240,7 @@ Row: 6, Col:0: VSAC: 0:87 | Request failed with status code 404 for oid = 1.16.8
|
|
|
240
240
|
alertProps={{
|
|
241
241
|
"data-testid": "alert-dialog",
|
|
242
242
|
}}
|
|
243
|
-
|
|
243
|
+
/>,
|
|
244
244
|
);
|
|
245
245
|
|
|
246
246
|
expect(getByTestId("alert-dialog")).toBeInTheDocument();
|
|
@@ -266,7 +266,7 @@ Row: 6, Col:0: VSAC: 0:87 | Request failed with status code 404 for oid = 1.16.8
|
|
|
266
266
|
alertProps={{
|
|
267
267
|
"data-testid": "alert-dialog",
|
|
268
268
|
}}
|
|
269
|
-
|
|
269
|
+
/>,
|
|
270
270
|
);
|
|
271
271
|
|
|
272
272
|
expect(getByTestId("alert-dialog")).toBeInTheDocument();
|
|
@@ -289,7 +289,7 @@ Row: 6, Col:0: VSAC: 0:87 | Request failed with status code 404 for oid = 1.16.8
|
|
|
289
289
|
canClose: false,
|
|
290
290
|
},
|
|
291
291
|
]}
|
|
292
|
-
|
|
292
|
+
/>,
|
|
293
293
|
);
|
|
294
294
|
|
|
295
295
|
// Should find two heading elements (one from each alert)
|
|
@@ -315,7 +315,7 @@ Row: 6, Col:0: VSAC: 0:87 | Request failed with status code 404 for oid = 1.16.8
|
|
|
315
315
|
alertProps: { "data-testid": "alert-dialog-2" },
|
|
316
316
|
},
|
|
317
317
|
]}
|
|
318
|
-
|
|
318
|
+
/>,
|
|
319
319
|
);
|
|
320
320
|
|
|
321
321
|
// Both alerts should be visible
|
|
@@ -360,7 +360,7 @@ Row: 6, Col:0: VSAC: 0:87 | Request failed with status code 404 for oid = 1.16.8
|
|
|
360
360
|
alertProps: { "data-testid": "alert-dialog-2" },
|
|
361
361
|
},
|
|
362
362
|
]}
|
|
363
|
-
|
|
363
|
+
/>,
|
|
364
364
|
);
|
|
365
365
|
|
|
366
366
|
// Minimize alerts - update to use the index-specific button ID
|
|
@@ -413,7 +413,7 @@ Row: 6, Col:0: VSAC: 0:87 | Request failed with status code 404 for oid = 1.16.8
|
|
|
413
413
|
alertProps: { "data-testid": "alert-dialog-2" },
|
|
414
414
|
},
|
|
415
415
|
]}
|
|
416
|
-
|
|
416
|
+
/>,
|
|
417
417
|
);
|
|
418
418
|
|
|
419
419
|
// Update to use the index-specific button ID
|
|
@@ -424,7 +424,7 @@ Row: 6, Col:0: VSAC: 0:87 | Request failed with status code 404 for oid = 1.16.8
|
|
|
424
424
|
// check for a count of 2 instead of 3
|
|
425
425
|
await waitFor(() => {
|
|
426
426
|
expect(getByTestId("minimized-alert-text")).toHaveTextContent(
|
|
427
|
-
"Display Alerts (2)"
|
|
427
|
+
"Display Alerts (2)",
|
|
428
428
|
);
|
|
429
429
|
});
|
|
430
430
|
|
|
@@ -435,7 +435,7 @@ Row: 6, Col:0: VSAC: 0:87 | Request failed with status code 404 for oid = 1.16.8
|
|
|
435
435
|
// Now both alerts are minimized, check for a count of 3
|
|
436
436
|
await waitFor(() => {
|
|
437
437
|
expect(getByTestId("minimized-alert-text")).toHaveTextContent(
|
|
438
|
-
"Display Alerts (3)"
|
|
438
|
+
"Display Alerts (3)",
|
|
439
439
|
);
|
|
440
440
|
});
|
|
441
441
|
});
|
|
@@ -476,7 +476,7 @@ Row: 6, Col:0: VSAC: 0:87 | Request failed with status code 404 for oid = 1.16.8
|
|
|
476
476
|
alertProps: { "data-testid": "alert-dialog-2" },
|
|
477
477
|
},
|
|
478
478
|
]}
|
|
479
|
-
|
|
479
|
+
/>,
|
|
480
480
|
);
|
|
481
481
|
|
|
482
482
|
// Get the first copy button and click it
|
|
@@ -488,7 +488,7 @@ Row: 6, Col:0: VSAC: 0:87 | Request failed with status code 404 for oid = 1.16.8
|
|
|
488
488
|
await waitFor(() => {
|
|
489
489
|
expect(mockedWriteText).toHaveBeenCalledTimes(1);
|
|
490
490
|
expect(mockedWriteText).toHaveBeenCalledWith(
|
|
491
|
-
expect.stringContaining("Error")
|
|
491
|
+
expect.stringContaining("Error"),
|
|
492
492
|
);
|
|
493
493
|
});
|
|
494
494
|
});
|
|
@@ -503,7 +503,7 @@ Row: 6, Col:0: VSAC: 0:87 | Request failed with status code 404 for oid = 1.16.8
|
|
|
503
503
|
alertProps={{
|
|
504
504
|
"data-testid": "old-alert",
|
|
505
505
|
}}
|
|
506
|
-
|
|
506
|
+
/>,
|
|
507
507
|
);
|
|
508
508
|
|
|
509
509
|
expect(getByTestId("old-alert")).toBeInTheDocument();
|
|
@@ -529,7 +529,7 @@ Row: 6, Col:0: VSAC: 0:87 | Request failed with status code 404 for oid = 1.16.8
|
|
|
529
529
|
alertProps={{
|
|
530
530
|
"data-testid": "alert-dialog",
|
|
531
531
|
}}
|
|
532
|
-
|
|
532
|
+
/>,
|
|
533
533
|
);
|
|
534
534
|
|
|
535
535
|
// Update to use the index-specific button ID
|
|
@@ -539,7 +539,7 @@ Row: 6, Col:0: VSAC: 0:87 | Request failed with status code 404 for oid = 1.16.8
|
|
|
539
539
|
// Check for error count in minimized alert
|
|
540
540
|
await waitFor(() => {
|
|
541
541
|
expect(getByTestId("minimized-alert-text")).toHaveTextContent(
|
|
542
|
-
"Display Alerts (3)"
|
|
542
|
+
"Display Alerts (3)",
|
|
543
543
|
);
|
|
544
544
|
});
|
|
545
545
|
});
|
|
@@ -555,7 +555,7 @@ Row: 6, Col:0: VSAC: 0:87 | Request failed with status code 404 for oid = 1.16.8
|
|
|
555
555
|
alertProps={{
|
|
556
556
|
"data-testid": "alert-dialog",
|
|
557
557
|
}}
|
|
558
|
-
|
|
558
|
+
/>,
|
|
559
559
|
);
|
|
560
560
|
|
|
561
561
|
// Update to use the index-specific button ID
|
|
@@ -565,10 +565,10 @@ Row: 6, Col:0: VSAC: 0:87 | Request failed with status code 404 for oid = 1.16.8
|
|
|
565
565
|
// Check that there's no error count
|
|
566
566
|
await waitFor(() => {
|
|
567
567
|
expect(getByTestId("minimized-alert-text")).toHaveTextContent(
|
|
568
|
-
"Display Alerts"
|
|
568
|
+
"Display Alerts",
|
|
569
569
|
);
|
|
570
570
|
expect(getByTestId("minimized-alert-text")).not.toHaveTextContent(
|
|
571
|
-
"Display Alerts ("
|
|
571
|
+
"Display Alerts (",
|
|
572
572
|
);
|
|
573
573
|
});
|
|
574
574
|
});
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import "@testing-library/jest-dom";
|
|
2
2
|
import { describe, expect, test } from "@jest/globals";
|
|
3
3
|
import MadieConfirmDialog from "../../components/MadieConfirmDialog/index";
|
|
4
|
-
import {
|
|
5
|
-
import { render, fireEvent, waitFor } from "@testing-library/react";
|
|
4
|
+
import { render, fireEvent, waitFor, screen } from "@testing-library/react";
|
|
6
5
|
|
|
7
6
|
import React, { useState } from "react";
|
|
8
7
|
|
|
@@ -75,85 +74,64 @@ const DialogTesterForDelete = () => {
|
|
|
75
74
|
);
|
|
76
75
|
};
|
|
77
76
|
|
|
77
|
+
const { findByTestId, getByTestId, queryByText } = screen;
|
|
78
78
|
describe("MadieConfirmDialog", () => {
|
|
79
79
|
test("Confirm Dialog renders", async () => {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
expect(confirmDialog).toBeInTheDocument();
|
|
88
|
-
await waitFor(() => {
|
|
89
|
-
expect(queryByText("log out of UMLS")).toBeVisible();
|
|
90
|
-
});
|
|
80
|
+
render(<DialogTester />);
|
|
81
|
+
const result = await findByTestId("dialog-tester");
|
|
82
|
+
fireEvent.click(result);
|
|
83
|
+
const confirmDialog = await getByTestId("confirm-dialog");
|
|
84
|
+
expect(confirmDialog).toBeInTheDocument();
|
|
85
|
+
await waitFor(() => {
|
|
86
|
+
expect(queryByText("log out of UMLS")).toBeVisible();
|
|
91
87
|
});
|
|
92
88
|
});
|
|
93
89
|
|
|
94
90
|
test("Discard Dialog renders", async () => {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
expect(
|
|
103
|
-
await waitFor(() => {
|
|
104
|
-
expect(queryByText("You have unsaved changes.")).toBeVisible();
|
|
105
|
-
expect(queryByText("Discard Changes")).toBeVisible();
|
|
106
|
-
});
|
|
91
|
+
render(<DialogTesterForDiscard />);
|
|
92
|
+
const result = await findByTestId("discard-dialog-tester");
|
|
93
|
+
fireEvent.click(result);
|
|
94
|
+
const confirmDialog = await getByTestId("discard-dialog");
|
|
95
|
+
expect(confirmDialog).toBeInTheDocument();
|
|
96
|
+
await waitFor(() => {
|
|
97
|
+
expect(queryByText("You have unsaved changes.")).toBeVisible();
|
|
98
|
+
expect(queryByText("Discard Changes")).toBeVisible();
|
|
107
99
|
});
|
|
108
100
|
});
|
|
109
101
|
|
|
110
102
|
test("Delete Dialog renders", async () => {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
expect(confirmDialog).toBeInTheDocument();
|
|
119
|
-
await waitFor(() => {
|
|
120
|
-
expect(queryByText("delete this Definition")).toBeVisible();
|
|
121
|
-
});
|
|
103
|
+
render(<DialogTesterForDelete />);
|
|
104
|
+
const result = await findByTestId("delete-dialog-tester");
|
|
105
|
+
fireEvent.click(result);
|
|
106
|
+
const confirmDialog = await getByTestId("delete-dialog");
|
|
107
|
+
expect(confirmDialog).toBeInTheDocument();
|
|
108
|
+
await waitFor(() => {
|
|
109
|
+
expect(queryByText("delete this Definition")).toBeVisible();
|
|
122
110
|
});
|
|
123
111
|
});
|
|
124
112
|
|
|
125
113
|
test("Dialog disappears onContinue", async () => {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
expect(
|
|
136
|
-
fireEvent.click(continueButton);
|
|
137
|
-
await waitFor(() => {
|
|
138
|
-
expect(queryByText("log out of UMLS")).not.toBeVisible();
|
|
139
|
-
});
|
|
114
|
+
render(<DialogTester />);
|
|
115
|
+
const result = await findByTestId("dialog-tester");
|
|
116
|
+
fireEvent.click(result);
|
|
117
|
+
const continueButton = await getByTestId(
|
|
118
|
+
"confirm-dialog-continue-button",
|
|
119
|
+
);
|
|
120
|
+
expect(continueButton).toBeInTheDocument();
|
|
121
|
+
fireEvent.click(continueButton);
|
|
122
|
+
await waitFor(() => {
|
|
123
|
+
expect(queryByText("log out of UMLS")).not.toBeVisible();
|
|
140
124
|
});
|
|
141
125
|
});
|
|
142
126
|
test("Dialog disappears onClose", async () => {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
);
|
|
152
|
-
expect(cancelButton).toBeInTheDocument();
|
|
153
|
-
fireEvent.click(cancelButton);
|
|
154
|
-
await waitFor(() => {
|
|
155
|
-
expect(queryByText("log out of UMLS")).not.toBeVisible();
|
|
156
|
-
});
|
|
127
|
+
render(<DialogTester />);
|
|
128
|
+
const result = await findByTestId("dialog-tester");
|
|
129
|
+
fireEvent.click(result);
|
|
130
|
+
const cancelButton = await getByTestId("confirm-dialog-cancel-button");
|
|
131
|
+
expect(cancelButton).toBeInTheDocument();
|
|
132
|
+
fireEvent.click(cancelButton);
|
|
133
|
+
await waitFor(() => {
|
|
134
|
+
expect(queryByText("log out of UMLS")).not.toBeVisible();
|
|
157
135
|
});
|
|
158
136
|
});
|
|
159
137
|
});
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import "@testing-library/jest-dom";
|
|
2
2
|
import { describe, expect, test } from "@jest/globals";
|
|
3
3
|
import MadieDeleteDialog from "../../components/MadieDeleteDialog/index";
|
|
4
|
-
import {
|
|
5
|
-
import { render, fireEvent, waitFor } from "@testing-library/react";
|
|
4
|
+
import { render, fireEvent, waitFor, screen } from "@testing-library/react";
|
|
6
5
|
|
|
7
6
|
import React, { useState } from "react";
|
|
8
7
|
|
|
@@ -25,87 +24,70 @@ const DialogTester = () => {
|
|
|
25
24
|
);
|
|
26
25
|
};
|
|
27
26
|
|
|
27
|
+
const { findByTestId, getByTestId, queryByText } = screen;
|
|
28
28
|
describe("MadieDeleteDialog", () => {
|
|
29
29
|
test("Dialog renders", async () => {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
queryByText("Are you sure you want to delete ?")
|
|
41
|
-
).toBeVisible();
|
|
42
|
-
expect(
|
|
43
|
-
queryByText("This Action cannot be undone.")
|
|
44
|
-
).toBeVisible();
|
|
45
|
-
});
|
|
30
|
+
render(<DialogTester />);
|
|
31
|
+
const result = await findByTestId("dialog-tester");
|
|
32
|
+
fireEvent.click(result);
|
|
33
|
+
const deleteDialog = await getByTestId("delete-dialog");
|
|
34
|
+
expect(deleteDialog).toBeInTheDocument();
|
|
35
|
+
await waitFor(() => {
|
|
36
|
+
expect(
|
|
37
|
+
queryByText("Are you sure you want to delete ?"),
|
|
38
|
+
).toBeVisible();
|
|
39
|
+
expect(queryByText("This Action cannot be undone.")).toBeVisible();
|
|
46
40
|
});
|
|
47
41
|
});
|
|
48
42
|
|
|
49
43
|
test("Dialog disappears onContinue", async () => {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
expect(
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
expect(
|
|
63
|
-
queryByText("Are you sure you want to delete ?")
|
|
64
|
-
).not.toBeVisible();
|
|
65
|
-
});
|
|
44
|
+
render(<DialogTester />);
|
|
45
|
+
const result = await findByTestId("dialog-tester");
|
|
46
|
+
fireEvent.click(result);
|
|
47
|
+
const continueButton = await getByTestId(
|
|
48
|
+
"delete-dialog-continue-button",
|
|
49
|
+
);
|
|
50
|
+
expect(continueButton).toBeInTheDocument();
|
|
51
|
+
fireEvent.click(continueButton);
|
|
52
|
+
await waitFor(() => {
|
|
53
|
+
expect(
|
|
54
|
+
queryByText("Are you sure you want to delete ?"),
|
|
55
|
+
).not.toBeVisible();
|
|
66
56
|
});
|
|
67
57
|
});
|
|
68
58
|
test("Dialog disappears onClose", async () => {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
fireEvent.click(cancelButton);
|
|
80
|
-
await waitFor(() => {
|
|
81
|
-
expect(
|
|
82
|
-
queryByText("Are you sure you want to delete ?")
|
|
83
|
-
).not.toBeVisible();
|
|
84
|
-
});
|
|
59
|
+
render(<DialogTester />);
|
|
60
|
+
const result = await findByTestId("dialog-tester");
|
|
61
|
+
fireEvent.click(result);
|
|
62
|
+
const cancelButton = await getByTestId("delete-dialog-cancel-button");
|
|
63
|
+
expect(cancelButton).toBeInTheDocument();
|
|
64
|
+
fireEvent.click(cancelButton);
|
|
65
|
+
await waitFor(() => {
|
|
66
|
+
expect(
|
|
67
|
+
queryByText("Are you sure you want to delete ?"),
|
|
68
|
+
).not.toBeVisible();
|
|
85
69
|
});
|
|
86
70
|
});
|
|
87
71
|
|
|
88
72
|
test("Dialog has not warning text", async () => {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
);
|
|
73
|
+
render(
|
|
74
|
+
<MadieDeleteDialog
|
|
75
|
+
open={true}
|
|
76
|
+
onClose={() => setDialogOpen(false)}
|
|
77
|
+
onContinue={() => setDialogOpen(false)}
|
|
78
|
+
hideWarning={true}
|
|
79
|
+
/>,
|
|
80
|
+
);
|
|
98
81
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
});
|
|
82
|
+
const deleteDialog = await getByTestId("delete-dialog");
|
|
83
|
+
expect(deleteDialog).toBeInTheDocument();
|
|
84
|
+
await waitFor(() => {
|
|
85
|
+
expect(
|
|
86
|
+
queryByText("Are you sure you want to delete ?"),
|
|
87
|
+
).toBeVisible();
|
|
88
|
+
expect(
|
|
89
|
+
queryByText("This Action cannot be undone."),
|
|
90
|
+
).not.toBeInTheDocument();
|
|
109
91
|
});
|
|
110
92
|
});
|
|
111
93
|
});
|
|
@@ -37,7 +37,7 @@ describe("Madie Dialog", () => {
|
|
|
37
37
|
>
|
|
38
38
|
<div>this is a form message</div>
|
|
39
39
|
</MadieDialog>
|
|
40
|
-
</div
|
|
40
|
+
</div>,
|
|
41
41
|
);
|
|
42
42
|
expect(getByTestId("dialog-form")).toBeInTheDocument();
|
|
43
43
|
expect(queryByText("Indicates required field")).toBeInTheDocument();
|
|
@@ -84,7 +84,7 @@ describe("Madie Dialog", () => {
|
|
|
84
84
|
>
|
|
85
85
|
<div>this is a dialog message</div>
|
|
86
86
|
</MadieDialog>
|
|
87
|
-
</div
|
|
87
|
+
</div>,
|
|
88
88
|
);
|
|
89
89
|
const cancelButton = getByTestId("dialog-cancel-button");
|
|
90
90
|
const submitButton = getByTestId("dialog-continue-button");
|
|
@@ -117,7 +117,7 @@ describe("Madie Dialog", () => {
|
|
|
117
117
|
>
|
|
118
118
|
<div>this is a basic dialog</div>
|
|
119
119
|
</MadieDialog>
|
|
120
|
-
</div
|
|
120
|
+
</div>,
|
|
121
121
|
);
|
|
122
122
|
// only one button should be there i.e. cancel model icon at top right corner
|
|
123
123
|
expect(queryAllByRole("button")).toHaveLength(1);
|
|
@@ -138,7 +138,7 @@ describe("Madie Dialog", () => {
|
|
|
138
138
|
>
|
|
139
139
|
<div>this is a form dialog</div>
|
|
140
140
|
</MadieDialog>
|
|
141
|
-
</div
|
|
141
|
+
</div>,
|
|
142
142
|
);
|
|
143
143
|
// only one button should be there i.e. cancel model icon at top right corner
|
|
144
144
|
expect(queryAllByRole("button")).toHaveLength(1);
|
|
@@ -167,7 +167,7 @@ describe("Madie Dialog", () => {
|
|
|
167
167
|
>
|
|
168
168
|
<div>this is a form message</div>
|
|
169
169
|
</MadieDialog>
|
|
170
|
-
</div
|
|
170
|
+
</div>,
|
|
171
171
|
);
|
|
172
172
|
expect(getByTestId("dialog-form")).toBeInTheDocument();
|
|
173
173
|
expect(queryByText("Indicates required field")).toBeInTheDocument();
|
|
@@ -206,7 +206,7 @@ describe("Madie Dialog", () => {
|
|
|
206
206
|
>
|
|
207
207
|
<div>this is a form message</div>
|
|
208
208
|
</MadieDialog>
|
|
209
|
-
</div
|
|
209
|
+
</div>,
|
|
210
210
|
);
|
|
211
211
|
expect(getByTestId("dialog-form")).toBeInTheDocument();
|
|
212
212
|
expect(queryByText("Indicates required field")).toBeInTheDocument();
|
|
@@ -218,7 +218,7 @@ describe("Madie Dialog", () => {
|
|
|
218
218
|
fireEvent.mouseOver(submitButton);
|
|
219
219
|
await waitFor(() => {
|
|
220
220
|
expect(
|
|
221
|
-
queryByText("Continue button is disabled")
|
|
221
|
+
queryByText("Continue button is disabled"),
|
|
222
222
|
).toBeInTheDocument();
|
|
223
223
|
});
|
|
224
224
|
});
|
|
@@ -252,7 +252,7 @@ describe("Madie Dialog", () => {
|
|
|
252
252
|
>
|
|
253
253
|
<div>this is a form message</div>
|
|
254
254
|
</MadieDialog>
|
|
255
|
-
</div
|
|
255
|
+
</div>,
|
|
256
256
|
);
|
|
257
257
|
expect(getByTestId("dialog-form")).toBeInTheDocument();
|
|
258
258
|
expect(queryByText("Indicates required field")).toBeInTheDocument();
|
|
@@ -264,7 +264,7 @@ describe("Madie Dialog", () => {
|
|
|
264
264
|
fireEvent.mouseOver(submitButton);
|
|
265
265
|
await waitFor(() => {
|
|
266
266
|
expect(
|
|
267
|
-
queryByText("Continue button is disabled")
|
|
267
|
+
queryByText("Continue button is disabled"),
|
|
268
268
|
).not.toBeInTheDocument();
|
|
269
269
|
});
|
|
270
270
|
});
|
|
@@ -296,7 +296,7 @@ describe("Madie Dialog", () => {
|
|
|
296
296
|
>
|
|
297
297
|
<div>this is a form message</div>
|
|
298
298
|
</MadieDialog>
|
|
299
|
-
</div
|
|
299
|
+
</div>,
|
|
300
300
|
);
|
|
301
301
|
expect(getByTestId("dialog-form")).toBeInTheDocument();
|
|
302
302
|
expect(queryByText("Indicates required field")).toBeInTheDocument();
|
|
@@ -308,7 +308,7 @@ describe("Madie Dialog", () => {
|
|
|
308
308
|
fireEvent.mouseOver(submitButton);
|
|
309
309
|
await waitFor(() => {
|
|
310
310
|
expect(
|
|
311
|
-
queryByText("Continue button is disabled")
|
|
311
|
+
queryByText("Continue button is disabled"),
|
|
312
312
|
).not.toBeInTheDocument();
|
|
313
313
|
});
|
|
314
314
|
});
|
|
@@ -354,7 +354,7 @@ describe("Madie Dialog", () => {
|
|
|
354
354
|
dataTestId: "export-publishing-option",
|
|
355
355
|
toImplementFunction: () =>
|
|
356
356
|
console.log(
|
|
357
|
-
"Export for Publishing clicked"
|
|
357
|
+
"Export for Publishing clicked",
|
|
358
358
|
),
|
|
359
359
|
},
|
|
360
360
|
],
|
|
@@ -362,7 +362,7 @@ describe("Madie Dialog", () => {
|
|
|
362
362
|
>
|
|
363
363
|
<div>this is a form message</div>
|
|
364
364
|
</MadieDialog>
|
|
365
|
-
</div
|
|
365
|
+
</div>,
|
|
366
366
|
);
|
|
367
367
|
|
|
368
368
|
const cancelButton = getByTestId("cancel-button");
|