@madie/madie-design-system 1.2.62 → 1.2.64
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/AutoComplete/AutoComplete.jsx +4 -2
- package/components/AutoComplete/AutoComplete.stories.js +12 -0
- package/components/DateField/DateField.jsx +5 -3
- package/components/DateField/DateField.stories.jsx +16 -0
- package/components/DateTimeField/DateTimeField.jsx +10 -4
- package/components/DateTimeField/DateTimeField.stories.jsx +28 -0
- package/components/NumberInput/index.jsx +3 -0
- package/components/RadioButton/RadioButton.jsx +7 -3
- package/components/RadioButton/RadioButton.stories.jsx +21 -2
- package/components/ReadOnlyTextField/index.jsx +9 -3
- package/components/RichTextEditor/RichTextEditor.stories.js +21 -3
- package/components/RichTextEditor/index.jsx +31 -18
- package/components/Select/Select.stories.js +53 -0
- package/components/Select/index.jsx +4 -2
- package/components/TextArea/TextArea.stories.js +16 -0
- package/components/TextArea/index.jsx +5 -2
- package/components/TextField/TextField.stories.js +14 -0
- package/components/TextField/index.jsx +4 -2
- package/dist/browser.js +1 -1
- package/dist/index.js +1 -1
- package/dist/react/index.js +5 -5
- package/dist/react/index.js.map +1 -1
- package/package.json +1 -1
- package/styles/components/_rich-text-editor.scss +43 -10
- package/styles/qppds/components/_rich-text-editor.scss +39 -5
- package/test/components/AutoComplete.test.js +25 -4
- package/test/components/DateField.test.js +26 -8
- package/test/components/DateTimeField.test.js +28 -7
- package/test/components/RadioButton.test.js +7 -5
- package/test/components/ReadOnlyTextField.test.js +4 -2
- package/test/components/RichTextEditor.test.js +34 -5
- package/test/components/Select.test.js +24 -4
- package/test/components/TextArea.test.js +27 -11
- package/test/components/TextField.test.js +21 -3
package/package.json
CHANGED
|
@@ -188,14 +188,47 @@
|
|
|
188
188
|
}
|
|
189
189
|
}
|
|
190
190
|
}
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
border:
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
191
|
+
/* Table-specific styling */
|
|
192
|
+
table {
|
|
193
|
+
border-collapse: collapse;
|
|
194
|
+
margin: 0;
|
|
195
|
+
overflow: hidden;
|
|
196
|
+
table-layout: fixed;
|
|
197
|
+
width: 100%;
|
|
198
|
+
|
|
199
|
+
td,
|
|
200
|
+
th {
|
|
201
|
+
border: 1px solid #9c9c9c;
|
|
202
|
+
box-sizing: border-box;
|
|
203
|
+
min-width: 1em;
|
|
204
|
+
padding: 6px 8px;
|
|
205
|
+
position: relative;
|
|
206
|
+
vertical-align: top;
|
|
207
|
+
|
|
208
|
+
> * {
|
|
209
|
+
margin-bottom: 0;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
th {
|
|
214
|
+
background-color: #3d25140d;
|
|
215
|
+
font-weight: bold;
|
|
216
|
+
text-align: left;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
.column-resize-handle {
|
|
220
|
+
background-color: #209fa6;
|
|
221
|
+
bottom: -2px;
|
|
222
|
+
pointer-events: none;
|
|
223
|
+
position: absolute;
|
|
224
|
+
right: -2px;
|
|
225
|
+
top: 0;
|
|
226
|
+
width: 4px;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
.tableWrapper {
|
|
231
|
+
margin: 1.5rem 0;
|
|
232
|
+
overflow-x: auto;
|
|
233
|
+
}
|
|
201
234
|
}
|
|
@@ -189,13 +189,47 @@
|
|
|
189
189
|
}
|
|
190
190
|
}
|
|
191
191
|
|
|
192
|
+
/* Table-specific styling */
|
|
192
193
|
table {
|
|
193
|
-
border:
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
194
|
+
border-collapse: collapse;
|
|
195
|
+
margin: 0;
|
|
196
|
+
overflow: hidden;
|
|
197
|
+
table-layout: fixed;
|
|
198
|
+
width: 100%;
|
|
199
|
+
|
|
200
|
+
td,
|
|
201
|
+
th {
|
|
202
|
+
border: 1px solid #9c9c9c;
|
|
203
|
+
box-sizing: border-box;
|
|
204
|
+
min-width: 1em;
|
|
205
|
+
padding: 6px 8px;
|
|
206
|
+
position: relative;
|
|
207
|
+
vertical-align: top;
|
|
208
|
+
|
|
209
|
+
> * {
|
|
210
|
+
margin-bottom: 0;
|
|
198
211
|
}
|
|
199
212
|
}
|
|
213
|
+
|
|
214
|
+
th {
|
|
215
|
+
background-color: #3d25140d;
|
|
216
|
+
font-weight: bold;
|
|
217
|
+
text-align: left;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
.column-resize-handle {
|
|
221
|
+
background-color: #209fa6;
|
|
222
|
+
bottom: -2px;
|
|
223
|
+
pointer-events: none;
|
|
224
|
+
position: absolute;
|
|
225
|
+
right: -2px;
|
|
226
|
+
top: 0;
|
|
227
|
+
width: 4px;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
.tableWrapper {
|
|
232
|
+
margin: 1.5rem 0;
|
|
233
|
+
overflow-x: auto;
|
|
200
234
|
}
|
|
201
235
|
}
|
|
@@ -2,7 +2,7 @@ import * as React from "react";
|
|
|
2
2
|
import "@testing-library/jest-dom";
|
|
3
3
|
import { describe, expect } from "@jest/globals";
|
|
4
4
|
import AutoComplete from "../../components/AutoComplete/AutoComplete";
|
|
5
|
-
import {render, screen } from "@testing-library/react";
|
|
5
|
+
import { render, screen } from "@testing-library/react";
|
|
6
6
|
import userEvent from "@testing-library/user-event";
|
|
7
7
|
|
|
8
8
|
describe("AutoComplete Component", () => {
|
|
@@ -29,7 +29,12 @@ describe("AutoComplete Component", () => {
|
|
|
29
29
|
expect(option).toBeInTheDocument();
|
|
30
30
|
|
|
31
31
|
await userEvent.click(option);
|
|
32
|
-
expect(mockOnChange).toHaveBeenCalledWith(
|
|
32
|
+
expect(mockOnChange).toHaveBeenCalledWith(
|
|
33
|
+
"autocomplete",
|
|
34
|
+
"Option1",
|
|
35
|
+
expect.any(String),
|
|
36
|
+
expect.any(Object)
|
|
37
|
+
);
|
|
33
38
|
});
|
|
34
39
|
|
|
35
40
|
it("renders AutoComplete in disabled mode", async () => {
|
|
@@ -43,9 +48,25 @@ describe("AutoComplete Component", () => {
|
|
|
43
48
|
/>
|
|
44
49
|
);
|
|
45
50
|
|
|
51
|
+
const disabledInput = screen.getByRole("combobox");
|
|
52
|
+
expect(disabledInput).toHaveValue("Option1");
|
|
53
|
+
expect(disabledInput).toBeDisabled();
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it("renders AutoComplete in read only mode", async () => {
|
|
57
|
+
render(
|
|
58
|
+
<AutoComplete
|
|
59
|
+
id="autocomplete-disabled"
|
|
60
|
+
dataTestId="autocomplete-disabled"
|
|
61
|
+
label="Auto Complete"
|
|
62
|
+
readOnly
|
|
63
|
+
value="Option1"
|
|
64
|
+
/>
|
|
65
|
+
);
|
|
66
|
+
|
|
46
67
|
const readOnlyField = screen.getByRole("textbox");
|
|
47
|
-
expect(readOnlyField).
|
|
48
|
-
expect(readOnlyField).
|
|
68
|
+
expect(readOnlyField).toHaveValue("Option1");
|
|
69
|
+
expect(readOnlyField).toHaveProperty("readOnly", true);
|
|
49
70
|
});
|
|
50
71
|
|
|
51
72
|
it("renders AutoComplete with helper text", () => {
|
|
@@ -44,7 +44,7 @@ describe("DateField", () => {
|
|
|
44
44
|
});
|
|
45
45
|
});
|
|
46
46
|
|
|
47
|
-
it("renders
|
|
47
|
+
it("renders disabled DateField when disabled is true", () => {
|
|
48
48
|
const mockProps = {
|
|
49
49
|
id: "test_id",
|
|
50
50
|
label: "Test Label",
|
|
@@ -54,20 +54,38 @@ describe("DateField", () => {
|
|
|
54
54
|
|
|
55
55
|
render(<DateField {...mockProps} />);
|
|
56
56
|
|
|
57
|
-
const
|
|
58
|
-
expect(
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
expect(
|
|
57
|
+
const label = screen.getByText("Test Label");
|
|
58
|
+
expect(label).toBeInTheDocument();
|
|
59
|
+
|
|
60
|
+
const disabledField = screen.getByRole("textbox");
|
|
61
|
+
expect(disabledField).toHaveValue("10/01/2023");
|
|
62
|
+
expect(disabledField).toBeDisabled();
|
|
62
63
|
});
|
|
63
64
|
|
|
64
|
-
it("renders
|
|
65
|
+
it("renders ReadOnlyTextField when readOnly is true", () => {
|
|
66
|
+
const mockProps = {
|
|
67
|
+
id: "test_id",
|
|
68
|
+
label: "Test Label",
|
|
69
|
+
value: dayjs.utc("2023-10-01"),
|
|
70
|
+
readOnly: true,
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
render(<DateField {...mockProps} />);
|
|
74
|
+
|
|
75
|
+
const label = screen.getByText("Test Label");
|
|
76
|
+
expect(label).toBeInTheDocument();
|
|
77
|
+
const readOnlyField = screen.getByRole("textbox");
|
|
78
|
+
expect(readOnlyField).toHaveTextContent("10/01/2023");
|
|
79
|
+
expect(readOnlyField).toHaveProperty("readOnly", true);
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it("renders placeholder '-' when value is null and readOnly is true", () => {
|
|
65
83
|
const mockProps = {
|
|
66
84
|
id: "test_id",
|
|
67
85
|
label: "Test Label",
|
|
68
86
|
value: null,
|
|
69
87
|
required: false,
|
|
70
|
-
|
|
88
|
+
readOnly: true,
|
|
71
89
|
};
|
|
72
90
|
|
|
73
91
|
const { getByLabelText } = render(<DateField {...mockProps} />);
|
|
@@ -32,7 +32,7 @@ describe("DateTimeField", () => {
|
|
|
32
32
|
});
|
|
33
33
|
});
|
|
34
34
|
|
|
35
|
-
it("renders
|
|
35
|
+
it("renders disabled DateTimeField when disabled is true", () => {
|
|
36
36
|
const label = "Test Label";
|
|
37
37
|
const dateTimeValue = new Date("2023-01-01T12:00:00Z");
|
|
38
38
|
const id = "test-id";
|
|
@@ -47,13 +47,13 @@ describe("DateTimeField", () => {
|
|
|
47
47
|
/>
|
|
48
48
|
);
|
|
49
49
|
|
|
50
|
-
const
|
|
51
|
-
expect(
|
|
52
|
-
expect(
|
|
53
|
-
expect(
|
|
50
|
+
const disabledField = getByLabelText(label);
|
|
51
|
+
expect(disabledField).toBeInTheDocument();
|
|
52
|
+
expect(disabledField).toHaveValue("01/01/2023 12:00 PM");
|
|
53
|
+
expect(disabledField).toBeDisabled();
|
|
54
54
|
});
|
|
55
55
|
|
|
56
|
-
it("renders empty value in
|
|
56
|
+
it("renders empty value in disabled DateTimeField when dateTimeValue is null", () => {
|
|
57
57
|
const label = "Test Label";
|
|
58
58
|
const id = "test-id";
|
|
59
59
|
|
|
@@ -67,8 +67,29 @@ describe("DateTimeField", () => {
|
|
|
67
67
|
/>
|
|
68
68
|
);
|
|
69
69
|
|
|
70
|
+
const disabledField = getByLabelText(label);
|
|
71
|
+
expect(disabledField).toBeInTheDocument();
|
|
72
|
+
expect(disabledField).toHaveValue("");
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it("renders ReadOnlyTextField when readOnly is true", () => {
|
|
76
|
+
const label = "Test Label";
|
|
77
|
+
const dateTimeValue = new Date("2023-01-01T12:00:00Z");
|
|
78
|
+
const id = "test-id";
|
|
79
|
+
|
|
80
|
+
const { getByLabelText } = render(
|
|
81
|
+
<DateTimeField
|
|
82
|
+
label={label}
|
|
83
|
+
dateTimeValue={dateTimeValue}
|
|
84
|
+
handleDateTimeChange={() => {}}
|
|
85
|
+
readOnly={true}
|
|
86
|
+
id={id}
|
|
87
|
+
/>
|
|
88
|
+
);
|
|
89
|
+
|
|
70
90
|
const readOnlyField = getByLabelText(label);
|
|
71
91
|
expect(readOnlyField).toBeInTheDocument();
|
|
72
|
-
expect(readOnlyField).
|
|
92
|
+
expect(readOnlyField).toHaveValue("01/01/2023 12:00 PM");
|
|
93
|
+
expect(readOnlyField).toHaveProperty("readOnly", true);
|
|
73
94
|
});
|
|
74
95
|
});
|
|
@@ -50,9 +50,10 @@ describe("RadioButton Component", () => {
|
|
|
50
50
|
/>
|
|
51
51
|
);
|
|
52
52
|
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
|
|
53
|
+
const radios = screen.getAllByRole("radio");
|
|
54
|
+
radios.forEach((radio) => {
|
|
55
|
+
expect(radio).toBeDisabled();
|
|
56
|
+
});
|
|
56
57
|
});
|
|
57
58
|
|
|
58
59
|
it("renders helper text", () => {
|
|
@@ -85,7 +86,7 @@ describe("RadioButton Component", () => {
|
|
|
85
86
|
expect(errorText).toHaveStyle("color: #d32f2f");
|
|
86
87
|
});
|
|
87
88
|
|
|
88
|
-
it("renders placeholder '-' when
|
|
89
|
+
it("renders placeholder '-' when read only and no value is provided", () => {
|
|
89
90
|
const options = [
|
|
90
91
|
{ value: "option1", label: "Option 1" },
|
|
91
92
|
{ value: "option2", label: "Option 2" },
|
|
@@ -97,11 +98,12 @@ describe("RadioButton Component", () => {
|
|
|
97
98
|
dataTestId="radio-button-placeholder"
|
|
98
99
|
label="Radio Button"
|
|
99
100
|
options={options}
|
|
100
|
-
|
|
101
|
+
readOnly
|
|
101
102
|
/>
|
|
102
103
|
);
|
|
103
104
|
|
|
104
105
|
const readOnlyField = screen.getByRole("textbox");
|
|
105
106
|
expect(readOnlyField).toHaveTextContent("-");
|
|
107
|
+
expect(readOnlyField).toHaveProperty("readOnly", true);
|
|
106
108
|
});
|
|
107
109
|
});
|
|
@@ -16,9 +16,11 @@ describe("ReadOnlyTextField", () => {
|
|
|
16
16
|
size="small"
|
|
17
17
|
/>
|
|
18
18
|
);
|
|
19
|
-
const textNode = getByRole(document.body, "textbox", {
|
|
19
|
+
const textNode = getByRole(document.body, "textbox", {
|
|
20
|
+
name: "test Name",
|
|
21
|
+
});
|
|
20
22
|
expect(textNode).toBeInTheDocument();
|
|
21
|
-
expect(textNode).
|
|
23
|
+
expect(textNode).toHaveProperty("readOnly", true);
|
|
22
24
|
expect(textNode).toHaveTextContent("-");
|
|
23
25
|
});
|
|
24
26
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {render, screen, fireEvent, waitFor} from "@testing-library/react";
|
|
2
|
+
import { render, screen, fireEvent, waitFor } from "@testing-library/react";
|
|
3
3
|
import RichTextEditor from "../../components/RichTextEditor/index";
|
|
4
4
|
|
|
5
5
|
describe("RichTextEditor Component", () => {
|
|
@@ -20,7 +20,9 @@ describe("RichTextEditor Component", () => {
|
|
|
20
20
|
expect(screen.getByText("Test Label")).toBeInTheDocument();
|
|
21
21
|
|
|
22
22
|
// Check if the editor content is rendered
|
|
23
|
-
expect(
|
|
23
|
+
expect(
|
|
24
|
+
screen.getByTestId("test-label-rich-text-editor")
|
|
25
|
+
).toBeInTheDocument();
|
|
24
26
|
});
|
|
25
27
|
|
|
26
28
|
it("calls onChange when content is updated", async () => {
|
|
@@ -36,7 +38,9 @@ describe("RichTextEditor Component", () => {
|
|
|
36
38
|
|
|
37
39
|
// Simulate content change
|
|
38
40
|
const editorContent = screen.getByRole("textbox");
|
|
39
|
-
fireEvent.input(editorContent, {
|
|
41
|
+
fireEvent.input(editorContent, {
|
|
42
|
+
target: { innerHTML: "Updated Content" },
|
|
43
|
+
});
|
|
40
44
|
|
|
41
45
|
// Check if onChange is called
|
|
42
46
|
await waitFor(() => {
|
|
@@ -44,19 +48,44 @@ describe("RichTextEditor Component", () => {
|
|
|
44
48
|
});
|
|
45
49
|
});
|
|
46
50
|
|
|
47
|
-
it("renders sanitized content when
|
|
51
|
+
it("renders sanitized content within editor when disabled is true", () => {
|
|
52
|
+
render(
|
|
53
|
+
<RichTextEditor
|
|
54
|
+
id="test-editor"
|
|
55
|
+
label="Test Label"
|
|
56
|
+
content="<script>alert('XSS')</script><p>Safe Content</p>"
|
|
57
|
+
onChange={mockOnChange}
|
|
58
|
+
disabled
|
|
59
|
+
/>
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
// Check if sanitized content is rendered
|
|
63
|
+
expect(screen.getByText("Safe Content")).toBeInTheDocument();
|
|
64
|
+
expect(screen.queryByText("alert('XSS')")).not.toBeInTheDocument();
|
|
65
|
+
|
|
66
|
+
const editorContent = screen.getByRole("textbox");
|
|
67
|
+
expect(editorContent).toBeInTheDocument();
|
|
68
|
+
expect(editorContent).toHaveAttribute("contenteditable", "false");
|
|
69
|
+
expect(editorContent).toHaveTextContent("Safe Content");
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
it("renders read only, sanitized content when readOnly is true", () => {
|
|
48
73
|
render(
|
|
49
74
|
<RichTextEditor
|
|
50
75
|
id="test-editor"
|
|
51
76
|
label="Test Label"
|
|
52
77
|
content="<script>alert('XSS')</script><p>Safe Content</p>"
|
|
53
78
|
onChange={mockOnChange}
|
|
54
|
-
|
|
79
|
+
readOnly
|
|
55
80
|
/>
|
|
56
81
|
);
|
|
57
82
|
|
|
58
83
|
// Check if sanitized content is rendered
|
|
59
84
|
expect(screen.getByText("Safe Content")).toBeInTheDocument();
|
|
60
85
|
expect(screen.queryByText("alert('XSS')")).not.toBeInTheDocument();
|
|
86
|
+
|
|
87
|
+
const editorContent = screen.getByTestId("test-editor-value");
|
|
88
|
+
expect(editorContent).toBeInTheDocument();
|
|
89
|
+
expect(editorContent).toHaveTextContent("Safe Content");
|
|
61
90
|
});
|
|
62
91
|
});
|
|
@@ -117,17 +117,37 @@ describe("Select", () => {
|
|
|
117
117
|
disabled
|
|
118
118
|
helperText="helper text"
|
|
119
119
|
label="Test"
|
|
120
|
-
value=""
|
|
120
|
+
value="select value"
|
|
121
121
|
id="test-select"
|
|
122
122
|
inputProps={{ "data-testid": "test-input" }}
|
|
123
123
|
data-testid="test-select"
|
|
124
124
|
size="small"
|
|
125
125
|
/>
|
|
126
126
|
);
|
|
127
|
-
const
|
|
128
|
-
expect(
|
|
129
|
-
expect(
|
|
127
|
+
const select = screen.getByTestId("test-input");
|
|
128
|
+
expect(select).toBeDisabled();
|
|
129
|
+
expect(select).toHaveValue("select value");
|
|
130
130
|
});
|
|
131
|
+
|
|
132
|
+
test("Select renders read only", () => {
|
|
133
|
+
render(
|
|
134
|
+
<Select
|
|
135
|
+
readOnly
|
|
136
|
+
helperText="helper text"
|
|
137
|
+
label="Test"
|
|
138
|
+
value="select value"
|
|
139
|
+
id="test-select"
|
|
140
|
+
inputProps={{ "data-testid": "test-input" }}
|
|
141
|
+
data-testid="test-select"
|
|
142
|
+
size="small"
|
|
143
|
+
/>
|
|
144
|
+
);
|
|
145
|
+
|
|
146
|
+
const readOnlyField = screen.getByRole("textbox");
|
|
147
|
+
expect(readOnlyField).toHaveTextContent("select value");
|
|
148
|
+
expect(readOnlyField).toHaveProperty("readOnly", true);
|
|
149
|
+
});
|
|
150
|
+
|
|
131
151
|
test("Select renders error", async () => {
|
|
132
152
|
await act(async () => {
|
|
133
153
|
const { findByText } = render(
|
|
@@ -6,11 +6,10 @@ import { act, Simulate } from "react-dom/test-utils";
|
|
|
6
6
|
import { render, screen } from "@testing-library/react";
|
|
7
7
|
import userEvent from "@testing-library/user-event";
|
|
8
8
|
|
|
9
|
-
|
|
10
9
|
describe("TextArea", () => {
|
|
11
10
|
test("TextArea exists, and simulates input correctly", async () => {
|
|
12
11
|
await act(async () => {
|
|
13
|
-
const {findByTestId, getByTestId} = render(
|
|
12
|
+
const { findByTestId, getByTestId } = render(
|
|
14
13
|
<TextArea
|
|
15
14
|
placeholder="test Name"
|
|
16
15
|
required
|
|
@@ -32,14 +31,14 @@ describe("TextArea", () => {
|
|
|
32
31
|
});
|
|
33
32
|
test("TextArea renders with helper text", async () => {
|
|
34
33
|
await act(async () => {
|
|
35
|
-
const {findByText} = render(
|
|
34
|
+
const { findByText } = render(
|
|
36
35
|
<TextArea
|
|
37
36
|
error={false}
|
|
38
37
|
placeholder="test Name"
|
|
39
38
|
helperText="helper text"
|
|
40
39
|
label="test Name"
|
|
41
40
|
id="testName"
|
|
42
|
-
inputProps={{"data-testid": "test-name-input"}}
|
|
41
|
+
inputProps={{ "data-testid": "test-name-input" }}
|
|
43
42
|
data-testid="test-name-text-field"
|
|
44
43
|
/>
|
|
45
44
|
);
|
|
@@ -47,6 +46,23 @@ describe("TextArea", () => {
|
|
|
47
46
|
expect(helperText).toBeInTheDocument();
|
|
48
47
|
});
|
|
49
48
|
});
|
|
49
|
+
test("renders TextArea for readOnly mode", async () => {
|
|
50
|
+
render(
|
|
51
|
+
<TextArea
|
|
52
|
+
readOnly
|
|
53
|
+
placeholder="test Name"
|
|
54
|
+
helperText="helper text"
|
|
55
|
+
label="test Name"
|
|
56
|
+
id="testName"
|
|
57
|
+
inputProps={{ "data-testid": "test-name-input" }}
|
|
58
|
+
data-testid="test-name-text-field"
|
|
59
|
+
value="test value"
|
|
60
|
+
/>
|
|
61
|
+
);
|
|
62
|
+
const textArea = await screen.findByRole("textbox");
|
|
63
|
+
expect(textArea).toHaveTextContent("test value");
|
|
64
|
+
expect(textArea).toHaveProperty("readOnly", true);
|
|
65
|
+
});
|
|
50
66
|
test("renders TextArea for disabled mode", async () => {
|
|
51
67
|
render(
|
|
52
68
|
<TextArea
|
|
@@ -55,25 +71,25 @@ describe("TextArea", () => {
|
|
|
55
71
|
helperText="helper text"
|
|
56
72
|
label="test Name"
|
|
57
73
|
id="testName"
|
|
58
|
-
inputProps={{"data-testid": "test-name-input"}}
|
|
74
|
+
inputProps={{ "data-testid": "test-name-input" }}
|
|
59
75
|
data-testid="test-name-text-field"
|
|
60
76
|
value="test value"
|
|
61
77
|
/>
|
|
62
78
|
);
|
|
63
79
|
const textArea = await screen.findByRole("textbox");
|
|
64
80
|
expect(textArea).toHaveTextContent("test value");
|
|
65
|
-
expect(textArea).
|
|
81
|
+
expect(textArea).toBeDisabled();
|
|
66
82
|
});
|
|
67
83
|
test("HelperText renders errored", async () => {
|
|
68
84
|
await act(async () => {
|
|
69
|
-
const {findByText} = render(
|
|
85
|
+
const { findByText } = render(
|
|
70
86
|
<TextArea
|
|
71
87
|
error
|
|
72
88
|
placeholder="test Name"
|
|
73
89
|
helperText="helper text"
|
|
74
90
|
label="test Name"
|
|
75
91
|
id="testName"
|
|
76
|
-
inputProps={{"data-testid": "test-name-input"}}
|
|
92
|
+
inputProps={{ "data-testid": "test-name-input" }}
|
|
77
93
|
data-testid="test-name-text-field"
|
|
78
94
|
/>
|
|
79
95
|
);
|
|
@@ -83,7 +99,7 @@ describe("TextArea", () => {
|
|
|
83
99
|
});
|
|
84
100
|
test("TextArea renders with default propTypes left out", async () => {
|
|
85
101
|
await act(async () => {
|
|
86
|
-
const {findByText} = render(
|
|
102
|
+
const { findByText } = render(
|
|
87
103
|
<TextArea
|
|
88
104
|
// error purposely omitted
|
|
89
105
|
// disabled purposely omitted
|
|
@@ -91,7 +107,7 @@ describe("TextArea", () => {
|
|
|
91
107
|
helperText="helper text"
|
|
92
108
|
label="test Name"
|
|
93
109
|
id="testName"
|
|
94
|
-
inputProps={{"data-testid": "test-name-input"}}
|
|
110
|
+
inputProps={{ "data-testid": "test-name-input" }}
|
|
95
111
|
data-testid="test-name-text-field"
|
|
96
112
|
/>
|
|
97
113
|
);
|
|
@@ -101,7 +117,7 @@ describe("TextArea", () => {
|
|
|
101
117
|
});
|
|
102
118
|
test("TextArea shows maxLength", async () => {
|
|
103
119
|
await act(async () => {
|
|
104
|
-
const {findByTestId, getByTestId, findByText} = render(
|
|
120
|
+
const { findByTestId, getByTestId, findByText } = render(
|
|
105
121
|
<TextArea
|
|
106
122
|
placeholder="test Name"
|
|
107
123
|
required
|
|
@@ -51,6 +51,24 @@ describe("TextField", () => {
|
|
|
51
51
|
expect(helperText).toBeInTheDocument();
|
|
52
52
|
});
|
|
53
53
|
});
|
|
54
|
+
test("renders TextField for read only mode", async () => {
|
|
55
|
+
render(
|
|
56
|
+
<TextField
|
|
57
|
+
readOnly
|
|
58
|
+
placeholder="test Name"
|
|
59
|
+
helperText="helper text"
|
|
60
|
+
label="test Name"
|
|
61
|
+
id="testName"
|
|
62
|
+
inputProps={{ "data-testid": "test-name-input" }}
|
|
63
|
+
data-testid="test-name-text-field"
|
|
64
|
+
size="small"
|
|
65
|
+
value="test value"
|
|
66
|
+
/>
|
|
67
|
+
);
|
|
68
|
+
const textField = await screen.findByRole("textbox");
|
|
69
|
+
expect(textField).toHaveValue("test value");
|
|
70
|
+
expect(textField).toHaveProperty("readOnly", true);
|
|
71
|
+
});
|
|
54
72
|
test("renders TextField for disabled mode", async () => {
|
|
55
73
|
render(
|
|
56
74
|
<TextField
|
|
@@ -59,15 +77,15 @@ describe("TextField", () => {
|
|
|
59
77
|
helperText="helper text"
|
|
60
78
|
label="test Name"
|
|
61
79
|
id="testName"
|
|
62
|
-
inputProps={{"data-testid": "test-name-input"}}
|
|
80
|
+
inputProps={{ "data-testid": "test-name-input" }}
|
|
63
81
|
data-testid="test-name-text-field"
|
|
64
82
|
size="small"
|
|
65
83
|
value="test value"
|
|
66
84
|
/>
|
|
67
85
|
);
|
|
68
86
|
const textField = await screen.findByRole("textbox");
|
|
69
|
-
expect(textField).
|
|
70
|
-
expect(textField).
|
|
87
|
+
expect(textField).toHaveValue("test value");
|
|
88
|
+
expect(textField).toBeDisabled();
|
|
71
89
|
});
|
|
72
90
|
test("HelperText renders errored", async () => {
|
|
73
91
|
await act(async () => {
|