Commit d5cb4762 authored by Mark Florian's avatar Mark Florian

Merge branch 'smaller-image-files-fe-prep' into 'master'

[FE] Support multiple design image sizes in Design Management

See merge request gitlab-org/gitlab!24828
parents b2b488cb b1653499
...@@ -43,6 +43,11 @@ export default { ...@@ -43,6 +43,11 @@ export default {
required: false, required: false,
default: true, default: true,
}, },
imageV432x230: {
type: String,
required: false,
default: null,
},
}, },
data() { data() {
return { return {
...@@ -80,7 +85,7 @@ export default { ...@@ -80,7 +85,7 @@ export default {
return this.imageLoading || this.isUploading; return this.imageLoading || this.isUploading;
}, },
imageLink() { imageLink() {
return this.isInView ? this.image : ''; return this.isInView ? this.imageV432x230 || this.image : '';
}, },
}, },
methods: { methods: {
......
...@@ -4,4 +4,5 @@ fragment DesignListItem on Design { ...@@ -4,4 +4,5 @@ fragment DesignListItem on Design {
event event
filename filename
notesCount notesCount
imageV432x230
} }
...@@ -53,6 +53,7 @@ export const designUploadOptimisticResponse = files => { ...@@ -53,6 +53,7 @@ export const designUploadOptimisticResponse = files => {
__typename: 'Design', __typename: 'Design',
id: -uniqueId(), id: -uniqueId(),
image: '', image: '',
imageV432x230: '',
filename: file.name, filename: file.name,
fullPath: '', fullPath: '',
notesCount: 0, notesCount: 0,
......
---
title: "Prefer smaller image size for design cards in Design Management"
merge_request: 24828
author:
type: added
...@@ -17,6 +17,7 @@ const DESIGN_VERSION_EVENT = { ...@@ -17,6 +17,7 @@ const DESIGN_VERSION_EVENT = {
describe('Design management list item component', () => { describe('Design management list item component', () => {
let wrapper; let wrapper;
function createComponent({ function createComponent({
notesCount = 0, notesCount = 0,
event = DESIGN_VERSION_EVENT.NO_CHANGE, event = DESIGN_VERSION_EVENT.NO_CHANGE,
...@@ -48,17 +49,39 @@ describe('Design management list item component', () => { ...@@ -48,17 +49,39 @@ describe('Design management list item component', () => {
wrapper.destroy(); wrapper.destroy();
}); });
it('renders an image when it appears in view', () => { describe('when item is not in view', () => {
it('image is not rendered', () => {
createComponent(); createComponent();
const image = wrapper.find('img');
const image = wrapper.find('img');
expect(image.attributes('src')).toBe(''); expect(image.attributes('src')).toBe('');
});
});
describe('when item appears in view', () => {
beforeEach(() => {
createComponent();
wrapper.find(GlIntersectionObserver).vm.$emit('appear'); wrapper.find(GlIntersectionObserver).vm.$emit('appear');
return wrapper.vm.$nextTick();
});
return wrapper.vm.$nextTick().then(() => { it('renders an image', () => {
const image = wrapper.find('img');
expect(image.attributes('src')).toBe('http://via.placeholder.com/300'); expect(image.attributes('src')).toBe('http://via.placeholder.com/300');
}); });
describe('when imageV432x230 and image provided', () => {
it('renders imageV432x230 image', () => {
const mockSrc = 'mock-imageV432x230-url';
wrapper.setProps({ imageV432x230: mockSrc });
return wrapper.vm.$nextTick().then(() => {
const image = wrapper.find('img');
expect(image.attributes('src')).toBe(mockSrc);
});
});
});
}); });
describe('with notes', () => { describe('with notes', () => {
......
...@@ -197,6 +197,7 @@ describe('Design management index page', () => { ...@@ -197,6 +197,7 @@ describe('Design management index page', () => {
__typename: 'Design', __typename: 'Design',
id: expect.anything(), id: expect.anything(),
image: '', image: '',
imageV432x230: '',
filename: 'test', filename: 'test',
fullPath: '', fullPath: '',
event: 'NONE', event: 'NONE',
......
...@@ -85,6 +85,7 @@ describe('optimistic responses', () => { ...@@ -85,6 +85,7 @@ describe('optimistic responses', () => {
__typename: 'Design', __typename: 'Design',
id: -1, id: -1,
image: '', image: '',
imageV432x230: '',
filename: 'test', filename: 'test',
fullPath: '', fullPath: '',
notesCount: 0, notesCount: 0,
......
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