@truedat/df 8.6.7 → 8.7.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/package.json +4 -4
- package/src/components/DynamicFormViewer.js +3 -3
- package/src/components/DynamicFormWithTranslations.js +4 -4
- package/src/components/FieldGroupDetail.js +1 -1
- package/src/components/FieldGroupWithTranslations.js +1 -1
- package/src/components/SelectDynamicFormWithTranslations.js +14 -15
- package/src/components/SelectableDynamicForm.js +1 -1
- package/src/components/__tests__/DynamicFieldValue.spec.js +2 -2
- package/src/components/__tests__/DynamicFormViewer.spec.js +7 -7
- package/src/components/__tests__/EditableDynamicFieldValue.spec.js +1 -1
- package/src/components/__tests__/FieldViewerValue.spec.js +12 -12
- package/src/components/__tests__/SelectDynamicFormWithTranslations.spec.js +1 -1
- package/src/components/__tests__/SelectableDynamicForm.spec.js +16 -12
- package/src/components/hierarchies/HierarchyView.js +9 -9
- package/src/components/hierarchies/__tests__/HierarchyRoutes.spec.js +1 -1
- package/src/components/widgets/DropdownDataLoader.js +1 -1
- package/src/components/widgets/DynamicField.js +5 -5
- package/src/components/widgets/DynamicTableField.js +129 -125
- package/src/components/widgets/GroupPreview.js +2 -2
- package/src/components/widgets/HierarchyPreview.js +1 -1
- package/src/components/widgets/ImageField.js +2 -3
- package/src/components/widgets/MarkdownField.js +0 -1
- package/src/components/widgets/StandardDropdown.js +5 -5
- package/src/components/widgets/StringField.js +1 -4
- package/src/components/widgets/TableField.js +1 -1
- package/src/components/widgets/UserGroupPreview.js +1 -1
- package/src/components/widgets/__tests__/CheckboxField.spec.js +2 -2
- package/src/components/widgets/__tests__/DropdownField.spec.js +2 -2
- package/src/components/widgets/__tests__/DynamicField.spec.js +11 -3
- package/src/components/widgets/__tests__/DynamicTableField.spec.js +237 -237
- package/src/components/widgets/__tests__/GroupPreview.spec.js +11 -11
- package/src/components/widgets/__tests__/HierarchyDropdown.spec.js +3 -3
- package/src/components/widgets/__tests__/NumberField.spec.js +1 -1
- package/src/components/widgets/__tests__/PairListField.spec.js +3 -3
- package/src/components/widgets/__tests__/StandardDropdown.spec.js +1 -1
- package/src/components/widgets/__tests__/UserGroupPreview.spec.js +14 -10
- package/src/messages/index.js +1 -1
- package/src/reducers/__tests__/dfMessage.spec.js +5 -5
- package/src/reducers/__tests__/selectedDomain.spec.js +2 -2
- package/src/reducers/__tests__/selectedDomains.spec.js +2 -2
- package/src/reducers/dfMessage.js +4 -4
- package/src/selectors/getOptions.js +2 -2
- package/src/selectors/templates.js +2 -2
- package/src/templates/components/Template.js +2 -2
- package/src/templates/components/TemplateFilters.js +1 -1
- package/src/templates/components/TemplateLoader.js +1 -1
- package/src/templates/components/TemplateRoutes.js +1 -1
- package/src/templates/components/Templates.js +1 -6
- package/src/templates/components/TemplatesContext.js +3 -3
- package/src/templates/components/TemplatesTable.js +1 -1
- package/src/templates/components/__tests__/TemplateLoader.spec.js +2 -2
- package/src/templates/components/__tests__/TemplateRoutes.spec.js +1 -1
- package/src/templates/components/__tests__/TemplatesTable.spec.js +1 -1
- package/src/templates/components/templateForm/ActiveGroupForm.js +3 -3
- package/src/templates/components/templateForm/ConditionalFieldForm.js +3 -3
- package/src/templates/components/templateForm/DependentDomain.js +3 -3
- package/src/templates/components/templateForm/FieldDefinition.js +126 -129
- package/src/templates/components/templateForm/HierarchiesList.js +1 -1
- package/src/templates/components/templateForm/MandatoryConditional.js +2 -2
- package/src/templates/components/templateForm/TemplateForm.js +46 -41
- package/src/templates/components/templateForm/ValuesConfiguration.js +69 -56
- package/src/templates/components/templateForm/ValuesField.js +43 -43
- package/src/templates/components/templateForm/__tests__/DefaultValue.spec.js +35 -35
- package/src/templates/components/templateForm/__tests__/DependentDomain.spec.js +1 -1
- package/src/templates/components/templateForm/__tests__/FieldDefinition.spec.js +227 -201
- package/src/templates/components/templateForm/__tests__/FieldForm.spec.js +12 -10
- package/src/templates/components/templateForm/__tests__/MandatoryConditional.spec.js +3 -3
- package/src/templates/components/templateForm/__tests__/SwitchListForm.spec.js +5 -5
- package/src/templates/components/templateForm/__tests__/SwitchSegment.spec.js +8 -8
- package/src/templates/components/templateForm/__tests__/TableValuesForm.spec.js +207 -189
- package/src/templates/components/templateForm/__tests__/TemplateForm.spec.js +42 -13
- package/src/templates/components/templateForm/__tests__/TemplateFormActions.spec.js +1 -1
- package/src/templates/components/templateForm/__tests__/TemplateRelationsForm.spec.js +3 -1
- package/src/templates/components/templateForm/__tests__/ValuesField.spec.js +6 -6
- package/src/templates/components/templateForm/__tests__/ValuesListForm.spec.js +4 -4
- package/src/templates/components/templateForm/__tests__/ValuesSelector.spec.js +3 -3
- package/src/templates/components/templateForm/widgetDefinitions.js +2 -0
- package/src/templates/reducers/__tests__/allTemplates.spec.js +4 -4
- package/src/templates/reducers/__tests__/selectedTemplate.spec.js +2 -2
- package/src/templates/reducers/__tests__/template.spec.js +4 -4
- package/src/templates/reducers/__tests__/templateDeleting.spec.js +2 -2
- package/src/templates/reducers/__tests__/templateLoading.spec.js +2 -2
- package/src/templates/reducers/__tests__/templates.spec.js +3 -3
- package/src/templates/reducers/__tests__/templatesLoading.spec.js +2 -2
- package/src/templates/sagas/__tests__/createTemplate.spec.js +3 -3
- package/src/templates/sagas/__tests__/fetchTemplates.spec.js +1 -1
- package/src/templates/sagas/index.js +2 -2
- package/src/templates/utils/__tests__/applyDefaults.spec.js +4 -4
- package/src/templates/utils/__tests__/filterDomains.spec.js +15 -15
- package/src/templates/utils/__tests__/filterFields.spec.js +2 -2
- package/src/templates/utils/__tests__/filterSwitches.spec.js +5 -5
- package/src/templates/utils/__tests__/filterValues.spec.js +4 -4
- package/src/templates/utils/__tests__/formatLegacyContent.spec.js +7 -7
- package/src/templates/utils/applyTemplate.js +66 -53
- package/src/templates/utils/filterDepends.js +1 -1
- package/src/templates/utils/filterSwitches.js +3 -3
- package/src/templates/utils/filterValues.js +4 -5
- package/src/templates/utils/flattenFields.js +2 -2
- package/src/templates/utils/formatLegacyContent.js +2 -1
- package/src/templates/utils/parseFieldOptions.js +15 -14
- package/src/templates/utils/parseGroups.js +43 -43
- package/src/templates/utils/validateContent.js +4 -4
|
@@ -5,253 +5,253 @@ import userEvent from "@testing-library/user-event";
|
|
|
5
5
|
import DynamicTableField from "../DynamicTableField";
|
|
6
6
|
|
|
7
7
|
jest.mock("../FieldByWidget", () => ({
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
8
|
+
__esModule: true,
|
|
9
|
+
default: ({ field, onChange }) => {
|
|
10
|
+
const testId = `cell-input-${field.name}`;
|
|
11
|
+
return (
|
|
12
|
+
<input
|
|
13
|
+
data-testid={testId}
|
|
14
|
+
defaultValue={field.value ?? ""}
|
|
15
|
+
onChange={(e) =>
|
|
16
|
+
onChange(e, { name: field.name, value: e.target.value })
|
|
17
|
+
}
|
|
18
|
+
/>
|
|
19
|
+
);
|
|
20
|
+
},
|
|
21
21
|
}));
|
|
22
22
|
|
|
23
23
|
const baseColumns = [
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
{ name: "col1", widget: "text" },
|
|
25
|
+
{ name: "col2", widget: "text" },
|
|
26
26
|
];
|
|
27
27
|
|
|
28
28
|
describe("DynamicTableField", () => {
|
|
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
|
-
const requiredMarks = rendered.getAllByText("*");
|
|
62
|
-
expect(requiredMarks.length).toBe(2);
|
|
29
|
+
test("renders header cells (including required asterisk when cardinality is '+' or '1')", async () => {
|
|
30
|
+
const onChange = jest.fn();
|
|
31
|
+
const table_columns = [
|
|
32
|
+
{ name: "col1", widget: "text", cardinality: "+" },
|
|
33
|
+
{ name: "col2", widget: "text" },
|
|
34
|
+
{ name: "col3", widget: "text", cardinality: "1" },
|
|
35
|
+
];
|
|
36
|
+
|
|
37
|
+
const props = {
|
|
38
|
+
field: {
|
|
39
|
+
name: "tbl",
|
|
40
|
+
value: [
|
|
41
|
+
{
|
|
42
|
+
col1: { value: "a" },
|
|
43
|
+
col2: { value: "b" },
|
|
44
|
+
col3: { value: "c" },
|
|
45
|
+
},
|
|
46
|
+
],
|
|
47
|
+
values: { table_columns },
|
|
48
|
+
},
|
|
49
|
+
onChange,
|
|
50
|
+
scope: "test",
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const rendered = render(<DynamicTableField {...props} />);
|
|
54
|
+
await waitForLoad(rendered);
|
|
55
|
+
expect(rendered.container).toMatchSnapshot();
|
|
56
|
+
|
|
57
|
+
table_columns.forEach((c) => {
|
|
58
|
+
expect(rendered.getByText(c.name)).toBeInTheDocument();
|
|
63
59
|
});
|
|
64
60
|
|
|
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
|
-
|
|
61
|
+
const requiredMarks = rendered.getAllByText("*");
|
|
62
|
+
expect(requiredMarks.length).toBe(2);
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
test("clicking add row calls onChange with a new empty row appended", async () => {
|
|
66
|
+
const user = userEvent.setup({ delay: null });
|
|
67
|
+
const onChange = jest.fn();
|
|
68
|
+
|
|
69
|
+
const initialValue = [
|
|
70
|
+
{ col1: { value: "a" }, col2: { value: "1" } },
|
|
71
|
+
{ col1: { value: "b" }, col2: { value: "2" } },
|
|
72
|
+
];
|
|
73
|
+
|
|
74
|
+
const props = {
|
|
75
|
+
field: {
|
|
76
|
+
name: "tbl",
|
|
77
|
+
value: initialValue,
|
|
78
|
+
values: { table_columns: baseColumns },
|
|
79
|
+
},
|
|
80
|
+
onChange,
|
|
81
|
+
scope: "test",
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
const rendered = render(<DynamicTableField {...props} />);
|
|
85
|
+
await waitForLoad(rendered);
|
|
86
|
+
const addButton = rendered.getByTestId("add-button");
|
|
87
|
+
await user.click(addButton);
|
|
88
|
+
|
|
89
|
+
expect(onChange).toHaveBeenCalledTimes(1);
|
|
90
|
+
const [_e, payload] = onChange.mock.calls[0];
|
|
91
|
+
expect(payload.name).toBe("tbl");
|
|
92
|
+
expect(Array.isArray(payload.value)).toBe(true);
|
|
93
|
+
expect(payload.value).toHaveLength(initialValue.length + 1);
|
|
94
|
+
|
|
95
|
+
expect(payload.value[payload.value.length - 1]).toEqual({});
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
test("clicking the trash icon removes the corresponding row and calls onChange", async () => {
|
|
99
|
+
const onChange = jest.fn();
|
|
100
|
+
|
|
101
|
+
const initialValue = [
|
|
102
|
+
{ col1: { value: "a" }, col2: { value: "1" } },
|
|
103
|
+
{ col1: { value: "b" }, col2: { value: "2" } },
|
|
104
|
+
{ col1: { value: "c" }, col2: { value: "3" } },
|
|
105
|
+
];
|
|
106
|
+
|
|
107
|
+
const props = {
|
|
108
|
+
field: {
|
|
109
|
+
name: "tbl",
|
|
110
|
+
value: initialValue,
|
|
111
|
+
values: { table_columns: baseColumns },
|
|
112
|
+
},
|
|
113
|
+
onChange,
|
|
114
|
+
scope: "test",
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
const rendered = render(<DynamicTableField {...props} />);
|
|
118
|
+
await waitForLoad(rendered);
|
|
119
|
+
|
|
120
|
+
const firstRow = rendered.container.querySelector("tbody tr");
|
|
121
|
+
expect(firstRow).toBeTruthy();
|
|
122
|
+
|
|
123
|
+
const trashIcon = firstRow.querySelector(".selectable");
|
|
124
|
+
expect(trashIcon).toBeTruthy();
|
|
125
|
+
|
|
126
|
+
fireEvent.click(trashIcon);
|
|
127
|
+
|
|
128
|
+
expect(onChange).toHaveBeenCalledTimes(1);
|
|
129
|
+
const [, payload] = onChange.mock.calls[0];
|
|
130
|
+
|
|
131
|
+
expect(payload.name).toBe("tbl");
|
|
132
|
+
expect(payload.value).toHaveLength(2);
|
|
133
|
+
|
|
134
|
+
expect(payload.value[0]).toEqual(initialValue[1]);
|
|
135
|
+
expect(payload.value[1]).toEqual(initialValue[2]);
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
test("editing a cell calls onChange with updated structure { origin: 'user', value }", async () => {
|
|
139
|
+
const user = userEvent.setup({ delay: null });
|
|
140
|
+
const onChange = jest.fn();
|
|
141
|
+
|
|
142
|
+
const initialValue = [
|
|
143
|
+
{ col1: { value: "old-a" }, col2: { value: "1" } },
|
|
144
|
+
{ col1: { value: "old-b" }, col2: { value: "2" } },
|
|
145
|
+
];
|
|
146
|
+
|
|
147
|
+
const props = {
|
|
148
|
+
field: {
|
|
149
|
+
name: "tbl",
|
|
150
|
+
value: initialValue,
|
|
151
|
+
values: { table_columns: baseColumns },
|
|
152
|
+
},
|
|
153
|
+
onChange,
|
|
154
|
+
scope: "test",
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
const rendered = render(<DynamicTableField {...props} />);
|
|
158
|
+
await waitForLoad(rendered);
|
|
159
|
+
|
|
160
|
+
const input = rendered.getAllByTestId("cell-input-col1")[0];
|
|
161
|
+
await user.clear(input);
|
|
162
|
+
await user.type(input, "new-a");
|
|
163
|
+
|
|
164
|
+
// Last call should have the updated row 0 col1 shape
|
|
165
|
+
expect(onChange).toHaveBeenCalled();
|
|
166
|
+
const [, payload] = onChange.mock.calls[onChange.mock.calls.length - 1];
|
|
167
|
+
|
|
168
|
+
expect(payload.name).toBe("tbl");
|
|
169
|
+
expect(payload.value).toHaveLength(2);
|
|
170
|
+
|
|
171
|
+
expect(payload.value[0].col1).toEqual({
|
|
172
|
+
origin: "user",
|
|
173
|
+
value: "new-a",
|
|
96
174
|
});
|
|
97
175
|
|
|
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
|
-
const initialValue = [
|
|
143
|
-
{ col1: { value: "old-a" }, col2: { value: "1" } },
|
|
144
|
-
{ col1: { value: "old-b" }, col2: { value: "2" } },
|
|
145
|
-
];
|
|
146
|
-
|
|
147
|
-
const props = {
|
|
148
|
-
field: {
|
|
149
|
-
name: "tbl",
|
|
150
|
-
value: initialValue,
|
|
151
|
-
values: { table_columns: baseColumns },
|
|
152
|
-
},
|
|
153
|
-
onChange,
|
|
154
|
-
scope: "test",
|
|
155
|
-
};
|
|
156
|
-
|
|
157
|
-
const rendered = render(<DynamicTableField {...props} />);
|
|
158
|
-
await waitForLoad(rendered);
|
|
159
|
-
|
|
160
|
-
const input = rendered.getAllByTestId("cell-input-col1")[0];
|
|
161
|
-
await user.clear(input);
|
|
162
|
-
await user.type(input, "new-a");
|
|
163
|
-
|
|
164
|
-
// Last call should have the updated row 0 col1 shape
|
|
165
|
-
expect(onChange).toHaveBeenCalled();
|
|
166
|
-
const [, payload] = onChange.mock.calls[onChange.mock.calls.length - 1];
|
|
167
|
-
|
|
168
|
-
expect(payload.name).toBe("tbl");
|
|
169
|
-
expect(payload.value).toHaveLength(2);
|
|
170
|
-
|
|
171
|
-
expect(payload.value[0].col1).toEqual({
|
|
172
|
-
origin: "user",
|
|
173
|
-
value: "new-a",
|
|
174
|
-
});
|
|
175
|
-
|
|
176
|
-
expect(payload.value[0].col2).toEqual({ value: "1" });
|
|
177
|
-
expect(payload.value[1]).toEqual(initialValue[1]);
|
|
176
|
+
expect(payload.value[0].col2).toEqual({ value: "1" });
|
|
177
|
+
expect(payload.value[1]).toEqual(initialValue[1]);
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
test("removeDeletedColumns strips keys not present in table_columns before emitting onChange", async () => {
|
|
181
|
+
const user = userEvent.setup({ delay: null });
|
|
182
|
+
const onChange = jest.fn();
|
|
183
|
+
|
|
184
|
+
const columns = [
|
|
185
|
+
{ name: "col1", widget: "text" },
|
|
186
|
+
{ name: "col2", widget: "text" },
|
|
187
|
+
// Note: no 'ghost' column
|
|
188
|
+
];
|
|
189
|
+
|
|
190
|
+
const initialValue = [
|
|
191
|
+
// Row contains an extra 'ghost' key that should be stripped on change
|
|
192
|
+
{ col1: { value: "x" }, col2: { value: "y" }, ghost: { value: "zzz" } },
|
|
193
|
+
];
|
|
194
|
+
|
|
195
|
+
const props = {
|
|
196
|
+
field: {
|
|
197
|
+
name: "tbl",
|
|
198
|
+
value: initialValue,
|
|
199
|
+
values: { table_columns: columns },
|
|
200
|
+
},
|
|
201
|
+
onChange,
|
|
202
|
+
scope: "test",
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
const rendered = render(<DynamicTableField {...props} />);
|
|
206
|
+
await waitForLoad(rendered);
|
|
207
|
+
|
|
208
|
+
// Trigger a change on col2; this will call handleChange → removeDeletedColumns
|
|
209
|
+
const input = rendered.getByTestId("cell-input-col2");
|
|
210
|
+
await user.clear(input);
|
|
211
|
+
await user.type(input, "updated");
|
|
212
|
+
|
|
213
|
+
expect(onChange).toHaveBeenCalled();
|
|
214
|
+
const [, payload] = onChange.mock.calls[onChange.mock.calls.length - 1];
|
|
215
|
+
|
|
216
|
+
// 'ghost' should be omitted from the emitted row
|
|
217
|
+
expect(payload.value[0]).toEqual({
|
|
218
|
+
col1: { value: "x" },
|
|
219
|
+
col2: { origin: "user", value: "updated" },
|
|
178
220
|
});
|
|
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
|
-
expect(onChange).toHaveBeenCalled();
|
|
214
|
-
const [, payload] = onChange.mock.calls[onChange.mock.calls.length - 1];
|
|
215
|
-
|
|
216
|
-
// 'ghost' should be omitted from the emitted row
|
|
217
|
-
expect(payload.value[0]).toEqual({
|
|
218
|
-
col1: { value: "x" },
|
|
219
|
-
col2: { origin: "user", value: "updated" },
|
|
220
|
-
});
|
|
221
|
-
expect(payload.value[0].ghost).toBeUndefined();
|
|
222
|
-
});
|
|
223
|
-
|
|
224
|
-
test("delete button exists per row and add button exists in footer", async () => {
|
|
225
|
-
const onChange = jest.fn();
|
|
226
|
-
|
|
227
|
-
const initialValue = [
|
|
228
|
-
{ col1: { value: "a" }, col2: { value: "1" } },
|
|
229
|
-
{ col1: { value: "b" }, col2: { value: "2" } },
|
|
230
|
-
];
|
|
231
|
-
|
|
232
|
-
const props = {
|
|
233
|
-
field: {
|
|
234
|
-
name: "tbl",
|
|
235
|
-
value: initialValue,
|
|
236
|
-
values: { table_columns: baseColumns },
|
|
237
|
-
},
|
|
238
|
-
onChange,
|
|
239
|
-
scope: "test",
|
|
240
|
-
};
|
|
241
|
-
|
|
242
|
-
const rendered = render(<DynamicTableField {...props} />);
|
|
243
|
-
await waitForLoad(rendered);
|
|
244
|
-
|
|
245
|
-
// Footer add button
|
|
246
|
-
expect(rendered.getByTestId("add-button")).toBeInTheDocument();
|
|
247
|
-
|
|
248
|
-
// Each row should render a Button containing the trash Icon
|
|
249
|
-
const rows = rendered.container.querySelectorAll("tbody tr");
|
|
250
|
-
expect(rows.length).toBe(2);
|
|
251
|
-
|
|
252
|
-
rows.forEach((row) => {
|
|
253
|
-
const trashIcon = row.querySelector(".selectable");
|
|
254
|
-
expect(trashIcon).toBeTruthy();
|
|
255
|
-
});
|
|
221
|
+
expect(payload.value[0].ghost).toBeUndefined();
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
test("delete button exists per row and add button exists in footer", async () => {
|
|
225
|
+
const onChange = jest.fn();
|
|
226
|
+
|
|
227
|
+
const initialValue = [
|
|
228
|
+
{ col1: { value: "a" }, col2: { value: "1" } },
|
|
229
|
+
{ col1: { value: "b" }, col2: { value: "2" } },
|
|
230
|
+
];
|
|
231
|
+
|
|
232
|
+
const props = {
|
|
233
|
+
field: {
|
|
234
|
+
name: "tbl",
|
|
235
|
+
value: initialValue,
|
|
236
|
+
values: { table_columns: baseColumns },
|
|
237
|
+
},
|
|
238
|
+
onChange,
|
|
239
|
+
scope: "test",
|
|
240
|
+
};
|
|
241
|
+
|
|
242
|
+
const rendered = render(<DynamicTableField {...props} />);
|
|
243
|
+
await waitForLoad(rendered);
|
|
244
|
+
|
|
245
|
+
// Footer add button
|
|
246
|
+
expect(rendered.getByTestId("add-button")).toBeInTheDocument();
|
|
247
|
+
|
|
248
|
+
// Each row should render a Button containing the trash Icon
|
|
249
|
+
const rows = rendered.container.querySelectorAll("tbody tr");
|
|
250
|
+
expect(rows.length).toBe(2);
|
|
251
|
+
|
|
252
|
+
rows.forEach((row) => {
|
|
253
|
+
const trashIcon = row.querySelector(".selectable");
|
|
254
|
+
expect(trashIcon).toBeTruthy();
|
|
256
255
|
});
|
|
256
|
+
});
|
|
257
257
|
});
|
|
@@ -20,38 +20,38 @@ describe("<GroupPreview />", () => {
|
|
|
20
20
|
|
|
21
21
|
it("renders group values with a group icon", () => {
|
|
22
22
|
const rendered = render(
|
|
23
|
-
<GroupPreview groups={[{ id: 123, name: "foo bar" }]}
|
|
23
|
+
<GroupPreview groups={[{ id: 123, name: "foo bar" }]} />,
|
|
24
24
|
);
|
|
25
25
|
|
|
26
26
|
expect(rendered.container.textContent).toBe("foo bar");
|
|
27
27
|
expect(rendered.container.querySelector(".group.icon")).toBeInTheDocument();
|
|
28
28
|
expect(rendered.getByRole("link", { name: /foo bar/i })).toHaveAttribute(
|
|
29
29
|
"href",
|
|
30
|
-
"/groups/123"
|
|
30
|
+
"/groups/123",
|
|
31
31
|
);
|
|
32
32
|
});
|
|
33
33
|
|
|
34
34
|
it("strips the legacy group: prefix when rendering names", () => {
|
|
35
35
|
const rendered = render(
|
|
36
|
-
<GroupPreview groups={[{ id: 123, name: "group:foo bar" }]}
|
|
36
|
+
<GroupPreview groups={[{ id: 123, name: "group:foo bar" }]} />,
|
|
37
37
|
);
|
|
38
38
|
|
|
39
39
|
expect(rendered.container.textContent).toBe("foo bar");
|
|
40
40
|
expect(rendered.container.querySelector(".group.icon")).toBeInTheDocument();
|
|
41
41
|
expect(rendered.getByRole("link", { name: /foo bar/i })).toHaveAttribute(
|
|
42
42
|
"href",
|
|
43
|
-
"/groups/123"
|
|
43
|
+
"/groups/123",
|
|
44
44
|
);
|
|
45
45
|
});
|
|
46
46
|
|
|
47
47
|
it("does not render user values", () => {
|
|
48
48
|
const rendered = render(
|
|
49
|
-
<GroupPreview groups={["user:baz qux", { id: 123, name: "foo bar" }]}
|
|
49
|
+
<GroupPreview groups={["user:baz qux", { id: 123, name: "foo bar" }]} />,
|
|
50
50
|
);
|
|
51
51
|
|
|
52
52
|
expect(rendered.container.textContent).toBe("foo bar");
|
|
53
53
|
expect(
|
|
54
|
-
rendered.container.querySelector(".user.icon")
|
|
54
|
+
rendered.container.querySelector(".user.icon"),
|
|
55
55
|
).not.toBeInTheDocument();
|
|
56
56
|
expect(rendered.container.querySelector(".group.icon")).toBeInTheDocument();
|
|
57
57
|
});
|
|
@@ -62,7 +62,7 @@ describe("<GroupPreview />", () => {
|
|
|
62
62
|
expect(rendered.container.textContent).toBe("lone foo bar");
|
|
63
63
|
expect(rendered.container.querySelector(".group.icon")).toBeInTheDocument();
|
|
64
64
|
expect(
|
|
65
|
-
rendered.queryByRole("link", { name: /lone foo bar/i })
|
|
65
|
+
rendered.queryByRole("link", { name: /lone foo bar/i }),
|
|
66
66
|
).not.toBeInTheDocument();
|
|
67
67
|
});
|
|
68
68
|
|
|
@@ -72,7 +72,7 @@ describe("<GroupPreview />", () => {
|
|
|
72
72
|
expect(rendered.container.textContent).toBe("foo bar");
|
|
73
73
|
expect(rendered.container.querySelector(".group.icon")).toBeInTheDocument();
|
|
74
74
|
expect(
|
|
75
|
-
rendered.queryByRole("link", { name: /foo bar/i })
|
|
75
|
+
rendered.queryByRole("link", { name: /foo bar/i }),
|
|
76
76
|
).not.toBeInTheDocument();
|
|
77
77
|
});
|
|
78
78
|
|
|
@@ -122,7 +122,7 @@ describe("<GroupPreview />", () => {
|
|
|
122
122
|
});
|
|
123
123
|
expect(rendered.getByRole("link", { name: /foo bar/i })).toHaveAttribute(
|
|
124
124
|
"href",
|
|
125
|
-
"/groups/123"
|
|
125
|
+
"/groups/123",
|
|
126
126
|
);
|
|
127
127
|
});
|
|
128
128
|
|
|
@@ -142,7 +142,7 @@ describe("<GroupPreview />", () => {
|
|
|
142
142
|
});
|
|
143
143
|
expect(rendered.getByRole("link", { name: /foo bar/i })).toHaveAttribute(
|
|
144
144
|
"href",
|
|
145
|
-
"/groups/123"
|
|
145
|
+
"/groups/123",
|
|
146
146
|
);
|
|
147
147
|
});
|
|
148
148
|
|
|
@@ -163,7 +163,7 @@ describe("<GroupPreview />", () => {
|
|
|
163
163
|
|
|
164
164
|
expect(rendered.getByRole("link", { name: /foo bar/i })).toHaveAttribute(
|
|
165
165
|
"href",
|
|
166
|
-
"/groups/123"
|
|
166
|
+
"/groups/123",
|
|
167
167
|
);
|
|
168
168
|
expect(rendered.container.querySelector(".group.icon")).toBeInTheDocument();
|
|
169
169
|
});
|
|
@@ -27,7 +27,7 @@ describe("<HierarchyDropdown />", () => {
|
|
|
27
27
|
onChange: jest.fn(),
|
|
28
28
|
};
|
|
29
29
|
const { container } = render(
|
|
30
|
-
<HierarchyDropdown {...missingMinDepthProps}
|
|
30
|
+
<HierarchyDropdown {...missingMinDepthProps} />,
|
|
31
31
|
);
|
|
32
32
|
expect(container).toMatchSnapshot();
|
|
33
33
|
});
|
|
@@ -43,7 +43,7 @@ describe("<HierarchyDropdown />", () => {
|
|
|
43
43
|
onChange: jest.fn(),
|
|
44
44
|
};
|
|
45
45
|
const { container } = render(
|
|
46
|
-
<HierarchyDropdown {...missingMinDepthProps}
|
|
46
|
+
<HierarchyDropdown {...missingMinDepthProps} />,
|
|
47
47
|
);
|
|
48
48
|
expect(container).toMatchSnapshot();
|
|
49
49
|
});
|
|
@@ -59,7 +59,7 @@ describe("<HierarchyDropdown />", () => {
|
|
|
59
59
|
onChange: jest.fn(),
|
|
60
60
|
};
|
|
61
61
|
const { container } = render(
|
|
62
|
-
<HierarchyDropdown {...missingMinDepthProps}
|
|
62
|
+
<HierarchyDropdown {...missingMinDepthProps} />,
|
|
63
63
|
);
|
|
64
64
|
expect(container).toMatchSnapshot();
|
|
65
65
|
});
|
|
@@ -23,7 +23,7 @@ describe("<NumberField />", () => {
|
|
|
23
23
|
|
|
24
24
|
// Find the number input and simulate a change
|
|
25
25
|
const numberInput = rendered.container.querySelector(
|
|
26
|
-
'input[type="number"]'
|
|
26
|
+
'input[type="number"]',
|
|
27
27
|
);
|
|
28
28
|
userEvent.clear(numberInput);
|
|
29
29
|
userEvent.type(numberInput, "42");
|
|
@@ -64,12 +64,12 @@ describe("<PairListField />", () => {
|
|
|
64
64
|
...props,
|
|
65
65
|
field,
|
|
66
66
|
}}
|
|
67
|
-
|
|
67
|
+
/>,
|
|
68
68
|
);
|
|
69
69
|
await waitForLoad(rendered);
|
|
70
70
|
|
|
71
71
|
const inputs = rendered.container.querySelectorAll(
|
|
72
|
-
'input[name="url_name"]'
|
|
72
|
+
'input[name="url_name"]',
|
|
73
73
|
);
|
|
74
74
|
const secondInput = inputs[1];
|
|
75
75
|
await user.type(secondInput, "1");
|
|
@@ -113,7 +113,7 @@ describe("<PairListField />", () => {
|
|
|
113
113
|
...props,
|
|
114
114
|
field,
|
|
115
115
|
}}
|
|
116
|
-
|
|
116
|
+
/>,
|
|
117
117
|
);
|
|
118
118
|
await waitForLoad(rendered);
|
|
119
119
|
const deleteButtons = rendered.container.querySelectorAll(".minus.icon");
|