test(FN-4728): align route tests with hook-driven tracking
Fusion-Task-Id: FN-4728 Fusion-Task-Lineage: 6e8e9040-0c2f-4290-8905-1c1be8487894
This commit is contained in:
committed by
gsxdsm
parent
56f38cf174
commit
b61db63661
@@ -869,7 +869,7 @@ describe("Automation routes", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("create-task automation step attempts tracking issue creation and links metadata", async () => {
|
||||
it("create-task automation step remains successful without explicit tracking issue creation", async () => {
|
||||
const createIssueSpy = vi.spyOn(GitHubClient.prototype, "createIssue").mockResolvedValue({
|
||||
owner: "task",
|
||||
repo: "repo",
|
||||
@@ -914,13 +914,13 @@ describe("Automation routes", () => {
|
||||
const res = await REQUEST(app, "POST", "/api/automations/sched-001/run");
|
||||
|
||||
expect(res.status).toBe(200);
|
||||
expect(createIssueSpy).toHaveBeenCalledWith(expect.objectContaining({ owner: "task", repo: "repo" }));
|
||||
expect(linkGithubIssue).toHaveBeenCalledWith("FN-9002", expect.objectContaining({ owner: "task", repo: "repo", number: 17 }));
|
||||
expect(recordActivity).toHaveBeenCalledWith(expect.objectContaining({ metadata: expect.objectContaining({ type: "github-issue-created" }) }));
|
||||
expect(createIssueSpy).not.toHaveBeenCalled();
|
||||
expect(linkGithubIssue).not.toHaveBeenCalled();
|
||||
expect(recordActivity).not.toHaveBeenCalled();
|
||||
createIssueSpy.mockRestore();
|
||||
});
|
||||
|
||||
it("create-task automation step keeps success when tracking issue creation fails", async () => {
|
||||
it("create-task automation step keeps success even if GitHub client would fail", async () => {
|
||||
const createIssueSpy = vi.spyOn(GitHubClient.prototype, "createIssue").mockRejectedValue(new Error("github down"));
|
||||
const mockStore = createMockAutomationStore();
|
||||
mockStore.getSchedule.mockResolvedValue({
|
||||
@@ -952,7 +952,7 @@ describe("Automation routes", () => {
|
||||
|
||||
expect(res.status).toBe(200);
|
||||
expect(res.body.result.stepResults[0]).toEqual(expect.objectContaining({ success: true }));
|
||||
expect(createIssueSpy).toHaveBeenCalledTimes(1);
|
||||
expect(createIssueSpy).not.toHaveBeenCalled();
|
||||
createIssueSpy.mockRestore();
|
||||
});
|
||||
it("does not create tracking issue in automation create-task when task already linked", async () => {
|
||||
|
||||
@@ -1918,7 +1918,7 @@ describe("POST /subtasks/*", () => {
|
||||
expect(store.updateTask).toHaveBeenCalledWith("FN-102", { dependencies: ["FN-101"] });
|
||||
});
|
||||
|
||||
it("subtask batch creation attempts tracking issue creation and links metadata", async () => {
|
||||
it("subtask batch creation succeeds without explicit tracking issue creation", async () => {
|
||||
const createIssueSpy = vi.spyOn(GitHubClient.prototype, "createIssue").mockResolvedValue({
|
||||
owner: "task",
|
||||
repo: "repo",
|
||||
@@ -1955,13 +1955,13 @@ describe("POST /subtasks/*", () => {
|
||||
);
|
||||
|
||||
expect(createRes.status).toBe(201);
|
||||
expect(createIssueSpy).toHaveBeenCalledWith(expect.objectContaining({ owner: "task", repo: "repo" }));
|
||||
expect(store.linkGithubIssue).toHaveBeenCalledWith("FN-103", expect.objectContaining({ owner: "task", repo: "repo", number: 55 }));
|
||||
expect(store.recordActivity).toHaveBeenCalledWith(expect.objectContaining({ metadata: expect.objectContaining({ type: "github-issue-created" }) }));
|
||||
expect(createIssueSpy).not.toHaveBeenCalled();
|
||||
expect(store.linkGithubIssue).not.toHaveBeenCalled();
|
||||
expect(store.recordActivity).not.toHaveBeenCalled();
|
||||
createIssueSpy.mockRestore();
|
||||
});
|
||||
|
||||
it("subtask batch creation remains successful when tracking issue creation fails", async () => {
|
||||
it("subtask batch creation remains successful even if GitHub client would fail", async () => {
|
||||
const createIssueSpy = vi.spyOn(GitHubClient.prototype, "createIssue").mockRejectedValue(new Error("boom"));
|
||||
|
||||
(store.getSettings as ReturnType<typeof vi.fn>).mockResolvedValue({
|
||||
@@ -1993,7 +1993,7 @@ describe("POST /subtasks/*", () => {
|
||||
|
||||
expect(createRes.status).toBe(201);
|
||||
expect(createRes.body.tasks).toHaveLength(1);
|
||||
expect(createIssueSpy).toHaveBeenCalledTimes(1);
|
||||
expect(createIssueSpy).not.toHaveBeenCalled();
|
||||
createIssueSpy.mockRestore();
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user