@truedat/df 8.7.0 → 8.7.2

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.
Files changed (101) hide show
  1. package/package.json +4 -4
  2. package/src/components/DynamicFormViewer.js +3 -3
  3. package/src/components/DynamicFormWithTranslations.js +4 -4
  4. package/src/components/FieldGroupDetail.js +1 -1
  5. package/src/components/FieldGroupWithTranslations.js +1 -1
  6. package/src/components/SelectableDynamicForm.js +1 -1
  7. package/src/components/__tests__/DynamicFieldValue.spec.js +2 -2
  8. package/src/components/__tests__/DynamicFormViewer.spec.js +7 -7
  9. package/src/components/__tests__/EditableDynamicFieldValue.spec.js +1 -1
  10. package/src/components/__tests__/FieldViewerValue.spec.js +12 -12
  11. package/src/components/__tests__/SelectDynamicFormWithTranslations.spec.js +1 -1
  12. package/src/components/__tests__/SelectableDynamicForm.spec.js +16 -12
  13. package/src/components/hierarchies/HierarchyView.js +9 -9
  14. package/src/components/hierarchies/__tests__/HierarchyRoutes.spec.js +1 -1
  15. package/src/components/widgets/DropdownDataLoader.js +1 -1
  16. package/src/components/widgets/DynamicField.js +5 -5
  17. package/src/components/widgets/DynamicTableField.js +129 -125
  18. package/src/components/widgets/GroupPreview.js +2 -2
  19. package/src/components/widgets/HierarchyPreview.js +1 -1
  20. package/src/components/widgets/ImageField.js +2 -3
  21. package/src/components/widgets/MarkdownField.js +0 -1
  22. package/src/components/widgets/StandardDropdown.js +5 -5
  23. package/src/components/widgets/StringField.js +1 -4
  24. package/src/components/widgets/TableField.js +1 -1
  25. package/src/components/widgets/UserGroupPreview.js +1 -1
  26. package/src/components/widgets/__tests__/CheckboxField.spec.js +2 -2
  27. package/src/components/widgets/__tests__/DropdownField.spec.js +2 -2
  28. package/src/components/widgets/__tests__/DynamicField.spec.js +11 -3
  29. package/src/components/widgets/__tests__/DynamicTableField.spec.js +237 -237
  30. package/src/components/widgets/__tests__/GroupPreview.spec.js +11 -11
  31. package/src/components/widgets/__tests__/HierarchyDropdown.spec.js +3 -3
  32. package/src/components/widgets/__tests__/NumberField.spec.js +1 -1
  33. package/src/components/widgets/__tests__/PairListField.spec.js +3 -3
  34. package/src/components/widgets/__tests__/StandardDropdown.spec.js +1 -1
  35. package/src/components/widgets/__tests__/UserGroupPreview.spec.js +14 -10
  36. package/src/messages/index.js +1 -1
  37. package/src/reducers/__tests__/dfMessage.spec.js +5 -5
  38. package/src/reducers/__tests__/selectedDomain.spec.js +2 -2
  39. package/src/reducers/__tests__/selectedDomains.spec.js +2 -2
  40. package/src/reducers/dfMessage.js +4 -4
  41. package/src/selectors/getOptions.js +2 -2
  42. package/src/selectors/templates.js +2 -2
  43. package/src/templates/components/Template.js +2 -2
  44. package/src/templates/components/TemplateFilters.js +1 -1
  45. package/src/templates/components/TemplateLoader.js +1 -1
  46. package/src/templates/components/TemplateRoutes.js +1 -1
  47. package/src/templates/components/Templates.js +1 -6
  48. package/src/templates/components/TemplatesContext.js +3 -3
  49. package/src/templates/components/TemplatesTable.js +1 -1
  50. package/src/templates/components/__tests__/TemplateLoader.spec.js +2 -2
  51. package/src/templates/components/__tests__/TemplateRoutes.spec.js +1 -1
  52. package/src/templates/components/__tests__/TemplatesTable.spec.js +1 -1
  53. package/src/templates/components/templateForm/ActiveGroupForm.js +3 -3
  54. package/src/templates/components/templateForm/ConditionalFieldForm.js +3 -3
  55. package/src/templates/components/templateForm/DependentDomain.js +3 -3
  56. package/src/templates/components/templateForm/FieldDefinition.js +126 -129
  57. package/src/templates/components/templateForm/HierarchiesList.js +1 -1
  58. package/src/templates/components/templateForm/MandatoryConditional.js +2 -2
  59. package/src/templates/components/templateForm/TemplateForm.js +46 -41
  60. package/src/templates/components/templateForm/ValuesConfiguration.js +69 -56
  61. package/src/templates/components/templateForm/ValuesField.js +43 -43
  62. package/src/templates/components/templateForm/__tests__/DefaultValue.spec.js +35 -35
  63. package/src/templates/components/templateForm/__tests__/DependentDomain.spec.js +1 -1
  64. package/src/templates/components/templateForm/__tests__/FieldDefinition.spec.js +227 -201
  65. package/src/templates/components/templateForm/__tests__/FieldForm.spec.js +12 -10
  66. package/src/templates/components/templateForm/__tests__/MandatoryConditional.spec.js +3 -3
  67. package/src/templates/components/templateForm/__tests__/SwitchListForm.spec.js +5 -5
  68. package/src/templates/components/templateForm/__tests__/SwitchSegment.spec.js +8 -8
  69. package/src/templates/components/templateForm/__tests__/TableValuesForm.spec.js +207 -189
  70. package/src/templates/components/templateForm/__tests__/TemplateForm.spec.js +42 -13
  71. package/src/templates/components/templateForm/__tests__/TemplateFormActions.spec.js +1 -1
  72. package/src/templates/components/templateForm/__tests__/TemplateRelationsForm.spec.js +3 -1
  73. package/src/templates/components/templateForm/__tests__/ValuesField.spec.js +6 -6
  74. package/src/templates/components/templateForm/__tests__/ValuesListForm.spec.js +4 -4
  75. package/src/templates/components/templateForm/__tests__/ValuesSelector.spec.js +3 -3
  76. package/src/templates/components/templateForm/widgetDefinitions.js +2 -0
  77. package/src/templates/reducers/__tests__/allTemplates.spec.js +4 -4
  78. package/src/templates/reducers/__tests__/selectedTemplate.spec.js +2 -2
  79. package/src/templates/reducers/__tests__/template.spec.js +4 -4
  80. package/src/templates/reducers/__tests__/templateDeleting.spec.js +2 -2
  81. package/src/templates/reducers/__tests__/templateLoading.spec.js +2 -2
  82. package/src/templates/reducers/__tests__/templates.spec.js +3 -3
  83. package/src/templates/reducers/__tests__/templatesLoading.spec.js +2 -2
  84. package/src/templates/sagas/__tests__/createTemplate.spec.js +3 -3
  85. package/src/templates/sagas/__tests__/fetchTemplates.spec.js +1 -1
  86. package/src/templates/sagas/index.js +2 -2
  87. package/src/templates/utils/__tests__/applyDefaults.spec.js +4 -4
  88. package/src/templates/utils/__tests__/filterDomains.spec.js +15 -15
  89. package/src/templates/utils/__tests__/filterFields.spec.js +2 -2
  90. package/src/templates/utils/__tests__/filterSwitches.spec.js +5 -5
  91. package/src/templates/utils/__tests__/filterValues.spec.js +4 -4
  92. package/src/templates/utils/__tests__/formatLegacyContent.spec.js +7 -7
  93. package/src/templates/utils/applyTemplate.js +66 -53
  94. package/src/templates/utils/filterDepends.js +1 -1
  95. package/src/templates/utils/filterSwitches.js +3 -3
  96. package/src/templates/utils/filterValues.js +4 -5
  97. package/src/templates/utils/flattenFields.js +2 -2
  98. package/src/templates/utils/formatLegacyContent.js +2 -1
  99. package/src/templates/utils/parseFieldOptions.js +15 -14
  100. package/src/templates/utils/parseGroups.js +43 -43
  101. package/src/templates/utils/validateContent.js +4 -4
@@ -7,209 +7,227 @@ import TableValuesForm from "../TableValuesForm";
7
7
  const mockFormatMessage = jest.fn(({ id }) => id);
8
8
 
9
9
  jest.mock("react-intl", () => ({
10
- ...jest.requireActual("react-intl"),
11
- useIntl: () => ({
12
- formatMessage: mockFormatMessage,
13
- }),
10
+ ...jest.requireActual("react-intl"),
11
+ useIntl: () => ({
12
+ formatMessage: mockFormatMessage,
13
+ }),
14
14
  }));
15
15
 
16
16
  // --- Stub child components to isolate TableValuesForm behavior ---
17
- jest.mock("../FieldDefinition", () => () => <div data-testid="FieldDefinition" />);
17
+ jest.mock("../FieldDefinition", () => () => (
18
+ <div data-testid="FieldDefinition" />
19
+ ));
18
20
  jest.mock("../ValuesField", () => () => <div data-testid="ValuesField" />);
19
- jest.mock("../ValuesConfiguration", () => () => <div data-testid="ValuesConfiguration" />);
21
+ jest.mock("../ValuesConfiguration", () => () => (
22
+ <div data-testid="ValuesConfiguration" />
23
+ ));
20
24
 
21
25
  const user = userEvent.setup({ delay: null });
22
26
 
23
27
  const values = [
24
- { name: "colA", widget: "string", type: "string", errors: {} },
25
- { name: "colB", widget: "string", type: "string", errors: { nameDuplicated: true, hasErrors: true } },
28
+ { name: "colA", widget: "string", type: "string", errors: {} },
29
+ {
30
+ name: "colB",
31
+ widget: "string",
32
+ type: "string",
33
+ errors: { nameDuplicated: true, hasErrors: true },
34
+ },
26
35
  ];
27
36
 
28
37
  const baseProps = {
29
- name: "myField",
30
- type: "table_columns", // used as the key in the onChange payload
31
- values,
32
- onChange: jest.fn(),
33
- scope: "scope-x",
34
- field: { values: { table_columns: values } },
35
- fieldNamePrefix: "myPrefix",
38
+ name: "myField",
39
+ type: "table_columns", // used as the key in the onChange payload
40
+ values,
41
+ onChange: jest.fn(),
42
+ scope: "scope-x",
43
+ field: { values: { table_columns: values } },
44
+ fieldNamePrefix: "myPrefix",
36
45
  };
37
46
 
38
-
39
47
  describe("TableValuesForm", () => {
40
- test("renders an Accordion with a panel per value, showing name and duplicated label", () => {
41
- const rendered = render(<TableValuesForm {...baseProps} />);
42
- waitForLoad(rendered);
43
-
44
- // Two labels for two columns
45
- expect(rendered.getByText("colA")).toBeInTheDocument();
46
- expect(rendered.getByText("colB")).toBeInTheDocument();
47
-
48
- // Duplicated name label for the second column only
49
- // The label text comes from formatMessage
50
- expect(rendered.getByText("template.form.validation.name_duplicated")).toBeInTheDocument();
51
- });
52
-
53
- test("clicking a panel title toggles it active and reveals its content", async () => {
54
- const rendered = render(<TableValuesForm {...baseProps} />);
55
- waitForLoad(rendered);
56
-
57
- // Click on "colA" title to expand
58
- await user.click(rendered.getByText("colA"));
59
-
60
- // Content should render the stubs under the active panel
61
- // (we don't assert which panel holds it; just that they are present)
62
- expect(rendered.getAllByTestId("FieldDefinition").length).toBeGreaterThan(0);
63
- expect(rendered.getAllByTestId("ValuesField").length).toBeGreaterThan(0);
64
- });
65
-
66
- test("move down moves the selected column forward and calls onChange with swapped array", async () => {
67
- const rendered = render(<TableValuesForm {...baseProps} />);
68
- waitForLoad(rendered);
69
-
70
- // Expand panel 0 (colA)
71
- await user.click(rendered.getByText("colA"));
72
-
73
- // In the panel content, there is a Button.Group with three buttons (up, down, delete)
74
- // We'll grab them by role=button within the expanded panel area.
75
- // Since Semantic UI doesn't attach specific names by default to icon-only buttons,
76
- // we'll pick by order: [up, down, delete].
77
- const activePanel = rendered.getByText("colA").closest(".title")?.nextElementSibling;
78
- expect(activePanel).toBeTruthy();
79
-
80
- const buttons = within(activePanel).getAllByRole("button");
81
- // up is disabled for index 0; down should move colA to index 1
82
- const [, downButton] = buttons;
83
- await user.click(downButton);
84
-
85
- // Expect onChange called with swapped values for key "table_columns"
86
- expect(baseProps.onChange).toHaveBeenCalledWith(
87
- null,
88
- expect.objectContaining({
89
- name: "myField",
90
- value: {
91
- table_columns: [
92
- expect.objectContaining({ name: "colB" }),
93
- expect.objectContaining({ name: "colA" }),
94
- ],
95
- },
96
- })
97
- );
98
- });
99
-
100
- test("move up moves the selected column backward and calls onChange with swapped array", async () => {
101
- const rendered = render(<TableValuesForm {...baseProps} />);
102
- waitForLoad(rendered);
103
-
104
- // Expand panel 1 (colB)
105
- await user.click(rendered.getByText("colB"));
106
-
107
- // Get the three buttons from this panel (up, down, delete)
108
- const activePanel = rendered.getByText("colB").closest(".title")?.nextElementSibling;
109
- expect(activePanel).toBeTruthy();
110
-
111
- const buttons = within(activePanel).getAllByRole("button");
112
- const [upButton] = buttons; // first button = up
113
- await user.click(upButton);
114
-
115
- // Expect swap: colB moves to index 0
116
- expect(baseProps.onChange).toHaveBeenCalledWith(
117
- null,
118
- expect.objectContaining({
119
- name: "myField",
120
- value: {
121
- table_columns: [
122
- expect.objectContaining({ name: "colB" }),
123
- expect.objectContaining({ name: "colA" }),
124
- ],
125
- },
126
- })
127
- );
128
- });
129
-
130
- test("delete removes the selected column and calls onChange with shortened array", async () => {
131
- const rendered = render(<TableValuesForm {...baseProps} />);
132
- waitForLoad(rendered);
133
-
134
- // Expand panel 0 (colA)
135
- await user.click(rendered.getByText("colA"));
136
-
137
- const activePanel = rendered.getByText("colA").closest(".title")?.nextElementSibling;
138
- const buttons = within(activePanel).getAllByRole("button");
139
- const deleteButton = buttons[buttons.length - 1];
140
-
141
- await user.click(deleteButton);
142
-
143
- expect(baseProps.onChange).toHaveBeenLastCalledWith(
144
- null,
145
- expect.objectContaining({
146
- name: "myField",
147
- value: {
148
- table_columns: [
149
- expect.objectContaining({ name: "colB" }), // only colB remains
150
- ],
151
- },
152
- })
153
- );
154
- });
155
-
156
- test("add column via Enter in input appends a default field with given name", async () => {
157
- const rendered = render(<TableValuesForm {...baseProps} />);
158
- waitForLoad(rendered);
159
-
160
- // Input is at the bottom with an icon. We'll type and press Enter.
161
- const input = rendered.getByRole("textbox");
162
- await user.type(input, "newCol{enter}");
163
-
164
- // The payload includes the new element at the end.
165
- // It uses defaultFieldDefinition + overrides: name, label set to 'myField', ai_suggestion=false
166
- expect(baseProps.onChange).toHaveBeenCalledWith(
167
- null,
48
+ test("renders an Accordion with a panel per value, showing name and duplicated label", () => {
49
+ const rendered = render(<TableValuesForm {...baseProps} />);
50
+ waitForLoad(rendered);
51
+
52
+ // Two labels for two columns
53
+ expect(rendered.getByText("colA")).toBeInTheDocument();
54
+ expect(rendered.getByText("colB")).toBeInTheDocument();
55
+
56
+ // Duplicated name label for the second column only
57
+ // The label text comes from formatMessage
58
+ expect(
59
+ rendered.getByText("template.form.validation.name_duplicated"),
60
+ ).toBeInTheDocument();
61
+ });
62
+
63
+ test("clicking a panel title toggles it active and reveals its content", async () => {
64
+ const rendered = render(<TableValuesForm {...baseProps} />);
65
+ waitForLoad(rendered);
66
+
67
+ // Click on "colA" title to expand
68
+ await user.click(rendered.getByText("colA"));
69
+
70
+ // Content should render the stubs under the active panel
71
+ // (we don't assert which panel holds it; just that they are present)
72
+ expect(rendered.getAllByTestId("FieldDefinition").length).toBeGreaterThan(
73
+ 0,
74
+ );
75
+ expect(rendered.getAllByTestId("ValuesField").length).toBeGreaterThan(0);
76
+ });
77
+
78
+ test("move down moves the selected column forward and calls onChange with swapped array", async () => {
79
+ const rendered = render(<TableValuesForm {...baseProps} />);
80
+ waitForLoad(rendered);
81
+
82
+ // Expand panel 0 (colA)
83
+ await user.click(rendered.getByText("colA"));
84
+
85
+ // In the panel content, there is a Button.Group with three buttons (up, down, delete)
86
+ // We'll grab them by role=button within the expanded panel area.
87
+ // Since Semantic UI doesn't attach specific names by default to icon-only buttons,
88
+ // we'll pick by order: [up, down, delete].
89
+ const activePanel = rendered
90
+ .getByText("colA")
91
+ .closest(".title")?.nextElementSibling;
92
+ expect(activePanel).toBeTruthy();
93
+
94
+ const buttons = within(activePanel).getAllByRole("button");
95
+ // up is disabled for index 0; down should move colA to index 1
96
+ const [, downButton] = buttons;
97
+ await user.click(downButton);
98
+
99
+ // Expect onChange called with swapped values for key "table_columns"
100
+ expect(baseProps.onChange).toHaveBeenCalledWith(
101
+ null,
102
+ expect.objectContaining({
103
+ name: "myField",
104
+ value: {
105
+ table_columns: [
106
+ expect.objectContaining({ name: "colB" }),
107
+ expect.objectContaining({ name: "colA" }),
108
+ ],
109
+ },
110
+ }),
111
+ );
112
+ });
113
+
114
+ test("move up moves the selected column backward and calls onChange with swapped array", async () => {
115
+ const rendered = render(<TableValuesForm {...baseProps} />);
116
+ waitForLoad(rendered);
117
+
118
+ // Expand panel 1 (colB)
119
+ await user.click(rendered.getByText("colB"));
120
+
121
+ // Get the three buttons from this panel (up, down, delete)
122
+ const activePanel = rendered
123
+ .getByText("colB")
124
+ .closest(".title")?.nextElementSibling;
125
+ expect(activePanel).toBeTruthy();
126
+
127
+ const buttons = within(activePanel).getAllByRole("button");
128
+ const [upButton] = buttons; // first button = up
129
+ await user.click(upButton);
130
+
131
+ // Expect swap: colB moves to index 0
132
+ expect(baseProps.onChange).toHaveBeenCalledWith(
133
+ null,
134
+ expect.objectContaining({
135
+ name: "myField",
136
+ value: {
137
+ table_columns: [
138
+ expect.objectContaining({ name: "colB" }),
139
+ expect.objectContaining({ name: "colA" }),
140
+ ],
141
+ },
142
+ }),
143
+ );
144
+ });
145
+
146
+ test("delete removes the selected column and calls onChange with shortened array", async () => {
147
+ const rendered = render(<TableValuesForm {...baseProps} />);
148
+ waitForLoad(rendered);
149
+
150
+ // Expand panel 0 (colA)
151
+ await user.click(rendered.getByText("colA"));
152
+
153
+ const activePanel = rendered
154
+ .getByText("colA")
155
+ .closest(".title")?.nextElementSibling;
156
+ const buttons = within(activePanel).getAllByRole("button");
157
+ const deleteButton = buttons[buttons.length - 1];
158
+
159
+ await user.click(deleteButton);
160
+
161
+ expect(baseProps.onChange).toHaveBeenLastCalledWith(
162
+ null,
163
+ expect.objectContaining({
164
+ name: "myField",
165
+ value: {
166
+ table_columns: [
167
+ expect.objectContaining({ name: "colB" }), // only colB remains
168
+ ],
169
+ },
170
+ }),
171
+ );
172
+ });
173
+
174
+ test("add column via Enter in input appends a default field with given name", async () => {
175
+ const rendered = render(<TableValuesForm {...baseProps} />);
176
+ waitForLoad(rendered);
177
+
178
+ // Input is at the bottom with an icon. We'll type and press Enter.
179
+ const input = rendered.getByRole("textbox");
180
+ await user.type(input, "newCol{enter}");
181
+
182
+ // The payload includes the new element at the end.
183
+ // It uses defaultFieldDefinition + overrides: name, label set to 'myField', ai_suggestion=false
184
+ expect(baseProps.onChange).toHaveBeenCalledWith(
185
+ null,
186
+ expect.objectContaining({
187
+ name: "myField",
188
+ value: {
189
+ table_columns: expect.arrayContaining([
168
190
  expect.objectContaining({
169
- name: "myField",
170
- value: {
171
- table_columns: expect.arrayContaining([
172
- expect.objectContaining({
173
- name: "newCol",
174
- ai_suggestion: false,
175
- label: "newCol",
176
- }),
177
- ]),
178
- },
179
- })
180
- );
181
- });
182
-
183
- test("add column via clicking the add icon triggers same append behavior", async () => {
184
- const rendered = render(<TableValuesForm {...baseProps} />);
185
- waitForLoad(rendered);
186
-
187
- // Type value first so state.fieldValue has content
188
- const input = rendered.getByRole("textbox");
189
- await user.type(input, "anotherCol");
190
-
191
- // Click the icon (it's rendered inside the input as a clickable Icon)
192
- // Find by role button might not exist; the icon has role="img" with class "add circle".
193
- // We'll click it via its container: the input's parent .input has an i.icon inside.
194
- const inputWrapper = input.closest(".input");
195
- const addIcon = inputWrapper?.querySelector(".icon");
196
- expect(addIcon).toBeTruthy();
197
- await user.click(addIcon);
198
-
199
- expect(baseProps.onChange).toHaveBeenCalledWith(
200
- null,
191
+ name: "newCol",
192
+ ai_suggestion: false,
193
+ label: "newCol",
194
+ }),
195
+ ]),
196
+ },
197
+ }),
198
+ );
199
+ });
200
+
201
+ test("add column via clicking the add icon triggers same append behavior", async () => {
202
+ const rendered = render(<TableValuesForm {...baseProps} />);
203
+ waitForLoad(rendered);
204
+
205
+ // Type value first so state.fieldValue has content
206
+ const input = rendered.getByRole("textbox");
207
+ await user.type(input, "anotherCol");
208
+
209
+ // Click the icon (it's rendered inside the input as a clickable Icon)
210
+ // Find by role button might not exist; the icon has role="img" with class "add circle".
211
+ // We'll click it via its container: the input's parent .input has an i.icon inside.
212
+ const inputWrapper = input.closest(".input");
213
+ const addIcon = inputWrapper?.querySelector(".icon");
214
+ expect(addIcon).toBeTruthy();
215
+ await user.click(addIcon);
216
+
217
+ expect(baseProps.onChange).toHaveBeenCalledWith(
218
+ null,
219
+ expect.objectContaining({
220
+ name: "myField",
221
+ value: {
222
+ table_columns: expect.arrayContaining([
201
223
  expect.objectContaining({
202
- name: "myField",
203
- value: {
204
- table_columns: expect.arrayContaining([
205
- expect.objectContaining({
206
- name: "anotherCol",
207
- ai_suggestion: false,
208
- label: "anotherCol",
209
- }),
210
- ]),
211
- },
212
- })
213
- );
214
- });
224
+ name: "anotherCol",
225
+ ai_suggestion: false,
226
+ label: "anotherCol",
227
+ }),
228
+ ]),
229
+ },
230
+ }),
231
+ );
232
+ });
215
233
  });
@@ -30,7 +30,12 @@ const validTemplate = {
30
30
  name: "Test Template",
31
31
  label: "Test Label",
32
32
  scope: "gr",
33
- content: [{ name: "Group1", fields: [{ name: "field1", label: "Field 1", type: "string" }] }],
33
+ content: [
34
+ {
35
+ name: "Group1",
36
+ fields: [{ name: "field1", label: "Field 1", type: "string" }],
37
+ },
38
+ ],
34
39
  };
35
40
 
36
41
  describe("<TemplateForm />", () => {
@@ -47,8 +52,12 @@ describe("<TemplateForm />", () => {
47
52
  },
48
53
  };
49
54
  const rendered = render(
50
- <TemplateForm template={validTemplate} onSubmit={jest.fn()} loading={false} />,
51
- renderOpts
55
+ <TemplateForm
56
+ template={validTemplate}
57
+ onSubmit={jest.fn()}
58
+ loading={false}
59
+ />,
60
+ renderOpts,
52
61
  );
53
62
  await waitForLoad(rendered);
54
63
  expect(rendered.container).toMatchSnapshot();
@@ -65,8 +74,12 @@ describe("<TemplateForm />", () => {
65
74
  },
66
75
  };
67
76
  const rendered = render(
68
- <TemplateForm template={templateOtherScope} onSubmit={jest.fn()} loading={false} />,
69
- renderOpts
77
+ <TemplateForm
78
+ template={templateOtherScope}
79
+ onSubmit={jest.fn()}
80
+ loading={false}
81
+ />,
82
+ renderOpts,
70
83
  );
71
84
  await waitForLoad(rendered);
72
85
  expect(rendered.container).toMatchSnapshot();
@@ -81,13 +94,19 @@ describe("<TemplateForm />", () => {
81
94
  },
82
95
  };
83
96
  const rendered = render(
84
- <TemplateForm template={validTemplate} onSubmit={onSubmit} loading={false} />,
85
- renderOpts
97
+ <TemplateForm
98
+ template={validTemplate}
99
+ onSubmit={onSubmit}
100
+ loading={false}
101
+ />,
102
+ renderOpts,
86
103
  );
87
104
  await waitForLoad(rendered);
88
105
 
89
106
  await waitFor(() => {
90
- expect(rendered.getByTestId("template-relations-form")).toBeInTheDocument();
107
+ expect(
108
+ rendered.getByTestId("template-relations-form"),
109
+ ).toBeInTheDocument();
91
110
  });
92
111
 
93
112
  const user = userEvent.setup({ delay: null });
@@ -120,8 +139,12 @@ describe("<TemplateForm />", () => {
120
139
  },
121
140
  };
122
141
  const rendered = render(
123
- <TemplateForm template={templateWithRelations} onSubmit={onSubmit} loading={false} />,
124
- renderOpts
142
+ <TemplateForm
143
+ template={templateWithRelations}
144
+ onSubmit={onSubmit}
145
+ loading={false}
146
+ />,
147
+ renderOpts,
125
148
  );
126
149
  await waitForLoad(rendered);
127
150
 
@@ -150,12 +173,18 @@ describe("<TemplateForm />", () => {
150
173
  },
151
174
  };
152
175
  const rendered = render(
153
- <TemplateForm template={templateOtherScope} onSubmit={onSubmit} loading={false} />,
154
- renderOpts
176
+ <TemplateForm
177
+ template={templateOtherScope}
178
+ onSubmit={onSubmit}
179
+ loading={false}
180
+ />,
181
+ renderOpts,
155
182
  );
156
183
  await waitForLoad(rendered);
157
184
 
158
- expect(rendered.queryByTestId("template-relations-form")).not.toBeInTheDocument();
185
+ expect(
186
+ rendered.queryByTestId("template-relations-form"),
187
+ ).not.toBeInTheDocument();
159
188
 
160
189
  const user = userEvent.setup({ delay: null });
161
190
  await user.click(rendered.getByRole("button", { name: /save/i }));
@@ -33,7 +33,7 @@ describe("<TemplateFormActions />", () => {
33
33
 
34
34
  it("matches the latest snapshot (deleting)", async () => {
35
35
  const rendered = render(
36
- <TemplateFormActions {...props} templateDeleting />
36
+ <TemplateFormActions {...props} templateDeleting />,
37
37
  );
38
38
  await waitForLoad(rendered);
39
39
  expect(rendered.container).toMatchSnapshot();
@@ -127,7 +127,9 @@ describe("<TemplateRelationsForm />", () => {
127
127
  await waitForLoad(rendered);
128
128
 
129
129
  // Just verify toggle is rendered and can be clicked without waiting for state
130
- const toggle = rendered.getByLabelText(/template\.relations\.group_by_domain/i);
130
+ const toggle = rendered.getByLabelText(
131
+ /template\.relations\.group_by_domain/i,
132
+ );
131
133
  expect(toggle).toBeInTheDocument();
132
134
  });
133
135
 
@@ -43,7 +43,7 @@ describe("<ValuesField /> noPrefix", () => {
43
43
  await user.click(
44
44
  await rendered.findByRole("option", {
45
45
  name: "template.field.values.switch",
46
- })
46
+ }),
47
47
  );
48
48
 
49
49
  expect(onChange).toHaveBeenCalledWith(
@@ -51,7 +51,7 @@ describe("<ValuesField /> noPrefix", () => {
51
51
  expect.objectContaining({
52
52
  name: subscribableField,
53
53
  value: false,
54
- })
54
+ }),
55
55
  );
56
56
 
57
57
  expect(onChange).toHaveBeenCalledWith(
@@ -59,7 +59,7 @@ describe("<ValuesField /> noPrefix", () => {
59
59
  expect.objectContaining({
60
60
  name,
61
61
  value: { switch: null },
62
- })
62
+ }),
63
63
  );
64
64
  });
65
65
  });
@@ -128,7 +128,7 @@ describe("<ValuesField /> fixed", () => {
128
128
 
129
129
  const user = userEvent.setup({ delay: null });
130
130
  const checkbox = rendered.container.querySelector(
131
- `[name="${subscribableField}"]`
131
+ `[name="${subscribableField}"]`,
132
132
  );
133
133
  expect(checkbox).toBeInTheDocument();
134
134
  await user.click(checkbox);
@@ -141,12 +141,12 @@ describe("<ValuesField /> fixed", () => {
141
141
  // Test with fixed_tuple keyType
142
142
  const renderedWithFixedTuple = render({
143
143
  ...props,
144
- values: { fixed_tuple: [{ value: "Foo", text: "Bar" }] }
144
+ values: { fixed_tuple: [{ value: "Foo", text: "Bar" }] },
145
145
  });
146
146
  await waitForLoad(renderedWithFixedTuple);
147
147
 
148
148
  const checkboxFixedTuple = renderedWithFixedTuple.getByText(
149
- "template.field.subscribable"
149
+ "template.field.subscribable",
150
150
  );
151
151
  expect(checkboxFixedTuple).toBeInTheDocument();
152
152
  await user.click(checkboxFixedTuple);
@@ -29,13 +29,13 @@ describe("<ValuesListForm /> fixed", () => {
29
29
  expect(onChange).toHaveBeenCalledWith(["Bar", "Foo"]);
30
30
 
31
31
  const downButton = rendered.container.querySelectorAll(
32
- ".chevron.circle.down"
32
+ ".chevron.circle.down",
33
33
  )[0];
34
34
  await user.click(downButton);
35
35
  expect(onChange).toHaveBeenCalledWith(["Foo", "Bar"]);
36
36
 
37
37
  const removeButton = rendered.container.querySelectorAll(
38
- ".remove.circle.icon"
38
+ ".remove.circle.icon",
39
39
  )[0];
40
40
  await user.click(removeButton);
41
41
  expect(onChange).toHaveBeenCalledWith(["Bar"]);
@@ -91,10 +91,10 @@ describe("<ValuesListForm /> fixed_tuple", () => {
91
91
  const user = userEvent.setup({ delay: null });
92
92
  // Write "Test" to inputs
93
93
  const valueInput = rendered.container.querySelector(
94
- "input[name='tuple_value']"
94
+ "input[name='tuple_value']",
95
95
  );
96
96
  const textInput = rendered.container.querySelector(
97
- "input[name='tuple_text']"
97
+ "input[name='tuple_text']",
98
98
  );
99
99
 
100
100
  await user.type(valueInput, "test");
@@ -28,7 +28,7 @@ describe("<ValuesSelector />", () => {
28
28
 
29
29
  it("renders SwitchListForm when type is switch", async () => {
30
30
  const rendered = render(
31
- <ValuesSelector {...props} values={{}} defaultValue={{}} type="switch" />
31
+ <ValuesSelector {...props} values={{}} defaultValue={{}} type="switch" />,
32
32
  );
33
33
  await waitForLoad(rendered);
34
34
  expect(rendered.container).toMatchSnapshot();
@@ -43,7 +43,7 @@ describe("<ValuesSelector />", () => {
43
43
  it("changes value on onChange with role_users", async () => {
44
44
  const user = userEvent.setup({ delay: null });
45
45
  const rendered = render(
46
- <ValuesSelector {...props} values="role" type="role_users" />
46
+ <ValuesSelector {...props} values="role" type="role_users" />,
47
47
  );
48
48
  await waitForLoad(rendered);
49
49
  await user.type(rendered.getByRole("textbox"), "1");
@@ -56,7 +56,7 @@ describe("<ValuesSelector />", () => {
56
56
  it("changes value on onChange with role_groups", async () => {
57
57
  const user = userEvent.setup({ delay: null });
58
58
  const rendered = render(
59
- <ValuesSelector {...props} values="role" type="role_groups" />
59
+ <ValuesSelector {...props} values="role" type="role_groups" />,
60
60
  );
61
61
  await waitForLoad(rendered);
62
62
  await user.type(rendered.getByRole("textbox"), "1");