2 - Scheduler Operations.js 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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('Scheduler Operations', () => {
  16. before(() => {
  17. cy.login()
  18. })
  19. beforeEach(() => {
  20. Cypress.Cookies.preserveOnce('token', 'projectId')
  21. })
  22. it('Creates a schedule', () => {
  23. cy.server()
  24. cy.route('GET', '**/executions/detail').as('execution')
  25. cy.getById('mainListItem-content').first().click()
  26. cy.wait('@execution')
  27. cy.getById('detailsNavigation-schedule').click()
  28. cy.route('POST', '**/schedules').as('schedule')
  29. cy.getById('schedule-noScheduleAddButton').click()
  30. cy.wait('@schedule')
  31. cy.getById('scheduleItem-saveButton').should('not.be.visible')
  32. })
  33. it('Changes the month', () => {
  34. cy.getById('scheduleItem-monthDropdown').last().click()
  35. cy.getById('dropdownListItem').contains('October').click()
  36. cy.getById('scheduleItem-monthDropdown').last().should('contain', 'October')
  37. cy.getById('scheduleItem-saveButton').should('be.visible')
  38. })
  39. it('Changes the hour', () => {
  40. cy.getById('scheduleItem-hourDropdown').last().click()
  41. cy.getById('dropdownListItem').contains('04').click()
  42. cy.getById('scheduleItem-hourDropdown').last().should('contain', '04')
  43. })
  44. it('Changes timezone', () => {
  45. cy.getById('schedule-timezoneDropdown').click()
  46. cy.get('div').contains('UTC').click()
  47. let utcTime = 4 + (new Date().getTimezoneOffset() / 60)
  48. if (utcTime < 10) {
  49. utcTime = `0${utcTime}`
  50. }
  51. utcTime = utcTime.toString()
  52. cy.getById('scheduleItem-hourDropdown').last().should('contain', utcTime)
  53. })
  54. it('Saves the changes', () => {
  55. cy.server()
  56. cy.route('PUT', '**/schedules/**').as('schedule')
  57. cy.getById('scheduleItem-saveButton').should('be.visible').last().click()
  58. cy.wait('@schedule')
  59. cy.getById('scheduleItem-saveButton').should('not.be.visible')
  60. })
  61. it('Deletes the last schedule', () => {
  62. cy.getById('scheduleItem-deleteButton').last().click()
  63. cy.server()
  64. cy.route('DELETE', '**/schedules/**').as('schedule')
  65. cy.get('button').contains('Yes').click()
  66. cy.wait('@schedule')
  67. })
  68. })