koel/cypress/integration/shortcut-keys.spec.ts

48 lines
1.5 KiB
TypeScript
Raw Normal View History

context('Shortcut Keys', () => {
2022-04-27 22:00:08 +00:00
beforeEach(() => {
cy.$login()
cy.$mockPlayback()
})
it('focus into Search input when F is pressed', () => {
cy.get('body').type('f')
cy.get('#searchForm [name=q]').should('be.focused')
})
it('shuffles all songs by default when Space is pressed', () => {
cy.fixture('data.get.200.json').then(data => {
2022-04-27 22:00:08 +00:00
cy.get('body').type(' ', { force: true })
cy.$assertSidebarItemActive('Current Queue')
cy.$assertPlaying()
cy.get('#queueWrapper .screen-header').should('contain.text', `${data.songs.length} songs`)
})
})
it('toggles playback when Space is pressed', () => {
cy.$shuffleSeveralSongs()
cy.$assertPlaying()
cy.get('body').type(' ')
cy.$assertNotPlaying()
cy.get('body').type(' ')
cy.$assertPlaying()
})
it('moves back and forward when K and J are pressed', () => {
cy.$shuffleSeveralSongs()
cy.get('body').type('j')
2022-04-26 09:46:31 +00:00
cy.get('#queueWrapper .song-item:nth-child(2)').should('have.class', 'playing')
cy.get('body').type('k')
2022-04-26 09:46:31 +00:00
cy.get('#queueWrapper .song-item:nth-child(1)').should('have.class', 'playing')
cy.$assertPlaying()
})
it('toggles favorite when L is pressed', () => {
cy.intercept('POST', '/api/interaction/like', {})
cy.$shuffleSeveralSongs()
cy.get('body').type('l')
cy.get('#queueWrapper .song-item:first-child [data-testid=btn-like-liked]').should('be.visible')
cy.get('body').type('l')
cy.get('#queueWrapper .song-item:first-child [data-testid=btn-like-unliked]').should('be.visible')
})
})