feat(test): add edit song e2e tests

This commit is contained in:
Phan An 2021-01-02 15:33:32 +01:00
parent 1dea8cd522
commit a83dcfb477
2 changed files with 71 additions and 2 deletions

View file

@ -0,0 +1,32 @@
{
"artists": [
{
"id": 3,
"name": "The Band",
"image": "http://localhost:8088/test/images/sample.png"
}
],
"albums": [
{
"id": 3,
"artist_id": 5,
"name": "The Wall",
"cover": "http://localhost:8088/test/images/sample.png",
"created_at": "2016-02-01 06:48:45",
"is_compilation": false
}
],
"songs": [
{
"id": "03bebf17f54e2afc7c0513fb1d931009",
"album_id": 5,
"artist_id": 3,
"title": "New Title",
"length": 204.11,
"track": null,
"disc": 1,
"created_at": "2019-08-24 18:03:35",
"lyrics": "New lyrics<br />Supports multiline."
}
]
}

View file

@ -1,3 +1,40 @@
context.skip('Song Editing', () => {
// @todo Write tests for song editing
context('Song Editing', () => {
beforeEach(() => {
cy.intercept('GET', '/api/**/info', {
fixture: 'info.get.200.json'
})
cy.$login()
cy.$clickSidebarItem('All Songs')
cy.get('#songsWrapper').within(() => cy.get('tr.song-item:first-child').rightclick())
cy.findByTestId('song-context-menu').within(() => cy.findByText('Edit').click())
})
it('edits a song', () => {
cy.intercept('PUT', '/api/songs', {
fixture: 'songs.put.200.json'
})
cy.findByTestId('edit-song-form').within(() => {
cy.get('[name=title]').clear().type('New Title')
cy.findByTestId('edit-song-lyrics-tab').click()
cy.get('textarea[name=lyrics]')
.should('be.visible')
.and('contain.value', 'Sample song lyrics')
.clear()
.type('New lyrics{enter}Supports multiline.')
cy.get('button[type=submit]').click()
})
cy.findByText('Updated 1 song.').should('be.visible')
cy.findByTestId('edit-song-form').should('not.exist')
cy.get('#songsWrapper tr.song-item:first-child .title').should('have.text', 'New Title')
})
it('edits a song', () => {
cy.$findInTestId('edit-song-form .btn-cancel').click()
cy.findByTestId('edit-song-form').should('not.exist')
})
})