-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#4390 - CAS Manual Intervention (e2e tests) #4478
Conversation
- Updated the expect message for one of the tests
.../route-controllers/cas-invoice/tests/e2e/cas-invoice.aest.controller.getInvoices.e2e-spec.ts
Outdated
Show resolved
Hide resolved
await db.casInvoiceDetail.delete({}); | ||
await db.casInvoice.delete({}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
API executes the E2E tests concurrently and deleting the invoices can potentially impact other E2E tests files, unless I am missing something.
Am I missing something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adjusted as per our discussion on call.
.../route-controllers/cas-invoice/tests/e2e/cas-invoice.aest.controller.getInvoices.e2e-spec.ts
Show resolved
Hide resolved
sources/packages/backend/libs/test-utils/src/factories/cas-invoice.ts
Outdated
Show resolved
Hide resolved
...ollers/cas-invoice/tests/e2e/cas-invoice.aest.controller.updateInvoiceToResolved.e2e-spec.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work, please take a look at the comments.
.../route-controllers/cas-invoice/tests/e2e/cas-invoice.aest.controller.getInvoices.e2e-spec.ts
Outdated
Show resolved
Hide resolved
.../route-controllers/cas-invoice/tests/e2e/cas-invoice.aest.controller.getInvoices.e2e-spec.ts
Outdated
Show resolved
Hide resolved
.../route-controllers/cas-invoice/tests/e2e/cas-invoice.aest.controller.getInvoices.e2e-spec.ts
Outdated
Show resolved
Hide resolved
), | ||
}, | ||
}); | ||
for (const invoice of invoicesToDelete) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we are keeping it we can avoid the for
as below, to avoid deleting the records from the DB one by one.
const invoiceIDsToDelete = invoicesToDelete.map((invoice) => invoice.id);
await db.casInvoiceDetail.delete({
casInvoice: In(invoiceIDsToDelete),
});
casInvoiceBatch, | ||
creator: systemUsersService.systemUser, | ||
// Part-time BC grants. | ||
disbursementValues: [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A note for the future: unless required for the test, we can avoid creating more records than required. Here, one DisbursementValueType.BCGrant
would be enough.
* and allow the retrieval of invoice batches to be tested. | ||
*/ | ||
const CAS_INVOICE_STATUS_LAST_UPDATED_ON_START_DATE = new Date("2080-01-01"); | ||
const CAS_INVOICE_STATUS_LAST_UPDATED_ON_END_DATE = new Date("2080-02-01"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see that CAS_INVOICE_STATUS_LAST_UPDATED_ON_END_DATE
is not used in the data preparation but only in delete. In that case we can remove it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found later in the code that usage of add days with days added to fall between these days are used.
Alternatively faker.date.between()
can be used to get a date randomly in the range.
Btw, the comment above and this is not a blocker.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will leave it as discussed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work, thanks for doing the changes, only a few non-blocker comments. Looks good 👍
.../route-controllers/cas-invoice/tests/e2e/cas-invoice.aest.controller.getInvoices.e2e-spec.ts
Show resolved
Hide resolved
...ollers/cas-invoice/tests/e2e/cas-invoice.aest.controller.updateInvoiceToResolved.e2e-spec.ts
Outdated
Show resolved
Hide resolved
...ollers/cas-invoice/tests/e2e/cas-invoice.aest.controller.updateInvoiceToResolved.e2e-spec.ts
Outdated
Show resolved
Hide resolved
invoiceNumber: casInvoice.invoiceNumber, | ||
invoiceStatus: CASInvoiceStatus.Resolved, | ||
invoiceStatusUpdatedBy: { id: invoiceStatusUpdatedBy.id } as User, | ||
invoiceStatusUpdatedOn: updatedCASInvoice.invoiceStatusUpdatedOn, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This assertion doesn't seem to be valid IMO.
An object return from find is checked for a property using it's own value.
I am even ok to check if it is some date.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I missed to remove it. I had added that for a totally different reason which got changed as a part of another review comment above. I will remove it.
...ollers/cas-invoice/tests/e2e/cas-invoice.aest.controller.updateInvoiceToResolved.e2e-spec.ts
Show resolved
Hide resolved
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for making the changes. Looks good. 👍
As a part of this PR, the following e2e tests have been written:
CASInvoiceAESTController(e2e)-updateInvoiceToResolved
√ Should resolve an invoice in Manual intervention status for the provided invoice identifier.
√ Should throw a HttpStatus Not Found (404) error when the CAS invoice to resolve doesn't exist.
√ Should throw a HttpStatus Not Found (404) error when the CAS invoice to resolve does not have the expected Manual intervention status.
√ Should throw a HttpStatus Forbidden (403) error when an unauthorized Ministry user tries to update the invoice.
CASInvoiceAESTController(e2e)-getInvoices
√ Should be able to get invoices for the first page in a paginated result with a limit of two per page with Manual intervention status in the descending order.
√ Should throw a HttpStatus Bad Request (400) error when the invoice status is invalid.
√ Should throw a HttpStatus Bad Request (400) error when the sortField is invalid.
√ Should throw a HttpStatus Forbidden (403) error when an unauthorized Ministry user tries to get the invoices.
Screenshots for the above e2e test execution: