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

feat: is_statutory_application_type helper functions added to API on publish #4200

Merged
merged 16 commits into from
Jan 30, 2025

Conversation

RODO94
Copy link
Contributor

@RODO94 RODO94 commented Jan 24, 2025

What does this PR do?

This PR introduces API functions to update is_statutory_application_type and unit testing within the API that monitors how it is assigned when a flow is published at the flow/:flowId/publish end point.

I have also rearranged parts of the code in the API to match the way I'm importing certain functions and mocks

Copy link

github-actions bot commented Jan 24, 2025

Removed vultr server and associated DNS entries

@RODO94 RODO94 force-pushed the rory/stat-service-api-helpers branch 5 times, most recently from fa04c0f to 159b849 Compare January 28, 2025 12:36
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved isComponentType out of validate folder as I was using it in the Publish work so it seemed necessary to put it in a file which covers the module rather than just a service within it

@RODO94 RODO94 force-pushed the rory/stat-service-api-helpers branch from 6260060 to 792555d Compare January 28, 2025 16:25
@RODO94 RODO94 marked this pull request as ready for review January 28, 2025 16:25
@RODO94 RODO94 requested a review from a team January 28, 2025 16:25
@RODO94 RODO94 changed the title feat: is_staturory_application_type helper functions added to API on publish feat: is_statutory_application_type helper functions added to API on publish Jan 28, 2025
Copy link
Member

@jessicamcinchak jessicamcinchak left a comment

Choose a reason for hiding this comment

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

Took a quick first pass - there's a few immediate things to tidy up here please!

I'll come back tomorrow morning with fresher eyes to fully review the functionality of the new function and testing on the pizza - I think it might be nice to check-in or pair about how to generate realistic mock flow data for testing, and how to simplify the logic here a bit ?

api.planx.uk/modules/flows/flowHelpers.ts Outdated Show resolved Hide resolved
api.planx.uk/modules/flows/publish/helpers.ts Show resolved Hide resolved
api.planx.uk/modules/flows/publish/publish.test.ts Outdated Show resolved Hide resolved
api.planx.uk/modules/flows/publish/publish.test.ts Outdated Show resolved Hide resolved
api.planx.uk/modules/flows/publish/service.ts Outdated Show resolved Hide resolved
api.planx.uk/tests/mocks/applicationTypeCheckMocks.ts Outdated Show resolved Hide resolved
api.planx.uk/modules/flows/publish/publish.test.ts Outdated Show resolved Hide resolved
@RODO94 RODO94 force-pushed the rory/stat-service-api-helpers branch from 173edfc to 8e11ab6 Compare January 30, 2025 10:51
remove appTypeCheckMocks

shift order of service.ts in publish

set user role for publish.test first publish test

add formatting back to publish.test

refine test return of schema values
@RODO94 RODO94 force-pushed the rory/stat-service-api-helpers branch from 6c3c801 to 30e3f50 Compare January 30, 2025 11:13

test("returns true for a flow with Send and at least one statutory application.type in a SetValue Component", () => {
expect(
hasStatutoryApplicationType(mockSetValueStatutoryApplicationType),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added this to ensure it goes into the first nested if() condition, otherwise the test didn't have it covered

},
type: TYPES.SetValue,
},
} as FlowGraph;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Required the cast to ensure type error didn't pop up on the next delete line

const delta = jsondiffpatch.diff(mostRecent, flattenedFlow);

if (!delta) return null;

const hasSendComponent = hasComponentType(flattenedFlow, ComponentType.Send);
const isStatutoryApplication =
hasSendComponent && hasStatutoryApplicationType(flattenedFlow);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

added this line so you don't need to go into the fn to understand it's initial condition or what defines a statutory application

Copy link
Member

@jessicamcinchak jessicamcinchak 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 changes - this all feels much simpler, more readable, and better tested than the first iteration ! Two small comments, happy for this to merge 👍

api.planx.uk/modules/flows/publish/helpers.ts Show resolved Hide resolved
api.planx.uk/modules/flows/publish/service.ts Outdated Show resolved Hide resolved
@RODO94 RODO94 merged commit 9cd3431 into main Jan 30, 2025
13 checks passed
@RODO94 RODO94 deleted the rory/stat-service-api-helpers branch January 30, 2025 16:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants