背景:
- pnpm ci:local 的 test:int 在本地真实 PG 上失败,与业务代码无关,是测试自身不稳定:
1) identity 用例断言部门树第一项根部门必须有子级,但管理员可以新建无子级根部门
并排在最前(本地已有手工部门「111」,sortOrder=0),该断言不成立;
2) identity.int.spec 清理用 account startsWith('it.'),会误删 departments.int.spec
的 it.dep.* 夹具;四个 int 文件默认并行且共用同一个真实 PG,beforeAll 偶发失败。
改动:
- identity.int.spec:部门树断言改为「存在带子级的根部门」,不再依赖根部门顺序;
- vitest.int.config:fileParallelism: false,集成测试文件串行执行,并注释原因。
影响面:
- 仅集成测试的断言与执行方式;业务代码、单测、构建不变;
- test:int 改为串行,耗时略增。
回滚方式:
- 回滚本提交即恢复原断言与并行执行。
验证证据:
- pnpm --filter @lingxi/api test:int 连续 3 次:4 个文件 / 33 项全通过;
- pnpm ci:local 第 1–8 步通过(第 10 步 e2e 为 A0 遗留问题,另行处理);
- pnpm format:check / lint / typecheck / test 通过。
This commit is contained in:
1 parent
4f6ccda6e3
commit
b489cb3152
2 files changed
+6
-1
No files matched your search
@@ -318,7 +318,9 @@ describe('identity 集成(真实 PG / Redis)', () => {
|
||||
expect(tree.statusCode).toBe(200);
|
||||
const treeBody = tree.json<{ items: { name: string; children: unknown[] }[] }>();
|
||||
expect(treeBody.items.length).toBeGreaterThanOrEqual(3);
|
||||
expect(treeBody.items[0]?.children.length).toBeGreaterThan(0);
|
||||
// 根部门按 sortOrder 排序,管理员可新建无子级的根部门并排在最前;
|
||||
// 这里只校验树里存在带子级的根部门,不依赖当前第一项(本地手工数据会让测试失真)。
|
||||
expect(treeBody.items.some((item) => item.children.length > 0)).toBe(true);
|
||||
|
||||
const roles = await created.app.inject({
|
||||
method: 'GET',
|
||||
|
||||
Reference in new issue
Block a user