mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 15:04:33 +00:00
test(gateway): use lightweight clears for hook cron run fences
This commit is contained in:
@@ -40,7 +40,7 @@ describe("gateway server hooks", () => {
|
|||||||
expect(wakeEvents.some((e) => e.includes("Ping"))).toBe(true);
|
expect(wakeEvents.some((e) => e.includes("Ping"))).toBe(true);
|
||||||
drainSystemEvents(resolveMainKey());
|
drainSystemEvents(resolveMainKey());
|
||||||
|
|
||||||
cronIsolatedRun.mockReset();
|
cronIsolatedRun.mockClear();
|
||||||
cronIsolatedRun.mockResolvedValueOnce({
|
cronIsolatedRun.mockResolvedValueOnce({
|
||||||
status: "ok",
|
status: "ok",
|
||||||
summary: "done",
|
summary: "done",
|
||||||
@@ -58,7 +58,7 @@ describe("gateway server hooks", () => {
|
|||||||
expect(agentEvents.some((e) => e.includes("Hook Email: done"))).toBe(true);
|
expect(agentEvents.some((e) => e.includes("Hook Email: done"))).toBe(true);
|
||||||
drainSystemEvents(resolveMainKey());
|
drainSystemEvents(resolveMainKey());
|
||||||
|
|
||||||
cronIsolatedRun.mockReset();
|
cronIsolatedRun.mockClear();
|
||||||
cronIsolatedRun.mockResolvedValueOnce({
|
cronIsolatedRun.mockResolvedValueOnce({
|
||||||
status: "ok",
|
status: "ok",
|
||||||
summary: "done",
|
summary: "done",
|
||||||
@@ -83,7 +83,7 @@ describe("gateway server hooks", () => {
|
|||||||
expect(call?.job?.payload?.model).toBe("openai/gpt-4.1-mini");
|
expect(call?.job?.payload?.model).toBe("openai/gpt-4.1-mini");
|
||||||
drainSystemEvents(resolveMainKey());
|
drainSystemEvents(resolveMainKey());
|
||||||
|
|
||||||
cronIsolatedRun.mockReset();
|
cronIsolatedRun.mockClear();
|
||||||
cronIsolatedRun.mockResolvedValueOnce({
|
cronIsolatedRun.mockResolvedValueOnce({
|
||||||
status: "ok",
|
status: "ok",
|
||||||
summary: "done",
|
summary: "done",
|
||||||
@@ -104,7 +104,7 @@ describe("gateway server hooks", () => {
|
|||||||
expect(routedCall?.job?.agentId).toBe("hooks");
|
expect(routedCall?.job?.agentId).toBe("hooks");
|
||||||
drainSystemEvents(resolveMainKey());
|
drainSystemEvents(resolveMainKey());
|
||||||
|
|
||||||
cronIsolatedRun.mockReset();
|
cronIsolatedRun.mockClear();
|
||||||
cronIsolatedRun.mockResolvedValueOnce({
|
cronIsolatedRun.mockResolvedValueOnce({
|
||||||
status: "ok",
|
status: "ok",
|
||||||
summary: "done",
|
summary: "done",
|
||||||
@@ -237,7 +237,7 @@ describe("gateway server hooks", () => {
|
|||||||
],
|
],
|
||||||
};
|
};
|
||||||
await withGatewayServer(async ({ port }) => {
|
await withGatewayServer(async ({ port }) => {
|
||||||
cronIsolatedRun.mockReset();
|
cronIsolatedRun.mockClear();
|
||||||
cronIsolatedRun.mockResolvedValue({ status: "ok", summary: "done" });
|
cronIsolatedRun.mockResolvedValue({ status: "ok", summary: "done" });
|
||||||
|
|
||||||
const defaultRoute = await fetch(`http://127.0.0.1:${port}/hooks/agent`, {
|
const defaultRoute = await fetch(`http://127.0.0.1:${port}/hooks/agent`, {
|
||||||
@@ -256,7 +256,7 @@ describe("gateway server hooks", () => {
|
|||||||
expect(defaultCall?.sessionKey).toBe("hook:ingress");
|
expect(defaultCall?.sessionKey).toBe("hook:ingress");
|
||||||
drainSystemEvents(resolveMainKey());
|
drainSystemEvents(resolveMainKey());
|
||||||
|
|
||||||
cronIsolatedRun.mockReset();
|
cronIsolatedRun.mockClear();
|
||||||
cronIsolatedRun.mockResolvedValue({ status: "ok", summary: "done" });
|
cronIsolatedRun.mockResolvedValue({ status: "ok", summary: "done" });
|
||||||
const mappedOk = await fetch(`http://127.0.0.1:${port}/hooks/mapped-ok`, {
|
const mappedOk = await fetch(`http://127.0.0.1:${port}/hooks/mapped-ok`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
@@ -317,7 +317,7 @@ describe("gateway server hooks", () => {
|
|||||||
list: [{ id: "main", default: true }, { id: "hooks" }],
|
list: [{ id: "main", default: true }, { id: "hooks" }],
|
||||||
};
|
};
|
||||||
await withGatewayServer(async ({ port }) => {
|
await withGatewayServer(async ({ port }) => {
|
||||||
cronIsolatedRun.mockReset();
|
cronIsolatedRun.mockClear();
|
||||||
cronIsolatedRun.mockResolvedValueOnce({
|
cronIsolatedRun.mockResolvedValueOnce({
|
||||||
status: "ok",
|
status: "ok",
|
||||||
summary: "done",
|
summary: "done",
|
||||||
@@ -338,7 +338,7 @@ describe("gateway server hooks", () => {
|
|||||||
expect(noAgentCall?.job?.agentId).toBeUndefined();
|
expect(noAgentCall?.job?.agentId).toBeUndefined();
|
||||||
drainSystemEvents(resolveMainKey());
|
drainSystemEvents(resolveMainKey());
|
||||||
|
|
||||||
cronIsolatedRun.mockReset();
|
cronIsolatedRun.mockClear();
|
||||||
cronIsolatedRun.mockResolvedValueOnce({
|
cronIsolatedRun.mockResolvedValueOnce({
|
||||||
status: "ok",
|
status: "ok",
|
||||||
summary: "done",
|
summary: "done",
|
||||||
|
|||||||
Reference in New Issue
Block a user