39 lines
1.2 KiB
TypeScript
39 lines
1.2 KiB
TypeScript
describe('admin login page', () => {
|
|
it('renders the login form with email, password, and submit button', () => {
|
|
cy.visit('/login')
|
|
|
|
cy.get('[data-cy="login-email"]').should('be.visible')
|
|
cy.get('[data-cy="login-password"]').should('be.visible')
|
|
cy.get('[data-cy="login-submit"]').should('be.visible')
|
|
})
|
|
|
|
it('is not linked from the home page', () => {
|
|
cy.visit('/')
|
|
|
|
cy.contains('login').should('not.exist')
|
|
cy.contains('Login').should('not.exist')
|
|
cy.contains('admin').should('not.exist')
|
|
cy.contains('Admin').should('not.exist')
|
|
cy.get('a[href="/login"]').should('not.exist')
|
|
})
|
|
|
|
it('shows an error on failed login', () => {
|
|
cy.visit('/login')
|
|
|
|
cy.get('[data-cy="login-email"]').type('bad@example.com')
|
|
cy.get('[data-cy="login-password"]').type('wrongpassword')
|
|
cy.get('[data-cy="login-submit"]').click()
|
|
|
|
cy.get('[data-cy="login-error"]').should('be.visible')
|
|
})
|
|
|
|
it('redirects to home on successful login', () => {
|
|
cy.visit('/login')
|
|
|
|
cy.get('[data-cy="login-email"]').type('admin@example.com')
|
|
cy.get('[data-cy="login-password"]').type('password123')
|
|
cy.get('[data-cy="login-submit"]').click()
|
|
|
|
cy.url().should('eq', Cypress.config().baseUrl + '/')
|
|
})
|
|
})
|