|
5 | 5 | getAccessTokenForMockAuthMicroService,
|
6 | 6 | getGivEconomyBasicAuth,
|
7 | 7 | getGivethIoBasicAuth,
|
| 8 | + getNotifyRewardBasicAuth, |
8 | 9 | serverUrl,
|
9 | 10 | sleep,
|
10 | 11 | } from '../../../test/testUtils';
|
@@ -2092,6 +2093,77 @@ function sendNotificationTestCases() {
|
2092 | 2093 | const createdNotification = await findNotificationByTrackId(trackId);
|
2093 | 2094 | assert.equal(createdNotification?.createdAt.getTime(), creationTime);
|
2094 | 2095 | });
|
| 2096 | + |
| 2097 | + it('should create *Notify reward amount* notification, success', async () => { |
| 2098 | + const data = { |
| 2099 | + eventName: "Notify reward amount", |
| 2100 | + sendEmail: true, |
| 2101 | + sendSegment: true, |
| 2102 | + creationTime: 1667992708000, |
| 2103 | + |
| 2104 | + segment: { |
| 2105 | + payload: { |
| 2106 | + round: 10, |
| 2107 | + date: "1667992708000", |
| 2108 | + amount: "12134", |
| 2109 | + contractAddress: "0xsfglsjfdflk", |
| 2110 | + farm: "test farm", |
| 2111 | + message: "test message", |
| 2112 | + network: "ethereum", |
| 2113 | + script: "test script", |
| 2114 | + transactionHash: "test txhash" |
| 2115 | + } |
| 2116 | + } |
| 2117 | + }; |
| 2118 | + |
| 2119 | + const result = await axios.post(sendNotificationUrl, data, { |
| 2120 | + headers: { |
| 2121 | + authorization: getNotifyRewardBasicAuth(), |
| 2122 | + }, |
| 2123 | + }); |
| 2124 | + |
| 2125 | + assert.equal(result.status, 200); |
| 2126 | + assert.isOk(result.data); |
| 2127 | + assert.isTrue(result.data.success); |
| 2128 | + }); |
| 2129 | + it('should create *Notify reward amount* notification, failed invalid payload', async () => { |
| 2130 | + try { |
| 2131 | + const data = { |
| 2132 | + eventName: "Notify reward amount", |
| 2133 | + sendEmail: true, |
| 2134 | + sendSegment: true, |
| 2135 | + creationTime: 1667992708000, |
| 2136 | + |
| 2137 | + segment: { |
| 2138 | + payload: { |
| 2139 | + round: 10, |
| 2140 | + date: "1667992708000", |
| 2141 | + amount: "12134", |
| 2142 | + contractAddress: "0xsfglsjfdflk", |
| 2143 | + farm: "test farm", |
| 2144 | + message: "test message", |
| 2145 | + network: "ethereum", |
| 2146 | + script: "test script", |
| 2147 | + transactionHash: "test txhash", |
| 2148 | + invalidField: "invalid data" |
| 2149 | + } |
| 2150 | + } |
| 2151 | + }; |
| 2152 | + await axios.post(sendNotificationUrl, data, { |
| 2153 | + headers: { |
| 2154 | + authorization: getNotifyRewardBasicAuth(), |
| 2155 | + }, |
| 2156 | + }); |
| 2157 | + // If request doesn't fail, it means this test failed |
| 2158 | + assert.isTrue(false); |
| 2159 | + } catch (e: any) { |
| 2160 | + assert.equal( |
| 2161 | + e.response.data.message, |
| 2162 | + errorMessagesEnum.IMPACT_GRAPH_VALIDATION_ERROR.message, |
| 2163 | + ); |
| 2164 | + assert.equal(e.response.data.description, '"segment.payload.invalidField" is not allowed'); |
| 2165 | + } |
| 2166 | + }); |
2095 | 2167 | }
|
2096 | 2168 |
|
2097 | 2169 | function sendBulkNotificationsTestCases() {
|
|
0 commit comments