apps.cy.ts 6.1 KB

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