|
| 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 | +}); |
0 commit comments