Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,14 @@ describe("useTaskPrStatus", () => {
);
expect(lastQueryOptions?.enabled).toBe(true);
});

it("ignores placeholder data when the query is disabled", () => {
queryData = { prState: "open", hasDiff: true };
const { result } = renderHook(() =>
useTaskPrStatus(
makeTask({ taskRunEnvironment: "cloud", cloudPrUrl: null }),
),
);
expect(result.current).toEqual({ prState: null, hasDiff: false });
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ export function useTaskPrStatus(task: {
),
);

if (!data || (!data.prState && !data.hasDiff)) return EMPTY;
// A disabled query can retain placeholder data from the previously selected
// task. Ignore it so a cloud task without a PR never shows stale PR status.
if (skipQuery || !data || (!data.prState && !data.hasDiff)) return EMPTY;
return data;
}
Loading