Skip to content

Commit

Permalink
Reproduce #5805 and fix. (#5826)
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Nelson <[email protected]>

<!--
Before you open the request please review the following guidelines and
tips to help it be more easily integrated:

 - Describe the scope of your change - i.e. what the change does.
 - Describe any known limitations with your change.
- Please run any tests or examples that can exercise your modified code.

 Thank you for contributing!
 -->

### Description of the change

<!-- Describe the scope of your change - i.e. what the change does. -->

Ensures that deployment form can still display even if the schemaEditor
feature flag is not set.

### Benefits

<!-- What benefits will be realized by the code change? -->

Fixes the immediate error shown for #5805, though I'm not convinced
it'll be the only error (it's still not clear why the configuration
options would not be set).

### Possible drawbacks

<!-- Describe any known limitations with your change -->

### Applicable issues

<!-- Enter any applicable Issues here (You can reference an issue using
#) -->

- fixes #5805 

### Additional information

<!-- If there's anything else that's important and relevant to your pull
request, mention that information here.-->

Signed-off-by: Michael Nelson <[email protected]>
  • Loading branch information
absoludity authored Jan 10, 2023
1 parent a26016a commit 32292ff
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import { defaultStore, getStore, initialState, mountWrapper } from "shared/specs
import { IPackageState } from "shared/types";
import BasicDeploymentForm from "./BasicDeploymentForm";
import DeploymentFormBody, { IDeploymentFormBodyProps } from "./DeploymentFormBody";
import configureMockStore from "redux-mock-store";
import thunk from "redux-thunk";

beforeEach(() => {
// mock the window.matchMedia for selecting the theme
Expand Down Expand Up @@ -190,6 +192,26 @@ it("should not render a schema editor if the feature flag is disabled", () => {
).not.toExist();
});

// Reproduce https://github.com/vmware-tanzu/kubeapps/issues/5805
it("should not render a schema editor if the feature flag is not set", () => {
const { schemaEditor, ...featureFlagsWithout } = initialState.config.featureFlags;
const state = {
...initialState,
config: {
...initialState.config,
featureFlags: featureFlagsWithout,
},
};
const mockStore = configureMockStore([thunk]);
const wrapper = mountWrapper(
mockStore(state),
<DeploymentFormBody {...defaultProps} selected={{ ...selected, schema: defaultSchema }} />,
);

expect(
wrapper.find(MonacoDiffEditor).filterWhere(p => p.prop("language") === "json"),
).not.toExist();
});
it("should render a schema editor if the feature flag is enabled", () => {
const state = {
...initialState,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -336,8 +336,7 @@ function DeploymentFormBody({
key="advanced-deployment-form"
></AdvancedDeploymentForm>,
);

if (featureFlags.schemaEditor.enabled) {
if (featureFlags?.schemaEditor?.enabled) {
// Schema editor creation, if the feature flag is enabled
tabColumns.push(
<div role="presentation" onClick={saveAllChanges}>
Expand Down

0 comments on commit 32292ff

Please sign in to comment.