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(() => {
|
|
|
|
cy.get('tr.song-item:first-child').dblclick()
|
|
|
|
cy.get('tr.song-item:first-child').should('have.class', 'playing')
|
|
|
|
})
|
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(() => {
|
|
|
|
cy.get('tr.song-item:first-child')
|
|
|
|
.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
|
|
|
})
|
|
|
|
|
|
|
|
it('goes to album', () => {
|
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(() => cy.get('tr.song-item:first-child').rightclick())
|
|
|
|
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')
|
|
|
|
cy.get('tr.song-item').should('have.length.at.least', 1)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
it('goes to artist', () => {
|
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(() => cy.get('tr.song-item:first-child').rightclick())
|
|
|
|
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')
|
|
|
|
cy.get('tr.song-item').should('have.length.at.least', 1)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
;([
|
|
|
|
{ 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-02 11:58:46 +00:00
|
|
|
cy.$queueSeveralSongs()
|
|
|
|
cy.$clickSidebarItem('All Songs')
|
|
|
|
|
|
|
|
let songTitle
|
|
|
|
cy.get('#songsWrapper').within(() => {
|
|
|
|
cy.get('tr.song-item:nth-child(4) .title')
|
|
|
|
.invoke('text')
|
|
|
|
.then(text => {
|
|
|
|
songTitle = text
|
|
|
|
})
|
|
|
|
|
|
|
|
cy.get('tr.song-item:nth-child(4)').rightclick()
|
|
|
|
})
|
|
|
|
|
|
|
|
cy.findByTestId('song-context-menu').within(() => {
|
|
|
|
cy.findByText('Add To').click()
|
|
|
|
cy.findByText(config.menuItem).click()
|
|
|
|
})
|
|
|
|
|
|
|
|
cy.$clickSidebarItem('Current Queue')
|
|
|
|
cy.get('#queueWrapper').within(() => {
|
|
|
|
cy.get('tr.song-item').should('have.length', 4)
|
|
|
|
cy.get(`tr.song-item:nth-child(${config.queuedPosition}) .title`).should('have.text', songTitle)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
;[
|
|
|
|
{ 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-01-02 11:58:46 +00:00
|
|
|
cy.intercept('GET', '/api/playlist/1/songs', {
|
|
|
|
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) {
|
2021-01-02 15:22:31 +00:00
|
|
|
cy.$selectSongRange(1, config.songCount).rightclick()
|
|
|
|
} else {
|
|
|
|
cy.get('tr.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')
|
2021-01-02 11:58:46 +00:00
|
|
|
cy.get('#songsWrapper').within(() => cy.get('tr.song-item:first-child').rightclick())
|
|
|
|
|
|
|
|
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', () => {
|
|
|
|
cy.intercept('POST', '/api/interaction/like', {
|
|
|
|
fixture: 'like.post.200.json'
|
|
|
|
})
|
|
|
|
|
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)
|
|
|
|
|
|
|
|
cy.get('#songsWrapper').within(() => cy.get('tr.song-item:first-child').rightclick())
|
|
|
|
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-01-02 11:58:46 +00:00
|
|
|
cy.intercept('GET', '/api/**/info', {
|
|
|
|
fixture: 'info.get.200.json'
|
|
|
|
})
|
|
|
|
|
|
|
|
cy.get('#songsWrapper').within(() => cy.get('tr.song-item:first-child').rightclick())
|
|
|
|
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', () => {
|
|
|
|
cy.intercept('/download/songs').as('download')
|
|
|
|
|
2021-01-03 15:21:36 +00:00
|
|
|
cy.$login()
|
|
|
|
cy.$clickSidebarItem('All Songs')
|
|
|
|
|
2021-01-02 14:13:26 +00:00
|
|
|
cy.get('#songsWrapper').within(() => cy.get('tr.song-item:first-child').rightclick())
|
|
|
|
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')
|
|
|
|
|
|
|
|
cy.get('#songsWrapper').within(() => cy.get('tr.song-item:first-child').rightclick())
|
|
|
|
cy.findByTestId('song-context-menu').within(() => cy.findByText('Download').should('not.exist'))
|
|
|
|
})
|
|
|
|
|
|
|
|
it.only('does not have an Edit item if user is not an admin', () => {
|
|
|
|
cy.$loginAsNonAdmin()
|
|
|
|
cy.$clickSidebarItem('All Songs')
|
|
|
|
|
|
|
|
cy.get('#songsWrapper').within(() => cy.get('tr.song-item:first-child').rightclick())
|
|
|
|
cy.findByTestId('song-context-menu').within(() => cy.findByText('Edit').should('not.exist'))
|
|
|
|
})
|
|
|
|
|
2021-01-02 14:13:26 +00:00
|
|
|
it("copies a song's URL", () => {
|
2021-01-03 15:21:36 +00:00
|
|
|
cy.$login()
|
|
|
|
cy.$clickSidebarItem('All Songs')
|
|
|
|
|
2021-01-02 14:13:26 +00:00
|
|
|
cy.window().then(window => cy.spy(window.document, 'execCommand').as('copy'));
|
|
|
|
cy.get('#songsWrapper').within(() => cy.get('tr.song-item:first-child').rightclick())
|
|
|
|
cy.findByTestId('song-context-menu').within(() => cy.findByText('Copy Shareable URL').click())
|
|
|
|
cy.get('@copy').should('be.calledWithExactly', 'copy');
|
|
|
|
})
|
2021-01-02 11:58:46 +00:00
|
|
|
})
|