1
0

admin-settings_default-app.cy.ts 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /**
  2. * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
  3. * SPDX-License-Identifier: AGPL-3.0-or-later
  4. */
  5. import { User } from '@nextcloud/cypress'
  6. import { NavigationHeader } from '../../pages/NavigationHeader'
  7. const admin = new User('admin', 'admin')
  8. describe('Admin theming set default apps', () => {
  9. const navigationHeader = new NavigationHeader()
  10. before(function() {
  11. // Just in case previous test failed
  12. cy.resetAdminTheming()
  13. cy.login(admin)
  14. })
  15. it('See the current default app is the dashboard', () => {
  16. // check default route
  17. cy.visit('/')
  18. cy.url().should('match', /apps\/dashboard/)
  19. // Also check the top logo link
  20. navigationHeader.logo().click()
  21. cy.url().should('match', /apps\/dashboard/)
  22. })
  23. it('See the default app settings', () => {
  24. cy.visit('/settings/admin/theming')
  25. cy.get('.settings-section').contains('Navigation bar settings').should('exist')
  26. cy.get('[data-cy-switch-default-app]').should('exist')
  27. cy.get('[data-cy-switch-default-app]').scrollIntoView()
  28. })
  29. it('Toggle the "use custom default app" switch', () => {
  30. cy.get('[data-cy-switch-default-app] input').should('not.be.checked')
  31. cy.get('[data-cy-switch-default-app] .checkbox-content').click()
  32. cy.get('[data-cy-switch-default-app] input').should('be.checked')
  33. })
  34. it('See the default app order selector', () => {
  35. cy.get('[data-cy-app-order] [data-cy-app-order-element]').then(elements => {
  36. const appIDs = elements.map((idx, el) => el.getAttribute('data-cy-app-order-element')).get()
  37. expect(appIDs).to.deep.eq(['dashboard', 'files'])
  38. })
  39. })
  40. it('Change the default app', () => {
  41. cy.get('[data-cy-app-order] [data-cy-app-order-element="files"]').scrollIntoView()
  42. cy.get('[data-cy-app-order] [data-cy-app-order-element="files"] [data-cy-app-order-button="up"]').should('be.visible')
  43. cy.get('[data-cy-app-order] [data-cy-app-order-element="files"] [data-cy-app-order-button="up"]').click()
  44. cy.get('[data-cy-app-order] [data-cy-app-order-element="files"] [data-cy-app-order-button="up"]').should('not.be.visible')
  45. })
  46. it('See the default app is changed', () => {
  47. cy.get('[data-cy-app-order] [data-cy-app-order-element]').then(elements => {
  48. const appIDs = elements.map((idx, el) => el.getAttribute('data-cy-app-order-element')).get()
  49. expect(appIDs).to.deep.eq(['files', 'dashboard'])
  50. })
  51. // Check the redirect to the default app works
  52. cy.request({ url: '/', followRedirect: false }).then((response) => {
  53. expect(response.status).to.eq(302)
  54. expect(response).to.have.property('headers')
  55. expect(response.headers.location).to.contain('/apps/files')
  56. })
  57. })
  58. it('Toggle the "use custom default app" switch back to reset the default apps', () => {
  59. cy.visit('/settings/admin/theming')
  60. cy.get('[data-cy-switch-default-app]').scrollIntoView()
  61. cy.get('[data-cy-switch-default-app] input').should('be.checked')
  62. cy.get('[data-cy-switch-default-app] .checkbox-content').click()
  63. cy.get('[data-cy-switch-default-app] input').should('be.not.checked')
  64. })
  65. it('See the default app is changed back to default', () => {
  66. // Check the redirect to the default app works
  67. cy.request({ url: '/', followRedirect: false }).then((response) => {
  68. expect(response.status).to.eq(302)
  69. expect(response).to.have.property('headers')
  70. expect(response.headers.location).to.contain('/apps/dashboard')
  71. })
  72. })
  73. })