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
19 changes: 16 additions & 3 deletions actions/setup/js/checkout_pr_branch.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ If the pull request is still open, verify that:
await runScript();

// Fork status should be "unknown" initially (minimal PR object)
expect(mockCore.info).toHaveBeenCalledWith("Is fork PR: unknown (PR details not available in event payload)");
expect(mockCore.info).toHaveBeenCalledWith("Is fork PR: unknown (head/base repo details not available in event payload)");
// After API call, fork status should be resolved
expect(mockCore.info).toHaveBeenCalledWith("Is fork PR (from API): false (same repository)");
// Should NOT emit fork warning for a non-fork PR
Expand Down Expand Up @@ -404,7 +404,7 @@ If the pull request is still open, verify that:
await runScript();

// Fork status should be "unknown" initially, then resolved from API
expect(mockCore.info).toHaveBeenCalledWith("Is fork PR: unknown (PR details not available in event payload)");
expect(mockCore.info).toHaveBeenCalledWith("Is fork PR: unknown (head/base repo details not available in event payload)");
expect(mockCore.info).toHaveBeenCalledWith("Is fork PR (from API): true (different repository names)");
// Should emit fork warning
expect(mockCore.warning).toHaveBeenCalledWith("⚠️ Fork PR detected - fetching via refs/pull/N/head from origin");
Expand Down Expand Up @@ -616,11 +616,24 @@ If the pull request is still open, verify that:
// Simulate deleted fork scenario
delete mockContext.payload.pull_request.head.repo;

// fetchPRDetails returns full PR data with deleted head repo
mockGithub.rest.pulls.get.mockResolvedValueOnce({
data: {
state: "open",
commits: 1,
head: { ref: "feature-branch", repo: null },
base: { ref: "main", repo: { full_name: "test-owner/test-repo", owner: { login: "test-owner" } } },
},
});

await runScript();

// Verify deleted fork detection
expect(mockCore.warning).toHaveBeenCalledWith("⚠️ Head repo information not available (repo may be deleted)");
expect(mockCore.info).toHaveBeenCalledWith("Is fork PR: true (head repository deleted (was likely a fork))");
// logPRContext reports unknown because head.repo is missing in the payload
expect(mockCore.info).toHaveBeenCalledWith("Is fork PR: unknown (head/base repo details not available in event payload)");
// After API call, fork status is resolved via detectForkPR
expect(mockCore.info).toHaveBeenCalledWith("Is fork PR (from API): true (head repository deleted (was likely a fork))");
expect(mockCore.warning).toHaveBeenCalledWith("⚠️ Fork PR detected - fetching via refs/pull/N/head from origin");
});

Expand Down
4 changes: 2 additions & 2 deletions actions/setup/js/safe_output_manifest.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -371,8 +371,8 @@ describe("safe_output_manifest", () => {
});

it("should throw when the file cannot be written", () => {
// Use a path that cannot be created (root filesystem)
expect(() => writeTemporaryIdMapFile({}, "/proc/fake/map.json")).toThrow("Failed to write temporary ID map file");
// Use a path under /dev/null which is a file, not a directory — mkdirSync fails immediately
expect(() => writeTemporaryIdMapFile({}, "/dev/null/fake/map.json")).toThrow("Failed to write temporary ID map file");
});
});
});
1 change: 0 additions & 1 deletion actions/setup/js/vitest.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ export default defineConfig({
include: ["**/*.test.{js,cjs}"],
testTimeout: 10000,
hookTimeout: 10000,
forceExit: true,
coverage: {
provider: "v8",
reporter: ["text", "html"],
Expand Down
Loading