/** * Copyright (c) 2026, Salesforce, Inc., * All rights reserved. * For full license text, see the LICENSE.txt file */ import { describe, expect, it } from "vitest"; import { makeSession } from "../../__tests__/helpers/schema.js"; import { formatHelp, formatNextSteps, QUERY_COMMANDS } from "../query-commands.js"; describe("query-commands", () => { describe("command registry", () => { it("lists all expected commands", () => { const names = QUERY_COMMANDS.map((c) => c.name); for (const expected of [ "pwd", "ls", "cd", "select", "drop", "set", "alias", "var", "show", "check", "run", "help", "interactive", ]) { expect(names).toContain(expected); } }); it("every command spec has a non-empty summary and usage", () => { for (const spec of QUERY_COMMANDS) { expect(spec.summary.length).toBeGreaterThan(0); expect(spec.usage.length).toBeGreaterThan(0); } }); }); describe("formatHelp", () => { it("with no topic returns a full listing", () => { const help = formatHelp(); expect(help).toContain("pwd"); expect(help).toContain("select"); expect(help).toContain("interactive"); expect(help).toContain("Run `help `"); }); it("with known topic returns usage and examples", () => { const help = formatHelp("set"); expect(help).toContain("set"); expect(help).toContain("Usage:"); expect(help).toContain("Examples:"); }); it("with unknown topic returns an error message", () => { const help = formatHelp("nonexistent_command"); expect(help).toContain("Unknown help topic"); }); }); describe("formatNextSteps", () => { it("returns next-step hints for each key command", () => { const session = makeSession(); for (const cmd of ["new", "ls", "cd", "select", "set", "var", "show", "check"]) { const output = formatNextSteps({ sessionId: session.id, command: cmd, session }); expect(output).toContain("Next steps:"); expect(output).toContain("graphiti query"); } }); }); });