From 9ba0f6e9b53f27410325e90bf437ffd5ff35b0c4 Mon Sep 17 00:00:00 2001 From: Hera Zhao Date: Tue, 14 Apr 2026 13:55:09 +0000 Subject: [PATCH] =?UTF-8?q?test:=20PR33=E6=B5=8B=E8=AF=95=20=E2=80=94=20?= =?UTF-8?q?=E5=93=81=E7=89=8C=E5=85=83=E7=B4=A0=E6=98=BE=E7=A4=BA=E9=80=BB?= =?UTF-8?q?=E8=BE=91=E3=80=81volumeLabel=E5=8F=82=E6=95=B0=E3=80=81PDF?= =?UTF-8?q?=E5=8D=95=E4=BB=B7=E5=8D=95=E4=BD=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 新增4个测试: 品牌数据决定卡片元素、空品牌显示plain、volumeLabel双参数、PDF单价适配 Co-Authored-By: Claude Opus 4.6 (1M context) --- frontend/src/__tests__/pr27Features.test.js | 43 +++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/frontend/src/__tests__/pr27Features.test.js b/frontend/src/__tests__/pr27Features.test.js index 02ab2b7..7d8ded3 100644 --- a/frontend/src/__tests__/pr27Features.test.js +++ b/frontend/src/__tests__/pr27Features.test.js @@ -499,3 +499,46 @@ describe('volume field in recipe mapping — PR31', () => { expect(labels['']).toBe('') }) }) + +// --------------------------------------------------------------------------- +// PR33: Oil card branding logic +// --------------------------------------------------------------------------- +describe('oil card branding — PR33', () => { + it('brand data determines card display elements', () => { + const brand = { qr_code: 'data:image/png;base64,abc', brand_bg: 'data:image/png;base64,bg', brand_logo: null, brand_name: '测试品牌', brand_align: 'center' } + expect(!!brand.qr_code).toBe(true) + expect(!!brand.brand_bg).toBe(true) + expect(!!brand.brand_logo).toBe(false) + expect(!!brand.brand_name).toBe(true) + }) + + it('empty brand shows plain card', () => { + const brand = {} + expect(!!brand.qr_code).toBe(false) + expect(!!brand.brand_bg).toBe(false) + expect(!!brand.brand_logo).toBe(false) + }) + + it('volumeLabel with name parameter works for drops and ml', () => { + // Simulates the fix: volumeLabel(dropCount, name) needs both params + const DROPS_TO_VOLUME = { 93: '5ml', 280: '15ml' } + function volumeLabel(dropCount, name) { + if (name === '无香乳液') return dropCount + 'ml' // ml unit + return DROPS_TO_VOLUME[dropCount] || (dropCount + '滴') + } + expect(volumeLabel(280, '薰衣草')).toBe('15ml') + expect(volumeLabel(200, '无香乳液')).toBe('200ml') + expect(volumeLabel(93, '茶树')).toBe('5ml') + }) + + it('PDF export price unit adapts to product type', () => { + function oilPriceUnit(name) { + if (name === '无香乳液') return 'ml' + if (name === '植物空胶囊') return '颗' + return '滴' + } + expect(oilPriceUnit('薰衣草')).toBe('滴') + expect(oilPriceUnit('无香乳液')).toBe('ml') + expect(oilPriceUnit('植物空胶囊')).toBe('颗') + }) +})