Skip to content

Commit

Permalink
feat(admin): added e2e tests for role RESOURCESELFSERVICE
Browse files Browse the repository at this point in the history
* added e2e tests to test basic use cases for role RESOURCESELFSERVICE
* fixed login credentials for e2e tests for role TOPGROUPCREATOR
  • Loading branch information
xkostka2 authored and HejdaJakub committed Sep 8, 2022
1 parent d6163ca commit e384259
Show file tree
Hide file tree
Showing 4 changed files with 104 additions and 4 deletions.
5 changes: 4 additions & 1 deletion apps/admin-gui-e2e/cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ export default defineConfig({
BA_PASSWORD_FACILITY_MANAGER: 'test',
BA_USERNAME_RESOURCE_MANAGER: 'resourceManager',
BA_PASSWORD_RESOURCE_MANAGER: 'test',
BA_PASSWORD_TOP_GROUP_CREATOR: 'topGroupCreator',
BA_USERNAME_TOP_GROUP_CREATOR: 'topGroupCreator',
BA_PASSWORD_TOP_GROUP_CREATOR: 'test',
BA_USERNAME_RESOURCE_SELF_SERVICE: 'resourceSelfService',
BA_PASSWORD_RESOURCE_SELF_SERVICE: 'test',
BA_USERNAME_TRUSTED_FACILITY_ADMIN: 'trustedFacilityAdmin',
BA_PASSWORD_TRUSTED_FACILITY_ADMIN: 'test',
},
Expand Down
97 changes: 97 additions & 0 deletions apps/admin-gui-e2e/src/e2e/resource-self-service-perun_admin.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
/// <reference types="cypress" />

context('Actions', () => {
const dbVoName = 'test-e2e-vo-from-db-6';
const dbResourceName = 'test-e2e-resource-from-db-4';

const dbGroupToAssign = 'test-e2e-group-from-db-9';
const dbGroupToRemove = 'test-e2e-group-from-db-8';
const dbGroupToActivate = 'test-e2e-group-from-db-7';
const dbGroupToDeactivate = 'test-e2e-group-from-db-6';


before(() => {
if (Cypress.env('BA_USERNAME_RESOURCE_SELF_SERVICE')) {
sessionStorage.setItem('baPrincipal', '{"name": "resourceSelfService"}');
sessionStorage.setItem('basicUsername', Cypress.env('BA_USERNAME_RESOURCE_SELF_SERVICE'));
sessionStorage.setItem('basicPassword', Cypress.env('BA_PASSWORD_RESOURCE_SELF_SERVICE'));
cy.visit('service-access');
}
});

beforeEach(() => {
cy.visit('organizations')
.get(`[data-cy=${dbVoName}]`)
.click()
.get('[data-cy=resources]')
.click()
.get('[data-cy=resource-list]')
.click()
.get(`[data-cy=${dbResourceName}]`)
.click()
.get('[data-cy=assigned-groups]')
.click();
});

it('test assign group to resource', () => {
cy.get('[data-cy=add-group-button]')
.click()
.get(`[data-cy=${dbGroupToAssign}-checkbox]`)
.click()
.get('[data-cy=next-button]')
.click()
.intercept('**/resourcesManager/getGroupAssignments**')
.as('getGroupAssignments')
.get('[data-cy=assign-button]')
.click()
.wait('@getGroupAssignments')

// assert that group was added
.get(`[data-cy=${dbGroupToAssign}-checkbox]`)
.should('exist');
});

it('test remove group from resource', () => {
cy.get(`[data-cy=${dbGroupToRemove}-checkbox]`)
.click()
.get('[data-cy=remove-group-button]')
.click()
.intercept('**/resourcesManager/getGroupAssignments**')
.as('getGroupAssignments')
.get('[data-cy=delete-button]')
.click()
.wait('@getGroupAssignments')

// assert that group was removed
.get(`[data-cy=${dbGroupToRemove}-checkbox]`)
.should('not.exist');
});

it('test activate group resource assignment', () => {
cy.get(`[data-cy=${dbGroupToActivate}-inactive]`)
.click()
.intercept('**/resourcesManager/activateGroupResourceAssignment**')
.as('activateGroupResourceAssignment')
.get('[data-cy=change-status-button]')
.click()
.wait('@activateGroupResourceAssignment')

// assert that group is active
.get(`[data-cy=${dbGroupToActivate}-active]`)
.should('exist');
});

it('test deactivate group resource assignment', () => {
cy.get(`[data-cy=${dbGroupToDeactivate}-active]`)
.click()
.intercept('**/resourcesManager/deactivateGroupResourceAssignment**')
.as('deactivateGroupResourceAssignment')
.get('[data-cy=change-status-button]')
.click()
.wait('@deactivateGroupResourceAssignment')

// assert that group is inactive
.get(`[data-cy=${dbGroupToDeactivate}-inactive]`)
.should('exist');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ context('Actions', () => {
const groupName = 'test';

before(() => {
if (Cypress.env('BA_PASSWORD_TOP_GROUP_CREATOR')) {
if (Cypress.env('BA_USERNAME_TOP_GROUP_CREATOR')) {
sessionStorage.setItem('baPrincipal', '{"name": "topGroupCreator"}');
sessionStorage.setItem('basicUsername', Cypress.env('BA_PASSWORD_TOP_GROUP_CREATOR'));
sessionStorage.setItem('basicUsername', Cypress.env('BA_USERNAME_TOP_GROUP_CREATOR'));
sessionStorage.setItem('basicPassword', Cypress.env('BA_PASSWORD_TOP_GROUP_CREATOR'));
cy.visit('service-access');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import { ChangeGroupResourceAssigmentDialogComponent } from '@perun-web-apps/per
export class GroupResourceStatusComponent {
@Input() status = '';
@Input() groupId: number;
@Input() groupName = '';
@Input() resourceId: number;
@Input() groupName: string;
@Input() theme: string;
@Input() failureCause: string;
@Output() statusChange: EventEmitter<void> = new EventEmitter<void>();
Expand Down

0 comments on commit e384259

Please sign in to comment.