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
01c22aba
Commit
01c22aba
authored
Jul 30, 2020
by
Natalia Tepluhina
Committed by
Andrew Fontaine
Jul 30, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Resolve "Pasting an image into a comment still uploades a design"
parent
1836a5c8
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
47 additions
and
29 deletions
+47
-29
app/assets/javascripts/design_management/pages/index.vue
app/assets/javascripts/design_management/pages/index.vue
+0
-1
changelogs/unreleased/232980-pasting-an-image-into-a-comment-still-uploades-a-design.yml
...sting-an-image-into-a-comment-still-uploades-a-design.yml
+5
-0
spec/frontend/design_management/pages/index_spec.js
spec/frontend/design_management/pages/index_spec.js
+42
-28
No files found.
app/assets/javascripts/design_management/pages/index.vue
View file @
01c22aba
...
...
@@ -106,7 +106,6 @@ export default {
},
},
mounted
()
{
this
.
toggleOnPasteListener
(
this
.
$route
.
name
);
if
(
this
.
$route
.
path
===
'
/designs
'
)
{
this
.
$el
.
scrollIntoView
();
}
...
...
changelogs/unreleased/232980-pasting-an-image-into-a-comment-still-uploades-a-design.yml
0 → 100644
View file @
01c22aba
---
title
:
Resolve Pasting an image into a comment still uploades a design
merge_request
:
38280
author
:
type
:
fixed
spec/frontend/design_management/pages/index_spec.js
View file @
01c22aba
...
...
@@ -72,6 +72,7 @@ describe('Design management index page', () => {
const
dropzoneClasses
=
()
=>
findDropzone
().
classes
();
const
findDropzoneWrapper
=
()
=>
wrapper
.
find
(
'
[data-testid="design-dropzone-wrapper"]
'
);
const
findFirstDropzoneWithDesign
=
()
=>
wrapper
.
findAll
(
DesignDropzone
).
at
(
1
);
const
findDesignsWrapper
=
()
=>
wrapper
.
find
(
'
[data-testid="designs-root"]
'
);
function
createComponent
({
loading
=
false
,
...
...
@@ -508,6 +509,10 @@ describe('Design management index page', () => {
});
event
=
new
Event
(
'
paste
'
);
event
.
clipboardData
=
{
files
:
[{
name
:
'
image.png
'
,
type
:
'
image/png
'
}],
getData
:
()
=>
'
test.png
'
,
};
router
.
replace
({
name
:
DESIGNS_ROUTE_NAME
,
...
...
@@ -517,43 +522,52 @@ describe('Design management index page', () => {
});
});
it
(
'
calls onUploadDesign with valid paste
'
,
()
=>
{
event
.
clipboardData
=
{
files
:
[{
name
:
'
image.png
'
,
type
:
'
image/png
'
}],
getData
:
()
=>
'
test.png
'
,
};
it
(
'
does not call paste event if designs wrapper is not hovered
'
,
()
=>
{
document
.
dispatchEvent
(
event
);
expect
(
wrapper
.
vm
.
onUploadDesign
).
toHaveBeenCalledTimes
(
1
);
expect
(
wrapper
.
vm
.
onUploadDesign
).
toHaveBeenCalledWith
([
new
File
([{
name
:
'
image.png
'
}],
'
test.png
'
),
]);
expect
(
wrapper
.
vm
.
onUploadDesign
).
not
.
toHaveBeenCalled
();
});
it
(
'
renames a design if it has an image.png filename
'
,
()
=>
{
event
.
clipboardData
=
{
files
:
[{
name
:
'
image.png
'
,
type
:
'
image/png
'
}],
getData
:
()
=>
'
image.png
'
,
};
describe
(
'
when designs wrapper is hovered
'
,
()
=>
{
beforeEach
(()
=>
{
findDesignsWrapper
().
trigger
(
'
mouseenter
'
);
});
document
.
dispatchEvent
(
event
);
it
(
'
calls onUploadDesign with valid paste
'
,
()
=>
{
document
.
dispatchEvent
(
event
);
expect
(
wrapper
.
vm
.
onUploadDesign
).
toHaveBeenCalledTimes
(
1
);
expect
(
wrapper
.
vm
.
onUploadDesign
).
toHaveBeenCalledWith
([
new
File
([{
name
:
'
image.png
'
}],
`design_
${
Date
.
now
()}
.png`
),
]);
});
expect
(
wrapper
.
vm
.
onUploadDesign
).
toHaveBeenCalledTimes
(
1
);
expect
(
wrapper
.
vm
.
onUploadDesign
).
toHaveBeenCalledWith
([
new
File
([{
name
:
'
image.png
'
}],
'
test.png
'
),
]);
});
it
(
'
does not call onUploadDesign with invalid paste
'
,
()
=>
{
event
.
clipboardData
=
{
items
:
[{
type
:
'
text/plain
'
},
{
type
:
'
text
'
}],
files
:
[],
};
it
(
'
renames a design if it has an image.png filename
'
,
()
=>
{
document
.
dispatchEvent
(
event
);
document
.
dispatchEvent
(
event
);
expect
(
wrapper
.
vm
.
onUploadDesign
).
toHaveBeenCalledTimes
(
1
);
expect
(
wrapper
.
vm
.
onUploadDesign
).
toHaveBeenCalledWith
([
new
File
([{
name
:
'
image.png
'
}],
`design_
${
Date
.
now
()}
.png`
),
]);
});
expect
(
wrapper
.
vm
.
onUploadDesign
).
not
.
toHaveBeenCalled
();
it
(
'
does not call onUploadDesign with invalid paste
'
,
()
=>
{
event
.
clipboardData
=
{
items
:
[{
type
:
'
text/plain
'
},
{
type
:
'
text
'
}],
files
:
[],
};
document
.
dispatchEvent
(
event
);
expect
(
wrapper
.
vm
.
onUploadDesign
).
not
.
toHaveBeenCalled
();
});
it
(
'
removes onPaste listener after mouseleave event
'
,
async
()
=>
{
findDesignsWrapper
().
trigger
(
'
mouseleave
'
);
document
.
dispatchEvent
(
event
);
expect
(
wrapper
.
vm
.
onUploadDesign
).
not
.
toHaveBeenCalled
();
});
});
});
...
...
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