Commit bf4e8b1b authored by Filipa Lacerda's avatar Filipa Lacerda

Merge branch 'design-management-large-image-component' into 'master'

Added image component to design detail view

See merge request gitlab-org/gitlab-ee!10480
parents bad1a2fa 93c84858
<script>
import { GlLoadingIcon } from '@gitlab/ui';
export default {
components: {
GlLoadingIcon,
},
props: {
image: {
type: String,
required: false,
default: '',
},
name: {
type: String,
required: false,
default: '',
},
isLoading: {
type: Boolean,
required: true,
},
},
};
</script>
<template>
<div class="d-flex align-items-center h-100 w-100 p-3 overflow-hidden js-design-image">
<gl-loading-icon v-if="isLoading" class="ml-auto mr-auto" size="md" color="light" />
<img v-else :src="image" :alt="name" class="ml-auto mr-auto img-fluid mh-100" />
</div>
</template>
...@@ -8,7 +8,7 @@ Vue.use(VueApollo); ...@@ -8,7 +8,7 @@ Vue.use(VueApollo);
const createMockDesign = id => ({ const createMockDesign = id => ({
id: Number(id), id: Number(id),
image: 'http://via.placeholder.com/300', image: 'http://via.placeholder.com/1000',
name: 'test.jpg', name: 'test.jpg',
commentsCount: 2, commentsCount: 2,
updatedAt: new Date().toString(), updatedAt: new Date().toString(),
......
<script> <script>
import Toolbar from '../../components/toolbar/index.vue'; import Toolbar from '../../components/toolbar/index.vue';
import DesignImage from '../../components/image.vue';
import getDesignQuery from '../../queries/getDesign.graphql'; import getDesignQuery from '../../queries/getDesign.graphql';
export default { export default {
components: { components: {
DesignImage,
Toolbar, Toolbar,
}, },
props: { props: {
...@@ -36,12 +38,13 @@ export default { ...@@ -36,12 +38,13 @@ export default {
</script> </script>
<template> <template>
<div class="design-detail fixed-top w-100 h-100"> <div class="design-detail fixed-top w-100 position-bottom-0 d-flex flex-column">
<toolbar <toolbar
:is-loading="isLoading" :is-loading="isLoading"
:name="design.name" :name="design.name"
:updated-at="design.updatedAt" :updated-at="design.updatedAt"
:updated-by="design.updatedBy" :updated-by="design.updatedBy"
/> />
<design-image :is-loading="isLoading" :image="design.image" :name="design.name" />
</div> </div>
</template> </template>
...@@ -19,5 +19,7 @@ describe 'User views issue designs', :js do ...@@ -19,5 +19,7 @@ describe 'User views issue designs', :js do
expect(page).to have_content('test.jpg') expect(page).to have_content('test.jpg')
expect(page).to have_content('Test Name') expect(page).to have_content('Test Name')
end end
expect(page).to have_selector('.js-design-image')
end end
end end
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Design management large image component renders image 1`] = `
<div
class="d-flex align-items-center h-100 w-100 p-3 overflow-hidden js-design-image"
>
<img
alt="test"
class="ml-auto mr-auto img-fluid mh-100"
src="test.jpg"
/>
</div>
`;
exports[`Design management large image component renders loading state 1`] = `
<div
class="d-flex align-items-center h-100 w-100 p-3 overflow-hidden js-design-image"
>
<glloadingicon-stub
class="ml-auto mr-auto"
color="light"
label="Loading"
size="md"
/>
</div>
`;
import { shallowMount } from '@vue/test-utils';
import DesignImage from 'ee/design_management/components/image.vue';
describe('Design management large image component', () => {
let vm;
function createComponent(propsData) {
vm = shallowMount(DesignImage, {
propsData,
});
}
afterEach(() => {
vm.destroy();
});
it('renders loading state', () => {
createComponent({
isLoading: true,
});
expect(vm.element).toMatchSnapshot();
});
it('renders image', () => {
createComponent({
isLoading: false,
image: 'test.jpg',
name: 'test',
});
expect(vm.element).toMatchSnapshot();
});
});
// Jest Snapshot v1, https://goo.gl/fbAQLP // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Design management design index page sets loading state 1`] = ` exports[`Design management design index page renders design index 1`] = `
<div <div
class="design-detail fixed-top w-100 h-100" class="design-detail fixed-top w-100 position-bottom-0 d-flex flex-column"
> >
<toolbar-stub <toolbar-stub
isloading="true" name="test.jpg"
name=""
updatedat="" updatedat=""
updatedby="[object Object]" updatedby="[object Object]"
/> />
<designimage-stub
image="test.jpg"
name="test.jpg"
/>
</div> </div>
`; `;
exports[`Design management design index page sets loading state 2`] = ` exports[`Design management design index page sets loading state 1`] = `
<div <div
class="design-detail fixed-top w-100 h-100" class="design-detail fixed-top w-100 position-bottom-0 d-flex flex-column"
> >
<toolbar-stub <toolbar-stub
name="test.jpg" isloading="true"
updatedat="01-01-2019" name=""
updatedat=""
updatedby="[object Object]" updatedby="[object Object]"
/> />
<designimage-stub
image=""
isloading="true"
name=""
/>
</div> </div>
`; `;
...@@ -25,12 +25,13 @@ describe('Design management design index page', () => { ...@@ -25,12 +25,13 @@ describe('Design management design index page', () => {
expect(vm.element).toMatchSnapshot(); expect(vm.element).toMatchSnapshot();
}); });
it('sets loading state', () => { it('renders design index', () => {
createComponent(); createComponent();
vm.setData({ vm.setData({
design: { design: {
name: 'test.jpg', name: 'test.jpg',
image: 'test.jpg',
updatedAt: '01-01-2019', updatedAt: '01-01-2019',
updatedBy: { updatedBy: {
name: 'test', name: 'test',
......
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