TASK22224: big parity bundle for completion message routes

This commit is contained in:
2026-03-23 18:09:36 +00:00
parent 9f5ec6f50a
commit 91a0ab82ea
4 changed files with 200 additions and 109 deletions
@@ -485,6 +485,68 @@ test("uploadsinglefile handler dependency failure returns UPLOAD_SINGLE_FILE_FAI
);
});
test("createrepcompletemessage handler accepts encoded hash variant", async () => {
const mod = loadModule("pages/api/file/createrepcompletemessage_api.js", {
nextConnect: createNextConnectMock(),
middleware: () => {},
hashAPIPath: (queryPath) =>
queryPath.includes("repid=rep%201")
? "&hash=expected"
: "&hash=other",
respondError: respondErrorMock,
respondSuccess: respondSuccessMock,
consoleLogger: () => {},
createRepCompleteMessage: async () => ({ ok: true })
});
const req = {
query: {
container: "c1",
tempcaseref: "TMP/1",
repid: "rep 1",
hash: "expected"
}
};
const res = createRes();
await mod.default.handler(req, res);
assert.strictEqual(res.state.statusCode, 200);
assert.deepStrictEqual(JSON.parse(JSON.stringify(res.state.jsonBody)), {
ok: true
});
});
test("createrepcompletemessage handler dependency failure returns CREATE_REP_COMPLETE_MESSAGE_FAILED", async () => {
const mod = loadModule("pages/api/file/createrepcompletemessage_api.js", {
nextConnect: createNextConnectMock(),
middleware: () => {},
hashAPIPath: () => "&hash=expected",
respondError: respondErrorMock,
respondSuccess: respondSuccessMock,
consoleLogger: () => {},
createRepCompleteMessage: async () => {
throw new Error("rep message failed");
}
});
const req = {
query: {
container: "c1",
tempcaseref: "TMP1",
repid: "rep1",
hash: "expected"
}
};
const res = createRes();
await mod.default.handler(req, res);
assert.strictEqual(res.state.statusCode, 400);
assert.strictEqual(
res.state.jsonBody.error.code,
"CREATE_REP_COMPLETE_MESSAGE_FAILED"
);
});
test("getawaitingsubmissionfromblob handler success returns payload", async () => {
const mod = loadModule("pages/api/file/getawaitingsubmissionfromblob.js", {
nextConnect: createNextConnectMock(),