test: PR33测试 — 品牌元素显示逻辑、volumeLabel参数、PDF单价单位
Some checks failed
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 12s
Test / e2e-test (push) Failing after 7m6s
Some checks failed
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 12s
Test / e2e-test (push) Failing after 7m6s
新增4个测试: 品牌数据决定卡片元素、空品牌显示plain、volumeLabel双参数、PDF单价适配 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -499,3 +499,46 @@ describe('volume field in recipe mapping — PR31', () => {
|
|||||||
expect(labels['']).toBe('')
|
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('颗')
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user