mirror of
https://github.com/koel/koel
synced 2024-11-10 14:44:13 +00:00
feat(test): add e2e tests for Profile
This commit is contained in:
parent
6335230f4b
commit
2235063e93
2 changed files with 105 additions and 1 deletions
104
cypress/integration/profile.spec.ts
Normal file
104
cypress/integration/profile.spec.ts
Normal file
|
@ -0,0 +1,104 @@
|
|||
context('Profiles & Preferences', () => {
|
||||
it('shows the current user\'s profile', () => {
|
||||
cy.$login()
|
||||
cy.findByTestId('view-profile-link').click()
|
||||
cy.url().should('contain', '/#!/profile')
|
||||
|
||||
cy.get('#profileWrapper').within(() => {
|
||||
cy.get('.screen-header').should('contain.text', 'Profile & Preferences')
|
||||
cy.findByTestId('update-profile-form').should('be.visible')
|
||||
|
||||
;[
|
||||
'name',
|
||||
'email',
|
||||
'password',
|
||||
'confirm_password',
|
||||
'notify',
|
||||
'show_album_art_overlay',
|
||||
'transcode_on_mobile',
|
||||
'confirm_closing'
|
||||
].forEach(inputName => cy.get(`[name=${inputName}]`).should('exist'))
|
||||
|
||||
cy.findByTestId('lastfm-integrated').scrollIntoView().should('be.visible')
|
||||
cy.findByTestId('lastfm-not-integrated').should('not.exist')
|
||||
})
|
||||
})
|
||||
|
||||
it('shows instruction for Last.fm integration to admins', () => {
|
||||
cy.$login({ useLastfm: false })
|
||||
cy.findByTestId('view-profile-link').click()
|
||||
cy.findByTestId('lastfm-integrated').should('not.exist')
|
||||
cy.findByTestId('lastfm-not-integrated').scrollIntoView().should('be.visible')
|
||||
cy.findByTestId('lastfm-admin-instruction').should('be.visible')
|
||||
})
|
||||
|
||||
it('shows instruction for Last.fm integration to normal users', () => {
|
||||
cy.$loginAsNonAdmin({ useLastfm: false })
|
||||
cy.findByTestId('view-profile-link').click()
|
||||
cy.findByTestId('lastfm-integrated').should('not.exist')
|
||||
cy.findByTestId('lastfm-not-integrated').scrollIntoView().should('be.visible')
|
||||
cy.findByTestId('lastfm-user-instruction').should('be.visible')
|
||||
})
|
||||
|
||||
it('updates the user profile', () => {
|
||||
cy.intercept('PUT', '/api/me', {})
|
||||
cy.$login()
|
||||
cy.findByTestId('view-profile-link').click()
|
||||
|
||||
cy.get('#profileWrapper').within(() => {
|
||||
cy.get('[name=name]').clear().type('Admin No. 2')
|
||||
cy.get('[name=email]').clear().type('admin.2@koel.test')
|
||||
cy.get('[type=submit]').click()
|
||||
})
|
||||
|
||||
cy.findByText('Profile updated.').should('be.visible')
|
||||
cy.findByTestId('view-profile-link').should('contain.text', 'Admin No. 2')
|
||||
})
|
||||
|
||||
it('updates the user profile along with password', () => {
|
||||
cy.intercept('PUT', '/api/me', {})
|
||||
cy.$login()
|
||||
cy.findByTestId('view-profile-link').click()
|
||||
|
||||
cy.get('#profileWrapper').within(() => {
|
||||
cy.get('[name=name]').clear().type('Admin No. 2')
|
||||
cy.get('[name=email]').clear().type('admin.2@koel.test')
|
||||
cy.get('[name=password]').type('new-password')
|
||||
cy.get('[name=confirm_password]').type('new-password')
|
||||
cy.get('[type=submit]').click()
|
||||
})
|
||||
|
||||
cy.findByText('Profile updated.').should('be.visible')
|
||||
cy.findByTestId('view-profile-link').should('contain.text', 'Admin No. 2')
|
||||
})
|
||||
|
||||
it('does not update the profile if password does not match', () => {
|
||||
cy.$login()
|
||||
cy.findByTestId('view-profile-link').click()
|
||||
|
||||
cy.get('#profileWrapper').within(() => {
|
||||
cy.get('[name=name]').clear().type('Admin No. 2')
|
||||
cy.get('[name=email]').clear().type('admin.2@koel.test')
|
||||
cy.get('[name=password]').as('password').type('new-password')
|
||||
cy.get('[name=confirm_password]').as('confirmPassword').type('not-matching-password')
|
||||
cy.get('[type=submit]').click()
|
||||
cy.get('@password').should('have.class', 'error')
|
||||
cy.get('@confirmPassword').should('have.class', 'error')
|
||||
cy.findByText('Profile updated.').should('not.exist')
|
||||
})
|
||||
})
|
||||
|
||||
it('has an option to show/hide album art overlay', () => {
|
||||
cy.$login()
|
||||
cy.$mockPlayback()
|
||||
cy.$clickSidebarItem('Current Queue')
|
||||
cy.get('#queueWrapper').within(() => cy.findByText('shuffling all songs').click())
|
||||
cy.findByTestId('album-art-overlay').should('exist')
|
||||
|
||||
cy.findByTestId('view-profile-link').click()
|
||||
cy.get('#profileWrapper [name=show_album_art_overlay]').scrollIntoView().uncheck()
|
||||
cy.findByTestId('album-art-overlay').should('not.exist')
|
||||
cy.get('#profileWrapper [name=show_album_art_overlay]').scrollIntoView().check()
|
||||
cy.findByTestId('album-art-overlay').should('exist')
|
||||
})
|
||||
})
|
|
@ -1 +1 @@
|
|||
Subproject commit 68a91c872839cc73dc341b24d68c2b927fc6a911
|
||||
Subproject commit cb92152218670abe2aa16a80b8e248249b4b8a56
|
Loading…
Reference in a new issue