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

#1981 - Request Offering Change: Ministry View [Approve / Deny Request] - Part 3 #2422

Conversation

sh16011993
Copy link
Collaborator

@sh16011993 sh16011993 commented Oct 17, 2023

As a part of this PR, the following tasks were completed:

  • Added an email notification for the scenario: offering change request approved or declined by SABC: This task involves DB migration to add the new notification type.

Screenshot:

image

  • e2e tests

ApplicationOfferingChangeRequestAESTController(e2e)-assessApplicationOfferingChangeRequest
√ Should assess the application offering change request for the provided application offering change request id.
√ Should not create a new assessment when the application offering change request has been declined by the ministry user.
√ Should throw a HttpStatus Not Found (404) error when an application offering change is not in a valid status to be assessed.
√ Should throw a HttpStatus Bad Request (400) error when an invalid application offering change request status is provided.
√ Should throw a HttpStatus Forbidden (403) error when an unauthorized AEST user tries to assess the application offering change request.

@sh16011993 sh16011993 changed the title #1981 - Request Offering Change: Ministry View [Approve / Deny Reques… #1981 - Request Offering Change: Ministry View [Approve / Deny Request] - Part 3 Oct 17, 2023
@sh16011993 sh16011993 self-assigned this Oct 17, 2023
@sh16011993 sh16011993 added the DB DB migration involved label Oct 17, 2023
initialValues: {
applicationOfferingChangeRequestStatus:
ApplicationOfferingChangeRequestStatus.InProgressWithSABC,
} as ApplicationOfferingChangeRequest,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no need for the as ApplicationOfferingChangeRequest here.

* @param auditUserId user that should be considered the one that is causing the changes.
* @param entityManager optional entity manager to execute in transaction.
*/
async saveApplicationOfferingChangeRequestCompletedByMinistry(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This name is not related to "create a notification". It sounds like it is saving the offering change request instead.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe not for this PR but the method name in line 161 also have this problem (missing "Notification" in the end of the name)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@andrepestana-aot I believe that must be part of the PR.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in both the places.

async saveApplicationOfferingChangeRequestCompletedByMinistry(
notification: ApplicationOfferingChangeRequestCompletedByMinistryNotification,
auditUserId: number,
entityManager?: EntityManager,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this method entityManager should be mandatory.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. I also see that all the methods in this class have entityManager mandatory but it is not utilized in an optional way.

Copy link
Collaborator

@andrepestana-aot andrepestana-aot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job. Left some comments. Please take a look.

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, just some minor comments.

email_address: notification.toAddress,
template_id: templateId,
personalisation: {
givenNames: notification.givenNames ?? "",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a part of this PR, we can have a common filler method in notification scope as this code is repeating for all methods.

},
);
const note = "Some dummy note.";
const token = await getAESTToken(AESTGroups.BusinessAdministrators);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just wondering should we need a test with non business administrator trying to approve/decline?

@dheepak-aot
Copy link
Collaborator

dheepak-aot commented Oct 17, 2023

Nice work @sh16011993 . Please have a look at the comments.

const updatedApplicationOfferingChangeRequest =
await db.applicationOfferingChangeRequest.findOne({
select: {
id: true,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like id here and in line 67 is not used , do we need it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMU, this id is required by the relations for doing the join. I have removed the id from line 67.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am sorry, why id is required for join? I am not following.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I checked that and I had an error without selecting the id. I had a similar issue with another findOne query.

Copy link
Contributor

@ann-aot ann-aot Oct 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh..okay, but when I checked the code, we have some type typeorm findOne query with relation without id. Now I suspect those query working or not, two examples is below, one is find and another is findOne eg,
image
image

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ann-aot I saw the missing ID issue happening yesterday while @andrepestana-aot was sharing the screen but the queries that you provided prove that it can work.
It may be a not-so-evident error or something that we are missing in the entity model classes.

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.

Looks good 👍

Copy link
Contributor

@ann-aot ann-aot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍 added a reply for a comment #2422 (comment), if there is an error, we might need to create a ticket to revisit/validate those queries in our code base.

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 doing the changes 👍

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@github-actions
Copy link

Backend Unit Tests Coverage Report

Totals Coverage
Statements: 17.22% ( 2219 / 12884 )
Methods: 7.92% ( 129 / 1629 )
Lines: 19.97% ( 1946 / 9746 )
Branches: 9.54% ( 144 / 1509 )

@github-actions
Copy link

E2E Workflow Workers Coverage Report

Totals Coverage
Statements: 46.3% ( 300 / 648 )
Methods: 40% ( 32 / 80 )
Lines: 50.6% ( 251 / 496 )
Branches: 23.61% ( 17 / 72 )

@github-actions
Copy link

E2E Queue Consumers Coverage Report

Totals Coverage
Statements: 75.72% ( 555 / 733 )
Methods: 69.32% ( 61 / 88 )
Lines: 77.64% ( 486 / 626 )
Branches: 42.11% ( 8 / 19 )

@github-actions
Copy link

E2E SIMS API Coverage Report

Totals Coverage
Statements: 55.18% ( 4057 / 7352 )
Methods: 52.25% ( 499 / 955 )
Lines: 59.95% ( 3293 / 5493 )
Branches: 29.31% ( 265 / 904 )

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.

Thanks for doing the changes, looks good 👍

Copy link
Collaborator

@andrepestana-aot andrepestana-aot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Thanks for the changes!

@sh16011993 sh16011993 merged commit eafdaeb into main Oct 18, 2023
@sh16011993 sh16011993 deleted the 1981_request_offering_change_ministry_view_approve_deny_request_part_3 branch October 18, 2023 16:23
@sh16011993 sh16011993 temporarily deployed to DEV October 18, 2023 16:35 — with GitHub Actions Inactive
@sh16011993 sh16011993 temporarily deployed to DEV October 18, 2023 16:36 — with GitHub Actions Inactive
@sh16011993 sh16011993 temporarily deployed to DEV October 18, 2023 16:36 — with GitHub Actions Inactive
@sh16011993 sh16011993 temporarily deployed to DEV October 18, 2023 16:36 — with GitHub Actions Inactive
@sh16011993 sh16011993 temporarily deployed to DEV October 18, 2023 16:36 — with GitHub Actions Inactive
@sh16011993 sh16011993 temporarily deployed to DEV October 18, 2023 16:40 — with GitHub Actions Inactive
@sh16011993 sh16011993 temporarily deployed to DEV October 18, 2023 16:40 — with GitHub Actions Inactive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DB DB migration involved E2E/Unit tests SIMS-Api SIMS-Api
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants