






























@@ -64,14 +64,11 @@ function expectTargetsToContainStores(
6464targets: Array<{ agentId: string; storePath: string }>,
6565stores: Record<string, string>,
6666): void {
67-expect(targets).toEqual(
68-expect.arrayContaining(
69-Object.entries(stores).map(([agentId, storePath]) => ({
70- agentId,
71- storePath,
72-})),
73-),
74-);
67+for (const [agentId, storePath] of Object.entries(stores)) {
68+expect(
69+targets.some((target) => target.agentId === agentId && target.storePath === storePath),
70+).toBe(true);
71+}
7572}
76737774const discoveryResolvers = [
@@ -216,14 +213,12 @@ describe("resolveAllAgentSessionStoreTargets", () => {
216213"Retired Agent",
217214]);
218215219-expect(targets).toEqual(
220-expect.arrayContaining([
221-expect.objectContaining({
222-agentId: "retired-agent",
223-storePath: storePaths["Retired Agent"],
224-}),
225-]),
226-);
216+expect(
217+targets.some(
218+(target) =>
219+target.agentId === "retired-agent" && target.storePath === storePaths["Retired Agent"],
220+),
221+).toBe(true);
227222});
228223});
229224@@ -247,18 +242,14 @@ describe("resolveAllAgentSessionStoreTargets", () => {
247242248243const targets = await resolveAllAgentSessionStoreTargets(cfg, { env });
249244250-expect(targets).toEqual(
251-expect.arrayContaining([
252-{
253-agentId: "main",
254-storePath: mainStorePath,
255-},
256-{
257-agentId: "retired",
258-storePath: retiredStorePath,
259-},
260-]),
261-);
245+expect(
246+targets.some((target) => target.agentId === "main" && target.storePath === mainStorePath),
247+).toBe(true);
248+expect(
249+targets.some(
250+(target) => target.agentId === "retired" && target.storePath === retiredStorePath,
251+),
252+).toBe(true);
262253});
263254});
264255@@ -277,14 +268,12 @@ describe("resolveAllAgentSessionStoreTargets", () => {
277268OPENCLAW_STATE_DIR: envStateDir,
278269};
279270280-await expect(resolver.resolve(cfg, env)).resolves.toEqual(
281-expect.arrayContaining([
282-{
283-agentId: "retired",
284-storePath: storePaths.retired,
285-},
286-]),
287-);
271+const targets = await resolver.resolve(cfg, env);
272+expect(
273+targets.some(
274+(target) => target.agentId === "retired" && target.storePath === storePaths.retired,
275+),
276+).toBe(true);
288277});
289278});
290279@@ -301,10 +290,12 @@ describe("resolveAllAgentSessionStoreTargets", () => {
301290await fs.symlink(leakedFile, path.join(opsSessionsDir, "sessions.json"));
302291303292const targets = await resolver.resolve(createCustomRootCfg(customRoot), process.env);
304-expect(targets).not.toContainEqual({
305-agentId: "ops",
306-storePath: expect.stringContaining(path.join("ops", "sessions", "sessions.json")),
307-});
293+const symlinkStoreSuffix = path.join("ops", "sessions", "sessions.json");
294+expect(
295+targets.some(
296+(target) => target.agentId === "ops" && target.storePath.includes(symlinkStoreSuffix),
297+),
298+).toBe(false);
308299});
309300});
310301}
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。