refactor(api): migrate batch 6 endpoints to relayGet
This commit is contained in:
@@ -41,6 +41,8 @@ const loadModule = (relativePath, injected = {}) => {
|
||||
source +=
|
||||
'\nif (typeof ApiProxy !== "undefined" && !module.exports.default) module.exports.default = ApiProxy;\n';
|
||||
|
||||
const defaultRelayGet = async () => ({});
|
||||
|
||||
const context = {
|
||||
module: { exports: {} },
|
||||
exports: {},
|
||||
@@ -52,6 +54,7 @@ const loadModule = (relativePath, injected = {}) => {
|
||||
warn: () => {},
|
||||
error: () => {}
|
||||
},
|
||||
relayGet: defaultRelayGet,
|
||||
...injected
|
||||
};
|
||||
|
||||
|
||||
@@ -947,6 +947,7 @@ test("getbasicsearch returns SEARCH_STRING_REQUIRED when searchString missing",
|
||||
const mod = loadModule("pages/api/endpoint/getbasicsearch_api.js", {
|
||||
respondError: respondErrorMock,
|
||||
respondSuccess: respondSuccessMock,
|
||||
relayGet: async () => ({}),
|
||||
getToken: async () => ({ access_token: "token" }),
|
||||
hashAPIPath: () => "&hash=expected",
|
||||
azureHeadersPaged: () => ({}),
|
||||
@@ -966,6 +967,8 @@ test("getbasicsearch catch path returns BASIC_SEARCH_FETCH_FAILED", async () =>
|
||||
const mod = loadModule("pages/api/endpoint/getbasicsearch_api.js", {
|
||||
respondError: respondErrorMock,
|
||||
respondSuccess: respondSuccessMock,
|
||||
relayGet: async ({ res, errorResponse }) =>
|
||||
respondErrorMock(res, errorResponse),
|
||||
getToken: async () => ({ access_token: "token" }),
|
||||
hashAPIPath: () => "&hash=expected",
|
||||
azureHeadersPaged: () => ({}),
|
||||
@@ -992,6 +995,7 @@ test("getcasemessage returns CASE_ID_REQUIRED when id missing", async () => {
|
||||
const mod = loadModule("pages/api/endpoint/getcasemessage_api.js", {
|
||||
respondError: respondErrorMock,
|
||||
respondSuccess: respondSuccessMock,
|
||||
relayGet: async () => ({}),
|
||||
getToken: async () => ({ access_token: "token" }),
|
||||
hashAPIPath: () => "&hash=expected",
|
||||
azureHeadersPaged: () => ({}),
|
||||
@@ -1011,6 +1015,8 @@ test("getcasemessage catch path returns CASE_MESSAGE_FETCH_FAILED", async () =>
|
||||
const mod = loadModule("pages/api/endpoint/getcasemessage_api.js", {
|
||||
respondError: respondErrorMock,
|
||||
respondSuccess: respondSuccessMock,
|
||||
relayGet: async ({ res, errorResponse }) =>
|
||||
respondErrorMock(res, errorResponse),
|
||||
getToken: async () => ({ access_token: "token" }),
|
||||
hashAPIPath: () => "&hash=expected",
|
||||
azureHeadersPaged: () => ({}),
|
||||
@@ -1195,6 +1201,7 @@ test("getsearchdocumenthistory returns DOCUMENT_ID_REQUIRED when documentid miss
|
||||
{
|
||||
respondError: respondErrorMock,
|
||||
respondSuccess: respondSuccessMock,
|
||||
relayGet: async () => ({}),
|
||||
getToken: async () => ({ access_token: "token" }),
|
||||
hashAPIPath: () => "&hash=expected",
|
||||
azureHeadersPaged: () => ({}),
|
||||
@@ -1217,6 +1224,8 @@ test("getsearchdocumenthistory catch path returns SEARCH_DOCUMENT_HISTORY_FETCH_
|
||||
{
|
||||
respondError: respondErrorMock,
|
||||
respondSuccess: respondSuccessMock,
|
||||
relayGet: async ({ res, errorResponse }) =>
|
||||
respondErrorMock(res, errorResponse),
|
||||
getToken: async () => ({ access_token: "token" }),
|
||||
hashAPIPath: () => "&hash=expected",
|
||||
azureHeadersPaged: () => ({}),
|
||||
@@ -1246,6 +1255,10 @@ test("getsearchdocumenthistory success returns existing data payload contract",
|
||||
{
|
||||
respondError: respondErrorMock,
|
||||
respondSuccess: respondSuccessMock,
|
||||
relayGet: async ({ res }) =>
|
||||
respondSuccessMock(res, {
|
||||
value: [{ _pinswg_documentid_value: "d1" }]
|
||||
}),
|
||||
getToken: async () => ({ access_token: "token" }),
|
||||
hashAPIPath: () => "&hash=expected",
|
||||
azureHeadersPaged: () => ({}),
|
||||
@@ -1274,6 +1287,7 @@ test("getsearchdocumenthistorypaged returns DOCUMENT_ID_REQUIRED when documentid
|
||||
{
|
||||
respondError: respondErrorMock,
|
||||
respondSuccess: respondSuccessMock,
|
||||
relayGet: async () => ({}),
|
||||
getToken: async () => ({ access_token: "token" }),
|
||||
hashAPIPath: () => "&hash=expected",
|
||||
azureHeadersPaged: () => ({}),
|
||||
@@ -1296,6 +1310,8 @@ test("getsearchdocumenthistorypaged catch path returns SEARCH_DOCUMENT_HISTORY_P
|
||||
{
|
||||
respondError: respondErrorMock,
|
||||
respondSuccess: respondSuccessMock,
|
||||
relayGet: async ({ res, errorResponse }) =>
|
||||
respondErrorMock(res, errorResponse),
|
||||
getToken: async () => ({ access_token: "token" }),
|
||||
hashAPIPath: () => "&hash=expected",
|
||||
azureHeadersPaged: () => ({}),
|
||||
@@ -2065,6 +2081,8 @@ test("getbasicdnssearch catch path returns BASIC_DNS_SEARCH_FETCH_FAILED", async
|
||||
const mod = loadModule("pages/api/endpoint/getbasicdnssearch_api.js", {
|
||||
respondError: respondErrorMock,
|
||||
respondSuccess: respondSuccessMock,
|
||||
relayGet: async ({ res, errorResponse }) =>
|
||||
respondErrorMock(res, errorResponse),
|
||||
getToken: async () => ({ access_token: "token" }),
|
||||
hashAPIPath: () => "&hash=expected",
|
||||
azureHeadersPaged: () => ({}),
|
||||
@@ -2259,6 +2277,7 @@ test("getportalmoduledetails returns APPEAL_TYPE_REQUIRED when appealType missin
|
||||
const mod = loadModule("pages/api/endpoint/getportalmoduledetails_api.js", {
|
||||
respondError: respondErrorMock,
|
||||
respondSuccess: respondSuccessMock,
|
||||
relayGet: async () => ({}),
|
||||
getToken: async () => ({ access_token: "token" }),
|
||||
getSelectQuery: () => "&$select=pinswg_name",
|
||||
hashAPIPath: () => "&hash=expected",
|
||||
@@ -2279,6 +2298,8 @@ test("getportalmoduledetails catch path returns PORTAL_MODULE_DETAILS_FETCH_FAIL
|
||||
const mod = loadModule("pages/api/endpoint/getportalmoduledetails_api.js", {
|
||||
respondError: respondErrorMock,
|
||||
respondSuccess: respondSuccessMock,
|
||||
relayGet: async ({ res, errorResponse }) =>
|
||||
respondErrorMock(res, errorResponse),
|
||||
getToken: async () => ({ access_token: "token" }),
|
||||
getSelectQuery: () => "&$select=pinswg_name",
|
||||
hashAPIPath: () => "&hash=expected",
|
||||
@@ -2853,6 +2874,8 @@ test("getlpa catch path returns LPA_FETCH_FAILED", async () => {
|
||||
const mod = loadModule("pages/api/endpoint/getlpa_api.js", {
|
||||
respondError: respondErrorMock,
|
||||
respondSuccess: respondSuccessMock,
|
||||
relayGet: async ({ res, errorResponse }) =>
|
||||
respondErrorMock(res, errorResponse),
|
||||
getToken: async () => ({ access_token: "token" }),
|
||||
hashAPIPath: () => "&hash=expected",
|
||||
azureHeaders: () => ({}),
|
||||
@@ -2932,6 +2955,8 @@ test("getprojecttypes catch path returns PROJECT_TYPES_FETCH_FAILED", async () =
|
||||
const mod = loadModule("pages/api/endpoint/getprojecttypes_api.js", {
|
||||
respondError: respondErrorMock,
|
||||
respondSuccess: respondSuccessMock,
|
||||
relayGet: async ({ res, errorResponse }) =>
|
||||
respondErrorMock(res, errorResponse),
|
||||
getToken: async () => ({ access_token: "token" }),
|
||||
hashAPIPath: () => "&hash=expected",
|
||||
azureHeaders: () => ({}),
|
||||
@@ -2958,6 +2983,8 @@ test("getappealtypes catch path returns APPEAL_TYPES_FETCH_FAILED", async () =>
|
||||
const mod = loadModule("pages/api/endpoint/getappealtypes_api.js", {
|
||||
respondError: respondErrorMock,
|
||||
respondSuccess: respondSuccessMock,
|
||||
relayGet: async ({ res, errorResponse }) =>
|
||||
respondErrorMock(res, errorResponse),
|
||||
getToken: async () => ({ access_token: "token" }),
|
||||
hashAPIPath: () => "&hash=expected",
|
||||
azureHeaders: () => ({}),
|
||||
@@ -2985,6 +3012,7 @@ test("getlinkedcases returns PARENT_INCIDENT_ID_REQUIRED when parentincidentid m
|
||||
const mod = loadModule("pages/api/endpoint/getlinkedcases_api.js", {
|
||||
respondError: respondErrorMock,
|
||||
respondSuccess: respondSuccessMock,
|
||||
relayGet: async () => ({}),
|
||||
getToken: async () => ({ access_token: "token" }),
|
||||
hashAPIPath: () => "&hash=expected",
|
||||
azureHeadersPaged: () => ({}),
|
||||
@@ -3007,6 +3035,8 @@ test("getlinkedcases catch path returns LINKED_CASES_FETCH_FAILED", async () =>
|
||||
const mod = loadModule("pages/api/endpoint/getlinkedcases_api.js", {
|
||||
respondError: respondErrorMock,
|
||||
respondSuccess: respondSuccessMock,
|
||||
relayGet: async ({ res, errorResponse }) =>
|
||||
respondErrorMock(res, errorResponse),
|
||||
getToken: async () => ({ access_token: "token" }),
|
||||
hashAPIPath: () => "&hash=expected",
|
||||
azureHeadersPaged: () => ({}),
|
||||
@@ -3033,6 +3063,7 @@ test("getformdata returns WHICH_FORM_REQUIRED when whichForm missing", async ()
|
||||
const mod = loadModule("pages/api/endpoint/getformdata_api.js", {
|
||||
respondError: respondErrorMock,
|
||||
respondSuccess: respondSuccessMock,
|
||||
relayGet: async () => ({}),
|
||||
getToken: async () => ({ access_token: "token" }),
|
||||
hashAPIPath: () => "&hash=expected",
|
||||
azureHeaders: () => ({}),
|
||||
@@ -3052,6 +3083,8 @@ test("getformdata catch path returns FORM_DATA_FETCH_FAILED", async () => {
|
||||
const mod = loadModule("pages/api/endpoint/getformdata_api.js", {
|
||||
respondError: respondErrorMock,
|
||||
respondSuccess: respondSuccessMock,
|
||||
relayGet: async ({ res, errorResponse }) =>
|
||||
respondErrorMock(res, errorResponse),
|
||||
getToken: async () => ({ access_token: "token" }),
|
||||
hashAPIPath: () => "&hash=expected",
|
||||
azureHeaders: () => ({}),
|
||||
@@ -3075,6 +3108,7 @@ test("getispublishedbyid returns SEARCH_STRING_REQUIRED when searchString missin
|
||||
const mod = loadModule("pages/api/endpoint/getispublishedbyid_api.js", {
|
||||
respondError: respondErrorMock,
|
||||
respondSuccess: respondSuccessMock,
|
||||
relayGet: async () => ({}),
|
||||
getToken: async () => ({ access_token: "token" }),
|
||||
hashAPIPath: () => "&hash=expected",
|
||||
azureHeaders: () => ({}),
|
||||
@@ -3094,6 +3128,8 @@ test("getispublishedbyid catch path returns IS_PUBLISHED_FETCH_FAILED", async ()
|
||||
const mod = loadModule("pages/api/endpoint/getispublishedbyid_api.js", {
|
||||
respondError: respondErrorMock,
|
||||
respondSuccess: respondSuccessMock,
|
||||
relayGet: async ({ res, errorResponse }) =>
|
||||
respondErrorMock(res, errorResponse),
|
||||
getToken: async () => ({ access_token: "token" }),
|
||||
hashAPIPath: () => "&hash=expected",
|
||||
azureHeaders: () => ({}),
|
||||
@@ -3257,6 +3293,7 @@ test("getbasicdnsurlsearch returns SEARCH_STRING_REQUIRED when searchString miss
|
||||
const mod = loadModule("pages/api/endpoint/getbasicdnsurlsearch_api.js", {
|
||||
respondError: respondErrorMock,
|
||||
respondSuccess: respondSuccessMock,
|
||||
relayGet: async () => ({}),
|
||||
getToken: async () => ({ access_token: "token" }),
|
||||
hashAPIPath: () => "&hash=expected",
|
||||
azureHeadersPaged: () => ({}),
|
||||
@@ -3277,6 +3314,8 @@ test("getbasicdnsurlsearch catch path returns BASIC_DNS_URL_SEARCH_FETCH_FAILED"
|
||||
const mod = loadModule("pages/api/endpoint/getbasicdnsurlsearch_api.js", {
|
||||
respondError: respondErrorMock,
|
||||
respondSuccess: respondSuccessMock,
|
||||
relayGet: async ({ res, errorResponse }) =>
|
||||
respondErrorMock(res, errorResponse),
|
||||
getToken: async () => ({ access_token: "token" }),
|
||||
hashAPIPath: () => "&hash=expected",
|
||||
azureHeadersPaged: () => ({}),
|
||||
@@ -3304,6 +3343,7 @@ test("getpartsavedappeal returns SEARCH_STRING_REQUIRED when searchString missin
|
||||
const mod = loadModule("pages/api/endpoint/getpartsavedappeal_api.js", {
|
||||
respondError: respondErrorMock,
|
||||
respondSuccess: respondSuccessMock,
|
||||
relayGet: async () => ({}),
|
||||
getToken: async () => ({ access_token: "token" }),
|
||||
hashAPIPath: () => "&hash=expected",
|
||||
azureHeadersPaged: () => ({}),
|
||||
@@ -3324,6 +3364,8 @@ test("getpartsavedappeal catch path returns PART_SAVED_APPEAL_FETCH_FAILED", asy
|
||||
const mod = loadModule("pages/api/endpoint/getpartsavedappeal_api.js", {
|
||||
respondError: respondErrorMock,
|
||||
respondSuccess: respondSuccessMock,
|
||||
relayGet: async ({ res, errorResponse }) =>
|
||||
respondErrorMock(res, errorResponse),
|
||||
getToken: async () => ({ access_token: "token" }),
|
||||
hashAPIPath: () => "&hash=expected",
|
||||
azureHeadersPaged: () => ({}),
|
||||
|
||||
Reference in New Issue
Block a user