Skip to content
This repository was archived by the owner on Mar 24, 2023. It is now read-only.

Commit ef1cda7

Browse files
authored
Allow saving after reaching error state on helm values step in UI (#765)
1 parent 04831e9 commit ef1cda7

File tree

2 files changed

+69
-2
lines changed

2 files changed

+69
-2
lines changed

web/init/src/components/kustomize/HelmValuesEditor.jsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export default class HelmValuesEditor extends React.Component {
4343
}
4444
}
4545

46-
46+
4747

4848
getLinterErrors = (specContents) => {
4949
if (specContents === "") return;
@@ -120,7 +120,8 @@ export default class HelmValuesEditor extends React.Component {
120120
if (errors) {
121121
return this.setState({
122122
saving: false,
123-
helmLintErrors: errors
123+
helmLintErrors: errors,
124+
saveFinal: false,
124125
});
125126
}
126127
this.setState({ saving: false, savedYaml: true });
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
import React from "react";
2+
import { shallow } from "enzyme";
3+
import HelmValuesEditor from "./HelmValuesEditor";
4+
5+
const mockShipAppMetadata = {
6+
values: "some: values",
7+
readme: "a readme",
8+
name: "test",
9+
}
10+
11+
const mockGetStep = {};
12+
13+
describe("HelmValuesEditor", () => {
14+
describe("with invalid helm values", () => {
15+
describe("saved and finalized", () => {
16+
it("allows for the save button to be clicked after an error", async() => {
17+
const mockSaveValues = jest.fn();
18+
mockSaveValues.mockImplementation(() => Promise.resolve({ errors: ["Test error"]}));
19+
20+
const mockSpecValue = "some: different values";
21+
const wrapper = shallow(
22+
<HelmValuesEditor
23+
shipAppMetadata={mockShipAppMetadata}
24+
saveValues={mockSaveValues}
25+
getStep={mockGetStep}
26+
/>
27+
);
28+
29+
wrapper.setState({ specValue: mockSpecValue });
30+
await wrapper.instance().handleSaveValues(true);
31+
32+
expect(mockSaveValues.mock.calls).toHaveLength(1);
33+
const elements = wrapper.find("button");
34+
expect(elements).toHaveLength(2);
35+
elements.forEach((element) => {
36+
expect(element.prop("disabled")).toEqual(false);
37+
});
38+
});
39+
});
40+
describe("saved", () => {
41+
it("allows for the save button to be clicked after an error", async() => {
42+
const mockSaveValues = jest.fn();
43+
mockSaveValues.mockImplementation(() => Promise.resolve({ errors: ["Test error"]}));
44+
45+
const mockSpecValue = "some: different values";
46+
const wrapper = shallow(
47+
<HelmValuesEditor
48+
shipAppMetadata={mockShipAppMetadata}
49+
saveValues={mockSaveValues}
50+
getStep={mockGetStep}
51+
/>
52+
);
53+
54+
wrapper.setState({ specValue: mockSpecValue });
55+
await wrapper.instance().handleSaveValues(false);
56+
57+
expect(mockSaveValues.mock.calls).toHaveLength(1);
58+
const elements = wrapper.find("button");
59+
expect(elements).toHaveLength(2);
60+
elements.forEach((element) => {
61+
expect(element.prop("disabled")).toEqual(false);
62+
});
63+
});
64+
});
65+
});
66+
});

0 commit comments

Comments
 (0)