koel/cypress/integration/favorites.spec.ts

84 lines
2.5 KiB
TypeScript
Raw Normal View History

context('Favorites', { scrollBehavior: false }, () => {
beforeEach(() => cy.$login())
2021-01-01 13:31:53 +00:00
2021-01-09 10:33:58 +00:00
it('loads the list of favorites', () => {
2021-01-01 13:31:53 +00:00
cy.$clickSidebarItem('Favorites')
cy.get('#favoritesWrapper')
.within(() => {
cy.findByText('Songs You Love').should('be.visible')
cy.findByText('Download All').should('be.visible')
2022-04-26 12:48:42 +00:00
2022-04-27 21:43:00 +00:00
cy.$getSongRows().should('have.length', 3)
.each(row => cy.wrap(row).findByTestId('btn-like-liked').should('be.visible'))
2021-01-01 13:31:53 +00:00
})
})
it('adds a favorite song from Like button', () => {
cy.intercept('POST', '/api/interaction/like', {
fixture: 'like.post.200.json'
})
cy.$clickSidebarItem('All Songs')
cy.get('#songsWrapper')
.within(() => {
2022-04-27 21:43:00 +00:00
cy.$getSongRows().first().within(() => {
cy.findByTestId('like-btn')
.within(() => cy.findByTestId('btn-like-unliked').should('be.visible')).click()
.within(() => cy.findByTestId('btn-like-liked').should('be.visible'))
2022-04-26 12:48:42 +00:00
})
2021-01-01 13:31:53 +00:00
})
cy.$assertFavoriteSongCount(4)
2021-01-01 13:31:53 +00:00
})
it('adds a favorite song from Add To dropdown', () => {
2021-05-23 12:32:38 +00:00
cy.intercept('POST', '/api/interaction/batch/like', {
fixture: 'batch-like.post.200.json'
2021-01-01 13:31:53 +00:00
})
cy.$clickSidebarItem('All Songs')
cy.get('#songsWrapper')
.within(() => {
2022-04-27 21:43:00 +00:00
cy.$getSongRows().first().click()
cy.findByTestId('add-to-btn').click()
cy.findByTestId('add-to-menu').should('be.visible')
2022-04-26 12:48:42 +00:00
.within(() => cy.findByText('Favorites').click()).should('not.be.visible')
2021-01-01 13:31:53 +00:00
})
cy.$assertFavoriteSongCount(4)
})
2021-01-01 13:31:53 +00:00
it('deletes a favorite with Unlike button', () => {
cy.intercept('POST', '/api/interaction/like', {})
cy.$clickSidebarItem('Favorites')
cy.get('#favoritesWrapper')
.within(() => {
2022-04-27 21:43:00 +00:00
cy.$getSongRows().should('have.length', 3)
2022-04-26 12:48:42 +00:00
.first().should('contain.text', 'November')
.within(() => cy.findByTestId('like-btn').click())
2021-01-01 13:31:53 +00:00
2022-04-27 21:43:00 +00:00
cy.$getSongRows().should('have.length', 2)
2022-04-26 12:48:42 +00:00
.first().should('not.contain.text', 'November')
2021-01-01 13:31:53 +00:00
})
})
it('deletes a favorite with Backspace key', () => {
cy.intercept('POST', '/api/interaction/like', {})
cy.$clickSidebarItem('Favorites')
cy.get('#favoritesWrapper')
.within(() => {
2022-04-27 21:43:00 +00:00
cy.$getSongRows().should('have.length', 3)
2022-04-26 12:48:42 +00:00
.first().should('contain.text', 'November')
.click().type('{backspace}')
2021-01-01 13:31:53 +00:00
2022-04-27 21:43:00 +00:00
cy.$getSongRows().should('have.length', 2)
2022-04-26 12:48:42 +00:00
.first().should('not.contain.text', 'November')
2021-01-01 13:31:53 +00:00
})
})
})