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
feaae37e
Commit
feaae37e
authored
Aug 27, 2020
by
Tom Quirk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test active discussion is updated on mount
parent
beb4e01c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
89 additions
and
55 deletions
+89
-55
app/assets/javascripts/design_management/pages/design/index.vue
...sets/javascripts/design_management/pages/design/index.vue
+10
-4
spec/frontend/design_management/pages/design/__snapshots__/index_spec.js.snap
..._management/pages/design/__snapshots__/index_spec.js.snap
+2
-2
spec/frontend/design_management/pages/design/index_spec.js
spec/frontend/design_management/pages/design/index_spec.js
+77
-49
No files found.
app/assets/javascripts/design_management/pages/design/index.vue
View file @
feaae37e
...
...
@@ -147,10 +147,11 @@ export default {
mounted
()
{
Mousetrap
.
bind
(
'
esc
'
,
this
.
closeDesign
);
this
.
trackEvent
();
// We need to reset the active discussion when opening a new design
const
noteId
=
parseDesignRouteHash
(
this
.
$route
.
hash
);
const
diffNoteGid
=
noteId
?
toDiffNoteGid
(
noteId
)
:
undefined
;
return
this
.
updateActiveDiscussion
(
diffNoteGid
);
// Set active discussion immediately.
// This will ensure that, if a note is specified in the URL hash,
// the browser will scroll to, and highlight, the note in the UI
this
.
updateActiveDiscussionFromUrl
();
},
beforeDestroy
()
{
Mousetrap
.
unbind
(
'
esc
'
,
this
.
closeDesign
);
...
...
@@ -279,6 +280,11 @@ export default {
},
});
},
updateActiveDiscussionFromUrl
()
{
const
noteId
=
parseDesignRouteHash
(
this
.
$route
.
hash
);
const
diffNoteGid
=
noteId
?
toDiffNoteGid
(
noteId
)
:
undefined
;
return
this
.
updateActiveDiscussion
(
diffNoteGid
);
},
toggleResolvedComments
()
{
this
.
resolvedDiscussionsExpanded
=
!
this
.
resolvedDiscussionsExpanded
;
},
...
...
spec/frontend/design_management/pages/design/__snapshots__/index_spec.js.snap
View file @
feaae37e
...
...
@@ -57,7 +57,7 @@ exports[`Design management design index page renders design index 1`] = `
<design-discussion-stub
data-testid="unresolved-discussion"
designid="
test
"
designid="
design-id
"
discussion="[object Object]"
discussionwithopenform=""
markdownpreviewpath="/project-path/preview_markdown?target_type=Issue"
...
...
@@ -105,7 +105,7 @@ exports[`Design management design index page renders design index 1`] = `
>
<design-discussion-stub
data-testid="resolved-discussion"
designid="
test
"
designid="
design-id
"
discussion="[object Object]"
discussionwithopenform=""
markdownpreviewpath="/project-path/preview_markdown?target_type=Issue"
...
...
spec/frontend/design_management/pages/design/index_spec.js
View file @
feaae37e
...
...
@@ -7,18 +7,19 @@ import DesignIndex from '~/design_management/pages/design/index.vue';
import
DesignSidebar
from
'
~/design_management/components/design_sidebar.vue
'
;
import
DesignPresentation
from
'
~/design_management/components/design_presentation.vue
'
;
import
createImageDiffNoteMutation
from
'
~/design_management/graphql/mutations/create_image_diff_note.mutation.graphql
'
;
import
design
from
'
../../mock_data/design
'
;
import
mockResponseWithDesigns
from
'
../../mock_data/designs
'
;
import
mockResponseNoDesigns
from
'
../../mock_data/no_designs
'
;
import
mockAllVersions
from
'
../../mock_data/all_versions
'
;
import
updateActiveDiscussion
from
'
~/design_management/graphql/mutations/update_active_discussion.mutation.graphql
'
;
import
{
DESIGN_NOT_FOUND_ERROR
,
DESIGN_VERSION_NOT_EXIST_ERROR
,
}
from
'
~/design_management/utils/error_messages
'
;
import
{
DESIGNS_ROUTE_NAME
}
from
'
~/design_management/router/constants
'
;
import
{
DESIGNS_ROUTE_NAME
,
DESIGN_ROUTE_NAME
}
from
'
~/design_management/router/constants
'
;
import
createRouter
from
'
~/design_management/router
'
;
import
*
as
utils
from
'
~/design_management/utils/design_management_utils
'
;
import
{
DESIGN_DETAIL_LAYOUT_CLASSLIST
}
from
'
~/design_management/constants
'
;
import
design
from
'
../../mock_data/design
'
;
import
mockResponseWithDesigns
from
'
../../mock_data/designs
'
;
import
mockResponseNoDesigns
from
'
../../mock_data/no_designs
'
;
import
mockAllVersions
from
'
../../mock_data/all_versions
'
;
jest
.
mock
(
'
~/flash
'
);
jest
.
mock
(
'
mousetrap
'
,
()
=>
({
...
...
@@ -34,6 +35,12 @@ const DesignReplyForm = {
focusInput
,
},
};
const
mockDesignNoDiscussions
=
{
...
design
,
discussions
:
{
nodes
:
[],
},
};
const
localVue
=
createLocalVue
();
localVue
.
use
(
VueRouter
);
...
...
@@ -75,7 +82,7 @@ describe('Design management design index page', () => {
const
findSidebar
=
()
=>
wrapper
.
find
(
DesignSidebar
);
const
findDesignPresentation
=
()
=>
wrapper
.
find
(
DesignPresentation
);
function
createComponent
(
loading
=
false
,
data
=
{})
{
function
createComponent
(
{
loading
=
false
}
=
{},
{
data
=
{},
intialRouteOptions
=
{}
}
=
{})
{
const
$apollo
=
{
queries
:
{
design
:
{
...
...
@@ -87,6 +94,8 @@ describe('Design management design index page', () => {
router
=
createRouter
();
router
.
push
({
name
:
DESIGN_ROUTE_NAME
,
params
:
{
id
:
design
.
id
},
...
intialRouteOptions
});
wrapper
=
shallowMount
(
DesignIndex
,
{
propsData
:
{
id
:
'
1
'
},
mocks
:
{
$apollo
},
...
...
@@ -126,29 +135,28 @@ describe('Design management design index page', () => {
},
};
jest
.
spyOn
(
utils
,
'
getPageLayoutElement
'
).
mockReturnValue
(
mockEl
);
createComponent
(
true
);
createComponent
(
{
loading
:
true
}
);
wrapper
.
vm
.
$router
.
push
(
'
/designs/test
'
);
expect
(
mockEl
.
classList
.
add
).
toHaveBeenCalledTimes
(
1
);
expect
(
mockEl
.
classList
.
add
).
toHaveBeenCalledWith
(...
DESIGN_DETAIL_LAYOUT_CLASSLIST
);
});
});
it
(
'
sets loading state
'
,
()
=>
{
createComponent
(
true
);
createComponent
(
{
loading
:
true
}
);
expect
(
wrapper
.
element
).
toMatchSnapshot
();
});
it
(
'
renders design index
'
,
()
=>
{
createComponent
(
false
,
{
design
});
createComponent
(
{
loading
:
false
},
{
data
:
{
design
}
});
expect
(
wrapper
.
element
).
toMatchSnapshot
();
expect
(
wrapper
.
find
(
GlAlert
).
exists
()).
toBe
(
false
);
});
it
(
'
passes correct props to sidebar component
'
,
()
=>
{
createComponent
(
false
,
{
design
});
createComponent
(
{
loading
:
false
},
{
data
:
{
design
}
});
expect
(
findSidebar
().
props
()).
toEqual
({
design
,
...
...
@@ -158,14 +166,14 @@ describe('Design management design index page', () => {
});
it
(
'
opens a new discussion form
'
,
()
=>
{
createComponent
(
false
,
{
design
:
{
...
design
,
d
iscussions
:
{
nodes
:
[]
,
createComponent
(
{
loading
:
false
},
{
d
ata
:
{
design
,
},
},
}
);
);
findDesignPresentation
().
vm
.
$emit
(
'
openCommentForm
'
,
{
x
:
0
,
y
:
0
});
...
...
@@ -175,15 +183,15 @@ describe('Design management design index page', () => {
});
it
(
'
keeps new discussion form focused
'
,
()
=>
{
createComponent
(
false
,
{
design
:
{
...
design
,
discussions
:
{
nodes
:
[],
createComponent
(
{
loading
:
false
},
{
data
:
{
design
,
annotationCoordinates
,
},
},
annotationCoordinates
,
});
);
findDesignPresentation
().
vm
.
$emit
(
'
openCommentForm
'
,
{
x
:
10
,
y
:
10
});
...
...
@@ -191,16 +199,16 @@ describe('Design management design index page', () => {
});
it
(
'
sends a mutation on submitting form and closes form
'
,
()
=>
{
createComponent
(
false
,
{
design
:
{
...
design
,
discussions
:
{
nodes
:
[],
createComponent
(
{
loading
:
false
},
{
data
:
{
design
,
annotationCoordinates
,
comment
:
newComment
,
},
},
annotationCoordinates
,
comment
:
newComment
,
});
);
findDiscussionForm
().
vm
.
$emit
(
'
submitForm
'
);
expect
(
mutate
).
toHaveBeenCalledWith
(
createDiscussionMutationVariables
);
...
...
@@ -216,16 +224,16 @@ describe('Design management design index page', () => {
});
it
(
'
closes the form and clears the comment on canceling form
'
,
()
=>
{
createComponent
(
false
,
{
design
:
{
...
design
,
discussions
:
{
nodes
:
[],
createComponent
(
{
loading
:
false
},
{
data
:
{
design
,
annotationCoordinates
,
comment
:
newComment
,
},
},
annotationCoordinates
,
comment
:
newComment
,
});
);
findDiscussionForm
().
vm
.
$emit
(
'
cancelForm
'
);
...
...
@@ -238,15 +246,15 @@ describe('Design management design index page', () => {
describe
(
'
with error
'
,
()
=>
{
beforeEach
(()
=>
{
createComponent
(
false
,
{
design
:
{
...
design
,
discussions
:
{
nodes
:
[],
createComponent
(
{
loading
:
false
},
{
data
:
{
design
:
mockDesignNoDiscussions
,
errorMessage
:
'
woops
'
,
},
},
errorMessage
:
'
woops
'
,
});
);
});
it
(
'
GlAlert is rendered in correct position with correct content
'
,
()
=>
{
...
...
@@ -257,7 +265,7 @@ describe('Design management design index page', () => {
describe
(
'
onDesignQueryResult
'
,
()
=>
{
describe
(
'
with no designs
'
,
()
=>
{
it
(
'
redirects to /designs
'
,
()
=>
{
createComponent
(
true
);
createComponent
(
{
loading
:
true
}
);
router
.
push
=
jest
.
fn
();
wrapper
.
vm
.
onDesignQueryResult
({
data
:
mockResponseNoDesigns
,
loading
:
false
});
...
...
@@ -272,7 +280,7 @@ describe('Design management design index page', () => {
describe
(
'
when no design exists for given version
'
,
()
=>
{
it
(
'
redirects to /designs
'
,
()
=>
{
createComponent
(
true
);
createComponent
(
{
loading
:
true
}
);
wrapper
.
setData
({
allVersions
:
mockAllVersions
,
});
...
...
@@ -291,4 +299,24 @@ describe('Design management design index page', () => {
});
});
});
describe
(
'
when hash present in current route
'
,
()
=>
{
it
(
'
calls updateActiveDiscussion mutation
'
,
()
=>
{
createComponent
(
{
loading
:
false
},
{
data
:
{
design
,
},
intialRouteOptions
:
{
hash
:
'
#note_123
'
},
},
);
expect
(
mutate
).
toHaveBeenCalledTimes
(
1
);
expect
(
mutate
).
toHaveBeenCalledWith
({
mutation
:
updateActiveDiscussion
,
variables
:
{
id
:
'
gid://gitlab/DiffNote/123
'
,
source
:
'
discussion
'
},
});
});
});
});
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