2021-01-04 18:30:05 +00:00
|
|
|
context('Shortcut Keys', () => {
|
2022-04-27 22:00:08 +00:00
|
|
|
beforeEach(() => {
|
|
|
|
cy.$login()
|
|
|
|
cy.$mockPlayback()
|
|
|
|
})
|
2021-01-04 18:30:05 +00:00
|
|
|
|
|
|
|
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 })
|
2021-01-04 18:30:05 +00:00
|
|
|
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')
|
2021-01-04 18:30:05 +00:00
|
|
|
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')
|
2021-01-04 18:30:05 +00:00
|
|
|
cy.$assertPlaying()
|
|
|
|
})
|
|
|
|
|
|
|
|
it('toggles favorite when L is pressed', () => {
|
|
|
|
cy.intercept('POST', '/api/interaction/like', {})
|
|
|
|
cy.$shuffleSeveralSongs()
|
|
|
|
cy.get('body').type('l')
|
2022-05-09 13:04:24 +00:00
|
|
|
cy.get('#queueWrapper .song-item:first-child [data-testid=btn-like-liked]').should('be.visible')
|
2021-01-04 18:30:05 +00:00
|
|
|
cy.get('body').type('l')
|
2022-05-09 13:04:24 +00:00
|
|
|
cy.get('#queueWrapper .song-item:first-child [data-testid=btn-like-unliked]').should('be.visible')
|
2021-01-04 18:30:05 +00:00
|
|
|
})
|
|
|
|
})
|