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
1f435d6b
Commit
1f435d6b
authored
Mar 13, 2020
by
Tom Quirk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test design presentation click drag
- Test isDesignOverflowing - Test click and drag - Test touch events
parent
b22ff8bc
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
129 additions
and
46 deletions
+129
-46
ee/app/assets/javascripts/design_management/components/design_overlay.vue
...vascripts/design_management/components/design_overlay.vue
+2
-5
ee/app/assets/javascripts/design_management/components/design_presentation.vue
...ipts/design_management/components/design_presentation.vue
+0
-3
ee/spec/frontend/design_management/components/design_presentation_spec.js
.../design_management/components/design_presentation_spec.js
+127
-38
No files found.
ee/app/assets/javascripts/design_management/components/design_overlay.vue
View file @
1f435d6b
...
@@ -39,16 +39,13 @@ export default {
...
@@ -39,16 +39,13 @@ export default {
},
},
computed
:
{
computed
:
{
overlayStyle
()
{
overlayStyle
()
{
const
s
tyle
=
{
const
baseS
tyle
=
{
width
:
`
${
this
.
dimensions
.
width
}
px`
,
width
:
`
${
this
.
dimensions
.
width
}
px`
,
height
:
`
${
this
.
dimensions
.
height
}
px`
,
height
:
`
${
this
.
dimensions
.
height
}
px`
,
...
this
.
position
,
...
this
.
position
,
};
};
if
(
this
.
disableCommenting
)
{
return
this
.
disableCommenting
?
Object
.
assign
(
baseStyle
,
{
cursor
:
'
unset
'
})
:
baseStyle
;
style
.
cursor
=
'
unset
'
;
}
return
style
;
},
},
isMovingCurrentComment
()
{
isMovingCurrentComment
()
{
return
Boolean
(
this
.
movingNoteStartPosition
&&
!
this
.
movingNoteStartPosition
.
noteId
);
return
Boolean
(
this
.
movingNoteStartPosition
&&
!
this
.
movingNoteStartPosition
.
noteId
);
...
...
ee/app/assets/javascripts/design_management/components/design_presentation.vue
View file @
1f435d6b
...
@@ -46,7 +46,6 @@ export default {
...
@@ -46,7 +46,6 @@ export default {
height
:
0
,
height
:
0
,
},
},
initialLoad
:
true
,
initialLoad
:
true
,
mousedown
:
false
,
lastDragPosition
:
null
,
lastDragPosition
:
null
,
isDraggingDesign
:
false
,
isDraggingDesign
:
false
,
};
};
...
@@ -234,7 +233,6 @@ export default {
...
@@ -234,7 +233,6 @@ export default {
const
{
scrollLeft
,
scrollTop
}
=
presentationViewport
;
const
{
scrollLeft
,
scrollTop
}
=
presentationViewport
;
const
deltaX
=
this
.
lastDragPosition
.
x
-
clientX
;
const
deltaX
=
this
.
lastDragPosition
.
x
-
clientX
;
const
deltaY
=
this
.
lastDragPosition
.
y
-
clientY
;
const
deltaY
=
this
.
lastDragPosition
.
y
-
clientY
;
presentationViewport
.
scrollTo
(
scrollLeft
+
deltaX
,
scrollTop
+
deltaY
);
presentationViewport
.
scrollTo
(
scrollLeft
+
deltaX
,
scrollTop
+
deltaY
);
this
.
lastDragPosition
=
{
this
.
lastDragPosition
=
{
...
@@ -244,7 +242,6 @@ export default {
...
@@ -244,7 +242,6 @@ export default {
},
},
onPresentationMouseup
()
{
onPresentationMouseup
()
{
this
.
lastDragPosition
=
null
;
this
.
lastDragPosition
=
null
;
this
.
mousedown
=
null
;
this
.
isDraggingDesign
=
false
;
this
.
isDraggingDesign
=
false
;
},
},
isDesignOverflowing
()
{
isDesignOverflowing
()
{
...
...
ee/spec/frontend/design_management/components/design_presentation_spec.js
View file @
1f435d6b
...
@@ -31,6 +31,58 @@ describe('Design management design presentation component', () => {
...
@@ -31,6 +31,58 @@ describe('Design management design presentation component', () => {
wrapper
.
setData
(
data
);
wrapper
.
setData
(
data
);
}
}
/**
* Spy on $refs and mock given values
* @param {Object} viewportDimensions {width, height}
* @param {Object} childDimensions {width, height}
* @param {Float} scrollTopPerc 0 < x < 1
* @param {Float} scrollLeftPerc 0 < x < 1
*/
function
mockRefDimensions
(
ref
,
viewportDimensions
,
childDimensions
,
scrollTopPerc
,
scrollLeftPerc
,
)
{
jest
.
spyOn
(
ref
,
'
scrollWidth
'
,
'
get
'
).
mockReturnValue
(
childDimensions
.
width
);
jest
.
spyOn
(
ref
,
'
scrollHeight
'
,
'
get
'
).
mockReturnValue
(
childDimensions
.
height
);
jest
.
spyOn
(
ref
,
'
offsetWidth
'
,
'
get
'
).
mockReturnValue
(
viewportDimensions
.
width
);
jest
.
spyOn
(
ref
,
'
offsetHeight
'
,
'
get
'
).
mockReturnValue
(
viewportDimensions
.
height
);
jest
.
spyOn
(
ref
,
'
scrollLeft
'
,
'
get
'
)
.
mockReturnValue
((
childDimensions
.
width
-
viewportDimensions
.
width
)
*
scrollLeftPerc
);
jest
.
spyOn
(
ref
,
'
scrollTop
'
,
'
get
'
)
.
mockReturnValue
((
childDimensions
.
height
-
viewportDimensions
.
height
)
*
scrollTopPerc
);
}
function
clickDragExplore
(
startCoords
,
endCoords
,
{
useTouchEvents
}
=
{})
{
const
event
=
useTouchEvents
?
{
mousedown
:
'
touchstart
'
,
mousemove
:
'
touchmove
'
,
mouseup
:
'
touchend
'
,
}
:
{
mousedown
:
'
mousedown
'
,
mousemove
:
'
mousemove
'
,
mouseup
:
'
mouseup
'
,
};
wrapper
.
trigger
(
event
.
mousedown
,
{
clientX
:
startCoords
.
clientX
,
clientY
:
startCoords
.
clientY
,
});
return
wrapper
.
vm
.
$nextTick
().
then
(()
=>
{
wrapper
.
trigger
(
event
.
mousemove
,
{
clientX
:
endCoords
.
clientX
,
clientY
:
endCoords
.
clientY
,
});
return
wrapper
.
vm
.
$nextTick
();
});
}
afterEach
(()
=>
{
afterEach
(()
=>
{
wrapper
.
destroy
();
wrapper
.
destroy
();
});
});
...
@@ -190,39 +242,6 @@ describe('Design management design presentation component', () => {
...
@@ -190,39 +242,6 @@ describe('Design management design presentation component', () => {
});
});
describe
(
'
getViewportCenter
'
,
()
=>
{
describe
(
'
getViewportCenter
'
,
()
=>
{
/**
* Spy on $refs.presentationViewport with given values
* @param {Object} viewportDimensions {width, height}
* @param {Object} childDimensions {width, height}
* @param {Float} scrollTopPerc 0 < x < 1
* @param {Float} scrollLeftPerc 0 < x < 1
*/
const
spyOnPresentationViewport
=
(
viewportDimensions
,
childDimensions
,
scrollTopPerc
,
scrollLeftPerc
,
)
=>
{
jest
.
spyOn
(
wrapper
.
vm
.
$refs
.
presentationViewport
,
'
scrollWidth
'
,
'
get
'
)
.
mockReturnValue
(
childDimensions
.
width
);
jest
.
spyOn
(
wrapper
.
vm
.
$refs
.
presentationViewport
,
'
scrollHeight
'
,
'
get
'
)
.
mockReturnValue
(
childDimensions
.
height
);
jest
.
spyOn
(
wrapper
.
vm
.
$refs
.
presentationViewport
,
'
offsetWidth
'
,
'
get
'
)
.
mockReturnValue
(
viewportDimensions
.
width
);
jest
.
spyOn
(
wrapper
.
vm
.
$refs
.
presentationViewport
,
'
offsetHeight
'
,
'
get
'
)
.
mockReturnValue
(
viewportDimensions
.
height
);
jest
.
spyOn
(
wrapper
.
vm
.
$refs
.
presentationViewport
,
'
scrollLeft
'
,
'
get
'
)
.
mockReturnValue
((
childDimensions
.
width
-
viewportDimensions
.
width
)
*
scrollLeftPerc
);
jest
.
spyOn
(
wrapper
.
vm
.
$refs
.
presentationViewport
,
'
scrollTop
'
,
'
get
'
)
.
mockReturnValue
((
childDimensions
.
height
-
viewportDimensions
.
height
)
*
scrollTopPerc
);
};
beforeEach
(()
=>
{
beforeEach
(()
=>
{
createComponent
(
createComponent
(
{
{
...
@@ -234,7 +253,13 @@ describe('Design management design presentation component', () => {
...
@@ -234,7 +253,13 @@ describe('Design management design presentation component', () => {
});
});
it
(
'
calculate center correctly with no scroll
'
,
()
=>
{
it
(
'
calculate center correctly with no scroll
'
,
()
=>
{
spyOnPresentationViewport
({
width
:
10
,
height
:
10
},
{
width
:
20
,
height
:
20
},
0
,
0
);
mockRefDimensions
(
wrapper
.
vm
.
$refs
.
presentationViewport
,
{
width
:
10
,
height
:
10
},
{
width
:
20
,
height
:
20
},
0
,
0
,
);
expect
(
wrapper
.
vm
.
getViewportCenter
()).
toEqual
({
expect
(
wrapper
.
vm
.
getViewportCenter
()).
toEqual
({
x
:
5
,
x
:
5
,
...
@@ -243,7 +268,13 @@ describe('Design management design presentation component', () => {
...
@@ -243,7 +268,13 @@ describe('Design management design presentation component', () => {
});
});
it
(
'
calculate center correctly with some scroll
'
,
()
=>
{
it
(
'
calculate center correctly with some scroll
'
,
()
=>
{
spyOnPresentationViewport
({
width
:
10
,
height
:
10
},
{
width
:
20
,
height
:
20
},
0.5
,
0.5
);
mockRefDimensions
(
wrapper
.
vm
.
$refs
.
presentationViewport
,
{
width
:
10
,
height
:
10
},
{
width
:
20
,
height
:
20
},
0.5
,
0.5
,
);
expect
(
wrapper
.
vm
.
getViewportCenter
()).
toEqual
({
expect
(
wrapper
.
vm
.
getViewportCenter
()).
toEqual
({
x
:
10
,
x
:
10
,
...
@@ -252,7 +283,13 @@ describe('Design management design presentation component', () => {
...
@@ -252,7 +283,13 @@ describe('Design management design presentation component', () => {
});
});
it
(
'
Returns default case if no overflow (scrollWidth==offsetWidth, etc.)
'
,
()
=>
{
it
(
'
Returns default case if no overflow (scrollWidth==offsetWidth, etc.)
'
,
()
=>
{
spyOnPresentationViewport
({
width
:
20
,
height
:
20
},
{
width
:
20
,
height
:
20
},
0.5
,
0.5
);
mockRefDimensions
(
wrapper
.
vm
.
$refs
.
presentationViewport
,
{
width
:
20
,
height
:
20
},
{
width
:
20
,
height
:
20
},
0.5
,
0.5
,
);
expect
(
wrapper
.
vm
.
getViewportCenter
()).
toEqual
({
expect
(
wrapper
.
vm
.
getViewportCenter
()).
toEqual
({
x
:
10
,
x
:
10
,
...
@@ -262,7 +299,7 @@ describe('Design management design presentation component', () => {
...
@@ -262,7 +299,7 @@ describe('Design management design presentation component', () => {
});
});
describe
(
'
scaleZoomFocalPoint
'
,
()
=>
{
describe
(
'
scaleZoomFocalPoint
'
,
()
=>
{
it
(
'
scale
ZoomFocalPoint scale
s focal point correctly when zooming in
'
,
()
=>
{
it
(
'
scales focal point correctly when zooming in
'
,
()
=>
{
createComponent
(
createComponent
(
{
{
image
:
'
test.jpg
'
,
image
:
'
test.jpg
'
,
...
@@ -288,7 +325,7 @@ describe('Design management design presentation component', () => {
...
@@ -288,7 +325,7 @@ describe('Design management design presentation component', () => {
});
});
});
});
it
(
'
scale
ZoomFocalPoint scale
s focal point correctly when zooming out
'
,
()
=>
{
it
(
'
scales focal point correctly when zooming out
'
,
()
=>
{
createComponent
(
createComponent
(
{
{
image
:
'
test.jpg
'
,
image
:
'
test.jpg
'
,
...
@@ -346,4 +383,56 @@ describe('Design management design presentation component', () => {
...
@@ -346,4 +383,56 @@ describe('Design management design presentation component', () => {
});
});
});
});
});
});
describe
(
'
isDesignOverflowing
'
,
()
=>
{
it
.
each
`
scenario | width | height | isOverflowing
${
'
width overflows
'
}
|
${
101
}
|
${
100
}
|
${
true
}
${
'
height overflows
'
}
|
${
100
}
|
${
101
}
|
${
true
}
${
'
width and height overflows
'
}
|
${
200
}
|
${
200
}
|
${
true
}
${
'
is smaller than container
'
}
|
${
100
}
|
${
100
}
|
${
false
}
`
(
'
returns $isOverflowing when design $scenario
'
,
({
width
,
height
,
isOverflowing
})
=>
{
createComponent
();
mockRefDimensions
(
wrapper
.
vm
.
$refs
.
presentationContainer
,
{
width
:
100
,
height
:
100
},
{
width
,
height
},
);
expect
(
wrapper
.
vm
.
isDesignOverflowing
()).
toBe
(
isOverflowing
);
});
});
describe
(
'
when clicking and dragging
'
,
()
=>
{
it
.
each
`
description | useTouchEvents
${
'
with touch events
'
}
|
${
true
}
${
'
without touch events
'
}
|
${
false
}
`
(
'
calls scrollTo with correct arguments $description
'
,
({
useTouchEvents
})
=>
{
createComponent
(
{
image
:
'
test.jpg
'
,
imageName
:
'
test
'
,
},
mockOverlayData
,
);
mockRefDimensions
(
wrapper
.
vm
.
$refs
.
presentationViewport
,
{
width
:
10
,
height
:
10
},
{
width
:
20
,
height
:
20
},
0
,
0
,
);
wrapper
.
element
.
scrollTo
=
jest
.
fn
();
wrapper
.
vm
.
isDesignOverflowing
=
jest
.
fn
().
mockReturnValue
(
true
);
return
clickDragExplore
(
{
clientX
:
0
,
clientY
:
0
},
{
clientX
:
10
,
clientY
:
10
},
{
useTouchEvents
},
).
then
(()
=>
{
expect
(
wrapper
.
element
.
scrollTo
).
toHaveBeenCalledTimes
(
1
);
expect
(
wrapper
.
element
.
scrollTo
).
toHaveBeenCalledWith
(
-
10
,
-
10
);
});
});
});
});
});
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