@onecx/angular-testing 4.11.0
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +7 -0
- package/esm2020/index.mjs +26 -0
- package/esm2020/lib/harnesses/button.harness.mjs +31 -0
- package/esm2020/lib/harnesses/div.harness.mjs +28 -0
- package/esm2020/lib/harnesses/input.harness.mjs +39 -0
- package/esm2020/lib/harnesses/list-item.harness.mjs +14 -0
- package/esm2020/lib/harnesses/menu-item.harness.mjs +11 -0
- package/esm2020/lib/harnesses/p-tableCheckbox.harness.mjs +18 -0
- package/esm2020/lib/harnesses/p.harness.mjs +30 -0
- package/esm2020/lib/harnesses/primeng/p-button-directive.harness.mjs +23 -0
- package/esm2020/lib/harnesses/primeng/p-button.harness.mjs +14 -0
- package/esm2020/lib/harnesses/primeng/p-chart.harness.mjs +11 -0
- package/esm2020/lib/harnesses/primeng/p-checkbox.harness.mjs +27 -0
- package/esm2020/lib/harnesses/primeng/p-dialog.harness.mjs +25 -0
- package/esm2020/lib/harnesses/primeng/p-dropdown.harness.mjs +49 -0
- package/esm2020/lib/harnesses/primeng/p-menu.harness.mjs +21 -0
- package/esm2020/lib/harnesses/primeng/p-multiSelect.harness.mjs +60 -0
- package/esm2020/lib/harnesses/primeng/p-multiSelectListItem.harness.mjs +14 -0
- package/esm2020/lib/harnesses/primeng/p-paginator.harness.mjs +21 -0
- package/esm2020/lib/harnesses/primeng/p-picklist.harness.mjs +64 -0
- package/esm2020/lib/harnesses/primeng/p-selectButton.harness.mjs +9 -0
- package/esm2020/lib/harnesses/span.harness.mjs +17 -0
- package/esm2020/lib/harnesses/table-header-column.harness.mjs +19 -0
- package/esm2020/lib/harnesses/table-row.harness.mjs +19 -0
- package/esm2020/lib/harnesses/utils/primeicon.utils.mjs +2 -0
- package/esm2020/onecx-angular-testing.mjs +5 -0
- package/fesm2015/onecx-angular-testing.mjs +710 -0
- package/fesm2015/onecx-angular-testing.mjs.map +1 -0
- package/fesm2020/onecx-angular-testing.mjs +537 -0
- package/fesm2020/onecx-angular-testing.mjs.map +1 -0
- package/index.d.ts +25 -0
- package/lib/harnesses/button.harness.d.ts +15 -0
- package/lib/harnesses/div.harness.d.ts +13 -0
- package/lib/harnesses/input.harness.d.ts +14 -0
- package/lib/harnesses/list-item.harness.d.ts +7 -0
- package/lib/harnesses/menu-item.harness.d.ts +6 -0
- package/lib/harnesses/p-tableCheckbox.harness.d.ts +10 -0
- package/lib/harnesses/p.harness.d.ts +14 -0
- package/lib/harnesses/primeng/p-button-directive.harness.d.ts +13 -0
- package/lib/harnesses/primeng/p-button.harness.d.ts +10 -0
- package/lib/harnesses/primeng/p-chart.harness.d.ts +6 -0
- package/lib/harnesses/primeng/p-checkbox.harness.d.ts +14 -0
- package/lib/harnesses/primeng/p-dialog.harness.d.ts +13 -0
- package/lib/harnesses/primeng/p-dropdown.harness.d.ts +18 -0
- package/lib/harnesses/primeng/p-menu.harness.d.ts +8 -0
- package/lib/harnesses/primeng/p-multiSelect.harness.d.ts +19 -0
- package/lib/harnesses/primeng/p-multiSelectListItem.harness.d.ts +7 -0
- package/lib/harnesses/primeng/p-paginator.harness.d.ts +12 -0
- package/lib/harnesses/primeng/p-picklist.harness.d.ts +38 -0
- package/lib/harnesses/primeng/p-selectButton.harness.d.ts +5 -0
- package/lib/harnesses/span.harness.d.ts +11 -0
- package/lib/harnesses/table-header-column.harness.d.ts +9 -0
- package/lib/harnesses/table-row.harness.d.ts +10 -0
- package/lib/harnesses/utils/primeicon.utils.d.ts +2 -0
- package/package.json +34 -0
@@ -0,0 +1,710 @@
|
|
1
|
+
import { __awaiter } from 'tslib';
|
2
|
+
import { ComponentHarness, HarnessPredicate, ContentContainerComponentHarness, TestKey } from '@angular/cdk/testing';
|
3
|
+
export * from '@angular/cdk/testing';
|
4
|
+
export * from '@angular/cdk/testing/testbed';
|
5
|
+
|
6
|
+
class PButtonDirectiveHarness extends ComponentHarness {
|
7
|
+
static with(options) {
|
8
|
+
return new HarnessPredicate(PButtonDirectiveHarness, options).addOption('id', options.id, (harness, id) => HarnessPredicate.stringMatches(harness.getId(), id));
|
9
|
+
}
|
10
|
+
getId() {
|
11
|
+
return __awaiter(this, void 0, void 0, function* () {
|
12
|
+
return yield (yield this.host()).getAttribute('id');
|
13
|
+
});
|
14
|
+
}
|
15
|
+
click() {
|
16
|
+
return __awaiter(this, void 0, void 0, function* () {
|
17
|
+
yield (yield this.host()).click();
|
18
|
+
});
|
19
|
+
}
|
20
|
+
getLabel() {
|
21
|
+
return __awaiter(this, void 0, void 0, function* () {
|
22
|
+
return yield (yield this.host()).text();
|
23
|
+
});
|
24
|
+
}
|
25
|
+
getIcon() {
|
26
|
+
return __awaiter(this, void 0, void 0, function* () {
|
27
|
+
return yield (yield this.host()).getAttribute('ng-reflect-icon');
|
28
|
+
});
|
29
|
+
}
|
30
|
+
getDisabled() {
|
31
|
+
return __awaiter(this, void 0, void 0, function* () {
|
32
|
+
return yield (yield this.host()).getProperty('disabled');
|
33
|
+
});
|
34
|
+
}
|
35
|
+
}
|
36
|
+
PButtonDirectiveHarness.hostSelector = 'button[pButton]';
|
37
|
+
|
38
|
+
class PButtonHarness extends ComponentHarness {
|
39
|
+
static with(options) {
|
40
|
+
return new HarnessPredicate(PButtonHarness, options).addOption('id', options.id, (harness, id) => HarnessPredicate.stringMatches(harness.getId(), id));
|
41
|
+
}
|
42
|
+
getId() {
|
43
|
+
return __awaiter(this, void 0, void 0, function* () {
|
44
|
+
return yield (yield this.host()).getAttribute('id');
|
45
|
+
});
|
46
|
+
}
|
47
|
+
click() {
|
48
|
+
return __awaiter(this, void 0, void 0, function* () {
|
49
|
+
yield (yield this.locatorFor('button')()).click();
|
50
|
+
});
|
51
|
+
}
|
52
|
+
}
|
53
|
+
PButtonHarness.hostSelector = 'p-button';
|
54
|
+
|
55
|
+
class PChartHarness extends ComponentHarness {
|
56
|
+
getType() {
|
57
|
+
return __awaiter(this, void 0, void 0, function* () {
|
58
|
+
return yield (yield this.host()).getAttribute('ng-reflect-type');
|
59
|
+
});
|
60
|
+
}
|
61
|
+
getOptions() {
|
62
|
+
return __awaiter(this, void 0, void 0, function* () {
|
63
|
+
return yield (yield this.host()).getAttribute('ng-reflect-options');
|
64
|
+
});
|
65
|
+
}
|
66
|
+
}
|
67
|
+
PChartHarness.hostSelector = 'p-chart';
|
68
|
+
|
69
|
+
class DivHarness extends ComponentHarness {
|
70
|
+
static with(options) {
|
71
|
+
return new HarnessPredicate(DivHarness, options).addOption('class', options.class, (harness, c) => HarnessPredicate.stringMatches(harness.getByClass(c), c));
|
72
|
+
}
|
73
|
+
getByClass(c) {
|
74
|
+
return __awaiter(this, void 0, void 0, function* () {
|
75
|
+
return (yield (yield this.host()).hasClass(c)) ? c : '';
|
76
|
+
});
|
77
|
+
}
|
78
|
+
checkHasClass(value) {
|
79
|
+
return __awaiter(this, void 0, void 0, function* () {
|
80
|
+
return yield (yield this.host()).hasClass(value);
|
81
|
+
});
|
82
|
+
}
|
83
|
+
getText() {
|
84
|
+
return __awaiter(this, void 0, void 0, function* () {
|
85
|
+
return yield (yield this.host()).text();
|
86
|
+
});
|
87
|
+
}
|
88
|
+
getClassList() {
|
89
|
+
return __awaiter(this, void 0, void 0, function* () {
|
90
|
+
const host = yield this.host();
|
91
|
+
const attributeString = yield host.getAttribute('class');
|
92
|
+
if (attributeString) {
|
93
|
+
return attributeString.trim().split(' ');
|
94
|
+
}
|
95
|
+
return [];
|
96
|
+
});
|
97
|
+
}
|
98
|
+
click() {
|
99
|
+
return __awaiter(this, void 0, void 0, function* () {
|
100
|
+
yield (yield this.host()).click();
|
101
|
+
});
|
102
|
+
}
|
103
|
+
}
|
104
|
+
DivHarness.hostSelector = 'div';
|
105
|
+
|
106
|
+
class InputHarness extends ComponentHarness {
|
107
|
+
static with(options) {
|
108
|
+
return new HarnessPredicate(InputHarness, options).addOption('id', options.id, (harness, id) => HarnessPredicate.stringMatches(harness.getId(), id));
|
109
|
+
}
|
110
|
+
getId() {
|
111
|
+
return __awaiter(this, void 0, void 0, function* () {
|
112
|
+
return yield (yield this.host()).getAttribute('id');
|
113
|
+
});
|
114
|
+
}
|
115
|
+
getValue() {
|
116
|
+
return __awaiter(this, void 0, void 0, function* () {
|
117
|
+
return yield (yield this.host()).getProperty('value');
|
118
|
+
});
|
119
|
+
}
|
120
|
+
getChecked() {
|
121
|
+
return __awaiter(this, void 0, void 0, function* () {
|
122
|
+
return yield (yield this.host()).getProperty('checked');
|
123
|
+
});
|
124
|
+
}
|
125
|
+
setValue(value) {
|
126
|
+
return __awaiter(this, void 0, void 0, function* () {
|
127
|
+
if (value instanceof Date) {
|
128
|
+
yield (yield this.host()).setInputValue(`${value.toLocaleDateString([], {
|
129
|
+
month: '2-digit',
|
130
|
+
day: '2-digit',
|
131
|
+
year: 'numeric',
|
132
|
+
})} ${value.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' })}`);
|
133
|
+
}
|
134
|
+
else {
|
135
|
+
yield (yield this.host()).clear();
|
136
|
+
if (value) {
|
137
|
+
yield (yield this.host()).sendKeys(value);
|
138
|
+
}
|
139
|
+
yield (yield this.host()).setInputValue(value);
|
140
|
+
}
|
141
|
+
});
|
142
|
+
}
|
143
|
+
getTestElement() {
|
144
|
+
return __awaiter(this, void 0, void 0, function* () {
|
145
|
+
return yield this.host();
|
146
|
+
});
|
147
|
+
}
|
148
|
+
click() {
|
149
|
+
return __awaiter(this, void 0, void 0, function* () {
|
150
|
+
yield (yield this.host()).click();
|
151
|
+
});
|
152
|
+
}
|
153
|
+
}
|
154
|
+
InputHarness.hostSelector = 'input';
|
155
|
+
|
156
|
+
class PCheckboxHarness extends ComponentHarness {
|
157
|
+
constructor() {
|
158
|
+
super(...arguments);
|
159
|
+
this.getCheckBoxDiv = this.locatorForOptional(DivHarness.with({ class: 'p-checkbox-box' }));
|
160
|
+
}
|
161
|
+
static with(options) {
|
162
|
+
return new HarnessPredicate(PCheckboxHarness, options).addOption('inputid', options.inputid, (harness, inputid) => HarnessPredicate.stringMatches(harness.getId(), inputid));
|
163
|
+
}
|
164
|
+
isChecked() {
|
165
|
+
return __awaiter(this, void 0, void 0, function* () {
|
166
|
+
return (yield this.locatorFor(InputHarness)()).getChecked();
|
167
|
+
});
|
168
|
+
}
|
169
|
+
getId() {
|
170
|
+
return __awaiter(this, void 0, void 0, function* () {
|
171
|
+
return yield (yield this.host()).getAttribute('inputId');
|
172
|
+
});
|
173
|
+
}
|
174
|
+
isHidden() {
|
175
|
+
return __awaiter(this, void 0, void 0, function* () {
|
176
|
+
const attr = yield (yield this.host()).getAttribute('hidden');
|
177
|
+
return Boolean(attr);
|
178
|
+
});
|
179
|
+
}
|
180
|
+
click() {
|
181
|
+
var _a;
|
182
|
+
return __awaiter(this, void 0, void 0, function* () {
|
183
|
+
yield ((_a = (yield this.getCheckBoxDiv())) === null || _a === void 0 ? void 0 : _a.click());
|
184
|
+
});
|
185
|
+
}
|
186
|
+
}
|
187
|
+
PCheckboxHarness.hostSelector = 'p-checkbox';
|
188
|
+
|
189
|
+
class PDialogHarness extends ContentContainerComponentHarness {
|
190
|
+
constructor() {
|
191
|
+
super(...arguments);
|
192
|
+
this.getHeader = this.locatorForOptional(DivHarness.with({ class: 'p-dialog-header' }));
|
193
|
+
this.getFooter = this.locatorForOptional(DivHarness.with({ class: 'p-dialog-footer' }));
|
194
|
+
}
|
195
|
+
getDialogTitle() {
|
196
|
+
var _a;
|
197
|
+
return __awaiter(this, void 0, void 0, function* () {
|
198
|
+
return yield ((_a = (yield this.getHeader())) === null || _a === void 0 ? void 0 : _a.getText());
|
199
|
+
});
|
200
|
+
}
|
201
|
+
close() {
|
202
|
+
return __awaiter(this, void 0, void 0, function* () {
|
203
|
+
if (yield this.isVisible()) {
|
204
|
+
yield (yield this.host()).sendKeys(TestKey.ESCAPE);
|
205
|
+
}
|
206
|
+
else {
|
207
|
+
console.warn('Unable to close CustomGroupColumnSelectionDialog, because it is not open.');
|
208
|
+
}
|
209
|
+
});
|
210
|
+
}
|
211
|
+
isVisible() {
|
212
|
+
return __awaiter(this, void 0, void 0, function* () {
|
213
|
+
return (yield (yield this.host()).getAttribute('ng-reflect-visible')) === 'true' ? true : false;
|
214
|
+
});
|
215
|
+
}
|
216
|
+
}
|
217
|
+
PDialogHarness.hostSelector = 'p-dialog';
|
218
|
+
|
219
|
+
class ListItemHarness extends ComponentHarness {
|
220
|
+
getText() {
|
221
|
+
return __awaiter(this, void 0, void 0, function* () {
|
222
|
+
return yield (yield this.host()).text();
|
223
|
+
});
|
224
|
+
}
|
225
|
+
isSelected() {
|
226
|
+
return __awaiter(this, void 0, void 0, function* () {
|
227
|
+
return (yield (yield this.host()).getAttribute('aria-selected')) === 'true' ? true : false;
|
228
|
+
});
|
229
|
+
}
|
230
|
+
selectItem() {
|
231
|
+
return __awaiter(this, void 0, void 0, function* () {
|
232
|
+
yield (yield this.host()).click();
|
233
|
+
});
|
234
|
+
}
|
235
|
+
}
|
236
|
+
ListItemHarness.hostSelector = 'li';
|
237
|
+
|
238
|
+
class PDropdownHarness extends ContentContainerComponentHarness {
|
239
|
+
static with(options) {
|
240
|
+
return new HarnessPredicate(PDropdownHarness, options).addOption('id', options.id, (harness, id) => HarnessPredicate.stringMatches(harness.getId(), id));
|
241
|
+
}
|
242
|
+
getId() {
|
243
|
+
return __awaiter(this, void 0, void 0, function* () {
|
244
|
+
return yield (yield this.host()).getAttribute('id');
|
245
|
+
});
|
246
|
+
}
|
247
|
+
getDefaultText() {
|
248
|
+
var _a;
|
249
|
+
return __awaiter(this, void 0, void 0, function* () {
|
250
|
+
return (_a = (yield this.locatorForOptional('span.p-placeholder')())) === null || _a === void 0 ? void 0 : _a.text();
|
251
|
+
});
|
252
|
+
}
|
253
|
+
isOpen() {
|
254
|
+
return __awaiter(this, void 0, void 0, function* () {
|
255
|
+
return (yield this.locatorFor('div')()).hasClass('p-dropdown-open');
|
256
|
+
});
|
257
|
+
}
|
258
|
+
open() {
|
259
|
+
return __awaiter(this, void 0, void 0, function* () {
|
260
|
+
if (!(yield this.isOpen())) {
|
261
|
+
yield (yield this.locatorFor('div')()).click();
|
262
|
+
}
|
263
|
+
else {
|
264
|
+
console.warn('Unable to open dropdown, because it is already open.');
|
265
|
+
}
|
266
|
+
});
|
267
|
+
}
|
268
|
+
close() {
|
269
|
+
return __awaiter(this, void 0, void 0, function* () {
|
270
|
+
if (yield this.isOpen()) {
|
271
|
+
yield (yield this.locatorFor('div')()).click();
|
272
|
+
}
|
273
|
+
else {
|
274
|
+
console.warn('Unable to close dropdown, because it is not open.');
|
275
|
+
}
|
276
|
+
});
|
277
|
+
}
|
278
|
+
getDropdownItems() {
|
279
|
+
return __awaiter(this, void 0, void 0, function* () {
|
280
|
+
yield this.open();
|
281
|
+
const dropdownItems = this.locatorForAll(ListItemHarness)();
|
282
|
+
return yield dropdownItems;
|
283
|
+
});
|
284
|
+
}
|
285
|
+
selectedDropdownItem(position) {
|
286
|
+
return __awaiter(this, void 0, void 0, function* () {
|
287
|
+
const selectedColumnGroup = yield Promise.all((yield this.getDropdownItems()).filter((listItem) => listItem.isSelected()));
|
288
|
+
return selectedColumnGroup[position];
|
289
|
+
});
|
290
|
+
}
|
291
|
+
selectedDropdownItemText(position) {
|
292
|
+
return __awaiter(this, void 0, void 0, function* () {
|
293
|
+
return (yield this.selectedDropdownItem(position)).getText();
|
294
|
+
});
|
295
|
+
}
|
296
|
+
hasClearOption() {
|
297
|
+
return __awaiter(this, void 0, void 0, function* () {
|
298
|
+
return (yield this.locatorFor('div')()).hasClass('p-dropdown-clearable');
|
299
|
+
});
|
300
|
+
}
|
301
|
+
}
|
302
|
+
PDropdownHarness.hostSelector = 'p-dropdown';
|
303
|
+
|
304
|
+
class MenuItemHarness extends ComponentHarness {
|
305
|
+
getText() {
|
306
|
+
return __awaiter(this, void 0, void 0, function* () {
|
307
|
+
return yield (yield this.host()).text();
|
308
|
+
});
|
309
|
+
}
|
310
|
+
selectItem() {
|
311
|
+
return __awaiter(this, void 0, void 0, function* () {
|
312
|
+
yield (yield this.host()).click();
|
313
|
+
});
|
314
|
+
}
|
315
|
+
}
|
316
|
+
MenuItemHarness.hostSelector = 'li > a';
|
317
|
+
|
318
|
+
class PMenuHarness extends ContentContainerComponentHarness {
|
319
|
+
getHarnessLoaderForPMenuOverlay() {
|
320
|
+
return __awaiter(this, void 0, void 0, function* () {
|
321
|
+
return this.documentRootLocatorFactory().harnessLoaderForOptional('.p-menu-overlay');
|
322
|
+
});
|
323
|
+
}
|
324
|
+
isOpen() {
|
325
|
+
return __awaiter(this, void 0, void 0, function* () {
|
326
|
+
return !!(yield this.getHarnessLoaderForPMenuOverlay());
|
327
|
+
});
|
328
|
+
}
|
329
|
+
getAllMenuItems() {
|
330
|
+
var _a;
|
331
|
+
return __awaiter(this, void 0, void 0, function* () {
|
332
|
+
if (yield this.isOpen()) {
|
333
|
+
return yield ((_a = (yield this.getHarnessLoaderForPMenuOverlay())) === null || _a === void 0 ? void 0 : _a.getAllHarnesses(MenuItemHarness));
|
334
|
+
}
|
335
|
+
else {
|
336
|
+
console.warn('Cannot get menu items because menu is closed.');
|
337
|
+
}
|
338
|
+
return [];
|
339
|
+
});
|
340
|
+
}
|
341
|
+
}
|
342
|
+
PMenuHarness.hostSelector = 'p-menu';
|
343
|
+
|
344
|
+
class PMultiSelectListItemHarness extends ComponentHarness {
|
345
|
+
getTestElement() {
|
346
|
+
return __awaiter(this, void 0, void 0, function* () {
|
347
|
+
return yield this.host();
|
348
|
+
});
|
349
|
+
}
|
350
|
+
click() {
|
351
|
+
return __awaiter(this, void 0, void 0, function* () {
|
352
|
+
yield (yield this.host()).click();
|
353
|
+
});
|
354
|
+
}
|
355
|
+
getText() {
|
356
|
+
return __awaiter(this, void 0, void 0, function* () {
|
357
|
+
return yield (yield this.host()).text();
|
358
|
+
});
|
359
|
+
}
|
360
|
+
}
|
361
|
+
PMultiSelectListItemHarness.hostSelector = 'li';
|
362
|
+
|
363
|
+
class PMultiSelectHarness extends ComponentHarness {
|
364
|
+
static with(options) {
|
365
|
+
return new HarnessPredicate(PMultiSelectHarness, options)
|
366
|
+
.addOption('id', options.id, (harness, id) => HarnessPredicate.stringMatches(harness.getId(), id))
|
367
|
+
.addOption('class', options.class, (harness, c) => HarnessPredicate.stringMatches(harness.getByClass(c), c));
|
368
|
+
}
|
369
|
+
getId() {
|
370
|
+
return __awaiter(this, void 0, void 0, function* () {
|
371
|
+
return yield (yield this.host()).getAttribute('id');
|
372
|
+
});
|
373
|
+
}
|
374
|
+
getByClass(c) {
|
375
|
+
return __awaiter(this, void 0, void 0, function* () {
|
376
|
+
return (yield (yield this.host()).hasClass(c)) ? c : '';
|
377
|
+
});
|
378
|
+
}
|
379
|
+
getHarnessLoaderForPMultiSelectPanel() {
|
380
|
+
return __awaiter(this, void 0, void 0, function* () {
|
381
|
+
const rootLocator = this.documentRootLocatorFactory();
|
382
|
+
return rootLocator.harnessLoaderFor('.p-multiselect-panel');
|
383
|
+
});
|
384
|
+
}
|
385
|
+
getAllOptions() {
|
386
|
+
return __awaiter(this, void 0, void 0, function* () {
|
387
|
+
if (!(yield this.isOpen())) {
|
388
|
+
yield this.open();
|
389
|
+
}
|
390
|
+
return yield (yield this.getHarnessLoaderForPMultiSelectPanel()).getAllHarnesses(PMultiSelectListItemHarness);
|
391
|
+
});
|
392
|
+
}
|
393
|
+
isOpen() {
|
394
|
+
return __awaiter(this, void 0, void 0, function* () {
|
395
|
+
return yield (yield this.locatorFor('div')()).hasClass('p-multiselect-open');
|
396
|
+
});
|
397
|
+
}
|
398
|
+
open() {
|
399
|
+
return __awaiter(this, void 0, void 0, function* () {
|
400
|
+
if (!(yield this.isOpen())) {
|
401
|
+
yield (yield this.locatorFor('div')()).click();
|
402
|
+
}
|
403
|
+
else {
|
404
|
+
console.warn('Unable to open multiSelect, because it is already open.');
|
405
|
+
}
|
406
|
+
});
|
407
|
+
}
|
408
|
+
close() {
|
409
|
+
return __awaiter(this, void 0, void 0, function* () {
|
410
|
+
if (yield this.isOpen()) {
|
411
|
+
yield (yield this.locatorFor('div')()).click();
|
412
|
+
}
|
413
|
+
else {
|
414
|
+
console.warn('Unable to close multiSelect, because it is not open.');
|
415
|
+
}
|
416
|
+
});
|
417
|
+
}
|
418
|
+
isHighlighted(PMultiSelectListItem) {
|
419
|
+
return __awaiter(this, void 0, void 0, function* () {
|
420
|
+
return yield (yield PMultiSelectListItem.getTestElement()).hasClass('p-highlight');
|
421
|
+
});
|
422
|
+
}
|
423
|
+
getSelectedOptions() {
|
424
|
+
return __awaiter(this, void 0, void 0, function* () {
|
425
|
+
const allOptions = yield this.getAllOptions();
|
426
|
+
const selectedOptions = [];
|
427
|
+
for (let index = 0; index < allOptions.length; index++) {
|
428
|
+
const option = allOptions[index];
|
429
|
+
if (yield this.isHighlighted(option)) {
|
430
|
+
selectedOptions.push(yield option.getText());
|
431
|
+
}
|
432
|
+
}
|
433
|
+
return selectedOptions;
|
434
|
+
});
|
435
|
+
}
|
436
|
+
}
|
437
|
+
PMultiSelectHarness.hostSelector = 'p-multiSelect';
|
438
|
+
|
439
|
+
class ButtonHarness extends ComponentHarness {
|
440
|
+
static with(options) {
|
441
|
+
return new HarnessPredicate(ButtonHarness, options)
|
442
|
+
.addOption('id', options.id, (harness, id) => HarnessPredicate.stringMatches(harness.getId(), id))
|
443
|
+
.addOption('icon', options.icon, (harness, icon) => HarnessPredicate.stringMatches(harness.getIcon(), icon))
|
444
|
+
.addOption('class', options.class, (harness, c) => HarnessPredicate.stringMatches(harness.getByClass(c), c));
|
445
|
+
}
|
446
|
+
getId() {
|
447
|
+
return __awaiter(this, void 0, void 0, function* () {
|
448
|
+
return yield (yield this.host()).getAttribute('id');
|
449
|
+
});
|
450
|
+
}
|
451
|
+
getIcon() {
|
452
|
+
return __awaiter(this, void 0, void 0, function* () {
|
453
|
+
return yield (yield this.host()).getAttribute('icon');
|
454
|
+
});
|
455
|
+
}
|
456
|
+
getByClass(c) {
|
457
|
+
return __awaiter(this, void 0, void 0, function* () {
|
458
|
+
return (yield (yield this.host()).hasClass(c)) ? c : '';
|
459
|
+
});
|
460
|
+
}
|
461
|
+
click() {
|
462
|
+
return __awaiter(this, void 0, void 0, function* () {
|
463
|
+
if (!(yield this.isDisabled())) {
|
464
|
+
yield (yield this.host()).click();
|
465
|
+
}
|
466
|
+
else {
|
467
|
+
console.warn('Button cannot be clicked, because it is disabled!');
|
468
|
+
}
|
469
|
+
});
|
470
|
+
}
|
471
|
+
isDisabled() {
|
472
|
+
return __awaiter(this, void 0, void 0, function* () {
|
473
|
+
return yield (yield this.host()).getProperty('disabled');
|
474
|
+
});
|
475
|
+
}
|
476
|
+
}
|
477
|
+
ButtonHarness.hostSelector = 'button';
|
478
|
+
|
479
|
+
class PPicklistControlsButtonsHarness extends ContentContainerComponentHarness {
|
480
|
+
constructor() {
|
481
|
+
super(...arguments);
|
482
|
+
this.getButtons = this.locatorForAll(ButtonHarness);
|
483
|
+
}
|
484
|
+
static with(options) {
|
485
|
+
return new HarnessPredicate(PPicklistControlsButtonsHarness, options).addOption('class', options.class, (harness, c) => HarnessPredicate.stringMatches(harness.getByClass(c), c));
|
486
|
+
}
|
487
|
+
getByClass(c) {
|
488
|
+
return __awaiter(this, void 0, void 0, function* () {
|
489
|
+
return (yield (yield this.host()).hasClass(c)) ? c : '';
|
490
|
+
});
|
491
|
+
}
|
492
|
+
}
|
493
|
+
PPicklistControlsButtonsHarness.hostSelector = '.p-picklist-buttons';
|
494
|
+
class PPicklistListWrapperHarness extends ContentContainerComponentHarness {
|
495
|
+
constructor() {
|
496
|
+
super(...arguments);
|
497
|
+
this.getHeader = this.locatorFor(DivHarness.with({ class: 'p-picklist-header' }));
|
498
|
+
this.getAllListItems = this.locatorForAll(ListItemHarness);
|
499
|
+
}
|
500
|
+
static with(options) {
|
501
|
+
return new HarnessPredicate(PPicklistListWrapperHarness, options).addOption('class', options.class, (harness, c) => HarnessPredicate.stringMatches(harness.getByClass(c), c));
|
502
|
+
}
|
503
|
+
getByClass(c) {
|
504
|
+
return __awaiter(this, void 0, void 0, function* () {
|
505
|
+
return (yield (yield this.host()).hasClass(c)) ? c : '';
|
506
|
+
});
|
507
|
+
}
|
508
|
+
}
|
509
|
+
PPicklistListWrapperHarness.hostSelector = '.p-picklist-list-wrapper';
|
510
|
+
class PPicklistHarness extends ContentContainerComponentHarness {
|
511
|
+
constructor() {
|
512
|
+
super(...arguments);
|
513
|
+
this.getPicklistSourceControls = this.locatorFor(PPicklistControlsButtonsHarness.with({ class: 'p-picklist-source-controls' }));
|
514
|
+
this.getPicklistTransferControls = this.locatorFor(PPicklistControlsButtonsHarness.with({ class: 'p-picklist-transfer-buttons' }));
|
515
|
+
this.getPicklistTargetControls = this.locatorFor(PPicklistControlsButtonsHarness.with({ class: 'p-picklist-target-controls' }));
|
516
|
+
this.getPicklistSource = this.locatorFor(PPicklistListWrapperHarness.with({ class: 'p-picklist-source-wrapper' }));
|
517
|
+
this.getPicklistTarget = this.locatorFor(PPicklistListWrapperHarness.with({ class: 'p-picklist-target-wrapper' }));
|
518
|
+
}
|
519
|
+
getSourceControlsButtons() {
|
520
|
+
return __awaiter(this, void 0, void 0, function* () {
|
521
|
+
return yield (yield this.getPicklistSourceControls()).getButtons();
|
522
|
+
});
|
523
|
+
}
|
524
|
+
getTransferControlsButtons() {
|
525
|
+
return __awaiter(this, void 0, void 0, function* () {
|
526
|
+
return yield (yield this.getPicklistTransferControls()).getButtons();
|
527
|
+
});
|
528
|
+
}
|
529
|
+
getTargetControlsButtons() {
|
530
|
+
return __awaiter(this, void 0, void 0, function* () {
|
531
|
+
return yield (yield this.getPicklistTargetControls()).getButtons();
|
532
|
+
});
|
533
|
+
}
|
534
|
+
getSourceHeader() {
|
535
|
+
return __awaiter(this, void 0, void 0, function* () {
|
536
|
+
return yield (yield (yield this.getPicklistSource()).getHeader()).getText();
|
537
|
+
});
|
538
|
+
}
|
539
|
+
getTargetHeader() {
|
540
|
+
return __awaiter(this, void 0, void 0, function* () {
|
541
|
+
return yield (yield (yield this.getPicklistTarget()).getHeader()).getText();
|
542
|
+
});
|
543
|
+
}
|
544
|
+
getSourceListItems() {
|
545
|
+
return __awaiter(this, void 0, void 0, function* () {
|
546
|
+
return yield (yield this.getPicklistSource()).getAllListItems();
|
547
|
+
});
|
548
|
+
}
|
549
|
+
getTargetListItems() {
|
550
|
+
return __awaiter(this, void 0, void 0, function* () {
|
551
|
+
return yield (yield this.getPicklistTarget()).getAllListItems();
|
552
|
+
});
|
553
|
+
}
|
554
|
+
}
|
555
|
+
PPicklistHarness.hostSelector = 'p-picklist';
|
556
|
+
|
557
|
+
class PSelectButtonHarness extends ContentContainerComponentHarness {
|
558
|
+
constructor() {
|
559
|
+
super(...arguments);
|
560
|
+
this.getAllButtons = this.locatorForAll('div > div');
|
561
|
+
}
|
562
|
+
}
|
563
|
+
PSelectButtonHarness.hostSelector = 'p-selectbutton';
|
564
|
+
|
565
|
+
class SpanHarness extends ComponentHarness {
|
566
|
+
static with(options) {
|
567
|
+
return new HarnessPredicate(SpanHarness, options).addOption('class', options.class, (harness, c) => HarnessPredicate.stringMatches(harness.getByClass(c), c));
|
568
|
+
}
|
569
|
+
getByClass(c) {
|
570
|
+
return __awaiter(this, void 0, void 0, function* () {
|
571
|
+
return (yield (yield this.host()).hasClass(c)) ? c : '';
|
572
|
+
});
|
573
|
+
}
|
574
|
+
checkHasClass(value) {
|
575
|
+
return __awaiter(this, void 0, void 0, function* () {
|
576
|
+
return yield (yield this.host()).hasClass(value);
|
577
|
+
});
|
578
|
+
}
|
579
|
+
getText() {
|
580
|
+
return __awaiter(this, void 0, void 0, function* () {
|
581
|
+
return yield (yield this.host()).text();
|
582
|
+
});
|
583
|
+
}
|
584
|
+
}
|
585
|
+
SpanHarness.hostSelector = 'span';
|
586
|
+
|
587
|
+
class PPaginatorHarness extends ContentContainerComponentHarness {
|
588
|
+
constructor() {
|
589
|
+
super(...arguments);
|
590
|
+
this.getCurrentPageReport = this.locatorFor(SpanHarness.with({ class: 'p-paginator-current' }));
|
591
|
+
this.getRowsPerPageOptions = this.locatorFor(PDropdownHarness);
|
592
|
+
this.getNextPageButton = this.locatorFor(ButtonHarness.with({ class: 'p-paginator-next' }));
|
593
|
+
}
|
594
|
+
getCurrentPageReportText() {
|
595
|
+
return __awaiter(this, void 0, void 0, function* () {
|
596
|
+
return yield (yield this.getCurrentPageReport()).getText();
|
597
|
+
});
|
598
|
+
}
|
599
|
+
clickNextPage() {
|
600
|
+
return __awaiter(this, void 0, void 0, function* () {
|
601
|
+
;
|
602
|
+
(yield this.getNextPageButton()).click();
|
603
|
+
});
|
604
|
+
}
|
605
|
+
}
|
606
|
+
PPaginatorHarness.hostSelector = 'p-paginator';
|
607
|
+
|
608
|
+
class PTableCheckboxHarness extends ComponentHarness {
|
609
|
+
static with(options = {}) {
|
610
|
+
return new HarnessPredicate(this, options).addOption('isSelected', options.isSelected, (harness, selected) => __awaiter(this, void 0, void 0, function* () {
|
611
|
+
return (yield harness.isChecked()) === selected;
|
612
|
+
}));
|
613
|
+
}
|
614
|
+
isChecked() {
|
615
|
+
return __awaiter(this, void 0, void 0, function* () {
|
616
|
+
const allChecked = yield this.locatorForAll('.pi-check')();
|
617
|
+
return allChecked.length === 1;
|
618
|
+
});
|
619
|
+
}
|
620
|
+
checkBox() {
|
621
|
+
return __awaiter(this, void 0, void 0, function* () {
|
622
|
+
const checkBoxElement = yield this.locatorFor('.p-checkbox-box')();
|
623
|
+
return checkBoxElement.click();
|
624
|
+
});
|
625
|
+
}
|
626
|
+
}
|
627
|
+
PTableCheckboxHarness.hostSelector = 'p-tableCheckbox';
|
628
|
+
|
629
|
+
class PHarness extends ComponentHarness {
|
630
|
+
static with(options) {
|
631
|
+
return new HarnessPredicate(PHarness, options)
|
632
|
+
.addOption('class', options.class, (harness, c) => HarnessPredicate.stringMatches(harness.getByClass(c), c))
|
633
|
+
.addOption('id', options.id, (harness, id) => HarnessPredicate.stringMatches(harness.hasId(id), id));
|
634
|
+
}
|
635
|
+
getByClass(c) {
|
636
|
+
return __awaiter(this, void 0, void 0, function* () {
|
637
|
+
return (yield (yield this.host()).hasClass(c)) ? c : '';
|
638
|
+
});
|
639
|
+
}
|
640
|
+
hasId(id) {
|
641
|
+
return __awaiter(this, void 0, void 0, function* () {
|
642
|
+
return (yield (yield this.host()).matchesSelector('#' + id)) ? id : '';
|
643
|
+
});
|
644
|
+
}
|
645
|
+
checkHasClass(value) {
|
646
|
+
return __awaiter(this, void 0, void 0, function* () {
|
647
|
+
return yield (yield this.host()).hasClass(value);
|
648
|
+
});
|
649
|
+
}
|
650
|
+
getText() {
|
651
|
+
return __awaiter(this, void 0, void 0, function* () {
|
652
|
+
return yield (yield this.host()).text();
|
653
|
+
});
|
654
|
+
}
|
655
|
+
getClassList() {
|
656
|
+
return __awaiter(this, void 0, void 0, function* () {
|
657
|
+
const host = yield this.host();
|
658
|
+
const attributeString = yield host.getAttribute('class');
|
659
|
+
if (attributeString) {
|
660
|
+
return attributeString.trim().split(' ');
|
661
|
+
}
|
662
|
+
return [];
|
663
|
+
});
|
664
|
+
}
|
665
|
+
}
|
666
|
+
PHarness.hostSelector = 'p';
|
667
|
+
|
668
|
+
class TableHeaderColumnHarness extends ContentContainerComponentHarness {
|
669
|
+
constructor() {
|
670
|
+
super(...arguments);
|
671
|
+
this.getSortButton = this.locatorFor(ButtonHarness.with({
|
672
|
+
class: 'sortButton',
|
673
|
+
}));
|
674
|
+
this.getFilterMultiSelect = this.locatorFor(PMultiSelectHarness.with({
|
675
|
+
class: 'filterMultiSelect',
|
676
|
+
}));
|
677
|
+
}
|
678
|
+
getText() {
|
679
|
+
return __awaiter(this, void 0, void 0, function* () {
|
680
|
+
return (yield this.host()).text();
|
681
|
+
});
|
682
|
+
}
|
683
|
+
}
|
684
|
+
TableHeaderColumnHarness.hostSelector = 'th';
|
685
|
+
|
686
|
+
class TableRowHarness extends ContentContainerComponentHarness {
|
687
|
+
constructor() {
|
688
|
+
super(...arguments);
|
689
|
+
this.getAllActionButtons = this.locatorForAll('button');
|
690
|
+
this.getViewButton = this.locatorForOptional(ButtonHarness.with({ class: 'viewTableRowButton' }));
|
691
|
+
this.getEditButton = this.locatorForOptional(ButtonHarness.with({ class: 'editTableRowButton' }));
|
692
|
+
this.getDeleteButton = this.locatorForOptional(ButtonHarness.with({ class: 'deleteTableRowButton' }));
|
693
|
+
}
|
694
|
+
getData() {
|
695
|
+
return __awaiter(this, void 0, void 0, function* () {
|
696
|
+
const tds = yield this.locatorForAll('td')();
|
697
|
+
const isActionsTd = yield Promise.all(tds.map((t) => t.hasClass('actions')));
|
698
|
+
const textTds = tds.filter((_v, index) => !isActionsTd[index]);
|
699
|
+
return Promise.all(textTds.map((t) => t.text()));
|
700
|
+
});
|
701
|
+
}
|
702
|
+
}
|
703
|
+
TableRowHarness.hostSelector = 'tbody > tr';
|
704
|
+
|
705
|
+
/**
|
706
|
+
* Generated bundle index. Do not edit.
|
707
|
+
*/
|
708
|
+
|
709
|
+
export { ButtonHarness, DivHarness, InputHarness, ListItemHarness, MenuItemHarness, PButtonDirectiveHarness, PButtonHarness, PChartHarness, PCheckboxHarness, PDialogHarness, PDropdownHarness, PHarness, PMenuHarness, PMultiSelectHarness, PMultiSelectListItemHarness, PPaginatorHarness, PPicklistControlsButtonsHarness, PPicklistHarness, PPicklistListWrapperHarness, PSelectButtonHarness, PTableCheckboxHarness, SpanHarness, TableHeaderColumnHarness, TableRowHarness };
|
710
|
+
//# sourceMappingURL=onecx-angular-testing.mjs.map
|