Skip to content

Commit cb86388

Browse files
committed
test: tighten plugin context assertions
1 parent 59b88e4 commit cb86388

1 file changed

Lines changed: 21 additions & 53 deletions

File tree

‎src/agents/openclaw-tools.plugin-context.test.ts‎

Lines changed: 21 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,8 @@ describe("openclaw plugin tool context", () => {
1414
},
1515
});
1616

17-
expect(result.context).toEqual(
18-
expect.objectContaining({
19-
requesterSenderId: "trusted-sender",
20-
senderIsOwner: true,
21-
}),
22-
);
17+
expect(result.context.requesterSenderId).toBe("trusted-sender");
18+
expect(result.context.senderIsOwner).toBe(true);
2319
});
2420

2521
it("forwards fs policy for plugin tool sandbox enforcement", () => {
@@ -30,11 +26,7 @@ describe("openclaw plugin tool context", () => {
3026
},
3127
});
3228

33-
expect(result.context).toEqual(
34-
expect.objectContaining({
35-
fsPolicy: { workspaceOnly: true },
36-
}),
37-
);
29+
expect(result.context.fsPolicy).toStrictEqual({ workspaceOnly: true });
3830
});
3931

4032
it("forwards ephemeral sessionId", () => {
@@ -46,12 +38,8 @@ describe("openclaw plugin tool context", () => {
4638
},
4739
});
4840

49-
expect(result.context).toEqual(
50-
expect.objectContaining({
51-
sessionKey: "agent:main:telegram:direct:12345",
52-
sessionId: "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
53-
}),
54-
);
41+
expect(result.context.sessionKey).toBe("agent:main:telegram:direct:12345");
42+
expect(result.context.sessionId).toBe("a1b2c3d4-e5f6-7890-abcd-ef1234567890");
5543
});
5644

5745
it("infers the default agent workspace when workspaceDir is omitted", () => {
@@ -74,12 +62,8 @@ describe("openclaw plugin tool context", () => {
7462
} as never,
7563
});
7664

77-
expect(result.context).toEqual(
78-
expect.objectContaining({
79-
agentId: "main",
80-
workspaceDir,
81-
}),
82-
);
65+
expect(result.context.agentId).toBe("main");
66+
expect(result.context.workspaceDir).toBe(workspaceDir);
8367
});
8468

8569
it("infers the session agent workspace when workspaceDir is omitted", () => {
@@ -101,12 +85,8 @@ describe("openclaw plugin tool context", () => {
10185
resolvedConfig: config,
10286
});
10387

104-
expect(result.context).toEqual(
105-
expect.objectContaining({
106-
agentId: "support",
107-
workspaceDir: supportWorkspace,
108-
}),
109-
);
88+
expect(result.context.agentId).toBe("support");
89+
expect(result.context.workspaceDir).toBe(supportWorkspace);
11090
});
11191

11292
it("uses requester agent override for synthetic embedded session keys", () => {
@@ -129,12 +109,8 @@ describe("openclaw plugin tool context", () => {
129109
resolvedConfig: config,
130110
});
131111

132-
expect(result.context).toEqual(
133-
expect.objectContaining({
134-
agentId: "recall",
135-
workspaceDir: recallWorkspace,
136-
}),
137-
);
112+
expect(result.context.agentId).toBe("recall");
113+
expect(result.context.workspaceDir).toBe(recallWorkspace);
138114
});
139115

140116
it("forwards browser session wiring", () => {
@@ -146,14 +122,10 @@ describe("openclaw plugin tool context", () => {
146122
},
147123
});
148124

149-
expect(result.context).toEqual(
150-
expect.objectContaining({
151-
browser: {
152-
sandboxBridgeUrl: "http://127.0.0.1:9999",
153-
allowHostControl: true,
154-
},
155-
}),
156-
);
125+
expect(result.context.browser).toStrictEqual({
126+
sandboxBridgeUrl: "http://127.0.0.1:9999",
127+
allowHostControl: true,
128+
});
157129
});
158130

159131
it("forwards gateway subagent binding", () => {
@@ -178,16 +150,12 @@ describe("openclaw plugin tool context", () => {
178150
},
179151
});
180152

181-
expect(result.context).toEqual(
182-
expect.objectContaining({
183-
deliveryContext: {
184-
channel: "slack",
185-
to: "channel:C123",
186-
accountId: "work",
187-
threadId: "1710000000.000100",
188-
},
189-
}),
190-
);
153+
expect(result.context.deliveryContext).toStrictEqual({
154+
channel: "slack",
155+
to: "channel:C123",
156+
accountId: "work",
157+
threadId: "1710000000.000100",
158+
});
191159
});
192160

193161
it("does not inject ambient thread defaults into plugin tools", async () => {

0 commit comments

Comments
 (0)