Skip to content
代码片段 群组 项目
未验证 提交 4cfd0af3 编辑于 作者: Kushal Pandya's avatar Kushal Pandya 提交者: GitLab
浏览文件

Merge branch '439145-hide-exposed-artifacts-widget-when-no-artifacts' into 'master'

No related branches found
No related tags found
无相关合并请求
...@@ -20,6 +20,9 @@ export default { ...@@ -20,6 +20,9 @@ export default {
computed: { computed: {
...mapState(['artifacts', 'isLoading', 'hasError']), ...mapState(['artifacts', 'isLoading', 'hasError']),
...mapGetters(['title']), ...mapGetters(['title']),
hasArtifacts() {
return this.artifacts.length > 0;
},
}, },
created() { created() {
this.setEndpoint(this.endpoint); this.setEndpoint(this.endpoint);
...@@ -31,7 +34,12 @@ export default { ...@@ -31,7 +34,12 @@ export default {
}; };
</script> </script>
<template> <template>
<mr-collapsible-extension :title="title" :is-loading="isLoading" :has-error="hasError"> <mr-collapsible-extension
v-if="isLoading || hasArtifacts || hasError"
:title="title"
:is-loading="isLoading"
:has-error="hasError"
>
<artifacts-list :artifacts="artifacts" /> <artifacts-list :artifacts="artifacts" />
</mr-collapsible-extension> </mr-collapsible-extension>
</template> </template>
...@@ -57,7 +57,6 @@ describe('Merge Requests Artifacts list app', () => { ...@@ -57,7 +57,6 @@ describe('Merge Requests Artifacts list app', () => {
beforeEach(() => { beforeEach(() => {
createComponent(); createComponent();
store.dispatch('requestArtifacts'); store.dispatch('requestArtifacts');
return nextTick();
}); });
it('renders a loading icon', () => { it('renders a loading icon', () => {
...@@ -84,7 +83,6 @@ describe('Merge Requests Artifacts list app', () => { ...@@ -84,7 +83,6 @@ describe('Merge Requests Artifacts list app', () => {
data: artifacts, data: artifacts,
status: HTTP_STATUS_OK, status: HTTP_STATUS_OK,
}); });
return nextTick();
}); });
it('renders a title with the number of artifacts', () => { it('renders a title with the number of artifacts', () => {
...@@ -107,12 +105,27 @@ describe('Merge Requests Artifacts list app', () => { ...@@ -107,12 +105,27 @@ describe('Merge Requests Artifacts list app', () => {
}); });
}); });
describe('with 0 artifacts', () => {
beforeEach(() => {
createComponent();
mock.onGet(FAKE_ENDPOINT).reply(HTTP_STATUS_OK, [], {});
store.dispatch('receiveArtifactsSuccess', {
data: [],
status: HTTP_STATUS_OK,
});
});
it('does not render', () => {
expect(findTitle().exists()).toBe(false);
expect(findButtons().exists()).toBe(false);
});
});
describe('with error', () => { describe('with error', () => {
beforeEach(() => { beforeEach(() => {
createComponent(); createComponent();
mock.onGet(FAKE_ENDPOINT).reply(HTTP_STATUS_INTERNAL_SERVER_ERROR, {}, {}); mock.onGet(FAKE_ENDPOINT).reply(HTTP_STATUS_INTERNAL_SERVER_ERROR, {}, {});
store.dispatch('receiveArtifactsError'); store.dispatch('receiveArtifactsError');
return nextTick();
}); });
it('renders the error state', () => { it('renders the error state', () => {
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册