Skip to content

Commit

Permalink
Add location grouping views
Browse files Browse the repository at this point in the history
Signed-off-by: Louis Chemineau <louis@chmn.me>
  • Loading branch information
artonge committed Nov 2, 2022
1 parent d652092 commit d3bebfe
Show file tree
Hide file tree
Showing 74 changed files with 10,087 additions and 503 deletions.
8 changes: 8 additions & 0 deletions appinfo/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@
'path' => '',
]
],
['name' => 'page#index', 'url' => '/locations/{path}', 'verb' => 'GET', 'postfix' => 'locations',
'requirements' => [
'path' => '.*',
],
'defaults' => [
'path' => '',
]
],
[ 'name' => 'publicAlbum#get', 'url' => '/public/{token}', 'verb' => 'GET',
'requirements' => [
'token' => '.*',
Expand Down
59 changes: 59 additions & 0 deletions cypress/e2e/locations.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/**
* @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 { randHash } from '../utils'

const alice = `alice_${randHash()}`

const resizeObserverLoopErrRe = /^[^(ResizeObserver loop limit exceeded)]/
Cypress.on('uncaught:exception', (err) => {
/* returning false here prevents Cypress from failing the test */
if (resizeObserverLoopErrRe.test(err.message)) {
return false
}
})

describe('Manage locations', () => {
before(function () {
cy.logout()
cy.nextcloudCreateUser(alice, 'password')

cy.login(alice, 'password')
cy.uploadTestMedia()
cy.runOccCommand('photos:map-media-to-location')

// wait a bit for things to be settled
cy.wait(1000)
})

beforeEach(() => {
cy.visit(`${Cypress.env('baseUrl')}/index.php/apps/photos/locations`)
})

it('Check that we detect some locations out of the existing files', () => {
cy.get('ul.collections__list li').should('have.length', 4)
})

it('Navigate to location and check that it contains some files', () => {
cy.navigateToLocation('Lauris')
cy.get('.collection li a.file').should('have.length', 1)
})
})
34 changes: 24 additions & 10 deletions cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@
const url = Cypress.config('baseUrl').replace(/\/index.php\/?$/g, '')
Cypress.env('baseUrl', url)

Cypress.Commands.add('runOccCommand', command => {
cy.exec(`docker-compose --project-directory cypress exec -T --user www-data nextcloud php ./occ ${command}`)
})

Cypress.Commands.add('login', (user, password, route = '/apps/files') => {
Cypress.Cookies.defaults({
preserve: /^(oc|nc)/,
Expand Down Expand Up @@ -115,16 +119,17 @@ Cypress.Commands.add('uploadFile', (fixtureFileName, mimeType, path = '', upload
.join("/")

const url = `${Cypress.env('baseUrl')}/remote.php/webdav${encodedPath}/${encodeURIComponent(uploadedFileName)}`
return cy.request({
method: 'PUT',
url,
body: file,
encoding: 'binary',
headers: {
'Content-Type': mimeType,
requesttoken: window.OC.requestToken,
},
})
return cy
.request({
method: 'PUT',
url,
body: file,
encoding: 'binary',
headers: {
'Content-Type': mimeType,
requesttoken: window.OC.requestToken,
},
})
})
})

Expand Down Expand Up @@ -245,3 +250,12 @@ Cypress.Commands.add('removeSharedAlbums', () => {
cy.get('[aria-label="Open actions menu"]').click()
cy.contains("Delete album").click()
})

Cypress.Commands.add('navigateToCollection', (collectionType, collectionName) => {
cy.get('.app-navigation__list').contains(collectionType).click()
cy.get('ul.collections__list').contains(collectionName).click()
})

Cypress.Commands.add('navigateToLocation', locationName => {
cy.navigateToCollection('Locations', locationName)
})
4 changes: 2 additions & 2 deletions js/photos-main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/photos-main.js.map

Large diffs are not rendered by default.

Loading

0 comments on commit d3bebfe

Please sign in to comment.