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('颗') + }) +})