apps.cy.ts 5.5 KB

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