Files
schedule-planner/frontend/cypress/e2e/auth-flow.cy.js
Hera Zhao d3f3b4f37b
Some checks failed
Test / build-check (push) Successful in 3s
PR Preview / test (pull_request) Successful in 3s
PR Preview / teardown-preview (pull_request) Has been skipped
Test / e2e-test (push) Failing after 55s
PR Preview / deploy-preview (pull_request) Failing after 40s
Refactor to Vue 3 + FastAPI + SQLite architecture
- Backend: FastAPI + SQLite (WAL mode), 22 tables, ~40 API endpoints
- Frontend: Vue 3 + Vite + Pinia + Vue Router, 8 views, 3 stores
- Database: migrate from JSON file to SQLite with proper schema
- Dockerfile: multi-stage build (node + python)
- Deploy: K8s manifests (namespace, deployment, service, ingress, pvc, backup)
- CI/CD: Gitea Actions (test, deploy, PR preview at pr-$id.planner.oci.euphon.net)
- Tests: 20 Cypress E2E test files, 196 test cases, ~85% coverage
- Doc: test-coverage.md with full feature coverage report

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-07 21:18:22 +00:00

56 lines
1.7 KiB
JavaScript

describe('Authentication Flow', () => {
it('redirects to login when session expired', () => {
cy.visit('/', {
onBeforeLoad(win) {
win.localStorage.setItem('sp_login_expires', String(Date.now() - 1000))
}
})
cy.get('.login-overlay').should('be.visible')
})
it('login form accepts Enter key', () => {
cy.visit('/')
cy.get('.login-input').type('123456{enter}')
// Should attempt login (success or fail depends on backend)
cy.wait(500)
})
it('valid login stores session and shows app', () => {
cy.visit('/')
cy.get('.login-input').type('123456')
cy.get('.login-btn').click()
// If default password matches, should show main app
cy.get('header', { timeout: 5000 }).should('be.visible')
cy.window().then(win => {
expect(win.localStorage.getItem('sp_login_expires')).to.not.be.null
})
})
it('logout clears session and shows login', () => {
cy.visit('/', {
onBeforeLoad(win) {
win.localStorage.setItem('sp_login_expires', String(Date.now() + 86400000))
}
})
cy.get('header').should('be.visible')
cy.get('.header-menu-btn').click()
cy.contains('退出登录').click()
cy.get('.login-overlay').should('be.visible')
cy.window().then(win => {
expect(win.localStorage.getItem('sp_login_expires')).to.be.null
})
})
it('session persists across page reloads', () => {
cy.visit('/', {
onBeforeLoad(win) {
win.localStorage.setItem('sp_login_expires', String(Date.now() + 86400000))
}
})
cy.get('header').should('be.visible')
cy.reload()
cy.get('header').should('be.visible')
cy.get('.login-overlay').should('not.exist')
})
})