fix(test): type the EngineError predicates in the learner-status web tests (CI #166 node-lane red triage — the QS dynamic import is untyped, so instanceof alone narrows nothing; the engine-client-identity assert.ok + InstanceType cast pattern)
This commit is contained in:
@@ -98,9 +98,11 @@ test("getMyApplication: no application → EngineError 404 (the apply-CTA arm)",
|
||||
);
|
||||
try {
|
||||
const { getMyApplication, EngineError } = await import(`../lib/engine-client.ts${QS}`);
|
||||
await assert.rejects(getMyApplication("post-1", "pilot-learner"), (err: unknown) =>
|
||||
err instanceof EngineError && err.status === 404,
|
||||
);
|
||||
await assert.rejects(getMyApplication("post-1", "pilot-learner"), (err: unknown) => {
|
||||
assert.ok(err instanceof EngineError, "must be EngineError");
|
||||
const e = err as InstanceType<typeof EngineError>;
|
||||
return e.status === 404;
|
||||
});
|
||||
} finally {
|
||||
restore();
|
||||
}
|
||||
@@ -146,9 +148,11 @@ test("withdrawApplication: terminal → EngineError 409 (the honest matrix refus
|
||||
);
|
||||
try {
|
||||
const { withdrawApplication, EngineError } = await import(`../lib/engine-client.ts${QS}`);
|
||||
await assert.rejects(withdrawApplication("app-1", "pilot-learner"), (err: unknown) =>
|
||||
err instanceof EngineError && err.status === 409,
|
||||
);
|
||||
await assert.rejects(withdrawApplication("app-1", "pilot-learner"), (err: unknown) => {
|
||||
assert.ok(err instanceof EngineError, "must be EngineError");
|
||||
const e = err as InstanceType<typeof EngineError>;
|
||||
return e.status === 409;
|
||||
});
|
||||
} finally {
|
||||
restore();
|
||||
}
|
||||
@@ -160,10 +164,11 @@ test("getLearnerApplicationStatus: foreign → EngineError 403 (the not-your-app
|
||||
);
|
||||
try {
|
||||
const { getLearnerApplicationStatus, EngineError } = await import(`../lib/engine-client.ts${QS}`);
|
||||
await assert.rejects(
|
||||
getLearnerApplicationStatus("app-1", "pilot-learner"),
|
||||
(err: unknown) => err instanceof EngineError && err.status === 403,
|
||||
);
|
||||
await assert.rejects(getLearnerApplicationStatus("app-1", "pilot-learner"), (err: unknown) => {
|
||||
assert.ok(err instanceof EngineError, "must be EngineError");
|
||||
const e = err as InstanceType<typeof EngineError>;
|
||||
return e.status === 403;
|
||||
});
|
||||
} finally {
|
||||
restore();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user