Commit 592a5273 authored by Phil Hughes's avatar Phil Hughes Committed by Bob Van Landuyt

Updated frontend specs

parent 09639474
// Jest Snapshot v1, https://goo.gl/fbAQLP // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Design management upload form component hides button if cant upload 1`] = `
<header
class="row-content-block border-top-0 p-2 d-flex"
>
<div>
<!---->
<input
accept="image/*"
class="hide"
multiple="multiple"
name="design_file"
type="file"
/>
</div>
</header>
`;
exports[`Design management upload form component renders loading icon 1`] = ` exports[`Design management upload form component renders loading icon 1`] = `
<header <header
class="row-content-block border-top-0 p-2 d-flex" class="row-content-block border-top-0 p-2 d-flex"
......
...@@ -4,10 +4,11 @@ import UploadForm from 'ee/design_management/components/upload/form.vue'; ...@@ -4,10 +4,11 @@ import UploadForm from 'ee/design_management/components/upload/form.vue';
describe('Design management upload form component', () => { describe('Design management upload form component', () => {
let vm; let vm;
function createComponent(isSaving = false) { function createComponent(isSaving = false, canUploadDesign = true) {
vm = shallowMount(UploadForm, { vm = shallowMount(UploadForm, {
propsData: { propsData: {
isSaving, isSaving,
canUploadDesign,
}, },
}); });
} }
...@@ -24,6 +25,12 @@ describe('Design management upload form component', () => { ...@@ -24,6 +25,12 @@ describe('Design management upload form component', () => {
expect(vm.element).toMatchSnapshot(); expect(vm.element).toMatchSnapshot();
}); });
it('hides button if cant upload', () => {
createComponent(false, false);
expect(vm.element).toMatchSnapshot();
});
describe('onFileUploadChange', () => { describe('onFileUploadChange', () => {
it('emits upload event', () => { it('emits upload event', () => {
createComponent(); createComponent();
......
...@@ -2,7 +2,9 @@ ...@@ -2,7 +2,9 @@
exports[`Design management index page designs renders designs list 1`] = ` exports[`Design management index page designs renders designs list 1`] = `
<div> <div>
<uploadform-stub /> <uploadform-stub
canuploaddesign="true"
/>
<div <div
class="mt-4" class="mt-4"
...@@ -18,7 +20,9 @@ exports[`Design management index page designs renders designs list 1`] = ` ...@@ -18,7 +20,9 @@ exports[`Design management index page designs renders designs list 1`] = `
exports[`Design management index page designs renders empty text 1`] = ` exports[`Design management index page designs renders empty text 1`] = `
<div> <div>
<uploadform-stub /> <uploadform-stub
canuploaddesign="true"
/>
<div <div
class="mt-4" class="mt-4"
...@@ -34,7 +38,9 @@ exports[`Design management index page designs renders empty text 1`] = ` ...@@ -34,7 +38,9 @@ exports[`Design management index page designs renders empty text 1`] = `
exports[`Design management index page designs renders error 1`] = ` exports[`Design management index page designs renders error 1`] = `
<div> <div>
<uploadform-stub /> <uploadform-stub
canuploaddesign="true"
/>
<div <div
class="mt-4" class="mt-4"
...@@ -54,7 +60,9 @@ exports[`Design management index page designs renders error 1`] = ` ...@@ -54,7 +60,9 @@ exports[`Design management index page designs renders error 1`] = `
exports[`Design management index page designs renders loading icon 1`] = ` exports[`Design management index page designs renders loading icon 1`] = `
<div> <div>
<uploadform-stub /> <uploadform-stub
canuploaddesign="true"
/>
<div <div
class="mt-4" class="mt-4"
......
...@@ -3,15 +3,19 @@ import Index from 'ee/design_management/pages/index.vue'; ...@@ -3,15 +3,19 @@ import Index from 'ee/design_management/pages/index.vue';
import uploadDesignQuery from 'ee/design_management/queries/uploadDesign.graphql'; import uploadDesignQuery from 'ee/design_management/queries/uploadDesign.graphql';
describe('Design management index page', () => { describe('Design management index page', () => {
const mutate = jest.fn(() => Promise.resolve()); let mutate;
let vm; let vm;
function createComponent(loading = false) { function createComponent(loading = false) {
mutate = jest.fn(() => Promise.resolve());
const $apollo = { const $apollo = {
queries: { queries: {
designs: { designs: {
loading, loading,
}, },
permissions: {
loading,
},
}, },
mutate, mutate,
}; };
...@@ -20,6 +24,12 @@ describe('Design management index page', () => { ...@@ -20,6 +24,12 @@ describe('Design management index page', () => {
mocks: { $apollo }, mocks: { $apollo },
stubs: ['router-view'], stubs: ['router-view'],
}); });
vm.setData({
permissions: {
createDesign: true,
},
});
} }
describe('designs', () => { describe('designs', () => {
...@@ -86,6 +96,20 @@ describe('Design management index page', () => { ...@@ -86,6 +96,20 @@ describe('Design management index page', () => {
}); });
}); });
it('does not call apollo mutate if createDesign is false', () => {
createComponent();
vm.setData({
permissions: {
createDesign: false,
},
});
vm.vm.onUploadDesign([]);
expect(mutate).not.toHaveBeenCalled();
});
it('sets isSaving', () => { it('sets isSaving', () => {
createComponent(); createComponent();
......
...@@ -24,7 +24,11 @@ describe('Design management router', () => { ...@@ -24,7 +24,11 @@ describe('Design management router', () => {
router, router,
mocks: { mocks: {
$apollo: { $apollo: {
queries: { designs: { loading: true }, design: { loading: true } }, queries: {
designs: { loading: true },
design: { loading: true },
permissions: { loading: true },
},
}, },
}, },
}); });
......
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