fix: 修复测试套件质量审查问题——act环境、正则匹配、mock排序、超时设置
This commit is contained in:
@@ -55,10 +55,13 @@ describe("AddMaterialModal", () => {
|
||||
|
||||
fireEvent.click(screen.getByText("确 定"));
|
||||
|
||||
await waitFor(() => {
|
||||
expect(screen.getByText("请输入描述")).not.toBeNull();
|
||||
});
|
||||
});
|
||||
await waitFor(
|
||||
() => {
|
||||
expect(screen.getByText("请输入描述")).not.toBeNull();
|
||||
},
|
||||
{ timeout: 10000 },
|
||||
);
|
||||
}, 30000);
|
||||
|
||||
test("点击确定触发表单提交", async () => {
|
||||
const onAdd = vi.fn<(body: CreateMaterialRequest) => Promise<Material>>();
|
||||
@@ -76,16 +79,19 @@ describe("AddMaterialModal", () => {
|
||||
|
||||
fireEvent.click(screen.getByText("确 定"));
|
||||
|
||||
await waitFor(() => {
|
||||
expect(onAdd).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
await waitFor(
|
||||
() => {
|
||||
expect(onAdd).toHaveBeenCalledTimes(1);
|
||||
},
|
||||
{ timeout: 10000 },
|
||||
);
|
||||
|
||||
const callArgs = onAdd.mock.calls[0];
|
||||
expect(callArgs).toBeDefined();
|
||||
const calledBody = callArgs![0];
|
||||
expect(calledBody.description).toBe("测试描述");
|
||||
expect(calledBody.associatedDate).toMatch(/^\d{4}-\d{2}-\d{2}$/);
|
||||
});
|
||||
}, 30000);
|
||||
|
||||
test("提交失败显示错误提示", async () => {
|
||||
const onAdd = vi.fn<(body: CreateMaterialRequest) => Promise<Material>>();
|
||||
@@ -103,8 +109,11 @@ describe("AddMaterialModal", () => {
|
||||
|
||||
fireEvent.click(screen.getByText("确 定"));
|
||||
|
||||
await waitFor(() => {
|
||||
expect(onAdd).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
});
|
||||
await waitFor(
|
||||
() => {
|
||||
expect(onAdd).toHaveBeenCalledTimes(1);
|
||||
},
|
||||
{ timeout: 10000 },
|
||||
);
|
||||
}, 30000);
|
||||
});
|
||||
|
||||
@@ -96,7 +96,7 @@ describe("InboxPage", () => {
|
||||
const cards = screen.getAllByText("新增的素材");
|
||||
expect(cards.length).toBeGreaterThanOrEqual(1);
|
||||
});
|
||||
});
|
||||
}, 30000);
|
||||
|
||||
test("删除素材后列表更新", async () => {
|
||||
let deleted = false;
|
||||
@@ -131,5 +131,5 @@ describe("InboxPage", () => {
|
||||
await waitFor(() => {
|
||||
expect(screen.getByText("暂无素材")).not.toBeNull();
|
||||
});
|
||||
});
|
||||
}, 30000);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user