mirror of https://github.com/openclaw/openclaw.git
test(feishu): avoid loading streaming card module in dispatcher tests
This commit is contained in:
parent
d888ce242b
commit
fbc4fa6ac3
|
|
@ -21,6 +21,33 @@ const addTypingIndicatorMock = vi.hoisted(() => vi.fn(async () => ({ messageId:
|
|||
const removeTypingIndicatorMock = vi.hoisted(() => vi.fn(async () => {}));
|
||||
const streamingInstances = vi.hoisted((): StreamingSessionStub[] => []);
|
||||
|
||||
function mergeStreamingText(
|
||||
previousText: string | undefined,
|
||||
nextText: string | undefined,
|
||||
): string {
|
||||
const previous = typeof previousText === "string" ? previousText : "";
|
||||
const next = typeof nextText === "string" ? nextText : "";
|
||||
if (!next) {
|
||||
return previous;
|
||||
}
|
||||
if (!previous || next === previous) {
|
||||
return next;
|
||||
}
|
||||
if (next.startsWith(previous) || next.includes(previous)) {
|
||||
return next;
|
||||
}
|
||||
if (previous.startsWith(next) || previous.includes(next)) {
|
||||
return previous;
|
||||
}
|
||||
const maxOverlap = Math.min(previous.length, next.length);
|
||||
for (let overlap = maxOverlap; overlap > 0; overlap -= 1) {
|
||||
if (previous.slice(-overlap) === next.slice(0, overlap)) {
|
||||
return `${previous}${next.slice(overlap)}`;
|
||||
}
|
||||
}
|
||||
return `${previous}${next}`;
|
||||
}
|
||||
|
||||
vi.mock("./accounts.js", () => ({
|
||||
resolveFeishuAccount: resolveFeishuAccountMock,
|
||||
resolveFeishuRuntimeAccount: resolveFeishuAccountMock,
|
||||
|
|
@ -38,10 +65,9 @@ vi.mock("./typing.js", () => ({
|
|||
addTypingIndicator: addTypingIndicatorMock,
|
||||
removeTypingIndicator: removeTypingIndicatorMock,
|
||||
}));
|
||||
vi.mock("./streaming-card.js", async () => {
|
||||
const actual = await vi.importActual<typeof import("./streaming-card.js")>("./streaming-card.js");
|
||||
vi.mock("./streaming-card.js", () => {
|
||||
return {
|
||||
mergeStreamingText: actual.mergeStreamingText,
|
||||
mergeStreamingText,
|
||||
FeishuStreamingSession: class {
|
||||
active = false;
|
||||
start = vi.fn(async () => {
|
||||
|
|
|
|||
Loading…
Reference in New Issue