mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-10 17:34:58 +00:00
fix(auto-reply): land #31080 from @scoootscooob
Co-authored-by: scoootscooob <zhentongfan@gmail.com>
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user