Skip to content

Commit

Permalink
fix: fixing test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
shrouti1507 committed Dec 16, 2024
1 parent 707dfe8 commit 8e5d6ab
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
14 changes: 11 additions & 3 deletions src/v0/destinations/iterable/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -796,17 +796,25 @@ const checkIfEventIsAbortableAndExtractErrorMessage = (event, destinationRespons
const userIdMatchPath = ITERABLE_RESPONSE_USER_ID_PATHS.filter((userIdPath) =>
isValueInResponseArray(destinationResponse.response, userIdPath, eventValues.userId),
);
errorMsg += `userId error:"${eventValues.userId}" in "${userIdMatchPath}".`;
if (userIdMatchPath.length > 0) {
errorMsg += `userId error:"${eventValues.userId}" in "${userIdMatchPath}".`;
}

const emailMatchPath = ITERABLE_RESPONSE_EMAIL_PATHS.filter((emailPath) =>
isValueInResponseArray(destinationResponse.response, emailPath, eventValues.email),
);
errorMsg += `email error:"${eventValues.email}" in "${emailMatchPath}".`;

if (emailMatchPath.length > 0) {
errorMsg += `email error:"${eventValues.email}" in "${emailMatchPath}".`;
}

const eventNameMatchPath = ['disallowedEventNames'].filter((eventNamePath) =>
isValueInResponseArray(destinationResponse.response, eventNamePath, eventValues.eventName),
);
errorMsg += `eventName error:"${eventValues.eventName}" in "${eventNameMatchPath}".`;

if (eventNameMatchPath.length > 0) {
errorMsg += `eventName error:"${eventValues.eventName}" in "${eventNameMatchPath}".`;
}

if (errorMsg) {
return {
Expand Down
7 changes: 3 additions & 4 deletions src/v0/destinations/iterable/util.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -882,7 +882,7 @@ describe('iterable utils test', () => {
const result = checkIfEventIsAbortableAndExtractErrorMessage(event, destinationResponse);
expect(result).toEqual({
isAbortable: true,
errorMsg: 'Request failed for value "test" because it is "failedUpdates.invalidEmails".',
errorMsg: 'email error:"test" in "failedUpdates.invalidEmails".',
});
});

Expand Down Expand Up @@ -924,8 +924,7 @@ describe('iterable utils test', () => {
const result = checkIfEventIsAbortableAndExtractErrorMessage(event, destinationResponse);
expect(result).toEqual({
isAbortable: true,
errorMsg:
'Request failed for value "user123" because it is "failedUpdates.invalidUserIds".',
errorMsg: 'userId error:"user123" in "failedUpdates.invalidUserIds".',
});
});

Expand All @@ -948,7 +947,7 @@ describe('iterable utils test', () => {
const result = checkIfEventIsAbortableAndExtractErrorMessage(event, destinationResponse);
expect(result).toEqual({
isAbortable: true,
errorMsg: 'Request failed for value "purchase" because it is "disallowedEventNames".',
errorMsg: 'eventName error:"purchase" in "disallowedEventNames".',
});
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ export const testScenariosForV1API: ProxyV1TestData[] = [
{
statusCode: 400,
metadata: generateMetadata(1),
error: 'Request failed for value "sayan" because it is "invalidEmails".',
error: 'email error:"sayan" in "invalidEmails,failedUpdates.invalidEmails".',
},
{
statusCode: 200,
Expand Down Expand Up @@ -460,7 +460,7 @@ export const testScenariosForV1API: ProxyV1TestData[] = [
{
statusCode: 400,
metadata: generateMetadata(2),
error: 'Request failed for value "shrouti" because it is "invalidEmails".',
error: 'email error:"shrouti" in "invalidEmails,failedUpdates.invalidEmails".',
},
],
},
Expand Down

0 comments on commit 8e5d6ab

Please sign in to comment.