Skip to content

Commit c6cfccc

Browse files
committed
test: align root onboarding tests with ESM harness
1 parent e2d4481 commit c6cfccc

File tree

4 files changed

+44
-42
lines changed

4 files changed

+44
-42
lines changed

test/inference-config.test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
22
// SPDX-License-Identifier: Apache-2.0
33

4-
const { describe, it } = require("node:test");
5-
const assert = require("node:assert/strict");
4+
import { describe, it } from "vitest";
5+
import assert from "node:assert/strict";
66

7-
const {
7+
import {
88
CLOUD_MODEL_OPTIONS,
99
DEFAULT_OLLAMA_MODEL,
1010
DEFAULT_ROUTE_CREDENTIAL_ENV,
@@ -13,7 +13,7 @@ const {
1313
MANAGED_PROVIDER_ID,
1414
getOpenClawPrimaryModel,
1515
getProviderSelectionConfig,
16-
} = require("../bin/lib/inference-config");
16+
} from "../bin/lib/inference-config.js";
1717

1818
describe("inference selection config", () => {
1919
it("exposes the curated cloud model picker options", () => {

test/local-inference.test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
22
// SPDX-License-Identifier: Apache-2.0
33

4-
const { describe, it } = require("node:test");
5-
const assert = require("node:assert/strict");
4+
import { describe, it } from "vitest";
5+
import assert from "node:assert/strict";
66

7-
const {
7+
import {
88
CONTAINER_REACHABILITY_IMAGE,
99
DEFAULT_OLLAMA_MODEL,
1010
getDefaultOllamaModel,
@@ -17,7 +17,7 @@ const {
1717
parseOllamaList,
1818
validateOllamaModel,
1919
validateLocalProvider,
20-
} = require("../bin/lib/local-inference");
20+
} from "../bin/lib/local-inference.js";
2121

2222
describe("local inference helpers", () => {
2323
it("returns the expected base URL for vllm-local", () => {

test/onboard-selection.test.js

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
22
// SPDX-License-Identifier: Apache-2.0
33

4-
const { describe, it } = require("node:test");
5-
const assert = require("node:assert/strict");
6-
const fs = require("node:fs");
7-
const os = require("node:os");
8-
const path = require("node:path");
9-
const { spawnSync } = require("node:child_process");
4+
import { describe, it } from "vitest";
5+
import assert from "node:assert/strict";
6+
import fs from "node:fs";
7+
import os from "node:os";
8+
import path from "node:path";
9+
import { spawnSync } from "node:child_process";
1010

1111
describe("onboard provider selection UX", () => {
1212
it("prompts explicitly instead of silently auto-selecting detected Ollama", () => {
13-
const repoRoot = path.join(__dirname, "..");
13+
const repoRoot = path.join(import.meta.dirname, "..");
1414
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "nemoclaw-onboard-selection-"));
1515
const fakeBin = path.join(tmpDir, "bin");
1616
const scriptPath = path.join(tmpDir, "selection-check.js");
@@ -106,7 +106,7 @@ const { setupNim } = require(${onboardPath});
106106
});
107107

108108
it("accepts a manually entered NVIDIA Endpoints model after validating it against /models", () => {
109-
const repoRoot = path.join(__dirname, "..");
109+
const repoRoot = path.join(import.meta.dirname, "..");
110110
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "nemoclaw-onboard-build-model-selection-"));
111111
const fakeBin = path.join(tmpDir, "bin");
112112
const scriptPath = path.join(tmpDir, "build-model-selection-check.js");
@@ -199,7 +199,7 @@ const { setupNim } = require(${onboardPath});
199199
});
200200

201201
it("reprompts for a manual NVIDIA Endpoints model when /models validation rejects it", () => {
202-
const repoRoot = path.join(__dirname, "..");
202+
const repoRoot = path.join(import.meta.dirname, "..");
203203
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "nemoclaw-onboard-build-model-retry-"));
204204
const fakeBin = path.join(tmpDir, "bin");
205205
const scriptPath = path.join(tmpDir, "build-model-retry-check.js");
@@ -289,7 +289,7 @@ const { setupNim } = require(${onboardPath});
289289
});
290290

291291
it("shows curated Gemini models and supports Other for manual entry", () => {
292-
const repoRoot = path.join(__dirname, "..");
292+
const repoRoot = path.join(import.meta.dirname, "..");
293293
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "nemoclaw-onboard-gemini-selection-"));
294294
const fakeBin = path.join(tmpDir, "bin");
295295
const scriptPath = path.join(tmpDir, "gemini-selection-check.js");
@@ -382,7 +382,7 @@ const { setupNim } = require(${onboardPath});
382382
});
383383

384384
it("warms and validates Ollama via localhost before moving on", () => {
385-
const repoRoot = path.join(__dirname, "..");
385+
const repoRoot = path.join(import.meta.dirname, "..");
386386
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "nemoclaw-onboard-ollama-validation-"));
387387
const fakeBin = path.join(tmpDir, "bin");
388388
const scriptPath = path.join(tmpDir, "ollama-validation-check.js");
@@ -476,7 +476,7 @@ const { setupNim } = require(${onboardPath});
476476
});
477477

478478
it("offers starter Ollama models when none are installed and pulls the selected model", () => {
479-
const repoRoot = path.join(__dirname, "..");
479+
const repoRoot = path.join(import.meta.dirname, "..");
480480
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "nemoclaw-onboard-ollama-bootstrap-"));
481481
const fakeBin = path.join(tmpDir, "bin");
482482
const scriptPath = path.join(tmpDir, "ollama-bootstrap-check.js");
@@ -578,7 +578,7 @@ const { setupNim } = require(${onboardPath});
578578
});
579579

580580
it("reprompts inside the Ollama model flow when a pull fails", () => {
581-
const repoRoot = path.join(__dirname, "..");
581+
const repoRoot = path.join(import.meta.dirname, "..");
582582
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "nemoclaw-onboard-ollama-retry-"));
583583
const fakeBin = path.join(tmpDir, "bin");
584584
const scriptPath = path.join(tmpDir, "ollama-retry-check.js");
@@ -683,7 +683,7 @@ const { setupNim } = require(${onboardPath});
683683
});
684684

685685
it("reprompts for an OpenAI Other model when /models validation rejects it", () => {
686-
const repoRoot = path.join(__dirname, "..");
686+
const repoRoot = path.join(import.meta.dirname, "..");
687687
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "nemoclaw-onboard-openai-model-retry-"));
688688
const fakeBin = path.join(tmpDir, "bin");
689689
const scriptPath = path.join(tmpDir, "openai-model-retry-check.js");
@@ -770,7 +770,7 @@ const { setupNim } = require(${onboardPath});
770770
});
771771

772772
it("reprompts for an Anthropic Other model when /v1/models validation rejects it", () => {
773-
const repoRoot = path.join(__dirname, "..");
773+
const repoRoot = path.join(import.meta.dirname, "..");
774774
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "nemoclaw-onboard-anthropic-model-retry-"));
775775
const fakeBin = path.join(tmpDir, "bin");
776776
const scriptPath = path.join(tmpDir, "anthropic-model-retry-check.js");
@@ -851,7 +851,7 @@ const { setupNim } = require(${onboardPath});
851851
});
852852

853853
it("returns to provider selection when Anthropic live validation fails interactively", () => {
854-
const repoRoot = path.join(__dirname, "..");
854+
const repoRoot = path.join(import.meta.dirname, "..");
855855
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "nemoclaw-onboard-anthropic-validation-retry-"));
856856
const fakeBin = path.join(tmpDir, "bin");
857857
const scriptPath = path.join(tmpDir, "anthropic-validation-retry-check.js");
@@ -943,7 +943,7 @@ const { setupNim } = require(${onboardPath});
943943
});
944944

945945
it("supports Other Anthropic-compatible endpoint with live validation", () => {
946-
const repoRoot = path.join(__dirname, "..");
946+
const repoRoot = path.join(import.meta.dirname, "..");
947947
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "nemoclaw-onboard-anthropic-compatible-"));
948948
const fakeBin = path.join(tmpDir, "bin");
949949
const scriptPath = path.join(tmpDir, "anthropic-compatible-check.js");
@@ -1028,7 +1028,7 @@ const { setupNim } = require(${onboardPath});
10281028
});
10291029

10301030
it("reprompts only for model name when Other OpenAI-compatible endpoint validation fails", () => {
1031-
const repoRoot = path.join(__dirname, "..");
1031+
const repoRoot = path.join(import.meta.dirname, "..");
10321032
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "nemoclaw-onboard-custom-openai-retry-"));
10331033
const fakeBin = path.join(tmpDir, "bin");
10341034
const scriptPath = path.join(tmpDir, "custom-openai-retry-check.js");
@@ -1121,7 +1121,7 @@ const { setupNim } = require(${onboardPath});
11211121
});
11221122

11231123
it("reprompts only for model name when Other Anthropic-compatible endpoint validation fails", () => {
1124-
const repoRoot = path.join(__dirname, "..");
1124+
const repoRoot = path.join(import.meta.dirname, "..");
11251125
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "nemoclaw-onboard-custom-anthropic-retry-"));
11261126
const fakeBin = path.join(tmpDir, "bin");
11271127
const scriptPath = path.join(tmpDir, "custom-anthropic-retry-check.js");
@@ -1214,7 +1214,7 @@ const { setupNim } = require(${onboardPath});
12141214
});
12151215

12161216
it("returns to provider selection when endpoint validation fails interactively", () => {
1217-
const repoRoot = path.join(__dirname, "..");
1217+
const repoRoot = path.join(import.meta.dirname, "..");
12181218
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "nemoclaw-onboard-selection-retry-"));
12191219
const fakeBin = path.join(tmpDir, "bin");
12201220
const scriptPath = path.join(tmpDir, "selection-retry-check.js");

test/onboard.test.js

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
22
// SPDX-License-Identifier: Apache-2.0
33

4-
const { describe, it } = require("node:test");
5-
const assert = require("node:assert/strict");
6-
const fs = require("node:fs");
7-
const os = require("node:os");
8-
const path = require("node:path");
9-
const { spawnSync } = require("node:child_process");
10-
4+
import { describe, it } from "vitest";
5+
import assert from "node:assert/strict";
6+
import fs from "node:fs";
7+
import os from "node:os";
8+
import path from "node:path";
9+
import { createRequire } from "node:module";
10+
import { spawnSync } from "node:child_process";
11+
12+
const require = createRequire(import.meta.url);
1113
const {
1214
buildSandboxConfigSyncScript,
1315
createSandbox,
@@ -172,7 +174,7 @@ describe("onboard helpers", () => {
172174
});
173175

174176
it("passes credential names to openshell without embedding secret values in argv", () => {
175-
const repoRoot = path.join(__dirname, "..");
177+
const repoRoot = path.join(import.meta.dirname, "..");
176178
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "nemoclaw-onboard-inference-"));
177179
const fakeBin = path.join(tmpDir, "bin");
178180
const scriptPath = path.join(tmpDir, "setup-inference-check.js");
@@ -242,7 +244,7 @@ const { setupInference } = require(${onboardPath});
242244
});
243245

244246
it("uses native Anthropic provider creation without embedding the secret in argv", () => {
245-
const repoRoot = path.join(__dirname, "..");
247+
const repoRoot = path.join(import.meta.dirname, "..");
246248
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "nemoclaw-onboard-anthropic-"));
247249
const fakeBin = path.join(tmpDir, "bin");
248250
const scriptPath = path.join(tmpDir, "setup-anthropic-check.js");
@@ -312,7 +314,7 @@ const { setupInference } = require(${onboardPath});
312314
});
313315

314316
it("updates OpenAI-compatible providers without passing an unsupported --type flag", () => {
315-
const repoRoot = path.join(__dirname, "..");
317+
const repoRoot = path.join(import.meta.dirname, "..");
316318
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "nemoclaw-onboard-openai-update-"));
317319
const fakeBin = path.join(tmpDir, "bin");
318320
const scriptPath = path.join(tmpDir, "setup-openai-update-check.js");
@@ -384,7 +386,7 @@ const { setupInference } = require(${onboardPath});
384386
});
385387

386388
it("drops stale local sandbox registry entries when the live sandbox is gone", () => {
387-
const repoRoot = path.join(__dirname, "..");
389+
const repoRoot = path.join(import.meta.dirname, "..");
388390
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "nemoclaw-onboard-stale-sandbox-"));
389391
const fakeBin = path.join(tmpDir, "bin");
390392
const scriptPath = path.join(tmpDir, "stale-sandbox-check.js");
@@ -426,7 +428,7 @@ console.log(JSON.stringify({ liveExists, sandbox: registry.getSandbox("my-assist
426428
});
427429

428430
it("builds the sandbox without uploading an external OpenClaw config file", async () => {
429-
const repoRoot = path.join(__dirname, "..");
431+
const repoRoot = path.join(import.meta.dirname, "..");
430432
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "nemoclaw-onboard-create-sandbox-"));
431433
const fakeBin = path.join(tmpDir, "bin");
432434
const scriptPath = path.join(tmpDir, "create-sandbox-check.js");
@@ -495,7 +497,7 @@ const { createSandbox } = require(${onboardPath});
495497
});
496498

497499
it("accepts gateway inference when system inference is separately not configured", () => {
498-
const repoRoot = path.join(__dirname, "..");
500+
const repoRoot = path.join(import.meta.dirname, "..");
499501
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "nemoclaw-onboard-inference-get-"));
500502
const fakeBin = path.join(tmpDir, "bin");
501503
const scriptPath = path.join(tmpDir, "inference-get-check.js");
@@ -563,7 +565,7 @@ const { setupInference } = require(${onboardPath});
563565
});
564566

565567
it("accepts gateway inference output that omits the Route line", () => {
566-
const repoRoot = path.join(__dirname, "..");
568+
const repoRoot = path.join(import.meta.dirname, "..");
567569
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "nemoclaw-onboard-inference-route-"));
568570
const fakeBin = path.join(tmpDir, "bin");
569571
const scriptPath = path.join(tmpDir, "inference-route-check.js");

0 commit comments

Comments
 (0)