From 51bfe9dc877ab4c3a12acdf24890e8af20a2f123 Mon Sep 17 00:00:00 2001 From: Chandra shekar Varkala Date: Tue, 9 Jan 2024 18:32:33 -0600 Subject: [PATCH] chore: component test assertions --- test/integrations/component.test.ts | 1 + test/testHelper.js | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/test/integrations/component.test.ts b/test/integrations/component.test.ts index 9abbb5cfcc..9c584cdbc6 100644 --- a/test/integrations/component.test.ts +++ b/test/integrations/component.test.ts @@ -125,6 +125,7 @@ const testRoute = async (route, tcData: TestCaseData) => { const outputResp = tcData.output.response || ({} as any); if (tcData.feature === tags.FEATURES.BATCH || tcData.feature === tags.FEATURES.ROUTER) { + //TODO not all test cases have userIds in their metadata. assertRouterOutput(response.body.output, tcData.input.request.body.input); } diff --git a/test/testHelper.js b/test/testHelper.js index 34ab9ec991..653fc60b1d 100644 --- a/test/testHelper.js +++ b/test/testHelper.js @@ -20,8 +20,8 @@ const setResponsesForMockAxiosAdapter = ({url, method, data, options}, {response } const assertRouterOutput = (output, input) => { - if (!input.metadata) { - return; + if (!Array.isArray(output) || !Array.isArray(input)) { + return } const returnedJobids = {}; @@ -68,6 +68,8 @@ const assertRouterOutput = (output, input) => { } }); + console.log(userIdJobIdMap); + //The jobids for a user should be in order. If not, there is an issue. Object.keys(userIdJobIdMap).forEach((userId) => { const jobIds = userIdJobIdMap[userId]; @@ -77,6 +79,14 @@ const assertRouterOutput = (output, input) => { }); }; +/*a = {b:3} +console.log(a.b) +input = [{message: {a: "b"}, destination: {a: "b"}, metadata: {jobId: 1}}, +{message: {a: "b"}, destination: {a: "b"}, metadata: {jobId: 2}}] +output = [{batchedRequest: {}, metadata: [{jobId: 2}], destination: {a: "b"}, statusCode: 200}, +{batchedRequest: {}, metadata: [{jobId: 1}], destination: {a: "b"}, statusCode: 200}] +assertRouterOutput(output, input)*/ + module.exports = { getFuncTestData, responses,