koel/cypress/integration/albums.spec.ts

81 lines
2.7 KiB
TypeScript
Raw Normal View History

context.only('Albums', { scrollBehavior: false }, () => {
2021-01-03 11:02:02 +00:00
beforeEach(() => {
cy.$login()
cy.$clickSidebarItem('Albums')
})
it('loads the list of albums', () => {
cy.get('#albumsWrapper').within(() => {
2022-04-26 12:54:03 +00:00
cy.get('.screen-header').should('be.visible').and('contain.text', 'Albums')
cy.findByTestId('view-mode-thumbnail').should('be.visible').and('have.class', 'active')
cy.findByTestId('view-mode-list').should('be.visible').and('not.have.class', 'active')
2022-05-13 12:40:04 +00:00
cy.findAllByTestId('album-card').should('have.length', 7)
2021-01-03 11:02:02 +00:00
})
})
it('changes display mode', () => {
cy.get('#albumsWrapper').should('be.visible').within(() => {
2022-05-13 12:40:04 +00:00
cy.findAllByTestId('album-card').should('have.length', 7)
cy.findByTestId('view-mode-list').click()
cy.get('[data-testid=album-card].compact').should('have.length', 7)
cy.findByTestId('view-mode-thumbnail').click()
cy.get('[data-testid=album-card].full').should('have.length', 7)
2021-01-03 11:02:02 +00:00
})
})
2021-01-03 14:43:57 +00:00
it('plays all songs in an album', () => {
2021-01-03 11:02:02 +00:00
cy.$mockPlayback()
cy.get('#albumsWrapper').within(() => {
cy.get('[data-testid=album-card]:first-child .control-play')
2021-01-03 11:02:02 +00:00
.invoke('show')
.click()
})
cy.url().should('contain', '/#!/queue')
cy.$assertPlaying()
})
2021-01-04 23:04:02 +00:00
it('invokes album screen', () => {
2021-05-23 11:42:18 +00:00
cy.intercept('/api/album/8/info', {
2021-01-03 11:02:02 +00:00
fixture: 'album-info.get.200.json'
})
cy.get('#albumsWrapper').within(() => {
cy.get('[data-testid=album-card]:first-child .name').click()
2021-01-03 11:02:02 +00:00
})
cy.get('#albumWrapper').within(() => {
2022-04-27 21:43:00 +00:00
cy.$getSongRows().should('have.length.at.least', 1)
2021-01-03 11:02:02 +00:00
cy.get('.screen-header').within(() => {
cy.findByText('Download All').should('be.visible')
cy.findByText('Info').click()
})
2022-05-03 16:51:59 +00:00
cy.findByTestId('album-info').should('be.visible').within(() => {
2021-01-03 11:02:02 +00:00
cy.findByText('Album full wiki').should('be.visible')
cy.get('.cover').should('be.visible')
2022-05-03 16:51:59 +00:00
cy.findByTestId('album-info-tracks').should('be.visible').within(() => {
2022-05-13 12:40:04 +00:00
// out of 4 tracks, 3 are already available in Koel. The last one has a link to Apple Music.
2021-01-03 11:02:02 +00:00
cy.get('li').should('have.length', 4)
cy.get('li.available').should('have.length', 3)
2022-05-13 12:40:04 +00:00
cy.get('li:last-child a[title="Preview and buy this song on Apple Music"]').should('be.visible')
2021-01-03 11:02:02 +00:00
})
})
2022-05-03 16:51:59 +00:00
cy.findByTestId('close-modal-btn').click()
cy.findByTestId('album-info').should('not.exist')
2021-01-03 11:02:02 +00:00
})
})
2021-01-04 23:04:02 +00:00
it('invokes artist screen', () => {
2021-01-03 11:02:02 +00:00
cy.get('#albumsWrapper').within(() => {
cy.get('[data-testid=album-card]:first-child .artist').click()
2021-01-03 11:02:02 +00:00
cy.url().should('contain', '/#!/artist/3')
// rest of the assertions belong to the Artist spec
})
})
})