Files
oil-formula-calculator/frontend/cypress/e2e/recipe-detail.cy.js
Hera Zhao f89cfff20b
All checks were successful
PR Preview / teardown-preview (pull_request) Has been skipped
Test / unit-test (push) Successful in 6s
Test / build-check (push) Successful in 4s
PR Preview / test (pull_request) Successful in 5s
PR Preview / deploy-preview (pull_request) Successful in 18s
Test / e2e-test (push) Successful in 1m1s
Fix E2E tests to match restored modal overlay UI
The recipe detail was reverted to modal with tabs (卡片预览/编辑),
so tests now click the 编辑 tab before checking for editor elements.

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

82 lines
2.3 KiB
JavaScript

describe('Recipe Detail', () => {
beforeEach(() => {
cy.visit('/')
cy.get('.recipe-card', { timeout: 10000 }).should('have.length.gte', 1)
})
it('opens detail panel when clicking a recipe card', () => {
cy.get('.recipe-card').first().click()
cy.get('[class*="detail"]').should('be.visible')
})
it('shows recipe name in detail view', () => {
cy.get('.recipe-card').first().invoke('text').then(cardText => {
cy.get('.recipe-card').first().click()
cy.wait(500)
cy.get('[class*="detail"]').should('be.visible')
})
})
it('shows ingredient info with drops', () => {
cy.get('.recipe-card').first().click()
cy.wait(500)
cy.contains('滴').should('exist')
})
it('shows cost with ¥ symbol', () => {
cy.get('.recipe-card').first().click()
cy.wait(500)
cy.contains('¥').should('exist')
})
it('closes detail panel when clicking close button', () => {
cy.get('.recipe-card').first().click()
cy.get('[class*="detail"]').should('be.visible')
cy.get('button').contains(/✕|关闭/).first().click()
cy.get('.recipe-card').should('be.visible')
})
it('shows action buttons in detail', () => {
cy.get('.recipe-card').first().click()
cy.wait(500)
cy.get('[class*="detail"] button').should('have.length.gte', 1)
})
it('shows favorite star on recipe cards', () => {
cy.get('.fav-btn').first().should('exist')
})
})
describe('Recipe Detail - Editor (Admin)', () => {
const ADMIN_TOKEN = 'c86ae7afbe10fabe3c1d5e1a7fee74feaadfd5dc7be2ab62'
beforeEach(() => {
cy.visit('/', {
onBeforeLoad(win) {
win.localStorage.setItem('oil_auth_token', ADMIN_TOKEN)
}
})
cy.get('.recipe-card', { timeout: 10000 }).should('have.length.gte', 1)
})
it('shows editable ingredients table in editor tab', () => {
cy.get('.recipe-card').first().click()
cy.wait(500)
cy.contains('编辑').click()
cy.get('.editor-select, .editor-drops').should('exist')
})
it('shows add ingredient button in editor tab', () => {
cy.get('.recipe-card').first().click()
cy.wait(500)
cy.contains('编辑').click()
cy.contains('添加精油').should('exist')
})
it('shows export image button', () => {
cy.get('.recipe-card').first().click()
cy.wait(500)
cy.contains('导出图片').should('exist')
})
})