Skip to content
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

Merged
merged 11 commits into from
Mar 18, 2025

Conversation

sh16011993
Copy link
Collaborator

@sh16011993 sh16011993 commented Mar 14, 2025

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:

image
image

@sh16011993 sh16011993 self-assigned this Mar 14, 2025
@sh16011993 sh16011993 changed the title 4390 cas manual intervention e2e tests #4390 - CAS Manual Intervention (e2e tests) Mar 14, 2025
- Updated the expect message for one of the tests
@andrewsignori-aot andrewsignori-aot self-requested a review March 14, 2025 00:12
Comment on lines 54 to 55
await db.casInvoiceDetail.delete({});
await db.casInvoice.delete({});
Copy link
Collaborator

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?

Copy link
Collaborator Author

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.

Copy link
Collaborator

@andrewsignori-aot andrewsignori-aot left a 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.

@dheepak-aot dheepak-aot self-requested a review March 17, 2025 22:26
),
},
});
for (const invoice of invoicesToDelete) {
Copy link
Collaborator

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: [
Copy link
Collaborator

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");
Copy link
Collaborator

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.

Copy link
Collaborator

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.

Copy link
Collaborator Author

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.

Copy link
Collaborator

@andrewsignori-aot andrewsignori-aot left a 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 👍

invoiceNumber: casInvoice.invoiceNumber,
invoiceStatus: CASInvoiceStatus.Resolved,
invoiceStatusUpdatedBy: { id: invoiceStatusUpdatedBy.id } as User,
invoiceStatusUpdatedOn: updatedCASInvoice.invoiceStatusUpdatedOn,
Copy link
Collaborator

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.

Copy link
Collaborator Author

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.

Copy link

E2E Workflow Workers Coverage Report

Totals Coverage
Statements: 65.95% ( 610 / 925 )
Methods: 60.36% ( 67 / 111 )
Lines: 68.99% ( 485 / 703 )
Branches: 52.25% ( 58 / 111 )

Copy link

Backend Unit Tests Coverage Report

Totals Coverage
Statements: 22.01% ( 3975 / 18063 )
Methods: 9.85% ( 228 / 2314 )
Lines: 25.4% ( 3437 / 13529 )
Branches: 13.96% ( 310 / 2220 )

Copy link

E2E Queue Consumers Coverage Report

Totals Coverage
Statements: 85.72% ( 1507 / 1758 )
Methods: 83.25% ( 169 / 203 )
Lines: 88.1% ( 1244 / 1412 )
Branches: 65.73% ( 94 / 143 )

Copy link

E2E SIMS API Coverage Report

Totals Coverage
Statements: 70.77% ( 6497 / 9181 )
Methods: 68.54% ( 806 / 1176 )
Lines: 74.32% ( 5049 / 6794 )
Branches: 53.01% ( 642 / 1211 )

Copy link
Collaborator

@dheepak-aot dheepak-aot left a 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. 👍

@sh16011993 sh16011993 added this pull request to the merge queue Mar 18, 2025
Merged via the queue into main with commit d766304 Mar 18, 2025
21 checks passed
@sh16011993 sh16011993 deleted the 4390_cas_manual_intervention_e2e_tests branch March 18, 2025 19:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants