apps.cy.ts 5.3 KB

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