feat(test): add e2e tests for YouTube

This commit is contained in:
Phan An 2021-01-03 16:55:41 +01:00
parent 457251242c
commit a9eefa5e29
5 changed files with 130 additions and 4 deletions

View file

@ -49,7 +49,7 @@
"etag": "rlsZALtflq8Sdba4Nia7uPC-l5k",
"id": {
"kind": "youtube#video",
"videoId": "L397TWLwrUU"
"videoId": "I03Hs6dwj7E"
},
"snippet": {
"publishedAt": "2009-11-24T13:38:04Z",
@ -83,7 +83,7 @@
"etag": "AwvO6Y5jkF0O-lDHehMYTy7Hims",
"id": {
"kind": "youtube#video",
"videoId": "AMfG3sMo34s"
"videoId": "cLgJQ8Zj3AA"
},
"snippet": {
"publishedAt": "2017-01-26T03:19:52Z",

View file

@ -0,0 +1,81 @@
{
"kind": "youtube#searchListResponse",
"etag": "onWmIRofIp1TZOvsf_4ol1evZlI",
"nextPageToken": "CBQQAA",
"prevPageToken": "CAoQAQ",
"regionCode": "DE",
"pageInfo": {
"totalResults": 1000000,
"resultsPerPage": 10
},
"items": [
{
"kind": "youtube#searchResult",
"etag": "rlsZALtflq8Sdba4Nia7uPC-l5k",
"id": {
"kind": "youtube#video",
"videoId": "L397TWLwrUU"
},
"snippet": {
"publishedAt": "2009-11-24T13:38:04Z",
"channelId": "UCStHqF-8YWv8x6SJcTFkEXA",
"title": "YouTube Video #3",
"description": "Description for YouTube Video #3",
"thumbnails": {
"default": {
"url": "http://localhost:8080/test/images/youtube-thumbnail.png",
"width": 120,
"height": 90
},
"medium": {
"url": "http://localhost:8080/test/images/youtube-thumbnail.png",
"width": 320,
"height": 180
},
"high": {
"url": "http://localhost:8080/test/images/youtube-thumbnail.png",
"width": 480,
"height": 360
}
},
"channelTitle": "SampleArtistVEVO",
"liveBroadcastContent": "none",
"publishTime": "2009-11-24T13:38:04Z"
}
},
{
"kind": "youtube#searchResult",
"etag": "AwvO6Y5jkF0O-lDHehMYTy7Hims",
"id": {
"kind": "youtube#video",
"videoId": "AMfG3sMo34s"
},
"snippet": {
"publishedAt": "2017-01-26T03:19:52Z",
"channelId": "UCy6-RHgm74I8CCCvMu4NPJQ",
"title": "YouTube Video #4",
"description": "Description for YouTube Video #4",
"thumbnails": {
"default": {
"url": "http://localhost:8080/test/images/youtube-thumbnail.png",
"width": 120,
"height": 90
},
"medium": {
"url": "http://localhost:8080/test/images/youtube-thumbnail.png",
"width": 320,
"height": 180
},
"high": {
"url": "http://localhost:8080/test/images/youtube-thumbnail.png",
"width": 480,
"height": 360
}
},
"channelTitle": "Sample Artist - Topic",
"liveBroadcastContent": "none",
"publishTime": "2017-01-26T03:19:52Z"
}
}
]
}

View file

@ -42,7 +42,7 @@ context('Sidebar Functionalities', () => {
it.only('does not have a YouTube item if YouTube is not used', () => {
cy.$login({ useYouTube: false })
cy.get('#sidebar')
.findByText('YouTube')
.findByText('YouTube Video')
.should('not.exist')
})
})

View file

@ -0,0 +1,45 @@
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()
cy.intercept('GET', '/api/youtube/search/song/**', {
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')
cy.$assertMenuItemActive('YouTube Video')
cy.get('#youtubeWrapper .screen-header').should('contain', 'YouTube Video #2')
})
})

@ -1 +1 @@
Subproject commit 9826b4f372a1c6190ba087680853c36d55e8aef6
Subproject commit 4a5caa18d1d087094e7f2c29c8c7f0ba71bbef6d