apps.cy.ts 6.0 KB

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