Skip to content
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

Add config to select source directories #2319

Merged
merged 13 commits into from
Feb 15, 2024
4 changes: 3 additions & 1 deletion cypress/e2e/albums.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import {
import {
deleteSelection,
favoriteSelection,
mkdir,
selectMedia,
unfavoriteSelection,
unselectMedia,
Expand All @@ -47,10 +48,11 @@ Cypress.on('uncaught:exception', (err) => {
describe('Manage albums', { testIsolation: true }, () => {
let user = null

beforeEach(function() {
beforeEach(function () {
cy.createRandomUser()
.then(_user => {
user = _user
mkdir(user, '/Photos')
uploadTestMedia(user)
cy.login(user)
})
Expand Down
28 changes: 26 additions & 2 deletions cypress/e2e/photosUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@
*/

import type { User } from '@nextcloud/cypress'
import axios from 'axios'

export function uploadTestMedia(user: User) {
export function uploadTestMedia(user: User, destination = '/Photos') {
cy.exec('ls cypress/fixtures/media')
.then((result) => {
for (const fileName of result.stdout.split('\n')) {
cy.uploadFile(user, `media/${fileName}`, 'image/png', `/${fileName}`)
cy.uploadFile(user, `media/${fileName}`, 'image/png', `/${destination}/${fileName}`)
}
})
}
Expand Down Expand Up @@ -72,3 +73,26 @@ export function deleteSelection() {
.click()
.wait('@deleteRequests')
}

export function mkdir(user: User, target: string) {
// eslint-disable-next-line cypress/unsafe-to-chain-command
cy.clearCookies()
.then({ timeout: 8000 }, async () => {
try {
const rootPath = `${Cypress.env('baseUrl')}/remote.php/dav/files/${encodeURIComponent(user.userId)}`
const filePath = target.split('/').map(encodeURIComponent).join('/')
const response = await axios({
url: `${rootPath}${filePath}`,
method: 'MKCOL',
auth: {
username: user.userId,
password: user.password,
},
})
cy.log(`Created directory ${target}`, response)
} catch (error) {
cy.log('error', error)
throw new Error('Unable to process fixture')
}
})
}
5 changes: 3 additions & 2 deletions cypress/e2e/places.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
import { uploadTestMedia } from './photosUtils'
import { mkdir, uploadTestMedia } from './photosUtils'
import { navigateToPlace, runOccCommand } from './placesUtils'

const resizeObserverLoopErrRe = /^[^(ResizeObserver loop limit exceeded)]/
Expand All @@ -31,9 +31,10 @@ Cypress.on('uncaught:exception', (err) => {
})

describe('Manage places', () => {
before(function() {
before(function () {
cy.createRandomUser()
.then((user) => {
mkdir(user, '/Photos')
uploadTestMedia(user)
runOccCommand('files:scan --all --generate-metadata')
cy.login(user)
Expand Down
5 changes: 5 additions & 0 deletions cypress/e2e/shared_albums.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import {
deleteSelection,
downloadAllFiles,
downloadSelection,
mkdir,
selectMedia,
uploadTestMedia,
} from './photosUtils'
Expand Down Expand Up @@ -64,6 +65,9 @@ describe('Manage shared albums', () => {
cy.createUser(alice)
cy.createUser(bob)
cy.createUser(charlie)
mkdir(alice, '/Photos')
mkdir(bob, '/Photos')
mkdir(charlie, '/Photos')
uploadTestMedia(alice)
uploadTestMedia(bob)
uploadTestMedia(charlie)
Expand Down Expand Up @@ -302,6 +306,7 @@ describe('Manage shared albums', () => {
cy.visit('apps/photos/sharedalbums')
cy.get('body').should('not.contain', `shared_album_test7 (${alice.userId})`)
cy.createUser(alice)
mkdir(alice, '/Photos')
uploadTestMedia(alice)
})
})
Expand Down
3 changes: 3 additions & 0 deletions cypress/e2e/timelines.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import {
deleteSelection,
downloadSelection,
favoriteSelection,
mkdir,
selectMedia,
unfavoriteSelection,
unselectMedia,
Expand All @@ -59,9 +60,11 @@ const bob = new User(`bob_${randHash()}`)
describe('View list of photos in the main timeline', () => {
before(() => {
cy.createUser(alice).then(() => {
mkdir(alice, '/Photos')
uploadTestMedia(alice)
})
cy.createUser(bob).then(() => {
mkdir(bob, '/Photos')
uploadTestMedia(bob)
})
cy.login(alice)
Expand Down
4 changes: 2 additions & 2 deletions js/photos-main.js

Large diffs are not rendered by default.

44 changes: 22 additions & 22 deletions js/photos-main.js.LICENSE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -391,28 +391,6 @@
*
*/

/**
* @copyright Copyright (c) 2020 John Molakvoæ <[email protected]>
*
* @author John Molakvoæ <[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/>.
*
*/

/**
* @copyright Copyright (c) 2020 John Molakvoæ <[email protected]>
*
Expand Down Expand Up @@ -612,6 +590,28 @@
*
*/

/**
* @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/>.
*
*/

/**
* @license nested-property https://github.com/cosmosio/nested-property
*
Expand Down
2 changes: 1 addition & 1 deletion js/photos-main.js.map

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Loading
Loading