Files
pi2d/test/core/install.test.ts
yuez d2e20d428a feat: session-first workspace activity and installable daemon
Workspaces page:
- list the newest sessions across workspaces in the activity column; the
  daemon exposes GET /api/v1/sessions/recent as a disk projection and the
  browser enriches live rows from the per-workspace session relay
- put recent activity first below 1100px and fix the mobile page-header
  flex-basis gap

Smoke:
- pin PI2_HOST=127.0.0.1 in both smoke scripts and make the startup-line
  assertion follow the configured host; the daemon default stays 0.0.0.0

Install:
- standalone binary build/install scripts, packaging templates, CI/release
  hooks, CLI-first install docs and the supporting config/doctor changes
2026-10-28 10:53:48 +08:00

48 lines
1.8 KiB
TypeScript

import { describe, expect, it } from "vitest";
import { readFileSync } from "node:fs";
import { dirname, isAbsolute, resolve } from "node:path";
import { fileURLToPath } from "node:url";
import {
defaultStaticDir,
executablePath,
isBundledRuntime,
runtimeDescription,
staticDirCandidates,
version,
} from "../../src/core/install.js";
describe("install helpers", () => {
it("reports version matching package.json when running from a checkout", () => {
const pkgPath = fileURLToPath(new URL("../../package.json", import.meta.url));
const pkg = JSON.parse(readFileSync(pkgPath, "utf8")) as { version: string };
expect(version()).toBe(pkg.version);
});
it("returns three absolute candidates with share/pi2d/web/dist first", () => {
const candidates = staticDirCandidates();
expect(candidates).toHaveLength(3);
for (const candidate of candidates) {
expect(isAbsolute(candidate)).toBe(true);
}
const exeDir = dirname(executablePath());
const expectedFirst = resolve(exeDir, "..", "share", "pi2d", "web", "dist");
expect(candidates[0]).toBe(expectedFirst);
});
it("resolves defaultStaticDir without throwing and returns dev checkout web/dist", () => {
expect(() => defaultStaticDir()).not.toThrow();
const dir = defaultStaticDir();
expect(isAbsolute(dir)).toBe(true);
const expectedDevPath = resolve(fileURLToPath(new URL("../../web/dist", import.meta.url)));
expect(dir).toBe(expectedDevPath);
});
it("reports isBundledRuntime as false under vitest", () => {
expect(isBundledRuntime()).toBe(false);
});
it("reports runtimeDescription starting with 'node '", () => {
expect(runtimeDescription().startsWith("node ")).toBe(true);
});
});