mirror of https://github.com/nextcloud/server.git
parent
305b1b6d21
commit
fd9937a171
@ -0,0 +1,81 @@
|
||||
/**
|
||||
* @copyright Copyright (c) 2022 Louis Chemineau <louis@chmn.me>
|
||||
*
|
||||
* @author Louis Chemineau <louis@chmn.me>
|
||||
*
|
||||
* @license AGPL-3.0-or-later
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
import path from "path"
|
||||
|
||||
export function uploadThreeVersions(user) {
|
||||
cy.uploadContent(user, new Blob(['v1'], { type: 'text/plain' }), 'text/plain', '/test.txt')
|
||||
cy.wait(1000)
|
||||
cy.uploadContent(user, new Blob(['v2'], { type: 'text/plain' }), 'text/plain', '/test.txt')
|
||||
cy.wait(1000)
|
||||
cy.uploadContent(user, new Blob(['v3'], { type: 'text/plain' }), 'text/plain', '/test.txt')
|
||||
cy.login(user)
|
||||
}
|
||||
|
||||
export function openVersionsPanel(fileName: string) {
|
||||
cy.get(`[data-file="${fileName}"]`).within(() => {
|
||||
cy.get('[data-action="menu"]')
|
||||
.click()
|
||||
|
||||
cy.get('.fileActionsMenu')
|
||||
.get('.action-details')
|
||||
.click()
|
||||
})
|
||||
|
||||
cy.get('#app-sidebar-vue')
|
||||
.get('[aria-controls="tab-version_vue"]')
|
||||
.click()
|
||||
|
||||
}
|
||||
|
||||
export function openVersionMenu(index: number) {
|
||||
cy.get('#tab-version_vue').within(() => {
|
||||
cy.get('[data-files-versions-version]')
|
||||
.eq(index).within(() => {
|
||||
cy.get('.action-item__menutoggle').filter(':visible')
|
||||
.click()
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export function clickPopperAction(actionName: string) {
|
||||
cy.get('.v-popper__popper').filter(':visible')
|
||||
.contains(actionName)
|
||||
.click()
|
||||
}
|
||||
|
||||
export function nameVersion(index: number, name: string) {
|
||||
openVersionMenu(index)
|
||||
clickPopperAction("Name this version")
|
||||
cy.get(':focused').type(`${name}{enter}`)
|
||||
}
|
||||
|
||||
export function assertVersionContent(index: number, expectedContent: string) {
|
||||
const downloadsFolder = Cypress.config('downloadsFolder')
|
||||
|
||||
openVersionMenu(index)
|
||||
clickPopperAction("Download version")
|
||||
|
||||
return cy.readFile(path.join(downloadsFolder, 'test.txt'))
|
||||
.then((versionContent) => expect(versionContent).to.equal(expectedContent))
|
||||
.then(() => cy.exec(`rm ${downloadsFolder}/test.txt`))
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
/**
|
||||
* @copyright Copyright (c) 2022 Louis Chmn <louis@chmn.me>
|
||||
*
|
||||
* @author Louis Chmn <louis@chmn.me>
|
||||
*
|
||||
* @license AGPL-3.0-or-later
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
import { openVersionsPanel, uploadThreeVersions } from './filesVersionsUtils'
|
||||
|
||||
describe('Versions creation', () => {
|
||||
before(() => {
|
||||
cy.createRandomUser()
|
||||
.then((user) => {
|
||||
uploadThreeVersions(user)
|
||||
cy.login(user)
|
||||
cy.visit('/apps/files')
|
||||
openVersionsPanel('test.txt')
|
||||
})
|
||||
})
|
||||
|
||||
it('Opens the versions panel and sees the versions', () => {
|
||||
openVersionsPanel('test.txt')
|
||||
|
||||
cy.get('#tab-version_vue').within(() => {
|
||||
cy.get('[data-files-versions-version]').should('have.length', 3)
|
||||
cy.get('[data-files-versions-version]').eq(0).contains('Current version')
|
||||
cy.get('[data-files-versions-version]').eq(2).contains('Initial version')
|
||||
})
|
||||
})
|
||||
})
|
@ -0,0 +1,41 @@
|
||||
/**
|
||||
* @copyright Copyright (c) 2022 Louis Chmn <louis@chmn.me>
|
||||
*
|
||||
* @author Louis Chmn <louis@chmn.me>
|
||||
*
|
||||
* @license AGPL-3.0-or-later
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
import { assertVersionContent, openVersionsPanel, uploadThreeVersions } from './filesVersionsUtils'
|
||||
|
||||
describe('Versions download', () => {
|
||||
before(() => {
|
||||
cy.createRandomUser()
|
||||
.then((user) => {
|
||||
uploadThreeVersions(user)
|
||||
cy.login(user)
|
||||
cy.visit('/apps/files')
|
||||
openVersionsPanel('test.txt')
|
||||
})
|
||||
})
|
||||
|
||||
it('Download versions and assert there content', () => {
|
||||
assertVersionContent(0, 'v3')
|
||||
assertVersionContent(1, 'v2')
|
||||
assertVersionContent(2, 'v1')
|
||||
})
|
||||
})
|
@ -0,0 +1,65 @@
|
||||
/**
|
||||
* @copyright Copyright (c) 2022 Louis Chmn <louis@chmn.me>
|
||||
*
|
||||
* @author Louis Chmn <louis@chmn.me>
|
||||
*
|
||||
* @license AGPL-3.0-or-later
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
import { assertVersionContent, nameVersion, openVersionsPanel, uploadThreeVersions } from './filesVersionsUtils'
|
||||
|
||||
describe('Versions expiration', () => {
|
||||
beforeEach(() => {
|
||||
cy.createRandomUser()
|
||||
.then((user) => {
|
||||
uploadThreeVersions(user)
|
||||
cy.login(user)
|
||||
cy.visit('/apps/files')
|
||||
openVersionsPanel('test.txt')
|
||||
})
|
||||
})
|
||||
|
||||
it('Expire all versions', () => {
|
||||
cy.runOccCommand('versions:expire')
|
||||
cy.visit('/apps/files')
|
||||
openVersionsPanel('test.txt')
|
||||
|
||||
cy.get('#tab-version_vue').within(() => {
|
||||
cy.get('[data-files-versions-version]').should('have.length', 1)
|
||||
cy.get('[data-files-versions-version]').eq(0).contains('Current version')
|
||||
})
|
||||
|
||||
assertVersionContent(0, 'v3')
|
||||
})
|
||||
|
||||
it('Expire versions v2', () => {
|
||||
nameVersion(2, 'v1')
|
||||
|
||||
cy.runOccCommand('versions:expire')
|
||||
cy.visit('/apps/files')
|
||||
openVersionsPanel('test.txt')
|
||||
|
||||
cy.get('#tab-version_vue').within(() => {
|
||||
cy.get('[data-files-versions-version]').should('have.length', 2)
|
||||
cy.get('[data-files-versions-version]').eq(0).contains('Current version')
|
||||
cy.get('[data-files-versions-version]').eq(1).contains('v1')
|
||||
})
|
||||
|
||||
assertVersionContent(0, 'v3')
|
||||
assertVersionContent(1, 'v1')
|
||||
})
|
||||
})
|
@ -0,0 +1,57 @@
|
||||
/**
|
||||
* @copyright Copyright (c) 2022 Louis Chmn <louis@chmn.me>
|
||||
*
|
||||
* @author Louis Chmn <louis@chmn.me>
|
||||
*
|
||||
* @license AGPL-3.0-or-later
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
import { nameVersion, openVersionsPanel, uploadThreeVersions } from './filesVersionsUtils'
|
||||
|
||||
describe('Versions naming', () => {
|
||||
before(() => {
|
||||
cy.createRandomUser()
|
||||
.then((user) => {
|
||||
uploadThreeVersions(user)
|
||||
cy.login(user)
|
||||
cy.visit('/apps/files')
|
||||
openVersionsPanel('test.txt')
|
||||
})
|
||||
})
|
||||
|
||||
it('Names the initial version as v1', () => {
|
||||
nameVersion(2, 'v1')
|
||||
cy.get('#tab-version_vue').within(() => {
|
||||
cy.get('[data-files-versions-version]').eq(2).contains('v1')
|
||||
cy.get('[data-files-versions-version]').eq(2).contains('Initial version').should('not.exist')
|
||||
})
|
||||
})
|
||||
|
||||
it('Names the second version as v2', () => {
|
||||
nameVersion(1, 'v2')
|
||||
cy.get('#tab-version_vue').within(() => {
|
||||
cy.get('[data-files-versions-version]').eq(1).contains('v2')
|
||||
})
|
||||
})
|
||||
|
||||
it('Names the current version as v3', () => {
|
||||
nameVersion(0, 'v3')
|
||||
cy.get('#tab-version_vue').within(() => {
|
||||
cy.get('[data-files-versions-version]').eq(0).contains('v3 (Current version)')
|
||||
})
|
||||
})
|
||||
})
|
@ -0,0 +1,55 @@
|
||||
/**
|
||||
* @copyright Copyright (c) 2022 Louis Chmn <louis@chmn.me>
|
||||
*
|
||||
* @author Louis Chmn <louis@chmn.me>
|
||||
*
|
||||
* @license AGPL-3.0-or-later
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
import { assertVersionContent, clickPopperAction, openVersionMenu, openVersionsPanel, uploadThreeVersions } from './filesVersionsUtils'
|
||||
|
||||
function restoreVersion(index: number) {
|
||||
openVersionMenu(index)
|
||||
clickPopperAction("Restore version")
|
||||
}
|
||||
|
||||
describe('Versions restoration', () => {
|
||||
before(() => {
|
||||
cy.createRandomUser()
|
||||
.then((user) => {
|
||||
uploadThreeVersions(user)
|
||||
cy.login(user)
|
||||
cy.visit('/apps/files')
|
||||
openVersionsPanel('test.txt')
|
||||
})
|
||||
})
|
||||
|
||||
it('Restores initial version', () => {
|
||||
restoreVersion(2)
|
||||
cy.get('#tab-version_vue').within(() => {
|
||||
cy.get('[data-files-versions-version]').should('have.length', 3)
|
||||
cy.get('[data-files-versions-version]').eq(0).contains('Current version')
|
||||
cy.get('[data-files-versions-version]').eq(2).contains('Initial version').should('not.exist')
|
||||
})
|
||||
})
|
||||
|
||||
it('Downloads versions and assert there content', () => {
|
||||
assertVersionContent(0, 'v1')
|
||||
assertVersionContent(1, 'v3')
|
||||
assertVersionContent(2, 'v2')
|
||||
})
|
||||
})
|
Loading…
Reference in New Issue