-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathUiBaseLocators.ts
1167 lines (1006 loc) · 46.8 KB
/
UiBaseLocators.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import {expect, Locator, Page} from "@playwright/test"
import {ConstantHelper} from "./ConstantHelper";
export class UiBaseLocators {
public readonly page: Page;
public readonly saveBtn: Locator;
public readonly chooseBtn: Locator;
public readonly submitBtn: Locator;
public readonly createFolderBtn: Locator;
public readonly breadcrumbBtn: Locator;
public readonly confirmToDeleteBtn: Locator;
public readonly deleteExactBtn: Locator;
public readonly confirmCreateFolderBtn: Locator;
public readonly insertBtn: Locator;
public readonly modalCaretBtn: Locator;
public readonly queryBuilderBtn: Locator;
public readonly queryBuilderOrderedBy: Locator;
public readonly queryBuilderCreateDate: Locator;
public readonly folderNameTxt: Locator;
public readonly textAreaInputArea: Locator;
public readonly wherePropertyAliasBtn: Locator;
public readonly whereOperatorBtn: Locator;
public readonly whereConstrainValueTxt: Locator;
public readonly orderByPropertyAliasBtn: Locator;
public readonly ascendingBtn: Locator;
public readonly queryBuilderShowCode: Locator;
public readonly createThreeDotsBtn: Locator;
public readonly newFolderThreeDotsBtn: Locator;
public readonly renameThreeDotsBtn: Locator;
public readonly newNameTxt: Locator;
public readonly renameModalBtn: Locator;
public readonly createBtn: Locator;
public readonly successState: Locator;
public readonly chooseModalBtn: Locator;
public readonly addBtn: Locator;
public readonly renameFolderThreeDotsBtn: Locator;
public readonly renameFolderBtn: Locator;
public readonly updateFolderBtn: Locator;
public readonly filterChooseBtn: Locator;
public readonly updateBtn: Locator;
public readonly changeBtn: Locator;
public readonly propertyNameTxt: Locator;
public readonly selectPropertyEditorBtn: Locator;
public readonly addGroupBtn: Locator;
public readonly iAmDoneReorderingBtn: Locator;
public readonly reorderBtn: Locator;
public readonly compositionsBtn: Locator;
public readonly addTabBtn: Locator;
public readonly descriptionBtn: Locator;
public readonly enterDescriptionTxt: Locator;
public readonly mandatoryToggle: Locator;
public readonly validation: Locator;
public readonly regexTxt: Locator;
public readonly regexMessageTxt: Locator;
public readonly structureTabBtn: Locator;
public readonly allowAtRootBtn: Locator;
public readonly addPropertyBtn: Locator;
public readonly typeToFilterSearchTxt: Locator;
public readonly editorSettingsBtn: Locator;
public readonly labelAboveBtn: Locator;
public readonly unnamedTxt: Locator;
public readonly deleteThreeDotsBtn: Locator;
public readonly removeExactBtn: Locator;
public readonly confirmBtn: Locator;
public readonly disableBtn: Locator;
public readonly confirmDisableBtn: Locator;
public readonly enableBtn: Locator;
public readonly confirmEnableBtn: Locator;
public readonly iconBtn: Locator;
public readonly aliasLockBtn: Locator;
public readonly aliasNameTxt: Locator;
public readonly deleteFolderThreeDotsBtn: Locator;
public readonly createLink: Locator;
public readonly actionMenucreateBtn: Locator;
public readonly insertValueBtn: Locator;
public readonly insertPartialViewBtn: Locator;
public readonly insertDictionaryItemBtn: Locator;
public readonly chooseFieldDropDown: Locator;
public readonly systemFieldsOption: Locator;
public readonly chooseFieldValueDropDown: Locator;
public readonly renameBtn: Locator;
public readonly returnedItemsCount: Locator;
public readonly chooseRootContentBtn: Locator;
public readonly queryResults: Locator;
public readonly reloadBtn: Locator;
public readonly confirmToRemoveBtn: Locator;
public readonly confirmToSubmitBtn: Locator;
public readonly typeGroups: Locator;
public readonly allowedChildNodesModal: Locator;
public readonly addCollectionBtn: Locator;
public readonly errorNotification: Locator;
public readonly confirmRenameBtn: Locator;
public readonly successNotification: Locator;
public readonly leftArrowBtn: Locator;
public readonly clickToUploadBtn: Locator;
public readonly backOfficeHeader: Locator;
public readonly failedStateButton: Locator;
public readonly sidebarModal: Locator;
public readonly enterAName: Locator;
public readonly mediaCardItems: Locator;
public readonly enterPropertyEditorDescriptionTxt: Locator;
public readonly breadcrumbsTemplateModal: Locator;
public readonly containerChooseBtn: Locator;
public readonly documentTypeNode: Locator;
public readonly groupLabel: Locator;
public readonly containerSaveAndPublishBtn: Locator;
public readonly confirmTrashBtn: Locator;
public readonly recycleBinBtn: Locator;
public readonly recycleBinMenuItemCaretBtn: Locator;
public readonly recycleBinMenuItem: Locator;
public readonly gridBtn: Locator;
public readonly listBtn: Locator;
public readonly viewBundleBtn: Locator;
public readonly chooseDocumentInputBtn: Locator;
public readonly chooseMediaInputBtn: Locator;
public readonly container: Locator;
public readonly createDocumentBlueprintBtn: Locator;
public readonly actionsBtn: Locator;
public readonly mediaPickerModalSubmitBtn: Locator;
public readonly deleteBtn: Locator;
public readonly createModalBtn: Locator;
public readonly mediaCaptionAltTextModalSubmitBtn: Locator;
public readonly embeddedMediaModal: Locator;
public readonly embeddedURLTxt: Locator;
public readonly embeddedRetrieveBtn: Locator;
public readonly embeddedMediaModalConfirmBtn: Locator;
public readonly embeddedPreview: Locator;
public readonly sectionSidebar: Locator;
public readonly actionsMenuContainer: Locator;
public readonly menuItem: Locator;
public readonly property: Locator;
public readonly currentUserAvatarBtn: Locator;
public readonly newPasswordTxt: Locator;
public readonly confirmPasswordTxt: Locator;
public readonly currentPasswordTxt: Locator;
public readonly createOptionActionListModal: Locator;
public readonly createActionButtonCollection: Locator;
public readonly createActionBtn: Locator;
public readonly collectionTreeItemTableRow: Locator;
public readonly folderBtn: Locator;
public readonly reloadChildrenBtn: Locator;
constructor(page: Page) {
this.page = page;
this.saveBtn = page.getByLabel('Save', {exact: true});
this.submitBtn = page.getByLabel('Submit');
this.deleteExactBtn = page.getByRole('button', {name: 'Delete', exact: true});
this.confirmToDeleteBtn = page.locator('#confirm').getByLabel('Delete');
this.confirmCreateFolderBtn = page.locator('#confirm').getByLabel('Create Folder');
this.breadcrumbBtn = page.getByLabel('Breadcrumb');
this.createFolderBtn = page.getByLabel('Create folder');
this.insertBtn = page.locator('uui-box uui-button').filter({hasText: 'Insert'});
this.sidebarModal = page.locator('uui-modal-sidebar');
this.modalCaretBtn = this.sidebarModal.locator('#caret-button');
this.enterAName = page.getByLabel('Enter a name...', {exact: true});
this.queryBuilderBtn = page.locator('#query-builder-button');
this.queryBuilderOrderedBy = page.locator('#property-alias-dropdown').getByLabel('Property alias');
this.queryBuilderCreateDate = page.locator('#property-alias-dropdown').getByText('CreateDate').locator("..");
this.folderNameTxt = page.getByLabel('Enter a folder name');
this.textAreaInputArea = page.locator('textarea.inputarea');
this.wherePropertyAliasBtn = page.locator('#property-alias-dropdown');
this.whereOperatorBtn = page.locator('#operator-dropdown');
this.whereConstrainValueTxt = page.getByLabel('constrain value');
this.orderByPropertyAliasBtn = page.locator('#sort-dropdown');
this.ascendingBtn = page.locator('[key="template_ascending"]');
this.queryBuilderShowCode = page.locator('umb-code-block');
this.createThreeDotsBtn = page.getByText('Create…', {exact: true});
this.chooseBtn = page.getByLabel('Choose', {exact: true});
this.containerChooseBtn = page.locator('#container').getByLabel('Choose');
this.containerSaveAndPublishBtn = page.locator('#container').getByLabel('Save and Publish');
this.newFolderThreeDotsBtn = page.getByLabel('New Folder…');
this.renameThreeDotsBtn = page.getByLabel('Rename…', {exact: true});
this.newNameTxt = page.getByRole('textbox', {name: 'Enter new name...'});
this.renameModalBtn = page.locator('umb-rename-modal').getByLabel('Rename');
this.createBtn = page.getByRole('button', {name: /^Create(…)?$/});
this.actionsMenuContainer = page.locator('uui-scroll-container');
this.actionMenucreateBtn = this.actionsMenuContainer.getByRole('button', {name: /^Create(…)?$/});
this.successState = page.locator('[state="success"]');
this.chooseModalBtn = this.sidebarModal.locator('[look="primary"]').getByLabel('Choose');
this.addBtn = page.getByRole('button', {name: 'Add', exact: true});
this.renameFolderThreeDotsBtn = page.getByRole('button', {name: 'Rename folder…'})
this.renameFolderBtn = page.getByLabel('Rename folder');
this.confirmRenameBtn = page.locator('#confirm').getByLabel('Rename');
this.updateFolderBtn = page.getByLabel('Update folder');
this.filterChooseBtn = page.locator('button').filter({hasText: 'Choose'});
this.updateBtn = page.getByLabel('Update');
this.changeBtn = page.getByLabel('Change');
this.propertyNameTxt = page.locator('#name-input #input');
this.selectPropertyEditorBtn = page.getByLabel('Select Property Editor');
this.addGroupBtn = page.getByLabel('Add group', {exact: true});
this.iAmDoneReorderingBtn = page.getByLabel('I am done reordering');
this.reorderBtn = page.getByLabel('Reorder');
this.compositionsBtn = page.getByLabel('Compositions');
this.addTabBtn = page.getByLabel('Add tab');
this.descriptionBtn = page.getByLabel('Description');
this.enterDescriptionTxt = page.getByLabel('Enter a description...');
this.mandatoryToggle = page.locator('#mandatory #toggle');
this.validation = page.locator('#native');
this.regexTxt = page.locator('input[name="pattern"]');
this.regexMessageTxt = page.locator('textarea[name="pattern-message"]');
this.structureTabBtn = page.locator('uui-tab').filter({hasText: 'Structure'}).locator('svg');
this.allowAtRootBtn = page.locator('label').filter({hasText: 'Allow at root'});
this.addPropertyBtn = page.getByLabel('Add property', {exact: true});
this.typeToFilterSearchTxt = page.locator('[type="search"] #input');
this.editorSettingsBtn = page.getByLabel('Editor settings');
this.labelAboveBtn = page.locator('button').filter({hasText: 'Label above'});
this.unnamedTxt = page.getByRole('textbox', {name: 'Unnamed'});
this.deleteThreeDotsBtn = page.getByLabel('Delete…');
this.removeExactBtn = page.getByLabel('Remove', {exact: true});
this.confirmBtn = page.getByLabel('Confirm');
this.disableBtn = page.getByLabel('Disable', {exact: true});
this.confirmDisableBtn = page.locator('#confirm').getByLabel('Disable');
this.confirmToSubmitBtn = page.locator('#confirm').getByLabel('Submit');
this.enableBtn = page.getByLabel('Enable');
this.confirmEnableBtn = page.locator('#confirm').getByLabel('Enable');
this.iconBtn = page.getByLabel('icon');
this.aliasLockBtn = page.locator('#name #lock');
this.aliasNameTxt = page.locator('#name').getByLabel('alias');
this.deleteFolderThreeDotsBtn = page.locator('#action-modal').getByLabel('Delete Folder...');
this.createLink = page.getByRole('link', {name: 'Create', exact: true});
this.insertValueBtn = page.locator('uui-button').filter({has: page.locator('[key="template_insertPageField"]')});
this.insertPartialViewBtn = page.locator('uui-button').filter({has: page.locator('[key="template_insertPartialView"]')});
this.insertDictionaryItemBtn = page.locator('uui-button').filter({has: page.locator('[key="template_insertDictionaryItem"]')});
this.chooseFieldDropDown = page.locator('#preview #expand-symbol-wrapper');
this.systemFieldsOption = page.getByText('System fields');
this.chooseFieldValueDropDown = page.locator('#value #expand-symbol-wrapper');
this.renameBtn = page.getByRole('button', {name: /^Rename(…)?$/});
this.returnedItemsCount = page.locator('#results-count');
this.chooseRootContentBtn = page.getByLabel('Choose root document');
this.queryResults = page.locator('query-results');
this.reloadBtn = page.getByRole('button', {name: 'Reload', exact: true});
this.confirmToRemoveBtn = page.locator('#confirm').getByLabel('Remove');
this.typeGroups = page.locator('umb-content-type-design-editor-group');
this.allowedChildNodesModal = page.locator('umb-tree-picker-modal');
this.addCollectionBtn = page.locator('umb-input-collection-configuration #create-button');
this.errorNotification = page.locator('uui-toast-notification[open][color="danger"]');
this.successNotification = page.locator('uui-toast-notification[open][color="positive"]');
this.leftArrowBtn = page.locator('[name="icon-arrow-left"] svg');
this.clickToUploadBtn = page.locator('uui-file-dropzone').filter({hasText: 'Click to upload'});
this.backOfficeHeader = page.locator('umb-backoffice-header');
this.failedStateButton = page.locator('uui-button[state="failed"]');
this.mediaCardItems = page.locator('uui-card-media');
this.enterPropertyEditorDescriptionTxt = this.sidebarModal.getByLabel('Enter a description...');
this.breadcrumbsTemplateModal = this.sidebarModal.locator('umb-template-workspace-editor uui-breadcrumbs');
this.documentTypeNode = page.locator('uui-ref-node-document-type');
this.groupLabel = page.getByLabel('Group', {exact: true});
this.confirmTrashBtn = page.locator('#confirm').getByLabel('Trash');
this.recycleBinBtn = page.getByLabel('Recycle Bin', {exact: true});
this.recycleBinMenuItem = page.locator('uui-menu-item[label="Recycle Bin"]');
this.recycleBinMenuItemCaretBtn = this.recycleBinMenuItem.locator('#caret-button');
this.gridBtn = this.page.getByLabel('Grid');
this.listBtn = this.page.getByLabel('List');
this.viewBundleBtn = this.page.locator('umb-collection-view-bundle uui-button svg');
this.createDocumentBlueprintBtn = page.getByLabel(/^Create Document Blueprint(…)?$/);
this.chooseDocumentInputBtn = page.locator('umb-input-document').getByLabel('Choose');
this.chooseMediaInputBtn = page.locator('umb-input-media').getByLabel('Choose');
this.container = page.locator('#container');
this.actionsBtn = page.getByLabel('Actions', {exact: true});
this.mediaPickerModalSubmitBtn = page.locator('umb-media-picker-modal').getByLabel('Submit');
this.deleteBtn = page.getByRole('button', {name: /^Delete(…)?$/});
this.createModalBtn = this.sidebarModal.getByLabel('Create', {exact: true});
this.mediaCaptionAltTextModalSubmitBtn = page.locator('umb-media-caption-alt-text-modal').getByLabel('Submit');
this.embeddedMediaModal = page.locator('umb-embedded-media-modal');
this.embeddedURLTxt = this.embeddedMediaModal.locator('[label="URL"] #input');
this.embeddedRetrieveBtn = this.embeddedMediaModal.locator('[label="Retrieve"]');
this.embeddedMediaModalConfirmBtn = this.embeddedMediaModal.getByLabel('Confirm');
this.embeddedPreview = this.embeddedMediaModal.locator('[label="Preview"]');
this.sectionSidebar = page.locator('umb-section-sidebar');
this.menuItem = page.locator('uui-menu-item');
this.property = this.page.locator('umb-property');
this.currentUserAvatarBtn = this.page.locator('[data-mark="header-app:Umb.HeaderApp.CurrentUser"] uui-avatar');
this.currentPasswordTxt = page.locator('input[name="oldPassword"]');
this.newPasswordTxt = page.locator('input[name="newPassword"]');
this.confirmPasswordTxt = page.locator('input[name="confirmPassword"]');
this.createOptionActionListModal = this.page.locator('umb-entity-create-option-action-list-modal');
this.createActionButtonCollection = this.page.locator('umb-collection-create-action-button');
this.createActionBtn = this.createActionButtonCollection.locator('[label="Create"]');
this.collectionTreeItemTableRow = this.page.locator('umb-collection-workspace-view umb-table uui-table-row');
this.folderBtn = this.createOptionActionListModal.locator('[name="Folder"]');
this.reloadChildrenBtn = page.getByRole('button', {name: 'Reload children'});
}
async clickActionsMenuForNameInSectionSidebar(name: string) {
await this.sectionSidebar.locator('[label="' + name + '"]').hover();
await this.sectionSidebar.locator('[label="' + name + '"] >> [label="Open actions menu"]').first().click();
}
async clickActionsMenuForName(name: string) {
await expect(this.page.locator('[label="' + name + '"]')).toBeVisible();
await this.page.locator('[label="' + name + '"]').hover();
await this.page.locator('[label="' + name + '"] >> [label="Open actions menu"]').first().click();
}
async isActionsMenuForNameVisible(name: string, isVisible = true) {
await this.page.locator('[label="' + name + '"]').click();
await expect(this.page.locator('[label="' + name + '"] >> [label="Open actions menu"]')).toBeVisible({visible: isVisible});
}
async clickCaretButtonForName(name: string) {
await this.isCaretButtonWithNameVisible(name);
await this.page.locator('div').filter({hasText: name}).locator('#caret-button').click();
}
async isCaretButtonWithNameVisible(name: string, isVisible = true) {
await expect(this.page.locator('div').filter({hasText: name}).locator('#caret-button')).toBeVisible({visible: isVisible});
}
async clickCaretButton() {
await this.page.locator('#caret-button').click();
}
async reloadTree(treeName: string) {
// Waits until the tree item is visible
await expect(this.page.getByLabel(treeName, {exact: true})).toBeVisible();
await this.page.waitForTimeout(500);
await this.clickActionsMenuForName(treeName);
await this.clickReloadChildrenButton();
const menuItem = this.page.locator('uui-menu-item[label="' + treeName + '"]');
const isCaretButtonOpen = await menuItem.getAttribute('show-children');
if (isCaretButtonOpen === null) {
// We need to wait before clicking the caret button. Because the reload might not have happend yet.
await this.clickCaretButtonForName(treeName);
}
}
async clickReloadButton() {
await expect(this.reloadBtn).toBeVisible();
await this.reloadBtn.click();
}
async clickReloadChildrenButton() {
await expect(this.reloadChildrenBtn).toBeVisible();
await this.reloadChildrenBtn.click();
}
async clickSaveButton() {
// This wait is necessary to avoid the save button is ignored
await this.page.waitForTimeout(500);
await expect(this.saveBtn).toBeVisible();
await this.saveBtn.click();
}
async clickChooseButton() {
await expect(this.chooseBtn).toBeVisible();
await this.chooseBtn.click();
}
async clickChooseContainerButton() {
await this.containerChooseBtn.click();
}
async clickFilterChooseButton() {
await this.filterChooseBtn.click();
}
async clickRenameFolderThreeDotsButton() {
await this.renameFolderThreeDotsBtn.click();
}
async clickRenameFolderButton() {
await this.clickRenameButton();
}
async clickConfirmRenameButton() {
await this.confirmRenameBtn.click();
}
async clickUpdateFolderButton() {
await this.updateFolderBtn.click();
}
async clickUpdateButton() {
await this.updateBtn.click();
}
async clickSubmitButton() {
await expect(this.submitBtn).toBeVisible();
await this.submitBtn.click();
}
async clickConfirmToSubmitButton() {
await this.confirmToSubmitBtn.click();
}
async clickChangeButton() {
await this.changeBtn.click();
}
async clickExactLinkWithName(name: string) {
const exactLinkWithNameLocator = this.page.getByRole('link', {name: name, exact: true});
await expect(exactLinkWithNameLocator).toBeVisible();
await exactLinkWithNameLocator.click();
}
async enterAliasName(aliasName: string) {
// Unlocks alias
await this.aliasLockBtn.click();
await this.aliasNameTxt.clear();
await this.aliasNameTxt.fill(aliasName);
}
async updateIcon(iconName: string) {
await expect(this.iconBtn).toBeVisible();
// Force click is needed
await this.iconBtn.click({force: true});
await this.searchForTypeToFilterValue(iconName);
await this.clickLabelWithName(iconName, true, true);
await this.clickSubmitButton();
}
async clickTextButtonWithName(name: string) {
await expect(this.page.getByText(name, {exact: true})).toBeVisible();
await this.page.getByText(name, {exact: true}).click();
}
async clickSelectPropertyEditorButton() {
await expect(this.selectPropertyEditorBtn).toBeVisible();
await this.selectPropertyEditorBtn.click();
}
async clickCreateFolderButton() {
await this.createFolderBtn.click();
}
async enterAPropertyName(name: string) {
await expect(this.propertyNameTxt).toBeVisible();
await this.propertyNameTxt.fill(name);
}
async clickConfirmButton() {
await this.confirmBtn.click();
}
async clickBreadcrumbButton() {
await this.breadcrumbBtn.click();
}
async clickInsertButton() {
await expect(this.insertBtn).toBeVisible();
await this.insertBtn.click();
}
async clickConfirmToDeleteButton() {
await this.confirmToDeleteBtn.click();
}
async clickConfirmCreateFolderButton() {
await this.confirmCreateFolderBtn.click();
}
async clickRemoveExactButton() {
await this.removeExactBtn.click();
}
async clickRemoveButtonForName(name: string) {
await this.page.locator('[name="' + name + '"] [Label="Remove"]').click();
}
async clickTrashIconButtonForName(name: string) {
await this.page.locator('[name="' + name + '"] [name="icon-trash"]').click();
}
async clickRemoveWithName(name: string) {
const removeLabelWithNameLocator = this.page.locator('[label="Remove ' + name + '"]');
await expect(removeLabelWithNameLocator).toBeVisible();
await removeLabelWithNameLocator.click();
}
async clickDisableButton() {
await this.disableBtn.click();
}
async clickConfirmDisableButton() {
await this.confirmDisableBtn.click();
}
async clickConfirmRemoveButton() {
await this.confirmToRemoveBtn.click();
}
async clickEnableButton() {
await this.enableBtn.click();
}
async clickConfirmEnableButton() {
await this.confirmEnableBtn.click();
}
async insertDictionaryItem(dictionaryName: string) {
await this.clickInsertButton();
await expect(this.insertDictionaryItemBtn).toBeVisible();
await this.insertDictionaryItemBtn.click();
await expect(this.page.getByLabel(dictionaryName)).toBeVisible();
await this.page.getByLabel(dictionaryName).click();
await this.chooseBtn.click();
}
async addQueryBuilderWithOrderByStatement(propertyAlias: string, isAscending: boolean) {
await expect(this.queryBuilderBtn).toBeVisible({timeout: 10000});
await this.queryBuilderBtn.click();
await expect(this.orderByPropertyAliasBtn).toBeVisible();
await this.orderByPropertyAliasBtn.click();
// Wait and choose property alias option
await this.waitAndSelectQueryBuilderDropDownList(propertyAlias);
await expect(this.orderByPropertyAliasBtn).toBeVisible();
await this.orderByPropertyAliasBtn.click();
// Click to ascending button if isAscending is false
if (!isAscending) {
await expect(this.ascendingBtn).toBeVisible();
await this.ascendingBtn.click();
}
}
async addQueryBuilderWithWhereStatement(propertyAlias: string, operator: string, constrainValue: string) {
await expect(this.queryBuilderBtn).toBeVisible({timeout: 10000});
await this.queryBuilderBtn.click();
// Wait and choose property alias
await expect(this.wherePropertyAliasBtn).toBeVisible();
await this.wherePropertyAliasBtn.click();
await this.waitAndSelectQueryBuilderDropDownList(propertyAlias);
// Wait and choose operator
await expect(this.whereOperatorBtn).toBeVisible();
await this.whereOperatorBtn.click();
await this.waitAndSelectQueryBuilderDropDownList(operator);
// Wait and choose constrain value and press Enter
await expect(this.whereConstrainValueTxt).toBeVisible();
await this.whereConstrainValueTxt.clear();
await this.whereConstrainValueTxt.fill(constrainValue);
await this.whereConstrainValueTxt.press('Enter');
}
async waitAndSelectQueryBuilderDropDownList(option: string) {
const ddlOption = this.page.locator('[open]').locator('uui-combobox-list-option').filter({hasText: option}).first();
await expect(ddlOption).toBeVisible({timeout: 10000});
await ddlOption.click();
}
async createFolder(folderName: string) {
await this.clickActionsMenuCreateButton();
await this.clickNewFolderThreeDotsButton();
await this.enterFolderName(folderName);
await this.clickConfirmCreateFolderButton();
}
async deletePropertyEditor(propertyEditorName: string) {
// We need to hover over the property to be able to see the delete button
await this.page.locator('uui-button').filter({hasText: propertyEditorName}).getByLabel('Editor settings').hover();
await this.deleteBtn.click();
}
async enterFolderName(folderName: string) {
await expect(this.folderNameTxt).toBeVisible();
await this.folderNameTxt.clear();
await this.folderNameTxt.fill(folderName);
await expect(this.folderNameTxt).toHaveValue(folderName);
}
async isTextWithExactNameVisible(name: string, isVisible = true) {
return expect(this.page.getByText(name, {exact: true})).toBeVisible({visible: isVisible});
}
async isQueryBuilderCodeShown(code: string) {
await expect(this.queryBuilderShowCode).toBeVisible();
await this.queryBuilderShowCode.click();
await expect(this.queryBuilderShowCode).toContainText(code, {timeout: 10000});
}
async deleteFolder() {
await this.clickDeleteButton();
await this.clickConfirmToDeleteButton();
}
async clickDeleteExactButton() {
await this.deleteExactBtn.click();
}
async isTreeItemVisible(name: string, isVisible = true) {
await expect(this.page.locator('umb-tree-item').locator('[label="' + name + '"]')).toBeVisible({visible: isVisible});
}
async doesTreeItemHaveTheCorrectIcon(name: string, icon: string) {
return await expect(this.page.locator('umb-tree-item').filter({hasText: name}).locator('umb-icon').locator('[name="' + icon + '"]')).toBeVisible();
}
async goToSection(sectionName: string, checkSections = true) {
if (checkSections) {
for (let section in ConstantHelper.sections) {
await expect(this.backOfficeHeader.getByRole('tab', {name: ConstantHelper.sections[section]})).toBeVisible({timeout: 30000});
}
}
await this.backOfficeHeader.getByRole('tab', {name: sectionName}).click();
}
async goToSettingsTreeItem(settingsTreeItemName: string) {
await this.goToSection(ConstantHelper.sections.settings);
await expect(this.page.getByLabel(settingsTreeItemName, {exact: true})).toBeVisible();
await this.page.getByLabel(settingsTreeItemName, {exact: true}).click();
}
async clickDataElement(elementName: string, options: any = null) {
await this.page.click(`[data-element="${elementName}"]`, options);
}
async getDataElement(elementName: string) {
return this.page.locator(`[data-element="${elementName}"]`);
}
async isButtonWithNameVisible(name: string) {
await expect(this.page.getByRole('button', {name: name})).toBeVisible();
}
async clickLabelWithName(name: string, isExact: boolean = true, toForce: boolean = false) {
await expect(this.page.getByLabel(name, {exact: isExact})).toBeVisible();
await this.page.getByLabel(name, {exact: isExact}).click({force: toForce});
}
async clickButtonWithName(name: string, isExact: boolean = false) {
const exactButtonWithNameLocator = this.page.getByRole('button', {name: name, exact: isExact});
await expect(exactButtonWithNameLocator).toBeVisible();
// Force click is needed
await exactButtonWithNameLocator.click({force: true});
}
async isSuccessNotificationVisible(isVisible: boolean = true) {
return await expect(this.successNotification.first()).toBeVisible({visible: isVisible, timeout: 10000});
}
async doesSuccessNotificationsHaveCount(count: number) {
return await expect(this.successNotification).toHaveCount(count);
}
async isErrorNotificationVisible(isVisible: boolean = true) {
return await expect(this.errorNotification.first()).toBeVisible({visible: isVisible});
}
async isTextWithMessageVisible(message: string, isVisible: boolean = true) {
return await expect(this.page.getByText(message)).toBeVisible({visible: isVisible});
}
async clickCreateThreeDotsButton() {
await this.createThreeDotsBtn.click();
}
async clickCreateButton() {
await expect(this.createBtn).toBeVisible();
await this.createBtn.click();
}
async clickActionsMenuCreateButton() {
await expect(this.actionMenucreateBtn).toBeVisible();
await this.actionMenucreateBtn.click();
}
async clickAddButton() {
await expect(this.addBtn).toBeVisible();
await this.addBtn.click();
};
async clickNewFolderThreeDotsButton() {
await this.newFolderThreeDotsBtn.click();
}
async clickEditorSettingsButton(index: number = 0) {
return this.editorSettingsBtn.nth(index).click();
}
async enterDescription(description: string) {
await this.enterDescriptionTxt.fill(description);
}
async doesDescriptionHaveValue(value: string, index: number = 0) {
return await expect(this.descriptionBtn.nth(index)).toHaveValue(value);
}
async clickStructureTab() {
await this.page.waitForTimeout(1000);
await this.structureTabBtn.waitFor({state: 'visible'});
await this.structureTabBtn.click();
}
async clickAllowAtRootButton() {
await this.allowAtRootBtn.click();
}
async clickIAmDoneReorderingButton() {
await this.iAmDoneReorderingBtn.click();
}
async clickReorderButton() {
await expect(this.reorderBtn).toBeVisible();
await this.reorderBtn.click();
}
async clickLabelAboveButton() {
await this.labelAboveBtn.click();
}
async clickMandatoryToggle() {
await this.mandatoryToggle.click();
}
async selectValidationOption(option: string) {
await this.validation.selectOption(option);
}
async enterRegEx(regEx: string) {
await expect(this.regexTxt).toBeVisible();
await this.regexTxt.fill(regEx);
}
async enterRegExMessage(regExMessage: string) {
await expect(this.regexMessageTxt).toBeVisible();
await this.regexMessageTxt.fill(regExMessage);
}
async clickCompositionsButton() {
await expect(this.compositionsBtn).toBeVisible();
await this.compositionsBtn.click();
}
async clickAddTabButton() {
await expect(this.addTabBtn).toBeVisible();
await this.addTabBtn.click();
}
async enterTabName(tabName: string) {
await expect(this.unnamedTxt).toBeVisible();
await this.page.waitForTimeout(400);
await this.unnamedTxt.clear();
await this.unnamedTxt.fill(tabName);
}
async searchForTypeToFilterValue(searchValue: string) {
await expect(this.typeToFilterSearchTxt).toBeVisible();
await this.typeToFilterSearchTxt.fill(searchValue);
}
async addPropertyEditor(propertyEditorName: string, index: number = 0) {
await expect(this.addPropertyBtn.nth(index)).toBeVisible();
await this.addPropertyBtn.nth(index).click();
await this.enterAPropertyName(propertyEditorName);
await expect(this.propertyNameTxt).toHaveValue(propertyEditorName);
await this.clickSelectPropertyEditorButton();
await this.searchForTypeToFilterValue(propertyEditorName);
await this.page.getByText(propertyEditorName, {exact: true}).click();
await this.clickSubmitButton();
}
async updatePropertyEditor(propertyEditorName: string) {
await this.clickEditorSettingsButton();
await this.clickChangeButton();
await this.searchForTypeToFilterValue(propertyEditorName);
await this.page.getByText(propertyEditorName, {exact: true}).click();
await this.enterAPropertyName(propertyEditorName);
await this.clickSubmitButton();
}
async enterPropertyEditorDescription(description: string) {
await expect(this.enterPropertyEditorDescriptionTxt).toBeVisible();
await this.enterPropertyEditorDescriptionTxt.clear();
await this.enterPropertyEditorDescriptionTxt.fill(description);
}
async clickAddGroupButton() {
await this.addGroupBtn.click();
}
async clickChooseModalButton() {
await expect(this.chooseModalBtn).toBeVisible();
await this.chooseModalBtn.click();
}
async enterGroupName(groupName: string, index: number = 0) {
const groupNameTxt = this.groupLabel.nth(index);
await expect(groupNameTxt).toBeVisible();
await groupNameTxt.clear();
await groupNameTxt.fill(groupName);
}
async isGroupVisible(groupName: string, isVisible = true) {
await expect(this.groupLabel.filter({hasText: groupName})).toBeVisible({visible: isVisible});
}
async doesGroupHaveValue(value: string) {
await expect(this.groupLabel).toBeVisible();
return await expect(this.groupLabel).toHaveValue(value);
}
async rename(newName: string) {
await this.clickRenameButton();
await expect(this.newNameTxt).toBeVisible();
await this.newNameTxt.click();
await this.newNameTxt.clear();
await this.newNameTxt.fill(newName);
await this.renameModalBtn.click();
}
async isSuccessButtonWithTextVisible(text: string) {
return await expect(this.successState.filter({hasText: text})).toBeVisible();
}
async dragAndDrop(dragFromSelector: Locator, dragToSelector: Locator, verticalOffset: number = 0, horizontalOffset: number = 0, steps: number = 5) {
await expect(dragFromSelector).toBeVisible();
await expect(dragToSelector).toBeVisible();
const targetLocation = await dragToSelector.boundingBox();
const elementCenterX = targetLocation!.x + targetLocation!.width / 2;
const elementCenterY = targetLocation!.y + targetLocation!.height / 2;
await dragFromSelector.hover();
await this.page.mouse.move(10, 10);
await dragFromSelector.hover();
await this.page.mouse.down();
await this.page.waitForTimeout(400);
await this.page.mouse.move(elementCenterX + horizontalOffset, elementCenterY + verticalOffset, {steps: steps});
await this.page.waitForTimeout(400);
await this.page.mouse.up();
}
async getButtonWithName(name: string) {
await expect(this.page.getByRole('button', {name: name})).toBeVisible();
return this.page.getByRole('button', {name: name});
}
async clickCreateLink() {
await expect(this.createLink).toBeVisible();
await this.createLink.click();
}
async insertSystemFieldValue(fieldValue: string) {
await this.clickInsertButton();
await expect(this.insertValueBtn).toBeVisible();
await this.insertValueBtn.click();
await expect(this.chooseFieldDropDown).toBeVisible();
await this.chooseFieldDropDown.click();
await this.systemFieldsOption.click();
await this.chooseFieldValueDropDown.click();
await this.page.getByText(fieldValue).click();
await this.clickSubmitButton();
}
async insertPartialView(partialViewName: string) {
await this.clickInsertButton();
await expect(this.insertPartialViewBtn).toBeVisible();
await this.insertPartialViewBtn.click();
await expect(this.page.getByLabel(partialViewName)).toBeVisible();
await this.page.getByLabel(partialViewName).click();
await this.chooseBtn.click();
}
async deletePropertyEditorWithName(name: string) {
// We need to hover over the Property Editor to make the delete button visible
const propertyEditor = this.page.locator('umb-content-type-design-editor-property', {hasText: name});
await expect(propertyEditor).toBeVisible();
await propertyEditor.hover();
await expect(propertyEditor.getByLabel('Delete')).toBeVisible();
// Force click is needed
await propertyEditor.getByLabel('Delete').click({force: true});
await this.clickConfirmToDeleteButton();
}
async clickRenameButton() {
await expect(this.renameBtn).toBeVisible();
await this.renameBtn.click();
}
async clickDeleteAndConfirmButton() {
await this.clickDeleteButton();
await this.clickConfirmToDeleteButton();
}
async clickDeleteButton() {
await expect(this.deleteBtn).toBeVisible();
await this.deleteBtn.click();
}
async clickQueryBuilderButton() {
await expect(this.queryBuilderBtn).toBeVisible();
await this.queryBuilderBtn.click();
}
async chooseRootContentInQueryBuilder(contentName: string) {
await expect(this.chooseRootContentBtn).toBeVisible();
await this.chooseRootContentBtn.click();
await expect(this.page.getByText(contentName)).toBeVisible();
await this.page.getByText(contentName).click();
await this.clickChooseButton();
}
async reorderTwoGroups() {
const firstGroup = this.typeGroups.nth(0);
const secondGroup = this.typeGroups.nth(1);
const firstGroupValue = await firstGroup.getByLabel('Group', {exact: true}).inputValue();
const secondGroupValue = await secondGroup.getByLabel('Group', {exact: true}).inputValue();
const dragToLocator = firstGroup.locator('[slot="header"]').first();
const dragFromLocator = secondGroup.locator('[slot="header"]').first();
await this.dragAndDrop(dragFromLocator, dragToLocator, 0, 0, 10);
return {firstGroupValue, secondGroupValue};
}
async clickAllowedChildNodesButton() {
await expect(this.allowedChildNodesModal.locator(this.chooseBtn)).toBeVisible();
await this.allowedChildNodesModal.locator(this.chooseBtn).click();
}
async clickAddCollectionButton() {
await expect(this.addCollectionBtn).toBeVisible();
await this.addCollectionBtn.click();
}
async doesReturnedItemsHaveCount(itemCount: number) {
await expect(this.returnedItemsCount).toContainText(itemCount.toString() + ' items returned');
}
async doesQueryResultHaveContentName(contentName: string) {
await expect(this.queryBuilderShowCode).toContainText(contentName);
}
async deleteGroup(groupName: string) {
await this.page.waitForTimeout(1000);
const groups = this.page.locator('umb-content-type-design-editor-group').all();
for (const group of await groups) {
if (await group.getByLabel('Group', {exact: true}).inputValue() === groupName) {
const headerActionsDeleteLocator = group.locator('[slot="header-actions"]').getByLabel('Delete');
await expect(headerActionsDeleteLocator).toBeVisible();
// Force click is needed
await headerActionsDeleteLocator.click({force: true});
return;
}
}
}
async clickRemoveTabWithName(name: string) {
await expect(this.page.locator('uui-tab').filter({hasText: name})).toBeVisible();
await this.page.locator('uui-tab').filter({hasText: name}).hover();
const removeTabWithNameLocator = this.page.locator('uui-tab').filter({hasText: name}).locator('[label="Remove"]');
await expect(removeTabWithNameLocator).toBeVisible();
await removeTabWithNameLocator.click();
}
async clickLeftArrowButton() {
await expect(this.leftArrowBtn).toBeVisible();
await this.leftArrowBtn.click();
}
async clickToUploadButton() {
await expect(this.clickToUploadBtn).toBeVisible();
await this.clickToUploadBtn.click();
}
async uploadFile(filePath: string) {
const fileChooserPromise = this.page.waitForEvent('filechooser');
await this.clickToUploadButton();
const fileChooser = await fileChooserPromise;
await fileChooser.setFiles(filePath);
}
getTabLocatorWithName(name: string) {
return this.page.getByRole('tab', {name: name});
}
getTextLocatorWithName(name: string) {
return this.page.getByText(name, {exact: true});
}
async isFailedStateButtonVisible() {
await expect(this.failedStateButton).toBeVisible();
}
async clickContainerSaveAndPublishButton() {
await expect(this.containerSaveAndPublishBtn).toBeVisible();
await this.containerSaveAndPublishBtn.click();
}
async clickConfirmTrashButton() {
await expect(this.confirmTrashBtn).toBeVisible();
await this.confirmTrashBtn.click();
}
async reloadRecycleBin(containsItems = true) {
// We need to wait to be sure that the item is visible after reload
await expect(this.recycleBinMenuItem).toBeVisible();
await this.clickActionsMenuForName('Recycle Bin');
await this.clickReloadChildrenButton();
await expect(this.recycleBinMenuItem).toBeVisible();
// If the Recycle Bin does not contain any items,0 the caret button should not be visible. and we should not try to click it
if (!containsItems) {
await expect(this.recycleBinMenuItemCaretBtn).not.toBeVisible();
return;
}
await expect(this.recycleBinMenuItemCaretBtn).toBeVisible();
const isCaretButtonOpen = await this.recycleBinMenuItem.getAttribute('show-children');
if (isCaretButtonOpen === null) {
// We need to wait before clicking the caret button. Because the reload might not have happened yet.
await this.clickCaretButtonForName('Recycle Bin');
}
}