41 lines
1.8 KiB
TypeScript
41 lines
1.8 KiB
TypeScript
import { test, expect, describe } from "bun:test";
|
|
import { readReportedMrUrl } from "../src/workspace";
|
|
|
|
/**
|
|
* What the node scrapes out of FixReport.md / ImplReport.md when the agent
|
|
* opened an MR itself. It is a HINT — the control plane resolves and verifies it
|
|
* against the task's branch — so this parser errs towards finding something, and
|
|
* the samples below are lifted from real reports.
|
|
*/
|
|
describe("readReportedMrUrl", () => {
|
|
test("prefers the machine `mr:` line", () => {
|
|
const report = [
|
|
"branch: feature/hide-profile-thought-creation-bubble",
|
|
"mr: https://code.byted.org/ugc/TikTok/merge_requests/296301",
|
|
"",
|
|
"顺带提到另一个 MR https://code.byted.org/ugc/TikTok/merge_requests/111111",
|
|
].join("\n");
|
|
expect(readReportedMrUrl(report)).toBe("https://code.byted.org/ugc/TikTok/merge_requests/296301");
|
|
});
|
|
|
|
test("falls back to an MR link written in prose", () => {
|
|
const report = "**MR 已生成并绑定**:在 `code.byted.org` 上生成 **MR #296301**"
|
|
+ "(`https://code.byted.org/ugc/TikTok/merge_requests/296301`,target=`develop`)。";
|
|
expect(readReportedMrUrl(report)).toBe("https://code.byted.org/ugc/TikTok/merge_requests/296301");
|
|
});
|
|
|
|
test("accepts a Bits detail URL too", () => {
|
|
expect(readReportedMrUrl("见 https://bits.bytedance.net/devops/1500037378/code/detail/8327494 。"))
|
|
.toBe("https://bits.bytedance.net/devops/1500037378/code/detail/8327494");
|
|
});
|
|
|
|
test("a report with no MR reports nothing", () => {
|
|
const report = "branch: bugfix/foo\n\n## 修复变更摘要\n改了 3 个文件,push 到 origin。";
|
|
expect(readReportedMrUrl(report)).toBeNull();
|
|
});
|
|
|
|
test("a repo link that is not an MR is not an MR", () => {
|
|
expect(readReportedMrUrl("代码在 https://code.byted.org/ugc/TikTok/blob/develop/README.md")).toBeNull();
|
|
});
|
|
});
|