Commit a48992de authored by Jarek Ostrowski's avatar Jarek Ostrowski Committed by Natalia Tepluhina

Remove actions buttons if theres no designs

Add changelog
Put v-if before class, lint error
Prettify
parent 7add986c
---
title: Remove action buttons from designs tab if there are no designs
merge_request: 21186
author:
type: fixed
...@@ -212,7 +212,7 @@ export default { ...@@ -212,7 +212,7 @@ export default {
<header v-if="showToolbar" class="row-content-block border-top-0 p-2 d-flex"> <header v-if="showToolbar" class="row-content-block border-top-0 p-2 d-flex">
<div class="d-flex justify-content-between align-items-center w-100"> <div class="d-flex justify-content-between align-items-center w-100">
<design-version-dropdown /> <design-version-dropdown />
<div class="d-flex"> <div v-if="hasDesigns" class="d-flex qa-selector-toolbar">
<gl-button <gl-button
v-if="isLatestVersion" v-if="isLatestVersion"
variant="link" variant="link"
......
...@@ -69,7 +69,7 @@ exports[`Design management index page designs renders designs list and header wi ...@@ -69,7 +69,7 @@ exports[`Design management index page designs renders designs list and header wi
<designversiondropdown-stub /> <designversiondropdown-stub />
<div <div
class="d-flex" class="d-flex qa-selector-toolbar"
> >
<glbutton-stub <glbutton-stub
class="mr-2 js-select-all" class="mr-2 js-select-all"
...@@ -158,17 +158,20 @@ exports[`Design management index page designs renders designs list and header wi ...@@ -158,17 +158,20 @@ exports[`Design management index page designs renders designs list and header wi
</div> </div>
`; `;
exports[`Design management index page designs renders empty text 1`] = ` exports[`Design management index page designs renders error 1`] = `
<div> <div>
<!----> <!---->
<div <div
class="mt-4" class="mt-4"
> >
<glemptystate-stub <div
description="Upload and view the latest designs for this issue. Consistent and easy to find, so everyone is up to date." class="alert alert-danger"
title="The one place for your designs" >
/>
An error occurred while loading designs. Please try again.
</div>
</div> </div>
<routerview-stub <routerview-stub
...@@ -177,20 +180,18 @@ exports[`Design management index page designs renders empty text 1`] = ` ...@@ -177,20 +180,18 @@ exports[`Design management index page designs renders empty text 1`] = `
</div> </div>
`; `;
exports[`Design management index page designs renders error 1`] = ` exports[`Design management index page designs renders loading icon 1`] = `
<div> <div>
<!----> <!---->
<div <div
class="mt-4" class="mt-4"
> >
<div <glloadingicon-stub
class="alert alert-danger" color="orange"
> label="Loading"
size="md"
An error occurred while loading designs. Please try again. />
</div>
</div> </div>
<routerview-stub <routerview-stub
...@@ -199,17 +200,16 @@ exports[`Design management index page designs renders error 1`] = ` ...@@ -199,17 +200,16 @@ exports[`Design management index page designs renders error 1`] = `
</div> </div>
`; `;
exports[`Design management index page designs renders loading icon 1`] = ` exports[`Design management index page when has no designs renders empty text 1`] = `
<div> <div>
<!----> <!---->
<div <div
class="mt-4" class="mt-4"
> >
<glloadingicon-stub <glemptystate-stub
color="orange" description="Upload and view the latest designs for this issue. Consistent and easy to find, so everyone is up to date."
label="Loading" title="The one place for your designs"
size="md"
/> />
</div> </div>
......
...@@ -56,6 +56,7 @@ describe('Design management index page', () => { ...@@ -56,6 +56,7 @@ describe('Design management index page', () => {
const findDesignCheckboxes = () => wrapper.findAll('.design-checkbox'); const findDesignCheckboxes = () => wrapper.findAll('.design-checkbox');
const findSelectAllButton = () => wrapper.find('.js-select-all'); const findSelectAllButton = () => wrapper.find('.js-select-all');
const findDeleteButton = () => wrapper.find('deletebutton-stub'); const findDeleteButton = () => wrapper.find('deletebutton-stub');
const findToolbar = () => wrapper.find('.qa-selector-toolbar');
function createComponent({ function createComponent({
loading = false, loading = false,
...@@ -115,10 +116,12 @@ describe('Design management index page', () => { ...@@ -115,10 +116,12 @@ describe('Design management index page', () => {
}); });
}); });
it('renders empty text', () => { it('renders a toolbar with buttons when there are designs', () => {
createComponent(); createComponent({ designs: mockDesigns, allVersions: [mockVersion] });
expect(wrapper.element).toMatchSnapshot(); return wrapper.vm.$nextTick().then(() => {
expect(findToolbar().exists()).toBe(true);
});
}); });
it('renders designs list and header with upload button', () => { it('renders designs list and header with upload button', () => {
...@@ -138,6 +141,20 @@ describe('Design management index page', () => { ...@@ -138,6 +141,20 @@ describe('Design management index page', () => {
}); });
}); });
describe('when has no designs', () => {
beforeEach(() => {
createComponent();
});
it('renders empty text', () => {
expect(wrapper.element).toMatchSnapshot();
});
it('does not render a toolbar with buttons', () => {
expect(findToolbar().exists()).toBe(false);
});
});
describe('onUploadDesign', () => { describe('onUploadDesign', () => {
it('calls apollo mutate', () => { it('calls apollo mutate', () => {
createComponent(); createComponent();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment