Files
oil-formula-calculator/frontend/cypress/support/e2e.js
Hera Zhao ee8ec23dc7 Refactor frontend to Vue 3 + Vite + Pinia + Cypress E2E
- Replace single-file 8441-line HTML with Vue 3 SPA
- Pinia stores: auth, oils, recipes, diary, ui
- Composables: useApi, useDialog, useSmartPaste, useOilTranslation
- 6 shared components: RecipeCard, RecipeDetailOverlay, TagPicker, etc.
- 9 page views: RecipeSearch, RecipeManager, Inventory, OilReference, etc.
- 14 Cypress E2E test specs (113 tests), all passing
- Multi-stage Dockerfile (Node build + Python runtime)
- Demo video generation scripts (TTS + subtitles + screen recording)

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

34 lines
921 B
JavaScript

// Ignore uncaught exceptions from the app (API errors during loading, etc.)
Cypress.on('uncaught:exception', () => false)
// Custom commands for the oil calculator app
// Login as admin via token injection
Cypress.Commands.add('loginAsAdmin', () => {
cy.request('GET', '/api/users').then((res) => {
const admin = res.body.find(u => u.role === 'admin')
if (admin) {
cy.window().then(win => {
win.localStorage.setItem('oil_auth_token', admin.token)
})
}
})
})
// Login with a specific token
Cypress.Commands.add('loginWithToken', (token) => {
cy.window().then(win => {
win.localStorage.setItem('oil_auth_token', token)
})
})
// Verify toast message appears
Cypress.Commands.add('expectToast', (text) => {
cy.get('.toast').should('contain', text)
})
// Navigate via nav tabs
Cypress.Commands.add('goToSection', (label) => {
cy.get('.nav-tab').contains(label).click()
})