Merged PR 2164: test(actions): phase 6 add parity and behavioural service hardening checks
test(actions): phase 6 add parity and behavioural service hardening checks Related work items: #21998
This commit is contained in:
@@ -1,14 +1,13 @@
|
|||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import { BASE_URL } from "../core/env";
|
import { BASE_URL } from "../core/env";
|
||||||
import { consoleLogger } from "../core/logger";
|
import { logAndReturnResponse } from "./httpServiceUtils";
|
||||||
|
|
||||||
export const getNewAppeals = async (searchString) => {
|
export const getNewAppeals = async (searchString) => {
|
||||||
try {
|
try {
|
||||||
const res = await axios.get(BASE_URL + "/api/admin/getnewappeals_api");
|
const res = await axios.get(BASE_URL + "/api/admin/getnewappeals_api");
|
||||||
return res.data;
|
return res.data;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
consoleLogger(error);
|
return logAndReturnResponse(error);
|
||||||
return error.response;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -35,10 +34,7 @@ export const getNewAppealsPage = async (
|
|||||||
.then((res) => {
|
.then((res) => {
|
||||||
return res.data;
|
return res.data;
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch(logAndReturnResponse);
|
||||||
consoleLogger(error);
|
|
||||||
return error.response;
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getNewDocumentsPaged = async (
|
export const getNewDocumentsPaged = async (
|
||||||
@@ -50,22 +46,6 @@ export const getNewDocumentsPaged = async (
|
|||||||
documentOrigin,
|
documentOrigin,
|
||||||
selectedWeeks
|
selectedWeeks
|
||||||
) => {
|
) => {
|
||||||
console.log(
|
|
||||||
"/api/admin/getlatestdocuments_api?pageNumber=" +
|
|
||||||
pageNumber +
|
|
||||||
"&orderby=" +
|
|
||||||
orderBy +
|
|
||||||
"&fieldSort=" +
|
|
||||||
fieldSort +
|
|
||||||
"&showNumberOfRecords=" +
|
|
||||||
showNumberOfRecords +
|
|
||||||
"&documentType=" +
|
|
||||||
documentType +
|
|
||||||
"&numberWeeks=" +
|
|
||||||
selectedWeeks +
|
|
||||||
"&documentOrigin=" +
|
|
||||||
documentOrigin
|
|
||||||
);
|
|
||||||
return axios
|
return axios
|
||||||
.get(
|
.get(
|
||||||
"/api/admin/getlatestdocuments_api?pageNumber=" +
|
"/api/admin/getlatestdocuments_api?pageNumber=" +
|
||||||
@@ -86,8 +66,5 @@ export const getNewDocumentsPaged = async (
|
|||||||
.then((res) => {
|
.then((res) => {
|
||||||
return res.data;
|
return res.data;
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch(logAndReturnResponse);
|
||||||
consoleLogger(error);
|
|
||||||
return error.response;
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import { BASE_URL } from "../core/env";
|
import { BASE_URL } from "../core/env";
|
||||||
import { consoleLogger } from "../core/logger";
|
import { consoleLogger } from "../core/logger";
|
||||||
|
import { logAndReturnResponse } from "./httpServiceUtils";
|
||||||
|
|
||||||
export const getCaseMessage = (searchString) => {
|
export const getCaseMessage = (searchString) => {
|
||||||
return axios
|
return axios
|
||||||
@@ -8,10 +9,7 @@ export const getCaseMessage = (searchString) => {
|
|||||||
.then((res) => {
|
.then((res) => {
|
||||||
return res.data;
|
return res.data;
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch(logAndReturnResponse);
|
||||||
consoleLogger(error);
|
|
||||||
return error.response;
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getIncidentbyID = (searchString) => {
|
export const getIncidentbyID = (searchString) => {
|
||||||
@@ -24,10 +22,7 @@ export const getIncidentbyID = (searchString) => {
|
|||||||
.then((res) => {
|
.then((res) => {
|
||||||
return res.data;
|
return res.data;
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch(logAndReturnResponse);
|
||||||
consoleLogger(error);
|
|
||||||
return error.response;
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getIsPublishedbyID = (searchString) => {
|
export const getIsPublishedbyID = (searchString) => {
|
||||||
@@ -38,10 +33,7 @@ export const getIsPublishedbyID = (searchString) => {
|
|||||||
.then((res) => {
|
.then((res) => {
|
||||||
return res.data;
|
return res.data;
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch(logAndReturnResponse);
|
||||||
consoleLogger(error);
|
|
||||||
return error.response;
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getPartSavedAppeal = (searchString) => {
|
export const getPartSavedAppeal = (searchString) => {
|
||||||
@@ -54,10 +46,7 @@ export const getPartSavedAppeal = (searchString) => {
|
|||||||
.then((res) => {
|
.then((res) => {
|
||||||
return res.data;
|
return res.data;
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch(logAndReturnResponse);
|
||||||
consoleLogger(error);
|
|
||||||
return error.response;
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getSIPSEvents = async (caseid) => {
|
export const getSIPSEvents = async (caseid) => {
|
||||||
@@ -66,10 +55,7 @@ export const getSIPSEvents = async (caseid) => {
|
|||||||
.then((res) => {
|
.then((res) => {
|
||||||
return res.data;
|
return res.data;
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch(logAndReturnResponse);
|
||||||
consoleLogger(error);
|
|
||||||
return error.response;
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getSIPSMedia = async (caseid) => {
|
export const getSIPSMedia = async (caseid) => {
|
||||||
@@ -78,10 +64,7 @@ export const getSIPSMedia = async (caseid) => {
|
|||||||
.then((res) => {
|
.then((res) => {
|
||||||
return res.data;
|
return res.data;
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch(logAndReturnResponse);
|
||||||
consoleLogger(error);
|
|
||||||
return error.response;
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getAppealID = (
|
export const getAppealID = (
|
||||||
@@ -342,7 +325,6 @@ export const getPortalModuleDetails = async (appealType, caseReference) => {
|
|||||||
const res = await axios(config);
|
const res = await axios(config);
|
||||||
return res.data;
|
return res.data;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log("error case ref:", caseReference);
|
|
||||||
consoleLogger(error);
|
consoleLogger(error);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -50,14 +50,6 @@ export const getRepsFromBlobProxy = async (containerName) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const getAwaitingSubmissionFromBlobProxy = async (containerName) => {
|
export const getAwaitingSubmissionFromBlobProxy = async (containerName) => {
|
||||||
console.log(
|
|
||||||
"///////////////////////getAwaitingSubmissionFromBlobProxy: " +
|
|
||||||
containerName,
|
|
||||||
"/api/file/getawaitingsubmissionfromblobproxy?container=" +
|
|
||||||
containerName,
|
|
||||||
"\n///////////////////////\n"
|
|
||||||
);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const res = await axios.get(
|
const res = await axios.get(
|
||||||
BASE_URL +
|
BASE_URL +
|
||||||
@@ -163,7 +155,6 @@ export const uploadSingleFile = async (filesObj, containerID, casefolderID) => {
|
|||||||
formData.append("casefolderID", casefolderID);
|
formData.append("casefolderID", casefolderID);
|
||||||
|
|
||||||
for (let i = 0; i < files.length; i++) {
|
for (let i = 0; i < files.length; i++) {
|
||||||
console.log(files.length);
|
|
||||||
formData.append(files[i].name, files[i]);
|
formData.append(files[i].name, files[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -219,8 +210,6 @@ export const generateRepPDF = async (
|
|||||||
casefolderID,
|
casefolderID,
|
||||||
options = {}
|
options = {}
|
||||||
) => {
|
) => {
|
||||||
console.log("generateRepPDF function: " + formValues);
|
|
||||||
|
|
||||||
var queryUrl =
|
var queryUrl =
|
||||||
"/api/file/generatepdf" + (options.download ? "?download=true" : "");
|
"/api/file/generatepdf" + (options.download ? "?download=true" : "");
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
import { consoleLogger } from "../core/logger";
|
||||||
|
|
||||||
|
export const buildEmptyValueErrorResponse = (error) => {
|
||||||
|
return {
|
||||||
|
value: [],
|
||||||
|
errorCode: error.response.status,
|
||||||
|
errorMsg: error.response.statusText
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
export const logAndReturnResponse = (error) => {
|
||||||
|
consoleLogger(error);
|
||||||
|
return error.response;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const logAndReturnEmptyValueErrorResponse = (error) => {
|
||||||
|
consoleLogger(error);
|
||||||
|
return buildEmptyValueErrorResponse(error);
|
||||||
|
};
|
||||||
@@ -237,7 +237,6 @@ export const sendCaseCompleteMessage = async (
|
|||||||
|
|
||||||
return axios(config)
|
return axios(config)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
console.log("sendCaseCompleteMessage: ", res.data);
|
|
||||||
return res.data;
|
return res.data;
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
|
|||||||
@@ -1,53 +1,27 @@
|
|||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import { BASE_URL } from "../core/env";
|
import { BASE_URL } from "../core/env";
|
||||||
import { consoleLogger } from "../core/logger";
|
import { consoleLogger } from "../core/logger";
|
||||||
|
import { logAndReturnEmptyValueErrorResponse } from "./httpServiceUtils";
|
||||||
|
|
||||||
export const getAppealsTypes = () => {
|
export const getAppealsTypes = () => {
|
||||||
return axios
|
return axios
|
||||||
.get(BASE_URL + "/api/endpoint/getappealtypes_api")
|
.get(BASE_URL + "/api/endpoint/getappealtypes_api")
|
||||||
.then((res) => res.data)
|
.then((res) => res.data)
|
||||||
.catch((error) => {
|
.catch(logAndReturnEmptyValueErrorResponse);
|
||||||
consoleLogger(error);
|
|
||||||
let ErrResponse = {
|
|
||||||
value: [],
|
|
||||||
errorCode: error.response.status,
|
|
||||||
errorMsg: error.response.statusText
|
|
||||||
};
|
|
||||||
|
|
||||||
return ErrResponse;
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getProjectTypes = () => {
|
export const getProjectTypes = () => {
|
||||||
return axios
|
return axios
|
||||||
.get(BASE_URL + "/api/endpoint/getprojecttypes_api")
|
.get(BASE_URL + "/api/endpoint/getprojecttypes_api")
|
||||||
.then((res) => res.data)
|
.then((res) => res.data)
|
||||||
.catch((error) => {
|
.catch(logAndReturnEmptyValueErrorResponse);
|
||||||
consoleLogger(error);
|
|
||||||
let ErrResponse = {
|
|
||||||
value: [],
|
|
||||||
errorCode: error.response.status,
|
|
||||||
errorMsg: error.response.statusText
|
|
||||||
};
|
|
||||||
|
|
||||||
return ErrResponse;
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getAppealsTypesForNewAppeal = () => {
|
export const getAppealsTypesForNewAppeal = () => {
|
||||||
return axios
|
return axios
|
||||||
.get(BASE_URL + "/api/endpoint/getappealtypesfornewappeal_api")
|
.get(BASE_URL + "/api/endpoint/getappealtypesfornewappeal_api")
|
||||||
.then((res) => res.data)
|
.then((res) => res.data)
|
||||||
.catch((error) => {
|
.catch(logAndReturnEmptyValueErrorResponse);
|
||||||
consoleLogger(error);
|
|
||||||
let ErrResponse = {
|
|
||||||
value: [],
|
|
||||||
errorCode: error.response.status,
|
|
||||||
errorMsg: error.response.statusText
|
|
||||||
};
|
|
||||||
|
|
||||||
return ErrResponse;
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getLPA = () => {
|
export const getLPA = () => {
|
||||||
@@ -56,16 +30,7 @@ export const getLPA = () => {
|
|||||||
.then((res) => {
|
.then((res) => {
|
||||||
return res.data;
|
return res.data;
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch(logAndReturnEmptyValueErrorResponse);
|
||||||
consoleLogger(error);
|
|
||||||
let ErrResponse = {
|
|
||||||
value: [],
|
|
||||||
errorCode: error.response.status,
|
|
||||||
errorMsg: error.response.statusText
|
|
||||||
};
|
|
||||||
|
|
||||||
return ErrResponse;
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getFormData = (whichForm) => {
|
export const getFormData = (whichForm) => {
|
||||||
|
|||||||
@@ -1,6 +1,10 @@
|
|||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import { BASE_URL } from "../core/env";
|
import { BASE_URL } from "../core/env";
|
||||||
import { consoleLogger } from "../core/logger";
|
import { consoleLogger } from "../core/logger";
|
||||||
|
import {
|
||||||
|
logAndReturnResponse,
|
||||||
|
logAndReturnEmptyValueErrorResponse
|
||||||
|
} from "./httpServiceUtils";
|
||||||
|
|
||||||
export const getBasicSearch = (searchString) => {
|
export const getBasicSearch = (searchString) => {
|
||||||
return axios
|
return axios
|
||||||
@@ -12,10 +16,7 @@ export const getBasicSearch = (searchString) => {
|
|||||||
.then((res) => {
|
.then((res) => {
|
||||||
return res.data;
|
return res.data;
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch(logAndReturnResponse);
|
||||||
consoleLogger(error);
|
|
||||||
return error.response;
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getBasicDNSURLSearch = (searchString) => {
|
export const getBasicDNSURLSearch = (searchString) => {
|
||||||
@@ -28,10 +29,7 @@ export const getBasicDNSURLSearch = (searchString) => {
|
|||||||
.then((res) => {
|
.then((res) => {
|
||||||
return res.data;
|
return res.data;
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch(logAndReturnResponse);
|
||||||
consoleLogger(error);
|
|
||||||
return error.response;
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getAddressSearchPaged = (
|
export const getAddressSearchPaged = (
|
||||||
@@ -57,10 +55,7 @@ export const getAddressSearchPaged = (
|
|||||||
.then((res) => {
|
.then((res) => {
|
||||||
return res.data;
|
return res.data;
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch(logAndReturnResponse);
|
||||||
consoleLogger(error);
|
|
||||||
return error.response;
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getBasicSearchPaged = (
|
export const getBasicSearchPaged = (
|
||||||
@@ -86,10 +81,7 @@ export const getBasicSearchPaged = (
|
|||||||
.then((res) => {
|
.then((res) => {
|
||||||
return res.data;
|
return res.data;
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch(logAndReturnResponse);
|
||||||
consoleLogger(error);
|
|
||||||
return error.response;
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getDNSCoords = () => {
|
export const getDNSCoords = () => {
|
||||||
@@ -98,36 +90,21 @@ export const getDNSCoords = () => {
|
|||||||
.then((res) => {
|
.then((res) => {
|
||||||
return res.data;
|
return res.data;
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch(logAndReturnEmptyValueErrorResponse);
|
||||||
consoleLogger(error);
|
|
||||||
let ErrResponse = {
|
|
||||||
value: [],
|
|
||||||
errorCode: error.response.status,
|
|
||||||
errorMsg: error.response.statusText
|
|
||||||
};
|
|
||||||
|
|
||||||
return ErrResponse;
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getDNSList = (searchString) => {
|
export const getDNSList = (searchString) => {
|
||||||
return axios
|
return axios
|
||||||
.get(BASE_URL + "/api/endpoint/getdnslist_api")
|
.get(BASE_URL + "/api/endpoint/getdnslist_api")
|
||||||
.then((res) => res.data)
|
.then((res) => res.data)
|
||||||
.catch((error) => {
|
.catch(logAndReturnResponse);
|
||||||
consoleLogger(error);
|
|
||||||
return error.response;
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getBasicDNSSearch = (searchString) => {
|
export const getBasicDNSSearch = (searchString) => {
|
||||||
return axios
|
return axios
|
||||||
.get(BASE_URL + "/api/endpoint/getbasicdnssearch_api")
|
.get(BASE_URL + "/api/endpoint/getbasicdnssearch_api")
|
||||||
.then((res) => res.data)
|
.then((res) => res.data)
|
||||||
.catch((error) => {
|
.catch(logAndReturnResponse);
|
||||||
consoleLogger(error);
|
|
||||||
return error.response;
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getBasicDNSSearchPaged = (
|
export const getBasicDNSSearchPaged = (
|
||||||
@@ -148,10 +125,7 @@ export const getBasicDNSSearchPaged = (
|
|||||||
showNumberOfRecords
|
showNumberOfRecords
|
||||||
)
|
)
|
||||||
.then((res) => res.data)
|
.then((res) => res.data)
|
||||||
.catch((error) => {
|
.catch(logAndReturnResponse);
|
||||||
consoleLogger(error);
|
|
||||||
return error.response;
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getAdvancedSearch = (searchString) => {
|
export const getAdvancedSearch = (searchString) => {
|
||||||
@@ -162,16 +136,7 @@ export const getAdvancedSearch = (searchString) => {
|
|||||||
JSON.stringify(searchString)
|
JSON.stringify(searchString)
|
||||||
)
|
)
|
||||||
.then((res) => res.data)
|
.then((res) => res.data)
|
||||||
.catch((error) => {
|
.catch(logAndReturnEmptyValueErrorResponse);
|
||||||
consoleLogger(error);
|
|
||||||
let ErrResponse = {
|
|
||||||
value: [],
|
|
||||||
errorCode: error.response.status,
|
|
||||||
errorMsg: error.response.statusText
|
|
||||||
};
|
|
||||||
|
|
||||||
return ErrResponse;
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getAdvancedSearchPaged = (
|
export const getAdvancedSearchPaged = (
|
||||||
@@ -195,16 +160,7 @@ export const getAdvancedSearchPaged = (
|
|||||||
showNumberOfRecords
|
showNumberOfRecords
|
||||||
)
|
)
|
||||||
.then((res) => res.data)
|
.then((res) => res.data)
|
||||||
.catch((error) => {
|
.catch(logAndReturnEmptyValueErrorResponse);
|
||||||
consoleLogger(error);
|
|
||||||
let ErrResponse = {
|
|
||||||
value: [],
|
|
||||||
errorCode: error.response.status,
|
|
||||||
errorMsg: error.response.statusText
|
|
||||||
};
|
|
||||||
|
|
||||||
return ErrResponse;
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getBasicSearchDetails = async (
|
export const getBasicSearchDetails = async (
|
||||||
@@ -247,7 +203,7 @@ export const getBasicPartSavedDetails = (
|
|||||||
)
|
)
|
||||||
.then((res) => res.data)
|
.then((res) => res.data)
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
console.log("this error", error);
|
consoleLogger(error);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -259,8 +215,6 @@ export const getBasicSearchDetailsPaged = async (
|
|||||||
) => {
|
) => {
|
||||||
if (!incidentIDs || incidentIDs.length === 0) return [];
|
if (!incidentIDs || incidentIDs.length === 0) return [];
|
||||||
|
|
||||||
console.log("=======", primaryIdAttribute);
|
|
||||||
|
|
||||||
const filter = incidentIDs
|
const filter = incidentIDs
|
||||||
.map((id) => {
|
.map((id) => {
|
||||||
const suffix =
|
const suffix =
|
||||||
@@ -276,10 +230,6 @@ export const getBasicSearchDetailsPaged = async (
|
|||||||
filter
|
filter
|
||||||
)}`;
|
)}`;
|
||||||
|
|
||||||
console.log(
|
|
||||||
`Fetching ${incidentIDs.length} incidents for appeal type: ${appealTypeName}`
|
|
||||||
);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const res = await axios.get(url);
|
const res = await axios.get(url);
|
||||||
return res.data.value || [];
|
return res.data.value || [];
|
||||||
@@ -372,13 +322,5 @@ export const getAddressSearch = async (searchString) => {
|
|||||||
.then((res) => {
|
.then((res) => {
|
||||||
return res.data;
|
return res.data;
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch(logAndReturnEmptyValueErrorResponse);
|
||||||
consoleLogger(error);
|
|
||||||
let ErrResponse = {
|
|
||||||
value: [],
|
|
||||||
errorCode: error.response.status,
|
|
||||||
errorMsg: error.response.statusText
|
|
||||||
};
|
|
||||||
return ErrResponse;
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -0,0 +1,309 @@
|
|||||||
|
const fs = require("fs");
|
||||||
|
const path = require("path");
|
||||||
|
const vm = require("vm");
|
||||||
|
const assert = require("assert");
|
||||||
|
|
||||||
|
const rootDir = path.resolve(__dirname, "..", "..");
|
||||||
|
const servicesDir = path.join(rootDir, "actions", "services");
|
||||||
|
|
||||||
|
const createAxiosMock = () => {
|
||||||
|
const axios = (config) => axios.request(config);
|
||||||
|
|
||||||
|
axios.calls = [];
|
||||||
|
axios.requestHandler = async () => {
|
||||||
|
throw new Error("No axios.request handler configured");
|
||||||
|
};
|
||||||
|
axios.getHandler = async () => {
|
||||||
|
throw new Error("No axios.get handler configured");
|
||||||
|
};
|
||||||
|
axios.postHandler = async () => {
|
||||||
|
throw new Error("No axios.post handler configured");
|
||||||
|
};
|
||||||
|
|
||||||
|
axios.request = (config) => {
|
||||||
|
axios.calls.push({ type: "request", config });
|
||||||
|
return axios.requestHandler(config);
|
||||||
|
};
|
||||||
|
|
||||||
|
axios.get = (url, config) => {
|
||||||
|
axios.calls.push({ type: "get", url, config });
|
||||||
|
return axios.getHandler(url, config);
|
||||||
|
};
|
||||||
|
|
||||||
|
axios.post = (url, data, config) => {
|
||||||
|
axios.calls.push({ type: "post", url, data, config });
|
||||||
|
return axios.postHandler(url, data, config);
|
||||||
|
};
|
||||||
|
|
||||||
|
return axios;
|
||||||
|
};
|
||||||
|
|
||||||
|
const createLoggerMock = () => {
|
||||||
|
const calls = [];
|
||||||
|
const consoleLogger = (error) => {
|
||||||
|
calls.push(error);
|
||||||
|
};
|
||||||
|
return { consoleLogger, calls };
|
||||||
|
};
|
||||||
|
|
||||||
|
const createAxiosError = (status = 500, statusText = "Server Error") => {
|
||||||
|
return {
|
||||||
|
response: {
|
||||||
|
status,
|
||||||
|
statusText,
|
||||||
|
data: {}
|
||||||
|
},
|
||||||
|
config: {
|
||||||
|
url: "/mock-url"
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
const loadServiceModule = (fileName, injected = {}) => {
|
||||||
|
const filePath = path.join(servicesDir, fileName);
|
||||||
|
let source = fs.readFileSync(filePath, "utf8");
|
||||||
|
|
||||||
|
source = source.replace(/import[\s\S]*?from\s+"[^"]+";\n?/g, "");
|
||||||
|
|
||||||
|
const exportNames = Array.from(
|
||||||
|
source.matchAll(/export const\s+(\w+)\s*=/g)
|
||||||
|
).map((match) => match[1]);
|
||||||
|
|
||||||
|
source = source.replace(/export const\s+/g, "const ");
|
||||||
|
source += `\nmodule.exports = { ${exportNames.join(", ")} };\n`;
|
||||||
|
|
||||||
|
const context = {
|
||||||
|
module: { exports: {} },
|
||||||
|
exports: {},
|
||||||
|
require,
|
||||||
|
URLSearchParams,
|
||||||
|
encodeURIComponent,
|
||||||
|
FormData: global.FormData,
|
||||||
|
console: {
|
||||||
|
log: () => {},
|
||||||
|
info: () => {},
|
||||||
|
warn: () => {},
|
||||||
|
error: () => {}
|
||||||
|
},
|
||||||
|
...injected
|
||||||
|
};
|
||||||
|
|
||||||
|
vm.runInNewContext(source, context, { filename: filePath });
|
||||||
|
return context.module.exports;
|
||||||
|
};
|
||||||
|
|
||||||
|
const tests = [];
|
||||||
|
|
||||||
|
const test = (name, fn) => {
|
||||||
|
tests.push({ name, fn });
|
||||||
|
};
|
||||||
|
|
||||||
|
const normalize = (value) => JSON.parse(JSON.stringify(value));
|
||||||
|
|
||||||
|
test("search/getBasicSearch returns res.data on success", async () => {
|
||||||
|
const axios = createAxiosMock();
|
||||||
|
const logger = createLoggerMock();
|
||||||
|
const helpers = loadServiceModule("httpServiceUtils.js", {
|
||||||
|
consoleLogger: logger.consoleLogger
|
||||||
|
});
|
||||||
|
|
||||||
|
axios.getHandler = async () => ({ data: { value: ["ok"] } });
|
||||||
|
|
||||||
|
const search = loadServiceModule("searchDirectService.js", {
|
||||||
|
axios,
|
||||||
|
BASE_URL: "http://example.local",
|
||||||
|
consoleLogger: logger.consoleLogger,
|
||||||
|
...helpers
|
||||||
|
});
|
||||||
|
|
||||||
|
const result = await search.getBasicSearch("abc");
|
||||||
|
|
||||||
|
assert.deepStrictEqual(normalize(result), { value: ["ok"] });
|
||||||
|
assert.strictEqual(
|
||||||
|
axios.calls[0].url,
|
||||||
|
"http://example.local/api/endpoint/getbasicsearch_api?searchString=abc"
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("search/getBasicSearch returns error.response on failure", async () => {
|
||||||
|
const axios = createAxiosMock();
|
||||||
|
const logger = createLoggerMock();
|
||||||
|
const helpers = loadServiceModule("httpServiceUtils.js", {
|
||||||
|
consoleLogger: logger.consoleLogger
|
||||||
|
});
|
||||||
|
|
||||||
|
const error = createAxiosError(503, "Unavailable");
|
||||||
|
axios.getHandler = async () => Promise.reject(error);
|
||||||
|
|
||||||
|
const search = loadServiceModule("searchDirectService.js", {
|
||||||
|
axios,
|
||||||
|
BASE_URL: "",
|
||||||
|
consoleLogger: logger.consoleLogger,
|
||||||
|
...helpers
|
||||||
|
});
|
||||||
|
|
||||||
|
const result = await search.getBasicSearch("abc");
|
||||||
|
|
||||||
|
assert.strictEqual(result, error.response);
|
||||||
|
assert.strictEqual(logger.calls.length, 1);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("search/getAdvancedSearch preserves ErrResponse shape on failure", async () => {
|
||||||
|
const axios = createAxiosMock();
|
||||||
|
const logger = createLoggerMock();
|
||||||
|
const helpers = loadServiceModule("httpServiceUtils.js", {
|
||||||
|
consoleLogger: logger.consoleLogger
|
||||||
|
});
|
||||||
|
|
||||||
|
axios.getHandler = async () =>
|
||||||
|
Promise.reject(createAxiosError(400, "Bad Request"));
|
||||||
|
|
||||||
|
const search = loadServiceModule("searchDirectService.js", {
|
||||||
|
axios,
|
||||||
|
BASE_URL: "",
|
||||||
|
consoleLogger: logger.consoleLogger,
|
||||||
|
...helpers
|
||||||
|
});
|
||||||
|
|
||||||
|
const result = await search.getAdvancedSearch({ foo: "bar" });
|
||||||
|
|
||||||
|
assert.deepStrictEqual(normalize(result), {
|
||||||
|
value: [],
|
||||||
|
errorCode: 400,
|
||||||
|
errorMsg: "Bad Request"
|
||||||
|
});
|
||||||
|
assert.strictEqual(logger.calls.length, 1);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("reference/getAppealsTypes preserves ErrResponse shape on failure", async () => {
|
||||||
|
const axios = createAxiosMock();
|
||||||
|
const logger = createLoggerMock();
|
||||||
|
const helpers = loadServiceModule("httpServiceUtils.js", {
|
||||||
|
consoleLogger: logger.consoleLogger
|
||||||
|
});
|
||||||
|
|
||||||
|
axios.getHandler = async () =>
|
||||||
|
Promise.reject(createAxiosError(404, "Not Found"));
|
||||||
|
|
||||||
|
const reference = loadServiceModule("referenceDataDirectService.js", {
|
||||||
|
axios,
|
||||||
|
BASE_URL: "",
|
||||||
|
consoleLogger: logger.consoleLogger,
|
||||||
|
...helpers
|
||||||
|
});
|
||||||
|
|
||||||
|
const result = await reference.getAppealsTypes();
|
||||||
|
|
||||||
|
assert.deepStrictEqual(normalize(result), {
|
||||||
|
value: [],
|
||||||
|
errorCode: 404,
|
||||||
|
errorMsg: "Not Found"
|
||||||
|
});
|
||||||
|
assert.strictEqual(logger.calls.length, 1);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("case/getCaseMessage returns error.response on failure", async () => {
|
||||||
|
const axios = createAxiosMock();
|
||||||
|
const logger = createLoggerMock();
|
||||||
|
const helpers = loadServiceModule("httpServiceUtils.js", {
|
||||||
|
consoleLogger: logger.consoleLogger
|
||||||
|
});
|
||||||
|
const error = createAxiosError(500, "Error");
|
||||||
|
|
||||||
|
axios.getHandler = async () => Promise.reject(error);
|
||||||
|
|
||||||
|
const caseService = loadServiceModule("caseDirectService.js", {
|
||||||
|
axios,
|
||||||
|
BASE_URL: "",
|
||||||
|
consoleLogger: logger.consoleLogger,
|
||||||
|
...helpers
|
||||||
|
});
|
||||||
|
|
||||||
|
const result = await caseService.getCaseMessage("x");
|
||||||
|
|
||||||
|
assert.strictEqual(result, error.response);
|
||||||
|
assert.strictEqual(logger.calls.length, 1);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("admin/getNewAppealsPage returns res.data on success", async () => {
|
||||||
|
const axios = createAxiosMock();
|
||||||
|
const logger = createLoggerMock();
|
||||||
|
const helpers = loadServiceModule("httpServiceUtils.js", {
|
||||||
|
consoleLogger: logger.consoleLogger
|
||||||
|
});
|
||||||
|
|
||||||
|
axios.getHandler = async () => ({ data: { value: [1, 2] } });
|
||||||
|
|
||||||
|
const admin = loadServiceModule("adminDirectService.js", {
|
||||||
|
axios,
|
||||||
|
BASE_URL: "",
|
||||||
|
...helpers
|
||||||
|
});
|
||||||
|
|
||||||
|
const result = await admin.getNewAppealsPage("q", 1, "a", "b", 20);
|
||||||
|
|
||||||
|
assert.deepStrictEqual(normalize(result), { value: [1, 2] });
|
||||||
|
assert.strictEqual(logger.calls.length, 0);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("admin/getNewAppealsPage returns error.response on failure", async () => {
|
||||||
|
const axios = createAxiosMock();
|
||||||
|
const logger = createLoggerMock();
|
||||||
|
const helpers = loadServiceModule("httpServiceUtils.js", {
|
||||||
|
consoleLogger: logger.consoleLogger
|
||||||
|
});
|
||||||
|
const error = createAxiosError(502, "Bad Gateway");
|
||||||
|
|
||||||
|
axios.getHandler = async () => Promise.reject(error);
|
||||||
|
|
||||||
|
const admin = loadServiceModule("adminDirectService.js", {
|
||||||
|
axios,
|
||||||
|
BASE_URL: "",
|
||||||
|
...helpers
|
||||||
|
});
|
||||||
|
|
||||||
|
const result = await admin.getNewAppealsPage("q", 1, "a", "b", 20);
|
||||||
|
|
||||||
|
assert.strictEqual(result, error.response);
|
||||||
|
assert.strictEqual(logger.calls.length, 1);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("admin/getNewAppeals returns error.response on failure", async () => {
|
||||||
|
const axios = createAxiosMock();
|
||||||
|
const logger = createLoggerMock();
|
||||||
|
const helpers = loadServiceModule("httpServiceUtils.js", {
|
||||||
|
consoleLogger: logger.consoleLogger
|
||||||
|
});
|
||||||
|
const error = createAxiosError(401, "Unauthorized");
|
||||||
|
|
||||||
|
axios.getHandler = async () => Promise.reject(error);
|
||||||
|
|
||||||
|
const admin = loadServiceModule("adminDirectService.js", {
|
||||||
|
axios,
|
||||||
|
BASE_URL: "",
|
||||||
|
...helpers
|
||||||
|
});
|
||||||
|
|
||||||
|
const result = await admin.getNewAppeals("ignored");
|
||||||
|
|
||||||
|
assert.strictEqual(result, error.response);
|
||||||
|
assert.strictEqual(logger.calls.length, 1);
|
||||||
|
});
|
||||||
|
|
||||||
|
const run = async () => {
|
||||||
|
let passed = 0;
|
||||||
|
|
||||||
|
for (const currentTest of tests) {
|
||||||
|
await currentTest.fn();
|
||||||
|
passed += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(
|
||||||
|
`Phase 6 behavioural tests passed (${passed}/${tests.length}).`
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
run().catch((error) => {
|
||||||
|
console.error(error);
|
||||||
|
process.exit(1);
|
||||||
|
});
|
||||||
@@ -0,0 +1,101 @@
|
|||||||
|
const fs = require("fs");
|
||||||
|
const path = require("path");
|
||||||
|
const assert = require("assert");
|
||||||
|
|
||||||
|
const rootDir = path.resolve(__dirname, "..", "..");
|
||||||
|
const servicesDir = path.join(rootDir, "actions", "services");
|
||||||
|
|
||||||
|
const groupedServiceFiles = [
|
||||||
|
"searchService.js",
|
||||||
|
"referenceDataService.js",
|
||||||
|
"documentService.js",
|
||||||
|
"portalService.js",
|
||||||
|
"accountService.js",
|
||||||
|
"caseService.js",
|
||||||
|
"adminService.js",
|
||||||
|
"integrationService.js",
|
||||||
|
"notifyService.js"
|
||||||
|
];
|
||||||
|
|
||||||
|
const expectedIndexReExports = [
|
||||||
|
"./searchService",
|
||||||
|
"./caseService",
|
||||||
|
"./accountService",
|
||||||
|
"./portalService",
|
||||||
|
"./documentService",
|
||||||
|
"./referenceDataService",
|
||||||
|
"./notifyService",
|
||||||
|
"./adminService",
|
||||||
|
"./integrationService"
|
||||||
|
];
|
||||||
|
|
||||||
|
const parseNamedList = (block) => {
|
||||||
|
return block
|
||||||
|
.split(",")
|
||||||
|
.map((item) => item.trim())
|
||||||
|
.filter(Boolean)
|
||||||
|
.map((item) => item.replace(/\s+/g, " "));
|
||||||
|
};
|
||||||
|
|
||||||
|
const parseGroupedServiceFile = (filePath) => {
|
||||||
|
const source = fs.readFileSync(filePath, "utf8");
|
||||||
|
|
||||||
|
const importMatch = source.match(
|
||||||
|
/import\s*\{([\s\S]*?)\}\s*from\s*"(\.\/[^"]+)";/
|
||||||
|
);
|
||||||
|
assert(
|
||||||
|
importMatch,
|
||||||
|
`Unable to parse import block in ${path.basename(filePath)}`
|
||||||
|
);
|
||||||
|
|
||||||
|
const exportMatch = source.match(/export\s*\{([\s\S]*?)\};/);
|
||||||
|
assert(
|
||||||
|
exportMatch,
|
||||||
|
`Unable to parse export block in ${path.basename(filePath)}`
|
||||||
|
);
|
||||||
|
|
||||||
|
return {
|
||||||
|
directModulePath: importMatch[2],
|
||||||
|
importedNames: parseNamedList(importMatch[1]).sort(),
|
||||||
|
exportedNames: parseNamedList(exportMatch[1]).sort()
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
const verifyGroupedServicesParity = () => {
|
||||||
|
groupedServiceFiles.forEach((groupedFile) => {
|
||||||
|
const groupedPath = path.join(servicesDir, groupedFile);
|
||||||
|
const parsed = parseGroupedServiceFile(groupedPath);
|
||||||
|
|
||||||
|
assert(
|
||||||
|
parsed.directModulePath.endsWith("DirectService"),
|
||||||
|
`${groupedFile} does not import a direct service module`
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.deepStrictEqual(
|
||||||
|
parsed.importedNames,
|
||||||
|
parsed.exportedNames,
|
||||||
|
`${groupedFile} import/export names are not in parity`
|
||||||
|
);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const verifyServicesIndexStability = () => {
|
||||||
|
const source = fs.readFileSync(path.join(servicesDir, "index.js"), "utf8");
|
||||||
|
const matches = Array.from(
|
||||||
|
source.matchAll(/export \* from "([^"]+)";/g)
|
||||||
|
).map((match) => match[1]);
|
||||||
|
|
||||||
|
assert.deepStrictEqual(
|
||||||
|
matches,
|
||||||
|
expectedIndexReExports,
|
||||||
|
"actions/services/index.js re-export list has changed unexpectedly"
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const run = () => {
|
||||||
|
verifyGroupedServicesParity();
|
||||||
|
verifyServicesIndexStability();
|
||||||
|
console.log("Phase 6 parity tests passed.");
|
||||||
|
};
|
||||||
|
|
||||||
|
run();
|
||||||
Reference in New Issue
Block a user