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

Fixes #37245 - 25 tests failing with "TypeError: Cannot read property 'perPage' of undefined" #698

Merged
merged 1 commit into from
Mar 19, 2024

Conversation

Thorben-D
Copy link
Contributor

Bug #37245

This pull-request fixes #37245 by wrapping the mocked context in a React state.

Detailed problem description

This bug was introduced, when useForemanContext of ForemanContext.js was changed in theforeman/foreman@0b40a64

In the commit, useForemanContext was split into useForemanContext and useForemanSetContext, which return getForemanContext.context and getForemanContext.setContext respectively. context and setContext were provided by wrapping the original context object in React.useState().
In foreman_ansible, this change is not yet reflected. getForemanContext still returns the raw context object. Since the context object does not have the fields context and setContext, useForemanContext and useForemanSetContext would return undefined, causing the tests to fail.

This is fixed, by wrapping the context object given to getForemanContext in withMockedProvider of testHelper.js in React.useState() similar to ReactApp.js of Foreman.

@nofaralfasi
Copy link
Contributor

@MariaAga can I get your approval on this?

Copy link
Member

@MariaAga MariaAga left a comment

Choose a reason for hiding this comment

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

Good solution, thanks! I'll implement it in foreman_openscap as well.
Ruby test failures dont look related

@dosas
Copy link
Contributor

dosas commented Mar 19, 2024

All approvals are there who can merge?

@nofaralfasi nofaralfasi merged commit 09517d6 into theforeman:master Mar 19, 2024
21 of 24 checks passed
@nofaralfasi
Copy link
Contributor

Thanks @dosas!!

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.

4 participants