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 {
computed: {
...mapState(['artifacts', 'isLoading', 'hasError']),
...mapGetters(['title']),
hasArtifacts() {
return this.artifacts.length > 0;
},
},
created() {
this.setEndpoint(this.endpoint);
......@@ -31,7 +34,12 @@ export default {
};
</script>
<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" />
</mr-collapsible-extension>
</template>
......@@ -57,7 +57,6 @@ describe('Merge Requests Artifacts list app', () => {
beforeEach(() => {
createComponent();
store.dispatch('requestArtifacts');
return nextTick();
});
it('renders a loading icon', () => {
......@@ -84,7 +83,6 @@ describe('Merge Requests Artifacts list app', () => {
data: artifacts,
status: HTTP_STATUS_OK,
});
return nextTick();
});
it('renders a title with the number of artifacts', () => {
......@@ -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', () => {
beforeEach(() => {
createComponent();
mock.onGet(FAKE_ENDPOINT).reply(HTTP_STATUS_INTERNAL_SERVER_ERROR, {}, {});
store.dispatch('receiveArtifactsError');
return nextTick();
});
it('renders the error state', () => {
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册