fix(auto-reply): land #31080 from @scoootscooob

Co-authored-by: scoootscooob <zhentongfan@gmail.com>
This commit is contained in:
Peter Steinberger
2026-03-02 01:17:35 +00:00
parent e7cd4bf1bd
commit a6a742f3d0
5 changed files with 101 additions and 2 deletions

View File

@@ -1,5 +1,5 @@
import { describe, it, expect } from "vitest";
import { isSilentReplyPrefixText, isSilentReplyText } from "./tokens.js";
import { isSilentReplyPrefixText, isSilentReplyText, stripSilentToken } from "./tokens.js";
describe("isSilentReplyText", () => {
it("returns true for exact token", () => {
@@ -36,6 +36,37 @@ describe("isSilentReplyText", () => {
});
});
describe("stripSilentToken", () => {
it("strips token from end of text", () => {
expect(stripSilentToken("Done.\n\nNO_REPLY")).toBe("Done.");
});
it("does not strip token from start of text", () => {
expect(stripSilentToken("NO_REPLY 👍")).toBe("NO_REPLY 👍");
});
it("strips token with emoji (#30916)", () => {
expect(stripSilentToken("😄 NO_REPLY")).toBe("😄");
});
it("does not strip embedded token suffix without whitespace delimiter", () => {
expect(stripSilentToken("interject.NO_REPLY")).toBe("interject.NO_REPLY");
});
it("strips only trailing occurrence", () => {
expect(stripSilentToken("NO_REPLY ok NO_REPLY")).toBe("NO_REPLY ok");
});
it("returns empty string when only token remains", () => {
expect(stripSilentToken("NO_REPLY")).toBe("");
expect(stripSilentToken(" NO_REPLY ")).toBe("");
});
it("works with custom token", () => {
expect(stripSilentToken("done HEARTBEAT_OK", "HEARTBEAT_OK")).toBe("done");
});
});
describe("isSilentReplyPrefixText", () => {
it("matches uppercase underscore prefixes", () => {
expect(isSilentReplyPrefixText("NO_")).toBe(true);