test: update endpoint contract fixtures and add test filtering
This commit is contained in:
@@ -1215,7 +1215,7 @@ test("getadvancedsearchpaged returns SEARCH_STRING_REQUIRED when searchstring mi
|
||||
respondSuccess: respondSuccessMock,
|
||||
relayGet: async () => ({}),
|
||||
azureHeadersPagedCustom: () => ({}),
|
||||
_: { has: () => false }
|
||||
hasOwn: (obj, key) => Object.prototype.hasOwnProperty.call(obj, key)
|
||||
});
|
||||
|
||||
const req = {
|
||||
@@ -1238,7 +1238,7 @@ test("getadvancedsearchpaged returns ORDER_BY_REQUIRED when orderby missing", as
|
||||
respondSuccess: respondSuccessMock,
|
||||
relayGet: async () => ({}),
|
||||
azureHeadersPagedCustom: () => ({}),
|
||||
_: { has: () => false }
|
||||
hasOwn: (obj, key) => Object.prototype.hasOwnProperty.call(obj, key)
|
||||
});
|
||||
|
||||
const req = {
|
||||
@@ -1262,7 +1262,7 @@ test("getadvancedsearchpaged catch path returns ADVANCED_SEARCH_PAGED_FETCH_FAIL
|
||||
relayGet: async ({ res, errorResponse }) =>
|
||||
respondErrorMock(res, errorResponse),
|
||||
azureHeadersPagedCustom: () => ({}),
|
||||
_: { has: () => false }
|
||||
hasOwn: (obj, key) => Object.prototype.hasOwnProperty.call(obj, key)
|
||||
});
|
||||
|
||||
const req = {
|
||||
@@ -4416,10 +4416,20 @@ test("getToken catch path returns TOKEN_FETCH_FAILED", async () => {
|
||||
|
||||
test("getsipsmedia returns success contract", async () => {
|
||||
const mod = loadModule("pages/api/endpoint/getsipsmedia_api.js", {
|
||||
respondSuccess: respondSuccessMock
|
||||
respondError: respondErrorMock,
|
||||
relayGet: async ({ res }) =>
|
||||
respondSuccessMock(res, {
|
||||
"@odata.count": 4,
|
||||
value: []
|
||||
})
|
||||
});
|
||||
|
||||
const req = { query: {} };
|
||||
const req = {
|
||||
method: "GET",
|
||||
query: {
|
||||
caseid: "11111111-1111-4111-8111-111111111111"
|
||||
}
|
||||
};
|
||||
const res = createRes();
|
||||
await mod.default(req, res);
|
||||
|
||||
@@ -4459,13 +4469,25 @@ test("getappealtypesfornewappeal returns METHOD_NOT_ALLOWED for non-GET methods"
|
||||
});
|
||||
|
||||
const run = async () => {
|
||||
const filter = process.env.PEDW_TEST_FILTER;
|
||||
|
||||
const selectedTests = filter
|
||||
? tests.filter((currentTest) => currentTest.name.includes(filter))
|
||||
: tests;
|
||||
|
||||
if (selectedTests.length === 0) {
|
||||
throw new Error(`No tests match filter: ${filter}`);
|
||||
}
|
||||
|
||||
let passed = 0;
|
||||
for (const currentTest of tests) {
|
||||
|
||||
for (const currentTest of selectedTests) {
|
||||
await currentTest.fn();
|
||||
passed += 1;
|
||||
}
|
||||
|
||||
console.log(
|
||||
`Phase 21 endpoint-handler contract tests passed (${passed}/${tests.length}).`
|
||||
`Phase 21 endpoint-handler contract tests passed (${passed}/${selectedTests.length}).`
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user