功能(订单服务): 将未成年提示和底部引导图并入分类配置

This commit is contained in:
2026-11-27 15:53:09 +08:00
parent 5e45b69720
commit c3a13c5f36
25 changed files with 619 additions and 384 deletions
@@ -3,10 +3,12 @@ import test from 'node:test'
import {
DEFAULT_ORDER_SERVICE_AGE_GATE_CONFIG,
dedupeOrderServiceBottomGuideImages,
canAccessOrderServiceMaterial,
isOrderServiceAgeGateOpen,
mergeOrderServiceAgeGateConfig,
parseOrderServiceAgeGateContent,
selectFirstOrderServiceAgeGate,
resolveOrderServiceAgeGateDecision,
shouldRequireOrderServiceAgeGate,
} from '../src/utils/order-service-age-gate.ts'
@@ -79,3 +81,37 @@ test('弹窗打开时整页内容必须隐藏,已成年后才恢复', () => {
assert.equal(isOrderServiceAgeGateOpen({ required: true, decision: 'adult' }), false)
assert.equal(isOrderServiceAgeGateOpen({ required: false, decision: 'pending' }), false)
})
test('多商品只选第一个未成年提示配置,底部引导图按图片去重', () => {
const gateA = {
enabled: true,
title: 'A',
warningText: 'A',
content: 'A',
importantNotice: 'A',
adultButtonText: '我已成年',
minorButtonText: '我是未成年',
minorBlockedTitle: '不能购买',
minorBlockedContent: '停止',
}
const gateB = { ...gateA, title: 'B' }
const image = {
objectKey: 'order-service-guide/a.png',
url: '/a.png',
thumbnailUrl: '/a.png',
mediumUrl: '/a.png',
filename: 'a.png',
contentType: 'image/png',
size: 1,
}
assert.equal(selectFirstOrderServiceAgeGate([{ ageGate: gateA }, { ageGate: gateB }])?.title, 'A')
assert.equal(
dedupeOrderServiceBottomGuideImages([
{ bottomGuideImage: { enabled: true, image } },
{ bottomGuideImage: { enabled: true, image } },
{ bottomGuideImage: { enabled: false, image } },
]).length,
1,
)
})