-
Notifications
You must be signed in to change notification settings - Fork 706
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1495 5 app repos for namespace only (#1503)
* Initial displaying of app repos per namespace. * Refetch on namespace change. Use kubeapps namespace for _all * Add info to help with change. * Update snapshot * Update to display app repos across all namespaces when All Namespaces selected. * Remove confusing sentence.
- Loading branch information
1 parent
9cac48d
commit c399f08
Showing
13 changed files
with
257 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
dashboard/src/components/Config/AppRepoList/AppRepoList.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import { shallow } from "enzyme"; | ||
import * as React from "react"; | ||
|
||
import AppRepoList from "./AppRepoList"; | ||
|
||
const defaultNamespace = "default-namespace"; | ||
|
||
const defaultProps = { | ||
errors: {}, | ||
repos: [], | ||
fetchRepos: jest.fn(), | ||
deleteRepo: jest.fn(), | ||
resyncRepo: jest.fn(), | ||
resyncAllRepos: jest.fn(), | ||
install: jest.fn(), | ||
namespace: defaultNamespace, | ||
displayReposPerNamespaceMsg: false, | ||
}; | ||
|
||
describe("AppRepoList", () => { | ||
it("fetches repos for a namespace when mounted", () => { | ||
const props = { | ||
...defaultProps, | ||
fetchRepos: jest.fn(), | ||
}; | ||
|
||
shallow(<AppRepoList {...props} />); | ||
|
||
expect(props.fetchRepos).toHaveBeenCalledWith(defaultNamespace); | ||
}); | ||
|
||
it("refetches repos when updating after a fetch error is cleared", () => { | ||
const props = { | ||
...defaultProps, | ||
errors: { fetch: new Error("Bang!") }, | ||
fetchRepos: jest.fn(), | ||
}; | ||
|
||
const wrapper = shallow(<AppRepoList {...props} />); | ||
wrapper.setProps({ | ||
...props, | ||
errors: {}, | ||
}); | ||
|
||
expect(props.fetchRepos).toHaveBeenCalledTimes(2); | ||
expect(props.fetchRepos).toHaveBeenLastCalledWith(defaultNamespace); | ||
}); | ||
|
||
it("refetches repos when the namespace changes", () => { | ||
const props = { | ||
...defaultProps, | ||
fetchRepos: jest.fn(), | ||
}; | ||
const differentNamespace = "different-namespace"; | ||
|
||
const wrapper = shallow(<AppRepoList {...props} />); | ||
wrapper.setProps({ | ||
...props, | ||
namespace: differentNamespace, | ||
}); | ||
|
||
expect(props.fetchRepos).toHaveBeenCalledTimes(2); | ||
expect(props.fetchRepos).toHaveBeenLastCalledWith(differentNamespace); | ||
}); | ||
|
||
it("does not refetch otherwise", () => { | ||
const props = { | ||
...defaultProps, | ||
fetchRepos: jest.fn(), | ||
}; | ||
|
||
const wrapper = shallow(<AppRepoList {...props} />); | ||
wrapper.setProps({ | ||
...props, | ||
errors: { fetch: new Error("Bang!") }, | ||
}); | ||
|
||
expect(props.fetchRepos).toHaveBeenCalledTimes(1); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.