Skip to content

Commit ea5b6e6

Browse files
xkostka2HejdaJakub
authored andcommitted
test(admin): e2e tests for group management
* implemented e2e tests for group management
1 parent 2fb11b3 commit ea5b6e6

File tree

9 files changed

+237
-4
lines changed

9 files changed

+237
-4
lines changed

apps/admin-gui-e2e/cypress.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
"BA_USERNAME": "perun",
1414
"BA_PASSWORD": "test",
1515
"BA_USERNAME_VO_MANAGER": "voManager",
16-
"BA_PASSWORD_VO_MANAGER": "test"
16+
"BA_PASSWORD_VO_MANAGER": "test",
17+
"BA_USERNAME_GROUP_MANAGER": "groupManager",
18+
"BA_PASSWORD_GROUP_MANAGER": "test"
1719
}
1820
}
Lines changed: 223 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,223 @@
1+
/// <reference types="cypress" />
2+
3+
context('Actions', () => {
4+
const dbGroupName = 'test-group-from-db-2';
5+
const dbSubGroupName = 'subgroup';
6+
const dbApplicationItemTextFieldName = 'input-test';
7+
const dbUser = 'test2';
8+
const dbGroupManager = 'group-manager-2';
9+
const addedAttribute = 'mail-footer';
10+
const dbGroupAttribute = 'notification-default-language';
11+
12+
before(() => {
13+
if (Cypress.env('BA_USERNAME_GROUP_MANAGER')) {
14+
sessionStorage.setItem('baPrincipal', '{"name": "groupManager"}');
15+
sessionStorage.setItem('basicUsername', Cypress.env('BA_USERNAME_GROUP_MANAGER'));
16+
sessionStorage.setItem('basicPassword', Cypress.env('BA_PASSWORD_GROUP_MANAGER'));
17+
cy.visit('service-access');
18+
}
19+
});
20+
21+
beforeEach(() => {
22+
cy.visit('home')
23+
.get(`[data-cy=${dbGroupName}]`)
24+
.click();
25+
});
26+
27+
it('test create subgroup', () => {
28+
29+
cy.intercept('**/groupsManager/createGroup/**').as('createGroup')
30+
.get(`[data-cy=subgroups]`)
31+
.click()
32+
.get('[data-cy=new-subgroup-button]')
33+
.click()
34+
.get('[data-cy=group-name]')
35+
.type('test-group')
36+
.get('[data-cy=group-description]')
37+
.type('test-group-description')
38+
.get('[data-cy=create-group-button-dialog]')
39+
.click()
40+
.wait('@createGroup')
41+
// assert that group was created
42+
.get('[data-cy=test-group-checkbox]')
43+
.should('exist')
44+
});
45+
46+
it('test remove subgroup', () => {
47+
48+
cy.intercept('**/groupsManager/deleteGroups').as('deleteGroups')
49+
.get('[data-cy=subgroups]')
50+
.click()
51+
.get(`[data-cy=${dbSubGroupName}-checkbox]`)
52+
.click()
53+
.get('[data-cy=delete-group-button]')
54+
.click()
55+
.get('[data-cy=delete-button-dialog]')
56+
.click()
57+
.wait('@deleteGroups')
58+
// assert that group was deleted
59+
.get(`[data-cy=${dbSubGroupName}-checkbox]`)
60+
.should('not.exist')
61+
});
62+
63+
it('test add attribute', () => {
64+
65+
cy.intercept('**/attributesManager/setAttributes/**').as('setAttributes')
66+
.get('[data-cy=attributes]')
67+
.click()
68+
.get('[data-cy=add-attributes]')
69+
.click()
70+
.get('[data-cy=filter-attributes]')
71+
.type('footer')
72+
.get(`[data-cy=${addedAttribute}-value]`)
73+
.type('test')
74+
.get('[data-cy=save-selected-attributes]')
75+
.click()
76+
.wait('@setAttributes')
77+
// assert that attribute exists
78+
.get(`[data-cy=${addedAttribute}-value]`)
79+
.should('exist')
80+
});
81+
82+
it('test delete attribute', () => {
83+
84+
cy.intercept('**/attributesManager/removeAttributes/**').as('removeAttributes')
85+
.get('[data-cy=attributes]')
86+
.click()
87+
.get(`[data-cy=${dbGroupAttribute}-checkbox]`)
88+
.click()
89+
.get('[data-cy=remove-attributes]')
90+
.click()
91+
.get('[data-cy=delete-attributes]')
92+
.click()
93+
.wait('@removeAttributes')
94+
// assert that attribute exists
95+
.get(`[data-cy=${dbGroupAttribute}-checkbox]`)
96+
.should('not.exist')
97+
});
98+
99+
it('test add group member', () => {
100+
101+
cy.intercept('**/groupsManager/addMember**').as('addMember')
102+
.get('[data-cy=members]')
103+
.click()
104+
.get('[data-cy=add-members]')
105+
.click()
106+
.get('[data-cy=search-members]')
107+
.type(`${dbUser}`)
108+
.get('[data-cy=search-button]')
109+
.click()
110+
.get(`[data-cy=${dbUser}-checkbox]`)
111+
.click()
112+
.get('[data-cy=add-button]')
113+
.click()
114+
.wait('@addMember')
115+
// assert that member was created
116+
.get(`[data-cy=${dbUser}-checkbox]`)
117+
.should('exist')
118+
});
119+
120+
it('test remove group member', () => {
121+
122+
cy.intercept('**/groupsManager/removeMember**').as('removeMember')
123+
.get('[data-cy=members]')
124+
.click()
125+
.get(`[data-cy=${dbGroupManager}-checkbox]`)
126+
.click()
127+
.get('[data-cy=remove-members]')
128+
.click()
129+
.get('[data-cy=remove-members-dialog]')
130+
.click()
131+
.wait('@removeMember')
132+
// assert that member was removed
133+
.get(`[data-cy=${dbGroupManager}-checkbox]`)
134+
.should('not.exist')
135+
});
136+
137+
it('test create group application form item', () => {
138+
139+
cy.intercept('**/registrarManager/updateFormItems/**').as('addFormItem')
140+
.get('[data-cy=advanced-settings]')
141+
.click()
142+
.get('[data-cy=application-form]')
143+
.click()
144+
.get('[data-cy=add-form-item]')
145+
.click()
146+
.get('[data-cy=item-short-name]')
147+
.type('Header')
148+
.get('[data-cy=add-form-item-button-dialog]')
149+
.click()
150+
.get('[data-cy=edit-form-item-button-dialog]')
151+
.click()
152+
.get('[data-cy=save-application-form]')
153+
.click()
154+
.wait('@addFormItem')
155+
.get('[data-cy=refresh-button]')
156+
.click()
157+
// assert that form item exists
158+
.get('[data-cy=header-delete]')
159+
.should('exist')
160+
});
161+
162+
it('test delete group application form item', () => {
163+
cy.intercept('**/registrarManager/updateFormItems/**').as('deleteFormItem')
164+
.get('[data-cy=advanced-settings]')
165+
.click()
166+
.get('[data-cy=application-form]')
167+
.click()
168+
.get(`[data-cy=${dbApplicationItemTextFieldName}-delete]`)
169+
.click()
170+
.get('[data-cy=delete-application-form-item-dialog]')
171+
.click()
172+
.get('[data-cy=save-application-form]')
173+
.click()
174+
.wait('@deleteFormItem')
175+
.get('[data-cy=refresh-button]')
176+
.click()
177+
// assert that form item doesn't exist
178+
.get(`[data-cy=${dbApplicationItemTextFieldName}-delete]`)
179+
.should('not.exist')
180+
});
181+
182+
it('test add group manager', () => {
183+
184+
cy.intercept('**/authzResolver/setRole/**').as('setRole')
185+
.get('[data-cy=advanced-settings]')
186+
.click()
187+
.get('[data-cy=managers]')
188+
.click()
189+
.get('[data-cy=add-manager-button]')
190+
.click()
191+
.get('[data-cy=search-manager-input]')
192+
.type(`${dbUser}`)
193+
.get('[data-cy=search-manager-button]')
194+
.click()
195+
.get(`[data-cy=${dbUser}-checkbox]`)
196+
.click()
197+
.get('[data-cy=add-manager-button-dialog]')
198+
.click()
199+
.wait('@setRole')
200+
// assert that manager was added
201+
.get(`[data-cy=${dbUser}-checkbox]`)
202+
.should('exist')
203+
});
204+
205+
it('test remove group manager', () => {
206+
207+
cy.intercept('**/authzResolver/unsetRole/**').as('unsetRole')
208+
.get('[data-cy=advanced-settings]')
209+
.click()
210+
.get('[data-cy=managers]')
211+
.click()
212+
.get(`[data-cy=${dbGroupManager}-checkbox]`)
213+
.click()
214+
.get('[data-cy=remove-manager-button]')
215+
.click()
216+
.get('[data-cy=remove-manager-button-dialog]')
217+
.click()
218+
.wait('@unsetRole')
219+
// assert that manager doesn't exist
220+
.get(`[data-cy=${dbGroupManager}-checkbox]`)
221+
.should('not.exist')
222+
});
223+
});

apps/admin-gui/src/app/shared/components/dialogs/create-attribute-dialog/create-attribute-dialog.component.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<div mat-dialog-title>
33
<h1 class="page-subtitle">{{'DIALOGS.CREATE_ATTRIBUTE.SET_NEW' | translate}}</h1>
44
<perun-web-apps-immediate-filter (filter)="applyFilter($event)" [placeholder]="'SHARED_LIB.PERUN.COMPONENTS.ATTRIBUTES_LIST.FILTER'"
5+
data-cy="filter-attributes"
56
class="font-size-1rem"></perun-web-apps-immediate-filter>
67
<app-alert *ngIf="showError" class="ml-3 font-size-1rem" alert_type="error">
78
{{'DIALOGS.CREATE_ATTRIBUTE.ERROR_EMPTY_VALUE' | translate}}

apps/admin-gui/src/app/vos/pages/group-detail-page/group-members/group-members.component.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ <h1 class="page-subtitle">{{'GROUP_DETAIL.MEMBERS.TITLE' | translate}}</h1>
1616
[disabled]="synchEnabled || blockGroupManualMemberAdding"
1717
class="mr-2 action-button"
1818
color="accent"
19+
data-cy="add-members"
1920
mat-flat-button>
2021
{{'GROUP_DETAIL.MEMBERS.ADD_MEMBER' | translate}}
2122
</button>
@@ -45,6 +46,7 @@ <h1 class="page-subtitle">{{'GROUP_DETAIL.MEMBERS.TITLE' | translate}}</h1>
4546
[disabled]="selection.isEmpty() || synchEnabled"
4647
class="mr-2"
4748
color="warn"
49+
data-cy="remove-members"
4850
mat-flat-button>
4951
{{'GROUP_DETAIL.MEMBERS.REMOVE_MEMBERS' | translate}}
5052
</button>

apps/admin-gui/src/app/vos/pages/group-detail-page/group-settings/group-settings-application-form/group-settings-application-form.component.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ <h1 class="page-subtitle">
6060
mat-flat-button
6161
color="accent"
6262
class="mr-2 action-button"
63+
data-cy=add-form-item
6364
(click)="add()">
6465
{{'GROUP_DETAIL.SETTINGS.APPLICATION_FORM.ADD_BUTTON' | translate}}
6566
</button>
@@ -70,6 +71,7 @@ <h1 class="page-subtitle">
7071
color="accent"
7172
class="mr-2"
7273
[disabled]="!itemsChanged"
74+
data-cy="save-application-form"
7375
(click)="save()">
7476
<i class="material-icons">save</i>
7577
{{'VO_DETAIL.SETTINGS.APPLICATION_FORM.SAVE_BUTTON' | translate}}
@@ -121,6 +123,7 @@ <h1 class="page-subtitle">
121123
<button
122124
*ngIf="createEmptyForm"
123125
mat-stroked-button
126+
data-cy="create-empty-form"
124127
(click)="createEmptyApplicationForm()">
125128
{{'GROUP_DETAIL.SETTINGS.APPLICATION_FORM.CREATE_APPLICATION_FORM' | translate}}
126129
</button>

apps/admin-gui/src/app/vos/pages/group-detail-page/group-subgroups/group-subgroups.component.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ <h1 class="page-subtitle">{{'GROUP_DETAIL.SUBGROUPS.TITLE' | translate}}</h1>
66
(click)="onCreateGroup()"
77
class="mr-2 action-button"
88
color="accent"
9+
data-cy="new-subgroup-button"
910
mat-flat-button>
1011
{{'GROUP_DETAIL.SUBGROUPS.CREATE_GROUP' | translate}}
1112
</button>
@@ -20,6 +21,7 @@ <h1 class="page-subtitle">{{'GROUP_DETAIL.SUBGROUPS.TITLE' | translate}}</h1>
2021
mat-flat-button
2122
color="warn"
2223
class="mr-2"
24+
data-cy=delete-group-button
2325
[disabled]="selected.selected.length === 0 ||
2426
(tree !== undefined && !tree.removeAuth) ||
2527
(list !== undefined && !list.removeAuth)">
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
<div>
2-
<mat-checkbox (change)="_sendEventToParent()" *ngIf="!readonly" [(ngModel)]="attribute.value"></mat-checkbox>
2+
<mat-checkbox (change)="_sendEventToParent()" *ngIf="!readonly" [(ngModel)]="attribute.value" attr.data-cy="{{attribute.displayName | multiWordDataCy}}-value"></mat-checkbox>
33
<mat-label *ngIf="readonly">{{attribute.value}}</mat-label>
44
</div>

libs/perun/components/src/lib/groups-list/groups-list.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
<ng-container matColumnDef="name">
7171
<th *matHeaderCellDef mat-header-cell
7272
mat-sort-header>{{'SHARED_LIB.PERUN.COMPONENTS.GROUPS_LIST.TABLE_GROUP_NAME' | translate}}</th>
73-
<td *matCellDef="let group" mat-cell>
73+
<td *matCellDef="let group" attr.data-cy="{{group.name}}" mat-cell>
7474
{{group.name}}
7575
</td>
7676
</ng-container>

libs/perun/components/src/lib/groups-tree/groups-tree.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
</mat-icon>
3535
</button>
3636
<div class="w-50">
37-
<span class="mr-2">
37+
<span attr.data-cy="{{group.name}}" class="mr-2">
3838
{{group.name}}
3939
</span>
4040
<span *ngIf="authResolver.isPerunAdminOrObserver()" class="text-muted">

0 commit comments

Comments
 (0)