Files
reverse-engineering-anything/tests/boundary/firmware/firmwareValidationProjection.test.ts
T
morluto 352a846127 test: reduce brittle assertions and test-only runtime paths (#9289)
* test: focus assertions on behavioral evidence

Prune redundant and wording-coupled checks while retaining diagnostic, parser, recovery, and cleanup coverage.

* refactor: remove test-only wrappers and duplicate checks

Exercise production operations through test fixtures, remove unused adapters, and keep managed-member uncertainty guidance under its existing owner.

* test: focus process validation on diagnostic facts

* refactor: remove test-only runtime helpers

Move semantic evidence fixture setup out of runtime and remove unused Windows settle recovery helpers while checking configured defaults independently.

* test: focus artifact diagnostics on format facts

* test: verify retained cleanup guidance delivery
2026-11-08 02:02:31 +08:00

60 lines
1.8 KiB
TypeScript

import { describe, expect, it, vi } from "vitest";
import { FirmwareAnalysisService } from "../../../src/application/firmware/FirmwareAnalysisService.js";
import { analysisErrorProjectionSchema } from "../../../src/contracts/errorSchemas.js";
import { projectAnalysisError } from "../../../src/domain/analysisErrorProjection.js";
describe("firmware request validation projection", () => {
it.each([
{
input: {
path: "/tmp/firmware.bin",
output_directory: "/tmp/out",
range: { offset: 5 },
},
missing: "length",
},
{
input: {
path: "/tmp/firmware.bin",
output_directory: "/tmp/out",
range: { length: 5 },
},
missing: "offset",
},
] as const)(
"identifies missing range.$missing before provider admission",
async ({ input, missing }) => {
const execute = vi.fn(async () => {
throw new Error("Provider must not execute for invalid input");
});
const service = new FirmwareAnalysisService({ execute });
const result = await service.execute("extract_firmware", input);
if (result.ok) throw new Error("Expected request validation to fail");
const projected = projectAnalysisError(result.error);
expect(analysisErrorProjectionSchema.safeParse(projected).success).toBe(
true,
);
expect(projected).toMatchObject({
code: "invalid_request",
category: "invalid_input",
retryable: false,
details: {
operation: "extract_firmware",
issues: [
{
path: ["range", missing],
reason: "missing_argument",
},
],
},
remediation: {
action: expect.stringContaining("Correct the listed fields"),
},
});
expect(execute).not.toHaveBeenCalled();
},
);
});