-
❌ Returns error 401 if
requestoris missing from the request- Ensures that the function checks for the presence of
requestor.requestorIdin the request body and responds with a401status code if it's missing.
- Ensures that the function checks for the presence of
-
❌ Returns error 403 if user doesn't have
sendEmailspermission- Verifies that the function checks user permissions and responds with a
403status code if the user is not authorized to retry emails.
- Verifies that the function checks user permissions and responds with a
-
❌ Returns error 400 if
emailIdparameter is missing or invalid- Ensures that the function validates
emailIdfromreq.paramsis a valid MongoDB ObjectId.
- Ensures that the function validates
-
❌ Returns error 404 if the email is not found
- Verifies that the function handles cases where the email with the provided
emailIddoesn't exist.
- Verifies that the function handles cases where the email with the provided
-
❌ Returns error 400 if email is not in a retryable status
- Ensures that the function only allows retry for emails in
FAILEDorPROCESSEDstatus. Returns400for other statuses.
- Ensures that the function only allows retry for emails in
-
❌ Returns error 500 if there is an internal error while fetching failed batches
- Covers scenarios where there are database errors while querying for failed EmailBatch items.
-
❌ Returns error 500 if there is an internal error while resetting email status
- Covers scenarios where there are database errors while updating the email status to PENDING.
-
❌ Returns error 500 if there is an internal error while resetting batches
- Covers scenarios where there are database errors while resetting individual EmailBatch items to PENDING.
-
✅ Returns status 200 when email is successfully retried with failed batches
- Ensures that the function marks the parent Email as PENDING, resets all failed EmailBatch items to PENDING, queues the email for processing, and returns success with the count of failed items retried.
-
✅ Returns status 200 when email has no failed batches
- Verifies that if an email has no failed EmailBatch items, the function returns success with
failedItemsRetried: 0without error.
- Verifies that if an email has no failed EmailBatch items, the function returns success with
-
✅ Correctly resets only failed EmailBatch items
- Ensures that only EmailBatch items with
FAILEDstatus are reset to PENDING for retry.
- Ensures that only EmailBatch items with
-
✅ Marks parent email as PENDING
- Verifies that the parent Email status is changed to PENDING, allowing it to be reprocessed.
-
✅ Queues email for processing after reset
- Ensures that after resetting the email and batches, the email is added to the processing queue.
-
✅ Returns correct data in response
- Verifies that the response includes
emailIdandfailedItemsRetriedcount in the data field.
- Verifies that the response includes
-
❌ Handles concurrent retry requests gracefully
- Ensures that if multiple retry requests are made simultaneously, the function handles race conditions appropriately.