Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
1f63581a
Commit
1f63581a
authored
Feb 21, 2020
by
Thomas Randolph
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ensure that the image size always appears
...regardless of the diffMode that occurred
parent
88648d16
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
16 deletions
+38
-16
app/assets/javascripts/vue_shared/components/diff_viewer/viewers/image_diff_viewer.vue
...ared/components/diff_viewer/viewers/image_diff_viewer.vue
+1
-0
spec/javascripts/vue_shared/components/diff_viewer/viewers/image_diff_viewer_spec.js
.../components/diff_viewer/viewers/image_diff_viewer_spec.js
+37
-16
No files found.
app/assets/javascripts/vue_shared/components/diff_viewer/viewers/image_diff_viewer.vue
View file @
1f63581a
...
@@ -112,6 +112,7 @@ export default {
...
@@ -112,6 +112,7 @@ export default {
<div
class=
"image"
>
<div
class=
"image"
>
<image-viewer
<image-viewer
:path=
"imagePath"
:path=
"imagePath"
:file-size=
"isNew ? newSize : oldSize"
:inner-css-classes=
"[
:inner-css-classes=
"[
'frame',
'frame',
{
{
...
...
spec/javascripts/vue_shared/components/diff_viewer/viewers/image_diff_viewer_spec.js
View file @
1f63581a
...
@@ -9,6 +9,11 @@ describe('ImageDiffViewer', () => {
...
@@ -9,6 +9,11 @@ describe('ImageDiffViewer', () => {
newPath
:
GREEN_BOX_IMAGE_URL
,
newPath
:
GREEN_BOX_IMAGE_URL
,
oldPath
:
RED_BOX_IMAGE_URL
,
oldPath
:
RED_BOX_IMAGE_URL
,
};
};
const
allProps
=
{
...
requiredProps
,
oldSize
:
2048
,
newSize
:
1024
,
};
let
vm
;
let
vm
;
function
createComponent
(
props
)
{
function
createComponent
(
props
)
{
...
@@ -50,9 +55,11 @@ describe('ImageDiffViewer', () => {
...
@@ -50,9 +55,11 @@ describe('ImageDiffViewer', () => {
});
});
it
(
'
renders image diff for replaced
'
,
done
=>
{
it
(
'
renders image diff for replaced
'
,
done
=>
{
createComponent
(
requiredProps
);
createComponent
(
{
...
allProps
}
);
setTimeout
(()
=>
{
setTimeout
(()
=>
{
const
metaInfoElements
=
vm
.
$el
.
querySelectorAll
(
'
.image-info
'
);
expect
(
vm
.
$el
.
querySelector
(
'
.added img
'
).
getAttribute
(
'
src
'
)).
toBe
(
GREEN_BOX_IMAGE_URL
);
expect
(
vm
.
$el
.
querySelector
(
'
.added img
'
).
getAttribute
(
'
src
'
)).
toBe
(
GREEN_BOX_IMAGE_URL
);
expect
(
vm
.
$el
.
querySelector
(
'
.deleted img
'
).
getAttribute
(
'
src
'
)).
toBe
(
RED_BOX_IMAGE_URL
);
expect
(
vm
.
$el
.
querySelector
(
'
.deleted img
'
).
getAttribute
(
'
src
'
)).
toBe
(
RED_BOX_IMAGE_URL
);
...
@@ -66,35 +73,35 @@ describe('ImageDiffViewer', () => {
...
@@ -66,35 +73,35 @@ describe('ImageDiffViewer', () => {
'
Onion skin
'
,
'
Onion skin
'
,
);
);
expect
(
metaInfoElements
.
length
).
toBe
(
2
);
expect
(
metaInfoElements
[
0
]).
toHaveText
(
'
2.00 KiB
'
);
expect
(
metaInfoElements
[
1
]).
toHaveText
(
'
1.00 KiB
'
);
done
();
done
();
});
});
});
});
it
(
'
renders image diff for new
'
,
done
=>
{
it
(
'
renders image diff for new
'
,
done
=>
{
createComponent
(
createComponent
({
...
allProps
,
diffMode
:
'
new
'
,
oldPath
:
''
});
Object
.
assign
({},
requiredProps
,
{
diffMode
:
'
new
'
,
oldPath
:
''
,
}),
);
setTimeout
(()
=>
{
setTimeout
(()
=>
{
const
metaInfoElement
=
vm
.
$el
.
querySelector
(
'
.image-info
'
);
expect
(
vm
.
$el
.
querySelector
(
'
.added img
'
).
getAttribute
(
'
src
'
)).
toBe
(
GREEN_BOX_IMAGE_URL
);
expect
(
vm
.
$el
.
querySelector
(
'
.added img
'
).
getAttribute
(
'
src
'
)).
toBe
(
GREEN_BOX_IMAGE_URL
);
expect
(
metaInfoElement
).
toHaveText
(
'
1.00 KiB
'
);
done
();
done
();
});
});
});
});
it
(
'
renders image diff for deleted
'
,
done
=>
{
it
(
'
renders image diff for deleted
'
,
done
=>
{
createComponent
(
createComponent
({
...
allProps
,
diffMode
:
'
deleted
'
,
newPath
:
''
});
Object
.
assign
({},
requiredProps
,
{
diffMode
:
'
deleted
'
,
newPath
:
''
,
}),
);
setTimeout
(()
=>
{
setTimeout
(()
=>
{
const
metaInfoElement
=
vm
.
$el
.
querySelector
(
'
.image-info
'
);
expect
(
vm
.
$el
.
querySelector
(
'
.deleted img
'
).
getAttribute
(
'
src
'
)).
toBe
(
RED_BOX_IMAGE_URL
);
expect
(
vm
.
$el
.
querySelector
(
'
.deleted img
'
).
getAttribute
(
'
src
'
)).
toBe
(
RED_BOX_IMAGE_URL
);
expect
(
metaInfoElement
).
toHaveText
(
'
2.00 KiB
'
);
done
();
done
();
});
});
...
@@ -105,24 +112,38 @@ describe('ImageDiffViewer', () => {
...
@@ -105,24 +112,38 @@ describe('ImageDiffViewer', () => {
components
:
{
components
:
{
imageDiffViewer
,
imageDiffViewer
,
},
},
data
:
{
...
allProps
,
diffMode
:
'
renamed
'
,
},
template
:
`
template
:
`
<image-diff-viewer diff-mode="renamed" new-path="
${
GREEN_BOX_IMAGE_URL
}
" old-path="">
<image-diff-viewer
:diff-mode="diffMode"
:new-path="newPath"
:old-path="oldPath"
:new-size="newSize"
:old-size="oldSize"
>
<span slot="image-overlay" class="overlay">test</span>
<span slot="image-overlay" class="overlay">test</span>
</image-diff-viewer>
</image-diff-viewer>
`
,
`
,
}).
$mount
();
}).
$mount
();
setTimeout
(()
=>
{
setTimeout
(()
=>
{
const
metaInfoElement
=
vm
.
$el
.
querySelector
(
'
.image-info
'
);
expect
(
vm
.
$el
.
querySelector
(
'
img
'
).
getAttribute
(
'
src
'
)).
toBe
(
GREEN_BOX_IMAGE_URL
);
expect
(
vm
.
$el
.
querySelector
(
'
img
'
).
getAttribute
(
'
src
'
)).
toBe
(
GREEN_BOX_IMAGE_URL
);
expect
(
vm
.
$el
.
querySelector
(
'
.overlay
'
)).
not
.
toBe
(
null
);
expect
(
vm
.
$el
.
querySelector
(
'
.overlay
'
)).
not
.
toBe
(
null
);
expect
(
metaInfoElement
).
toHaveText
(
'
2.00 KiB
'
);
done
();
done
();
});
});
});
});
describe
(
'
swipeMode
'
,
()
=>
{
describe
(
'
swipeMode
'
,
()
=>
{
beforeEach
(
done
=>
{
beforeEach
(
done
=>
{
createComponent
(
requiredProps
);
createComponent
(
{
...
requiredProps
}
);
setTimeout
(()
=>
{
setTimeout
(()
=>
{
done
();
done
();
...
@@ -141,7 +162,7 @@ describe('ImageDiffViewer', () => {
...
@@ -141,7 +162,7 @@ describe('ImageDiffViewer', () => {
describe
(
'
onionSkin
'
,
()
=>
{
describe
(
'
onionSkin
'
,
()
=>
{
beforeEach
(
done
=>
{
beforeEach
(
done
=>
{
createComponent
(
requiredProps
);
createComponent
(
{
...
requiredProps
}
);
setTimeout
(()
=>
{
setTimeout
(()
=>
{
done
();
done
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment