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
3cd8e1ff
Commit
3cd8e1ff
authored
Apr 07, 2021
by
Florie Guibert
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Epic boards sidebar - Edit epic title
Add ability to edit epic title from epic board sidebar
parent
09580cb6
Changes
12
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
126 additions
and
71 deletions
+126
-71
app/assets/javascripts/boards/components/board_content_sidebar.vue
...s/javascripts/boards/components/board_content_sidebar.vue
+3
-3
app/assets/javascripts/boards/components/sidebar/board_sidebar_title.vue
...scripts/boards/components/sidebar/board_sidebar_title.vue
+24
-24
app/assets/javascripts/boards/constants.js
app/assets/javascripts/boards/constants.js
+11
-0
app/assets/javascripts/boards/graphql/issue_set_title.mutation.graphql
...vascripts/boards/graphql/issue_set_title.mutation.graphql
+1
-1
app/assets/javascripts/boards/stores/actions.js
app/assets/javascripts/boards/stores/actions.js
+12
-8
app/assets/javascripts/sidebar/queries/update_epic_title.mutation.graphql
...cripts/sidebar/queries/update_epic_title.mutation.graphql
+8
-0
ee/app/assets/javascripts/boards/components/epic_board_content_sidebar.vue
...ascripts/boards/components/epic_board_content_sidebar.vue
+3
-0
ee/spec/features/epic_boards/epic_boards_sidebar_spec.rb
ee/spec/features/epic_boards/epic_boards_sidebar_spec.rb
+31
-0
locale/gitlab.pot
locale/gitlab.pot
+2
-8
spec/frontend/boards/components/board_content_sidebar_spec.js
.../frontend/boards/components/board_content_sidebar_spec.js
+3
-3
spec/frontend/boards/components/sidebar/board_sidebar_title_spec.js
...end/boards/components/sidebar/board_sidebar_title_spec.js
+18
-18
spec/frontend/boards/stores/actions_spec.js
spec/frontend/boards/stores/actions_spec.js
+10
-6
No files found.
app/assets/javascripts/boards/components/board_content_sidebar.vue
View file @
3cd8e1ff
...
...
@@ -2,11 +2,11 @@
import
{
GlDrawer
}
from
'
@gitlab/ui
'
;
import
{
mapState
,
mapActions
,
mapGetters
}
from
'
vuex
'
;
import
BoardSidebarDueDate
from
'
~/boards/components/sidebar/board_sidebar_due_date.vue
'
;
import
BoardSidebarIssueTitle
from
'
~/boards/components/sidebar/board_sidebar_issue_title.vue
'
;
import
BoardSidebarLabelsSelect
from
'
~/boards/components/sidebar/board_sidebar_labels_select.vue
'
;
import
BoardSidebarMilestoneSelect
from
'
~/boards/components/sidebar/board_sidebar_milestone_select.vue
'
;
import
BoardSidebarSubscription
from
'
~/boards/components/sidebar/board_sidebar_subscription.vue
'
;
import
BoardSidebarTimeTracker
from
'
~/boards/components/sidebar/board_sidebar_time_tracker.vue
'
;
import
BoardSidebarTitle
from
'
~/boards/components/sidebar/board_sidebar_title.vue
'
;
import
{
ISSUABLE
}
from
'
~/boards/constants
'
;
import
{
contentTop
}
from
'
~/lib/utils/common_utils
'
;
import
SidebarAssigneesWidget
from
'
~/sidebar/components/assignees/sidebar_assignees_widget.vue
'
;
...
...
@@ -16,7 +16,7 @@ export default {
headerHeight
:
`
${
contentTop
()}
px`
,
components
:
{
GlDrawer
,
BoardSidebar
Issue
Title
,
BoardSidebarTitle
,
SidebarAssigneesWidget
,
BoardSidebarTimeTracker
,
BoardSidebarLabelsSelect
,
...
...
@@ -67,7 +67,7 @@ export default {
>
<template
#header
>
{{
__
(
'
Issue details
'
)
}}
</
template
>
<
template
#default
>
<board-sidebar-
issue-
title
/>
<board-sidebar-title
/>
<sidebar-assignees-widget
:iid=
"activeBoardItem.iid"
:full-path=
"fullPath"
...
...
app/assets/javascripts/boards/components/sidebar/board_sidebar_
issue_
title.vue
→
app/assets/javascripts/boards/components/sidebar/board_sidebar_title.vue
View file @
3cd8e1ff
...
...
@@ -27,12 +27,12 @@ export default {
};
},
computed
:
{
...
mapGetters
({
i
ssue
:
'
activeBoardItem
'
}),
...
mapGetters
({
i
tem
:
'
activeBoardItem
'
}),
pendingChangesStorageKey
()
{
return
this
.
getPendingChangesKey
(
this
.
i
ssue
);
return
this
.
getPendingChangesKey
(
this
.
i
tem
);
},
projectPath
()
{
const
referencePath
=
this
.
i
ssue
.
referencePath
||
''
;
const
referencePath
=
this
.
i
tem
.
referencePath
||
''
;
return
referencePath
.
slice
(
0
,
referencePath
.
indexOf
(
'
#
'
));
},
validationState
()
{
...
...
@@ -40,29 +40,29 @@ export default {
},
},
watch
:
{
i
ssue
:
{
handler
(
updatedI
ssue
,
formerIssue
)
{
if
(
formerI
ssue
?.
title
!==
this
.
title
)
{
localStorage
.
setItem
(
this
.
getPendingChangesKey
(
formerI
ssue
),
this
.
title
);
i
tem
:
{
handler
(
updatedI
tem
,
formerItem
)
{
if
(
formerI
tem
?.
title
!==
this
.
title
)
{
localStorage
.
setItem
(
this
.
getPendingChangesKey
(
formerI
tem
),
this
.
title
);
}
this
.
title
=
updatedI
ssue
.
title
;
this
.
title
=
updatedI
tem
.
title
;
this
.
setPendingState
();
},
immediate
:
true
,
},
},
methods
:
{
...
mapActions
([
'
setActiveI
ssue
Title
'
]),
getPendingChangesKey
(
i
ssue
)
{
if
(
!
i
ssue
)
{
...
mapActions
([
'
setActiveI
tem
Title
'
]),
getPendingChangesKey
(
i
tem
)
{
if
(
!
i
tem
)
{
return
''
;
}
return
joinPaths
(
window
.
location
.
pathname
.
slice
(
1
),
String
(
i
ssue
.
id
),
'
i
ssue
-title-pending-changes
'
,
String
(
i
tem
.
id
),
'
i
tem
-title-pending-changes
'
,
);
},
async
setPendingState
()
{
...
...
@@ -78,7 +78,7 @@ export default {
}
},
cancel
()
{
this
.
title
=
this
.
i
ssue
.
title
;
this
.
title
=
this
.
i
tem
.
title
;
this
.
$refs
.
sidebarItem
.
collapse
();
this
.
showChangesAlert
=
false
;
localStorage
.
removeItem
(
this
.
pendingChangesStorageKey
);
...
...
@@ -86,24 +86,24 @@ export default {
async
setTitle
()
{
this
.
$refs
.
sidebarItem
.
collapse
();
if
(
!
this
.
title
||
this
.
title
===
this
.
i
ssue
.
title
)
{
if
(
!
this
.
title
||
this
.
title
===
this
.
i
tem
.
title
)
{
return
;
}
try
{
this
.
loading
=
true
;
await
this
.
setActiveI
ssue
Title
({
title
:
this
.
title
,
projectPath
:
this
.
projectPath
});
await
this
.
setActiveI
tem
Title
({
title
:
this
.
title
,
projectPath
:
this
.
projectPath
});
localStorage
.
removeItem
(
this
.
pendingChangesStorageKey
);
this
.
showChangesAlert
=
false
;
}
catch
(
e
)
{
this
.
title
=
this
.
i
ssue
.
title
;
this
.
title
=
this
.
i
tem
.
title
;
createFlash
({
message
:
this
.
$options
.
i18n
.
updateTitleError
});
}
finally
{
this
.
loading
=
false
;
}
},
handleOffClick
()
{
if
(
this
.
title
!==
this
.
i
ssue
.
title
)
{
if
(
this
.
title
!==
this
.
i
tem
.
title
)
{
this
.
showChangesAlert
=
true
;
localStorage
.
setItem
(
this
.
pendingChangesStorageKey
,
this
.
title
);
}
else
{
...
...
@@ -112,11 +112,11 @@ export default {
},
},
i18n
:
{
issueTitlePlaceholder
:
__
(
'
Issue t
itle
'
),
titlePlaceholder
:
__
(
'
T
itle
'
),
submitButton
:
__
(
'
Save changes
'
),
cancelButton
:
__
(
'
Cancel
'
),
updateTitleError
:
__
(
'
An error occurred when updating the
issue
title
'
),
invalidFeedback
:
__
(
'
A
n issue
title is required
'
),
updateTitleError
:
__
(
'
An error occurred when updating the title
'
),
invalidFeedback
:
__
(
'
A title is required
'
),
reviewYourChanges
:
__
(
'
Changes to the title have not been saved
'
),
},
};
...
...
@@ -131,10 +131,10 @@ export default {
@
off-click=
"handleOffClick"
>
<template
#title
>
<span
class=
"gl-font-weight-bold"
data-testid=
"i
ssue-title"
>
{{
issue
.
title
}}
</span>
<span
class=
"gl-font-weight-bold"
data-testid=
"i
tem-title"
>
{{
item
.
title
}}
</span>
</
template
>
<
template
#collapsed
>
<span
class=
"gl-text-gray-800"
>
{{
i
ssue
.
referencePath
}}
</span>
<span
class=
"gl-text-gray-800"
>
{{
i
tem
.
referencePath
}}
</span>
</
template
>
<gl-alert
v-if=
"showChangesAlert"
variant=
"warning"
class=
"gl-mb-5"
:dismissible=
"false"
>
{{ $options.i18n.reviewYourChanges }}
...
...
@@ -144,7 +144,7 @@ export default {
<gl-form-input
v-model=
"title"
v-autofocusonshow
:placeholder=
"$options.i18n.
issueT
itlePlaceholder"
:placeholder=
"$options.i18n.
t
itlePlaceholder"
:state=
"validationState"
/>
</gl-form-group>
...
...
app/assets/javascripts/boards/constants.js
View file @
3cd8e1ff
import
{
__
}
from
'
~/locale
'
;
import
updateEpicTitleMutation
from
'
~/sidebar/queries/update_epic_title.mutation.graphql
'
;
import
boardBlockingIssuesQuery
from
'
./graphql/board_blocking_issues.query.graphql
'
;
import
issueSetTitleMutation
from
'
./graphql/issue_set_title.mutation.graphql
'
;
export
const
issuableTypes
=
{
issue
:
'
issue
'
,
...
...
@@ -52,3 +54,12 @@ export const blockingIssuablesQueries = {
query
:
boardBlockingIssuesQuery
,
},
};
export
const
titleQueries
=
{
[
issuableTypes
.
issue
]:
{
mutation
:
issueSetTitleMutation
,
},
[
issuableTypes
.
epic
]:
{
mutation
:
updateEpicTitleMutation
,
},
};
app/assets/javascripts/boards/graphql/issue_set_title.mutation.graphql
View file @
3cd8e1ff
mutation
issueSetTitle
(
$input
:
UpdateIssueInput
!)
{
updateIssue
(
input
:
$input
)
{
updateIssu
ableTitle
:
updateIssu
e
(
input
:
$input
)
{
issue
{
title
}
...
...
app/assets/javascripts/boards/stores/actions.js
View file @
3cd8e1ff
...
...
@@ -8,6 +8,7 @@ import {
inactiveId
,
flashAnimationDuration
,
ISSUABLE
,
titleQueries
,
}
from
'
~/boards/constants
'
;
import
{
getIdFromGraphQLId
}
from
'
~/graphql_shared/utils
'
;
import
createGqClient
,
{
fetchPolicies
}
from
'
~/lib/graphql
'
;
...
...
@@ -33,7 +34,6 @@ import issueSetDueDateMutation from '../graphql/issue_set_due_date.mutation.grap
import
issueSetLabelsMutation
from
'
../graphql/issue_set_labels.mutation.graphql
'
;
import
issueSetMilestoneMutation
from
'
../graphql/issue_set_milestone.mutation.graphql
'
;
import
issueSetSubscriptionMutation
from
'
../graphql/issue_set_subscription.mutation.graphql
'
;
import
issueSetTitleMutation
from
'
../graphql/issue_set_title.mutation.graphql
'
;
import
listsIssuesQuery
from
'
../graphql/lists_issues.query.graphql
'
;
import
*
as
types
from
'
./mutation_types
'
;
...
...
@@ -526,27 +526,31 @@ export default {
});
},
setActiveIssueTitle
:
async
({
commit
,
getters
},
input
)
=>
{
const
{
activeBoardItem
}
=
getters
;
setActiveItemTitle
:
async
({
commit
,
getters
,
state
},
input
)
=>
{
const
{
activeBoardItem
,
isEpicBoard
}
=
getters
;
const
{
fullPath
,
issuableType
}
=
state
;
const
workspacePath
=
isEpicBoard
?
{
groupPath
:
fullPath
}
:
{
projectPath
:
input
.
projectPath
};
const
{
data
}
=
await
gqlClient
.
mutate
({
mutation
:
issueSetTitleM
utation
,
mutation
:
titleQueries
[
issuableType
].
m
utation
,
variables
:
{
input
:
{
...
workspacePath
,
iid
:
String
(
activeBoardItem
.
iid
),
projectPath
:
input
.
projectPath
,
title
:
input
.
title
,
},
},
});
if
(
data
.
updateIssue
?.
errors
?.
length
>
0
)
{
throw
new
Error
(
data
.
updateIssue
.
errors
);
if
(
data
.
updateIssu
ableTitl
e
?.
errors
?.
length
>
0
)
{
throw
new
Error
(
data
.
updateIssu
ableTitl
e
.
errors
);
}
commit
(
types
.
UPDATE_BOARD_ITEM_BY_ID
,
{
itemId
:
activeBoardItem
.
id
,
prop
:
'
title
'
,
value
:
data
.
updateIssu
e
.
issue
.
title
,
value
:
data
.
updateIssu
ableTitle
[
issuableType
]
.
title
,
});
},
...
...
app/assets/javascripts/sidebar/queries/update_epic_title.mutation.graphql
0 → 100644
View file @
3cd8e1ff
mutation
updateEpic
(
$input
:
UpdateEpicInput
!)
{
updateIssuableTitle
:
updateEpic
(
input
:
$input
)
{
epic
{
title
}
errors
}
}
ee/app/assets/javascripts/boards/components/epic_board_content_sidebar.vue
View file @
3cd8e1ff
...
...
@@ -2,6 +2,7 @@
import
{
GlDrawer
}
from
'
@gitlab/ui
'
;
import
{
mapState
,
mapActions
,
mapGetters
}
from
'
vuex
'
;
import
BoardSidebarLabelsSelect
from
'
~/boards/components/sidebar/board_sidebar_labels_select.vue
'
;
import
BoardSidebarTitle
from
'
~/boards/components/sidebar/board_sidebar_title.vue
'
;
import
{
ISSUABLE
}
from
'
~/boards/constants
'
;
import
{
contentTop
}
from
'
~/lib/utils/common_utils
'
;
...
...
@@ -10,6 +11,7 @@ export default {
components
:
{
GlDrawer
,
BoardSidebarLabelsSelect
,
BoardSidebarTitle
,
},
computed
:
{
...
mapGetters
([
'
isSidebarOpen
'
,
'
activeBoardItem
'
]),
...
...
@@ -39,6 +41,7 @@ export default {
>
<template
#header
>
{{
__
(
'
Epic details
'
)
}}
</
template
>
<
template
#default
>
<board-sidebar-title
data-testid=
"sidebar-title"
/>
<board-sidebar-labels-select
class=
"labels"
/>
</
template
>
</gl-drawer>
...
...
ee/spec/features/epic_boards/epic_boards_sidebar_spec.rb
View file @
3cd8e1ff
...
...
@@ -50,6 +50,37 @@ RSpec.describe 'Epic boards sidebar', :js do
expect
(
page
).
not_to
have_selector
(
'[data-testid="epic-boards-sidebar"]'
)
end
it
'shows epic details when sidebar is open'
,
:aggregate_failures
do
click_card
(
card
)
page
.
within
(
'[data-testid="epic-boards-sidebar"]'
)
do
expect
(
page
).
to
have_content
(
epic1
.
title
)
expect
(
page
).
to
have_content
(
epic1
.
to_reference
)
end
end
context
'title'
do
it
'edits epic title'
do
click_card
(
card
)
page
.
within
(
'[data-testid="sidebar-title"]'
)
do
click_button
'Edit'
wait_for_requests
find
(
'input'
).
set
(
'Test title'
)
click_button
'Save changes'
wait_for_requests
expect
(
page
).
to
have_content
(
'Test title'
)
end
expect
(
card
).
to
have_content
(
'Test title'
)
end
end
context
'labels'
do
it
'adds a single label'
do
click_card
(
card
)
...
...
locale/gitlab.pot
View file @
3cd8e1ff
...
...
@@ -3353,10 +3353,10 @@ msgstr ""
msgid "An error occurred when updating the issue due date"
msgstr ""
msgid "An error occurred when updating the issue
title
"
msgid "An error occurred when updating the issue
weight
"
msgstr ""
msgid "An error occurred when updating the
issue weight
"
msgid "An error occurred when updating the
title
"
msgstr ""
msgid "An error occurred while acknowledging the notification. Refresh the page and try again."
...
...
@@ -3686,9 +3686,6 @@ msgstr ""
msgid "An issue already exists"
msgstr ""
msgid "An issue title is required"
msgstr ""
msgid "An unauthenticated user"
msgstr ""
...
...
@@ -17342,9 +17339,6 @@ msgstr ""
msgid "Issue published on status page."
msgstr ""
msgid "Issue title"
msgstr ""
msgid "Issue types"
msgstr ""
...
...
spec/frontend/boards/components/board_content_sidebar_spec.js
View file @
3cd8e1ff
...
...
@@ -4,10 +4,10 @@ import Vuex from 'vuex';
import
{
stubComponent
}
from
'
helpers/stub_component
'
;
import
BoardContentSidebar
from
'
~/boards/components/board_content_sidebar.vue
'
;
import
BoardSidebarDueDate
from
'
~/boards/components/sidebar/board_sidebar_due_date.vue
'
;
import
BoardSidebarIssueTitle
from
'
~/boards/components/sidebar/board_sidebar_issue_title.vue
'
;
import
BoardSidebarLabelsSelect
from
'
~/boards/components/sidebar/board_sidebar_labels_select.vue
'
;
import
BoardSidebarMilestoneSelect
from
'
~/boards/components/sidebar/board_sidebar_milestone_select.vue
'
;
import
BoardSidebarSubscription
from
'
~/boards/components/sidebar/board_sidebar_subscription.vue
'
;
import
BoardSidebarTitle
from
'
~/boards/components/sidebar/board_sidebar_title.vue
'
;
import
{
ISSUABLE
}
from
'
~/boards/constants
'
;
import
{
mockIssue
,
mockIssueGroupPath
,
mockIssueProjectPath
}
from
'
../mock_data
'
;
...
...
@@ -102,8 +102,8 @@ describe('BoardContentSidebar', () => {
expect
(
wrapper
.
find
(
BoardSidebarLabelsSelect
).
exists
()).
toBe
(
true
);
});
it
(
'
renders BoardSidebar
Issue
Title
'
,
()
=>
{
expect
(
wrapper
.
find
(
BoardSidebar
Issue
Title
).
exists
()).
toBe
(
true
);
it
(
'
renders BoardSidebarTitle
'
,
()
=>
{
expect
(
wrapper
.
find
(
BoardSidebarTitle
).
exists
()).
toBe
(
true
);
});
it
(
'
renders BoardSidebarDueDate
'
,
()
=>
{
...
...
spec/frontend/boards/components/sidebar/board_sidebar_
issue_
title_spec.js
→
spec/frontend/boards/components/sidebar/board_sidebar_title_spec.js
View file @
3cd8e1ff
import
{
GlAlert
,
GlFormInput
,
GlForm
}
from
'
@gitlab/ui
'
;
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
BoardEditableItem
from
'
~/boards/components/sidebar/board_editable_item.vue
'
;
import
BoardSidebar
IssueTitle
from
'
~/boards/components/sidebar/board_sidebar_issue
_title.vue
'
;
import
BoardSidebar
Title
from
'
~/boards/components/sidebar/board_sidebar
_title.vue
'
;
import
{
createStore
}
from
'
~/boards/stores
'
;
import
createFlash
from
'
~/flash
'
;
const
TEST_TITLE
=
'
New i
ssue
title
'
;
const
TEST_TITLE
=
'
New i
tem
title
'
;
const
TEST_ISSUE_A
=
{
id
:
'
gid://gitlab/Issue/1
'
,
iid
:
8
,
...
...
@@ -21,7 +21,7 @@ const TEST_ISSUE_B = {
jest
.
mock
(
'
~/flash
'
);
describe
(
'
~/boards/components/sidebar/board_sidebar_
issue_
title.vue
'
,
()
=>
{
describe
(
'
~/boards/components/sidebar/board_sidebar_title.vue
'
,
()
=>
{
let
wrapper
;
let
store
;
...
...
@@ -32,12 +32,12 @@ describe('~/boards/components/sidebar/board_sidebar_issue_title.vue', () => {
wrapper
=
null
;
});
const
createWrapper
=
(
i
ssue
=
TEST_ISSUE_A
)
=>
{
const
createWrapper
=
(
i
tem
=
TEST_ISSUE_A
)
=>
{
store
=
createStore
();
store
.
state
.
boardItems
=
{
[
i
ssue
.
id
]:
{
...
issue
}
};
store
.
dispatch
(
'
setActiveId
'
,
{
id
:
i
ssue
.
id
});
store
.
state
.
boardItems
=
{
[
i
tem
.
id
]:
{
...
item
}
};
store
.
dispatch
(
'
setActiveId
'
,
{
id
:
i
tem
.
id
});
wrapper
=
shallowMount
(
BoardSidebar
Issue
Title
,
{
wrapper
=
shallowMount
(
BoardSidebarTitle
,
{
store
,
provide
:
{
canUpdate
:
true
,
...
...
@@ -53,7 +53,7 @@ describe('~/boards/components/sidebar/board_sidebar_issue_title.vue', () => {
const
findFormInput
=
()
=>
wrapper
.
find
(
GlFormInput
);
const
findEditableItem
=
()
=>
wrapper
.
find
(
BoardEditableItem
);
const
findCancelButton
=
()
=>
wrapper
.
find
(
'
[data-testid="cancel-button"]
'
);
const
findTitle
=
()
=>
wrapper
.
find
(
'
[data-testid="i
ssue
-title"]
'
);
const
findTitle
=
()
=>
wrapper
.
find
(
'
[data-testid="i
tem
-title"]
'
);
const
findCollapsed
=
()
=>
wrapper
.
find
(
'
[data-testid="collapsed-content"]
'
);
it
(
'
renders title and reference
'
,
()
=>
{
...
...
@@ -73,7 +73,7 @@ describe('~/boards/components/sidebar/board_sidebar_issue_title.vue', () => {
beforeEach
(
async
()
=>
{
createWrapper
();
jest
.
spyOn
(
wrapper
.
vm
,
'
setActiveI
ssue
Title
'
).
mockImplementation
(()
=>
{
jest
.
spyOn
(
wrapper
.
vm
,
'
setActiveI
tem
Title
'
).
mockImplementation
(()
=>
{
store
.
state
.
boardItems
[
TEST_ISSUE_A
.
id
].
title
=
TEST_TITLE
;
});
findFormInput
().
vm
.
$emit
(
'
input
'
,
TEST_TITLE
);
...
...
@@ -87,7 +87,7 @@ describe('~/boards/components/sidebar/board_sidebar_issue_title.vue', () => {
});
it
(
'
commits change to the server
'
,
()
=>
{
expect
(
wrapper
.
vm
.
setActiveI
ssue
Title
).
toHaveBeenCalledWith
({
expect
(
wrapper
.
vm
.
setActiveI
tem
Title
).
toHaveBeenCalledWith
({
title
:
TEST_TITLE
,
projectPath
:
'
h/b
'
,
});
...
...
@@ -98,14 +98,14 @@ describe('~/boards/components/sidebar/board_sidebar_issue_title.vue', () => {
beforeEach
(
async
()
=>
{
createWrapper
();
jest
.
spyOn
(
wrapper
.
vm
,
'
setActiveI
ssue
Title
'
).
mockImplementation
(()
=>
{});
jest
.
spyOn
(
wrapper
.
vm
,
'
setActiveI
tem
Title
'
).
mockImplementation
(()
=>
{});
findFormInput
().
vm
.
$emit
(
'
input
'
,
''
);
findForm
().
vm
.
$emit
(
'
submit
'
,
{
preventDefault
:
()
=>
{}
});
await
wrapper
.
vm
.
$nextTick
();
});
it
(
'
commits change to the server
'
,
()
=>
{
expect
(
wrapper
.
vm
.
setActiveI
ssue
Title
).
not
.
toHaveBeenCalled
();
expect
(
wrapper
.
vm
.
setActiveI
tem
Title
).
not
.
toHaveBeenCalled
();
});
});
...
...
@@ -122,7 +122,7 @@ describe('~/boards/components/sidebar/board_sidebar_issue_title.vue', () => {
it
(
'
does not collapses sidebar and shows alert
'
,
()
=>
{
expect
(
findCollapsed
().
isVisible
()).
toBe
(
false
);
expect
(
findAlert
().
exists
()).
toBe
(
true
);
expect
(
localStorage
.
getItem
(
`
${
TEST_ISSUE_A
.
id
}
/i
ssue
-title-pending-changes`
)).
toBe
(
expect
(
localStorage
.
getItem
(
`
${
TEST_ISSUE_A
.
id
}
/i
tem
-title-pending-changes`
)).
toBe
(
TEST_TITLE
,
);
});
...
...
@@ -130,7 +130,7 @@ describe('~/boards/components/sidebar/board_sidebar_issue_title.vue', () => {
describe
(
'
when accessing the form with pending changes
'
,
()
=>
{
beforeAll
(()
=>
{
localStorage
.
setItem
(
`
${
TEST_ISSUE_A
.
id
}
/i
ssue
-title-pending-changes`
,
TEST_TITLE
);
localStorage
.
setItem
(
`
${
TEST_ISSUE_A
.
id
}
/i
tem
-title-pending-changes`
,
TEST_TITLE
);
createWrapper
();
});
...
...
@@ -146,7 +146,7 @@ describe('~/boards/components/sidebar/board_sidebar_issue_title.vue', () => {
beforeEach
(
async
()
=>
{
createWrapper
(
TEST_ISSUE_B
);
jest
.
spyOn
(
wrapper
.
vm
,
'
setActiveI
ssue
Title
'
).
mockImplementation
(()
=>
{
jest
.
spyOn
(
wrapper
.
vm
,
'
setActiveI
tem
Title
'
).
mockImplementation
(()
=>
{
store
.
state
.
boardItems
[
TEST_ISSUE_B
.
id
].
title
=
TEST_TITLE
;
});
findFormInput
().
vm
.
$emit
(
'
input
'
,
TEST_TITLE
);
...
...
@@ -155,7 +155,7 @@ describe('~/boards/components/sidebar/board_sidebar_issue_title.vue', () => {
});
it
(
'
collapses sidebar and render former title
'
,
()
=>
{
expect
(
wrapper
.
vm
.
setActiveI
ssue
Title
).
not
.
toHaveBeenCalled
();
expect
(
wrapper
.
vm
.
setActiveI
tem
Title
).
not
.
toHaveBeenCalled
();
expect
(
findCollapsed
().
isVisible
()).
toBe
(
true
);
expect
(
findTitle
().
text
()).
toBe
(
TEST_ISSUE_B
.
title
);
});
...
...
@@ -165,7 +165,7 @@ describe('~/boards/components/sidebar/board_sidebar_issue_title.vue', () => {
beforeEach
(
async
()
=>
{
createWrapper
(
TEST_ISSUE_B
);
jest
.
spyOn
(
wrapper
.
vm
,
'
setActiveI
ssue
Title
'
).
mockImplementation
(()
=>
{
jest
.
spyOn
(
wrapper
.
vm
,
'
setActiveI
tem
Title
'
).
mockImplementation
(()
=>
{
throw
new
Error
([
'
failed mutation
'
]);
});
findFormInput
().
vm
.
$emit
(
'
input
'
,
'
Invalid title
'
);
...
...
@@ -173,7 +173,7 @@ describe('~/boards/components/sidebar/board_sidebar_issue_title.vue', () => {
await
wrapper
.
vm
.
$nextTick
();
});
it
(
'
collapses sidebar and renders former i
ssue
title
'
,
()
=>
{
it
(
'
collapses sidebar and renders former i
tem
title
'
,
()
=>
{
expect
(
findCollapsed
().
isVisible
()).
toBe
(
true
);
expect
(
findTitle
().
text
()).
toContain
(
TEST_ISSUE_B
.
title
);
expect
(
createFlash
).
toHaveBeenCalled
();
...
...
spec/frontend/boards/stores/actions_spec.js
View file @
3cd8e1ff
...
...
@@ -1223,9 +1223,13 @@ describe('setActiveIssueMilestone', () => {
});
});
describe
(
'
setActiveIssueTitle
'
,
()
=>
{
const
state
=
{
boardItems
:
{
[
mockIssue
.
id
]:
mockIssue
}
};
const
getters
=
{
activeBoardItem
:
mockIssue
};
describe
(
'
setActiveItemTitle
'
,
()
=>
{
const
state
=
{
boardItems
:
{
[
mockIssue
.
id
]:
mockIssue
},
issuableType
:
'
issue
'
,
fullPath
:
'
path/f
'
,
};
const
getters
=
{
activeBoardItem
:
mockIssue
,
isEpicBoard
:
false
};
const
testTitle
=
'
Test Title
'
;
const
input
=
{
title
:
testTitle
,
...
...
@@ -1235,7 +1239,7 @@ describe('setActiveIssueTitle', () => {
it
(
'
should commit title after setting the issue
'
,
(
done
)
=>
{
jest
.
spyOn
(
gqlClient
,
'
mutate
'
).
mockResolvedValue
({
data
:
{
updateIssue
:
{
updateIssu
ableTitl
e
:
{
issue
:
{
title
:
testTitle
,
},
...
...
@@ -1251,7 +1255,7 @@ describe('setActiveIssueTitle', () => {
};
testAction
(
actions
.
setActiveI
ssue
Title
,
actions
.
setActiveI
tem
Title
,
input
,
{
...
state
,
...
getters
},
[
...
...
@@ -1270,7 +1274,7 @@ describe('setActiveIssueTitle', () => {
.
spyOn
(
gqlClient
,
'
mutate
'
)
.
mockResolvedValue
({
data
:
{
updateIssue
:
{
errors
:
[
'
failed mutation
'
]
}
}
});
await
expect
(
actions
.
setActiveI
ssue
Title
({
getters
},
input
)).
rejects
.
toThrow
(
Error
);
await
expect
(
actions
.
setActiveI
tem
Title
({
getters
},
input
)).
rejects
.
toThrow
(
Error
);
});
});
...
...
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