You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

navigation-bar-settings.cy.ts 8.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. /**
  2. * @copyright Copyright (c) 2023 Ferdinand Thiessen <opensource@fthiessen.de>
  3. *
  4. * @author Ferdinand Thiessen <opensource@fthiessen.de>
  5. *
  6. * @license AGPL-3.0-or-later
  7. *
  8. * This program is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU Affero General Public License as
  10. * published by the Free Software Foundation, either version 3 of the
  11. * License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU Affero General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU Affero General Public License
  19. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. *
  21. */
  22. import { User } from '@nextcloud/cypress'
  23. const admin = new User('admin', 'admin')
  24. describe('Admin theming set default apps', () => {
  25. before(function() {
  26. // Just in case previous test failed
  27. cy.resetAdminTheming()
  28. cy.login(admin)
  29. })
  30. it('See the current default app is the dashboard', () => {
  31. cy.visit('/')
  32. cy.url().should('match', /apps\/dashboard/)
  33. cy.get('#nextcloud').click()
  34. cy.url().should('match', /apps\/dashboard/)
  35. })
  36. it('See the default app settings', () => {
  37. cy.visit('/settings/admin/theming')
  38. cy.get('.settings-section').contains('Navigation bar settings').should('exist')
  39. cy.get('[data-cy-switch-default-app]').should('exist')
  40. cy.get('[data-cy-switch-default-app]').scrollIntoView()
  41. })
  42. it('Toggle the "use custom default app" switch', () => {
  43. cy.get('[data-cy-switch-default-app] input').should('not.be.checked')
  44. cy.get('[data-cy-switch-default-app] label').click()
  45. cy.get('[data-cy-switch-default-app] input').should('be.checked')
  46. })
  47. it('See the default app order selector', () => {
  48. cy.get('[data-cy-app-order] [data-cy-app-order-element]').each(($el, idx) => {
  49. if (idx === 0) cy.wrap($el).should('have.attr', 'data-cy-app-order-element', 'dashboard')
  50. else cy.wrap($el).should('have.attr', 'data-cy-app-order-element', 'files')
  51. })
  52. })
  53. it('Change the default app', () => {
  54. cy.get('[data-cy-app-order] [data-cy-app-order-element="files"]').scrollIntoView()
  55. cy.get('[data-cy-app-order] [data-cy-app-order-element="files"] [data-cy-app-order-button="up"]').should('be.visible')
  56. cy.get('[data-cy-app-order] [data-cy-app-order-element="files"] [data-cy-app-order-button="up"]').click()
  57. cy.get('[data-cy-app-order] [data-cy-app-order-element="files"] [data-cy-app-order-button="up"]').should('not.be.visible')
  58. })
  59. it('See the default app is changed', () => {
  60. cy.get('[data-cy-app-order] [data-cy-app-order-element]').each(($el, idx) => {
  61. if (idx === 0) cy.wrap($el).should('have.attr', 'data-cy-app-order-element', 'files')
  62. else cy.wrap($el).should('have.attr', 'data-cy-app-order-element', 'dashboard')
  63. })
  64. cy.get('#nextcloud').click()
  65. cy.url().should('match', /apps\/files/)
  66. })
  67. it('Toggle the "use custom default app" switch back to reset the default apps', () => {
  68. cy.visit('/settings/admin/theming')
  69. cy.get('[data-cy-switch-default-app]').scrollIntoView()
  70. cy.get('[data-cy-switch-default-app] input').should('be.checked')
  71. cy.get('[data-cy-switch-default-app] label').click()
  72. cy.get('[data-cy-switch-default-app] input').should('be.not.checked')
  73. })
  74. it('See the default app is changed back to default', () => {
  75. cy.get('#nextcloud').click()
  76. cy.url().should('match', /apps\/dashboard/)
  77. })
  78. })
  79. describe('User theming set app order', () => {
  80. before(() => {
  81. cy.resetAdminTheming()
  82. // Create random user for this test
  83. cy.createRandomUser().then((user) => {
  84. cy.login(user)
  85. })
  86. })
  87. after(() => cy.logout())
  88. it('See the app order settings', () => {
  89. cy.visit('/settings/user/theming')
  90. cy.get('.settings-section').contains('Navigation bar settings').should('exist')
  91. cy.get('[data-cy-app-order]').scrollIntoView()
  92. })
  93. it('See that the dashboard app is the first one', () => {
  94. cy.get('[data-cy-app-order] [data-cy-app-order-element]').each(($el, idx) => {
  95. if (idx === 0) cy.wrap($el).should('have.attr', 'data-cy-app-order-element', 'dashboard')
  96. else cy.wrap($el).should('have.attr', 'data-cy-app-order-element', 'files')
  97. })
  98. cy.get('.app-menu-main .app-menu-entry').each(($el, idx) => {
  99. if (idx === 0) cy.wrap($el).should('have.attr', 'data-app-id', 'dashboard')
  100. else cy.wrap($el).should('have.attr', 'data-app-id', 'files')
  101. })
  102. })
  103. it('Change the app order', () => {
  104. cy.get('[data-cy-app-order] [data-cy-app-order-element="files"] [data-cy-app-order-button="up"]').should('be.visible')
  105. cy.get('[data-cy-app-order] [data-cy-app-order-element="files"] [data-cy-app-order-button="up"]').click()
  106. cy.get('[data-cy-app-order] [data-cy-app-order-element="files"] [data-cy-app-order-button="up"]').should('not.be.visible')
  107. cy.get('[data-cy-app-order] [data-cy-app-order-element]').each(($el, idx) => {
  108. if (idx === 0) cy.wrap($el).should('have.attr', 'data-cy-app-order-element', 'files')
  109. else cy.wrap($el).should('have.attr', 'data-cy-app-order-element', 'dashboard')
  110. })
  111. })
  112. it('See the app menu order is changed', () => {
  113. cy.reload()
  114. cy.get('.app-menu-main .app-menu-entry').each(($el, idx) => {
  115. if (idx === 0) cy.wrap($el).should('have.attr', 'data-app-id', 'files')
  116. else cy.wrap($el).should('have.attr', 'data-app-id', 'dashboard')
  117. })
  118. })
  119. })
  120. describe('User theming set app order with default app', () => {
  121. before(() => {
  122. cy.resetAdminTheming()
  123. // install a third app
  124. cy.runOccCommand('app:install --force --allow-unstable calendar')
  125. // set calendar as default app
  126. cy.runOccCommand('config:system:set --value "calendar,files" defaultapp')
  127. // Create random user for this test
  128. cy.createRandomUser().then((user) => {
  129. cy.login(user)
  130. })
  131. })
  132. after(() => {
  133. cy.logout()
  134. cy.runOccCommand('app:remove calendar')
  135. })
  136. it('See calendar is the default app', () => {
  137. cy.visit('/')
  138. cy.url().should('match', /apps\/calendar/)
  139. cy.get('.app-menu-main .app-menu-entry').each(($el, idx) => {
  140. if (idx === 0) cy.wrap($el).should('have.attr', 'data-app-id', 'calendar')
  141. })
  142. })
  143. it('See the app order settings: calendar is the first one', () => {
  144. cy.visit('/settings/user/theming')
  145. cy.get('[data-cy-app-order]').scrollIntoView()
  146. cy.get('[data-cy-app-order] [data-cy-app-order-element]').should('have.length', 3).each(($el, idx) => {
  147. if (idx === 0) cy.wrap($el).should('have.attr', 'data-cy-app-order-element', 'calendar')
  148. else if (idx === 1) cy.wrap($el).should('have.attr', 'data-cy-app-order-element', 'dashboard')
  149. })
  150. })
  151. it('Can not change the default app', () => {
  152. cy.get('[data-cy-app-order] [data-cy-app-order-element="calendar"] [data-cy-app-order-button="up"]').should('not.be.visible')
  153. cy.get('[data-cy-app-order] [data-cy-app-order-element="calendar"] [data-cy-app-order-button="down"]').should('not.be.visible')
  154. cy.get('[data-cy-app-order] [data-cy-app-order-element="dashboard"] [data-cy-app-order-button="up"]').should('not.be.visible')
  155. cy.get('[data-cy-app-order] [data-cy-app-order-element="dashboard"] [data-cy-app-order-button="down"]').should('be.visible')
  156. cy.get('[data-cy-app-order] [data-cy-app-order-element="files"] [data-cy-app-order-button="down"]').should('not.be.visible')
  157. cy.get('[data-cy-app-order] [data-cy-app-order-element="files"] [data-cy-app-order-button="up"]').should('be.visible')
  158. })
  159. it('Change the other apps order', () => {
  160. cy.get('[data-cy-app-order] [data-cy-app-order-element="files"] [data-cy-app-order-button="up"]').click()
  161. cy.get('[data-cy-app-order] [data-cy-app-order-element="files"] [data-cy-app-order-button="up"]').should('not.be.visible')
  162. cy.get('[data-cy-app-order] [data-cy-app-order-element]').each(($el, idx) => {
  163. if (idx === 0) cy.wrap($el).should('have.attr', 'data-cy-app-order-element', 'calendar')
  164. else if (idx === 1) cy.wrap($el).should('have.attr', 'data-cy-app-order-element', 'files')
  165. else cy.wrap($el).should('have.attr', 'data-cy-app-order-element', 'dashboard')
  166. })
  167. })
  168. it('See the app menu order is changed', () => {
  169. cy.reload()
  170. cy.get('.app-menu-main .app-menu-entry').each(($el, idx) => {
  171. if (idx === 0) cy.wrap($el).should('have.attr', 'data-app-id', 'calendar')
  172. else if (idx === 1) cy.wrap($el).should('have.attr', 'data-app-id', 'files')
  173. else cy.wrap($el).should('have.attr', 'data-app-id', 'dashboard')
  174. })
  175. })
  176. })