apps.cy.ts 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. /**
  2. * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
  3. * SPDX-License-Identifier: AGPL-3.0-or-later
  4. */
  5. import { User } from '@nextcloud/cypress'
  6. import { handlePasswordConfirmation } from './usersUtils'
  7. const admin = new User('admin', 'admin')
  8. describe('Settings: App management', { testIsolation: true }, () => {
  9. beforeEach(() => {
  10. // disable QA if already enabled
  11. cy.runOccCommand('app:disable -n testing')
  12. // enable notification if already disabled
  13. cy.runOccCommand('app:enable -n updatenotification')
  14. // I am logged in as the admin
  15. cy.login(admin)
  16. // Intercept the apps list request
  17. cy.intercept('GET', '*/settings/apps/list').as('fetchAppsList')
  18. // I open the Apps management
  19. cy.visit('/settings/apps/installed')
  20. // Wait for the apps list to load
  21. cy.wait('@fetchAppsList')
  22. })
  23. it('Can enable an installed app', () => {
  24. cy.get('#apps-list').should('exist')
  25. // Wait for the app list to load
  26. .contains('tr', 'QA testing', { timeout: 10000 })
  27. .should('exist')
  28. // I enable the "QA testing" app
  29. .contains('button', 'Enable')
  30. .click({ force: true })
  31. handlePasswordConfirmation(admin.password)
  32. // Wait until we see the disable button for the app
  33. cy.get('#apps-list').should('exist')
  34. .contains('tr', 'QA testing')
  35. .should('exist')
  36. // I see the disable button for the app
  37. .contains('button', 'Disable', { timeout: 10000 })
  38. // Change to enabled apps view
  39. cy.get('#app-category-enabled a').click({ force: true })
  40. cy.url().should('match', /settings\/apps\/enabled$/)
  41. // I see that the "QA testing" app has been enabled
  42. cy.get('#apps-list').contains('tr', 'QA testing')
  43. })
  44. it('Can disable an installed app', () => {
  45. cy.get('#apps-list')
  46. .should('exist')
  47. // Wait for the app list to load
  48. .contains('tr', 'Update notification', { timeout: 10000 })
  49. .should('exist')
  50. // I disable the "Update notification" app
  51. .contains('button', 'Disable')
  52. .click({ force: true })
  53. handlePasswordConfirmation(admin.password)
  54. // Wait until we see the disable button for the app
  55. cy.get('#apps-list').should('exist')
  56. .contains('tr', 'Update notification')
  57. .should('exist')
  58. // I see the enable button for the app
  59. .contains('button', 'Enable', { timeout: 10000 })
  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').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('exist')
  77. .find('tr button')
  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('exist')
  93. .find('tr button')
  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 bundle')
  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').contains(/Version \d+\.\d+\.\d+/).should('be.visible')
  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. })