feat(relay): apply policy overrides for my-portal case and representation endpoints
This commit is contained in:
@@ -1725,6 +1725,32 @@ test("getmycases catch path returns MY_CASES_FETCH_FAILED", async () => {
|
||||
assert.strictEqual(res.state.jsonBody.error.code, "MY_CASES_FETCH_FAILED");
|
||||
});
|
||||
|
||||
test("getmycases passes relayPolicy overrides to relayGet", async () => {
|
||||
let capturedRelayPolicy = null;
|
||||
|
||||
const mod = loadModule("pages/api/endpoint/getmycases_api.js", {
|
||||
respondError: respondErrorMock,
|
||||
respondSuccess: respondSuccessMock,
|
||||
relayGet: async ({ relayPolicy, res }) => {
|
||||
capturedRelayPolicy = relayPolicy;
|
||||
return respondSuccessMock(res, { value: [] });
|
||||
}
|
||||
});
|
||||
|
||||
const req = { query: { loggedInUserId: "c1" } };
|
||||
const res = createRes();
|
||||
await mod.default(req, res);
|
||||
|
||||
assert.strictEqual(res.state.statusCode, 200);
|
||||
assert.deepStrictEqual(JSON.parse(JSON.stringify(capturedRelayPolicy)), {
|
||||
method: "GET",
|
||||
timeoutMs: 8000,
|
||||
maxRetries: 2,
|
||||
retryBaseDelayMs: 150,
|
||||
retryMaxDelayMs: 800
|
||||
});
|
||||
});
|
||||
|
||||
test("getmyrepresentations returns LOGGED_IN_USER_ID_REQUIRED when loggedInUserId missing", async () => {
|
||||
const mod = loadModule("pages/api/endpoint/getmyrepresentations_api.js", {
|
||||
respondError: respondErrorMock,
|
||||
@@ -1776,6 +1802,32 @@ test("getmyrepresentations catch path returns MY_REPRESENTATIONS_FETCH_FAILED",
|
||||
);
|
||||
});
|
||||
|
||||
test("getmyrepresentations passes relayPolicy overrides to relayGet", async () => {
|
||||
let capturedRelayPolicy = null;
|
||||
|
||||
const mod = loadModule("pages/api/endpoint/getmyrepresentations_api.js", {
|
||||
respondError: respondErrorMock,
|
||||
respondSuccess: respondSuccessMock,
|
||||
relayGet: async ({ relayPolicy, res }) => {
|
||||
capturedRelayPolicy = relayPolicy;
|
||||
return respondSuccessMock(res, { value: [] });
|
||||
}
|
||||
});
|
||||
|
||||
const req = { query: { loggedInUserId: "c1" } };
|
||||
const res = createRes();
|
||||
await mod.default(req, res);
|
||||
|
||||
assert.strictEqual(res.state.statusCode, 200);
|
||||
assert.deepStrictEqual(JSON.parse(JSON.stringify(capturedRelayPolicy)), {
|
||||
method: "GET",
|
||||
timeoutMs: 8000,
|
||||
maxRetries: 2,
|
||||
retryBaseDelayMs: 150,
|
||||
retryMaxDelayMs: 800
|
||||
});
|
||||
});
|
||||
|
||||
test("getwatchedcases returns LOGGED_IN_USER_ID_REQUIRED when loggedInUserId missing", async () => {
|
||||
const mod = loadModule("pages/api/endpoint/getwatchedcases_api.js", {
|
||||
respondError: respondErrorMock,
|
||||
@@ -1827,6 +1879,32 @@ test("getwatchedcases catch path returns WATCHED_CASES_FETCH_FAILED", async () =
|
||||
);
|
||||
});
|
||||
|
||||
test("getwatchedcases passes relayPolicy overrides to relayGet", async () => {
|
||||
let capturedRelayPolicy = null;
|
||||
|
||||
const mod = loadModule("pages/api/endpoint/getwatchedcases_api.js", {
|
||||
respondError: respondErrorMock,
|
||||
respondSuccess: respondSuccessMock,
|
||||
relayGet: async ({ relayPolicy, res }) => {
|
||||
capturedRelayPolicy = relayPolicy;
|
||||
return respondSuccessMock(res, { value: [] });
|
||||
}
|
||||
});
|
||||
|
||||
const req = { query: { loggedInUserId: "c1" } };
|
||||
const res = createRes();
|
||||
await mod.default(req, res);
|
||||
|
||||
assert.strictEqual(res.state.statusCode, 200);
|
||||
assert.deepStrictEqual(JSON.parse(JSON.stringify(capturedRelayPolicy)), {
|
||||
method: "GET",
|
||||
timeoutMs: 8000,
|
||||
maxRetries: 2,
|
||||
retryBaseDelayMs: 150,
|
||||
retryMaxDelayMs: 800
|
||||
});
|
||||
});
|
||||
|
||||
test("getawaitingsubmission returns LOGGED_IN_USER_ID_REQUIRED when loggedInUserId missing", async () => {
|
||||
const mod = loadModule("pages/api/endpoint/getawaitingsubmission_api.js", {
|
||||
respondError: respondErrorMock,
|
||||
@@ -1878,6 +1956,32 @@ test("getawaitingsubmission catch path returns AWAITING_SUBMISSION_FETCH_FAILED"
|
||||
);
|
||||
});
|
||||
|
||||
test("getawaitingsubmission passes relayPolicy overrides to relayGet", async () => {
|
||||
let capturedRelayPolicy = null;
|
||||
|
||||
const mod = loadModule("pages/api/endpoint/getawaitingsubmission_api.js", {
|
||||
respondError: respondErrorMock,
|
||||
respondSuccess: respondSuccessMock,
|
||||
relayGet: async ({ relayPolicy, res }) => {
|
||||
capturedRelayPolicy = relayPolicy;
|
||||
return respondSuccessMock(res, { value: [] });
|
||||
}
|
||||
});
|
||||
|
||||
const req = { query: { loggedInUserId: "c1" } };
|
||||
const res = createRes();
|
||||
await mod.default(req, res);
|
||||
|
||||
assert.strictEqual(res.state.statusCode, 200);
|
||||
assert.deepStrictEqual(JSON.parse(JSON.stringify(capturedRelayPolicy)), {
|
||||
method: "GET",
|
||||
timeoutMs: 8000,
|
||||
maxRetries: 2,
|
||||
retryBaseDelayMs: 150,
|
||||
retryMaxDelayMs: 800
|
||||
});
|
||||
});
|
||||
|
||||
test("getbasicsearchdetails returns APPEAL_TYPE_NAME_REQUIRED when appealTypeName missing", async () => {
|
||||
const mod = loadModule("pages/api/endpoint/getbasicsearchdetails_api.js", {
|
||||
respondError: respondErrorMock,
|
||||
@@ -3609,6 +3713,32 @@ test("getrepresentations catch path returns REPRESENTATIONS_FETCH_FAILED", async
|
||||
);
|
||||
});
|
||||
|
||||
test("getrepresentations passes relayPolicy overrides to relayGet", async () => {
|
||||
let capturedRelayPolicy = null;
|
||||
|
||||
const mod = loadModule("pages/api/endpoint/getrepresentations_api.js", {
|
||||
respondError: respondErrorMock,
|
||||
respondSuccess: respondSuccessMock,
|
||||
relayGet: async ({ relayPolicy, res }) => {
|
||||
capturedRelayPolicy = relayPolicy;
|
||||
return respondSuccessMock(res, { value: [] });
|
||||
}
|
||||
});
|
||||
|
||||
const req = { query: { incidentID: "i1" } };
|
||||
const res = createRes();
|
||||
await mod.default(req, res);
|
||||
|
||||
assert.strictEqual(res.state.statusCode, 200);
|
||||
assert.deepStrictEqual(JSON.parse(JSON.stringify(capturedRelayPolicy)), {
|
||||
method: "GET",
|
||||
timeoutMs: 8000,
|
||||
maxRetries: 2,
|
||||
retryBaseDelayMs: 150,
|
||||
retryMaxDelayMs: 800
|
||||
});
|
||||
});
|
||||
|
||||
test("getdnscoords catch path returns DNS_COORDS_FETCH_FAILED", async () => {
|
||||
const mod = loadModule("pages/api/endpoint/getdnscoords_api.js", {
|
||||
respondError: respondErrorMock,
|
||||
|
||||
Reference in New Issue
Block a user