From 32b520b2a4f3fee65adf52c28d9d31c9d4ec5f82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E6=A9=98?= Date: Wed, 3 Jun 2026 06:16:33 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20vitest=20=E8=BF=81?= =?UTF-8?q?=E7=A7=BB=E5=90=8E=E6=B5=8B=E8=AF=95=E5=A4=B1=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - async 函数断言改用 await expect().rejects.toThrow() - 所有局部 runCli 从 tsx 改为 node - rest params (...args) 改为 array params (args) - 更新 snapshots 36/36 files pass, 617/617 tests pass Fixes #64 --- .../__snapshots__/edge-cases.test.ts.snap | 579 ++++++++++++++++-- .../tests/__snapshots__/render.test.ts.snap | 4 + packages/cli/tests/alias.test.ts | 2 +- packages/cli/tests/edge-cases.test.ts | 16 +- packages/cli/tests/gc.test.ts | 6 +- packages/cli/tests/get-tag-info.test.ts | 2 +- packages/cli/tests/list-pagination.test.ts | 2 +- packages/cli/tests/list-tag-filter.test.ts | 4 +- packages/cli/tests/pipe.test.ts | 6 +- packages/cli/tests/put-get-has.test.ts | 2 +- packages/cli/tests/render.test.ts | 6 +- packages/cli/tests/schema-validation.test.ts | 6 +- packages/cli/tests/tag-untag.test.ts | 2 +- packages/cli/tests/template.test.ts | 2 +- packages/cli/tests/variable-history.test.ts | 2 +- packages/cli/tests/variable.test.ts | 4 +- packages/cli/tests/verify-refs-walk.test.ts | 2 +- packages/core/src/liquid-render.test.ts | 16 +- packages/core/tests/schema-validation.test.ts | 68 +- 19 files changed, 601 insertions(+), 130 deletions(-) diff --git a/packages/cli/tests/__snapshots__/edge-cases.test.ts.snap b/packages/cli/tests/__snapshots__/edge-cases.test.ts.snap index cb917d0..f0e1358 100644 --- a/packages/cli/tests/__snapshots__/edge-cases.test.ts.snap +++ b/packages/cli/tests/__snapshots__/edge-cases.test.ts.snap @@ -1,5 +1,528 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html +exports[`Phase 3: Variable System > 3.1 var set creates variable 1`] = ` +{ + "type": "0Q5EMYK4SYSS9", + "value": { + "labels": [], + "name": "@myapp/config", + "schema": "FRBAB1BF0ZBCS", + "tags": {}, + "value": "9W3MGR3184QYE", + }, +} +`; + +exports[`Phase 3: Variable System > 3.2 var get returns variable 1`] = ` +{ + "type": "F5RRJTXP8Z99D", + "value": { + "labels": [], + "name": "@myapp/config", + "schema": "FRBAB1BF0ZBCS", + "tags": {}, + "value": "9W3MGR3184QYE", + }, +} +`; + +exports[`Phase 3: Variable System > 3.3 var list shows all variables 1`] = ` +{ + "type": "AF0XACGXHPMC1", + "value": [ + { + "labels": [], + "name": "@myapp/config", + "schema": "FRBAB1BF0ZBCS", + "tags": {}, + "value": "9W3MGR3184QYE", + }, + { + "labels": [], + "name": "@ocas/array", + "schema": "CTS5P6RD8HMCS", + "tags": {}, + "value": "D45CW047XS17Y", + }, + { + "labels": [], + "name": "@ocas/bool", + "schema": "CTS5P6RD8HMCS", + "tags": {}, + "value": "1AVHCXEJVDCPP", + }, + { + "labels": [], + "name": "@ocas/boolean", + "schema": "CTS5P6RD8HMCS", + "tags": {}, + "value": "1AVHCXEJVDCPP", + }, + { + "labels": [], + "name": "@ocas/integer", + "schema": "CTS5P6RD8HMCS", + "tags": {}, + "value": "B26JM4PBHPAFK", + }, + { + "labels": [], + "name": "@ocas/null", + "schema": "CTS5P6RD8HMCS", + "tags": {}, + "value": "8E33KAS0HMAZ7", + }, + { + "labels": [], + "name": "@ocas/number", + "schema": "CTS5P6RD8HMCS", + "tags": {}, + "value": "BEAZQGKVXMZT8", + }, + { + "labels": [], + "name": "@ocas/object", + "schema": "CTS5P6RD8HMCS", + "tags": {}, + "value": "944RT37WX1PQ5", + }, + { + "labels": [], + "name": "@ocas/output/gc", + "schema": "CTS5P6RD8HMCS", + "tags": {}, + "value": "7KHZTY010988K", + }, + { + "labels": [], + "name": "@ocas/output/get", + "schema": "CTS5P6RD8HMCS", + "tags": {}, + "value": "7V5G8E2VW8B2G", + }, + { + "labels": [], + "name": "@ocas/output/has", + "schema": "CTS5P6RD8HMCS", + "tags": {}, + "value": "FHXQQZMVHW924", + }, + { + "labels": [], + "name": "@ocas/output/hash", + "schema": "CTS5P6RD8HMCS", + "tags": {}, + "value": "1B24CBF95Q5G6", + }, + { + "labels": [], + "name": "@ocas/output/list", + "schema": "CTS5P6RD8HMCS", + "tags": {}, + "value": "7BWZ3JKKMSH4N", + }, + { + "labels": [], + "name": "@ocas/output/list-meta", + "schema": "CTS5P6RD8HMCS", + "tags": {}, + "value": "1WQ7C0EV8QGA4", + }, + { + "labels": [], + "name": "@ocas/output/list-schema", + "schema": "CTS5P6RD8HMCS", + "tags": {}, + "value": "7FYGS2KQ3REM9", + }, + { + "labels": [], + "name": "@ocas/output/put", + "schema": "CTS5P6RD8HMCS", + "tags": {}, + "value": "4ZHWK21APCFZ5", + }, + { + "labels": [], + "name": "@ocas/output/refs", + "schema": "CTS5P6RD8HMCS", + "tags": {}, + "value": "2TKP4RGBJ4V43", + }, + { + "labels": [], + "name": "@ocas/output/tag", + "schema": "CTS5P6RD8HMCS", + "tags": {}, + "value": "CPSWA9TB2JMWP", + }, + { + "labels": [], + "name": "@ocas/output/template-delete", + "schema": "CTS5P6RD8HMCS", + "tags": {}, + "value": "BY7BGZJND3N7R", + }, + { + "labels": [], + "name": "@ocas/output/template-get", + "schema": "CTS5P6RD8HMCS", + "tags": {}, + "value": "0B0HBHZGYHR84", + }, + { + "labels": [], + "name": "@ocas/output/template-list", + "schema": "CTS5P6RD8HMCS", + "tags": {}, + "value": "8917JQTD1R5JF", + }, + { + "labels": [], + "name": "@ocas/output/template-set", + "schema": "CTS5P6RD8HMCS", + "tags": {}, + "value": "BJDHPAE4Q8TXM", + }, + { + "labels": [], + "name": "@ocas/output/untag", + "schema": "CTS5P6RD8HMCS", + "tags": {}, + "value": "BPEQMRQNJK80Z", + }, + { + "labels": [], + "name": "@ocas/output/var-delete", + "schema": "CTS5P6RD8HMCS", + "tags": {}, + "value": "C3MYPR5RGQFZT", + }, + { + "labels": [], + "name": "@ocas/output/var-get", + "schema": "CTS5P6RD8HMCS", + "tags": {}, + "value": "F5RRJTXP8Z99D", + }, + { + "labels": [], + "name": "@ocas/output/var-history", + "schema": "CTS5P6RD8HMCS", + "tags": {}, + "value": "EVZJS80TRFKE1", + }, + { + "labels": [], + "name": "@ocas/output/var-list", + "schema": "CTS5P6RD8HMCS", + "tags": {}, + "value": "AF0XACGXHPMC1", + }, + { + "labels": [], + "name": "@ocas/output/var-set", + "schema": "CTS5P6RD8HMCS", + "tags": {}, + "value": "0Q5EMYK4SYSS9", + }, + { + "labels": [], + "name": "@ocas/output/verify", + "schema": "CTS5P6RD8HMCS", + "tags": {}, + "value": "52HEFB52BD0GF", + }, + { + "labels": [], + "name": "@ocas/output/walk", + "schema": "CTS5P6RD8HMCS", + "tags": {}, + "value": "4HG6MD3XG5H5C", + }, + { + "labels": [], + "name": "@ocas/schema", + "schema": "CTS5P6RD8HMCS", + "tags": {}, + "value": "CTS5P6RD8HMCS", + }, + { + "labels": [], + "name": "@ocas/string", + "schema": "CTS5P6RD8HMCS", + "tags": {}, + "value": "7VQ43ZSJTEWA7", + }, + ], +} +`; + +exports[`Phase 3: Variable System > 3.4 var list prefix filters by prefix 1`] = ` +{ + "type": "AF0XACGXHPMC1", + "value": [ + { + "labels": [], + "name": "@myapp/config", + "schema": "FRBAB1BF0ZBCS", + "tags": {}, + "value": "9W3MGR3184QYE", + }, + ], +} +`; + +exports[`Phase 3: Variable System > 3.5 var set upsert updates existing variable 1`] = ` +{ + "type": "0Q5EMYK4SYSS9", + "value": { + "labels": [], + "name": "@myapp/config", + "schema": "FRBAB1BF0ZBCS", + "tags": {}, + "value": "A6QPKJAFR68NP", + }, +} +`; + +exports[`Phase 3: Variable System > 3.6 var set with tag and label adds them 1`] = ` +{ + "type": "0Q5EMYK4SYSS9", + "value": { + "labels": [ + "important", + ], + "name": "@myapp/config", + "schema": "FRBAB1BF0ZBCS", + "tags": { + "env": "prod", + }, + "value": "9W3MGR3184QYE", + }, +} +`; + +exports[`Phase 3: Variable System > 3.7 var list --tag env:prod filters by kv tag 1`] = ` +{ + "type": "AF0XACGXHPMC1", + "value": [ + { + "labels": [ + "important", + ], + "name": "@myapp/config", + "schema": "FRBAB1BF0ZBCS", + "tags": { + "env": "prod", + }, + "value": "9W3MGR3184QYE", + }, + ], +} +`; + +exports[`Phase 3: Variable System > 3.8 var list --tag important filters by label 1`] = ` +{ + "type": "AF0XACGXHPMC1", + "value": [ + { + "labels": [ + "important", + ], + "name": "@myapp/config", + "schema": "FRBAB1BF0ZBCS", + "tags": { + "env": "prod", + }, + "value": "9W3MGR3184QYE", + }, + ], +} +`; + +exports[`Phase 3: Variable System > 3.9 var set without label removes it 1`] = ` +{ + "type": "0Q5EMYK4SYSS9", + "value": { + "labels": [], + "name": "@myapp/config", + "schema": "FRBAB1BF0ZBCS", + "tags": { + "env": "prod", + }, + "value": "9W3MGR3184QYE", + }, +} +`; + +exports[`Phase 3: Variable System > 3.10 var delete removes variable 1`] = ` +{ + "type": "C3MYPR5RGQFZT", + "value": [ + { + "labels": [], + "name": "@myapp/config", + "schema": "FRBAB1BF0ZBCS", + "tags": { + "env": "prod", + }, + "value": "9W3MGR3184QYE", + }, + ], +} +`; + +exports[`Phase 3: Variable System > 3.11 var get deleted variable returns not found 1`] = `"Error: Variable not found: name=@myapp/config, schema=FRBAB1BF0ZBCS"`; + +exports[`Phase 4: Template System > 4.1 template set registers template 1`] = ` +{ + "type": "BJDHPAE4Q8TXM", + "value": { + "contentHash": "6WW8WNB38GTTP", + "schemaHash": "FRBAB1BF0ZBCS", + }, +} +`; + +exports[`Phase 4: Template System > 4.2 template get returns template text 1`] = ` +{ + "type": "0B0HBHZGYHR84", + "value": "Name: {{ payload.name }}, Age: {{ payload.age }}", +} +`; + +exports[`Phase 4: Template System > 4.3 template list shows registered templates 1`] = ` +{ + "type": "8917JQTD1R5JF", + "value": [ + { + "contentHash": "6WW8WNB38GTTP", + "schemaHash": "FRBAB1BF0ZBCS", + }, + ], +} +`; + +exports[`Phase 4: Template System > 4.4 template delete removes template 1`] = ` +{ + "type": "BY7BGZJND3N7R", + "value": { + "deleted": true, + }, +} +`; + +exports[`Phase 4: Template System > 4.5 template get deleted template returns not found 1`] = `"Error: Template not found for schema: FRBAB1BF0ZBCS"`; + +exports[`Phase 7: Edge Cases > 7.1 get non-existent hash errors gracefully 1`] = `"Node not found: AAAAAAAAAAAAA"`; + +exports[`Phase 7: Edge Cases > 7.3 var set empty name errors 1`] = `"Usage: ocas var set [--tag ...]"`; + +exports[`Phase 7: Edge Cases > 7.4 var set name with invalid chars errors 1`] = `"Error: Invalid variable name "invalid name!": Name must follow @scope/name format (e.g. @myapp/config)"`; + +exports[`Phase 7: Edge Cases > 7.5 no subcommand shows help text 1`] = ` +"Usage: ocas [--home ] [--json] [args] + +All JSON commands emit a { type, value } envelope. The type is the hash of the +command's @ocas/output/* schema (shown in parentheses); pipe any envelope into +\`render -p\` to render its value (ocas_ref hashes are expanded). + +Commands: + put Store node, print envelope (value=hash) (@ocas/output/put) + get Print node as envelope (@ocas/output/get) + has Print envelope (value=boolean) (@ocas/output/has) + verify Verify integrity + schema (value=ok/corrupted/invalid) (@ocas/output/verify) + refs List direct ocas_ref edges (@ocas/output/refs) + walk [--format tree] Recursive traversal (@ocas/output/walk) + hash Compute hash without storing (@ocas/output/hash) + render [options] Render node as text with resolution decay (raw output) + render --pipe/-p [options] Render { type, value } from stdin (raw output) + list --type [--tag ...] List hashes for a type, optionally filtered by tags (@ocas/output/list) + list-meta List meta-schema hashes (value=string[]) (@ocas/output/list-meta) + list-schema List all schema hashes (value=string[]) (@ocas/output/list-schema) + tag ... Apply tags/labels to a target (@ocas/output/tag) + untag ... Remove tags/labels from a target (@ocas/output/untag) + var set [--tag ...] Create/update a variable (@ocas/output/var-set) + var get --schema Get a variable by name + schema (@ocas/output/var-get) + var delete [--schema ] Delete variable(s) (@ocas/output/var-delete) + var list [prefix] [--schema ] [--tag ...] List variables (@ocas/output/var-list) + var history [--schema ] Show value history (LRU) (@ocas/output/var-history) + template set | --inline Set template for schema (@ocas/output/template-set) + template get Get template content (value=string) (@ocas/output/template-get) + template list List all templates (@ocas/output/template-list) + template delete Delete template for schema (@ocas/output/template-delete) + gc Run garbage collection (@ocas/output/gc) + +Flags: + --home Store directory (default: $OCAS_HOME or ~/.ocas) + --json Compact JSON output + --render, -r Render output inline (equivalent to | ocas render -p) + --schema Schema hash filter for var get/delete/tag/list + --tag Tag/label (can be repeated): key:value (tag), name (label), :name (delete) + --inline Inline text content for template set + --resolution Initial resolution for render (default: 1.0) + --decay Decay factor for render (default: 0.5) + --epsilon Cutoff threshold for render (default: 0.01) + --pipe, -p Read from stdin (put/hash: raw JSON payload; render: { type, value } envelope) + +Agent: If you have not installed the ocas skill for this version (0.2.0), run \`ocas prompt setup\` and follow the instructions." +`; + +exports[`Phase 7: Edge Cases 7.1 get non-existent hash errors gracefully 1`] = `"Node not found: AAAAAAAAAAAAA"`; + +exports[`Phase 7: Edge Cases 7.3 var set empty name errors 1`] = `"Usage: ocas var set [--tag ...]"`; + +exports[`Phase 7: Edge Cases 7.4 var set name with invalid chars errors 1`] = `"Error: Invalid variable name "invalid name!": Name must follow @scope/name format (e.g. @myapp/config)"`; + +exports[`Phase 7: Edge Cases 7.5 no subcommand shows help text 1`] = ` +"Usage: ocas [--home ] [--json] [args] + +All JSON commands emit a { type, value } envelope. The type is the hash of the +command's @ocas/output/* schema (shown in parentheses); pipe any envelope into +\`render -p\` to render its value (ocas_ref hashes are expanded). + +Commands: + put Store node, print envelope (value=hash) (@ocas/output/put) + get Print node as envelope (@ocas/output/get) + has Print envelope (value=boolean) (@ocas/output/has) + verify Verify integrity + schema (value=ok/corrupted/invalid) (@ocas/output/verify) + refs List direct ocas_ref edges (@ocas/output/refs) + walk [--format tree] Recursive traversal (@ocas/output/walk) + hash Compute hash without storing (@ocas/output/hash) + render [options] Render node as text with resolution decay (raw output) + render --pipe/-p [options] Render { type, value } from stdin (raw output) + list --type [--tag ...] List hashes for a type, optionally filtered by tags (@ocas/output/list) + list-meta List meta-schema hashes (value=string[]) (@ocas/output/list-meta) + list-schema List all schema hashes (value=string[]) (@ocas/output/list-schema) + tag ... Apply tags/labels to a target (@ocas/output/tag) + untag ... Remove tags/labels from a target (@ocas/output/untag) + var set [--tag ...] Create/update a variable (@ocas/output/var-set) + var get --schema Get a variable by name + schema (@ocas/output/var-get) + var delete [--schema ] Delete variable(s) (@ocas/output/var-delete) + var list [prefix] [--schema ] [--tag ...] List variables (@ocas/output/var-list) + var history [--schema ] Show value history (LRU) (@ocas/output/var-history) + template set | --inline Set template for schema (@ocas/output/template-set) + template get Get template content (value=string) (@ocas/output/template-get) + template list List all templates (@ocas/output/template-list) + template delete Delete template for schema (@ocas/output/template-delete) + gc Run garbage collection (@ocas/output/gc) + +Flags: + --home Store directory (default: $OCAS_HOME or ~/.ocas) + --json Compact JSON output + --render, -r Render output inline (equivalent to | ocas render -p) + --schema Schema hash filter for var get/delete/tag/list + --tag Tag/label (can be repeated): key:value (tag), name (label), :name (delete) + --inline Inline text content for template set + --resolution Initial resolution for render (default: 1.0) + --decay Decay factor for render (default: 0.5) + --epsilon Cutoff threshold for render (default: 0.01) + --pipe, -p Read from stdin (put/hash: raw JSON payload; render: { type, value } envelope) + +Agent: If you have not installed the ocas skill for this version (0.2.0), run \`ocas prompt setup\` and follow the instructions." +`; + exports[`Phase 3: Variable System 3.1 var set creates variable 1`] = ` { "type": "0Q5EMYK4SYSS9", @@ -375,8 +898,6 @@ exports[`Phase 3: Variable System 3.10 var delete removes variable 1`] = ` exports[`Phase 3: Variable System 3.11 var get deleted variable returns not found 1`] = `"Error: Variable not found: name=@myapp/config, schema=FRBAB1BF0ZBCS"`; -exports[`Phase 4: Template System > 4.5 template get deleted template returns not found 1`] = `"Unknown command: template,get,FRBAB1BF0ZBCS"`; - exports[`Phase 4: Template System 4.1 template set registers template 1`] = ` { "type": "BJDHPAE4Q8TXM", @@ -416,57 +937,3 @@ exports[`Phase 4: Template System 4.4 template delete removes template 1`] = ` `; exports[`Phase 4: Template System 4.5 template get deleted template returns not found 1`] = `"Error: Template not found for schema: FRBAB1BF0ZBCS"`; - -exports[`Phase 7: Edge Cases 7.1 get non-existent hash errors gracefully 1`] = `"Node not found: AAAAAAAAAAAAA"`; - -exports[`Phase 7: Edge Cases 7.3 var set empty name errors 1`] = `"Usage: ocas var set [--tag ...]"`; - -exports[`Phase 7: Edge Cases 7.4 var set name with invalid chars errors 1`] = `"Error: Invalid variable name "invalid name!": Name must follow @scope/name format (e.g. @myapp/config)"`; - -exports[`Phase 7: Edge Cases 7.5 no subcommand shows help text 1`] = ` -"Usage: ocas [--home ] [--json] [args] - -All JSON commands emit a { type, value } envelope. The type is the hash of the -command's @ocas/output/* schema (shown in parentheses); pipe any envelope into -\`render -p\` to render its value (ocas_ref hashes are expanded). - -Commands: - put Store node, print envelope (value=hash) (@ocas/output/put) - get Print node as envelope (@ocas/output/get) - has Print envelope (value=boolean) (@ocas/output/has) - verify Verify integrity + schema (value=ok/corrupted/invalid) (@ocas/output/verify) - refs List direct ocas_ref edges (@ocas/output/refs) - walk [--format tree] Recursive traversal (@ocas/output/walk) - hash Compute hash without storing (@ocas/output/hash) - render [options] Render node as text with resolution decay (raw output) - render --pipe/-p [options] Render { type, value } from stdin (raw output) - list --type [--tag ...] List hashes for a type, optionally filtered by tags (@ocas/output/list) - list-meta List meta-schema hashes (value=string[]) (@ocas/output/list-meta) - list-schema List all schema hashes (value=string[]) (@ocas/output/list-schema) - tag ... Apply tags/labels to a target (@ocas/output/tag) - untag ... Remove tags/labels from a target (@ocas/output/untag) - var set [--tag ...] Create/update a variable (@ocas/output/var-set) - var get --schema Get a variable by name + schema (@ocas/output/var-get) - var delete [--schema ] Delete variable(s) (@ocas/output/var-delete) - var list [prefix] [--schema ] [--tag ...] List variables (@ocas/output/var-list) - var history [--schema ] Show value history (LRU) (@ocas/output/var-history) - template set | --inline Set template for schema (@ocas/output/template-set) - template get Get template content (value=string) (@ocas/output/template-get) - template list List all templates (@ocas/output/template-list) - template delete Delete template for schema (@ocas/output/template-delete) - gc Run garbage collection (@ocas/output/gc) - -Flags: - --home Store directory (default: $OCAS_HOME or ~/.ocas) - --json Compact JSON output - --render, -r Render output inline (equivalent to | ocas render -p) - --schema Schema hash filter for var get/delete/tag/list - --tag Tag/label (can be repeated): key:value (tag), name (label), :name (delete) - --inline Inline text content for template set - --resolution Initial resolution for render (default: 1.0) - --decay Decay factor for render (default: 0.5) - --epsilon Cutoff threshold for render (default: 0.01) - --pipe, -p Read from stdin (put/hash: raw JSON payload; render: { type, value } envelope) - -Agent: If you have not installed the ocas skill for this version (0.2.0), run \`ocas prompt setup\` and follow the instructions." -`; diff --git a/packages/cli/tests/__snapshots__/render.test.ts.snap b/packages/cli/tests/__snapshots__/render.test.ts.snap index 99c5c23..77bc4d9 100644 --- a/packages/cli/tests/__snapshots__/render.test.ts.snap +++ b/packages/cli/tests/__snapshots__/render.test.ts.snap @@ -1,5 +1,9 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html +exports[`Phase 5: Render > 5.1 render fills payload variables 1`] = `"Hello Alice!"`; + +exports[`Phase 5: Render > 5.2 render --resolution with different value 1`] = `"Hello Alice!"`; + exports[`Phase 5: Render 5.1 render fills payload variables 1`] = `"Hello Alice!"`; exports[`Phase 5: Render 5.2 render --resolution with different value 1`] = `"Hello Alice!"`; diff --git a/packages/cli/tests/alias.test.ts b/packages/cli/tests/alias.test.ts index da4b3b3..dc04ef5 100644 --- a/packages/cli/tests/alias.test.ts +++ b/packages/cli/tests/alias.test.ts @@ -37,7 +37,7 @@ afterEach(() => { */ function runCliAlias(...args: string[]): { stdout: string; stderr: string; exitCode: number } { try { - const stdout = execFileSync("tsx", [cliPath, "--home", storePath, ...args], { + const stdout = execFileSync("node", [cliPath, "--home", storePath, ...args], { encoding: "utf-8", timeout: 10000, }); diff --git a/packages/cli/tests/edge-cases.test.ts b/packages/cli/tests/edge-cases.test.ts index 57beec8..7d6b8ce 100644 --- a/packages/cli/tests/edge-cases.test.ts +++ b/packages/cli/tests/edge-cases.test.ts @@ -24,7 +24,7 @@ describe("ocas binary", () => { }); test("T3: ocas command is executable and shows help", () => { - const stdout = execFileSync("tsx", [entrypoint, "--help"], { + const stdout = execFileSync("node", [entrypoint, "--help"], { encoding: "utf-8", timeout: 10000, }); @@ -39,9 +39,9 @@ describe("Phase 7: Edge Cases", () => { let typeHash: string; let nodeHash: string; - function runCli(...args: string[]): { stdout: string; stderr: string; exitCode: number } { + function runCli(args: string[]): { stdout: string; stderr: string; exitCode: number } { try { - const stdout = execFileSync("tsx", [entrypoint, "--home", tmpStore, ...args], { + const stdout = execFileSync("node", [entrypoint, "--home", tmpStore, ...args], { encoding: "utf-8", timeout: 10000, }); @@ -127,7 +127,7 @@ describe("Phase 7: Edge Cases", () => { const fileAsStore = join(tmpStore, "not-a-directory"); writeFileSync(fileAsStore, "test"); try { - execFileSync("tsx", [entrypoint, "--home", fileAsStore, "get", "AAAAAAAAAAAAA"], { + execFileSync("node", [entrypoint, "--home", fileAsStore, "get", "AAAAAAAAAAAAA"], { encoding: "utf-8", timeout: 10000, }); @@ -147,9 +147,9 @@ describe("Phase 3: Variable System", () => { let typeHash: string; let nodeHash: string; - function runCli(...args: string[]): { stdout: string; stderr: string; exitCode: number } { + function runCli(args: string[]): { stdout: string; stderr: string; exitCode: number } { try { - const stdout = execFileSync("tsx", [entrypoint, "--home", tmpStore, ...args], { + const stdout = execFileSync("node", [entrypoint, "--home", tmpStore, ...args], { encoding: "utf-8", timeout: 10000, }); @@ -336,9 +336,9 @@ describe("Phase 4: Template System", () => { let tmpStore: string; let typeHash: string; - function runCli(...args: string[]): { stdout: string; stderr: string; exitCode: number } { + function runCli(args: string[]): { stdout: string; stderr: string; exitCode: number } { try { - const stdout = execFileSync("tsx", [entrypoint, "--home", tmpStore, ...args], { + const stdout = execFileSync("node", [entrypoint, "--home", tmpStore, ...args], { encoding: "utf-8", timeout: 10000, }); diff --git a/packages/cli/tests/gc.test.ts b/packages/cli/tests/gc.test.ts index fde3bf2..1df115f 100644 --- a/packages/cli/tests/gc.test.ts +++ b/packages/cli/tests/gc.test.ts @@ -42,9 +42,9 @@ afterAll(() => { rmSync(tmpStore, { recursive: true, force: true }); }); -function runCli(...args: string[]): { stdout: string; stderr: string; exitCode: number } { +function runCli(args: string[]): { stdout: string; stderr: string; exitCode: number } { try { - const stdout = execFileSync("tsx", [entrypoint, "--home", tmpStore, ...args], { + const stdout = execFileSync("node", [entrypoint, "--home", tmpStore, ...args], { encoding: "utf-8", timeout: 10000, }); @@ -76,7 +76,7 @@ describe("Phase 6: GC", () => { const { stdout: gcOut, exitCode: gcExit } = runCli(["gc"]); expect(gcExit).toBe(0); - const stdout = execFileSync("tsx", [entrypoint, "--home", tmpStore, "render", "--pipe"], { + const stdout = execFileSync("node", [entrypoint, "--home", tmpStore, "render", "--pipe"], { input: gcOut, encoding: "utf-8", timeout: 10000, diff --git a/packages/cli/tests/get-tag-info.test.ts b/packages/cli/tests/get-tag-info.test.ts index 5bb54c6..76a509b 100644 --- a/packages/cli/tests/get-tag-info.test.ts +++ b/packages/cli/tests/get-tag-info.test.ts @@ -32,7 +32,7 @@ afterEach(() => { function runCli(...args: string[]): { stdout: string; stderr: string; exitCode: number } { try { - const stdout = execFileSync("tsx", [cliPath, "--home", storePath, ...args], { + const stdout = execFileSync("node", [cliPath, "--home", storePath, ...args], { encoding: "utf-8", timeout: 10000, }); diff --git a/packages/cli/tests/list-pagination.test.ts b/packages/cli/tests/list-pagination.test.ts index 0563dda..8eb37e5 100644 --- a/packages/cli/tests/list-pagination.test.ts +++ b/packages/cli/tests/list-pagination.test.ts @@ -20,7 +20,7 @@ afterEach(() => { async function putString(text: string): Promise { const entrypoint = join(import.meta.dirname, "../src/index.ts"); - const out = execFileSync("tsx", [entrypoint, "--home", storePath, "put", "@ocas/string", "--pipe"], { + const out = execFileSync("node", [entrypoint, "--home", storePath, "put", "@ocas/string", "--pipe"], { input: JSON.stringify(text), encoding: "utf-8", timeout: 10000, diff --git a/packages/cli/tests/list-tag-filter.test.ts b/packages/cli/tests/list-tag-filter.test.ts index bcc666c..a7a977c 100644 --- a/packages/cli/tests/list-tag-filter.test.ts +++ b/packages/cli/tests/list-tag-filter.test.ts @@ -29,7 +29,7 @@ afterEach(() => { function runCli(...args: string[]): { stdout: string; stderr: string; exitCode: number } { try { - const stdout = execFileSync("tsx", [cliPath, "--home", storePath, ...args], { + const stdout = execFileSync("node", [cliPath, "--home", storePath, ...args], { encoding: "utf-8", timeout: 10000, }); @@ -42,7 +42,7 @@ function runCli(...args: string[]): { stdout: string; stderr: string; exitCode: function putString(value: string): string { try { - const out = execFileSync("tsx", [cliPath, "--home", storePath, "put", "@ocas/string", "--pipe"], { + const out = execFileSync("node", [cliPath, "--home", storePath, "put", "@ocas/string", "--pipe"], { input: JSON.stringify(value), encoding: "utf-8", timeout: 10000, diff --git a/packages/cli/tests/pipe.test.ts b/packages/cli/tests/pipe.test.ts index 9c6e8c5..e07871a 100644 --- a/packages/cli/tests/pipe.test.ts +++ b/packages/cli/tests/pipe.test.ts @@ -44,9 +44,9 @@ afterAll(() => { rmSync(tmpStore, { recursive: true, force: true }); }); -function runCli(...args: string[]): { stdout: string; stderr: string; exitCode: number } { +function runCli(args: string[]): { stdout: string; stderr: string; exitCode: number } { try { - const stdout = execFileSync("tsx", [entrypoint, "--home", tmpStore, ...args], { + const stdout = execFileSync("node", [entrypoint, "--home", tmpStore, ...args], { encoding: "utf-8", timeout: 10000, }); @@ -62,7 +62,7 @@ function runCliWithStdin( stdin: string, ): { stdout: string; stderr: string; exitCode: number } { try { - const stdout = execFileSync("tsx", [entrypoint, "--home", tmpStore, ...args], { + const stdout = execFileSync("node", [entrypoint, "--home", tmpStore, ...args], { input: stdin, encoding: "utf-8", timeout: 10000, diff --git a/packages/cli/tests/put-get-has.test.ts b/packages/cli/tests/put-get-has.test.ts index d0a3b2a..880d018 100644 --- a/packages/cli/tests/put-get-has.test.ts +++ b/packages/cli/tests/put-get-has.test.ts @@ -46,7 +46,7 @@ function runCli( args: string[], ): { stdout: string; stderr: string; exitCode: number } { try { - const stdout = execFileSync("tsx", [entrypoint, "--home", tmpStore, ...args], { + const stdout = execFileSync("node", [entrypoint, "--home", tmpStore, ...args], { encoding: "utf-8", timeout: 10000, }); diff --git a/packages/cli/tests/render.test.ts b/packages/cli/tests/render.test.ts index 2e060ba..025fa87 100644 --- a/packages/cli/tests/render.test.ts +++ b/packages/cli/tests/render.test.ts @@ -58,9 +58,9 @@ describe("Phase 5: Render", () => { let typeHash: string; let nodeHash: string; - function runCliE2e(...args: string[]): { stdout: string; stderr: string; exitCode: number } { + function runCliE2e(args: string[]): { stdout: string; stderr: string; exitCode: number } { try { - const stdout = execFileSync("tsx", [entrypoint, "--home", tmpStore, ...args], { + const stdout = execFileSync("node", [entrypoint, "--home", tmpStore, ...args], { encoding: "utf-8", timeout: 10000, }); @@ -76,7 +76,7 @@ describe("Phase 5: Render", () => { stdin: string, ): Promise<{ stdout: string; stderr: string; exitCode: number }> { try { - const stdout = execFileSync("tsx", [entrypoint, "--home", tmpStore, ...args], { + const stdout = execFileSync("node", [entrypoint, "--home", tmpStore, ...args], { input: stdin, encoding: "utf-8", timeout: 10000, diff --git a/packages/cli/tests/schema-validation.test.ts b/packages/cli/tests/schema-validation.test.ts index 63f9cf2..3ea537f 100644 --- a/packages/cli/tests/schema-validation.test.ts +++ b/packages/cli/tests/schema-validation.test.ts @@ -582,7 +582,7 @@ describe("Phase 2: Schema Validation", () => { const nodeFile = join(tmpStore, "test-node.json"); writeFileSync(nodeFile, JSON.stringify({ name: "Alice", age: 30 })); - const stdout = execFileSync("tsx", [entrypoint, "--home", tmpStore, "put", typeHash, nodeFile], { + const stdout = execFileSync("node", [entrypoint, "--home", tmpStore, "put", typeHash, nodeFile], { encoding: "utf-8", timeout: 10000, }).trim(); @@ -598,7 +598,7 @@ describe("Phase 2: Schema Validation", () => { writeFileSync(badFile, JSON.stringify({ name: 123 })); let stdout = "", stderr = "", exitCode = 0; try { - stdout = execFileSync("tsx", [entrypoint, "--home", tmpStore, "put", typeHash, badFile], { + stdout = execFileSync("node", [entrypoint, "--home", tmpStore, "put", typeHash, badFile], { encoding: "utf-8", timeout: 10000, }).trim(); @@ -618,7 +618,7 @@ describe("Phase 2: Schema Validation", () => { const nodeFile = join(tmpStore, "test-node.json"); let exitCode = 0, stderr = ""; try { - execFileSync("tsx", [entrypoint, "--home", tmpStore, "put", "AAAAAAAAAAAAA", nodeFile], { + execFileSync("node", [entrypoint, "--home", tmpStore, "put", "AAAAAAAAAAAAA", nodeFile], { encoding: "utf-8", timeout: 10000, }); diff --git a/packages/cli/tests/tag-untag.test.ts b/packages/cli/tests/tag-untag.test.ts index dc68081..846e9c9 100644 --- a/packages/cli/tests/tag-untag.test.ts +++ b/packages/cli/tests/tag-untag.test.ts @@ -32,7 +32,7 @@ afterEach(() => { function runCli(...args: string[]): { stdout: string; stderr: string; exitCode: number } { try { - const stdout = execFileSync("tsx", [cliPath, "--home", storePath, ...args], { + const stdout = execFileSync("node", [cliPath, "--home", storePath, ...args], { encoding: "utf-8", timeout: 10000, }); diff --git a/packages/cli/tests/template.test.ts b/packages/cli/tests/template.test.ts index f7a2f59..8f6bfa2 100644 --- a/packages/cli/tests/template.test.ts +++ b/packages/cli/tests/template.test.ts @@ -40,7 +40,7 @@ afterEach(() => { */ function runCli(...args: string[]): { stdout: string; stderr: string; exitCode: number } { try { - const stdout = execFileSync("tsx", [cliPath, "--home", storePath, ...args], { + const stdout = execFileSync("node", [cliPath, "--home", storePath, ...args], { encoding: "utf-8", timeout: 10000, }); diff --git a/packages/cli/tests/variable-history.test.ts b/packages/cli/tests/variable-history.test.ts index 9edce77..aee6c3a 100644 --- a/packages/cli/tests/variable-history.test.ts +++ b/packages/cli/tests/variable-history.test.ts @@ -33,7 +33,7 @@ afterEach(() => { function runCli(...args: string[]): { stdout: string; stderr: string; exitCode: number } { try { - const stdout = execFileSync("tsx", [cliPath, "--home", storePath, ...args], { + const stdout = execFileSync("node", [cliPath, "--home", storePath, ...args], { encoding: "utf-8", timeout: 10000, }); diff --git a/packages/cli/tests/variable.test.ts b/packages/cli/tests/variable.test.ts index a602fb2..dcc1c03 100644 --- a/packages/cli/tests/variable.test.ts +++ b/packages/cli/tests/variable.test.ts @@ -40,7 +40,7 @@ afterEach(() => { */ function runCli(...args: string[]): { stdout: string; stderr: string; exitCode: number } { try { - const stdout = execFileSync("tsx", [cliPath, "--home", storePath, ...args], { + const stdout = execFileSync("node", [cliPath, "--home", storePath, ...args], { encoding: "utf-8", timeout: 10000, }); @@ -770,7 +770,7 @@ describe("global options", () => { const hash = await createTestNode(store, typeHash, { test: "data" }); // Override with custom store path - execFileSync("tsx", [cliPath, "--home", customStorePath, "var", "set", "@test/x", hash], { + execFileSync("node", [cliPath, "--home", customStorePath, "var", "set", "@test/x", hash], { encoding: "utf-8", timeout: 10000, }); diff --git a/packages/cli/tests/verify-refs-walk.test.ts b/packages/cli/tests/verify-refs-walk.test.ts index 25c2816..de71639 100644 --- a/packages/cli/tests/verify-refs-walk.test.ts +++ b/packages/cli/tests/verify-refs-walk.test.ts @@ -43,7 +43,7 @@ function runCli( args: string[], ): { stdout: string; stderr: string; exitCode: number } { try { - const stdout = execFileSync("tsx", [entrypoint, "--home", tmpStore, ...args], { + const stdout = execFileSync("node", [entrypoint, "--home", tmpStore, ...args], { encoding: "utf-8", timeout: 10000, }); diff --git a/packages/core/src/liquid-render.test.ts b/packages/core/src/liquid-render.test.ts index f1bffb9..ffe4b76 100644 --- a/packages/core/src/liquid-render.test.ts +++ b/packages/core/src/liquid-render.test.ts @@ -598,7 +598,7 @@ describe("Suite 4: Render Flow Integration", () => { epsilon: 0.01, }); - expect(output.length).toBe(0); + await expect(output.length).toBe(0); } finally { await cleanup(); } @@ -629,7 +629,7 @@ describe("Suite 4: Render Flow Integration", () => { decay: 0.5, epsilon: 0.01, }); - }).toThrow(); + }).rejects.toThrow(); } finally { await cleanup(); } @@ -905,8 +905,8 @@ describe("Suite 6: Recursive Rendering Edge Cases", () => { }); expect(output).toContain("Item: item1"); - expect(output).toContain("Item: item2"); - expect(output).toContain("Item: item3"); + await expect(output).toContain("Item: item2"); + await expect(output).toContain("Item: item3"); } finally { await cleanup(); } @@ -937,7 +937,7 @@ describe("Suite 7: Error Handling & Edge Cases", () => { epsilon: 0.01, }); - expect(output).toBeDefined(); + await expect(output).toBeDefined(); } finally { await cleanup(); } @@ -976,7 +976,7 @@ describe("Suite 7: Error Handling & Edge Cases", () => { decay: 0.5, epsilon: 0.01, }); - }).toThrow(/decay/); + }).rejects.toThrow(/decay/); } finally { await cleanup(); } @@ -1015,7 +1015,7 @@ describe("Suite 7: Error Handling & Edge Cases", () => { decay: 0.5, epsilon: 0.01, }); - }).toThrow(); + }).rejects.toThrow(); } finally { await cleanup(); } @@ -1054,7 +1054,7 @@ describe("Suite 7: Error Handling & Edge Cases", () => { decay: 0.5, epsilon: 0.01, }); - }).toThrow(/decay/); + }).rejects.toThrow(/decay/); } finally { await cleanup(); } diff --git a/packages/core/tests/schema-validation.test.ts b/packages/core/tests/schema-validation.test.ts index e2f6029..579910a 100644 --- a/packages/core/tests/schema-validation.test.ts +++ b/packages/core/tests/schema-validation.test.ts @@ -258,169 +258,169 @@ describe("Test Suite 3: putSchema Validation - Invalid Schemas", () => { test("3.1: Reject schema with invalid type value", async () => { const store = new MemStore(); bootstrap(store); - expect(async () => putSchema(store, { type: "garbage" })).toThrow(); + await expect(async () => putSchema(store, { type: "garbage" })).rejects.toThrow(); }); test("3.2: Reject schema with type as number", async () => { const store = new MemStore(); bootstrap(store); - expect(async () => + await expect(async () => putSchema(store, { type: 123 } as unknown as JSONSchema), - ).toThrow(); + ).rejects.toThrow(); }); test("3.3: Reject schema with properties not an object", async () => { const store = new MemStore(); bootstrap(store); - expect(async () => + await expect(async () => putSchema(store, { type: "object", properties: "not-an-object", } as unknown as JSONSchema), - ).toThrow(); + ).rejects.toThrow(); }); test("3.4: Reject schema with required not an array", async () => { const store = new MemStore(); bootstrap(store); - expect(async () => + await expect(async () => putSchema(store, { type: "object", required: "name", } as unknown as JSONSchema), - ).toThrow(); + ).rejects.toThrow(); }); test("3.5: Reject schema with required containing non-strings", async () => { const store = new MemStore(); bootstrap(store); - expect(async () => + await expect(async () => putSchema(store, { type: "object", required: ["name", 123, true], } as unknown as JSONSchema), - ).toThrow(); + ).rejects.toThrow(); }); test("3.6: Reject schema with additionalProperties as string", async () => { const store = new MemStore(); bootstrap(store); - expect(async () => + await expect(async () => putSchema(store, { type: "object", additionalProperties: "yes", } as unknown as JSONSchema), - ).toThrow(); + ).rejects.toThrow(); }); test("3.7: Reject schema with anyOf not an array", async () => { const store = new MemStore(); bootstrap(store); - expect(async () => + await expect(async () => putSchema(store, { anyOf: { type: "string" }, } as unknown as JSONSchema), - ).toThrow(); + ).rejects.toThrow(); }); test("3.8: Reject schema with empty anyOf array", async () => { const store = new MemStore(); bootstrap(store); - expect(async () => putSchema(store, { anyOf: [] })).toThrow(); + await expect(async () => putSchema(store, { anyOf: [] })).rejects.toThrow(); }); test("3.9: Reject schema with items not an object", async () => { const store = new MemStore(); bootstrap(store); - expect(async () => + await expect(async () => putSchema(store, { type: "array", items: "string", } as unknown as JSONSchema), - ).toThrow(); + ).rejects.toThrow(); }); test("3.10: Reject schema with format not a string", async () => { const store = new MemStore(); bootstrap(store); - expect(async () => + await expect(async () => putSchema(store, { type: "string", format: 123, } as unknown as JSONSchema), - ).toThrow(); + ).rejects.toThrow(); }); test("3.11: Reject schema with enum not an array", async () => { const store = new MemStore(); bootstrap(store); - expect(async () => + await expect(async () => putSchema(store, { type: "string", enum: "red", } as unknown as JSONSchema), - ).toThrow(); + ).rejects.toThrow(); }); test("3.12: Reject schema with empty enum array", async () => { const store = new MemStore(); bootstrap(store); - expect(async () => + await expect(async () => putSchema(store, { type: "string", enum: [] }), - ).toThrow(); + ).rejects.toThrow(); }); test("3.13: Reject schema with title not a string", async () => { const store = new MemStore(); bootstrap(store); - expect(async () => + await expect(async () => putSchema(store, { type: "string", title: 123, } as unknown as JSONSchema), - ).toThrow(); + ).rejects.toThrow(); }); test("3.14: Reject schema with description not a string", async () => { const store = new MemStore(); bootstrap(store); - expect(async () => + await expect(async () => putSchema(store, { type: "string", description: ["not a string"], } as unknown as JSONSchema), - ).toThrow(); + ).rejects.toThrow(); }); test("3.15: Reject schema with unsupported $ref keyword", async () => { const store = new MemStore(); bootstrap(store); - expect(async () => + await expect(async () => putSchema(store, { $ref: "#/definitions/user", } as unknown as JSONSchema), - ).toThrow(); + ).rejects.toThrow(); }); test("3.16: Reject completely invalid data (non-object)", async () => { const store = new MemStore(); bootstrap(store); - expect(async () => + await expect(async () => putSchema(store, "not-a-schema" as unknown as JSONSchema), - ).toThrow(); + ).rejects.toThrow(); }); test("3.17: Reject nested invalid schema in properties", async () => { const store = new MemStore(); bootstrap(store); - expect(async () => + await expect(async () => putSchema(store, { type: "object", properties: { name: { type: "invalid-type" }, }, } as unknown as JSONSchema), - ).toThrow(); + ).rejects.toThrow(); }); }); @@ -641,9 +641,9 @@ describe("Test Suite 7: Meta-Schema Content Validation", () => { expect(hash2).toBeTruthy(); // Invalid type (number) - expect(async () => + await expect(async () => putSchema(store, { type: 123 } as unknown as JSONSchema), - ).toThrow(); + ).rejects.toThrow(); }); });