Conversation
sam-schu
left a comment
There was a problem hiding this comment.
For sending the emails:
- For consistency with our other emails, can we send the emails outside of the transaction, so the order is still created even if an email fails to send? (We do plan to add better handling for failed emails across the board)
- Can we try sending both emails, even if one fails?
sam-schu
left a comment
There was a problem hiding this comment.
Confirmed the emails are properly sent! A few comments on the contents:
- Can we link the text "log into the platform" rather than including the link at the end of the email?
- Can we turn the coordinator email into a link?
- For the manufacturer email, can we make sure the different address lines appear on different lines in the email body, and add a comma between city and state?
814 Cedar Hollow Way
[Unit 1]
Madison, WI 53711
[US]
dburkhart07
left a comment
There was a problem hiding this comment.
sorry this is so many comments lol. should hopefully be good after this <3
|
|
||
| it('sends pantry closed email with last delivered order assignee on auto-close', async () => { | ||
| const requestId = 1; | ||
| const pantry = await testDataSource.getRepository(Pantry).findOne({ |
There was a problem hiding this comment.
nit: can we cast both of these rather than a !
| await service.updateRequestStatus(1); | ||
|
|
||
| const request = await service.findOne(1); | ||
| expect(request.status).toBe(FoodRequestStatus.CLOSED); |
There was a problem hiding this comment.
Can we either add to this test or create another test that, in this event, in addition to the request still closing, that the error message is also logged?
| mockEmailsService.sendEmails.mockRejectedValueOnce( | ||
| new Error('SMTP error'), | ||
| ); | ||
|
|
There was a problem hiding this comment.
Can we make sure before this update call, that the request beforehand was marked as active?
| `UPDATE food_requests SET status = 'closed' WHERE request_id = 1`, | ||
| ); | ||
|
|
||
| await service.updateRequestStatus(1); |
There was a problem hiding this comment.
can we make sure the request was closed before this call?
| expect(item1After?.reservedQuantity).toBe(item1Before?.reservedQuantity); | ||
| expect(item2After?.reservedQuantity).toBe(item2Before?.reservedQuantity); | ||
| }); | ||
| }); |
There was a problem hiding this comment.
Can we add the following tests:
- Rollsback transaction when the donation service match fails
- Add a new test for throwing an error when we have 0 donation items (an empty map gets passed in), since we cant create an order with no items/allocations
- A test where the request is not found
| ', ', | ||
| )}`, | ||
| const donationItemIds = Array.from(itemAllocations.keys()); | ||
| const donationItems = await this.donationItemsService.getByIds( |
There was a problem hiding this comment.
Can we make sure that donationItems has at least one item in it beforehand, and throw a BadReqeustException otherwise?
| const donationItems = await this.donationItemsService.getByIds( | ||
| donationItemIds, | ||
| ); | ||
| const fmDonations = await this.donationRepo.find({ |
There was a problem hiding this comment.
Can we also make sure the food manufacturer has some donations?
| for (const donationItem of donationItems) { | ||
| const id = donationItem.itemId; | ||
| const quantityToAllocate = itemAllocations.get(id)!; | ||
| const invalidItems = donationItems.filter( |
There was a problem hiding this comment.
I'm thinking about the edge case where we have a bunch of fulfilled donations. In the instance where we have donation items part of this filled donation, we will get an issue about the desired quantity being more than the fulfilled quantity. Can we get either @sam-schu or @Yurika-Kan's thoughts on this? should we keep it the way it is, or throw a potentially more helpful error that no donation item ids can belong to fulfilled donations, in addition to needing to be from donations from this food manufacturer.
| await this.dataSource.transaction(async (transactionManager) => { | ||
| validateId(manufacturerId, 'Food Manufacturer'); | ||
| validateId(requestId, 'Request'); | ||
|
|
There was a problem hiding this comment.
Can we also validate early on that all the allocation values are greater than 0?
ℹ️ Issue
Closes https://vidushimisra.atlassian.net/jira/software/projects/SSF/boards/1?jql=assignee%20%3D%20712020%3A10ef9ad9-e290-4bbd-8c4b-cb215e8d449a&selectedIssue=SSF-188
📝 Description
Email templates for:
✔️ Verification
BEFORE TESTING: Add 2 new environment variables:
AWS_SES_SENDER_EMAIL (set this to one of your emails, this will be the address that sends the emails for you to verify)
SEND_AUTOMATED_EMAILS (switch this to true to turn on Cognito account creation and email sending permissions)
Add your email that you put in the AWS_SES_SENDER_EMAIL into the following AWS SES Identities: https://us-east-2.console.aws.amazon.com/ses/home?region=us-east-2#/identities
Tested each workflow to ensure the proper sender, subject, message, attachments were all there.
Same testing as #127
I verified it worked via new tests and testing email functionality with postman.
🏕️ (Optional) Future Work / Notes
For food request closed the functionality is as follows (per Yurika):
For manual close (closeRequest endpoint):
For auto close (updateRequestStatus):