diff options
author | Louis <louis@chmn.me> | 2024-12-04 17:02:56 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-12-04 17:02:56 +0100 |
commit | 1ef3e3e753aa1e1e767f6e1ed6576a0c00b27030 (patch) | |
tree | 2dad217ec9bacefec0813f81818f4da8d415588d /cypress/e2e/files/live_photos.cy.ts | |
parent | 27331d48e377d5e908439cfdef8950b4b5ec47b2 (diff) | |
parent | 8be6a7c7dd51b018a20fb4f1c7e530999bc10faf (diff) | |
download | nextcloud-server-1ef3e3e753aa1e1e767f6e1ed6576a0c00b27030.tar.gz nextcloud-server-1ef3e3e753aa1e1e767f6e1ed6576a0c00b27030.zip |
Merge pull request #49293 from nextcloud/artonge/fix/handle_folders_copy_live_photos
fix: Handle copy of folders containing live photos
Diffstat (limited to 'cypress/e2e/files/live_photos.cy.ts')
-rw-r--r-- | cypress/e2e/files/live_photos.cy.ts | 120 |
1 files changed, 52 insertions, 68 deletions
diff --git a/cypress/e2e/files/live_photos.cy.ts b/cypress/e2e/files/live_photos.cy.ts index 659cdc544ed..8eb4efaaec0 100644 --- a/cypress/e2e/files/live_photos.cy.ts +++ b/cypress/e2e/files/live_photos.cy.ts @@ -4,75 +4,34 @@ */ import type { User } from '@nextcloud/cypress' -import { clickOnBreadcrumbs, closeSidebar, copyFile, getRowForFile, getRowForFileId, renameFile, triggerActionForFile, triggerInlineActionForFileId } from './FilesUtils' - -/** - * - * @param user - * @param fileName - * @param domain - * @param requesttoken - * @param metadata - */ -function setMetadata(user: User, fileName: string, domain: string, requesttoken: string, metadata: object) { - cy.request({ - method: 'PROPPATCH', - url: `http://${domain}/remote.php/dav/files/${user.userId}/${fileName}`, - auth: { user: user.userId, pass: user.password }, - headers: { - requesttoken, - }, - body: `<?xml version="1.0"?> - <d:propertyupdate xmlns:d="DAV:" xmlns:nc="http://nextcloud.org/ns"> - <d:set> - <d:prop> - ${Object.entries(metadata).map(([key, value]) => `<${key}>${value}</${key}>`).join('\n')} - </d:prop> - </d:set> - </d:propertyupdate>`, - }) -} +import { + clickOnBreadcrumbs, + copyFile, + createFolder, + getRowForFile, + getRowForFileId, + moveFile, + navigateToFolder, + renameFile, + triggerActionForFile, + triggerInlineActionForFileId, +} from './FilesUtils' +import { setShowHiddenFiles, setupLivePhotos } from './LivePhotosUtils' describe('Files: Live photos', { testIsolation: true }, () => { - let currentUser: User + let user: User let randomFileName: string let jpgFileId: number let movFileId: number - let hostname: string - let requesttoken: string - - before(() => { - cy.createRandomUser().then((user) => { - currentUser = user - cy.login(currentUser) - cy.visit('/apps/files') - }) - - cy.url().then(url => { hostname = new URL(url).hostname }) - }) beforeEach(() => { - randomFileName = Math.random().toString(36).replace(/[^a-z]+/g, '').substring(0, 10) - - cy.uploadContent(currentUser, new Blob(['jpg file'], { type: 'image/jpg' }), 'image/jpg', `/${randomFileName}.jpg`) - .then(response => { jpgFileId = parseInt(response.headers['oc-fileid']) }) - cy.uploadContent(currentUser, new Blob(['mov file'], { type: 'video/mov' }), 'video/mov', `/${randomFileName}.mov`) - .then(response => { movFileId = parseInt(response.headers['oc-fileid']) }) - - cy.login(currentUser) - cy.visit('/apps/files') - - cy.get('head').invoke('attr', 'data-requesttoken').then(_requesttoken => { requesttoken = _requesttoken as string }) - - cy.then(() => { - setMetadata(currentUser, `${randomFileName}.jpg`, hostname, requesttoken, { 'nc:metadata-files-live-photo': movFileId }) - setMetadata(currentUser, `${randomFileName}.mov`, hostname, requesttoken, { 'nc:metadata-files-live-photo': jpgFileId }) - }) - - cy.then(() => { - cy.visit(`/apps/files/files/${jpgFileId}`) // Refresh and scroll to the .jpg file. - closeSidebar() - }) + setupLivePhotos() + .then((setupInfo) => { + user = setupInfo.user + randomFileName = setupInfo.fileName + jpgFileId = setupInfo.jpgFileId + movFileId = setupInfo.movFileId + }) }) it('Only renders the .jpg file', () => { @@ -81,12 +40,8 @@ describe('Files: Live photos', { testIsolation: true }, () => { }) context("'Show hidden files' is enabled", () => { - before(() => { - cy.login(currentUser) - cy.visit('/apps/files') - cy.get('[data-cy-files-navigation-settings-button]').click() - // Force:true because the checkbox is hidden by the pretty UI. - cy.get('[data-cy-files-settings-setting="show_hidden"] input').check({ force: true }) + beforeEach(() => { + setShowHiddenFiles(true) }) it("Shows both files when 'Show hidden files' is enabled", () => { @@ -113,6 +68,35 @@ describe('Files: Live photos', { testIsolation: true }, () => { getRowForFile(`${randomFileName} (copy).mov`).should('have.length', 1) }) + it('Keeps live photo link when copying folder', () => { + createFolder('folder') + moveFile(`${randomFileName}.jpg`, 'folder') + copyFile('folder', '.') + navigateToFolder('folder (copy)') + + getRowForFile(`${randomFileName}.jpg`).should('have.length', 1) + getRowForFile(`${randomFileName}.mov`).should('have.length', 1) + + setShowHiddenFiles(false) + + getRowForFile(`${randomFileName}.jpg`).should('have.length', 1) + getRowForFile(`${randomFileName}.mov`).should('have.length', 0) + }) + + it('Block copying live photo in a folder containing a mov file with the same name', () => { + createFolder('folder') + cy.uploadContent(user, new Blob(['mov file'], { type: 'video/mov' }), 'video/mov', `/folder/${randomFileName}.mov`) + cy.login(user) + cy.visit('/apps/files') + copyFile(`${randomFileName}.jpg`, 'folder') + navigateToFolder('folder') + + cy.get('[data-cy-files-list-row-fileid]').should('have.length', 1) + getRowForFile(`${randomFileName}.mov`).should('have.length', 1) + getRowForFile(`${randomFileName}.jpg`).should('have.length', 0) + getRowForFile(`${randomFileName} (copy).jpg`).should('have.length', 0) + }) + it('Moves files when moving the .jpg', () => { renameFile(`${randomFileName}.jpg`, `${randomFileName}_moved.jpg`) clickOnBreadcrumbs('All files') |