Files
rea/tests/evaluation/package/packageSetupSupport.test.ts
CindyGestandmorluto e1897c3c17 fix(verify-package): read Hopper installer applicability from its owner (#2973)
* fix(verify-package): read Hopper installer applicability from its owner

packageSetupSupport derived hopperSetupSupported from the general doctor
host check plus a non-Windows condition, so a Debian-family host REA
supports but the Hopper package never tested reported an automated
installer the packaged setup never offers. verifySetupApply then expected
needs_confirmation for the explicit --install-hopper request and failed
at verify-package-setup.mjs:403.

Applicability now comes from readLinuxDistribution() in the built
application, so the verifier follows the predicate the package ships, and
it stays unknown when no distribution can be read instead of collapsing
into a known-unsupported host. Generic agent configuration and idempotence
assertions stay independent of installer applicability, and the expected
status is still derived from the host rather than from the request being
asserted.

Verified on Kali 2026.3, a Debian-family host with an installer-untested
distribution and the simulated Hopper package environment: before the
change npm run verify:package fails at verify-package-setup.mjs:403 with
the packaged setup correctly returning needs_human; after it the same run
passes every stage. Both applicability branches are covered by
tests/evaluation/package/packageSetupSupport.test.ts, which runs in the
source lane without a build. No real Hopper installation was exercised,
so no engine compatibility claim follows.

Refs #2939

* fix(ci): preserve Hopper doctor readiness checks

---------

Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
2026-10-14 03:19:45 +08:00

87 lines
2.7 KiB
TypeScript

import { describe, expect, it } from "vitest";
import { packageSetupSupport } from "../../../scripts/verify-package-discovery.mjs";
import { parseLinuxDistribution } from "../../../src/application/LinuxHopper.js";
const osRelease = (fields: Record<string, string>) =>
parseLinuxDistribution(
Object.entries(fields)
.map(([key, value]) => `${key}="${value}"`)
.join("\n"),
);
/** A Debian-family host REA supports that the Hopper package never tests. */
const KALI = osRelease({ ID: "kali", VERSION_ID: "2026.3", ID_LIKE: "debian" });
const UBUNTU_24 = osRelease({ ID: "ubuntu", VERSION_ID: "24.04" });
const checks = ({ node = true, host = true } = {}) => [
{ name: "node", ok: node },
{ name: "host", ok: host },
];
describe("packaged setup support derivation", () => {
it("keeps an installer-untested REA-supported distribution out of the automated Hopper path", () => {
// The doctor host check passes on Kali, so reading installer applicability
// from it promised an automated install the packaged setup never offers.
expect(
packageSetupSupport(checks(), {
platform: "linux",
linuxDistribution: KALI,
}),
).toEqual({
supportedSetupHost: true,
hopperReadinessRequired: true,
hopperSetupSupported: false,
});
});
it("follows the distribution's own applicability, not host readiness", () => {
expect(
packageSetupSupport(checks({ host: false }), {
platform: "linux",
linuxDistribution: UBUNTU_24,
}),
).toEqual({
supportedSetupHost: true,
hopperReadinessRequired: false,
hopperSetupSupported: true,
});
});
it("keeps unreadable Linux applicability unknown", () => {
expect(
packageSetupSupport(checks(), { platform: "linux" }).hopperSetupSupported,
).toBeUndefined();
});
it("uses the owner's macOS predicate and excludes Windows", () => {
expect(
packageSetupSupport(checks(), { platform: "darwin" })
.hopperSetupSupported,
).toBe(true);
expect(
packageSetupSupport(checks({ host: false }), { platform: "darwin" })
.hopperSetupSupported,
).toBe(false);
expect(
packageSetupSupport([], { platform: "darwin" }).hopperSetupSupported,
).toBeUndefined();
expect(
packageSetupSupport(checks(), { platform: "win32" }).hopperSetupSupported,
).toBe(false);
});
it("reports agent setup support from the node check alone", () => {
expect(
packageSetupSupport(checks({ node: false }), {
platform: "linux",
linuxDistribution: UBUNTU_24,
}),
).toEqual({
supportedSetupHost: false,
hopperReadinessRequired: true,
hopperSetupSupported: true,
});
});
});