@onehat/ui 0.3.282 → 0.3.284
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 +1 -1
- package/src/Components/Editor/Editor.js +0 -1
- package/src/Components/Editor/InlineEditor.js +163 -0
- package/src/Components/Grid/Grid.js +4 -5
- package/src/Components/Hoc/withInlineEditor.js +22 -142
- package/src/Functions/Cypress/button_functions.js +84 -0
- package/src/Functions/Cypress/common_functions.js +108 -0
- package/src/Functions/Cypress/crud_functions.js +694 -0
- package/src/Functions/Cypress/dom_functions.js +43 -0
- package/src/Functions/Cypress/form_functions.js +510 -0
- package/src/Functions/Cypress/grid_functions.js +269 -0
- package/src/Functions/Cypress/index.js +19 -0
- package/src/Functions/Cypress/navigation_functions.js +77 -0
- package/src/Functions/Cypress/utilities.js +109 -0
- package/src/Styles/Global.css +5 -0
|
@@ -0,0 +1,694 @@
|
|
|
1
|
+
import {
|
|
2
|
+
fixInflector,
|
|
3
|
+
getLastPartOfPath,
|
|
4
|
+
} from './utilities';
|
|
5
|
+
import {
|
|
6
|
+
loginAsSuper,
|
|
7
|
+
logout,
|
|
8
|
+
navigateViaTabOrHomeButtonTo,
|
|
9
|
+
} from './navigation_functions';
|
|
10
|
+
import {
|
|
11
|
+
getDomNode,
|
|
12
|
+
getDomNodes,
|
|
13
|
+
} from './dom_functions';
|
|
14
|
+
import {
|
|
15
|
+
hasRowWithFieldValue,
|
|
16
|
+
getRowWithFieldValue,
|
|
17
|
+
selectGridRowById,
|
|
18
|
+
selectGridRowIfNotAlreadySelectedById,
|
|
19
|
+
verifyGridRecordDoesNotExistByValue,
|
|
20
|
+
verifyGridRecordExistsByValue,
|
|
21
|
+
verifyGridRecordExistsById,
|
|
22
|
+
verifyGridRecordDoesNotExistById,
|
|
23
|
+
verifyGridRowIsSelectedById,
|
|
24
|
+
getModelFromGridName,
|
|
25
|
+
getModelFromGridSelector,
|
|
26
|
+
getGridRowSelectorById,
|
|
27
|
+
} from './grid_functions';
|
|
28
|
+
import {
|
|
29
|
+
verifyNoErrorBox,
|
|
30
|
+
} from './common_functions';
|
|
31
|
+
import {
|
|
32
|
+
fillForm,
|
|
33
|
+
getFormValues,
|
|
34
|
+
} from './form_functions';
|
|
35
|
+
import {
|
|
36
|
+
clickAddButton,
|
|
37
|
+
clickSaveButton,
|
|
38
|
+
clickEditButton,
|
|
39
|
+
clickDeleteButton,
|
|
40
|
+
clickDuplicateButton,
|
|
41
|
+
clickReloadButton,
|
|
42
|
+
clickCloseButton,
|
|
43
|
+
clickCancelButton,
|
|
44
|
+
clickOkButton,
|
|
45
|
+
clickYesButton,
|
|
46
|
+
clickNoButton,
|
|
47
|
+
clickToEditButton,
|
|
48
|
+
clickToEditButtonIfExists,
|
|
49
|
+
clickToViewButton,
|
|
50
|
+
clickToViewButtonIfExists,
|
|
51
|
+
clickTrigger,
|
|
52
|
+
clickButton,
|
|
53
|
+
clickButtonIfExists,
|
|
54
|
+
toFullMode,
|
|
55
|
+
toSideMode,
|
|
56
|
+
} from './button_functions';
|
|
57
|
+
import Inflector from 'inflector-js';
|
|
58
|
+
import _ from 'lodash';
|
|
59
|
+
const $ = Cypress.$;
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
export function crudCombo(selector, newData, editData, schema, ancillaryData, level = 0) {
|
|
63
|
+
cy.then(() => {
|
|
64
|
+
Cypress.log({ name: 'crudCombo' });
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
const
|
|
68
|
+
fieldName = selector[1].match(/^field-(.*)$/)[1],
|
|
69
|
+
gridSelector = selector[0] + '/' + fieldName + '/grid';
|
|
70
|
+
|
|
71
|
+
clickTrigger(selector);
|
|
72
|
+
|
|
73
|
+
crudWindowedGridRecord(gridSelector, newData, editData, schema, ancillaryData, level +1);
|
|
74
|
+
|
|
75
|
+
clickTrigger(selector);
|
|
76
|
+
}
|
|
77
|
+
export function crudTag(selector, newData, editData, schema, ancillaryData, level = 0) {
|
|
78
|
+
cy.then(() => {
|
|
79
|
+
Cypress.log({ name: 'crudTag' });
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
const
|
|
83
|
+
fieldName = selector[1].match(/^field-(.*)$/)[1],
|
|
84
|
+
gridSelector = selector[0] + '/' + fieldName + '/combo/grid';
|
|
85
|
+
|
|
86
|
+
clickTrigger(selector);
|
|
87
|
+
|
|
88
|
+
// When crudding a tag, on edit, re-selecting the row can put up "already selected value" error box.
|
|
89
|
+
// Need to explicitly ignore this, dismiss the error, and continue on
|
|
90
|
+
|
|
91
|
+
crudWindowedGridRecord(gridSelector, newData, editData, schema, ancillaryData, level +1);
|
|
92
|
+
|
|
93
|
+
clickTrigger(selector);
|
|
94
|
+
}
|
|
95
|
+
export function crudSideGridRecord(gridSelector, newData, editData, schema, ancillaryData, level = 0) {
|
|
96
|
+
// NOTE: the 'level' arg allows this fn to be called recursively
|
|
97
|
+
// and to use the @id alias correctly, keeping track of the level of recursion
|
|
98
|
+
// so the CRUD operations don't step on each other at different levels.
|
|
99
|
+
cy.then(() => {
|
|
100
|
+
Cypress.log({ name: 'crudSideGridRecord ' + gridSelector });
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
getDomNode(gridSelector).scrollIntoView();
|
|
104
|
+
|
|
105
|
+
// add
|
|
106
|
+
addGridRecord(gridSelector, newData, schema, ancillaryData, level); // saves the id in @id
|
|
107
|
+
|
|
108
|
+
cy.get('@id' + level).then((id) => {
|
|
109
|
+
|
|
110
|
+
// read
|
|
111
|
+
clickReloadButton(gridSelector);
|
|
112
|
+
cy.wait(1000); // allow time for grid to load
|
|
113
|
+
verifyGridRecordExistsById(gridSelector, id);
|
|
114
|
+
|
|
115
|
+
// edit
|
|
116
|
+
editGridRecord(gridSelector, editData, schema, id);
|
|
117
|
+
|
|
118
|
+
// delete
|
|
119
|
+
verifyGridRecordExistsById(gridSelector, id);
|
|
120
|
+
deleteGridRecord(gridSelector, id);
|
|
121
|
+
verifyGridRecordDoesNotExistById(gridSelector, id);
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
export function crudWindowedGridRecord(gridSelector, newData, editData, schema, ancillaryData, level = 0) {
|
|
125
|
+
|
|
126
|
+
cy.then(() => {
|
|
127
|
+
Cypress.log({ name: 'crudWindowedGridRecord ' + gridSelector });
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
getDomNode(gridSelector).scrollIntoView();
|
|
131
|
+
|
|
132
|
+
// add
|
|
133
|
+
addWindowedGridRecord(gridSelector, newData, schema, ancillaryData, level); // saves the id in @id
|
|
134
|
+
|
|
135
|
+
cy.get('@id' + level).then((id) => {
|
|
136
|
+
|
|
137
|
+
cy.then(() => {
|
|
138
|
+
Cypress.log({ name: 'crudWindowedGridRecord: continue thru CRUD ' + gridSelector });
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
// read
|
|
142
|
+
clickReloadButton(gridSelector);
|
|
143
|
+
cy.wait(1000); // allow time for grid to load
|
|
144
|
+
verifyGridRecordExistsById(gridSelector, id);
|
|
145
|
+
|
|
146
|
+
// edit
|
|
147
|
+
editWindowedGridRecord(gridSelector, editData, schema, id);
|
|
148
|
+
|
|
149
|
+
// delete
|
|
150
|
+
verifyGridRecordExistsById(gridSelector, id);
|
|
151
|
+
deleteGridRecord(gridSelector, id);
|
|
152
|
+
verifyGridRecordDoesNotExistById(gridSelector, id);
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
export function crudInlineGridRecord(gridSelector, newData, editData, schema, ancillaryData, level = 0) {
|
|
156
|
+
|
|
157
|
+
cy.then(() => {
|
|
158
|
+
Cypress.log({ name: 'crudInlineGridRecord ' + gridSelector });
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
getDomNode(gridSelector).scrollIntoView();
|
|
162
|
+
|
|
163
|
+
// add
|
|
164
|
+
addInlineGridRecord(gridSelector, newData, schema, ancillaryData, level); // saves the id in @id
|
|
165
|
+
|
|
166
|
+
cy.get('@id' + level).then((id) => {
|
|
167
|
+
|
|
168
|
+
cy.then(() => {
|
|
169
|
+
Cypress.log({ name: 'crudWindowedGridRecord: continue thru CRUD ' + gridSelector });
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
// read
|
|
173
|
+
clickReloadButton(gridSelector);
|
|
174
|
+
cy.wait(1000); // allow time for grid to load
|
|
175
|
+
verifyGridRecordExistsById(gridSelector, id);
|
|
176
|
+
|
|
177
|
+
// edit
|
|
178
|
+
editInlineGridRecord(gridSelector, editData, schema, id);
|
|
179
|
+
|
|
180
|
+
// delete
|
|
181
|
+
verifyGridRecordExistsById(gridSelector, id);
|
|
182
|
+
deleteGridRecord(gridSelector, id);
|
|
183
|
+
verifyGridRecordDoesNotExistById(gridSelector, id);
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
export function addGridRecord(gridSelector, fieldValues, schema, ancillaryData, level = 0) {
|
|
187
|
+
|
|
188
|
+
cy.then(() => {
|
|
189
|
+
Cypress.log({ name: 'addGridRecord ' + gridSelector });
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
const
|
|
193
|
+
editorSelector = gridSelector + '/editor',
|
|
194
|
+
viewerSelector = editorSelector + '/viewer',
|
|
195
|
+
formSelector = editorSelector + '/form';
|
|
196
|
+
|
|
197
|
+
clickAddButton(gridSelector);
|
|
198
|
+
getDomNode(formSelector).should('exist');
|
|
199
|
+
|
|
200
|
+
fillForm(formSelector, fieldValues, schema, level +1);
|
|
201
|
+
cy.wait(500); // allow validator to enable save button
|
|
202
|
+
// TODO: Change this to wait until save button is enabled
|
|
203
|
+
|
|
204
|
+
let method = 'add';
|
|
205
|
+
if (schema.repository.isRemotePhantomMode) {
|
|
206
|
+
method = 'edit';
|
|
207
|
+
}
|
|
208
|
+
cy.intercept('POST', '**/' + method + '**').as('waiter');
|
|
209
|
+
clickSaveButton(formSelector); // it's labeled 'Add' in the form, but is really the save button
|
|
210
|
+
cy.wait('@waiter');
|
|
211
|
+
|
|
212
|
+
verifyNoErrorBox();
|
|
213
|
+
|
|
214
|
+
cy.wait(1000); // allow temp id to be replaced by real one
|
|
215
|
+
|
|
216
|
+
// Get and save id of new record
|
|
217
|
+
getDomNode([gridSelector, 'row-selected']).then((row) => {
|
|
218
|
+
const parent = row[0].parentNode;
|
|
219
|
+
cy.wrap(parent).invoke('attr', 'data-testid').then((testId) => {
|
|
220
|
+
const id = testId.split('-')[1];
|
|
221
|
+
cy.wrap(id).as('id' + level);
|
|
222
|
+
});
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
if (!_.isEmpty(ancillaryData)) {
|
|
226
|
+
_.each(ancillaryData, (data) => {
|
|
227
|
+
const
|
|
228
|
+
model = data.model,
|
|
229
|
+
Models = fixInflector(Inflector.camelize(Inflector.pluralize(model))),
|
|
230
|
+
gridType = data.gridType,
|
|
231
|
+
schema = data.schema,
|
|
232
|
+
newData = data.newData,
|
|
233
|
+
editData = data.editData,
|
|
234
|
+
ancillaryData = data.ancillaryData,
|
|
235
|
+
ancillaryGridSelector = formSelector + '/' + (gridType || Models + 'GridEditor');
|
|
236
|
+
crudWindowedGridRecord(ancillaryGridSelector, newData, editData, schema, ancillaryData, level+1);
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
export function addWindowedGridRecord(gridSelector, fieldValues, schema, ancillaryData, level = 0) {
|
|
241
|
+
// adds the record as normal, then closes the editor window
|
|
242
|
+
|
|
243
|
+
cy.then(() => {
|
|
244
|
+
Cypress.log({ name: 'addWindowedGridRecord ' + gridSelector });
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
addGridRecord(gridSelector, fieldValues, schema, ancillaryData, level);
|
|
248
|
+
|
|
249
|
+
cy.then(() => {
|
|
250
|
+
Cypress.log({ name: 'addWindowedGridRecord: close window ' + gridSelector });
|
|
251
|
+
});
|
|
252
|
+
const formSelector = gridSelector + '/editor/form';
|
|
253
|
+
clickCloseButton(formSelector);
|
|
254
|
+
cy.wait(500); // allow window to close
|
|
255
|
+
// TODO: Change this to wait until window is closed
|
|
256
|
+
}
|
|
257
|
+
export function addInlineGridRecord(gridSelector, fieldValues, schema, ancillaryData, level = 0) {
|
|
258
|
+
// adds the record as normal, then closes the editor window
|
|
259
|
+
|
|
260
|
+
cy.then(() => {
|
|
261
|
+
Cypress.log({ name: 'addInlineGridRecord ' + gridSelector });
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
addGridRecord(gridSelector, fieldValues, schema, ancillaryData, level);
|
|
265
|
+
|
|
266
|
+
cy.then(() => {
|
|
267
|
+
Cypress.log({ name: 'addWindowedGridRecord: close window ' + gridSelector });
|
|
268
|
+
});
|
|
269
|
+
const formSelector = gridSelector + '/editor/form';
|
|
270
|
+
clickCloseButton(formSelector);
|
|
271
|
+
cy.wait(500); // allow window to close
|
|
272
|
+
// TODO: Change this to wait until window is closed
|
|
273
|
+
}
|
|
274
|
+
export function editGridRecord(gridSelector, fieldValues, schema, id, level = 0) {
|
|
275
|
+
|
|
276
|
+
cy.then(() => {
|
|
277
|
+
Cypress.log({ name: 'editGridRecord ' + gridSelector + ' ' + id});
|
|
278
|
+
});
|
|
279
|
+
|
|
280
|
+
selectGridRowIfNotAlreadySelectedById(gridSelector, id);
|
|
281
|
+
|
|
282
|
+
const
|
|
283
|
+
editorSelector = gridSelector + '/editor',
|
|
284
|
+
viewerSelector = editorSelector + '/viewer',
|
|
285
|
+
formSelector = editorSelector + '/form';
|
|
286
|
+
|
|
287
|
+
const gridName = getLastPartOfPath(gridSelector);
|
|
288
|
+
if (gridName.match(/SideGrid/)) { // as opposed to 'SideA' -- we want the side editor, not particular sides of another editor
|
|
289
|
+
// side editor
|
|
290
|
+
// switch to Edit mode if necessary
|
|
291
|
+
clickToEditButtonIfExists(viewerSelector);
|
|
292
|
+
} else {
|
|
293
|
+
// windowed or inline editor
|
|
294
|
+
clickEditButton(gridSelector);
|
|
295
|
+
}
|
|
296
|
+
cy.wait(1500); // allow form to build
|
|
297
|
+
getDomNode(formSelector).should('exist');
|
|
298
|
+
|
|
299
|
+
fillForm(formSelector, fieldValues, schema, level +1);
|
|
300
|
+
cy.wait(500); // allow validator to enable save button
|
|
301
|
+
// TODO: Change this to wait until save button is enabled
|
|
302
|
+
|
|
303
|
+
cy.intercept('POST', '**/edit**').as('waiter');
|
|
304
|
+
clickSaveButton(formSelector);
|
|
305
|
+
cy.wait('@waiter');
|
|
306
|
+
|
|
307
|
+
verifyNoErrorBox();
|
|
308
|
+
// cy.wait(1000);
|
|
309
|
+
|
|
310
|
+
}
|
|
311
|
+
export function editWindowedGridRecord(gridSelector, fieldValues, schema, id, level = 0) {
|
|
312
|
+
// edits the record as normal, then closes the editor window
|
|
313
|
+
|
|
314
|
+
cy.then(() => {
|
|
315
|
+
Cypress.log({ name: 'editWindowedGridRecord ' + gridSelector + ' ' + id});
|
|
316
|
+
});
|
|
317
|
+
|
|
318
|
+
editGridRecord(gridSelector, fieldValues, schema, id, level);
|
|
319
|
+
|
|
320
|
+
const formSelector = gridSelector + '/editor/form';
|
|
321
|
+
clickCloseButton(formSelector);
|
|
322
|
+
cy.wait(500); // allow window to close
|
|
323
|
+
// TODO: Change this to wait until window is closed
|
|
324
|
+
}
|
|
325
|
+
export function editInlineGridRecord(gridSelector, fieldValues, schema, id, level = 0) {
|
|
326
|
+
// edits the record as normal, then closes the editor window
|
|
327
|
+
|
|
328
|
+
cy.then(() => {
|
|
329
|
+
Cypress.log({ name: 'editWindowedGridRecord ' + gridSelector + ' ' + id});
|
|
330
|
+
});
|
|
331
|
+
|
|
332
|
+
editGridRecord(gridSelector, fieldValues, schema, id, level);
|
|
333
|
+
|
|
334
|
+
const formSelector = gridSelector + '/editor/form';
|
|
335
|
+
clickCloseButton(formSelector);
|
|
336
|
+
cy.wait(500); // allow window to close
|
|
337
|
+
// TODO: Change this to wait until window is closed
|
|
338
|
+
}
|
|
339
|
+
export function deleteGridRecord(gridSelector, id) {
|
|
340
|
+
|
|
341
|
+
cy.then(() => {
|
|
342
|
+
Cypress.log({ name: 'deleteGridRecord ' + gridSelector + ' ' + id });
|
|
343
|
+
});
|
|
344
|
+
|
|
345
|
+
selectGridRowIfNotAlreadySelectedById(gridSelector, id);
|
|
346
|
+
clickDeleteButton(gridSelector);
|
|
347
|
+
cy.wait(500); // allow confirmation box to appear
|
|
348
|
+
|
|
349
|
+
// Click OK on confirmation box
|
|
350
|
+
cy.intercept('POST', '**/delete**').as('waiter');
|
|
351
|
+
clickYesButton('AlertDialog');
|
|
352
|
+
cy.wait('@waiter');
|
|
353
|
+
|
|
354
|
+
verifyNoErrorBox();
|
|
355
|
+
// cy.wait(1000);
|
|
356
|
+
}
|
|
357
|
+
export function switchToEditModeIfNecessary(editorSelector) {
|
|
358
|
+
cy.then(() => {
|
|
359
|
+
Cypress.log({ name: 'switchToEditModeIfNecessary ' + editorSelector });
|
|
360
|
+
});
|
|
361
|
+
|
|
362
|
+
getDomNode(editorSelector).then((editor) => {
|
|
363
|
+
const btn = editor.find('.toEditBtn');
|
|
364
|
+
if (btn.length) {
|
|
365
|
+
cy.wrap(btn)
|
|
366
|
+
.click()
|
|
367
|
+
.wait(500); // allow form to switch to edit mode
|
|
368
|
+
}
|
|
369
|
+
});
|
|
370
|
+
}
|
|
371
|
+
export function switchToViewModeIfNecessary(editorSelector) {
|
|
372
|
+
cy.then(() => {
|
|
373
|
+
Cypress.log({ name: 'switchToViewModeIfNecessary ' + editorSelector });
|
|
374
|
+
});
|
|
375
|
+
|
|
376
|
+
getDomNode(editorSelector).then((editor) => {
|
|
377
|
+
const btn = editor.find('.toViewBtn');
|
|
378
|
+
if (btn.length) {
|
|
379
|
+
cy.wrap(btn)
|
|
380
|
+
.click()
|
|
381
|
+
.wait(500); // allow form to switch to edit mode
|
|
382
|
+
}
|
|
383
|
+
});
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
|
|
387
|
+
// Manager screen CRUD functions
|
|
388
|
+
export function runClosureTreeControlledManagerScreenCrudTests(model, schema, newData, editData) {
|
|
389
|
+
|
|
390
|
+
const
|
|
391
|
+
Models = Inflector.camelize(Inflector.pluralize(model)),
|
|
392
|
+
url = '/' + Inflector.dasherize(Inflector.underscore(Models));
|
|
393
|
+
|
|
394
|
+
describe(Models + 'Manager', () => {
|
|
395
|
+
|
|
396
|
+
beforeEach(function () {
|
|
397
|
+
loginAsSuper();
|
|
398
|
+
cy.restoreLocalStorage();
|
|
399
|
+
cy.url().then((currentUrl) => {
|
|
400
|
+
if (!currentUrl.endsWith(url)) {
|
|
401
|
+
navigateViaTabOrHomeButtonTo(url);
|
|
402
|
+
}
|
|
403
|
+
});
|
|
404
|
+
});
|
|
405
|
+
|
|
406
|
+
afterEach(function () {
|
|
407
|
+
cy.saveLocalStorage();
|
|
408
|
+
logout();
|
|
409
|
+
});
|
|
410
|
+
|
|
411
|
+
// TODO: This takes the standard runManagerScreenCrudTests
|
|
412
|
+
// and adds the control of the Fleet Tree. i.e. Check that the grids
|
|
413
|
+
// respond to the tree selection.
|
|
414
|
+
|
|
415
|
+
|
|
416
|
+
|
|
417
|
+
// it('CRUD in full mode', function() {
|
|
418
|
+
|
|
419
|
+
// const gridSelector = '/' + Models + 'FilteredGridEditor';
|
|
420
|
+
|
|
421
|
+
// toFullMode();
|
|
422
|
+
// cy.wait(500); // wait for grid to load
|
|
423
|
+
|
|
424
|
+
// // add
|
|
425
|
+
// addWindowedGridRecord(gridSelector, newData, schema); // saves the id in @id
|
|
426
|
+
|
|
427
|
+
// // cy.wrap(39).as('id');
|
|
428
|
+
// cy.get('@id').then((id) => {
|
|
429
|
+
|
|
430
|
+
// // read
|
|
431
|
+
// clickReloadButton(gridSelector);
|
|
432
|
+
// cy.wait(1000); // allow time for grid to load
|
|
433
|
+
// verifyGridRecordExistsById(gridSelector, id);
|
|
434
|
+
|
|
435
|
+
// // edit
|
|
436
|
+
// editWindowedGridRecord(gridSelector, editData, schema, id);
|
|
437
|
+
|
|
438
|
+
// // delete
|
|
439
|
+
// verifyGridRecordExistsById(gridSelector, id);
|
|
440
|
+
// deleteGridRecord(gridSelector, id);
|
|
441
|
+
// verifyGridRecordDoesNotExistById(gridSelector, id);
|
|
442
|
+
// });
|
|
443
|
+
|
|
444
|
+
// });
|
|
445
|
+
|
|
446
|
+
// it('CRUD in side mode', function() {
|
|
447
|
+
|
|
448
|
+
// const gridSelector = '/' + Models + 'FilteredSideGridEditor';
|
|
449
|
+
|
|
450
|
+
// toSideMode();
|
|
451
|
+
// cy.wait(1000); // wait for grid to load
|
|
452
|
+
|
|
453
|
+
// // add
|
|
454
|
+
// addGridRecord(gridSelector, newData, schema); // saves the id in @id
|
|
455
|
+
|
|
456
|
+
// cy.get('@id').then((id) => {
|
|
457
|
+
|
|
458
|
+
// // read
|
|
459
|
+
// clickReloadButton(gridSelector);
|
|
460
|
+
// cy.wait(1000); // allow time for grid to load
|
|
461
|
+
// verifyGridRecordExistsById(gridSelector, id);
|
|
462
|
+
|
|
463
|
+
// // edit
|
|
464
|
+
// editGridRecord(gridSelector, editData, schema, id);
|
|
465
|
+
|
|
466
|
+
// // delete
|
|
467
|
+
// verifyGridRecordExistsById(gridSelector, id);
|
|
468
|
+
// deleteGridRecord(gridSelector, id);
|
|
469
|
+
// verifyGridRecordDoesNotExistById(gridSelector, id);
|
|
470
|
+
// });
|
|
471
|
+
|
|
472
|
+
// });
|
|
473
|
+
|
|
474
|
+
});
|
|
475
|
+
|
|
476
|
+
}
|
|
477
|
+
export function runClosureTreeManagerScreenCrudTests(model, schema, newData, editData) {
|
|
478
|
+
|
|
479
|
+
const
|
|
480
|
+
Models = Inflector.camelize(Inflector.pluralize(model)),
|
|
481
|
+
url = '/' + Inflector.dasherize(Inflector.underscore(Models));
|
|
482
|
+
|
|
483
|
+
describe(Models + 'Manager', () => {
|
|
484
|
+
|
|
485
|
+
beforeEach(function () {
|
|
486
|
+
loginAsSuper();
|
|
487
|
+
cy.restoreLocalStorage();
|
|
488
|
+
cy.url().then((currentUrl) => {
|
|
489
|
+
if (!currentUrl.endsWith(url)) {
|
|
490
|
+
navigateViaTabOrHomeButtonTo(url);
|
|
491
|
+
}
|
|
492
|
+
});
|
|
493
|
+
});
|
|
494
|
+
|
|
495
|
+
afterEach(function () {
|
|
496
|
+
cy.saveLocalStorage();
|
|
497
|
+
logout();
|
|
498
|
+
});
|
|
499
|
+
|
|
500
|
+
it('CRUD ClosureTree', function() {
|
|
501
|
+
|
|
502
|
+
const treeSelector = '/' + Models + 'TreeEditor';
|
|
503
|
+
|
|
504
|
+
toFullMode();
|
|
505
|
+
cy.wait(500); // wait for tree to load
|
|
506
|
+
|
|
507
|
+
|
|
508
|
+
// TODO: Customize these for crudding a ClosureTree
|
|
509
|
+
|
|
510
|
+
|
|
511
|
+
|
|
512
|
+
|
|
513
|
+
|
|
514
|
+
// // add
|
|
515
|
+
// addWindowedGridRecord(treeSelector, newData, schema); // saves the id in @id
|
|
516
|
+
|
|
517
|
+
// // cy.wrap(39).as('id');
|
|
518
|
+
// cy.get('@id').then((id) => {
|
|
519
|
+
|
|
520
|
+
// // read
|
|
521
|
+
// clickReloadButton(treeSelector);
|
|
522
|
+
// cy.wait(1000); // allow time for tree to load
|
|
523
|
+
// verifyGridRecordExistsById(treeSelector, id);
|
|
524
|
+
|
|
525
|
+
// // edit
|
|
526
|
+
// editWindowedGridRecord(treeSelector, editData, schema, id);
|
|
527
|
+
|
|
528
|
+
// // delete
|
|
529
|
+
// verifyGridRecordExistsById(treeSelector, id);
|
|
530
|
+
// deleteGridRecord(treeSelector, id);
|
|
531
|
+
// verifyGridRecordDoesNotExistById(treeSelector, id);
|
|
532
|
+
// });
|
|
533
|
+
|
|
534
|
+
});
|
|
535
|
+
|
|
536
|
+
});
|
|
537
|
+
|
|
538
|
+
}
|
|
539
|
+
export function runInlineManagerScreenCrudTests(model, schema, newData, editData, ancillaryData) {
|
|
540
|
+
|
|
541
|
+
const
|
|
542
|
+
Models = fixInflector(Inflector.camelize(Inflector.pluralize(model))),
|
|
543
|
+
url = '/' + fixInflector(Inflector.dasherize(Inflector.underscore(Models)));
|
|
544
|
+
|
|
545
|
+
describe(Models + 'Manager', () => {
|
|
546
|
+
|
|
547
|
+
beforeEach(function () {
|
|
548
|
+
loginAsSuper();
|
|
549
|
+
cy.restoreLocalStorage();
|
|
550
|
+
cy.url().then((currentUrl) => {
|
|
551
|
+
if (!currentUrl.endsWith(url)) {
|
|
552
|
+
navigateViaTabOrHomeButtonTo(url);
|
|
553
|
+
}
|
|
554
|
+
});
|
|
555
|
+
});
|
|
556
|
+
|
|
557
|
+
afterEach(function () {
|
|
558
|
+
cy.saveLocalStorage();
|
|
559
|
+
logout();
|
|
560
|
+
});
|
|
561
|
+
|
|
562
|
+
it('CRUD with inline editor in full mode', function() {
|
|
563
|
+
|
|
564
|
+
const
|
|
565
|
+
managerSelector = '/' + Models + 'Manager',
|
|
566
|
+
gridSelector = '/' + Models + 'FilteredInlineGridEditor';
|
|
567
|
+
|
|
568
|
+
toFullMode(managerSelector);
|
|
569
|
+
cy.wait(500); // wait for grid to load
|
|
570
|
+
|
|
571
|
+
crudInlineGridRecord(gridSelector, newData, editData, schema, ancillaryData);
|
|
572
|
+
|
|
573
|
+
});
|
|
574
|
+
|
|
575
|
+
it('CRUD in side mode', function() {
|
|
576
|
+
|
|
577
|
+
const
|
|
578
|
+
managerSelector = '/' + Models + 'Manager',
|
|
579
|
+
gridSelector = '/' + Models + 'FilteredSideGridEditor';
|
|
580
|
+
|
|
581
|
+
toSideMode(managerSelector);
|
|
582
|
+
cy.wait(1000); // wait for grid to load
|
|
583
|
+
|
|
584
|
+
crudSideGridRecord(gridSelector, newData, editData, schema, ancillaryData);
|
|
585
|
+
|
|
586
|
+
});
|
|
587
|
+
|
|
588
|
+
});
|
|
589
|
+
|
|
590
|
+
}
|
|
591
|
+
export function runManagerScreenCrudTests(model, schema, newData, editData, ancillaryData) {
|
|
592
|
+
|
|
593
|
+
const
|
|
594
|
+
Models = fixInflector(Inflector.camelize(Inflector.pluralize(model))),
|
|
595
|
+
url = '/' + fixInflector(Inflector.dasherize(Inflector.underscore(Models)));
|
|
596
|
+
|
|
597
|
+
describe(Models + 'Manager', () => {
|
|
598
|
+
|
|
599
|
+
beforeEach(function () {
|
|
600
|
+
loginAsSuper();
|
|
601
|
+
cy.restoreLocalStorage();
|
|
602
|
+
cy.url().then((currentUrl) => {
|
|
603
|
+
if (!currentUrl.endsWith(url)) {
|
|
604
|
+
navigateViaTabOrHomeButtonTo(url);
|
|
605
|
+
}
|
|
606
|
+
});
|
|
607
|
+
});
|
|
608
|
+
|
|
609
|
+
// afterEach(function () {
|
|
610
|
+
// cy.saveLocalStorage();
|
|
611
|
+
// logout();
|
|
612
|
+
// });
|
|
613
|
+
|
|
614
|
+
it('CRUD in full mode', function() {
|
|
615
|
+
|
|
616
|
+
const
|
|
617
|
+
managerSelector = '/' + Models + 'Manager',
|
|
618
|
+
gridSelector = '/' + Models + 'FilteredGridEditor';
|
|
619
|
+
|
|
620
|
+
toFullMode(managerSelector);
|
|
621
|
+
cy.wait(500); // wait for grid to load
|
|
622
|
+
|
|
623
|
+
crudWindowedGridRecord(gridSelector, newData, editData, schema, ancillaryData);
|
|
624
|
+
|
|
625
|
+
});
|
|
626
|
+
|
|
627
|
+
it.skip('CRUD in side mode', function() {
|
|
628
|
+
|
|
629
|
+
const
|
|
630
|
+
managerSelector = '/' + Models + 'Manager',
|
|
631
|
+
gridSelector = '/' + Models + 'FilteredSideGridEditor';
|
|
632
|
+
|
|
633
|
+
toSideMode(managerSelector);
|
|
634
|
+
cy.wait(1000); // wait for grid to load
|
|
635
|
+
|
|
636
|
+
crudSideGridRecord(gridSelector, newData, editData, schema, ancillaryData);
|
|
637
|
+
|
|
638
|
+
});
|
|
639
|
+
|
|
640
|
+
});
|
|
641
|
+
|
|
642
|
+
}
|
|
643
|
+
export function runReportsManagerTests(reportData) {
|
|
644
|
+
|
|
645
|
+
const url = '/reports';
|
|
646
|
+
|
|
647
|
+
describe('ReportsManager', () => {
|
|
648
|
+
|
|
649
|
+
beforeEach(function () {
|
|
650
|
+
loginAsSuper();
|
|
651
|
+
cy.url().then((currentUrl) => {
|
|
652
|
+
if (!currentUrl.endsWith(url)) {
|
|
653
|
+
navigateViaTabOrHomeButtonTo(url);
|
|
654
|
+
}
|
|
655
|
+
});
|
|
656
|
+
});
|
|
657
|
+
|
|
658
|
+
_.each(reportData, (report) => {
|
|
659
|
+
|
|
660
|
+
it('Report ' + report.id, function() {
|
|
661
|
+
|
|
662
|
+
cy.then(() => {
|
|
663
|
+
Cypress.log({ name: 'report ' + report.id });
|
|
664
|
+
});
|
|
665
|
+
|
|
666
|
+
const selector = 'Report-' + report.id;
|
|
667
|
+
|
|
668
|
+
if (report.fieldValues && !_.isEmpty(report.fieldValues)) {
|
|
669
|
+
fillForm(selector, report.fieldValues, report.schema);
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
|
|
673
|
+
// Press Excel button
|
|
674
|
+
cy.intercept('GET', '**/getReport**').as('waiter');
|
|
675
|
+
clickButton(selector, 'excelBtn');
|
|
676
|
+
cy.wait('@waiter', { timeout: 10000 }).then((interception) => {
|
|
677
|
+
expect(interception.response.headers['content-type']).to.include('application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
|
|
678
|
+
});
|
|
679
|
+
|
|
680
|
+
|
|
681
|
+
// Press PDF button
|
|
682
|
+
cy.intercept('POST', '**/getReport**').as('waiter');
|
|
683
|
+
clickButton(selector, 'pdfBtn');
|
|
684
|
+
cy.wait('@waiter', { timeout: 10000 }).then((interception) => {
|
|
685
|
+
expect(interception.response.headers['content-type']).to.include('pdf');
|
|
686
|
+
});
|
|
687
|
+
|
|
688
|
+
});
|
|
689
|
+
|
|
690
|
+
});
|
|
691
|
+
|
|
692
|
+
});
|
|
693
|
+
|
|
694
|
+
}
|