Rewrite recipe search page to match original design
Some checks failed
PR Preview / teardown-preview (pull_request) Has been skipped
Test / unit-test (push) Successful in 5s
Test / build-check (push) Successful in 4s
Test / e2e-test (push) Has been cancelled
PR Preview / test (pull_request) Successful in 4s
PR Preview / deploy-preview (pull_request) Successful in 13s

- RecipeCard: simple card with name, tags, oil names, price (matching
  original .recipe-card style with hover translateY and warm shadows)
- RecipeDetailOverlay: inline panel (not modal) with editable ingredients
  table, add ingredient row, total cost bar, and card preview section
  matching the original detail-panel + #recipe-card-export layout
- RecipeSearch: simplified layout with search box and grid, detail panel
  appears inline below grid when a card is clicked
- Updated Cypress tests to match new component structure

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-06 22:38:35 +00:00
parent 9c85ed21b3
commit f884bff452
5 changed files with 640 additions and 1077 deletions

View File

@@ -4,8 +4,8 @@ describe('Price Display Regression', () => {
cy.get('.recipe-card', { timeout: 10000 }).should('have.length.gte', 1)
cy.wait(2000) // wait for oils store to load and re-render
// Check via .card-price elements which hold the formatted cost
cy.get('.card-price').first().invoke('text').then(text => {
// Check via .recipe-card-price elements which hold the formatted cost
cy.get('.recipe-card-price').first().invoke('text').then(text => {
const match = text.match(/¥\s*(\d+\.?\d*)/)
expect(match, 'Card price should contain ¥').to.not.be.null
expect(parseFloat(match[1]), 'Price should be > 0').to.be.gt(0)

View File

@@ -4,18 +4,16 @@ describe('Recipe Detail', () => {
cy.get('.recipe-card', { timeout: 10000 }).should('have.length.gte', 1)
})
it('opens detail overlay when clicking a recipe card', () => {
it('opens detail panel when clicking a recipe card', () => {
cy.get('.recipe-card').first().click()
cy.get('[class*="overlay"], [class*="detail"]').should('be.visible')
cy.get('[class*="detail"]').should('be.visible')
})
it('shows recipe name in detail view', () => {
// Get recipe name from card, however it's structured
cy.get('.recipe-card').first().invoke('text').then(cardText => {
cy.get('.recipe-card').first().click()
cy.wait(500)
// The detail view should show some text from the card
cy.get('[class*="overlay"], [class*="detail"]').should('be.visible')
cy.get('[class*="detail"]').should('be.visible')
})
})
@@ -31,24 +29,21 @@ describe('Recipe Detail', () => {
cy.contains('¥').should('exist')
})
it('closes detail overlay when clicking close button', () => {
it('closes detail panel when clicking close button', () => {
cy.get('.recipe-card').first().click()
cy.get('[class*="overlay"], [class*="detail"]').should('be.visible')
cy.get('button').contains(/✕|关闭|←/).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)
// Should have at least one action button
cy.get('[class*="overlay"] button, [class*="detail"] button').should('have.length.gte', 1)
cy.get('[class*="detail"] button').should('have.length.gte', 1)
})
it('shows favorite star', () => {
cy.get('.recipe-card').first().click()
cy.wait(500)
cy.contains(/★|☆|收藏/).should('exist')
it('shows favorite star on recipe cards', () => {
cy.get('.fav-btn').first().should('exist')
})
})
@@ -64,21 +59,21 @@ describe('Recipe Detail - Editor (Admin)', () => {
cy.get('.recipe-card', { timeout: 10000 }).should('have.length.gte', 1)
})
it('shows edit button for admin', () => {
it('shows editable ingredients table directly', () => {
cy.get('.recipe-card').first().click()
cy.wait(500)
cy.contains(/编辑|✏/).should('exist')
cy.get('.oil-select, .drops-input').should('exist')
})
it('can switch to editor view', () => {
it('shows add ingredient button', () => {
cy.get('.recipe-card').first().click()
cy.contains(/编辑|✏/).first().click()
cy.get('select, input[type="number"], .oil-select, .drops-input').should('exist')
cy.wait(500)
cy.contains('加精油').should('exist')
})
it('editor shows save button', () => {
it('shows export image button', () => {
cy.get('.recipe-card').first().click()
cy.contains(/编辑|✏/).first().click()
cy.contains(/保存|💾/).should('exist')
cy.wait(500)
cy.contains('导出图片').should('exist')
})
})