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 Jan 31, 2023
1 parent 42aafdf commit a62b318
Show file tree
Hide file tree
Showing 37 changed files with 1,354 additions and 34 deletions.
25 changes: 22 additions & 3 deletions .github/workflows/cypress.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ jobs:
uses: skjnldsv/read-package-engines-version-actions@v1.1
id: versions
with:
fallbackNode: '^12'
fallbackNpm: '^6'
fallbackNode: "^16"
fallbackNpm: "^7"

- name: Set up node ${{ steps.versions.outputs.nodeVersion }}
uses: actions/setup-node@v3
Expand All @@ -52,6 +52,11 @@ jobs:

cypress:
runs-on: ubuntu-latest
# Specify which version of browser we are testing.
# This prevent hard to track error when the default browser is upgraded and break our tests.
# But this means that we have to regularly update this line.
# https://hub.docker.com/r/cypress/browsers/tags
container: node18.12.0-chrome106-ff106
needs: init

strategy:
Expand Down Expand Up @@ -90,6 +95,9 @@ jobs:
# cypress env
ci-build-id: ${{ github.sha }}-${{ github.run_number }}
tag: ${{ github.event_name }}
# Currently testing on Firefox as chrome does not upload files correctly.
# https://docs.cypress.io/guides/continuous-integration/github-actions#Basic-Setup
browser: firefox
env:
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
# https://github.com/cypress-io/github-action/issues/124
Expand All @@ -100,9 +108,20 @@ jobs:
uses: actions/upload-artifact@v3
if: always()
with:
name: snapshots
name: snapshots_${{ matrix.containers }}
path: cypress/snapshots

- name: Extract NC logs
if: always()
run: docker-compose --project-directory cypress logs > nextcloud.log

- name: Upload NC logs
uses: actions/upload-artifact@v3
if: always()
with:
name: nc_logs_${{ matrix.containers }}
path: nextcloud.log

summary:
runs-on: ubuntu-latest
needs: [init, cypress]
Expand Down
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 --user ${alice}`)

// 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)
})
})
3 changes: 2 additions & 1 deletion cypress/initserver.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ su www-data -c "
"

cd apps
git clone --depth 1 https://github.com/nextcloud/viewer.git
git clone --depth 1 https://github.com/nextcloud/viewer.git
cd ../
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.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */

/**
* @copyright Copyright (c) 2022 Louis Chemineau <louis@chmn.me>
*
* @author Louis Chemineau <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/>.
*
*/

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions js/photos-public.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/photos-public.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.

Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */

/**
* @copyright Copyright (c) 2022 Louis Chemineau <louis@chmn.me>
*
* @author Louis Chemineau <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/>.
*
*/

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions js/photos-src_views_Locations_vue.js

Large diffs are not rendered by default.

23 changes: 23 additions & 0 deletions js/photos-src_views_Locations_vue.js.LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */

/**
* @copyright Copyright (c) 2022 Louis Chemineau <louis@chmn.me>
*
* @author Louis Chemineau <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/>.
*
*/
Loading

0 comments on commit a62b318

Please sign in to comment.