Files
reverse-engineering-anything/tests/process-global/cliLogging.test.ts
T
morluto 3c84080aab refactor(app): split Setup and ProcessOwnership modules (#628)
* refactor(domain): consolidate canonical ordering and digest helpers (#624)

* refactor(domain): consolidate canonical ordering and digest helpers

Single owner for code-point ordering (domain/canonicalOrdering.ts)
and canonical JSON digests (domain/comparisonSemantics.ts). Delete
all local compareCodePoints/compareText/digestCanonical duplicates
and migrate every importer. No re-export shims.

* fix(ci): allow slower real browser startup

* chore(config): remove dead eslint, dedupe scripts, cacheable turbo tasks

Delete eslint.config.js (oxlint is the linter), drop lint:dead alias,
pin smol-toml, fold jscpd/scan:todos into check:pr, make test:run
cacheable, align oxlint ignores.

* fix(config): hash all test inputs for cached runs

* docs: fix architecture diagram and pretty-print tool catalog

Drop dangling REPLAY edges, add dotnet/reference/error/evaluation
nodes. Emit 2-space JSON from the catalog generator and regenerate.

* test: extract shared fixtures, drop knip carve-outs

Dedupe android/apple session tests, bundler adapter headers, and
reconstruction helpers into tests/support fixtures. Delete unused
type aliases and the knip ignoreIssues block. Lower jscpd threshold
2.7 to 2.5.

* refactor(app): split Setup and ProcessOwnership modules

Extract SetupTypes/SetupHost from Setup.ts and move observation
helpers into ProcessOwnershipObservation/ProcessTree. Migrate all
importers including CLI commands. No re-export shims.
2026-10-06 05:00:32 +08:00

73 lines
2.2 KiB
TypeScript

import { afterEach, describe, expect, it } from "vitest";
import { logCliCommand } from "../../src/cliLogging.js";
import { silentLogger } from "../../src/logger.js";
import {
ArtifactOperationError,
projectAnalysisError,
} from "../../src/domain/errors.js";
import { runSetup } from "../../src/application/Setup.js";
import { isSetupFailure } from "../../src/application/SetupTypes.js";
import {
FakeSetupHost,
options as setupOptions,
} from "../../src/application/Setup.fixture.js";
const originalExitCode = process.exitCode;
afterEach(() => {
process.exitCode = originalExitCode;
});
describe("CLI operation status", () => {
it("treats a requested setup dry run and cancellation as successful outcomes", async () => {
for (const status of ["planned", "cancelled"]) {
process.exitCode = undefined;
await logCliCommand(silentLogger, "setup", () =>
Promise.resolve({ status }),
);
expect(process.exitCode).toBeUndefined();
}
});
it("keeps unapproved setup applications unsuccessful", async () => {
const host = new FakeSetupHost();
host.availableClients = [{ name: "cursor", configPath: "/cursor.json" }];
const result = await runSetup(
{ ...setupOptions(false), clientIds: ["cursor"] },
host,
);
expect(result.status).toBe("needs_confirmation");
expect(isSetupFailure(result)).toBe(true);
process.exitCode = undefined;
await logCliCommand(
silentLogger,
"setup",
() => Promise.resolve(result),
isSetupFailure,
);
expect(process.exitCode).toBe(1);
});
it("sets a nonzero process status without replacing structured output", async () => {
const output = {
error: "Analysis failed",
...projectAnalysisError(
new ArtifactOperationError("inspect_artifact", "integrity", {
logicalPath: "main.js",
declaredSha256: "a".repeat(64),
calculatedSha256: "b".repeat(64),
unpacked: false,
}),
),
};
await expect(
logCliCommand(silentLogger, "inspect-artifact", () =>
Promise.resolve(output),
),
).resolves.toBe(output);
expect(process.exitCode).toBe(1);
});
});