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

#3815 - Identification of changed information during edit #4221

Merged
merged 26 commits into from
Jan 13, 2025

Conversation

andrewsignori-aot
Copy link
Collaborator

@andrewsignori-aot andrewsignori-aot commented Jan 9, 2025

New method compareApplicationData

  • Created a new helper method with the sole intention of executing the comparison between two application dynamic data JSONB data.
    • The method will detect changes as below
      • Added/removed/updated properties
      • Added/removed array items
    • Used JSON.stringify a simple solution to perform a deep equality between two objects. During the tests, the comparison of two part-time applications took less than a millisecond to execute.
    • Method created at lib level to allow its usage in future comparison in application data by other apps than API.

Form.io considerations

  • The Form.io event render was used instead of load because the lists are not fully created right after the loading stage which means that not all the children will be present to have the highlight style applied.
  • Form.io component tree for lists contains only the "first child" and the regular document.getElementById was used to ensure that a child component in a list would receive the highlight style.

Other changes

  • Adjusted the Ministry controller to execute the application data comparison in the application read-only versions that is the data being displayed to the users where the changes should be detected.
    Note: The compareApplicationData would also be able to detect changes in the non-read-only application dynamic data.

Sample API result

[
    {
        "key": "dependants",
        "changeType": "itemsRemoved",
        "changes": [
            {
                "index": 0,
                "changeType": "updated",
                "changes": [
                    {
                        "key": "fullName",
                        "changeType": "updated"
                    },
                    {
                        "key": "dateOfBirth",
                        "changeType": "updated"
                    }
                ]
            }
        ]
    },
    {
        "key": "citizenship",
        "changeType": "updated"
    },
    {
        "key": "courseDetails",
        "changeType": "updated",
        "changes": [
            {
                "index": 1,
                "changeType": "updated",
                "changes": [
                    {
                        "key": "courseCode",
                        "changeType": "updated"
                    },
                    {
                        "key": "courseStartDate",
                        "changeType": "updated"
                    }
                ]
            }
        ]
    },
    {
        "key": "studentNumber",
        "changeType": "updated"
    },
    {
        "key": "studentHomeAddress",
        "changeType": "updated"
    },
    {
        "key": "applicationPDPPDStatus",
        "changeType": "updated"
    },
    {
        "key": "hasSignificantDegreeOfIncome",
        "changeType": "updated"
    },
    {
        "key": "partTimeAwardTypesToBeConsidered",
        "changeType": "updated"
    },
    {
        "key": "reasonsignificantdecreaseInIncome",
        "changeType": "updated"
    },
    {
        "key": "decreaseInIncomeSupportingDocuments",
        "changeType": "itemsRemoved"
    },
    {
        "key": "currentYearIncomeApplicationException",
        "changeType": "updated"
    },
    {
        "key": "selectedLocationName",
        "changeType": "updated"
    },
    {
        "key": "selectedOfferingName",
        "changeType": "updated"
    }
]

Sample UI Changes

image

image

image

image

image

Non-PR-related changes

  • Added a new option for VS Code debug Unit tests - Current test file following the same idea from other available.
  • Extracted the jest configurations from packages.json and moved to a file to allow the reference using the --config while executing the npm commands, following the same idea from the E2E tests.

@andrewsignori-aot andrewsignori-aot added the Ministry Ministry Features label Jan 9, 2025
@andrewsignori-aot andrewsignori-aot self-assigned this Jan 9, 2025
@andrewsignori-aot andrewsignori-aot changed the title #3815 - Detect application changes #3815 - Identification of changed information during edit Jan 9, 2025
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No changes in these configurations, they were extracted from the packages.json as they were.

@andrewsignori-aot andrewsignori-aot marked this pull request as ready for review January 10, 2025 19:40
@dheepak-aot dheepak-aot self-requested a review January 10, 2025 21:29
{
"type": "node",
"request": "launch",
"name": "Unit tests - Current test file",
Copy link
Collaborator

Choose a reason for hiding this comment

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

👍

@guru-aot guru-aot self-requested a review January 10, 2025 22:50
);
// If there is a previous application, generate its read-only data.
const previousReadOnlyDataPromise =
previousApplicationVersion &&
Copy link
Collaborator

Choose a reason for hiding this comment

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

👍

const dataChangeDTO: ApplicationDataChangeAPIOutDTO = {
key: dataChange.key,
index: dataChange.index,
changeType: dataChange.changeType,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggestion:

add changes to the const dataChangeDTO:

changes: dataChange.changes.length ? [] : undefined

and do the below changes,

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 am not able to see the benefit. Would it be to improve the code readability or something else?
Unless there is a stronger reason I am keeping the current way.

@@ -16,6 +16,7 @@
{{ emptyStringFiller(applicationDetail.applicationNumber) }}
</h2>
<StudentApplication
@render="formRender"
Copy link
Collaborator

Choose a reason for hiding this comment

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

👍

Comment on lines +187 to +189
if (
component.type === FromIOComponentTypes.Hidden ||
component._visible === false
Copy link
Collaborator

Choose a reason for hiding this comment

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

👍


.changed-value::before {
@extend .changed-value-content-base;
content: "\00a0\00a0Updated";
Copy link
Collaborator

Choose a reason for hiding this comment

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

What is this \00a0\00a0 ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Just to add some white space.

Copy link
Collaborator

@dheepak-aot dheepak-aot Jan 13, 2025

Choose a reason for hiding this comment

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

Can you try like this ?

content: "  Updated";
white-space: pre;

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It looks better, I did the change 😉

@dheepak-aot
Copy link
Collaborator

Great work @andrewsignori-aot and thanks for the walkthrough. I see that almost all the comments are addressed. Only one question and clarification there now.

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. 👍Great work.

Copy link

Backend Unit Tests Coverage Report

Totals Coverage
Statements: 22.49% ( 3850 / 17122 )
Methods: 10.37% ( 224 / 2161 )
Lines: 25.88% ( 3322 / 12837 )
Branches: 14.31% ( 304 / 2124 )

Copy link

E2E Workflow Workers Coverage Report

Totals Coverage
Statements: 65.59% ( 589 / 898 )
Methods: 59.63% ( 65 / 109 )
Lines: 68.72% ( 468 / 681 )
Branches: 51.85% ( 56 / 108 )

Copy link

E2E Queue Consumers Coverage Report

Totals Coverage
Statements: 86.14% ( 1249 / 1450 )
Methods: 82.42% ( 136 / 165 )
Lines: 88.51% ( 1032 / 1166 )
Branches: 68.07% ( 81 / 119 )

Copy link

E2E SIMS API Coverage Report

Totals Coverage
Statements: 67.77% ( 5992 / 8842 )
Methods: 65.54% ( 738 / 1126 )
Lines: 71.62% ( 4695 / 6555 )
Branches: 48.15% ( 559 / 1161 )

Copy link
Collaborator

@guru-aot guru-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, nice and great work @andrewsignori-aot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Ministry Ministry Features SIMS-Api SIMS-Api Web portal
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants