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

Improve resilience of e2e tests #1642

Closed
wants to merge 1 commit into from
Closed
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
12 changes: 8 additions & 4 deletions cypress/e2e/albums.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,15 @@ import {
removeSelectionFromAlbum,
} from './albumsUtils'
import {
downloadSelection,
favoriteSelection,
selectMedia,
unfavoriteSelection,
unselectMedia,
uploadTestMedia,
} from './photosUtils'

import { randHash } from '../utils'

const resizeObserverLoopErrRe = /^[^(ResizeObserver loop limit exceeded)]/
Cypress.on('uncaught:exception', (err) => {
/* returning false here prevents Cypress from failing the test */
Expand All @@ -43,6 +44,8 @@ Cypress.on('uncaught:exception', (err) => {
})

describe('Manage albums', () => {
let albumName = ''

before(function() {
cy.createRandomUser()
.then((user) => {
Expand All @@ -54,8 +57,9 @@ describe('Manage albums', () => {

beforeEach(() => {
cy.visit(`${Cypress.env('baseUrl')}/index.php/apps/photos/albums`)
createAnAlbumFromAlbums('albums_test')
addFilesToAlbumFromAlbum('albums_test', [0, 1, 2])
albumName = `albums_test_${randHash()}`
createAnAlbumFromAlbums(albumName)
addFilesToAlbumFromAlbum(albumName, [0, 1, 2])
})

afterEach(() => {
Expand Down Expand Up @@ -124,7 +128,7 @@ describe('Manage albums', () => {

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

Expand Down
57 changes: 36 additions & 21 deletions cypress/e2e/shared_albums.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,29 +64,32 @@ describe('Manage shared albums', () => {
})

context('Adding and removing files in a shared album', () => {
let albumName = ''

before(() => {
albumName = `shared_album_test_1_${randHash()}`
cy.login(alice)
cy.visit('apps/photos/albums')
createAnAlbumFromAlbums('shared_album_test1')
createAnAlbumFromAlbums(albumName)
addCollaborators([bob.userId])
})

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

it('Add and remove multiple files to a shared album from a shared album', () => {
goToSharedAlbum('shared_album_test1')
goToSharedAlbum(albumName)
cy.get('[data-test="media"]').should('have.length', 0)
addFilesToAlbumFromAlbum('shared_album_test1', [1, 2])
addFilesToAlbumFromAlbum(albumName, [1, 2])
cy.get('[data-test="media"]').should('have.length', 2)
selectMedia([0, 1])
removeSelectionFromAlbum()
Expand All @@ -95,100 +98,112 @@ describe('Manage shared albums', () => {
})

context('Download files from a shared album', () => {
let albumName = ''

before(() => {
albumName = `shared_album_test_2_${randHash()}`
cy.login(alice)
cy.visit('apps/photos/albums')
createAnAlbumFromAlbums('shared_album_test2')
createAnAlbumFromAlbums(albumName)
addCollaborators([bob.userId])

cy.login(bob)
cy.visit('apps/photos/sharedalbums')
goToSharedAlbum('shared_album_test2')
addFilesToAlbumFromAlbum('shared_album_test2', [0, 1, 2])
goToSharedAlbum(albumName)
addFilesToAlbumFromAlbum(albumName, [0, 1, 2])
})

xit('Download a file from a shared album', () => {
goToSharedAlbum('shared_album_test2')
goToSharedAlbum(albumName)
selectMedia([0])
downloadSelection()
selectMedia([0])
})

xit('Download multiple files from a shared album', () => {
goToSharedAlbum('shared_album_test2')
goToSharedAlbum(albumName)
selectMedia([1, 2])
downloadSelection()
selectMedia([1, 2])
})

xit('Download all files from a shared album', () => {
goToSharedAlbum('shared_album_test2')
goToSharedAlbum(albumName)
downloadAllFiles()
})
})

context('Delete a received shared album', () => {
let albumName = ''

before(() => {
albumName = `shared_album_test_3_${randHash()}`
cy.login(alice)
cy.visit('apps/photos/albums')
createAnAlbumFromAlbums('shared_album_test3')
createAnAlbumFromAlbums(albumName)
addCollaborators([bob.userId])
})

it('Remove shared album', () => {
cy.login(bob)
cy.visit('apps/photos/albums')
goToSharedAlbum('shared_album_test3')
goToSharedAlbum(albumName)
removeSharedAlbums()
})
})

context('Remove a collaborator from an album', () => {
let albumName = ''

before(() => {
albumName = `shared_album_test_4_${randHash()}`
cy.login(alice)
cy.visit('/apps/photos/albums')
createAnAlbumFromAlbums('shared_album_test4')
createAnAlbumFromAlbums(albumName)
addCollaborators([bob.userId])
})

it('Remove collaborator from an album', () => {
cy.login(bob)
cy.visit('apps/photos/sharedalbums')
cy.get('ul.collections__list li')
.should('contain', `shared_album_test4 (${alice.userId})`)
.should('contain', `${albumName} (${alice.userId})`)

cy.login(alice)
cy.visit('/apps/photos')
goToAlbum('shared_album_test4')
goToAlbum(albumName)
removeCollaborators([bob.userId])

cy.login(bob)
cy.visit('/apps/photos/sharedalbums')
cy.get('body')
.should('not.contain', `shared_album_test4 (${alice.userId})`)
.should('not.contain', `${albumName} (${alice.userId})`)
})
})

context('Two shared albums with the same name', () => {
let albumName = ''

before(() => {
albumName = `shared_album_test_5_${randHash()}`
cy.login(alice)
cy.visit('apps/photos/albums')
createAnAlbumFromAlbums('shared_album_test5')
createAnAlbumFromAlbums(albumName)
addCollaborators([bob.userId])

cy.login(charlie)
cy.visit('apps/photos/albums')
createAnAlbumFromAlbums('shared_album_test5')
createAnAlbumFromAlbums(albumName)
addCollaborators([bob.userId])
})

it('It should display two shared albums', () => {
cy.login(bob)
cy.visit('/apps/photos/sharedalbums')
cy.get('ul.collections__list li')
.contains(`shared_album_test5 (${alice.userId})`)
.contains(`${albumName} (${alice.userId})`)
cy.get('ul.collections__list li')
.contains(`shared_album_test5 (${charlie.userId})`)
.contains(`${albumName} (${charlie.userId})`)
})
})
})