deploy(v2): h5 build with base /v2/h5, admin dockerfile & nginx route, shared compose
This commit is contained in:
@@ -328,6 +328,74 @@ describe('PublicService', () => {
|
||||
expect(result.items[0].goodName).toBe(`Pub High ${stamp}`); // 代表行 = 排序第一条
|
||||
});
|
||||
|
||||
it('list price is the family price matrix minimum (SQL aggregate)', async () => {
|
||||
// 自包含 fixture:CUSTOM 光板成员(craftLabel/logisticsLabel 是矩阵归因来源)
|
||||
// + 单变体 38 元。SDS 成员无标签时矩阵为空(不解析名称,等整理补标签),
|
||||
// 共享 fixture 族 therefore 无矩阵,无法覆盖该路径。
|
||||
const og = await prisma.originGood.create({
|
||||
data: {
|
||||
source: 'CUSTOM',
|
||||
sdsGoodId: `pub-matrix-${stamp}`,
|
||||
goodName: `Pub Matrix ${stamp}`,
|
||||
craftLabel: '不打印',
|
||||
logisticsLabel: '包邮',
|
||||
goodPrice: 50, // 无矩阵时的回退链接价
|
||||
},
|
||||
});
|
||||
const family = await prisma.productFamily.create({
|
||||
data: { familyName: `Pub Matrix Family ${stamp}`, primaryOriginGoodId: og.id },
|
||||
});
|
||||
await prisma.originGood.update({
|
||||
where: { id: og.id },
|
||||
data: { familyId: family.id },
|
||||
});
|
||||
await prisma.originGoodVariant.create({
|
||||
data: {
|
||||
originGoodId: og.id,
|
||||
sdsVariantId: `pub-matrix-v-${stamp}`,
|
||||
sku: `PM${stamp}`,
|
||||
sizeName: 'S',
|
||||
price: 38,
|
||||
},
|
||||
});
|
||||
const good = await prisma.good.create({
|
||||
data: {
|
||||
goodName: `Pub Matrix Good ${stamp}`,
|
||||
originGoodId: og.id,
|
||||
familyId: family.id,
|
||||
countryId,
|
||||
categoryId,
|
||||
},
|
||||
});
|
||||
try {
|
||||
// 重算前:族无矩阵 → 回退链接价
|
||||
const before = await service.getGoods({
|
||||
page: 1,
|
||||
pageSize: 50,
|
||||
keyword: `Pub Matrix Good`,
|
||||
});
|
||||
expect(before.items).toHaveLength(1);
|
||||
expect(before.items[0].price).toBe('50');
|
||||
|
||||
await new FamilyRecomputeService(prisma).recomputeFamily(family.id);
|
||||
const after = await service.getGoods({
|
||||
page: 1,
|
||||
pageSize: 50,
|
||||
keyword: `Pub Matrix Good`,
|
||||
});
|
||||
expect(after.items).toHaveLength(1);
|
||||
// 重算后:矩阵最低价 38 生效,不再是回退链接价
|
||||
expect(after.items[0].price).toBe('38');
|
||||
} finally {
|
||||
await prisma.good.delete({ where: { id: good.id } });
|
||||
await prisma.originGoodVariant.deleteMany({
|
||||
where: { sdsVariantId: `pub-matrix-v-${stamp}` },
|
||||
});
|
||||
await prisma.productFamily.delete({ where: { id: family.id } });
|
||||
await prisma.originGood.delete({ where: { id: og.id } });
|
||||
}
|
||||
});
|
||||
|
||||
it('custom goods (无族) are not visible on public endpoints', async () => {
|
||||
const customPublicId = `custom-public-${stamp}`;
|
||||
const origin = await prisma.originGood.create({
|
||||
|
||||
Reference in New Issue
Block a user