fix(api,admin): stop test fixture junk leaking to shared dev DB; badge text x个配置

清理标签筛选里的「Upd {ts}-v2」空分组与原产品库树里的
「Tree Cat {ts}」垃圾分类——两者均为集成测试夹具残留:
- tag-groups spec「改名」用例把分组改成 -v2 后缀,afterAll 按原名
  删除永远漏掉它(累积 31 个空分组);修复:改名前把 v2 名一并登记
- origin-goods spec getTree 用例的 finally 先删 good,被
  goodOriginGood 外键限制挡住且错误被 .catch 吞掉,分类/商品/国家/
  链接全部残留;修复:先删引用行再删 good
- 已清库:31 个 Upd 空分组、Tree Cat 分类 + Tree Good 商品 +
  Tree Country 国家 + 2 条 tree-a/b 链接;复跑两 spec 复核零残留

左树一族一行徽标文案按用户反馈去掉「N 条链接」,仅显示「M 个配置」
(memberCount 字段保留在 DTO,悬浮弹层行为不变)

验证:tag-groups + origin-goods spec 13/13 绿且零残留;admin
vue-tsc 干净 + vitest 22/22
This commit is contained in:
yeuimu
2026-08-30 03:15:18 +08:00
parent 12882e7d5a
commit 674d38a9a7
4 changed files with 9 additions and 6 deletions
+1 -1
View File
@@ -1180,7 +1180,7 @@ onMounted(() => loadAll())
popper-class="cfg-pop-popper"
>
<template #reference>
<span class="cfg-badge" :title="`同款共 ${data.linkCount ?? data.configCount} 条链接 · ${data.configCount} 个官网配置`" @click.stop>{{ data.linkCount ? `${data.linkCount} 条链接 · ` : '' }}{{ data.configCount }} 个配置</span>
<span class="cfg-badge" :title="`同款共 ${data.configCount} 个官网配置`" @click.stop>{{ data.configCount }} 个配置</span>
</template>
<div class="cfg-pop-list">
<div v-for="c in (data.familyConfigs || [])" :key="c.goodId" class="cfg-pop-row">
@@ -1,7 +1,7 @@
import { Test } from '@nestjs/testing';
import { OriginGoodsService } from './origin-goods.service';
import { FamilyRecomputeService } from '../product-families/family-recompute.service';
import { ProductFamiliesService } from '../product-families/product-families.service';
import { FamilyRecomputeService } from '../product-families/family-recompute.service';
import { ProductFamiliesService } from '../product-families/product-families.service';
import { OrganizeService } from '../product-families/organize.service';
import { PrismaService } from '../prisma/prisma.service';
@@ -153,6 +153,8 @@ describe('OriginGoodsService', () => {
expect(nodeB.configuredCount).toBeGreaterThanOrEqual(1);
expect(nodeB.configuredCountries).toContain(`Tree Country ${stamp}`);
} finally {
// 先删引用行,否则 good.delete 被外键限制挡住(错误被吞后分类/商品/国家全残留)
await prisma.goodOriginGood.deleteMany({ where: { goodId: good.id } }).catch(() => undefined);
await prisma.good.delete({ where: { id: good.id } }).catch(() => undefined);
await prisma.country.delete({ where: { id: country.id } }).catch(() => undefined);
await prisma.category.delete({ where: { id: cat.id } }).catch(() => undefined);
@@ -50,7 +50,8 @@ describe('TagGroupsService', () => {
it('updates group name and color', async () => {
const name = `Upd ${Date.now()}`;
createdNames.push(name);
// 改名后的行也要纳入清理,否则 -v2 行会残留在共享开发库
createdNames.push(name, `${name}-v2`);
const g = await service.create({ groupName: name });
const updated = await service.update(g.id, {
groupName: `${name}-v2`,