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

chore: replace test router with memoryrouter, update partially tests #8102

Merged
merged 35 commits into from
Dec 3, 2024

Conversation

makelicious
Copy link
Collaborator

No description provided.

Copy link

Oops! Looks like you forgot to update the changelog. When updating CHANGELOG.md, please consider the following:

  • Changelog is read by country implementors who might not always be familiar with all technical details of OpenCRVS. Keep language high-level, user friendly and avoid technical references to internals.
  • Answer "What's new?", "Why was the change made?" and "Why should I care?" for each change.
  • If it's a breaking change, include a migration guide answering "What do I need to do to upgrade?".

vi.spyOn(profileSelectors, 'getScope').mockReturnValue(['register'])

const form = await getReviewFormFromStore(store, EventType.Birth)

const testComponent = await createTestComponent(
// @ts-ignore
// @TODO
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

In a sense that test logic needs to be inspected

const app = mount(
<App store={store} history={history} client={createGraphQLClient()} />
<Root store={store} router={router} client={createGraphQLClient()} />
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

History is no longert needed. Use Router to access location etc. in tests.

</Provider>
)
}

return mount(<PropProxy {...node.props} />, options)
return { component: mount(<PropProxy />, options), router }
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Most of the tests will work once history is removed and we access component property

staticContext={undefined}
history={history}
location={history.location}
// match={{
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

These should not be needed, router will handle them

const testComponent = await createTestComponent(
// @ts-ignore
// @TODO
const foo = formatUrl(REVIEW_EVENT_PARENT_FORM_PAGE_GROUP, {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Figure out which URL needs to be given here. I changed it group since it was given as part of match.

)

const { status, node } = actionStatus(component, [ACTION.VIEW_DECLARATION])
expect(status).toBe(ACTION_STATUS.ENABLED)

node?.simulate('click')

expect(window.location.href).toContain(
expect(router.state.location.pathname).toContain(
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 need to access window, use this pattern

@makelicious makelicious marked this pull request as ready for review December 3, 2024 10:41
@makelicious makelicious merged commit 0f0bdad into chore/upgrade-react-router-dom Dec 3, 2024
29 of 32 checks passed
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