diff options
author | Louis Chemineau <louis@chmn.me> | 2022-12-21 10:16:44 +0100 |
---|---|---|
committer | Louis (Rebase PR Action) <artonge@users.noreply.github.com> | 2023-01-26 10:12:23 +0000 |
commit | fd9937a171c3dc0d8615e113ccc72f699ab2cd78 (patch) | |
tree | 99603a6727f6f75c1066751fed4c21e5217eafe1 /cypress/e2e | |
parent | 305b1b6d2155fa2cd6e911a05ceae98950350226 (diff) | |
download | nextcloud-server-fd9937a171c3dc0d8615e113ccc72f699ab2cd78.tar.gz nextcloud-server-fd9937a171c3dc0d8615e113ccc72f699ab2cd78.zip |
Add cypress tests
Signed-off-by: Louis Chemineau <louis@chmn.me>
Diffstat (limited to 'cypress/e2e')
-rw-r--r-- | cypress/e2e/files_versions/filesVersionsUtils.ts | 81 | ||||
-rw-r--r-- | cypress/e2e/files_versions/version_creation.cy.ts | 45 | ||||
-rw-r--r-- | cypress/e2e/files_versions/version_download.cy.ts | 41 | ||||
-rw-r--r-- | cypress/e2e/files_versions/version_expiration.cy.ts | 65 | ||||
-rw-r--r-- | cypress/e2e/files_versions/version_naming.cy.ts | 57 | ||||
-rw-r--r-- | cypress/e2e/files_versions/version_restoration.cy.ts | 55 |
6 files changed, 344 insertions, 0 deletions
diff --git a/cypress/e2e/files_versions/filesVersionsUtils.ts b/cypress/e2e/files_versions/filesVersionsUtils.ts new file mode 100644 index 00000000000..1aa7ebde316 --- /dev/null +++ b/cypress/e2e/files_versions/filesVersionsUtils.ts @@ -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`)) +}
\ No newline at end of file diff --git a/cypress/e2e/files_versions/version_creation.cy.ts b/cypress/e2e/files_versions/version_creation.cy.ts new file mode 100644 index 00000000000..d6655059143 --- /dev/null +++ b/cypress/e2e/files_versions/version_creation.cy.ts @@ -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') + }) + }) +}) diff --git a/cypress/e2e/files_versions/version_download.cy.ts b/cypress/e2e/files_versions/version_download.cy.ts new file mode 100644 index 00000000000..69f46915031 --- /dev/null +++ b/cypress/e2e/files_versions/version_download.cy.ts @@ -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') + }) +}) diff --git a/cypress/e2e/files_versions/version_expiration.cy.ts b/cypress/e2e/files_versions/version_expiration.cy.ts new file mode 100644 index 00000000000..fdac454884d --- /dev/null +++ b/cypress/e2e/files_versions/version_expiration.cy.ts @@ -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') + }) +}) diff --git a/cypress/e2e/files_versions/version_naming.cy.ts b/cypress/e2e/files_versions/version_naming.cy.ts new file mode 100644 index 00000000000..03edae131b6 --- /dev/null +++ b/cypress/e2e/files_versions/version_naming.cy.ts @@ -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)') + }) + }) +}) diff --git a/cypress/e2e/files_versions/version_restoration.cy.ts b/cypress/e2e/files_versions/version_restoration.cy.ts new file mode 100644 index 00000000000..0e09b0d8aa6 --- /dev/null +++ b/cypress/e2e/files_versions/version_restoration.cy.ts @@ -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') + }) +}) |