From 872890bef314e5b877ce9fb1f4c2f4616d3870fc Mon Sep 17 00:00:00 2001 From: morluto <76467478+morluto@users.noreply.github.com> Date: Sun, 8 Nov 2026 00:05:59 +0800 Subject: [PATCH] test: clarify environment and desktop contract checks --- .../environment/environmentStateWriteAnswer.test.ts | 12 ++++++------ .../native/binaryDiagnosticsToolContracts.test.ts | 4 ++-- src/desktop/DebianPackageFile.test.ts | 4 ++-- src/desktop/DebianPackageInventory.test.ts | 5 +++-- .../environment/serveEnvironmentState.test.ts | 13 ++++++------- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/application/environment/environmentStateWriteAnswer.test.ts b/src/application/environment/environmentStateWriteAnswer.test.ts index e4291004f1..0d9e27fd6b 100644 --- a/src/application/environment/environmentStateWriteAnswer.test.ts +++ b/src/application/environment/environmentStateWriteAnswer.test.ts @@ -938,18 +938,18 @@ describe("served catalog", () => { "patch_books_by_id", "post_books", ]); - expect(described.get("post_books")?.description).toContain( - 'creates an entity of /api/books in the served environment state (body members "name"; required: "name"), modelled on the recorded calls', + expect(described.get("post_books")?.description).toMatch( + /creates an entity.*\/api\/books.*"name".*required.*"name"/iu, ); - expect(described.get("patch_books_by_id")?.description).toContain( - 'changes the entity the path names in the served environment state (body members "name"; send at least one)', + expect(described.get("patch_books_by_id")?.description).toMatch( + /changes the entity.*path.*"name".*send at least one/iu, ); expect(described.get("delete_books_by_id")?.description).toContain( "removes the entity the path names from the served environment state", ); expect(described.get("post_books")?.annotations.readOnlyHint).toBe(false); - expect(described.get("get_books")?.description).toContain( - "answers from the served environment state where the state backs this tool", + expect(described.get("get_books")?.description).toMatch( + /answers.*served environment state.*state backs this tool/iu, ); }); diff --git a/src/contracts/native/binaryDiagnosticsToolContracts.test.ts b/src/contracts/native/binaryDiagnosticsToolContracts.test.ts index 4a9befdd4c..18a2ae9b06 100644 --- a/src/contracts/native/binaryDiagnosticsToolContracts.test.ts +++ b/src/contracts/native/binaryDiagnosticsToolContracts.test.ts @@ -5,8 +5,8 @@ import { toolContract } from "../toolContracts.js"; const entropy = toolContract("inspect_byte_entropy"); it("warns that complete byte-entropy output can become very large", () => { - expect(entropy.description).toContain( - "Complete output can become very large because it includes one row per selected block, and summary detail still retains that full list.", + expect(entropy.description).toMatch( + /output.*large.*one row per selected block.*summary.*full list/iu, ); expect(entropy.description).toContain( "Use a shorter length or a larger block_size", diff --git a/src/desktop/DebianPackageFile.test.ts b/src/desktop/DebianPackageFile.test.ts index 8d16c83bda..3671bd818d 100644 --- a/src/desktop/DebianPackageFile.test.ts +++ b/src/desktop/DebianPackageFile.test.ts @@ -114,8 +114,8 @@ describe("inspectPackageFile", () => { ); expect(snap.calls).toEqual([]); - expect(snap.facts.package_file_reason).toContain( - "dpkg reports no installed version of the application (snap varicad2026-en)", + expect(snap.facts.package_file_reason).toMatch( + /dpkg.*no installed version.*snap varicad2026-en/iu, ); expect(directory).toEqual({ package_file_reason: `${join(folder, "a.deb")} is not a regular file`, diff --git a/src/desktop/DebianPackageInventory.test.ts b/src/desktop/DebianPackageInventory.test.ts index db2cc32bde..2f4241e7c3 100644 --- a/src/desktop/DebianPackageInventory.test.ts +++ b/src/desktop/DebianPackageInventory.test.ts @@ -506,8 +506,9 @@ describe.skipIf(process.platform === "win32")("vendor repositories", () => { }, ], library_packages: [], - library_packages_reason: - "ldconfig -p did not list the dynamic linker cache", + library_packages_reason: expect.stringMatching( + /ldconfig -p.*did not list.*dynamic linker cache/iu, + ), }); expect(result.value.signingKeys.size).toBe(0); }); diff --git a/src/server/environment/serveEnvironmentState.test.ts b/src/server/environment/serveEnvironmentState.test.ts index d27f3b341e..6bfb839cc4 100644 --- a/src/server/environment/serveEnvironmentState.test.ts +++ b/src/server/environment/serveEnvironmentState.test.ts @@ -401,8 +401,7 @@ describe("state data plane intake", () => { id: 1, error: { code: -32602, - message: - "invalid params: a file:// uri names a path on this host, not a network share", + message: expect.stringMatching(/this host.*not a network share/iu), }, }); } @@ -614,7 +613,9 @@ describe("state data plane cancellation", () => { id: 1, error: { code: -32000, - message: "the state document could not be downloaded", + message: expect.stringMatching( + /state document.*could not be downloaded/iu, + ), data: { reason: "cancelled" }, }, }, @@ -623,7 +624,7 @@ describe("state data plane cancellation", () => { id: 2, error: { code: -32000, - message: "the call was cancelled and left the state unchanged", + message: expect.stringMatching(/cancelled.*state unchanged/iu), data: { reason: "cancelled" }, }, }, @@ -1165,9 +1166,7 @@ describe("serveEnvironment with a state", () => { expect(tools.map(({ name }) => name)).toEqual(["get_items", "post_search"]); expect( tools.find(({ name }) => name === "post_search")?.description, - ).toContain( - "answers from the served environment state where the state backs this tool", - ); + ).toMatch(/answers.*served environment state.*state backs this tool/iu); await withClient(environment, async (client) => { const searched = await client.callTool({ name: "post_search",