apps.cy.ts 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  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. import { handlePasswordConfirmation } from './usersUtils'
  24. const admin = new User('admin', 'admin')
  25. describe('Settings: App management', { testIsolation: true }, () => {
  26. beforeEach(() => {
  27. // disable QA if already enabled
  28. cy.runOccCommand('app:disable -n testing')
  29. // enable notification if already disabled
  30. cy.runOccCommand('app:enable -n updatenotification')
  31. // I am logged in as the admin
  32. cy.login(admin)
  33. // Intercept the apps list request
  34. cy.intercept('GET', '*/settings/apps/list').as('fetchAppsList')
  35. // I open the Apps management
  36. cy.visit('/settings/apps/installed')
  37. // Wait for the apps list to load
  38. cy.wait('@fetchAppsList')
  39. })
  40. it('Can enable an installed app', () => {
  41. cy.get('#apps-list').should('exist')
  42. // Wait for the app list to load
  43. .contains('tr', 'QA testing', { timeout: 10000 })
  44. .should('exist')
  45. // I enable the "QA testing" app
  46. .contains('button', 'Enable')
  47. .click({ force: true })
  48. handlePasswordConfirmation(admin.password)
  49. // Wait until we see the disable button for the app
  50. cy.get('#apps-list').should('exist')
  51. .contains('tr', 'QA testing')
  52. .should('exist')
  53. // I see the disable button for the app
  54. .contains('button', 'Disable', { timeout: 10000 })
  55. // Change to enabled apps view
  56. cy.get('#app-category-enabled a').click({ force: true })
  57. cy.url().should('match', /settings\/apps\/enabled$/)
  58. // I see that the "QA testing" app has been enabled
  59. cy.get('#apps-list').contains('tr', 'QA testing')
  60. })
  61. it('Can disable an installed app', () => {
  62. cy.get('#apps-list')
  63. .should('exist')
  64. // Wait for the app list to load
  65. .contains('tr', 'Update notification', { timeout: 10000 })
  66. .should('exist')
  67. // I disable the "Update notification" app
  68. .contains('button', 'Disable')
  69. .click({ force: true })
  70. handlePasswordConfirmation(admin.password)
  71. // Wait until we see the disable button for the app
  72. cy.get('#apps-list').should('exist')
  73. .contains('tr', 'Update notification')
  74. .should('exist')
  75. // I see the enable button for the app
  76. .contains('button', 'Enable', { timeout: 10000 })
  77. // Change to disabled apps view
  78. cy.get('#app-category-disabled a').click({ force: true })
  79. cy.url().should('match', /settings\/apps\/disabled$/)
  80. // I see that the "Update notification" app has been disabled
  81. cy.get('#apps-list').contains('tr', 'Update notification')
  82. })
  83. it('Browse enabled apps', () => {
  84. // When I open the "Active apps" section
  85. cy.get('#app-category-enabled a')
  86. .should('contain', 'Active apps')
  87. .click({ force: true })
  88. // Then I see that the current section is "Active apps"
  89. cy.url().should('match', /settings\/apps\/enabled$/)
  90. cy.get('#app-category-enabled').find('.active').should('exist')
  91. // I see that there are only enabled apps
  92. cy.get('#apps-list')
  93. .should('exist')
  94. .find('tr button')
  95. .each(($action) => {
  96. cy.wrap($action).should('not.contain', 'Enable')
  97. })
  98. })
  99. it('Browse disabled apps', () => {
  100. // When I open the "Active apps" section
  101. cy.get('#app-category-disabled a')
  102. .should('contain', 'Disabled apps')
  103. .click({ force: true })
  104. // Then I see that the current section is "Active apps"
  105. cy.url().should('match', /settings\/apps\/disabled$/)
  106. cy.get('#app-category-disabled').find('.active').should('exist')
  107. // I see that there are only disabled apps
  108. cy.get('#apps-list')
  109. .should('exist')
  110. .find('tr button')
  111. .each(($action) => {
  112. cy.wrap($action).should('not.contain', 'Disable')
  113. })
  114. })
  115. it('Browse app bundles', () => {
  116. // When I open the "App bundles" section
  117. cy.get('#app-category-your-bundles a')
  118. .should('contain', 'App bundles')
  119. .click({ force: true })
  120. // Then I see that the current section is "App bundles"
  121. cy.url().should('match', /settings\/apps\/app-bundles$/)
  122. cy.get('#app-category-your-bundles').find('.active').should('exist')
  123. // I see the app bundles
  124. cy.get('#apps-list').contains('tr', 'Enterprise bundle')
  125. cy.get('#apps-list').contains('tr', 'Education Edition')
  126. // I see that the "Enterprise bundle" is disabled
  127. cy.get('#apps-list').contains('tr', 'Enterprise bundle').contains('button', 'Download and enable all')
  128. })
  129. it('View app details', () => {
  130. // When I click on the "QA testing" app
  131. cy.get('#apps-list').contains('a', 'QA testing').click({ force: true })
  132. // I see that the app details are shown
  133. cy.get('#app-sidebar-vue')
  134. .should('be.visible')
  135. .find('.app-sidebar-header__info')
  136. .should('contain', 'QA testing')
  137. cy.get('#app-sidebar-vue').contains('a', 'View in store').should('exist')
  138. cy.get('#app-sidebar-vue').find('input[type="button"][value="Enable"]').should('be.visible')
  139. cy.get('#app-sidebar-vue').find('input[type="button"][value="Remove"]').should('be.visible')
  140. cy.get('#app-sidebar-vue').contains(/Version \d+\.\d+\.\d+/).should('be.visible')
  141. })
  142. /*
  143. * TODO: Improve testing with app store as external API
  144. * The following scenarios require the files_antivirus and calendar app
  145. * being present in the app store with support for the current server version
  146. * Ideally we would have either a dummy app store endpoint with some test apps
  147. * or even an app store instance running somewhere to properly test this.
  148. * This is also a requirement to properly test updates of apps
  149. */
  150. // TODO: View app details for app store apps
  151. // TODO: Install an app from the app store
  152. // TODO: Show section from app store
  153. })