-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Split live photo listener to extract trashbin specific code into its own listener #44069
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
caa720c
test(cypress): Do not run cron in ajax mode
artonge d9e09d5
test(cypress): Scroll element in the center of the view
artonge 2de9880
fix(files): Do not require files_trashbin in live photo sync listener
artonge 01fe326
test(files): Add e2e tests for live photo sync
artonge File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev
Previous commit
test(files): Add e2e tests for live photo sync
Signed-off-by: Louis Chemineau <[email protected]>
- Loading branch information
commit 01fe326df16bd479a0c75842b6baa22eebb9e279
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,215 @@ | ||
| /** | ||
| * @copyright Copyright (c) 2024 Louis Chmn <[email protected]> | ||
| * | ||
| * @author Louis Chmn <[email protected]> | ||
| * | ||
| * @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 { closeSidebar, copyFile, getRowForFile, getRowForFileId, renameFile, triggerActionForFile, triggerInlineActionForFileId } from './FilesUtils' | ||
|
|
||
| /** | ||
| * | ||
| * @param label | ||
| */ | ||
| function refreshView(label: string) { | ||
| cy.intercept('PROPFIND', /\/remote.php\/dav\//).as('propfind') | ||
| cy.get('[data-cy-files-content-breadcrumbs]').contains(label).click() | ||
| cy.wait('@propfind') | ||
| } | ||
|
|
||
| /** | ||
| * | ||
| * @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>`, | ||
| }) | ||
| } | ||
|
|
||
| describe('Files: Live photos', { testIsolation: true }, () => { | ||
| let currentUser: 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() | ||
| }) | ||
| }) | ||
|
|
||
| it('Only renders the .jpg file', () => { | ||
| getRowForFileId(jpgFileId).should('have.length', 1) | ||
| getRowForFileId(movFileId).should('have.length', 0) | ||
| }) | ||
|
|
||
| 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 }) | ||
| }) | ||
|
|
||
| it("Shows both files when 'Show hidden files' is enabled", () => { | ||
| getRowForFileId(jpgFileId).should('have.length', 1).invoke('attr', 'data-cy-files-list-row-name').should('equal', `${randomFileName}.jpg`) | ||
| getRowForFileId(movFileId).should('have.length', 1).invoke('attr', 'data-cy-files-list-row-name').should('equal', `${randomFileName}.mov`) | ||
| }) | ||
|
|
||
| it('Copies both files when copying the .jpg', () => { | ||
| copyFile(`${randomFileName}.jpg`, '.') | ||
| refreshView('All files') | ||
|
|
||
| getRowForFile(`${randomFileName}.jpg`).should('have.length', 1) | ||
| getRowForFile(`${randomFileName}.mov`).should('have.length', 1) | ||
| getRowForFile(`${randomFileName} (copy).jpg`).should('have.length', 1) | ||
| getRowForFile(`${randomFileName} (copy).mov`).should('have.length', 1) | ||
| }) | ||
|
|
||
| it('Copies both files when copying the .mov', () => { | ||
| copyFile(`${randomFileName}.mov`, '.') | ||
| refreshView('All files') | ||
|
|
||
| getRowForFile(`${randomFileName}.mov`).should('have.length', 1) | ||
| getRowForFile(`${randomFileName} (copy).jpg`).should('have.length', 1) | ||
| getRowForFile(`${randomFileName} (copy).mov`).should('have.length', 1) | ||
| }) | ||
|
|
||
| it('Moves files when moving the .jpg', () => { | ||
| renameFile(`${randomFileName}.jpg`, `${randomFileName}_moved.jpg`) | ||
| refreshView('All files') | ||
|
|
||
| getRowForFileId(jpgFileId).invoke('attr', 'data-cy-files-list-row-name').should('equal', `${randomFileName}_moved.jpg`) | ||
| getRowForFileId(movFileId).invoke('attr', 'data-cy-files-list-row-name').should('equal', `${randomFileName}_moved.mov`) | ||
| }) | ||
|
|
||
| it('Moves files when moving the .mov', () => { | ||
| renameFile(`${randomFileName}.mov`, `${randomFileName}_moved.mov`) | ||
| refreshView('All files') | ||
|
|
||
| getRowForFileId(jpgFileId).invoke('attr', 'data-cy-files-list-row-name').should('equal', `${randomFileName}_moved.jpg`) | ||
| getRowForFileId(movFileId).invoke('attr', 'data-cy-files-list-row-name').should('equal', `${randomFileName}_moved.mov`) | ||
| }) | ||
|
|
||
| it('Deletes files when deleting the .jpg', () => { | ||
| triggerActionForFile(`${randomFileName}.jpg`, 'delete') | ||
| refreshView('All files') | ||
|
|
||
| getRowForFile(`${randomFileName}.jpg`).should('have.length', 0) | ||
| getRowForFile(`${randomFileName}.mov`).should('have.length', 0) | ||
|
|
||
| cy.visit('/apps/files/trashbin') | ||
|
|
||
| getRowForFileId(jpgFileId).invoke('attr', 'data-cy-files-list-row-name').should('to.match', new RegExp(`^${randomFileName}.jpg\\.d[0-9]+$`)) | ||
| getRowForFileId(movFileId).invoke('attr', 'data-cy-files-list-row-name').should('to.match', new RegExp(`^${randomFileName}.mov\\.d[0-9]+$`)) | ||
| }) | ||
|
|
||
| it('Block deletion when deleting the .mov', () => { | ||
| triggerActionForFile(`${randomFileName}.mov`, 'delete') | ||
| refreshView('All files') | ||
|
|
||
| getRowForFile(`${randomFileName}.jpg`).should('have.length', 1) | ||
| getRowForFile(`${randomFileName}.mov`).should('have.length', 1) | ||
|
|
||
| cy.visit('/apps/files/trashbin') | ||
|
|
||
| getRowForFileId(jpgFileId).should('have.length', 0) | ||
| getRowForFileId(movFileId).should('have.length', 0) | ||
| }) | ||
|
|
||
| it('Restores files when restoring the .jpg', () => { | ||
| triggerActionForFile(`${randomFileName}.jpg`, 'delete') | ||
| cy.visit('/apps/files/trashbin') | ||
| triggerInlineActionForFileId(jpgFileId, 'restore') | ||
| refreshView('Deleted files') | ||
|
|
||
| getRowForFile(`${randomFileName}.jpg`).should('have.length', 0) | ||
| getRowForFile(`${randomFileName}.mov`).should('have.length', 0) | ||
|
|
||
| cy.visit('/apps/files') | ||
|
|
||
| getRowForFile(`${randomFileName}.jpg`).should('have.length', 1) | ||
| getRowForFile(`${randomFileName}.mov`).should('have.length', 1) | ||
| }) | ||
|
|
||
| it('Blocks restoration when restoring the .mov', () => { | ||
| triggerActionForFile(`${randomFileName}.jpg`, 'delete') | ||
| cy.visit('/apps/files/trashbin') | ||
| triggerInlineActionForFileId(movFileId, 'restore') | ||
| refreshView('Deleted files') | ||
|
|
||
| getRowForFileId(jpgFileId).should('have.length', 1) | ||
| getRowForFileId(movFileId).should('have.length', 1) | ||
|
|
||
| cy.visit('/apps/files') | ||
|
|
||
| getRowForFile(`${randomFileName}.jpg`).should('have.length', 0) | ||
| getRowForFile(`${randomFileName}.mov`).should('have.length', 0) | ||
| }) | ||
| }) | ||
| }) | ||
This file contains hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.