TASK22224: harden awaiting-submission blob retrieval contract
This commit is contained in:
@@ -307,6 +307,55 @@ test("getrepsblob handler dependency failure returns GET_REPS_BLOB_FAILED", asyn
|
||||
assert.strictEqual(res.state.jsonBody.error.code, "GET_REPS_BLOB_FAILED");
|
||||
});
|
||||
|
||||
test("getawaitingsubmissionfromblob handler success returns payload", async () => {
|
||||
const mod = loadModule("pages/api/file/getawaitingsubmissionfromblob.js", {
|
||||
nextConnect: createNextConnectMock(),
|
||||
middleware: () => {},
|
||||
hashAPIPath: () => "&hash=expected",
|
||||
respondError: respondErrorMock,
|
||||
respondSuccess: respondSuccessMock,
|
||||
getAllProgressBlobs: async () => [{ path: "c1/case1_appeal.json" }],
|
||||
downloadAllProgressFiles: async () => ({ value: [{ id: "a1" }] })
|
||||
});
|
||||
|
||||
const req = {
|
||||
query: { container: "c1", 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)), {
|
||||
value: [{ id: "a1" }]
|
||||
});
|
||||
});
|
||||
|
||||
test("getawaitingsubmissionfromblob handler dependency failure returns GET_AWAITING_SUBMISSION_BLOB_FAILED", async () => {
|
||||
const mod = loadModule("pages/api/file/getawaitingsubmissionfromblob.js", {
|
||||
nextConnect: createNextConnectMock(),
|
||||
middleware: () => {},
|
||||
hashAPIPath: () => "&hash=expected",
|
||||
respondError: respondErrorMock,
|
||||
respondSuccess: respondSuccessMock,
|
||||
getAllProgressBlobs: async () => {
|
||||
throw new Error("progress fetch failed");
|
||||
},
|
||||
downloadAllProgressFiles: async () => ({})
|
||||
});
|
||||
|
||||
const req = {
|
||||
query: { container: "c1", hash: "expected" }
|
||||
};
|
||||
const res = createRes();
|
||||
await mod.default.handler(req, res);
|
||||
|
||||
assert.strictEqual(res.state.statusCode, 400);
|
||||
assert.strictEqual(
|
||||
res.state.jsonBody.error.code,
|
||||
"GET_AWAITING_SUBMISSION_BLOB_FAILED"
|
||||
);
|
||||
});
|
||||
|
||||
test("getbloblist handler returns INVALID_HASH for mismatch", async () => {
|
||||
const mod = loadModule("pages/api/file/getbloblist.js", {
|
||||
nextConnect: createNextConnectMock(),
|
||||
|
||||
Reference in New Issue
Block a user