mirror of
https://github.com/koel/koel
synced 2024-11-28 06:50:27 +00:00
feat(test): add e2e tests for Home
This commit is contained in:
parent
9740bf8d12
commit
dc180064be
5 changed files with 39 additions and 5 deletions
|
@ -1,5 +1,3 @@
|
|||
/// <reference types="cypress" />
|
||||
|
||||
context('Authentication', () => {
|
||||
const submitLoginForm = () => {
|
||||
cy.get('[type=email]').type('admin@koel.test')
|
||||
|
@ -35,7 +33,7 @@ context('Authentication', () => {
|
|||
|
||||
it('logs out', () => {
|
||||
cy.intercept('DELETE', '/api/me', {})
|
||||
cy.$login('/')
|
||||
cy.$login()
|
||||
cy.findByTestId('btn-logout').click()
|
||||
cy.findByTestId('login-form').should('be.visible')
|
||||
})
|
||||
|
|
31
cypress/integration/home.spec.ts
Normal file
31
cypress/integration/home.spec.ts
Normal file
|
@ -0,0 +1,31 @@
|
|||
context('Home Screen', () => {
|
||||
beforeEach(() => {
|
||||
cy.clock()
|
||||
cy.$login()
|
||||
cy.tick(1)
|
||||
})
|
||||
|
||||
it('renders', () => {
|
||||
cy.get('.screen-header').should('be.visible')
|
||||
cy.$each([
|
||||
['.top-song-list', 7],
|
||||
['.recent-song-list', 7],
|
||||
['.recently-added-album-list', 6],
|
||||
['.recently-added-song-list', 10],
|
||||
['.top-artist-list', 1],
|
||||
['.top-album-list', 6]
|
||||
], (selector: string, itemCount: number) => {
|
||||
cy.get(selector)
|
||||
.should('exist')
|
||||
.find('li')
|
||||
.should('have.length', itemCount)
|
||||
})
|
||||
})
|
||||
|
||||
it('has a link to view all recently-played songs', () => {
|
||||
cy.findByTestId('home-view-all-recently-played-btn')
|
||||
.click()
|
||||
.url()
|
||||
.should('contain', '/#!/recently-played')
|
||||
})
|
||||
})
|
|
@ -11,3 +11,7 @@ Cypress.Commands.add('$login', (redirectTo = '/'): Chainable<AUTWindow> => {
|
|||
|
||||
return cy.visit(redirectTo)
|
||||
})
|
||||
|
||||
Cypress.Commands.add('$each', (dataset: Array<Array<any>>, callback: Function) => {
|
||||
dataset.forEach(args => callback(...args))
|
||||
})
|
||||
|
|
3
cypress/types.d.ts
vendored
3
cypress/types.d.ts
vendored
|
@ -2,6 +2,7 @@
|
|||
|
||||
declare namespace Cypress {
|
||||
interface Chainable {
|
||||
$login(redirectTo: string): Chainable
|
||||
$login(redirectTo?: string): Chainable
|
||||
$each(dataset: Array<Array<any>>, callback: Function): void
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 9571bb50bb9cb15e943a7586e505d53247b298b5
|
||||
Subproject commit d8a122ab08535b920616f098838a7139adb7e2e9
|
Loading…
Reference in a new issue