Skip to content

Commit

Permalink
Request chart when both repo and app are populated (#1455)
Browse files Browse the repository at this point in the history
  • Loading branch information
Andres Martinez Gotor authored Jan 16, 2020
1 parent e1d3c21 commit 7b96684
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
19 changes: 19 additions & 0 deletions dashboard/src/components/AppUpgrade/AppUpgrade.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,25 @@ describe("when receiving new props", () => {
expect(getDeployedChartVersion).toHaveBeenCalledWith("stable/bar", "1.0.0");
});

it("should request the deployed chart when the repo is populated later", () => {
const repo = { metadata: { name: "stable" } };
const app = {
chart: {
metadata: {
name: "bar",
version: "1.0.0",
},
},
} as IRelease;
const getDeployedChartVersion = jest.fn();
const wrapper = shallow(
<AppUpgrade {...defaultProps} app={app} getDeployedChartVersion={getDeployedChartVersion} />,
);
expect(getDeployedChartVersion).not.toHaveBeenCalled();
wrapper.setProps({ repo });
expect(getDeployedChartVersion).toHaveBeenCalledWith("stable/bar", "1.0.0");
});

it("a new app should re-trigger the deployed chart retrieval", () => {
const repo = { metadata: { name: "stable" } };
const app = {
Expand Down
2 changes: 1 addition & 1 deletion dashboard/src/components/AppUpgrade/AppUpgrade.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class AppUpgrade extends React.Component<IAppUpgradeProps, IAppUpgradeState> {
repo &&
repo.metadata &&
repo.metadata.name &&
prevProps.app !== app
(prevProps.app !== app || prevProps.repo !== repo)
) {
const chartID = `${repo.metadata.name}/${chart.metadata.name}`;
this.props.getDeployedChartVersion(chartID, chart.metadata.version);
Expand Down

0 comments on commit 7b96684

Please sign in to comment.