1
0

version_expiration.cy.ts 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /**
  2. * SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors
  3. * SPDX-License-Identifier: AGPL-3.0-or-later
  4. */
  5. import { assertVersionContent, nameVersion, openVersionsPanel, uploadThreeVersions } from './filesVersionsUtils'
  6. describe('Versions expiration', () => {
  7. let randomFileName = ''
  8. beforeEach(() => {
  9. randomFileName = Math.random().toString(36).replace(/[^a-z]+/g, '').substring(0, 10) + '.txt'
  10. cy.createRandomUser()
  11. .then((user) => {
  12. uploadThreeVersions(user, randomFileName)
  13. cy.login(user)
  14. cy.visit('/apps/files')
  15. openVersionsPanel(randomFileName)
  16. })
  17. })
  18. it('Expire all versions', () => {
  19. cy.runOccCommand('config:system:set versions_retention_obligation --value \'0, 0\'')
  20. cy.runOccCommand('versions:expire')
  21. cy.runOccCommand('config:system:set versions_retention_obligation --value auto')
  22. cy.visit('/apps/files')
  23. openVersionsPanel(randomFileName)
  24. cy.get('#tab-version_vue').within(() => {
  25. cy.get('[data-files-versions-version]').should('have.length', 1)
  26. cy.get('[data-files-versions-version]').eq(0).contains('Current version')
  27. })
  28. assertVersionContent(0, 'v3')
  29. })
  30. it('Expire versions v2', () => {
  31. nameVersion(2, 'v1')
  32. cy.runOccCommand('config:system:set versions_retention_obligation --value \'0, 0\'')
  33. cy.runOccCommand('versions:expire')
  34. cy.runOccCommand('config:system:set versions_retention_obligation --value auto')
  35. cy.visit('/apps/files')
  36. openVersionsPanel(randomFileName)
  37. cy.get('#tab-version_vue').within(() => {
  38. cy.get('[data-files-versions-version]').should('have.length', 2)
  39. cy.get('[data-files-versions-version]').eq(0).contains('Current version')
  40. cy.get('[data-files-versions-version]').eq(1).contains('v1')
  41. })
  42. assertVersionContent(0, 'v3')
  43. assertVersionContent(1, 'v1')
  44. })
  45. })