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 #37276 - test failing because of foreman context change #564

Merged
merged 1 commit into from
Mar 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions webpack/testHelper.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { useState } from 'react';
import { Provider } from 'react-redux';
import store from 'foremanReact/redux';
import { MockedProvider } from '@apollo/react-testing';
Expand All @@ -19,20 +19,21 @@ export const withRouter = Component => props => (
);

export const withMockedProvider = Component => props => {
const ForemanContext = getForemanContext(ctx);
// eslint-disable-next-line react/prop-types
const { mocks, ...rest } = props;

const ctx = {
const [context, setContext] = useState({
metadata: {
UISettings: {
perPage: 20,
},
},
};
});

const contextData = { context, setContext };
const ForemanContext = getForemanContext(contextData);
return (
<ForemanContext.Provider value={ctx}>
<ForemanContext.Provider value={contextData}>
<MockedProvider mocks={mocks}>
<Component {...rest} />
</MockedProvider>
Expand Down
Loading