6 - Edit and delete project.js 2.3 KB

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