feat(test): add e2e tests for albums

This commit is contained in:
Phan An 2021-01-03 12:02:02 +01:00
parent 963dfa6f45
commit e9c9fafc3a
4 changed files with 125 additions and 6 deletions

View file

@ -0,0 +1,31 @@
{
"url": "https://www.last.fm/music/The+Band/Abstract",
"image": "http://localhost:8080/test/images/sample.png",
"wiki": {
"summary": "Album summary",
"full": "Album full wiki"
},
"tracks": [
{
"title": "Memories",
"length": 156,
"url": "https://www.last.fm/music/The+Band/Memories"
},
{
"title": "Ofelia's Dream",
"length": 247,
"url": "https://www.last.fm/music/The+Band/Ofelia's+Dream"
},
{
"title": "November",
"length": 237,
"url": "https://www.last.fm/music/The+Band/November"
},
{
"title": "Extra Song",
"length": 237,
"url": "https://www.last.fm/music/The+Band/Extra+Song"
}
],
"cover": "http://localhost:8080/test/images/sample.png"
}

View file

@ -1,7 +1,7 @@
{
"lyrics": "Sample song lyrics",
"album_info": {
"url": "https://www.last.fm/music/Sample+Artist/Sample+Album",
"url": "https://www.last.fm/music/The+Band/Sample+Album",
"image": "http://localhost:8080/test/images/sample.png",
"wiki": {
"summary": "Album summary",
@ -11,23 +11,23 @@
{
"title": "Album track #1",
"length": 156,
"url": "https://www.last.fm/music/Sample-Artist/Album+track+1"
"url": "https://www.last.fm/music/The+Band/Album+track+1"
},
{
"title": "Album track #2",
"length": 247,
"url": "https://www.last.fm/music/Sample+Artist/Album+track+2"
"url": "https://www.last.fm/music/The+Band/Album+track+2"
},
{
"title": "Album track #3",
"length": 237,
"url": "https://www.last.fm/music/Sample+Artist/Album+track+3"
"url": "https://www.last.fm/music/The+Band/Album+track+3"
}
],
"cover": "http://localhost:8080/test/images/sample.png"
},
"artist_info": {
"url": "https://www.last.fm/music/Sample+Artist",
"url": "https://www.last.fm/music/The+Band",
"image": "http://localhost:8080/test/images/sample.png",
"bio": {
"summary": "Artist summary",

View file

@ -0,0 +1,88 @@
context('Albums', { scrollBehavior: false }, () => {
beforeEach(() => {
cy.$login()
cy.$clickSidebarItem('Albums')
})
it('loads the list of albums', () => {
cy.get('#albumsWrapper').within(() => {
cy.get('.screen-header')
.should('be.visible')
.and('contain.text', 'Albums')
cy.get('[data-test=view-mode-thumbnail]')
.should('be.visible')
.and('have.class', 'active')
cy.get('[data-test=view-mode-list]')
.should('be.visible')
.and('not.have.class', 'active')
cy.get('[data-test=album-card]').should('have.length', 7)
})
})
it('changes display mode', () => {
cy.get('#albumsWrapper').should('be.visible').within(() => {
cy.get('[data-test=album-card]').should('have.length', 7)
cy.get('[data-test=view-mode-list]').click()
cy.get('[data-test=album-card].compact').should('have.length', 7)
cy.get('[data-test=view-mode-thumbnail]').click()
cy.get('[data-test=album-card].full').should('have.length', 7)
})
})
it('plays all song in an album', () => {
cy.$mockPlayback()
cy.get('#albumsWrapper').within(() => {
cy.get('[data-test=album-card]:first-child .control-play')
.invoke('show')
.click()
})
cy.url().should('contain', '/#!/queue')
cy.$assertPlaying()
})
it('goes to album', () => {
cy.intercept('GET', '/api/album/8/info', {
fixture: 'album-info.get.200.json'
})
cy.get('#albumsWrapper').within(() => {
cy.get('[data-test=album-card]:first-child .name').click()
})
cy.get('#albumWrapper').within(() => {
cy.get('tr.song-item').should('have.length.at.least', 1)
cy.get('.screen-header').within(() => {
cy.findByText('Download All').should('be.visible')
cy.findByText('Info').click()
})
cy.get('[data-test=album-info]').should('be.visible').within(() => {
cy.findByText('Album full wiki').should('be.visible')
cy.get('.cover').should('be.visible')
cy.get('[data-test=album-info-tracks]').should('be.visible').within(() => {
// out of 4 tracks, 3 are already available in Koel. The last one has a link to iTunes.
cy.get('li').should('have.length', 4)
cy.get('li.available').should('have.length', 3)
cy.get('li:last-child a.view-on-itunes').should('be.visible')
})
})
cy.get('[data-test=close-modal-btn]').click()
cy.get('[data-test=album-info]').should('not.exist')
})
})
it('goes to artist', () => {
cy.get('#albumsWrapper').within(() => {
cy.get('[data-test=album-card]:first-child .artist').click()
cy.url().should('contain', '/#!/artist/3')
// rest of the assertions belong to the Artist spec
})
})
})

@ -1 +1 @@
Subproject commit ba0a66ce0a2160ee1e829d981b18937dcf4bb82d
Subproject commit e0486fabc1119886ec8df6cad5863d20c4231e09