feat(test): add a command to assert menu item is active

This commit is contained in:
Phan An 2021-01-03 16:54:06 +01:00
parent d56a69c449
commit 457251242c
3 changed files with 8 additions and 4 deletions

View file

@ -232,10 +232,7 @@ context('Playlists', () => {
.should('be.visible')
.and('contain', 'My Smart Playlist')
cy.get('#sidebar')
.findByText('My Smart Playlist')
.should('have.class', 'active')
cy.$assertMenuItemActive('My Smart Playlist')
cy.$assertPlaylistSongCount('My Smart Playlist', 3)
})

View file

@ -112,3 +112,9 @@ Cypress.Commands.add('$assertNotPlaying', () => {
cy.findByTestId('play-btn').should('exist')
cy.findByTestId('sound-bar-play').should('not.exist')
})
Cypress.Commands.add('$assertMenuItemActive', (text: string) => {
cy.get('#sidebar')
.findByText(text)
.should('have.class', 'active')
})

1
cypress/types.d.ts vendored
View file

@ -31,6 +31,7 @@ declare namespace Cypress {
$selectSongRange(start: number, end: number, scrollBehavior?: scrollBehaviorOptions): Chainable<JQuery>
$assertPlaying(): void
$assertNotPlaying(): void
$assertMenuItemActive(text: string): void
/**
* Support finding an element within an element identified with a test ID.