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

Polish albums - second round #1247

Merged
merged 9 commits into from
Sep 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions cypress/e2e/albums.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,36 @@ describe('Manage albums', () => {
cy.downloadSelection()
cy.unselectMedia([1, 2])
})

it('Edit an album\'s name', () => {
cy.get('[aria-label="Open actions menu"]').click()
cy.contains('Edit album details').click()
cy.get('form [name="name"]').clear().type("New name")
cy.contains('Save').click()

cy.reload()

cy.contains('New name')

cy.get('[aria-label="Open actions menu"]').click()
cy.contains('Edit album details').click()
cy.get('form [name="name"]').clear().type("albums_test")
cy.contains('Save').click()
})

it('Edit an album\'s location', () => {
cy.get('[aria-label="Open actions menu"]').click()
cy.contains('Edit album details').click()
cy.get('form [name="location"]').clear().type("New location")
cy.contains('Save').click()

cy.reload()

cy.contains('New location')

cy.get('[aria-label="Open actions menu"]').click()
cy.contains('Edit album details').click()
cy.get('form [name="location"]').clear()
cy.contains('Save').click()
})
})
220 changes: 132 additions & 88 deletions cypress/e2e/shared_albums.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@
*
*/
import { randHash } from '../utils'

const randUser = randHash()
const randUser2 = randHash()
const randUser3 = randHash()

const resizeObserverLoopErrRe = /^[^(ResizeObserver loop limit exceeded)]/
Cypress.on('uncaught:exception', (err) => {
Expand All @@ -34,112 +36,154 @@ Cypress.on('uncaught:exception', (err) => {
describe('Manage shared albums', () => {
before(() => {
cy.logout()

cy.nextcloudCreateUser(randUser, 'password')
cy.nextcloudCreateUser(randUser2, 'password')

cy.login(randUser, 'password')
cy.visit(`${Cypress.env('baseUrl')}/index.php/apps/photos/albums`)
cy.createAnAlbumFromAlbums('shared_album_test1')
cy.addCollaborators([randUser2])
cy.visit(`${Cypress.env('baseUrl')}/index.php/apps/photos/albums`)
cy.createAnAlbumFromAlbums('shared_album_test2')
cy.addCollaborators([randUser2])
cy.visit(`${Cypress.env('baseUrl')}/index.php/apps/photos/albums`)
cy.createAnAlbumFromAlbums('shared_album_test3')
cy.addCollaborators([randUser2])
cy.visit(`${Cypress.env('baseUrl')}/index.php/apps/photos/albums`)
cy.createAnAlbumFromAlbums('shared_album_test4')
cy.addCollaborators([randUser2])
cy.logout()
cy.nextcloudCreateUser(randUser3, 'password')

cy.login(randUser2, 'password')
cy.uploadTestMedia()
cy.visit(`${Cypress.env('baseUrl')}/index.php/apps/photos/sharedalbums`)
cy.goToSharedAlbum('shared_album_test2')
cy.addFilesToAlbumFromAlbum('shared_album_test2', [0, 1, 2])

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

beforeEach(() => {
cy.logout()
cy.login(randUser2, 'password')
cy.visit(`${Cypress.env('baseUrl')}/index.php/apps/photos/sharedalbums`)
})

it('Add and remove a file to a shared album from a shared album', () => {
cy.goToSharedAlbum('shared_album_test1')
cy.get('[data-test="media"]').should('have.length', 0)
cy.addFilesToAlbumFromAlbum('shared_album_test1', [0])
cy.get('[data-test="media"]').should('have.length', 1)
cy.selectMedia([0])
cy.removeSelectionFromAlbum()
cy.get('[data-test="media"]').should('have.length', 0)
})

it('Add and remove multiple files to a shared album from a shared album', () => {
cy.goToSharedAlbum('shared_album_test1')
cy.get('[data-test="media"]').should('have.length', 0)
cy.addFilesToAlbumFromAlbum('shared_album_test1', [1, 2])
cy.get('[data-test="media"]').should('have.length', 2)
cy.selectMedia([0, 1])
cy.removeSelectionFromAlbum()
cy.get('[data-test="media"]').should('have.length', 0)
})

it('Download a file from a shared album', () => {
cy.goToSharedAlbum('shared_album_test2')
cy.selectMedia([0])
cy.downloadSelection()
cy.unselectMedia([0])
})

it('Download multiple files from a shared album', () => {
cy.goToSharedAlbum('shared_album_test2')
cy.selectMedia([1, 2])
cy.downloadSelection()
cy.unselectMedia([1, 2])
context('Adding and removing files in a shared album', () => {
before(() => {
cy.logout()
cy.login(randUser, 'password')
cy.visit(`${Cypress.env('baseUrl')}/index.php/apps/photos/albums`)
cy.createAnAlbumFromAlbums('shared_album_test1')
cy.addCollaborators([randUser2])
cy.logout()
})

it('Add and remove a file to a shared album from a shared album', () => {
cy.goToSharedAlbum('shared_album_test1')
cy.get('[data-test="media"]').should('have.length', 0)
cy.addFilesToAlbumFromAlbum('shared_album_test1', [0])
cy.get('[data-test="media"]').should('have.length', 1)
cy.selectMedia([0])
cy.removeSelectionFromAlbum()
cy.get('[data-test="media"]').should('have.length', 0)
})

it('Add and remove multiple files to a shared album from a shared album', () => {
cy.goToSharedAlbum('shared_album_test1')
cy.get('[data-test="media"]').should('have.length', 0)
cy.addFilesToAlbumFromAlbum('shared_album_test1', [1, 2])
cy.get('[data-test="media"]').should('have.length', 2)
cy.selectMedia([0, 1])
cy.removeSelectionFromAlbum()
cy.get('[data-test="media"]').should('have.length', 0)
})
})

it('Download all files from a shared album', () => {
cy.goToSharedAlbum('shared_album_test2')
cy.downloadAllFiles()
context('Download files from a shared album', () => {
before(() => {
cy.logout()
cy.login(randUser, 'password')
cy.visit(`${Cypress.env('baseUrl')}/index.php/apps/photos/albums`)
cy.createAnAlbumFromAlbums('shared_album_test2')
cy.addCollaborators([randUser2])
cy.logout()

cy.login(randUser2, 'password')
cy.visit(`${Cypress.env('baseUrl')}/index.php/apps/photos/sharedalbums`)
cy.goToSharedAlbum('shared_album_test2')
cy.addFilesToAlbumFromAlbum('shared_album_test2', [0, 1, 2])
cy.logout()
})

it('Download a file from a shared album', () => {
cy.goToSharedAlbum('shared_album_test2')
cy.selectMedia([0])
cy.downloadSelection()
cy.unselectMedia([0])
})

it('Download multiple files from a shared album', () => {
cy.goToSharedAlbum('shared_album_test2')
cy.selectMedia([1, 2])
cy.downloadSelection()
cy.unselectMedia([1, 2])
})

it('Download all files from a shared album', () => {
cy.goToSharedAlbum('shared_album_test2')
cy.downloadAllFiles()
})
})

it('Remove a file from a shared album', () => {
cy.goToSharedAlbum('shared_album_test2')
cy.get('[data-test="media"]').should('have.length', 3)
cy.goToSharedAlbum('shared_album_test2')
cy.selectMedia([0])
cy.removeSelectionFromAlbum()
cy.get('[data-test="media"]').should('have.length', 2)
context('Delete a received shared album', () => {
before(() => {
cy.logout()
cy.login(randUser, 'password')
cy.visit(`${Cypress.env('baseUrl')}/index.php/apps/photos/albums`)
cy.createAnAlbumFromAlbums('shared_album_test3')
cy.addCollaborators([randUser2])
cy.logout()
})

it('Remove shared album', () => {
cy.goToSharedAlbum('shared_album_test3')
cy.removeSharedAlbums()
})
})

it('Remove multiple files from a shared album', () => {
cy.goToSharedAlbum('shared_album_test2')
cy.get('[data-test="media"]').should('have.length', 2)
cy.goToSharedAlbum('shared_album_test2')
cy.selectMedia([0, 1])
cy.removeSelectionFromAlbum()
cy.get('[data-test="media"]').should('have.length', 0)
context('Remove a collaborator from an album', () => {
before(() => {
cy.logout()
cy.login(randUser, 'password')
cy.visit(`${Cypress.env('baseUrl')}/index.php/apps/photos/albums`)
cy.createAnAlbumFromAlbums('shared_album_test4')
cy.addCollaborators([randUser2])
cy.logout()
})

it('Remove collaborator from an album', () => {
cy.get('ul.collections__list li').should('have.length', 4)

cy.logout()
cy.login(randUser, 'password')
cy.visit(`${Cypress.env('baseUrl')}/index.php/apps/photos`)
cy.goToAlbum('shared_album_test4')
cy.removeCollaborators([randUser2])
cy.logout()

cy.login(randUser2, 'password')
cy.visit(`${Cypress.env('baseUrl')}/index.php/apps/photos/sharedalbums`)

cy.get('ul.collections__list li').should('have.length', 3)
})
})

xit('Remove shared album', () => {
cy.goToSharedAlbum('shared_album_test3')
cy.removeSharedAlbums()
})

xit('Remove collaborator from an album', () => {
cy.get('[data-test="media"]').should('have.length', 4)

cy.logout()
cy.login(randUser, 'password')
cy.goToAlbum('shared_album_test4')
cy.removeCollaborators([randUser2])
cy.logout()

cy.login(randUser2, 'password')
cy.visit(`${Cypress.env('baseUrl')}/index.php/apps/photos/sharedalbums`)

cy.get('ul.collections__list li').should('have.length', 3)
context('Two shared albums with the same name', () => {
before(() => {
cy.logout()
cy.login(randUser, 'password')
cy.visit(`${Cypress.env('baseUrl')}/index.php/apps/photos/albums`)
cy.createAnAlbumFromAlbums('shared_album_test5')
cy.addCollaborators([randUser2])
cy.logout()

cy.login(randUser3, 'password')
cy.visit(`${Cypress.env('baseUrl')}/index.php/apps/photos/albums`)
cy.createAnAlbumFromAlbums('shared_album_test5')
cy.addCollaborators([randUser2])
cy.logout()
})


it('It should display two shared albums', () => {
cy.get('ul.collections__list li')
.contains(`shared_album_test5 (${randUser})`)
cy.get('ul.collections__list li')
.contains(`shared_album_test5 (${randUser3})`)
})
})
})
13 changes: 9 additions & 4 deletions cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,13 +232,18 @@ Cypress.Commands.add('addCollaborators', collaborators => {
Cypress.Commands.add('removeCollaborators', collaborators => {
cy.get('[aria-label="Manage collaborators for this album"]').click()
collaborators.forEach((collaborator) => {
cy.get('[aria-label="Search for collaborators"').type(collaborator)
cy.contains(collaborator).click()
cy.get('.manage-collaborators')
.within(() => {
cy.contains(collaborator)
.parentsUntil('ul')
.get(`[aria-label="Remove ${collaborator} from the collaborators list"]`)
.click()
})
})
cy.contains('Save').click()
})

Cypress.Commands.add('removeSharedAlbums', collaborators => {
Cypress.Commands.add('removeSharedAlbums', () => {
cy.get('[aria-label="Open actions menu"]').click()
cy.contains("Remove selection from album").click()
cy.contains("Delete album").click()
})
6 changes: 3 additions & 3 deletions lib/Album/AlbumMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -364,11 +364,11 @@ public function getSharedAlbumsForCollaboratorWithFiles(string $collaboratorId,
if ($row['fileid']) {
$mimeId = $row['mimetype'];
$mimeType = $this->mimeTypeLoader->getMimetypeById($mimeId);
$filesByAlbum[$albumId][] = new AlbumFile((int)$row['fileid'], $row['file_name'], $mimeType, (int)$row['size'], (int)$row['mtime'], $row['etag'], (int)$row['added'], $row['owner']);
$filesByAlbum[$albumId][] = new AlbumFile((int)$row['fileid'], $row['album_name'].' ('.$row['album_user'].')', $mimeType, (int)$row['size'], (int)$row['mtime'], $row['etag'], (int)$row['added'], $row['owner']);
}

if (!isset($albumsById[$albumId])) {
$albumsById[$albumId] = new AlbumInfo($albumId, $row['album_user'], $row['album_name'], $row['location'], (int)$row['created'], (int)$row['last_added_photo']);
$albumsById[$albumId] = new AlbumInfo($albumId, $row['album_user'], $row['album_name'].' ('.$row['album_user'].')', $row['location'], (int)$row['created'], (int)$row['last_added_photo']);
}
}

Expand Down Expand Up @@ -419,7 +419,7 @@ public function getAlbumForCollaboratorIdAndFileId(string $collaboratorId, int $
return new AlbumInfo(
(int)$row['album_id'],
$row['user'],
$row['name'],
$row['name'].' ('.$row['user'].')',
$row['location'],
(int)$row['created'],
(int)$row['last_added_photo']
Expand Down
Loading