mirror of https://github.com/openclaw/openclaw.git
fix(ci): stabilize zero-delay retry and slack interaction tests
This commit is contained in:
parent
1420b3bad7
commit
eecb36eff4
|
|
@ -67,7 +67,7 @@ describe("fetchDiscord", () => {
|
|||
"/users/@me/guilds",
|
||||
"test",
|
||||
fetcher,
|
||||
{ retry: { attempts: 2, minDelayMs: 0, maxDelayMs: 0 } },
|
||||
{ retry: { attempts: 2, minDelayMs: 0, maxDelayMs: 0, jitter: 0 } },
|
||||
);
|
||||
|
||||
expect(result).toHaveLength(1);
|
||||
|
|
|
|||
|
|
@ -358,17 +358,8 @@ describe("registerSlackInteractionEvents", () => {
|
|||
expect.objectContaining({
|
||||
channel: "slack",
|
||||
data: "codex:approve:thread-1",
|
||||
interactionId: "U123:C1:100.200:123.trigger:codex:approve:thread-1",
|
||||
ctx: expect.objectContaining({
|
||||
accountId: ctx.accountId,
|
||||
conversationId: "C1",
|
||||
interactionId: "U123:C1:100.200:123.trigger:codex:approve:thread-1",
|
||||
threadId: "100.100",
|
||||
interaction: expect.objectContaining({
|
||||
actionId: "codex",
|
||||
value: "approve:thread-1",
|
||||
}),
|
||||
}),
|
||||
dedupeId: "U123:C1:100.200:123.trigger:codex:approve:thread-1",
|
||||
invoke: expect.any(Function),
|
||||
}),
|
||||
);
|
||||
expect(enqueueSystemEventMock).not.toHaveBeenCalled();
|
||||
|
|
@ -491,17 +482,17 @@ describe("registerSlackInteractionEvents", () => {
|
|||
const calls = dispatchPluginInteractiveHandlerMock.mock.calls as unknown[][];
|
||||
const firstCall = calls[0]?.[0] as
|
||||
| {
|
||||
interactionId?: string;
|
||||
dedupeId?: string;
|
||||
}
|
||||
| undefined;
|
||||
const secondCall = calls[1]?.[0] as
|
||||
| {
|
||||
interactionId?: string;
|
||||
dedupeId?: string;
|
||||
}
|
||||
| undefined;
|
||||
expect(firstCall?.interactionId).toContain(":trigger-1:");
|
||||
expect(secondCall?.interactionId).toContain(":trigger-2:");
|
||||
expect(firstCall?.interactionId).not.toBe(secondCall?.interactionId);
|
||||
expect(firstCall?.dedupeId).toContain(":trigger-1:");
|
||||
expect(secondCall?.dedupeId).toContain(":trigger-2:");
|
||||
expect(firstCall?.dedupeId).not.toBe(secondCall?.dedupeId);
|
||||
});
|
||||
|
||||
it("resolves plugin binding approvals from shared interactive Slack actions", async () => {
|
||||
|
|
|
|||
|
|
@ -162,6 +162,19 @@ describe("retryAsync", () => {
|
|||
);
|
||||
});
|
||||
|
||||
it("retries immediately when the resolved delay is zero", async () => {
|
||||
const fn = vi.fn().mockRejectedValueOnce(new Error("boom")).mockResolvedValueOnce("ok");
|
||||
await expect(
|
||||
retryAsync(fn, {
|
||||
attempts: 2,
|
||||
minDelayMs: 0,
|
||||
maxDelayMs: 0,
|
||||
jitter: 0,
|
||||
}),
|
||||
).resolves.toBe("ok");
|
||||
expect(fn).toHaveBeenCalledTimes(2);
|
||||
});
|
||||
|
||||
it("clamps attempts to at least 1", async () => {
|
||||
const fn = vi.fn().mockRejectedValue(new Error("boom"));
|
||||
await expect(retryAsync(fn, { attempts: 0, minDelayMs: 0, maxDelayMs: 0 })).rejects.toThrow(
|
||||
|
|
|
|||
|
|
@ -129,7 +129,9 @@ export async function retryAsync<T>(
|
|||
err,
|
||||
label: options.label,
|
||||
});
|
||||
await sleep(delay);
|
||||
if (delay > 0) {
|
||||
await sleep(delay);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue