Files
2026-11-16 17:26:44 -08:00

41 lines
2.6 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// MUST be first — pins env before the repo registry is evaluated.
import "./setup_env";
import { describe, expect, test } from "bun:test";
import { parseReportBranch } from "@bbbug/shared/report_branch";
describe("从报告里读修复分支", () => {
// 每一条都是 2026-10-22 线上复核阶段没分支的单子报告里的原文(截短)。
const seen: [string, string][] = [
["branch: bugfix/plain", "bugfix/plain"],
["branch: `bugfix/explore-card-impression-overreport`", "bugfix/explore-card-impression-overreport"],
["- branch: `bugfix/profile-edit-title-bar-large-font`", "bugfix/profile-edit-title-bar-large-font"],
["- branch: bugfix/duplicate-link-popup-status-update", "bugfix/duplicate-link-popup-status-update"],
["> branch: bugfix/skylight-thought-bubble-long-press", "bugfix/skylight-thought-bubble-long-press"],
["- 分支: `bugfix/lynx-surl-whitelist-bypass`", "bugfix/lynx-surl-whitelist-bypass"],
["分支:`bugfix/thought-aggregate-avatar-profile-event`(基于 develop `cf914c1a3498cc1`)", "bugfix/thought-aggregate-avatar-profile-event"],
["分支:`bugfix/text-mode-reedit-retry-content-loss`(基于 origin/develop 3fc33edd291b,round 1)", "bugfix/text-mode-reedit-retry-content-loss"],
["- 修复分支: `bugfix/story-forward-photo-rounded-corner`", "bugfix/story-forward-photo-rounded-corner"],
["**分支**:`bugfix/photo-clear-mode-text-alpha-stuck`(基于 `origin/develop` @ `6b6caba820131`)", "bugfix/photo-clear-mode-text-alpha-stuck"],
["- 分支:`feature/chatbot-image-only-intent-guide`(基线 `notes/develop@1c26b4f7c9db9`)", "feature/chatbot-image-only-intent-guide"],
["## Branch\n\n`feature/story-datetime-sticker-style-switch`\n", "feature/story-datetime-sticker-style-switch"],
["- 已推送分支:`origin/bugfix/x`\n- 分支:`bugfix/y`", "bugfix/y"],
["branch: `origin/bugfix/z`.", "bugfix/z"],
];
for (const [text, want] of seen) {
test(text.split("\n")[0], () => expect(parseReportBranch(`# FixReport\n\n${text}\n\n## 用户影响\n…`)).toBe(want));
}
test("英文 branch: 优先于正文里出现的中文分支", () => {
expect(parseReportBranch("- 分支:`bugfix/a`\nbranch: bugfix/b")).toBe("bugfix/b");
});
test("中文标签不收没有斜杠的值,也不认基线分支", () => {
expect(parseReportBranch("分支:无代码改动")).toBeNull();
expect(parseReportBranch("- 基线分支:`origin/develop`")).toBeNull();
expect(parseReportBranch("依赖服务端回包的分支未验")).toBeNull();
expect(parseReportBranch("")).toBeNull();
expect(parseReportBranch(null)).toBeNull();
});
});