-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(files_versions): Support moving versions across storages
Signed-off-by: Louis Chemineau <louis@chmn.me>
- Loading branch information
Showing
8 changed files
with
315 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,4 @@ node_modules/ | |
build | ||
vendor | ||
js/ | ||
cypress/downloads/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
145 changes: 145 additions & 0 deletions
145
cypress/e2e/files_versions/version_cross_storage_move.cy.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
/** | ||
* @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 type { User } from '@nextcloud/cypress' | ||
|
||
import { PERMISSION_DELETE, PERMISSION_READ, PERMISSION_WRITE, addUserToGroup, createGroup, createGroupFolder } from '../groupfoldersUtils' | ||
import { assertVersionContent, nameVersion, openVersionsPanel, uploadThreeVersions } from './filesVersionsUtils' | ||
import { clickOnBreadcumbs, closeSidebar, copyFile, moveFile, navigateToFolder } from '../files/filesUtils' | ||
|
||
/** | ||
* | ||
* @param filePath | ||
*/ | ||
function assertVersionsContent(filePath: string) { | ||
const path = filePath.split('/').slice(0, -1).join('/') | ||
|
||
clickOnBreadcumbs('All files') | ||
|
||
if (path !== '') { | ||
navigateToFolder(path) | ||
} | ||
|
||
closeSidebar() | ||
openVersionsPanel(filePath) | ||
|
||
cy.get('[data-files-versions-version]').should('have.length', 3) | ||
cy.get('[data-files-versions-version]').eq(2).contains('v1') | ||
assertVersionContent(0, 'v3') | ||
assertVersionContent(1, 'v2') | ||
assertVersionContent(2, 'v1') | ||
} | ||
|
||
describe('Versions cross storage move', () => { | ||
let randomGroupName: string | ||
let randomGroupFolderName: string | ||
let randomFileName: string | ||
let randomCopiedFileName: string | ||
let user: User | ||
|
||
before(() => { | ||
randomGroupName = Math.random().toString(36).replace(/[^a-z]+/g, '').substring(0, 10) | ||
randomGroupFolderName = Math.random().toString(36).replace(/[^a-z]+/g, '').substring(0, 10) | ||
|
||
cy.createRandomUser().then(_user => { user = _user }) | ||
createGroup(randomGroupName) | ||
|
||
cy.then(() => { | ||
addUserToGroup(randomGroupName, user.userId) | ||
createGroupFolder(randomGroupFolderName, randomGroupName, [PERMISSION_READ, PERMISSION_WRITE, PERMISSION_DELETE]) | ||
}) | ||
}) | ||
|
||
beforeEach(() => { | ||
const randomString = Math.random().toString(36).replace(/[^a-z]+/g, '').substring(0, 10) | ||
randomFileName = randomString + '.txt' | ||
randomCopiedFileName = randomString + ' (copy).txt' | ||
uploadThreeVersions(user, `${randomGroupFolderName}/${randomFileName}`) | ||
|
||
cy.login(user) | ||
cy.visit('/apps/files') | ||
navigateToFolder(randomGroupFolderName) | ||
openVersionsPanel(`${randomGroupFolderName}/${randomFileName}`) | ||
nameVersion(2, 'v1') | ||
}) | ||
|
||
it('Correctly moves versions to the user\'s FS when the user moves the file out of the groupfolder', () => { | ||
moveFile(randomFileName, '/') | ||
|
||
assertVersionsContent(randomFileName) | ||
|
||
moveFile(randomFileName, randomGroupFolderName) | ||
|
||
assertVersionsContent(`${randomGroupFolderName}/${randomFileName}`) | ||
}) | ||
|
||
it('Correctly copies versions to the user\'s FS when the user copies the file out of the groupfolder', () => { | ||
copyFile(randomFileName, '/') | ||
|
||
assertVersionsContent(randomFileName) | ||
|
||
copyFile(randomFileName, randomGroupFolderName) | ||
|
||
assertVersionsContent(`${randomGroupFolderName}/${randomCopiedFileName}`) | ||
}) | ||
|
||
context('When a file is in a subfolder', () => { | ||
let randomSubFolderName | ||
let randomCopiedSubFolderName | ||
let randomSubSubFolderName | ||
|
||
beforeEach(() => { | ||
const randomString = Math.random().toString(36).replace(/[^a-z]+/g, '').substring(0, 10) | ||
randomSubFolderName = randomString | ||
randomCopiedSubFolderName = randomString + ' (copy)' | ||
|
||
randomSubSubFolderName = Math.random().toString(36).replace(/[^a-z]+/g, '').substring(0, 10) | ||
clickOnBreadcumbs('All files') | ||
cy.mkdir(user, `/${randomGroupFolderName}/${randomSubFolderName}`) | ||
cy.mkdir(user, `/${randomGroupFolderName}/${randomSubFolderName}/${randomSubSubFolderName}`) | ||
cy.login(user) | ||
navigateToFolder(randomGroupFolderName) | ||
}) | ||
|
||
it('Correctly moves versions when user moves the containing folder out of the groupfolder', () => { | ||
moveFile(randomFileName, `${randomSubFolderName}/${randomSubSubFolderName}`) | ||
moveFile(randomSubFolderName, '/') | ||
|
||
assertVersionsContent(`${randomSubFolderName}/${randomSubSubFolderName}/${randomFileName}`) | ||
|
||
clickOnBreadcumbs('All files') | ||
moveFile(randomSubFolderName, randomGroupFolderName) | ||
assertVersionsContent(`${randomGroupFolderName}/${randomSubFolderName}/${randomSubSubFolderName}/${randomFileName}`) | ||
}) | ||
|
||
it('Correctly copies versions when user copies the containing folder out of the groupfolder', () => { | ||
moveFile(randomFileName, `${randomSubFolderName}/${randomSubSubFolderName}`) | ||
copyFile(randomSubFolderName, '/') | ||
|
||
assertVersionsContent(`${randomSubFolderName}/${randomSubSubFolderName}/${randomFileName}`) | ||
|
||
clickOnBreadcumbs('All files') | ||
copyFile(randomSubFolderName, randomGroupFolderName) | ||
assertVersionsContent(`${randomGroupFolderName}/${randomCopiedSubFolderName}/${randomSubSubFolderName}/${randomFileName}`) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.