4 - Create a user.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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('Create a user', () => {
  16. before(() => {
  17. cy.login()
  18. })
  19. beforeEach(() => {
  20. Cypress.Cookies.preserveOnce('token', 'projectId')
  21. })
  22. it('Shows users page', () => {
  23. cy.getById('navigation-smallMenuItem-users').click()
  24. cy.title().should('eq', 'Users')
  25. })
  26. it('Shows new user modal', () => {
  27. cy.getById('newItemDropdown-button').click()
  28. cy.getById('newItemDropdown-listItem-User').click()
  29. cy.getById('modal-title').should('contain', 'New User')
  30. })
  31. it('Creates user', () => {
  32. cy.getById('endpointField-textInput-username').last().type('cypress-user')
  33. cy.getById('endpointField-textInput-description').last().type('User created by Cypress')
  34. cy.getById('endpointField-dropdown-Primary Project').click()
  35. cy.getById('dropdownListItem').contains('cypress-project').click()
  36. cy.getById('endpointField-textInput-new_password').last().type('cypress-user')
  37. cy.getById('endpointField-textInput-confirm_password').last().type('cypress-user')
  38. cy.server()
  39. cy.route({ url: '**/users', method: 'POST' }).as('addUser')
  40. cy.route({ url: '**/roles/**', method: 'PUT' }).as('addRole')
  41. cy.get('button').contains('New User').click()
  42. cy.wait(['@addUser', '@addRole'])
  43. cy.getById('ulItem-name').contains('cypress-user').should('exist')
  44. })
  45. })