test public and protected routes

This commit is contained in:
Yisroel Baum 2026-07-31 09:51:12 +03:00
parent 4e3d8f74b8
commit edcaf80b98
Signed by: yisroelbaum
GPG key ID: 0FA60884F75520A9
2 changed files with 12 additions and 1 deletions

View file

@ -3,6 +3,7 @@ import { defineConfig } from 'cypress'
const frontendPort = process.env.VITE_PORT ?? '5173' const frontendPort = process.env.VITE_PORT ?? '5173'
export default defineConfig({ export default defineConfig({
allowCypressEnv: false,
e2e: { e2e: {
baseUrl: `http://127.0.0.1:${frontendPort}`, baseUrl: `http://127.0.0.1:${frontendPort}`,
supportFile: false, supportFile: false,

View file

@ -1,8 +1,18 @@
describe('guest authentication pages', () => { describe('guest authentication pages', () => {
it('redirects the root route to login', () => { it('shows a public home route to guests', () => {
cy.visit('/') cy.visit('/')
cy.location('pathname').should('equal', '/')
cy.get('h1').should('have.text', 'Make big goals feel possible.')
cy.contains('a', 'Log in').should('have.attr', 'href', '/login')
cy.contains('a', 'Get started').should('have.attr', 'href', '/signup')
})
it('redirects guests away from the protected dashboard', () => {
cy.visit('/dashboard')
cy.location('pathname').should('equal', '/login') cy.location('pathname').should('equal', '/login')
cy.location('search').should('include', 'redirect=/dashboard')
}) })
it('shows the login form and links to signup', () => { it('shows the login form and links to signup', () => {