Skip to content

Commit

Permalink
Merge pull request #64 from Giveth/hotfix_3552_fix_send_donation_noti…
Browse files Browse the repository at this point in the history
…fication

Fix made/receive donation notification by allowing donationEthValue be null
  • Loading branch information
mohammadranjbarz authored Jan 7, 2024
2 parents ad68ca4 + 231aa95 commit 0799de1
Show file tree
Hide file tree
Showing 2 changed files with 130 additions and 1 deletion.
129 changes: 129 additions & 0 deletions src/routes/v1/notificationRouter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1399,6 +1399,49 @@ function sendNotificationTestCases() {
assert.isOk(result.data);
assert.isTrue(result.data.success);
});
it('should create *Made donation* notification, success, segment is on, donationValueEth is null', async () => {
const data = {
eventName: 'Made donation',
sendEmail: true,
sendSegment: true,
userWalletAddress: generateRandomEthereumAddress(),
metadata: {
projectTitle,
projectLink,
},
segment: {
analyticsUserId: 'givethId-255',
anonymousId: 'givethId-255',
payload: {
email: '[email protected]',
title: 'How many photos is too many photos?',
firstName: 'firstName',
projectOwnerId: '68',
slug: 'how-many-photos-is-too-many-photos',
amount: 0.0001,
transactionId: generateRandomTxHash(),
transactionNetworkId: 5,
currency: 'ETH',
createdAt: '2022-11-10T07:36:13.182Z',
toWalletAddress: generateRandomEthereumAddress(),
donationValueUsd: 0.120492,
donationValueEth: null,
verified: true,
transakStatus: null,
fromWalletAddress: generateRandomEthereumAddress(),
},
},
};

const result = await axios.post(sendNotificationUrl, data, {
headers: {
authorization: getGivethIoBasicAuth(),
},
});
assert.equal(result.status, 200);
assert.isOk(result.data);
assert.isTrue(result.data.success);
});
it('should create *Made donation* notification, failed invalid metadata, segment is off', async () => {
try {
const data = {
Expand Down Expand Up @@ -1427,6 +1470,92 @@ function sendNotificationTestCases() {
}
});

it('should create *Donation received* notification, success, segment is on', async () => {
const data = {
eventName: 'Donation received',
sendEmail: true,
sendSegment: true,
userWalletAddress: generateRandomEthereumAddress(),
metadata: {
projectTitle,
projectLink,
},
segment: {
analyticsUserId: 'givethId-255',
anonymousId: 'givethId-255',
payload: {
email: '[email protected]',
title: 'How many photos is too many photos?',
firstName: 'firstName',
projectOwnerId: '68',
slug: 'how-many-photos-is-too-many-photos',
amount: 0.0001,
transactionId: generateRandomTxHash(),
transactionNetworkId: 5,
currency: 'ETH',
createdAt: '2022-11-10T07:36:13.182Z',
toWalletAddress: generateRandomEthereumAddress(),
donationValueUsd: 0.120492,
donationValueEth: 0.0001,
verified: true,
transakStatus: null,
fromWalletAddress: generateRandomEthereumAddress(),
},
},
};

const result = await axios.post(sendNotificationUrl, data, {
headers: {
authorization: getGivethIoBasicAuth(),
},
});
assert.equal(result.status, 200);
assert.isOk(result.data);
assert.isTrue(result.data.success);
});
it('should create *Donation received* notification, success, segment is on, donationValueEth is null', async () => {
const data = {
eventName: 'Donation received',
sendEmail: true,
sendSegment: true,
userWalletAddress: generateRandomEthereumAddress(),
metadata: {
projectTitle,
projectLink,
},
segment: {
analyticsUserId: 'givethId-255',
anonymousId: 'givethId-255',
payload: {
email: '[email protected]',
title: 'How many photos is too many photos?',
firstName: 'firstName',
projectOwnerId: '68',
slug: 'how-many-photos-is-too-many-photos',
amount: 0.0001,
transactionId: generateRandomTxHash(),
transactionNetworkId: 5,
currency: 'ETH',
createdAt: '2022-11-10T07:36:13.182Z',
toWalletAddress: generateRandomEthereumAddress(),
donationValueUsd: 0.120492,
donationValueEth: null,
verified: true,
transakStatus: null,
fromWalletAddress: generateRandomEthereumAddress(),
},
},
};

const result = await axios.post(sendNotificationUrl, data, {
headers: {
authorization: getGivethIoBasicAuth(),
},
});
assert.equal(result.status, 200);
assert.isOk(result.data);
assert.isTrue(result.data.success);
});
it('should create *Donation received* notification, success, segment is off', async () => {
const data = {
eventName: 'Donation received',
Expand Down
2 changes: 1 addition & 1 deletion src/validators/schemaValidators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export const sendNotificationValidator = Joi.object({
toWalletAddress: Joi.string(),
fromWalletAddress: Joi.string().allow(null).allow(''),
donationValueUsd: Joi.number(),
donationValueEth: Joi.number(),
donationValueEth: Joi.number().allow(null),
verified: Joi.boolean(),
transakStatus: Joi.string().allow(null).allow(''),

Expand Down

0 comments on commit 0799de1

Please sign in to comment.