-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add unit tests for email verification for Qacc
- Loading branch information
Showing
4 changed files
with
92 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ import { | |
getGivEconomyBasicAuth, | ||
getGivethIoBasicAuth, | ||
getNotifyRewardBasicAuth, | ||
getQaccBasicAuth, | ||
serverUrl, | ||
sleep, | ||
} from '../../../test/testUtils'; | ||
|
@@ -2167,6 +2168,58 @@ function sendNotificationTestCases() { | |
); | ||
} | ||
}); | ||
|
||
it('should create *Send email verification code for Qacc* notification, success', async () => { | ||
const data = { | ||
eventName: 'Send email verification code for Qacc', | ||
segment: { | ||
payload: { | ||
verificationCode: 654321, | ||
email: '[email protected]', | ||
}, | ||
}, | ||
}; | ||
|
||
const result = await axios.post(sendNotificationUrl, data, { | ||
headers: { | ||
authorization: getQaccBasicAuth(), | ||
}, | ||
}); | ||
|
||
assert.equal(result.status, 200); | ||
assert.isOk(result.data); | ||
assert.isTrue(result.data.success); | ||
}); | ||
it('should create *Send email verification code for Qacc* notification, failed invalid payload', async () => { | ||
try { | ||
const data = { | ||
eventName: 'Send email verification code for Qacc', | ||
segment: { | ||
payload: { | ||
verificationCode: 654321, | ||
email: '[email protected]', | ||
invalidField: 'invalid data', | ||
}, | ||
}, | ||
}; | ||
await axios.post(sendNotificationUrl, data, { | ||
headers: { | ||
authorization: getQaccBasicAuth(), | ||
}, | ||
}); | ||
// If request doesn't fail, it means this test failed | ||
assert.isTrue(false); | ||
} catch (e: any) { | ||
assert.equal( | ||
e.response.data.message, | ||
errorMessagesEnum.IMPACT_GRAPH_VALIDATION_ERROR.message, | ||
); | ||
assert.equal( | ||
e.response.data.description, | ||
'"segment.payload.invalidField" is not allowed', | ||
); | ||
} | ||
}); | ||
} | ||
|
||
function sendBulkNotificationsTestCases() { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,4 +52,33 @@ describe('activityCreator', () => { | |
}), | ||
); | ||
}); | ||
|
||
it('should create attributes for SEND_EMAIL_VERIFICATION_CODE_FOR_QACC', () => { | ||
const payload = { | ||
verificationCode: 123456, | ||
email: '[email protected]', | ||
}; | ||
const result = activityCreator( | ||
payload, | ||
NOTIFICATIONS_EVENT_NAMES.SEND_EMAIL_VERIFICATION_CODE_FOR_QACC, | ||
MICRO_SERVICES.qacc, | ||
); | ||
expect(JSON.stringify(result)).equal( | ||
JSON.stringify({ | ||
activities: [ | ||
{ | ||
activity_id: 'act:cm:qacc-email-verification', | ||
attributes: { | ||
'int:cm:verificationcode': 123456, | ||
'str:cm:email': '[email protected]', | ||
}, | ||
fields: { | ||
'str::email': payload.email, | ||
}, | ||
}, | ||
], | ||
merge_by: ['str::email'], | ||
}), | ||
); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters