hermes-agent/web/src/lib/chat-sidebar-session-params.test.ts
ethernet 2f3007ff51 test: port JS/package.json invariant tests from Python to vitest
The CI change classifier routes package.json / package-lock.json /
.ts/.tsx changes to the frontend lane, not the Python lane. Four
Python tests asserted about these JS-side artifacts, so a PR touching
only those files would skip the Python suite — the regression goes
green on the PR and red on main (where the classifier fails open).

Ported all four to vitest so they run in the correct CI lane:

  tests/test_package_json_lazy_deps.py
    → apps/desktop/electron/package-json-lazy-deps.test.ts
    (camofox is lazy, agent-browser is eager, lockfile clean)

  tests/test_desktop_electron_pin.py
    → apps/desktop/electron/desktop-electron-pin.test.ts
    (electron dep is exact, matches build.electronVersion, lockfile agrees)

  tests/test_assistant_ui_tap_compat.py
    → apps/desktop/electron/assistant-ui-tap-compat.test.ts
    (@assistant-ui cluster shares one tap version + semver helper)

  tests/test_dashboard_sidecar_close_on_disconnect.py
    → web/src/lib/chat-sidebar-session-params.test.ts
    (sidecar session.create opts into close_on_disconnect + profile)

The ChatSidebar test was regex-matching .tsx source text (the
source-reading anti-pattern). Extracted sidecarSessionCreateParams()
from the component's effect into an exported pure function so the
test calls real code instead of pattern-matching a string.

Verified: 8 electron tests + 76 web tests pass; both typecheck clean.
2026-07-15 17:24:12 -04:00

35 lines
1.1 KiB
TypeScript

/**
* Tests for the sidecar ``session.create`` params built by ChatSidebar.
*
* The sidecar must opt its session into close_on_disconnect so the gateway
* reaps the slash_worker on WS disconnect (the #21370/#21467 leak), and it
* must pass the dashboard's selected profile so model/credential info
* matches the PTY child under profile-scoped chat.
*
*/
import { describe, expect, it } from "vitest";
import { sidecarSessionCreateParams } from "@/components/ChatSidebar";
describe("sidecarSessionCreateParams", () => {
it("opts into close_on_disconnect", () => {
const params = sidecarSessionCreateParams();
expect(params.close_on_disconnect).toBe(true);
});
it("sets source to 'tool'", () => {
const params = sidecarSessionCreateParams();
expect(params.source).toBe("tool");
});
it("forwards the profile when present", () => {
const params = sidecarSessionCreateParams("work");
expect(params.profile).toBe("work");
});
it("omits profile when undefined", () => {
const params = sidecarSessionCreateParams();
expect(params).not.toHaveProperty("profile");
});
});