Skip to content
Merged
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
64 changes: 64 additions & 0 deletions actions/setup/js/add_labels.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -681,5 +681,69 @@ describe("add_labels", () => {
expect(mockCore.infos.some(msg => msg.includes("Blocked patterns:"))).toBe(false);
expect(mockCore.infos.some(msg => msg.includes("max=5"))).toBe(true);
});

it("should succeed with empty labelsAdded when all labels are blocked by patterns", async () => {
const handler = await main({
max: 10,
blocked: ["*"],
Comment on lines +685 to +688
Copy link

Copilot AI Apr 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR description claims 4 new tests (31 → 35 total), but this diff adds 3 new it(...) cases (which would typically bring 31 → 34). Consider updating the PR description (or include the missing 4th test change) to avoid confusion for reviewers and release notes.

Copilot uses AI. Check for mistakes.
});

const addLabelsCalls = [];
mockGithub.rest.issues.addLabels = async params => {
addLabelsCalls.push(params);
return {};
};

const result = await handler(
{
item_number: 100,
labels: ["bug", "enhancement"],
},
{}
);

// All labels blocked → treated as "no valid labels"
expect(result.success).toBe(true);
expect(result.labelsAdded).toEqual([]);
expect(result.message).toContain("No valid labels");
expect(addLabelsCalls.length).toBe(0);
});

it("should reject labels starting with '-' (removal attempt)", async () => {
const handler = await main({ max: 10 });

const result = await handler(
{
item_number: 100,
labels: ["-bug"],
},
{}
);

expect(result.success).toBe(false);
expect(result.error).toContain("Label removal is not permitted");
});

it("should truncate labels longer than 64 characters", async () => {
const handler = await main({ max: 10 });
const addLabelsCalls = [];

mockGithub.rest.issues.addLabels = async params => {
addLabelsCalls.push(params);
return {};
};

const longLabel = "a".repeat(80);
const result = await handler(
{
item_number: 100,
labels: [longLabel],
},
{}
);

expect(result.success).toBe(true);
expect(result.labelsAdded[0].length).toBe(64);
});
});
});
Loading