Skip to content
Closed
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
26 changes: 17 additions & 9 deletions src/__tests__/queue.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -901,32 +901,40 @@ describe("batch-PR informational links", () => {
.map((a) => a.textContent.trim())
.filter((t) => t === "queue" || t === "logs");
}
function queueHrefOf(row) {
function hrefOf(row, label) {
return [...row.querySelectorAll("a")]
.find((a) => a.textContent.trim() === "queue")
.find((a) => a.textContent.trim() === label)
?.getAttribute("href");
}

test("open batch PR: queue link deep-links via batch_pr, no logs link", () => {
const BATCH_ACTIVITY_LOG_HREF =
"https://dashboard.mergify.com/activity-log?login=acme&repository=widget&batch_pull=42&preset=Past1month";

test("open batch PR: queue link deep-links via batch_pr, logs link via batch_pull", () => {
setPrDom({ draft: true, author: "mergify", baseRef: "develop" });
const row = buildMergifyRow();
expect(linkLabels(row)).toEqual(["queue"]);
expect(queueHrefOf(row)).toBe(
expect(linkLabels(row)).toEqual(["queue", "logs"]);
expect(hrefOf(row, "queue")).toBe(
"https://dashboard.mergify.com/queues/status?login=acme&repository=widget&branch=develop&batch_pr=42",
);
expect(hrefOf(row, "logs")).toBe(BATCH_ACTIVITY_LOG_HREF);
});

test("closed batch PR: no queue link and no logs link", () => {
test("closed batch PR: no queue link, logs link via batch_pull", () => {
setPrDom({ closed: true, author: "mergify" });
const row = buildMergifyRow();
expect(linkLabels(row)).toEqual([]);
expect(linkLabels(row)).toEqual(["logs"]);
expect(hrefOf(row, "logs")).toBe(BATCH_ACTIVITY_LOG_HREF);
});

test("open non-batch PR keeps both the queue and logs links", () => {
test("open non-batch PR keeps both the queue and per-PR event-log links", () => {
setPrDom({ author: "octocat", baseRef: "develop" });
const row = buildMergifyRow();
expect(linkLabels(row)).toEqual(["queue", "logs"]);
expect(queueHrefOf(row)).toContain("pull-request-number=42");
expect(hrefOf(row, "queue")).toContain("pull-request-number=42");
expect(hrefOf(row, "logs")).toBe(
"https://dashboard.mergify.com/event-logs?login=acme&repository=widget&pullRequestNumber=42",
);
});

test("closed human PR is unaffected — keeps both links", () => {
Expand Down
30 changes: 25 additions & 5 deletions src/queue.js
Original file line number Diff line number Diff line change
Expand Up @@ -535,23 +535,43 @@ function appendCommandButtons(container) {
// Append the queue and logs links via the caller's appendLink(href, text, svg),
// honoring batch-PR restrictions: the queue link points at the batch peek
// drawer while the batch PR is open and is dropped once it closes (the batch
// has drained — nothing to open); the logs link is omitted on batch PRs
// entirely (not supported for batches yet).
// has drained — nothing to open); the logs link points at the batch-filtered
// activity log on batch PRs — kept on closed ones, where the batch's event
// history is the post-mortem trail.
function appendBatchAwareLinks(appendLink) {
const batch = isBatchPrContext();
if (!batch || isPullRequestOpen()) {
appendLink(getMergeQueueLink(), "queue", QUEUE_ICON_SVG);
}
if (!batch) {
appendLink(getEventLogLink(), "logs", LOGS_ICON_SVG);
}
appendLink(
batch ? getBatchActivityLogLink() : getEventLogLink(),
"logs",
LOGS_ICON_SVG,
);
}

export function getEventLogLink() {
const data = getPullRequestData();
return `https://dashboard.mergify.com/event-logs?login=${data.org}&repository=${data.repo}&pullRequestNumber=${data.pull}`;
}

// Activity log pivoted to a batch's own lifecycle events via its batch_pull
// filter — a batch PR has no per-PR event log, so this replaces
// getEventLogLink() on batch PRs. preset=Past1month widens the page's default
// 1-hour window, which would render empty for any batch older than an hour
// (a drained batch's post-mortem being the main use); same convention as the
// dashboard's own queue → activity-log deep link.
export function getBatchActivityLogLink() {
const data = getPullRequestData();
const params = new URLSearchParams({
login: data.org,
repository: data.repo,
batch_pull: data.pull,
preset: "Past1month",
});
return `https://dashboard.mergify.com/activity-log?${params}`;
}

// Base branch of the current PR, read from the classic PR UI. The
// `.commit-ref.base-ref` span is titled "owner/repo:branch"; ref names can't
// contain ":", so everything after the first colon is the branch (which may
Expand Down
Loading