koel/cypress/integration/youtube.spec.ts

46 lines
1.4 KiB
TypeScript
Raw Normal View History

2021-01-03 15:55:41 +00:00
context('YouTube', () => {
beforeEach(() => cy.$login())
it('renders a placeholder screen', () => {
cy.$clickSidebarItem('YouTube Video')
cy.get('#youtubeWrapper').within(() => {
cy.get('.screen-header').should('contain.text', 'YouTube Video')
cy.findByTestId('youtube-placeholder').should('be.visible')
})
})
it('searches for videos when a song is played', () => {
cy.$mockPlayback()
2021-05-23 11:42:18 +00:00
cy.intercept('/api/youtube/search/song/**', {
2021-01-03 15:55:41 +00:00
fixture: 'youtube-search.get.200.json'
})
cy.$clickSidebarItem('All Songs')
cy.get('#songsWrapper tr.song-item:first-child').dblclick()
cy.get('#extra').within(() => {
cy.get('#extraTabYouTube').click()
cy.get('[data-test=youtube-search-result]').should('have.length', 2)
cy.findByTestId('youtube-search-more-btn').click()
cy.get('[data-test=youtube-search-result]').should('have.length', 4)
})
})
it('plays a video when a search result is clicked', () => {
cy.$mockPlayback()
cy.$clickSidebarItem('All Songs')
cy.get('#songsWrapper tr.song-item:first-child').dblclick()
cy.get('#extra').within(() => {
cy.get('#extraTabYouTube').click()
cy.get('[data-test=youtube-search-result]:nth-child(2)').click()
})
cy.url().should('contain', '/#!/youtube')
2021-01-03 16:24:35 +00:00
cy.$assertSidebarItemActive('YouTube Video')
2021-01-03 15:55:41 +00:00
cy.get('#youtubeWrapper .screen-header').should('contain', 'YouTube Video #2')
})
})