2 - Add a new user as a member.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. Copyright (C) 2018 Cloudbase Solutions SRL
  3. This program is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU Affero General Public License as
  5. published by the Free Software Foundation, either version 3 of the
  6. License, or (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU Affero General Public License for more details.
  11. You should have received a copy of the GNU Affero General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. */
  14. // @flow
  15. describe('Adds a new user as a member to the project', () => {
  16. before(() => {
  17. cy.login()
  18. })
  19. beforeEach(() => {
  20. Cypress.Cookies.preserveOnce('token', 'projectId')
  21. })
  22. it('Shows projects details page', () => {
  23. cy.getById('navigation-smallMenuItem-projects').click()
  24. cy.getById('plItem-content').contains('cypress-project').click()
  25. cy.title().should('eq', 'Project Details')
  26. })
  27. it('Opens add member modal', () => {
  28. cy.get('button').contains('Add Member').click()
  29. cy.getById('modal-title').should('contain', 'Add Project Member')
  30. })
  31. it('Creates new user', () => {
  32. cy.getById('toggleButtonBar-new').click()
  33. cy.getById('endpointField-textInput-username').last().type('cypress-member-user')
  34. cy.getById('endpointField-textInput-description').last().type('User created by Cypress in Add Project Member modal')
  35. cy.getById('endpointField-dropdown-Primary Project').click()
  36. cy.getById('dropdownListItem').contains('cypress-project').click()
  37. cy.getById('endpointField-multidropdown-role(s)').click()
  38. cy.getById('dropdownListItem').contains('_member_').click()
  39. cy.getById('endpointField-textInput-password').last().type('cypress-member-user')
  40. cy.getById('endpointField-textInput-confirm_password').last().type('cypress-member-user')
  41. cy.server()
  42. cy.route({ url: '**/users', method: 'POST' }).as('addUser')
  43. cy.route({ url: '**/roles/**', method: 'PUT' }).as('addRole')
  44. cy.route({ url: '**/role_assignments**', method: 'GET' }).as('getRoles')
  45. cy.getById('pmModal-addButton').contains('Add Member').click()
  46. cy.wait(['@addUser', '@addRole', '@getRoles'])
  47. cy.getById('pdContent-users-cypress-member-user').its('length').should('eq', 1)
  48. cy.getById('pdContent-roles-cypress-member-user').should('contain', '_member_')
  49. })
  50. it('Adds admin as its role', () => {
  51. cy.getById('pdContent-roles-cypress-member-user').click()
  52. cy.getById('dropdownLink-listItem').contains('admin').click()
  53. cy.getById('pdContent-roles-cypress-member-user').should('contain', '_member_, admin')
  54. })
  55. it('Removes user from project', () => {
  56. cy.getById('pdContent-actions-cypress-member-user').click()
  57. cy.getById('dropdownLink-listItem').contains('Remove').click()
  58. cy.server()
  59. cy.route({ url: '**/roles/**', method: 'DELETE' }).as('deleteRole')
  60. cy.getById('aModal-yesButton').click()
  61. cy.wait('@deleteRole')
  62. cy.getById('pdContent-users-cypress-member-user').should('not.exist')
  63. })
  64. })