From cf5b974ae17e641e43935b01e0e9bca1781e34e3 Mon Sep 17 00:00:00 2001 From: Hera Zhao Date: Thu, 9 Apr 2026 19:06:22 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20rebase=20=E5=90=8E?= =?UTF-8?q?=E9=87=8D=E5=A4=8D=20clearBrandImage=20=E5=A3=B0=E6=98=8E=20+?= =?UTF-8?q?=20=E6=B5=8B=E8=AF=95=E5=8A=A0=20dismissDialog?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 删除 MyDiary.vue 重复的 clearBrandImage 函数(rebase 遗留) - 测试加 dismissDialog() 关闭 CI 中 API 错误弹出的 dialog Co-Authored-By: Claude Opus 4.6 (1M context) --- frontend/cypress/e2e/recipe-detail.cy.js | 33 +++++++++++++++++------- frontend/src/views/MyDiary.vue | 20 -------------- 2 files changed, 24 insertions(+), 29 deletions(-) diff --git a/frontend/cypress/e2e/recipe-detail.cy.js b/frontend/cypress/e2e/recipe-detail.cy.js index 9197291..235dab7 100644 --- a/frontend/cypress/e2e/recipe-detail.cy.js +++ b/frontend/cypress/e2e/recipe-detail.cy.js @@ -1,36 +1,47 @@ +// Helper: dismiss any CustomDialog that may appear (e.g. API errors in CI) +function dismissDialog() { + cy.get('body').then($body => { + if ($body.find('.dialog-overlay').length) { + cy.get('.dialog-btn-primary').click() + cy.get('.dialog-overlay').should('not.exist') + } + }) +} + describe('Recipe Detail', () => { beforeEach(() => { cy.visit('/') cy.get('.recipe-card', { timeout: 10000 }).should('have.length.gte', 1) + dismissDialog() }) it('opens detail panel when clicking a recipe card', () => { cy.get('.recipe-card').first().click() + dismissDialog() cy.get('.detail-overlay').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('.detail-overlay').should('be.visible') - }) + cy.get('.recipe-card').first().click() + dismissDialog() + cy.get('.detail-overlay').should('be.visible') }) it('shows ingredient info with drops', () => { cy.get('.recipe-card').first().click() - cy.wait(500) + dismissDialog() cy.contains('滴').should('exist') }) it('shows cost with ¥ symbol', () => { cy.get('.recipe-card').first().click() - cy.wait(500) + dismissDialog() cy.contains('¥').should('exist') }) it('closes detail panel when clicking close button', () => { cy.get('.recipe-card').first().click() + dismissDialog() cy.get('.detail-overlay').should('be.visible') cy.get('button').contains(/✕|关闭/).first().click() cy.get('.recipe-card').should('be.visible') @@ -38,8 +49,8 @@ describe('Recipe Detail', () => { 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) + dismissDialog() + cy.get('.detail-overlay button').should('have.length.gte', 1) }) it('shows favorite star on recipe cards', () => { @@ -57,10 +68,12 @@ describe('Recipe Detail - Editor (Admin)', () => { } }) cy.get('.recipe-card', { timeout: 10000 }).should('have.length.gte', 1) + dismissDialog() }) it('shows editable ingredients table in editor tab', () => { cy.get('.recipe-card').first().click() + dismissDialog() cy.get('.detail-overlay', { timeout: 5000 }).should('be.visible') cy.get('.detail-overlay').then($el => { if ($el.find(':contains("编辑")').filter('button').length) { @@ -74,6 +87,7 @@ describe('Recipe Detail - Editor (Admin)', () => { it('shows add ingredient button in editor tab', () => { cy.get('.recipe-card').first().click() + dismissDialog() cy.get('.detail-overlay', { timeout: 5000 }).should('be.visible') cy.get('.detail-overlay').then($el => { if ($el.find(':contains("编辑")').filter('button').length) { @@ -87,6 +101,7 @@ describe('Recipe Detail - Editor (Admin)', () => { it('shows save image button', () => { cy.get('.recipe-card').first().click() + dismissDialog() cy.get('.detail-overlay', { timeout: 5000 }).should('be.visible') cy.contains('保存图片').should('exist') }) diff --git a/frontend/src/views/MyDiary.vue b/frontend/src/views/MyDiary.vue index 94baee7..fda3760 100644 --- a/frontend/src/views/MyDiary.vue +++ b/frontend/src/views/MyDiary.vue @@ -574,26 +574,6 @@ async function clearBrandImage(type) { } } -async function clearBrandImage(type) { - const fieldMap = { logo: 'brand_logo', bg: 'brand_bg', qr: 'qr_code' } - const field = fieldMap[type] - if (!field) return - try { - const res = await api('/api/brand', { - method: 'PUT', - body: JSON.stringify({ [field]: '' }), - }) - if (res.ok) { - if (type === 'logo') brandLogo.value = '' - else if (type === 'bg') brandBg.value = '' - else if (type === 'qr') brandQrImage.value = '' - ui.showToast('已清除') - } - } catch { - ui.showToast('清除失败') - } -} - // Account async function updateDisplayName() { try {