mirror of https://github.com/openclaw/openclaw.git
test: reuse feishu streaming merge helper
This commit is contained in:
parent
b6c297af8c
commit
a474a9c45d
|
|
@ -25,40 +25,27 @@ vi.mock("./typing.js", () => ({
|
||||||
addTypingIndicator: addTypingIndicatorMock,
|
addTypingIndicator: addTypingIndicatorMock,
|
||||||
removeTypingIndicator: removeTypingIndicatorMock,
|
removeTypingIndicator: removeTypingIndicatorMock,
|
||||||
}));
|
}));
|
||||||
vi.mock("./streaming-card.js", () => ({
|
vi.mock("./streaming-card.js", async () => {
|
||||||
mergeStreamingText: (previousText: string | undefined, nextText: string | undefined) => {
|
const actual = await vi.importActual<typeof import("./streaming-card.js")>("./streaming-card.js");
|
||||||
const previous = typeof previousText === "string" ? previousText : "";
|
return {
|
||||||
const next = typeof nextText === "string" ? nextText : "";
|
mergeStreamingText: actual.mergeStreamingText,
|
||||||
if (!next) {
|
FeishuStreamingSession: class {
|
||||||
return previous;
|
active = false;
|
||||||
}
|
start = vi.fn(async () => {
|
||||||
if (!previous || next === previous) {
|
this.active = true;
|
||||||
return next;
|
});
|
||||||
}
|
update = vi.fn(async () => {});
|
||||||
if (next.startsWith(previous)) {
|
close = vi.fn(async () => {
|
||||||
return next;
|
this.active = false;
|
||||||
}
|
});
|
||||||
if (previous.startsWith(next)) {
|
isActive = vi.fn(() => this.active);
|
||||||
return previous;
|
|
||||||
}
|
|
||||||
return `${previous}${next}`;
|
|
||||||
},
|
|
||||||
FeishuStreamingSession: class {
|
|
||||||
active = false;
|
|
||||||
start = vi.fn(async () => {
|
|
||||||
this.active = true;
|
|
||||||
});
|
|
||||||
update = vi.fn(async () => {});
|
|
||||||
close = vi.fn(async () => {
|
|
||||||
this.active = false;
|
|
||||||
});
|
|
||||||
isActive = vi.fn(() => this.active);
|
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
streamingInstances.push(this);
|
streamingInstances.push(this);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}));
|
};
|
||||||
|
});
|
||||||
|
|
||||||
import { createFeishuReplyDispatcher } from "./reply-dispatcher.js";
|
import { createFeishuReplyDispatcher } from "./reply-dispatcher.js";
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue