5 - Edit and delete user.js 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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('Edit created user', () => {
  16. before(() => {
  17. cy.login()
  18. })
  19. beforeEach(() => {
  20. Cypress.Cookies.preserveOnce('token', 'projectId')
  21. })
  22. it('Shows user details page', () => {
  23. cy.getById('navigation-smallMenuItem-users').click()
  24. cy.server()
  25. cy.route({ url: '**/role_assignments**', method: 'GET' }).as('getRoles')
  26. cy.getById('ulItem-name').contains('cypress-user').click()
  27. cy.wait('@getRoles')
  28. cy.title().should('eq', 'User Details')
  29. cy.getById('dcHeader-title').should('contain', 'cypress-user')
  30. })
  31. it('Opens user edit modal', () => {
  32. cy.getById('dcHeader-actionButton').click()
  33. cy.getById('actionDropdown-listItem-Edit user').click()
  34. cy.getById('modal-title').should('contain', 'Update User')
  35. })
  36. it('Edits user', () => {
  37. cy.getById('endpointField-textInput-username').last().clear()
  38. cy.getById('endpointField-textInput-username').last().type('user-cypress')
  39. cy.server()
  40. cy.route({ url: '**/users/**', method: 'PATCH' }).as('updateUser')
  41. cy.route({ url: '**/role_assignments**', method: 'GET' }).as('getRoles')
  42. cy.get('button').contains('Update User').click()
  43. cy.wait(['@updateUser', '@getRoles'])
  44. cy.getById('dcHeader-title').should('contain', 'user-cypress')
  45. })
  46. it('Deletes the user', () => {
  47. cy.server()
  48. cy.get('button').contains('Delete user').click()
  49. cy.route({ url: '**/users/**', method: 'DELETE' }).as('deleteUser')
  50. cy.route({ url: '**/users', method: 'GET' }).as('getUsers')
  51. cy.getById('aModal-yesButton').click()
  52. cy.wait(['@deleteUser', '@getUsers'])
  53. cy.getById('ulItem-name').contains('user-cypress').should('not.exist')
  54. })
  55. })