feat(test): add more e2e test for queue navigation

This commit is contained in:
Phan An 2021-01-04 19:10:12 +01:00
parent bd70cd5bac
commit 2135a8faba
5 changed files with 52 additions and 8 deletions

View file

@ -52,7 +52,7 @@ context('Queuing', { scrollBehavior: false }, () => {
})
it('creates a queue from selected songs', () => {
cy.$queueSeveralSongs()
cy.$shuffleSeveralSongs()
cy.get('#queueWrapper').within(() => {
cy.get('tr.song-item').should('have.length', 3)
@ -61,7 +61,7 @@ context('Queuing', { scrollBehavior: false }, () => {
})
it('deletes a song from queue', () => {
cy.$queueSeveralSongs()
cy.$shuffleSeveralSongs()
cy.get('#queueWrapper').within(() => {
cy.get('tr.song-item').should('have.length', 3)
@ -71,7 +71,7 @@ context('Queuing', { scrollBehavior: false }, () => {
})
it('queues a song when plays it', () => {
cy.$queueSeveralSongs()
cy.$shuffleSeveralSongs()
cy.$clickSidebarItem('All Songs')
let songTitle
@ -94,4 +94,48 @@ context('Queuing', { scrollBehavior: false }, () => {
cy.$assertPlaying()
})
it('navigates through the queue', () => {
cy.$shuffleSeveralSongs()
cy.get('#queueWrapper tr.song-item:nth-child(1)').should('have.class', 'playing')
cy.findByTestId('play-next-btn').click({ force: true })
cy.get('#queueWrapper tr.song-item:nth-child(2)').should('have.class', 'playing')
cy.$assertPlaying()
cy.findByTestId('play-prev-btn').click({ force: true })
cy.get('#queueWrapper tr.song-item:nth-child(1)').should('have.class', 'playing')
cy.$assertPlaying()
})
it('stops playing if reaches end of queue in no-repeat mode', () => {
cy.$shuffleSeveralSongs()
cy.findByTestId('play-next-btn').click({ force: true })
cy.findByTestId('play-next-btn').click({ force: true })
cy.findByTestId('play-next-btn').click({ force: true })
cy.$assertNotPlaying()
})
it('rotates if reaches end of queue in repeat-all mode', () => {
cy.findByTestId('repeat-mode-switch').click()
cy.$shuffleSeveralSongs()
cy.findByTestId('play-next-btn').click({ force: true })
cy.findByTestId('play-next-btn').click({ force: true })
cy.findByTestId('play-next-btn').click({ force: true })
cy.get('#queueWrapper tr.song-item:nth-child(1)').should('have.class', 'playing')
cy.$assertPlaying()
})
it('still moves to next song in repeat-one mode', () => {
cy.findByTestId('repeat-mode-switch').click()
cy.findByTestId('repeat-mode-switch').click()
cy.$shuffleSeveralSongs()
cy.findByTestId('play-next-btn').click({ force: true })
cy.get('#queueWrapper tr.song-item:nth-child(2)').should('have.class', 'playing')
cy.$assertPlaying()
})
})

View file

@ -69,7 +69,7 @@ context('Song Context Menu', { scrollBehavior: false }, () => {
]).forEach(config => {
it(`queues a song to ${config.menuItem}`, () => {
cy.$login()
cy.$queueSeveralSongs()
cy.$shuffleSeveralSongs()
cy.$clickSidebarItem('All Songs')
let songTitle

View file

@ -64,7 +64,7 @@ Cypress.Commands.add('$mockPlayback', () => {
})
})
Cypress.Commands.add('$queueSeveralSongs', (count = 3) => {
Cypress.Commands.add('$shuffleSeveralSongs', (count = 3) => {
cy.$mockPlayback()
cy.$clickSidebarItem('All Songs')

4
cypress/types.d.ts vendored
View file

@ -11,7 +11,7 @@ declare namespace Cypress {
interface Chainable {
$login(options?: Partial<LoginOptions>): Chainable<AUTWindow>
$loginAsNonAdmin(options?: Partial<LoginOptions>): Chainable<AUTWindow>
$each(dataset: Array<Array<any>>, callback: Function): void
$each(dataset: Array<Array<any>>, callback: (...args) => void): void
$confirm(): void
$clickSidebarItem(sidebarItemText: string): Chainable<JQuery>
@ -24,7 +24,7 @@ declare namespace Cypress {
* Queue several songs from the All Song screen.
* @param count
*/
$queueSeveralSongs(count?: number): void
$shuffleSeveralSongs(count?: number): void
$assertPlaylistSongCount(name: string, count: number): void
$assertFavoriteSongCount(count: number): void

@ -1 +1 @@
Subproject commit d1ba4b2c17e9cfb81b1e0c00cd2464f5549ea85b
Subproject commit e603d05a170e219fd1d14747ecc05b466c438f8e