Files
multica/packages/views/issues/utils/strip-mention-markdown.test.ts
LinYushen ca10535bb6 fix: execution log name rendering and squad assignee support (#2575)
* fix: execution log name rendering and squad assignee support

- Strip mention markdown in trigger_summary ([@Name](mention://...) → @Name)
  so execution log rows show clean text instead of raw markdown
- Add squad to ActorFilterValue type so squad assignees are filterable
- Add squad section to assignee filter dropdown in issues-header
- Add i18n keys for squads_group (en/zh-Hans)

Co-authored-by: multica-agent <github@multica.ai>

* fix: address PR #2575 review feedback

1. Extract stripMentionMarkdown as reusable helper with proper regex
   - Handles escaped brackets in names (e.g. David\[TF\])
   - Skips backslash-escaped mentions (\[@...])
   - Handles issue mentions (no @ prefix)
   - Does not touch regular markdown links
   - 10 unit tests added

2. Squad only appears in Assignee filter, not Creator
   - Added showSquads prop to ActorSubContent (default true)
   - Creator filter passes showSquads={false}

3. Squad included in Agents scope
   - issues-page scope filter now includes squad in agents scope
   - 2 regression tests added for scope coverage

Co-authored-by: multica-agent <github@multica.ai>

---------

Co-authored-by: multica-agent <github@multica.ai>
2026-05-14 13:08:05 +08:00

63 lines
1.8 KiB
TypeScript

import { describe, it, expect } from "vitest";
import { stripMentionMarkdown } from "./strip-mention-markdown";
describe("stripMentionMarkdown", () => {
it("strips simple agent mention", () => {
expect(
stripMentionMarkdown("[@魏和尚](mention://agent/de8efbcc-eaa1-4605-a6ac-d50cfa88e447)"),
).toBe("@魏和尚");
});
it("strips simple member mention", () => {
expect(
stripMentionMarkdown("[@Alice](mention://member/abc-123)"),
).toBe("@Alice");
});
it("strips issue mention (no @ prefix)", () => {
expect(
stripMentionMarkdown("[MUL-123](mention://issue/some-uuid)"),
).toBe("MUL-123");
});
it("handles escaped brackets in names", () => {
expect(
stripMentionMarkdown("[@David\\[TF\\]](mention://agent/id-123)"),
).toBe("@David[TF]");
});
it("handles multiple mentions in one string", () => {
expect(
stripMentionMarkdown(
"Triggered by [@Alice](mention://member/a1) and [@Bob](mention://agent/b2)",
),
).toBe("Triggered by @Alice and @Bob");
});
it("does NOT strip regular markdown links", () => {
expect(
stripMentionMarkdown("[docs](https://example.com)"),
).toBe("[docs](https://example.com)");
});
it("does NOT strip non-mention parenthetical links", () => {
expect(
stripMentionMarkdown("[click here](http://foo.bar/baz)"),
).toBe("[click here](http://foo.bar/baz)");
});
it("handles backslash-escaped content that is NOT a mention", () => {
expect(
stripMentionMarkdown("\\[@Literal](mention://agent/id)"),
).toBe("\\[@Literal](mention://agent/id)");
});
it("returns plain text unchanged", () => {
expect(stripMentionMarkdown("hello world")).toBe("hello world");
});
it("handles empty string", () => {
expect(stripMentionMarkdown("")).toBe("");
});
});