|
1 | 1 | // SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. |
2 | 2 | // SPDX-License-Identifier: Apache-2.0 |
3 | 3 |
|
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"; |
10 | 10 |
|
11 | 11 | describe("onboard provider selection UX", () => { |
12 | 12 | it("prompts explicitly instead of silently auto-selecting detected Ollama", () => { |
13 | | - const repoRoot = path.join(__dirname, ".."); |
| 13 | + const repoRoot = path.join(import.meta.dirname, ".."); |
14 | 14 | const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "nemoclaw-onboard-selection-")); |
15 | 15 | const fakeBin = path.join(tmpDir, "bin"); |
16 | 16 | const scriptPath = path.join(tmpDir, "selection-check.js"); |
@@ -106,7 +106,7 @@ const { setupNim } = require(${onboardPath}); |
106 | 106 | }); |
107 | 107 |
|
108 | 108 | 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, ".."); |
110 | 110 | const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "nemoclaw-onboard-build-model-selection-")); |
111 | 111 | const fakeBin = path.join(tmpDir, "bin"); |
112 | 112 | const scriptPath = path.join(tmpDir, "build-model-selection-check.js"); |
@@ -199,7 +199,7 @@ const { setupNim } = require(${onboardPath}); |
199 | 199 | }); |
200 | 200 |
|
201 | 201 | 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, ".."); |
203 | 203 | const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "nemoclaw-onboard-build-model-retry-")); |
204 | 204 | const fakeBin = path.join(tmpDir, "bin"); |
205 | 205 | const scriptPath = path.join(tmpDir, "build-model-retry-check.js"); |
@@ -289,7 +289,7 @@ const { setupNim } = require(${onboardPath}); |
289 | 289 | }); |
290 | 290 |
|
291 | 291 | 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, ".."); |
293 | 293 | const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "nemoclaw-onboard-gemini-selection-")); |
294 | 294 | const fakeBin = path.join(tmpDir, "bin"); |
295 | 295 | const scriptPath = path.join(tmpDir, "gemini-selection-check.js"); |
@@ -382,7 +382,7 @@ const { setupNim } = require(${onboardPath}); |
382 | 382 | }); |
383 | 383 |
|
384 | 384 | it("warms and validates Ollama via localhost before moving on", () => { |
385 | | - const repoRoot = path.join(__dirname, ".."); |
| 385 | + const repoRoot = path.join(import.meta.dirname, ".."); |
386 | 386 | const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "nemoclaw-onboard-ollama-validation-")); |
387 | 387 | const fakeBin = path.join(tmpDir, "bin"); |
388 | 388 | const scriptPath = path.join(tmpDir, "ollama-validation-check.js"); |
@@ -476,7 +476,7 @@ const { setupNim } = require(${onboardPath}); |
476 | 476 | }); |
477 | 477 |
|
478 | 478 | 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, ".."); |
480 | 480 | const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "nemoclaw-onboard-ollama-bootstrap-")); |
481 | 481 | const fakeBin = path.join(tmpDir, "bin"); |
482 | 482 | const scriptPath = path.join(tmpDir, "ollama-bootstrap-check.js"); |
@@ -578,7 +578,7 @@ const { setupNim } = require(${onboardPath}); |
578 | 578 | }); |
579 | 579 |
|
580 | 580 | 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, ".."); |
582 | 582 | const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "nemoclaw-onboard-ollama-retry-")); |
583 | 583 | const fakeBin = path.join(tmpDir, "bin"); |
584 | 584 | const scriptPath = path.join(tmpDir, "ollama-retry-check.js"); |
@@ -683,7 +683,7 @@ const { setupNim } = require(${onboardPath}); |
683 | 683 | }); |
684 | 684 |
|
685 | 685 | 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, ".."); |
687 | 687 | const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "nemoclaw-onboard-openai-model-retry-")); |
688 | 688 | const fakeBin = path.join(tmpDir, "bin"); |
689 | 689 | const scriptPath = path.join(tmpDir, "openai-model-retry-check.js"); |
@@ -770,7 +770,7 @@ const { setupNim } = require(${onboardPath}); |
770 | 770 | }); |
771 | 771 |
|
772 | 772 | 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, ".."); |
774 | 774 | const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "nemoclaw-onboard-anthropic-model-retry-")); |
775 | 775 | const fakeBin = path.join(tmpDir, "bin"); |
776 | 776 | const scriptPath = path.join(tmpDir, "anthropic-model-retry-check.js"); |
@@ -851,7 +851,7 @@ const { setupNim } = require(${onboardPath}); |
851 | 851 | }); |
852 | 852 |
|
853 | 853 | 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, ".."); |
855 | 855 | const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "nemoclaw-onboard-anthropic-validation-retry-")); |
856 | 856 | const fakeBin = path.join(tmpDir, "bin"); |
857 | 857 | const scriptPath = path.join(tmpDir, "anthropic-validation-retry-check.js"); |
@@ -943,7 +943,7 @@ const { setupNim } = require(${onboardPath}); |
943 | 943 | }); |
944 | 944 |
|
945 | 945 | it("supports Other Anthropic-compatible endpoint with live validation", () => { |
946 | | - const repoRoot = path.join(__dirname, ".."); |
| 946 | + const repoRoot = path.join(import.meta.dirname, ".."); |
947 | 947 | const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "nemoclaw-onboard-anthropic-compatible-")); |
948 | 948 | const fakeBin = path.join(tmpDir, "bin"); |
949 | 949 | const scriptPath = path.join(tmpDir, "anthropic-compatible-check.js"); |
@@ -1028,7 +1028,7 @@ const { setupNim } = require(${onboardPath}); |
1028 | 1028 | }); |
1029 | 1029 |
|
1030 | 1030 | 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, ".."); |
1032 | 1032 | const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "nemoclaw-onboard-custom-openai-retry-")); |
1033 | 1033 | const fakeBin = path.join(tmpDir, "bin"); |
1034 | 1034 | const scriptPath = path.join(tmpDir, "custom-openai-retry-check.js"); |
@@ -1121,7 +1121,7 @@ const { setupNim } = require(${onboardPath}); |
1121 | 1121 | }); |
1122 | 1122 |
|
1123 | 1123 | 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, ".."); |
1125 | 1125 | const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "nemoclaw-onboard-custom-anthropic-retry-")); |
1126 | 1126 | const fakeBin = path.join(tmpDir, "bin"); |
1127 | 1127 | const scriptPath = path.join(tmpDir, "custom-anthropic-retry-check.js"); |
@@ -1214,7 +1214,7 @@ const { setupNim } = require(${onboardPath}); |
1214 | 1214 | }); |
1215 | 1215 |
|
1216 | 1216 | it("returns to provider selection when endpoint validation fails interactively", () => { |
1217 | | - const repoRoot = path.join(__dirname, ".."); |
| 1217 | + const repoRoot = path.join(import.meta.dirname, ".."); |
1218 | 1218 | const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "nemoclaw-onboard-selection-retry-")); |
1219 | 1219 | const fakeBin = path.join(tmpDir, "bin"); |
1220 | 1220 | const scriptPath = path.join(tmpDir, "selection-retry-check.js"); |
|
0 commit comments