@ukhomeoffice/cop-react-form-renderer 5.74.3 → 5.74.5
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/dist/components/CollectionSummary/CollectionSummary.js +12 -1
- package/dist/components/CollectionSummary/CollectionSummary.test.js +66 -20
- package/dist/components/CollectionSummary/SummaryCard.js +10 -8
- package/dist/components/CollectionSummary/SummaryCard.test.js +94 -37
- package/dist/utils/CollectionPage/getQuickEditPage.js +2 -1
- package/dist/utils/CollectionPage/getQuickEditPage.test.js +8 -0
- package/package.json +1 -1
|
@@ -76,6 +76,15 @@ var CollectionSummary = function CollectionSummary(_ref) {
|
|
|
76
76
|
var data = (0, _react.useMemo)(function () {
|
|
77
77
|
return _utils.default.CollectionPage.getData(config.collectionName, formData) || [];
|
|
78
78
|
}, [formData]);
|
|
79
|
+
var toFocusOn = Array.isArray(data) && data.length > 0 ? data.reduce(function (acc, current) {
|
|
80
|
+
if (current.isDuplicate) {
|
|
81
|
+
if (!acc || current.id > acc.id) {
|
|
82
|
+
return current;
|
|
83
|
+
}
|
|
84
|
+
return acc;
|
|
85
|
+
}
|
|
86
|
+
return acc;
|
|
87
|
+
}, null) : null;
|
|
79
88
|
var masterPage = (0, _react.useMemo)(function () {
|
|
80
89
|
var collectionNameParts = config.collectionName.split('.');
|
|
81
90
|
var childPages = _utils.default.CollectionPage.mergePages(pages || []) || [];
|
|
@@ -247,7 +256,9 @@ var CollectionSummary = function CollectionSummary(_ref) {
|
|
|
247
256
|
var isInError = errors.filter(function (e) {
|
|
248
257
|
return e.entryId === entry.id;
|
|
249
258
|
}).length > 0;
|
|
250
|
-
var finalConfig = _objectSpread(_objectSpread(_objectSpread({}, config.card), entry.isDuplicate && config.duplicatedCard ? config.duplicatedCard : {}), isInError && config.errorCard ? config.errorCard : {})
|
|
259
|
+
var finalConfig = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, config.card), entry.isDuplicate && config.duplicatedCard ? config.duplicatedCard : {}), isInError && config.errorCard ? config.errorCard : {}), {}, {
|
|
260
|
+
focusOn: (toFocusOn === null || toFocusOn === void 0 ? void 0 : toFocusOn.id) === entry.id
|
|
261
|
+
});
|
|
251
262
|
var key = "".concat(config.fieldId, ".summaryCard").concat(entry.id);
|
|
252
263
|
return /*#__PURE__*/_react.default.createElement(_SummaryCardValidationContext.default, {
|
|
253
264
|
entryId: entry.id,
|
|
@@ -73,6 +73,52 @@ describe('components.CollectionSummary.CollectionSummary', function () {
|
|
|
73
73
|
expect(summary.children[0].id).toEqual("".concat(CONFIG.fieldId, ".summaryCard").concat(FORM_DATA.testCollection[0].id));
|
|
74
74
|
expect(summary.children[1].id).toEqual("".concat(CONFIG.fieldId, ".summaryCard").concat(FORM_DATA.testCollection[1].id));
|
|
75
75
|
});
|
|
76
|
+
it('should focus on the most recently duplicated item', function () {
|
|
77
|
+
var customConfig = {
|
|
78
|
+
id: 'testSummary',
|
|
79
|
+
fieldId: 'testSummary',
|
|
80
|
+
collectionName: 'testCollection',
|
|
81
|
+
card: {
|
|
82
|
+
title: 'Title',
|
|
83
|
+
deleteAction: {
|
|
84
|
+
label: 'Delete'
|
|
85
|
+
},
|
|
86
|
+
changeAction: {
|
|
87
|
+
label: 'Change label',
|
|
88
|
+
page: 'testPage',
|
|
89
|
+
aria_label: [{
|
|
90
|
+
text: 'testText'
|
|
91
|
+
}]
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
quickEdit: true,
|
|
95
|
+
focusOn: true
|
|
96
|
+
};
|
|
97
|
+
var customFormData = {
|
|
98
|
+
testCollectionActiveId: '001',
|
|
99
|
+
testCollection: [{
|
|
100
|
+
id: '000',
|
|
101
|
+
testText: 'value',
|
|
102
|
+
isDuplicate: true
|
|
103
|
+
}, {
|
|
104
|
+
id: '001',
|
|
105
|
+
isDuplicate: true
|
|
106
|
+
}]
|
|
107
|
+
};
|
|
108
|
+
var _renderWithValidation2 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react.default.createElement(_CollectionSummary.default, {
|
|
109
|
+
config: customConfig,
|
|
110
|
+
formData: customFormData,
|
|
111
|
+
onAction: ON_ACTION
|
|
112
|
+
})),
|
|
113
|
+
container = _renderWithValidation2.container;
|
|
114
|
+
var changeButtons = container.querySelectorAll('[data-testid="change-button"]');
|
|
115
|
+
var firstDuplicatedItem = changeButtons[0];
|
|
116
|
+
var lastDuplicatedItem = changeButtons[changeButtons.length - 1];
|
|
117
|
+
expect(lastDuplicatedItem).toBeDefined();
|
|
118
|
+
expect(document.activeElement).toEqual(lastDuplicatedItem);
|
|
119
|
+
expect(lastDuplicatedItem.id).toEqual('testSummary.summaryCard001.changeButton');
|
|
120
|
+
expect(document.activeElement).not.toEqual(firstDuplicatedItem);
|
|
121
|
+
});
|
|
76
122
|
it('should correctly queue errors found when validating entries', function () {
|
|
77
123
|
var ErrorCheckComponent = function ErrorCheckComponent() {
|
|
78
124
|
var _useValidation = (0, _hooks.useValidation)(),
|
|
@@ -81,24 +127,24 @@ describe('components.CollectionSummary.CollectionSummary', function () {
|
|
|
81
127
|
return e.error;
|
|
82
128
|
}));
|
|
83
129
|
};
|
|
84
|
-
var
|
|
130
|
+
var _renderWithValidation3 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(ErrorCheckComponent, null), /*#__PURE__*/_react.default.createElement(_CollectionSummary.default, {
|
|
85
131
|
config: CONFIG,
|
|
86
132
|
formData: FORM_DATA,
|
|
87
133
|
onAction: ON_ACTION,
|
|
88
134
|
pages: PAGES
|
|
89
135
|
}))),
|
|
90
|
-
container =
|
|
136
|
+
container = _renderWithValidation3.container;
|
|
91
137
|
var errorChecker = container.children[0];
|
|
92
138
|
expect(errorChecker.textContent).toContain('queuedErrors is an array of length 1');
|
|
93
139
|
expect(errorChecker.textContent).toContain('testText is required');
|
|
94
140
|
});
|
|
95
141
|
it('should render a confirmation when a SummaryCard\'s delete button is pressed', function () {
|
|
96
|
-
var
|
|
142
|
+
var _renderWithValidation4 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react.default.createElement(_CollectionSummary.default, {
|
|
97
143
|
config: CONFIG,
|
|
98
144
|
formData: FORM_DATA,
|
|
99
145
|
onAction: ON_ACTION
|
|
100
146
|
})),
|
|
101
|
-
container =
|
|
147
|
+
container = _renderWithValidation4.container;
|
|
102
148
|
var summary = checkSetup(container);
|
|
103
149
|
expect(summary.children.length).toEqual(2);
|
|
104
150
|
var card = summary.children[0];
|
|
@@ -122,12 +168,12 @@ describe('components.CollectionSummary.CollectionSummary', function () {
|
|
|
122
168
|
title: 'Title'
|
|
123
169
|
}
|
|
124
170
|
};
|
|
125
|
-
var
|
|
171
|
+
var _renderWithValidation5 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react.default.createElement(_CollectionSummary.default, {
|
|
126
172
|
config: CONFIG_WITH_BUTTON,
|
|
127
173
|
formData: FORM_DATA,
|
|
128
174
|
onAction: ON_ACTION
|
|
129
175
|
})),
|
|
130
|
-
container =
|
|
176
|
+
container = _renderWithValidation5.container;
|
|
131
177
|
var summary = checkSetup(container);
|
|
132
178
|
expect(summary.children.length).toEqual(3); // The button and a card for each item.
|
|
133
179
|
expect(summary.children[0].id).toEqual("".concat(CONFIG_WITH_BUTTON.fieldId, ".addButton"));
|
|
@@ -146,12 +192,12 @@ describe('components.CollectionSummary.CollectionSummary', function () {
|
|
|
146
192
|
title: 'Title'
|
|
147
193
|
}
|
|
148
194
|
};
|
|
149
|
-
var
|
|
195
|
+
var _renderWithValidation6 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react.default.createElement(_CollectionSummary.default, {
|
|
150
196
|
config: CONFIG_WITH_BUTTON,
|
|
151
197
|
formData: FORM_DATA,
|
|
152
198
|
onAction: ON_ACTION
|
|
153
199
|
})),
|
|
154
|
-
container =
|
|
200
|
+
container = _renderWithValidation6.container;
|
|
155
201
|
var summary = checkSetup(container);
|
|
156
202
|
expect(summary.children.length).toEqual(3); // The button and a card for each item.
|
|
157
203
|
expect(summary.children[0].id).toEqual("".concat(CONFIG_WITH_BUTTON.fieldId, ".addButton"));
|
|
@@ -159,12 +205,12 @@ describe('components.CollectionSummary.CollectionSummary', function () {
|
|
|
159
205
|
expect(summary.children[0].tagName).toEqual('BUTTON');
|
|
160
206
|
});
|
|
161
207
|
it('should apply the expected class name to the summary card when delete button is pressed', function () {
|
|
162
|
-
var
|
|
208
|
+
var _renderWithValidation7 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react.default.createElement(_CollectionSummary.default, {
|
|
163
209
|
config: CONFIG,
|
|
164
210
|
formData: FORM_DATA,
|
|
165
211
|
onAction: ON_ACTION
|
|
166
212
|
})),
|
|
167
|
-
container =
|
|
213
|
+
container = _renderWithValidation7.container;
|
|
168
214
|
var summary = checkSetup(container);
|
|
169
215
|
expect(summary.children.length).toEqual(2);
|
|
170
216
|
var card = summary.children[0];
|
|
@@ -175,12 +221,12 @@ describe('components.CollectionSummary.CollectionSummary', function () {
|
|
|
175
221
|
expect(card.className).toContain('deleting-summary-card');
|
|
176
222
|
});
|
|
177
223
|
it('should focus on the delete button in the confirmation panel', function () {
|
|
178
|
-
var
|
|
224
|
+
var _renderWithValidation8 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react.default.createElement(_CollectionSummary.default, {
|
|
179
225
|
config: CONFIG,
|
|
180
226
|
formData: FORM_DATA,
|
|
181
227
|
onAction: ON_ACTION
|
|
182
228
|
})),
|
|
183
|
-
container =
|
|
229
|
+
container = _renderWithValidation8.container;
|
|
184
230
|
var summary = checkSetup(container);
|
|
185
231
|
expect(summary.children.length).toEqual(2);
|
|
186
232
|
var card = summary.children[0];
|
|
@@ -191,12 +237,12 @@ describe('components.CollectionSummary.CollectionSummary', function () {
|
|
|
191
237
|
expect(document.activeElement).toEqual(confirmButton);
|
|
192
238
|
});
|
|
193
239
|
it('should have the role "alert" in the confirmation panel', function () {
|
|
194
|
-
var
|
|
240
|
+
var _renderWithValidation9 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react.default.createElement(_CollectionSummary.default, {
|
|
195
241
|
config: CONFIG,
|
|
196
242
|
formData: FORM_DATA,
|
|
197
243
|
onAction: ON_ACTION
|
|
198
244
|
})),
|
|
199
|
-
container =
|
|
245
|
+
container = _renderWithValidation9.container;
|
|
200
246
|
var summary = checkSetup(container);
|
|
201
247
|
expect(summary.children.length).toEqual(2);
|
|
202
248
|
var card = summary.children[0];
|
|
@@ -216,14 +262,14 @@ describe('components.CollectionSummary.CollectionSummary', function () {
|
|
|
216
262
|
displayFields: ['testText']
|
|
217
263
|
}
|
|
218
264
|
});
|
|
219
|
-
var
|
|
265
|
+
var _renderWithValidation10 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react.default.createElement(_CollectionSummary.default, {
|
|
220
266
|
config: listViewConfig,
|
|
221
267
|
formData: FORM_DATA,
|
|
222
268
|
onAction: ON_ACTION,
|
|
223
269
|
pages: PAGES
|
|
224
270
|
})),
|
|
225
|
-
container =
|
|
226
|
-
getByText =
|
|
271
|
+
container = _renderWithValidation10.container,
|
|
272
|
+
getByText = _renderWithValidation10.getByText;
|
|
227
273
|
var summary = checkSetup(container);
|
|
228
274
|
expect(summary.children.length).toEqual(2);
|
|
229
275
|
var card = summary.children[0];
|
|
@@ -248,14 +294,14 @@ describe('components.CollectionSummary.CollectionSummary', function () {
|
|
|
248
294
|
message: 'Test confirmation message with index number ${index}'
|
|
249
295
|
}
|
|
250
296
|
});
|
|
251
|
-
var
|
|
297
|
+
var _renderWithValidation11 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react.default.createElement(_CollectionSummary.default, {
|
|
252
298
|
config: listViewConfig,
|
|
253
299
|
formData: FORM_DATA,
|
|
254
300
|
onAction: ON_ACTION,
|
|
255
301
|
pages: PAGES
|
|
256
302
|
})),
|
|
257
|
-
container =
|
|
258
|
-
getByText =
|
|
303
|
+
container = _renderWithValidation11.container,
|
|
304
|
+
getByText = _renderWithValidation11.getByText;
|
|
259
305
|
var summary = checkSetup(container);
|
|
260
306
|
expect(summary.children.length).toEqual(2);
|
|
261
307
|
var card = summary.children[0];
|
|
@@ -178,6 +178,7 @@ var SummaryCard = function SummaryCard(_ref) {
|
|
|
178
178
|
}, _utils.default.FormPage.getConditionalText(config.details, entryData))), /*#__PURE__*/_react.default.createElement("div", {
|
|
179
179
|
className: classes('header-actions')
|
|
180
180
|
}, config.quickEdit && /*#__PURE__*/_react.default.createElement(_copReactComponents.Button, {
|
|
181
|
+
"data-testid": "quickedit-button",
|
|
181
182
|
id: "".concat(id, ".quickEditButton"),
|
|
182
183
|
onClick: function onClick() {
|
|
183
184
|
return setQuickEdit(function (prevState) {
|
|
@@ -187,9 +188,10 @@ var SummaryCard = function SummaryCard(_ref) {
|
|
|
187
188
|
classModifiers: "primary",
|
|
188
189
|
disabled: quickEdit,
|
|
189
190
|
name: "QuickEdit",
|
|
190
|
-
autoFocus:
|
|
191
|
+
autoFocus: config.focusOn
|
|
191
192
|
}, DEFAULT_EDIT_LABEL), config.changeAction && typeof onFullEdit === 'function' && /*#__PURE__*/_react.default.createElement(_copReactComponents.Button, {
|
|
192
193
|
id: "".concat(id, ".changeButton"),
|
|
194
|
+
"data-testid": "change-button",
|
|
193
195
|
onClick: function onClick() {
|
|
194
196
|
var _config$changeAction;
|
|
195
197
|
return onFullEdit((_config$changeAction = config.changeAction) === null || _config$changeAction === void 0 ? void 0 : _config$changeAction.page, entryData.id);
|
|
@@ -197,7 +199,7 @@ var SummaryCard = function SummaryCard(_ref) {
|
|
|
197
199
|
classModifiers: ((_config$changeAction2 = config.changeAction) === null || _config$changeAction2 === void 0 ? void 0 : _config$changeAction2.classModifiers) || DEFAULT_CHANGE_BUTTON_CLASS,
|
|
198
200
|
"aria-label": _utils.default.FormPage.getConditionalText((_config$changeAction3 = config.changeAction) === null || _config$changeAction3 === void 0 ? void 0 : _config$changeAction3.aria_label, entryData),
|
|
199
201
|
name: "Change",
|
|
200
|
-
autoFocus:
|
|
202
|
+
autoFocus: config.focusOn
|
|
201
203
|
}, ((_config$changeAction4 = config.changeAction) === null || _config$changeAction4 === void 0 ? void 0 : _config$changeAction4.label) || DEFAULT_CHANGE_BUTTON_LABEL), config.deleteAction && typeof onDelete === 'function' && /*#__PURE__*/_react.default.createElement(_copReactComponents.Button, {
|
|
202
204
|
id: "".concat(id, ".deleteButton"),
|
|
203
205
|
onClick: function onClick() {
|
|
@@ -205,9 +207,9 @@ var SummaryCard = function SummaryCard(_ref) {
|
|
|
205
207
|
},
|
|
206
208
|
classModifiers: "secondary",
|
|
207
209
|
"aria-label": _utils.default.FormPage.getConditionalText((_config$deleteAction = config.deleteAction) === null || _config$deleteAction === void 0 ? void 0 : _config$deleteAction.aria_label, entryData),
|
|
208
|
-
name: "Delete"
|
|
209
|
-
autoFocus: entryData.isDuplicate
|
|
210
|
+
name: "Delete"
|
|
210
211
|
}, ((_config$deleteAction2 = config.deleteAction) === null || _config$deleteAction2 === void 0 ? void 0 : _config$deleteAction2.label) || DEFAULT_DELETE_BUTTON_LABEL), config.duplicateAction && typeof onDuplicate === 'function' && /*#__PURE__*/_react.default.createElement(_copReactComponents.Button, {
|
|
212
|
+
"data-testid": "duplicate-button",
|
|
211
213
|
id: "".concat(id, ".duplicateButton"),
|
|
212
214
|
onClick: function onClick() {
|
|
213
215
|
onDuplicate(entryData);
|
|
@@ -215,7 +217,7 @@ var SummaryCard = function SummaryCard(_ref) {
|
|
|
215
217
|
classModifiers: "secondary",
|
|
216
218
|
"aria-label": _utils.default.FormPage.getConditionalText((_config$duplicateActi = config.duplicateAction) === null || _config$duplicateActi === void 0 ? void 0 : _config$duplicateActi.aria_label, entryData),
|
|
217
219
|
name: "Duplicate",
|
|
218
|
-
autoFocus:
|
|
220
|
+
autoFocus: config.focusOn
|
|
219
221
|
}, ((_config$duplicateActi2 = config.duplicateAction) === null || _config$duplicateActi2 === void 0 ? void 0 : _config$duplicateActi2.label) || DEFAULT_DUPLICATE_BUTTON_LABEL))), quickEdit && quickEditPage && /*#__PURE__*/_react.default.createElement(_FormPage.default, {
|
|
220
222
|
page: quickEditPage,
|
|
221
223
|
onAction: function onAction(action, patch) {
|
|
@@ -238,8 +240,7 @@ SummaryCard.propTypes = {
|
|
|
238
240
|
id: _propTypes.default.string.isRequired,
|
|
239
241
|
entryData: _propTypes.default.shape({
|
|
240
242
|
id: _propTypes.default.string.isRequired,
|
|
241
|
-
index: _propTypes.default.number.isRequired
|
|
242
|
-
isDuplicate: _propTypes.default.bool
|
|
243
|
+
index: _propTypes.default.number.isRequired
|
|
243
244
|
}).isRequired,
|
|
244
245
|
config: _propTypes.default.shape({
|
|
245
246
|
className: _propTypes.default.string,
|
|
@@ -266,7 +267,8 @@ SummaryCard.propTypes = {
|
|
|
266
267
|
}))
|
|
267
268
|
}),
|
|
268
269
|
detailsTitle: _propTypes.default.string,
|
|
269
|
-
listView: _propTypes.default.bool
|
|
270
|
+
listView: _propTypes.default.bool,
|
|
271
|
+
focusOn: _propTypes.default.bool
|
|
270
272
|
}).isRequired,
|
|
271
273
|
masterPage: _propTypes.default.shape({
|
|
272
274
|
childPages: _propTypes.default.arrayOf(_propTypes.default.shape({
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _react = require("@testing-library/react");
|
|
4
|
+
require("@testing-library/jest-dom/extend-expect");
|
|
4
5
|
var _react2 = _interopRequireDefault(require("react"));
|
|
5
6
|
var _copReactComponents = require("@ukhomeoffice/cop-react-components");
|
|
6
7
|
var _testUtils = require("react-dom/test-utils");
|
|
@@ -582,6 +583,62 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
582
583
|
headerActionDiv = _checkSetup18.headerActionDiv;
|
|
583
584
|
expect(headerActionDiv.children.length).toEqual(0);
|
|
584
585
|
});
|
|
586
|
+
it('should focus on the most recently duplicated item', function () {
|
|
587
|
+
var entryData = {
|
|
588
|
+
id: ID,
|
|
589
|
+
isDuplicate: true
|
|
590
|
+
};
|
|
591
|
+
var config = {
|
|
592
|
+
duplicateAction: {
|
|
593
|
+
label: 'Duplicate Label',
|
|
594
|
+
aria_label: 'Duplicate Aria Label'
|
|
595
|
+
}
|
|
596
|
+
};
|
|
597
|
+
var onDuplicate = jest.fn();
|
|
598
|
+
var _renderWithValidation20 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
599
|
+
id: ID,
|
|
600
|
+
entryData: entryData,
|
|
601
|
+
config: config,
|
|
602
|
+
onDuplicate: onDuplicate,
|
|
603
|
+
parentCollectionName: "parent",
|
|
604
|
+
pages: [],
|
|
605
|
+
formData: {},
|
|
606
|
+
hideDetails: true,
|
|
607
|
+
masterPage: {
|
|
608
|
+
childPages: []
|
|
609
|
+
}
|
|
610
|
+
})),
|
|
611
|
+
getByTestId = _renderWithValidation20.getByTestId;
|
|
612
|
+
var updatedConfig = {
|
|
613
|
+
focusOn: true,
|
|
614
|
+
quickEdit: true
|
|
615
|
+
};
|
|
616
|
+
|
|
617
|
+
// Rerender the component with updated config
|
|
618
|
+
var _renderWithValidation21 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
619
|
+
id: ID,
|
|
620
|
+
entryData: entryData,
|
|
621
|
+
config: updatedConfig,
|
|
622
|
+
parentCollectionName: "parent",
|
|
623
|
+
pages: [],
|
|
624
|
+
formData: {},
|
|
625
|
+
hideDetails: true,
|
|
626
|
+
masterPage: {
|
|
627
|
+
childPages: []
|
|
628
|
+
}
|
|
629
|
+
})),
|
|
630
|
+
getByTestIdRerender = _renderWithValidation21.getByTestId;
|
|
631
|
+
|
|
632
|
+
// check that focus isn't on the initial component
|
|
633
|
+
var initialComponent = getByTestId('duplicate-button');
|
|
634
|
+
expect(initialComponent).toBeInTheDocument();
|
|
635
|
+
expect(initialComponent).not.toHaveFocus();
|
|
636
|
+
|
|
637
|
+
// check that the focus is on the newly duplicated component
|
|
638
|
+
var DuplicatedComponent = getByTestIdRerender('quickedit-button');
|
|
639
|
+
expect(DuplicatedComponent).toBeInTheDocument();
|
|
640
|
+
expect(DuplicatedComponent).toHaveFocus();
|
|
641
|
+
});
|
|
585
642
|
});
|
|
586
643
|
describe('Quick Edit action button', function () {
|
|
587
644
|
var CONFIG = {
|
|
@@ -611,7 +668,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
611
668
|
}
|
|
612
669
|
}];
|
|
613
670
|
it('should render correctly', function () {
|
|
614
|
-
var
|
|
671
|
+
var _renderWithValidation22 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
615
672
|
id: ID,
|
|
616
673
|
entryData: ENTRY,
|
|
617
674
|
config: CONFIG,
|
|
@@ -621,7 +678,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
621
678
|
childPages: PAGES
|
|
622
679
|
}
|
|
623
680
|
})),
|
|
624
|
-
container =
|
|
681
|
+
container = _renderWithValidation22.container;
|
|
625
682
|
var _checkSetup19 = checkSetup(container),
|
|
626
683
|
headerActionDiv = _checkSetup19.headerActionDiv;
|
|
627
684
|
expect(headerActionDiv.children.length).toEqual(1);
|
|
@@ -652,7 +709,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
652
709
|
});
|
|
653
710
|
|
|
654
711
|
it('should not render when no config is provided for it', function () {
|
|
655
|
-
var
|
|
712
|
+
var _renderWithValidation23 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
656
713
|
id: ID,
|
|
657
714
|
entryData: ENTRY,
|
|
658
715
|
config: {},
|
|
@@ -662,7 +719,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
662
719
|
childPages: PAGES
|
|
663
720
|
}
|
|
664
721
|
})),
|
|
665
|
-
container =
|
|
722
|
+
container = _renderWithValidation23.container;
|
|
666
723
|
var _checkSetup20 = checkSetup(container),
|
|
667
724
|
headerActionDiv = _checkSetup20.headerActionDiv;
|
|
668
725
|
expect(headerActionDiv.children.length).toEqual(0);
|
|
@@ -707,7 +764,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
707
764
|
entryId: '123',
|
|
708
765
|
error: 'top-level error message'
|
|
709
766
|
}];
|
|
710
|
-
var
|
|
767
|
+
var _renderWithValidation24 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCardValidationContext.default, {
|
|
711
768
|
entryId: CUSTOM_ENTRY.id,
|
|
712
769
|
topLevelErrors: TOP_LEVEL_ERRORS
|
|
713
770
|
}, /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
@@ -720,7 +777,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
720
777
|
childPages: PAGES
|
|
721
778
|
}
|
|
722
779
|
}))),
|
|
723
|
-
container =
|
|
780
|
+
container = _renderWithValidation24.container;
|
|
724
781
|
var _checkSetup21 = checkSetup(container),
|
|
725
782
|
headerActionDiv = _checkSetup21.headerActionDiv;
|
|
726
783
|
expect(headerActionDiv.children.length).toEqual(1);
|
|
@@ -742,7 +799,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
742
799
|
expect(errorSummary.textContent).toContain(TOP_LEVEL_ERRORS[0].error);
|
|
743
800
|
});
|
|
744
801
|
it('should only show errors from validation when it happens, ignoring top-level errors', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
745
|
-
var TOP_LEVEL_ERRORS,
|
|
802
|
+
var TOP_LEVEL_ERRORS, _renderWithValidation25, container, _checkSetup22, headerActionDiv, editButton, quickEdit, errorSummary, component, componentInput, quickEditButtons, saveButton;
|
|
746
803
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
747
804
|
while (1) switch (_context3.prev = _context3.next) {
|
|
748
805
|
case 0:
|
|
@@ -751,7 +808,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
751
808
|
entryId: '123',
|
|
752
809
|
error: 'top-level error message'
|
|
753
810
|
}];
|
|
754
|
-
|
|
811
|
+
_renderWithValidation25 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCardValidationContext.default, {
|
|
755
812
|
entryId: CUSTOM_ENTRY.id,
|
|
756
813
|
topLevelErrors: TOP_LEVEL_ERRORS
|
|
757
814
|
}, /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
@@ -764,7 +821,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
764
821
|
childPages: PAGES
|
|
765
822
|
},
|
|
766
823
|
onQuickEdit: function onQuickEdit() {}
|
|
767
|
-
}))), container =
|
|
824
|
+
}))), container = _renderWithValidation25.container;
|
|
768
825
|
_checkSetup22 = checkSetup(container), headerActionDiv = _checkSetup22.headerActionDiv;
|
|
769
826
|
expect(headerActionDiv.children.length).toEqual(1);
|
|
770
827
|
|
|
@@ -864,7 +921,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
864
921
|
}
|
|
865
922
|
}];
|
|
866
923
|
it('should render correctly', function () {
|
|
867
|
-
var
|
|
924
|
+
var _renderWithValidation26 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
868
925
|
id: ID,
|
|
869
926
|
entryData: ENTRY,
|
|
870
927
|
config: CONFIG,
|
|
@@ -874,7 +931,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
874
931
|
childPages: PAGES
|
|
875
932
|
}
|
|
876
933
|
})),
|
|
877
|
-
container =
|
|
934
|
+
container = _renderWithValidation26.container;
|
|
878
935
|
var _checkSetup23 = checkSetup(container),
|
|
879
936
|
headerActionDiv = _checkSetup23.headerActionDiv;
|
|
880
937
|
expect(headerActionDiv.children.length).toEqual(1);
|
|
@@ -910,7 +967,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
910
967
|
return ON_SUBMIT_CALLS.push(patch);
|
|
911
968
|
}
|
|
912
969
|
};
|
|
913
|
-
var
|
|
970
|
+
var _renderWithValidation27 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
914
971
|
id: ID,
|
|
915
972
|
entryData: ENTRY,
|
|
916
973
|
config: CONFIG,
|
|
@@ -922,7 +979,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
922
979
|
}), {
|
|
923
980
|
hooks: hooks
|
|
924
981
|
}),
|
|
925
|
-
container =
|
|
982
|
+
container = _renderWithValidation27.container;
|
|
926
983
|
var _checkSetup24 = checkSetup(container),
|
|
927
984
|
headerActionDiv = _checkSetup24.headerActionDiv;
|
|
928
985
|
|
|
@@ -938,7 +995,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
938
995
|
expect(ON_SUBMIT_CALLS.length).toEqual(0);
|
|
939
996
|
});
|
|
940
997
|
it('should return after local validation if errors are present', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
|
|
941
|
-
var ON_SUBMIT_CALLS, hooks, ON_QUICK_EDIT_CALLS, ON_QUICK_EDIT,
|
|
998
|
+
var ON_SUBMIT_CALLS, hooks, ON_QUICK_EDIT_CALLS, ON_QUICK_EDIT, _renderWithValidation28, container, _checkSetup25, headerActionDiv, editButton, quickEdit, component, componentInput, quickEditButtons, saveButton;
|
|
942
999
|
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
943
1000
|
while (1) switch (_context6.prev = _context6.next) {
|
|
944
1001
|
case 0:
|
|
@@ -953,7 +1010,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
953
1010
|
var target = _ref5.target;
|
|
954
1011
|
ON_QUICK_EDIT_CALLS.push(target);
|
|
955
1012
|
};
|
|
956
|
-
|
|
1013
|
+
_renderWithValidation28 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
957
1014
|
id: ID,
|
|
958
1015
|
entryData: _objectSpread(_objectSpread({}, ENTRY), {}, {
|
|
959
1016
|
index: 0
|
|
@@ -971,7 +1028,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
971
1028
|
}
|
|
972
1029
|
}), {
|
|
973
1030
|
hooks: hooks
|
|
974
|
-
}), container =
|
|
1031
|
+
}), container = _renderWithValidation28.container;
|
|
975
1032
|
_checkSetup25 = checkSetup(container), headerActionDiv = _checkSetup25.headerActionDiv;
|
|
976
1033
|
editButton = headerActionDiv.children[0];
|
|
977
1034
|
_react.fireEvent.click(editButton, {});
|
|
@@ -1019,7 +1076,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
1019
1076
|
}, _callee6);
|
|
1020
1077
|
})));
|
|
1021
1078
|
it('should run hook validation when local validation is passed', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
|
|
1022
|
-
var ON_SUBMIT_CALLS, hooks, ON_QUICK_EDIT_CALLS, ON_QUICK_EDIT,
|
|
1079
|
+
var ON_SUBMIT_CALLS, hooks, ON_QUICK_EDIT_CALLS, ON_QUICK_EDIT, _renderWithValidation29, container, _checkSetup26, headerActionDiv, editButton, quickEdit, component, componentInput, quickEditButtons, saveButton;
|
|
1023
1080
|
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
1024
1081
|
while (1) switch (_context8.prev = _context8.next) {
|
|
1025
1082
|
case 0:
|
|
@@ -1038,7 +1095,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
1038
1095
|
var target = _ref9.target;
|
|
1039
1096
|
ON_QUICK_EDIT_CALLS.push(target);
|
|
1040
1097
|
};
|
|
1041
|
-
|
|
1098
|
+
_renderWithValidation29 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
1042
1099
|
id: ID,
|
|
1043
1100
|
entryData: ENTRY,
|
|
1044
1101
|
config: CONFIG,
|
|
@@ -1054,7 +1111,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
1054
1111
|
}
|
|
1055
1112
|
}), {
|
|
1056
1113
|
hooks: hooks
|
|
1057
|
-
}), container =
|
|
1114
|
+
}), container = _renderWithValidation29.container;
|
|
1058
1115
|
_checkSetup26 = checkSetup(container), headerActionDiv = _checkSetup26.headerActionDiv;
|
|
1059
1116
|
editButton = headerActionDiv.children[0];
|
|
1060
1117
|
_react.fireEvent.click(editButton, {});
|
|
@@ -1092,7 +1149,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
1092
1149
|
}, _callee8);
|
|
1093
1150
|
})));
|
|
1094
1151
|
it('should apply changes if no errors are present', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
|
|
1095
|
-
var ON_SUBMIT_CALLS, hooks, ON_QUICK_EDIT_CALLS, ON_QUICK_EDIT,
|
|
1152
|
+
var ON_SUBMIT_CALLS, hooks, ON_QUICK_EDIT_CALLS, ON_QUICK_EDIT, _renderWithValidation30, container, _checkSetup27, headerActionDiv, editButton, quickEdit, component, componentInput, quickEditButtons, saveButton;
|
|
1096
1153
|
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
1097
1154
|
while (1) switch (_context10.prev = _context10.next) {
|
|
1098
1155
|
case 0:
|
|
@@ -1107,7 +1164,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
1107
1164
|
var target = _ref12.target;
|
|
1108
1165
|
ON_QUICK_EDIT_CALLS.push(target);
|
|
1109
1166
|
};
|
|
1110
|
-
|
|
1167
|
+
_renderWithValidation30 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCardValidationContext.default, {
|
|
1111
1168
|
entryId: "id",
|
|
1112
1169
|
topLevelErrors: [],
|
|
1113
1170
|
clearTopLevelErrorsForCard: function clearTopLevelErrorsForCard() {}
|
|
@@ -1130,7 +1187,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
1130
1187
|
}
|
|
1131
1188
|
})), {
|
|
1132
1189
|
hooks: hooks
|
|
1133
|
-
}), container =
|
|
1190
|
+
}), container = _renderWithValidation30.container;
|
|
1134
1191
|
_checkSetup27 = checkSetup(container), headerActionDiv = _checkSetup27.headerActionDiv;
|
|
1135
1192
|
editButton = headerActionDiv.children[0];
|
|
1136
1193
|
_react.fireEvent.click(editButton, {});
|
|
@@ -1169,7 +1226,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
1169
1226
|
}, _callee10);
|
|
1170
1227
|
})));
|
|
1171
1228
|
it('should remove the isDuplicate flag on a sucessful quick edit', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
|
|
1172
|
-
var ON_SUBMIT_CALLS, hooks, ON_QUICK_EDIT_CALLS, ON_QUICK_EDIT,
|
|
1229
|
+
var ON_SUBMIT_CALLS, hooks, ON_QUICK_EDIT_CALLS, ON_QUICK_EDIT, _renderWithValidation31, container, _checkSetup28, headerActionDiv, editButton, quickEdit, component, componentInput, quickEditButtons, saveButton;
|
|
1173
1230
|
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
1174
1231
|
while (1) switch (_context12.prev = _context12.next) {
|
|
1175
1232
|
case 0:
|
|
@@ -1184,7 +1241,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
1184
1241
|
var target = _ref15.target;
|
|
1185
1242
|
ON_QUICK_EDIT_CALLS.push(target);
|
|
1186
1243
|
};
|
|
1187
|
-
|
|
1244
|
+
_renderWithValidation31 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCardValidationContext.default, {
|
|
1188
1245
|
entryId: "id",
|
|
1189
1246
|
topLevelErrors: [],
|
|
1190
1247
|
clearTopLevelErrorsForCard: function clearTopLevelErrorsForCard() {}
|
|
@@ -1208,7 +1265,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
1208
1265
|
}
|
|
1209
1266
|
})), {
|
|
1210
1267
|
hooks: hooks
|
|
1211
|
-
}), container =
|
|
1268
|
+
}), container = _renderWithValidation31.container;
|
|
1212
1269
|
_checkSetup28 = checkSetup(container), headerActionDiv = _checkSetup28.headerActionDiv;
|
|
1213
1270
|
editButton = headerActionDiv.children[0];
|
|
1214
1271
|
_react.fireEvent.click(editButton, {});
|
|
@@ -1255,7 +1312,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
1255
1312
|
title: 'Title',
|
|
1256
1313
|
details: DETAILS
|
|
1257
1314
|
};
|
|
1258
|
-
var
|
|
1315
|
+
var _renderWithValidation32 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
1259
1316
|
id: ID,
|
|
1260
1317
|
entryData: ENTRY,
|
|
1261
1318
|
config: CONFIG,
|
|
@@ -1266,7 +1323,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
1266
1323
|
childPages: []
|
|
1267
1324
|
}
|
|
1268
1325
|
})),
|
|
1269
|
-
container =
|
|
1326
|
+
container = _renderWithValidation32.container;
|
|
1270
1327
|
var _checkSetup29 = checkSetup(container),
|
|
1271
1328
|
headerContentDiv = _checkSetup29.headerContentDiv;
|
|
1272
1329
|
var headerDetails = headerContentDiv.children[1];
|
|
@@ -1293,7 +1350,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
1293
1350
|
}]
|
|
1294
1351
|
}]
|
|
1295
1352
|
};
|
|
1296
|
-
var
|
|
1353
|
+
var _renderWithValidation33 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
1297
1354
|
id: ID,
|
|
1298
1355
|
entryData: _objectSpread(_objectSpread({}, ENTRY), {}, {
|
|
1299
1356
|
field: true
|
|
@@ -1306,7 +1363,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
1306
1363
|
childPages: []
|
|
1307
1364
|
}
|
|
1308
1365
|
})),
|
|
1309
|
-
container =
|
|
1366
|
+
container = _renderWithValidation33.container;
|
|
1310
1367
|
var _checkSetup30 = checkSetup(container),
|
|
1311
1368
|
headerContentDiv = _checkSetup30.headerContentDiv;
|
|
1312
1369
|
var headerDetails = headerContentDiv.children[1];
|
|
@@ -1319,7 +1376,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
1319
1376
|
title: 'Title',
|
|
1320
1377
|
details: ''
|
|
1321
1378
|
};
|
|
1322
|
-
var
|
|
1379
|
+
var _renderWithValidation34 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
1323
1380
|
id: ID,
|
|
1324
1381
|
entryData: ENTRY,
|
|
1325
1382
|
config: CONFIG,
|
|
@@ -1330,7 +1387,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
1330
1387
|
childPages: []
|
|
1331
1388
|
}
|
|
1332
1389
|
})),
|
|
1333
|
-
container =
|
|
1390
|
+
container = _renderWithValidation34.container;
|
|
1334
1391
|
var _checkSetup31 = checkSetup(container),
|
|
1335
1392
|
headerContentDiv = _checkSetup31.headerContentDiv;
|
|
1336
1393
|
// If no details are provided, we expect only the header title to be rendered.
|
|
@@ -1347,7 +1404,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
1347
1404
|
title: 'Title',
|
|
1348
1405
|
details: DETAILS
|
|
1349
1406
|
};
|
|
1350
|
-
var
|
|
1407
|
+
var _renderWithValidation35 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
1351
1408
|
id: ID,
|
|
1352
1409
|
entryData: INTERPOLATED_ENTRY,
|
|
1353
1410
|
config: CONFIG,
|
|
@@ -1358,7 +1415,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
1358
1415
|
childPages: []
|
|
1359
1416
|
}
|
|
1360
1417
|
})),
|
|
1361
|
-
container =
|
|
1418
|
+
container = _renderWithValidation35.container;
|
|
1362
1419
|
var _checkSetup32 = checkSetup(container),
|
|
1363
1420
|
headerContentDiv = _checkSetup32.headerContentDiv;
|
|
1364
1421
|
var headerDetails = headerContentDiv.children[1];
|
|
@@ -1369,7 +1426,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
1369
1426
|
var CONFIG = {
|
|
1370
1427
|
title: 'Title'
|
|
1371
1428
|
};
|
|
1372
|
-
var
|
|
1429
|
+
var _renderWithValidation36 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
1373
1430
|
id: ID,
|
|
1374
1431
|
entryData: ENTRY,
|
|
1375
1432
|
config: CONFIG,
|
|
@@ -1380,7 +1437,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
1380
1437
|
childPages: []
|
|
1381
1438
|
}
|
|
1382
1439
|
})),
|
|
1383
|
-
container =
|
|
1440
|
+
container = _renderWithValidation36.container;
|
|
1384
1441
|
var _checkSetup33 = checkSetup(container),
|
|
1385
1442
|
headerContentDiv = _checkSetup33.headerContentDiv;
|
|
1386
1443
|
var headerDetails = headerContentDiv.querySelector("#".concat(ID, ".titleDetail"));
|
|
@@ -1392,7 +1449,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
1392
1449
|
title: 'Title',
|
|
1393
1450
|
details: DETAILS
|
|
1394
1451
|
};
|
|
1395
|
-
var
|
|
1452
|
+
var _renderWithValidation37 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
1396
1453
|
id: ID,
|
|
1397
1454
|
entryData: ENTRY,
|
|
1398
1455
|
config: CONFIG,
|
|
@@ -1404,7 +1461,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
1404
1461
|
childPages: []
|
|
1405
1462
|
}
|
|
1406
1463
|
})),
|
|
1407
|
-
container =
|
|
1464
|
+
container = _renderWithValidation37.container;
|
|
1408
1465
|
var detailsComponent = container.querySelector('.details');
|
|
1409
1466
|
expect(detailsComponent).toBeNull();
|
|
1410
1467
|
});
|
|
@@ -55,6 +55,7 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input ==
|
|
|
55
55
|
* @returns Page suitble for rendering in a QuickEdit
|
|
56
56
|
*/
|
|
57
57
|
var getQuickEditPage = function getQuickEditPage(masterPage, formData, entryData) {
|
|
58
|
+
var _masterPage$collectio;
|
|
58
59
|
if (!masterPage) {
|
|
59
60
|
return null;
|
|
60
61
|
}
|
|
@@ -113,7 +114,7 @@ var getQuickEditPage = function getQuickEditPage(masterPage, formData, entryData
|
|
|
113
114
|
// Remove ID to stop overwriting top-level form ID.
|
|
114
115
|
var id = entryData.id,
|
|
115
116
|
entryWithNoId = _objectWithoutProperties(entryData, _excluded);
|
|
116
|
-
pageToReturn.formData = _objectSpread(_objectSpread({}, pageToReturn.formData), entryWithNoId);
|
|
117
|
+
pageToReturn.formData = _objectSpread(_objectSpread(_objectSpread({}, pageToReturn.formData), entryWithNoId), {}, _defineProperty({}, "".concat((_masterPage$collectio = masterPage.collection) === null || _masterPage$collectio === void 0 || (_masterPage$collectio = _masterPage$collectio.name) === null || _masterPage$collectio === void 0 ? void 0 : _masterPage$collectio.split('.').pop(), "ActiveId"), entryData.id));
|
|
117
118
|
delete pageToReturn.title;
|
|
118
119
|
delete pageToReturn.collection;
|
|
119
120
|
return pageToReturn;
|
|
@@ -19,6 +19,9 @@ describe('Utils.CollectionPage.getQuickEditPage', function () {
|
|
|
19
19
|
}]
|
|
20
20
|
};
|
|
21
21
|
var MASTER_PAGE = {
|
|
22
|
+
collection: {
|
|
23
|
+
name: 'entries'
|
|
24
|
+
},
|
|
22
25
|
childPages: [{
|
|
23
26
|
id: 'firstPage',
|
|
24
27
|
name: 'firstPage',
|
|
@@ -132,4 +135,9 @@ describe('Utils.CollectionPage.getQuickEditPage', function () {
|
|
|
132
135
|
var createdPage = (0, _getQuickEditPage.default)(MASTER_PAGE, FORM_DATA, CUSTOM_ENTRY_DATA);
|
|
133
136
|
expect(createdPage).toMatchObject(CUSTOM_OUTPUT);
|
|
134
137
|
});
|
|
138
|
+
it('should return a quick edit page with the activeId for the current collection correctly set', function () {
|
|
139
|
+
var createdPage = (0, _getQuickEditPage.default)(MASTER_PAGE, FORM_DATA, ENTRY_DATA);
|
|
140
|
+
expect(createdPage.formData.entriesActiveId).toEqual('123');
|
|
141
|
+
expect(createdPage).toMatchObject(EXPECTED_OUTPUT);
|
|
142
|
+
});
|
|
135
143
|
});
|