fix: 修复测试套件质量审查问题——act环境、正则匹配、mock排序、超时设置

This commit is contained in:
2026-06-08 14:13:45 +08:00
parent 74266dc5cc
commit d02abce58d
11 changed files with 204 additions and 179 deletions

View File

@@ -148,7 +148,7 @@ describe("ProjectsPage", () => {
await waitFor(() => expect(calls.some((call) => call.url.includes("status=archived"))).toBe(true));
await screen.findByText("归档项目");
});
}, 30000);
test("清空搜索条件复位请求参数并重新展示全部项目", async () => {
const calls = createProjectFetchMock();
@@ -190,7 +190,7 @@ describe("ProjectsPage", () => {
const createCall = calls.find((call) => call.url.endsWith("/api/projects") && call.method === "POST");
expect(createCall).toBeDefined();
expect(jsonBody(createCall?.body)).toEqual({ description: "新增描述", name: "新增项目" });
});
}, 30000);
test("编辑项目表单只提交变更字段", async () => {
const updateCalls: unknown[] = [];
@@ -217,7 +217,7 @@ describe("ProjectsPage", () => {
await waitFor(() => expect(onUpdate).toHaveBeenCalled());
expect(updateCalls[0]).toEqual({ data: { name: "编辑项目" }, id: "p1" });
});
}, 30000);
test("项目表单校验失败不会提交,接口失败时保留弹窗", async () => {
const onCreate = mock(() => Promise.reject(new Error("创建失败")));
@@ -244,7 +244,7 @@ describe("ProjectsPage", () => {
await waitFor(() => expect(onCreate).toHaveBeenCalled());
expect(onOpenChange).not.toHaveBeenCalledWith(false);
expect(screen.getByText("新建项目")).not.toBeNull();
});
}, 30000);
test("项目表格操作触发导航和行级动作", async () => {
const onArchive = mock(() => Promise.resolve());
@@ -287,5 +287,5 @@ describe("ProjectsPage", () => {
await screen.findByText("确认永久删除此项目?");
await clickLatestConfirmButton();
await waitFor(() => expect(onDelete).toHaveBeenCalledWith("p2"));
}, 15000);
}, 30000);
});