Files
schedule-planner/frontend/cypress/support/e2e.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

32 lines
1.1 KiB
JavaScript

// Ignore uncaught exceptions from the Vue app during E2E tests.
Cypress.on('uncaught:exception', () => false)
// Login as planner user by injecting session into localStorage
Cypress.Commands.add('loginAsPlanner', (password = '123456') => {
// Hash the password and call login API
cy.window().then(async (win) => {
const buf = await win.crypto.subtle.digest('SHA-256', new TextEncoder().encode(password))
const hash = Array.from(new Uint8Array(buf)).map(b => b.toString(16).padStart(2, '0')).join('')
cy.request('POST', '/api/login', { hash }).then(() => {
win.localStorage.setItem('sp_login_expires', String(Date.now() + 7 * 86400000))
})
})
})
// Inject planner login session directly (skip API call)
Cypress.Commands.add('injectSession', () => {
cy.window().then(win => {
win.localStorage.setItem('sp_login_expires', String(Date.now() + 7 * 86400000))
})
})
// Navigate via tab button
Cypress.Commands.add('goToTab', (label) => {
cy.get('.tab-btn').contains(label).click()
})
// Verify toast message appears
Cypress.Commands.add('expectToast', (text) => {
cy.get('.toast').should('contain', text)
})