import { test } from "node:test"; import assert from "node:assert/strict"; import { AGENT_FEATURE_VERSION, compareVersions, shouldOfferAgentOnboarding, } from "../out/agent/onboarding.js"; test("compareVersions orders dotted numeric versions", () => { assert.equal(compareVersions("0.1.26", "0.1.26"), 0); assert.equal(compareVersions("0.1.26", "0.1.25"), 1); assert.equal(compareVersions("0.1.25", "0.1.26"), -1); assert.equal(compareVersions("0.1.26", "0.1"), 1); assert.equal(compareVersions("0.2", "0.1.99"), 1); assert.equal(compareVersions("1.0.0", "2.0.0"), -1); assert.equal(compareVersions("0.1.26-beta", "0.1.26"), 0); assert.equal(compareVersions("dev", "0.1.25"), -1); }); test("a fresh install is offered the AI Agent introduction once", () => { assert.equal(shouldOfferAgentOnboarding(undefined, "0.1.26"), true); assert.equal(shouldOfferAgentOnboarding({}, "0.1.26"), true); }); test("upgrading from before the feature informs once", () => { assert.equal( shouldOfferAgentOnboarding({ informedVersion: "0.1.25" }, "0.1.26"), true, ); // ...but not again on the same version or later ones. assert.equal( shouldOfferAgentOnboarding({ informedVersion: "0.1.26" }, "0.1.26"), false, ); assert.equal( shouldOfferAgentOnboarding({ informedVersion: "0.1.26" }, "0.1.27"), false, ); }); test("upgrading from a build that already had the feature stays silent", () => { // 0.1.26 introduced it; someone informed on 0.1.26 must not be re-prompted. assert.equal( shouldOfferAgentOnboarding({ informedVersion: "0.1.26" }, "0.1.30"), false, ); }); test("dismissed state suppresses the prompt forever", () => { assert.equal( shouldOfferAgentOnboarding( { informedVersion: "0.1.20", dismissed: true }, "0.1.26", ), false, ); assert.equal( shouldOfferAgentOnboarding( { informedVersion: AGENT_FEATURE_VERSION, dismissed: true }, "0.1.30", ), false, ); });