From 4e3d8f74b89ec95a6e6e63c126f4237ce50497a8 Mon Sep 17 00:00:00 2001 From: Yisroel Baum Date: Fri, 31 Jul 2026 09:46:39 +0300 Subject: [PATCH] test guest auth pages --- frontend/website/cypress.config.ts | 11 +++ frontend/website/cypress/e2e/guest-auth.cy.ts | 68 +++++++++++++++++++ frontend/website/package.json | 1 + 3 files changed, 80 insertions(+) create mode 100644 frontend/website/cypress.config.ts create mode 100644 frontend/website/cypress/e2e/guest-auth.cy.ts diff --git a/frontend/website/cypress.config.ts b/frontend/website/cypress.config.ts new file mode 100644 index 0000000..a99e605 --- /dev/null +++ b/frontend/website/cypress.config.ts @@ -0,0 +1,11 @@ +import { defineConfig } from 'cypress' + +const frontendPort = process.env.VITE_PORT ?? '5173' + +export default defineConfig({ + e2e: { + baseUrl: `http://127.0.0.1:${frontendPort}`, + supportFile: false, + }, + video: false, +}) diff --git a/frontend/website/cypress/e2e/guest-auth.cy.ts b/frontend/website/cypress/e2e/guest-auth.cy.ts new file mode 100644 index 0000000..e6ac7af --- /dev/null +++ b/frontend/website/cypress/e2e/guest-auth.cy.ts @@ -0,0 +1,68 @@ +describe('guest authentication pages', () => { + it('redirects the root route to login', () => { + cy.visit('/') + + cy.location('pathname').should('equal', '/login') + }) + + it('shows the login form and links to signup', () => { + cy.visit('/login') + + cy.get('h1').should('have.text', 'Welcome back') + cy.get('label[for="login-email"]').should('have.text', 'Email address') + cy.get('#login-email').should('have.attr', 'autocomplete', 'email') + cy.get('label[for="login-password"]').should('have.text', 'Password') + cy.get('#login-password').should('have.attr', 'autocomplete', 'current-password') + cy.get('button[type="submit"]').should('have.text', 'Log in') + + cy.contains('a', 'Create an account').click() + cy.location('pathname').should('equal', '/signup') + }) + + it('shows the signup form and links to login', () => { + cy.visit('/signup') + + cy.get('h1').should('have.text', 'Start your journey') + cy.get('label[for="signup-name"]').should('have.text', 'Full name') + cy.get('#signup-name').should('have.attr', 'autocomplete', 'name') + cy.get('label[for="signup-email"]').should('have.text', 'Email address') + cy.get('#signup-email').should('have.attr', 'autocomplete', 'email') + cy.get('label[for="signup-password"]').should('have.text', 'Password') + cy.get('#signup-password').should('have.attr', 'autocomplete', 'new-password') + cy.get('label[for="signup-password-confirmation"]').should( + 'have.text', + 'Confirm password', + ) + cy.get('#signup-password-confirmation').should( + 'have.attr', + 'autocomplete', + 'new-password', + ) + cy.get('button[type="submit"]').should('have.text', 'Create account') + + cy.contains('a', 'Log in').click() + cy.location('pathname').should('equal', '/login') + }) + + it('keeps UI-only form submissions on their current route', () => { + cy.visit('/login') + cy.get('form').submit() + cy.location('pathname').should('equal', '/login') + + cy.visit('/signup') + cy.get('form').submit() + cy.location('pathname').should('equal', '/signup') + }) + + it('fits the signup page within a mobile viewport', () => { + cy.viewport(390, 844) + cy.visit('/signup') + + cy.get('main').should('be.visible') + cy.document().then((document) => { + expect(document.documentElement.scrollWidth).to.be.at.most( + document.documentElement.clientWidth, + ) + }) + }) +}) diff --git a/frontend/website/package.json b/frontend/website/package.json index 5ba881d..ebd0942 100644 --- a/frontend/website/package.json +++ b/frontend/website/package.json @@ -9,6 +9,7 @@ "preview": "vite preview", "build-only": "vite build", "type-check": "vue-tsc --build", + "test:e2e": "cypress run", "lint": "run-s \"lint:*\"", "lint:oxlint": "oxlint . --fix", "lint:eslint": "eslint . --fix --cache",