2021-01-02 11:58:46 +00:00
|
|
|
context('Song Context Menu', { scrollBehavior: false }, () => {
|
|
|
|
it('plays a song via double-clicking', () => {
|
|
|
|
cy.$mockPlayback()
|
2021-01-03 15:21:36 +00:00
|
|
|
cy.$login()
|
|
|
|
cy.$clickSidebarItem('All Songs')
|
2021-01-02 11:58:46 +00:00
|
|
|
|
|
|
|
cy.get('#songsWrapper').within(() => {
|
2022-04-26 09:46:31 +00:00
|
|
|
cy.get('.song-item:first-child').dblclick()
|
|
|
|
cy.get('.song-item:first-child').should('have.class', 'playing')
|
2021-01-02 11:58:46 +00:00
|
|
|
})
|
2021-01-02 22:19:33 +00:00
|
|
|
|
|
|
|
cy.$assertPlaying()
|
2021-01-02 11:58:46 +00:00
|
|
|
})
|
|
|
|
|
2021-01-02 22:19:33 +00:00
|
|
|
it('plays and pauses a song via context menu', () => {
|
2021-01-02 11:58:46 +00:00
|
|
|
cy.$mockPlayback()
|
2021-01-03 15:21:36 +00:00
|
|
|
cy.$login()
|
|
|
|
cy.$clickSidebarItem('All Songs')
|
2021-01-02 11:58:46 +00:00
|
|
|
|
|
|
|
cy.get('#songsWrapper').within(() => {
|
2022-04-26 09:46:31 +00:00
|
|
|
cy.get('.song-item:first-child')
|
2021-01-02 11:58:46 +00:00
|
|
|
.as('item')
|
|
|
|
.rightclick()
|
|
|
|
})
|
|
|
|
|
|
|
|
cy.findByTestId('song-context-menu').within(() => cy.findByText('Play').click())
|
|
|
|
cy.get('@item').should('have.class', 'playing')
|
2021-01-02 22:19:33 +00:00
|
|
|
cy.$assertPlaying()
|
|
|
|
|
|
|
|
cy.get('@item').rightclick()
|
|
|
|
cy.findByTestId('song-context-menu').within(() => cy.findByText('Pause').click())
|
|
|
|
cy.$assertNotPlaying()
|
2021-01-02 11:58:46 +00:00
|
|
|
})
|
|
|
|
|
2021-01-04 23:04:02 +00:00
|
|
|
it('invokes album screen', () => {
|
2021-01-03 15:21:36 +00:00
|
|
|
cy.$login()
|
|
|
|
cy.$clickSidebarItem('All Songs')
|
|
|
|
|
2022-04-26 09:46:31 +00:00
|
|
|
cy.get('#songsWrapper').within(() => cy.get('.song-item:first-child').rightclick())
|
2021-01-02 11:58:46 +00:00
|
|
|
cy.findByTestId('song-context-menu').within(() => cy.findByText('Go to Album').click())
|
|
|
|
|
|
|
|
cy.get('#albumWrapper')
|
|
|
|
.should('be.visible')
|
|
|
|
.within(() => {
|
|
|
|
cy.get('.screen-header').should('be.visible')
|
2022-04-26 09:46:31 +00:00
|
|
|
cy.get('.song-item').should('have.length.at.least', 1)
|
2021-01-02 11:58:46 +00:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2021-01-04 23:04:02 +00:00
|
|
|
it('invokes artist screen', () => {
|
2021-01-03 15:21:36 +00:00
|
|
|
cy.$login()
|
|
|
|
cy.$clickSidebarItem('All Songs')
|
|
|
|
|
2022-04-26 09:46:31 +00:00
|
|
|
cy.get('#songsWrapper').within(() => cy.get('.song-item:first-child').rightclick())
|
2021-01-02 11:58:46 +00:00
|
|
|
cy.findByTestId('song-context-menu').within(() => cy.findByText('Go to Artist').click())
|
|
|
|
|
|
|
|
cy.get('#artistWrapper')
|
|
|
|
.should('be.visible')
|
|
|
|
.within(() => {
|
|
|
|
cy.get('.screen-header').should('be.visible')
|
2022-04-26 09:46:31 +00:00
|
|
|
cy.get('.song-item').should('have.length.at.least', 1)
|
2021-01-02 11:58:46 +00:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
;([
|
|
|
|
{ menuItem: 'After Current Song', queuedPosition: 2 },
|
|
|
|
{ menuItem: 'Bottom of Queue', queuedPosition: 4 },
|
|
|
|
{ menuItem: 'Top of Queue', queuedPosition: 1 }
|
|
|
|
]).forEach(config => {
|
|
|
|
it(`queues a song to ${config.menuItem}`, () => {
|
2021-01-03 15:21:36 +00:00
|
|
|
cy.$login()
|
2021-01-04 18:10:12 +00:00
|
|
|
cy.$shuffleSeveralSongs()
|
2021-01-02 11:58:46 +00:00
|
|
|
cy.$clickSidebarItem('All Songs')
|
|
|
|
|
|
|
|
let songTitle
|
|
|
|
cy.get('#songsWrapper').within(() => {
|
2022-04-26 09:46:31 +00:00
|
|
|
cy.get('.song-item:nth-child(4) .title')
|
2021-01-02 11:58:46 +00:00
|
|
|
.invoke('text')
|
|
|
|
.then(text => {
|
|
|
|
songTitle = text
|
|
|
|
})
|
|
|
|
|
2022-04-26 09:46:31 +00:00
|
|
|
cy.get('.song-item:nth-child(4)').rightclick()
|
2021-01-02 11:58:46 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
cy.findByTestId('song-context-menu').within(() => {
|
2022-04-25 16:38:33 +00:00
|
|
|
cy.findByText('Add To').click()
|
|
|
|
cy.findByText(config.menuItem).click()
|
|
|
|
})
|
2021-01-02 11:58:46 +00:00
|
|
|
|
|
|
|
cy.$clickSidebarItem('Current Queue')
|
|
|
|
cy.get('#queueWrapper').within(() => {
|
2022-04-26 09:46:31 +00:00
|
|
|
cy.get('.song-item').should('have.length', 4)
|
|
|
|
cy.get(`.song-item:nth-child(${config.queuedPosition}) .title`).should('have.text', songTitle)
|
2021-01-02 11:58:46 +00:00
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
;[
|
|
|
|
{ name: 'one song', songCount: 1 },
|
|
|
|
{ name: 'several songs', songCount: 2 }
|
|
|
|
].forEach((config) => {
|
2021-01-02 22:19:33 +00:00
|
|
|
it(`adds ${config.name} into a simple playlist`, () => {
|
2021-05-23 11:42:18 +00:00
|
|
|
cy.intercept('/api/playlist/1/songs', {
|
2021-01-02 11:58:46 +00:00
|
|
|
fixture: 'playlist-songs.get.200.json'
|
|
|
|
})
|
|
|
|
|
|
|
|
cy.intercept('PUT', '/api/playlist/1/sync', {})
|
|
|
|
|
2021-01-03 15:21:36 +00:00
|
|
|
cy.$login()
|
|
|
|
cy.$clickSidebarItem('All Songs')
|
|
|
|
|
2021-01-02 11:58:46 +00:00
|
|
|
cy.$assertPlaylistSongCount('Simple Playlist', 3)
|
|
|
|
cy.get('#songsWrapper').within(() => {
|
|
|
|
if (config.songCount > 1) {
|
2022-04-27 21:43:00 +00:00
|
|
|
cy.$selectSongRange(0, config.songCount - 1).rightclick()
|
2021-01-02 15:22:31 +00:00
|
|
|
} else {
|
2022-04-26 09:46:31 +00:00
|
|
|
cy.get('.song-item:first-child').rightclick()
|
2021-01-02 11:58:46 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
cy.findByTestId('song-context-menu')
|
|
|
|
.within(() => {
|
|
|
|
cy.findByText('Add To').click()
|
|
|
|
cy.findByText('Simple Playlist').click()
|
|
|
|
})
|
|
|
|
|
|
|
|
cy.$assertPlaylistSongCount('Simple Playlist', 3 + config.songCount)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
it('does not have smart playlists as target for adding songs', () => {
|
2021-01-03 15:21:36 +00:00
|
|
|
cy.$login()
|
|
|
|
cy.$clickSidebarItem('All Songs')
|
2022-04-26 09:46:31 +00:00
|
|
|
cy.get('#songsWrapper').within(() => cy.get('.song-item:first-child').rightclick())
|
2021-01-02 11:58:46 +00:00
|
|
|
|
|
|
|
cy.findByTestId('song-context-menu')
|
|
|
|
.within(() => {
|
|
|
|
cy.findByText('Add To').click()
|
|
|
|
cy.findByText('Smart Playlist').should('not.exist')
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
it('adds a favorite song from context menu', () => {
|
2021-05-23 12:32:38 +00:00
|
|
|
cy.intercept('POST', '/api/interaction/batch/like', {
|
|
|
|
fixture: 'batch-like.post.200.json'
|
2021-01-02 11:58:46 +00:00
|
|
|
})
|
|
|
|
|
2021-01-03 15:21:36 +00:00
|
|
|
cy.$login()
|
|
|
|
cy.$clickSidebarItem('All Songs')
|
2021-01-02 11:58:46 +00:00
|
|
|
cy.$assertFavoriteSongCount(3)
|
|
|
|
|
2022-04-26 09:46:31 +00:00
|
|
|
cy.get('#songsWrapper').within(() => cy.get('.song-item:first-child').rightclick())
|
2021-01-02 11:58:46 +00:00
|
|
|
cy.findByTestId('song-context-menu').within(() => {
|
|
|
|
cy.findByText('Add To').click()
|
|
|
|
cy.findByText('Favorites').click()
|
|
|
|
})
|
|
|
|
|
|
|
|
cy.$assertFavoriteSongCount(4)
|
|
|
|
})
|
|
|
|
|
2021-01-02 12:40:40 +00:00
|
|
|
it('initiates editing a song', () => {
|
2021-05-23 11:42:18 +00:00
|
|
|
cy.intercept('/api/**/info', {
|
2022-04-26 09:46:31 +00:00
|
|
|
fixture: 'song-info.get.200.json'
|
2021-01-02 11:58:46 +00:00
|
|
|
})
|
|
|
|
|
2022-04-26 09:46:31 +00:00
|
|
|
cy.get('#songsWrapper').within(() => cy.get('.song-item:first-child').rightclick())
|
2021-01-02 11:58:46 +00:00
|
|
|
cy.findByTestId('song-context-menu').within(() => cy.findByText('Edit').click())
|
|
|
|
cy.findByTestId('edit-song-form').should('be.visible')
|
|
|
|
})
|
2021-01-02 14:13:26 +00:00
|
|
|
|
|
|
|
it('downloads a song', () => {
|
2021-05-23 11:42:18 +00:00
|
|
|
cy.intercept('/download/songs?*').as('download')
|
2021-01-02 14:13:26 +00:00
|
|
|
|
2021-01-03 15:21:36 +00:00
|
|
|
cy.$login()
|
|
|
|
cy.$clickSidebarItem('All Songs')
|
|
|
|
|
2022-04-26 09:46:31 +00:00
|
|
|
cy.get('#songsWrapper').within(() => cy.get('.song-item:first-child').rightclick())
|
2021-01-02 14:13:26 +00:00
|
|
|
cy.findByTestId('song-context-menu').within(() => cy.findByText('Download').click())
|
|
|
|
|
|
|
|
cy.wait('@download')
|
|
|
|
})
|
|
|
|
|
2021-01-03 15:21:36 +00:00
|
|
|
it('does not have a Download item if download is not allowed', () => {
|
|
|
|
cy.$login({ allowDownload: false })
|
|
|
|
cy.$clickSidebarItem('All Songs')
|
|
|
|
|
2022-04-26 09:46:31 +00:00
|
|
|
cy.get('#songsWrapper').within(() => cy.get('.song-item:first-child').rightclick())
|
2021-01-03 15:21:36 +00:00
|
|
|
cy.findByTestId('song-context-menu').within(() => cy.findByText('Download').should('not.exist'))
|
|
|
|
})
|
|
|
|
|
2021-01-04 23:29:54 +00:00
|
|
|
it('does not have an Edit item if user is not an admin', () => {
|
2021-01-03 15:21:36 +00:00
|
|
|
cy.$loginAsNonAdmin()
|
|
|
|
cy.$clickSidebarItem('All Songs')
|
|
|
|
|
2022-04-26 09:46:31 +00:00
|
|
|
cy.get('#songsWrapper').within(() => cy.get('.song-item:first-child').rightclick())
|
2021-01-03 15:21:36 +00:00
|
|
|
cy.findByTestId('song-context-menu').within(() => cy.findByText('Edit').should('not.exist'))
|
|
|
|
})
|
|
|
|
|
2022-04-25 16:38:33 +00:00
|
|
|
it('copies a song\'s URL', () => {
|
2021-01-03 15:21:36 +00:00
|
|
|
cy.$login()
|
|
|
|
cy.$clickSidebarItem('All Songs')
|
|
|
|
|
2022-04-25 16:38:33 +00:00
|
|
|
cy.window().then(window => cy.spy(window.document, 'execCommand').as('copy'))
|
2022-04-26 09:46:31 +00:00
|
|
|
cy.get('#songsWrapper').within(() => cy.get('.song-item:first-child').rightclick())
|
2021-01-02 14:13:26 +00:00
|
|
|
cy.findByTestId('song-context-menu').within(() => cy.findByText('Copy Shareable URL').click())
|
2022-04-25 16:38:33 +00:00
|
|
|
cy.get('@copy').should('be.calledWithExactly', 'copy')
|
2021-01-02 14:13:26 +00:00
|
|
|
})
|
2021-01-02 11:58:46 +00:00
|
|
|
})
|