Files
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

88 lines
2.5 KiB
JavaScript

describe('Favorites System', () => {
const ADMIN_TOKEN = 'c86ae7afbe10fabe3c1d5e1a7fee74feaadfd5dc7be2ab62'
describe('API Level', () => {
let firstRecipeId
before(() => {
cy.request('/api/recipes').then(res => {
firstRecipeId = res.body[0].id
})
})
it('can add a favorite via API', () => {
cy.request({
method: 'POST',
url: `/api/favorites/${firstRecipeId}`,
headers: { Authorization: `Bearer ${ADMIN_TOKEN}` },
body: {}
}).then(res => {
expect(res.status).to.be.oneOf([200, 201])
})
})
it('lists the favorite', () => {
cy.request({
url: '/api/favorites',
headers: { Authorization: `Bearer ${ADMIN_TOKEN}` }
}).then(res => {
expect(res.body).to.include(firstRecipeId)
})
})
it('can remove the favorite via API', () => {
cy.request({
method: 'DELETE',
url: `/api/favorites/${firstRecipeId}`,
headers: { Authorization: `Bearer ${ADMIN_TOKEN}` }
}).then(res => {
expect(res.status).to.eq(200)
})
})
it('favorite is removed from list', () => {
cy.request({
url: '/api/favorites',
headers: { Authorization: `Bearer ${ADMIN_TOKEN}` }
}).then(res => {
expect(res.body).to.not.include(firstRecipeId)
})
})
})
describe('UI Level', () => {
it('recipe cards have star buttons for logged-in users', () => {
cy.visit('/', {
onBeforeLoad(win) {
win.localStorage.setItem('oil_auth_token', ADMIN_TOKEN)
}
})
cy.get('.recipe-card', { timeout: 10000 }).should('have.length.gte', 1)
// Stars should be present on cards
cy.get('.recipe-card').first().within(() => {
cy.contains(/★|☆/).should('exist')
})
})
it('clicking star toggles favorite state', () => {
cy.visit('/', {
onBeforeLoad(win) {
win.localStorage.setItem('oil_auth_token', ADMIN_TOKEN)
}
})
cy.get('.recipe-card', { timeout: 10000 }).first().within(() => {
cy.contains(/★|☆/).then($star => {
const wasFav = $star.text().includes('★')
$star.trigger('click')
// Star text should have toggled
cy.wait(500)
cy.contains(/★|☆/).invoke('text').should(text => {
if (wasFav) expect(text).to.include('☆')
else expect(text).to.include('★')
})
})
})
})
})
})