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
1d59a6fb
Commit
1d59a6fb
authored
Mar 04, 2021
by
Simon Knox
Committed by
Kushal Pandya
Mar 04, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Split new column form into data/display components
Makes it easier to extend for different types of list in EE
parent
827fcc6a
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
383 additions
and
219 deletions
+383
-219
app/assets/javascripts/boards/components/board_add_new_column.vue
...ts/javascripts/boards/components/board_add_new_column.vue
+64
-152
app/assets/javascripts/boards/components/board_add_new_column_form.vue
...vascripts/boards/components/board_add_new_column_form.vue
+122
-0
app/assets/javascripts/boards/stores/actions.js
app/assets/javascripts/boards/stores/actions.js
+2
-2
app/assets/javascripts/boards/stores/mutations.js
app/assets/javascripts/boards/stores/mutations.js
+5
-2
ee/app/assets/javascripts/boards/stores/actions.js
ee/app/assets/javascripts/boards/stores/actions.js
+1
-1
ee/spec/frontend/boards/stores/actions_spec.js
ee/spec/frontend/boards/stores/actions_spec.js
+2
-2
locale/gitlab.pot
locale/gitlab.pot
+2
-5
spec/frontend/boards/components/board_add_new_column_form_spec.js
...ntend/boards/components/board_add_new_column_form_spec.js
+166
-0
spec/frontend/boards/components/board_add_new_column_spec.js
spec/frontend/boards/components/board_add_new_column_spec.js
+17
-53
spec/frontend/boards/stores/actions_spec.js
spec/frontend/boards/stores/actions_spec.js
+2
-2
No files found.
app/assets/javascripts/boards/components/board_add_new_column.vue
View file @
1d59a6fb
<
script
>
<
script
>
import
{
import
{
GlButton
,
GlFormGroup
,
GlFormRadio
,
GlFormRadio
,
GlFormRadioGroup
,
GlFormRadioGroup
,
GlLabel
,
GlLabel
,
GlSearchBoxByType
,
GlSkeletonLoader
,
GlTooltipDirective
as
GlTooltip
,
GlTooltipDirective
as
GlTooltip
,
}
from
'
@gitlab/ui
'
;
}
from
'
@gitlab/ui
'
;
import
{
mapActions
,
mapGetters
,
mapState
}
from
'
vuex
'
;
import
{
mapActions
,
mapGetters
,
mapState
}
from
'
vuex
'
;
import
BoardAddNewColumnForm
from
'
~/boards/components/board_add_new_column_form.vue
'
;
import
{
ListType
}
from
'
~/boards/constants
'
;
import
boardsStore
from
'
~/boards/stores/boards_store
'
;
import
{
getIdFromGraphQLId
}
from
'
~/graphql_shared/utils
'
;
import
{
isScopedLabel
}
from
'
~/lib/utils/common_utils
'
;
import
{
isScopedLabel
}
from
'
~/lib/utils/common_utils
'
;
import
{
__
}
from
'
~/locale
'
;
import
boardsStore
from
'
../stores/boards_store
'
;
export
default
{
export
default
{
i18n
:
{
add
:
__
(
'
Add
'
),
cancel
:
__
(
'
Cancel
'
),
formDescription
:
__
(
'
A label list displays all issues with the selected label.
'
),
newLabelList
:
__
(
'
New label list
'
),
noLabelSelected
:
__
(
'
No label selected
'
),
searchPlaceholder
:
__
(
'
Search labels
'
),
selectLabel
:
__
(
'
Select label
'
),
selected
:
__
(
'
Selected
'
),
},
components
:
{
components
:
{
GlButton
,
BoardAddNewColumnForm
,
GlFormGroup
,
GlFormRadio
,
GlFormRadio
,
GlFormRadioGroup
,
GlFormRadioGroup
,
GlLabel
,
GlLabel
,
GlSearchBoxByType
,
GlSkeletonLoader
,
},
},
directives
:
{
directives
:
{
GlTooltip
,
GlTooltip
,
...
@@ -40,31 +25,27 @@ export default {
...
@@ -40,31 +25,27 @@ export default {
inject
:
[
'
scopedLabelsAvailable
'
],
inject
:
[
'
scopedLabelsAvailable
'
],
data
()
{
data
()
{
return
{
return
{
searchTerm
:
''
,
selectedId
:
null
,
selectedLabelId
:
null
,
};
};
},
},
computed
:
{
computed
:
{
...
mapState
([
'
labels
'
,
'
labelsLoading
'
,
'
isEpicBoard
'
]),
...
mapState
([
'
labels
'
,
'
labelsLoading
'
,
'
isEpicBoard
'
]),
...
mapGetters
([
'
getListByLabelId
'
,
'
shouldUseGraphQL
'
]),
...
mapGetters
([
'
getListByLabelId
'
,
'
shouldUseGraphQL
'
]),
selectedLabel
()
{
selectedLabel
()
{
return
this
.
labels
.
find
(({
id
})
=>
id
===
this
.
selectedLabelId
);
if
(
!
this
.
selectedId
)
{
return
null
;
}
return
this
.
labels
.
find
(({
id
})
=>
id
===
this
.
selectedId
);
},
columnForSelected
()
{
return
this
.
getListByLabelId
(
this
.
selectedId
);
},
},
},
},
created
()
{
created
()
{
this
.
filter
Label
s
();
this
.
filter
Item
s
();
},
},
methods
:
{
methods
:
{
...
mapActions
([
'
createList
'
,
'
fetchLabels
'
,
'
highlightList
'
,
'
setAddColumnFormVisibility
'
]),
...
mapActions
([
'
createList
'
,
'
fetchLabels
'
,
'
highlightList
'
,
'
setAddColumnFormVisibility
'
]),
getListByLabel
(
label
)
{
if
(
this
.
shouldUseGraphQL
||
this
.
isEpicBoard
)
{
return
this
.
getListByLabelId
(
label
);
}
return
boardsStore
.
findListByLabelId
(
label
.
id
);
},
columnExists
(
label
)
{
return
Boolean
(
this
.
getListByLabel
(
label
));
},
highlight
(
listId
)
{
highlight
(
listId
)
{
if
(
this
.
shouldUseGraphQL
||
this
.
isEpicBoard
)
{
if
(
this
.
shouldUseGraphQL
||
this
.
isEpicBoard
)
{
this
.
highlightList
(
listId
);
this
.
highlightList
(
listId
);
...
@@ -77,44 +58,35 @@ export default {
...
@@ -77,44 +58,35 @@ export default {
}
}
},
},
addList
()
{
addList
()
{
if
(
!
this
.
selectedLabelId
)
{
if
(
!
this
.
selectedLabel
)
{
return
;
}
const
label
=
this
.
selectedLabel
;
if
(
!
label
)
{
return
;
return
;
}
}
this
.
setAddColumnFormVisibility
(
false
);
this
.
setAddColumnFormVisibility
(
false
);
if
(
this
.
column
Exists
({
id
:
this
.
selectedLabelId
})
)
{
if
(
this
.
column
ForSelected
)
{
const
listId
=
this
.
getListByLabel
(
label
)
.
id
;
const
listId
=
this
.
columnForSelected
.
id
;
this
.
highlight
(
listId
);
this
.
highlight
(
listId
);
return
;
return
;
}
}
if
(
this
.
shouldUseGraphQL
||
this
.
isEpicBoard
)
{
if
(
this
.
shouldUseGraphQL
||
this
.
isEpicBoard
)
{
this
.
createList
({
labelId
:
this
.
selected
Label
Id
});
this
.
createList
({
labelId
:
this
.
selectedId
});
}
else
{
}
else
{
boardsStore
.
new
({
const
listObj
=
{
title
:
label
.
title
,
labelId
:
getIdFromGraphQLId
(
this
.
selectedId
),
title
:
this
.
selectedLabel
.
title
,
position
:
boardsStore
.
state
.
lists
.
length
-
2
,
position
:
boardsStore
.
state
.
lists
.
length
-
2
,
list_type
:
'
label
'
,
list_type
:
ListType
.
label
,
label
:
{
label
:
this
.
selectedLabel
,
id
:
label
.
id
,
};
title
:
label
.
title
,
color
:
label
.
color
,
},
});
this
.
highlight
(
boardsStore
.
findListByLabelId
(
label
.
id
).
id
);
boardsStore
.
new
(
listObj
);
}
}
},
},
filter
Labels
(
)
{
filter
Items
(
searchTerm
)
{
this
.
fetchLabels
(
this
.
searchTerm
);
this
.
fetchLabels
(
searchTerm
);
},
},
showScopedLabels
(
label
)
{
showScopedLabels
(
label
)
{
...
@@ -125,29 +97,16 @@ export default {
...
@@ -125,29 +97,16 @@ export default {
</
script
>
</
script
>
<
template
>
<
template
>
<div
<board-add-new-column-form
class=
"board-add-new-list board gl-display-inline-block gl-h-full gl-px-3 gl-vertical-align-top gl-white-space-normal gl-flex-shrink-0"
:loading=
"labelsLoading"
data-testid=
"board-add-new-column"
:form-description=
"__('A label list displays issues with the selected label.')"
data-qa-selector=
"board_add_new_list"
:search-label=
"__('Select label')"
>
:search-placeholder=
"__('Search labels')"
<div
:selected-id=
"selectedId"
class=
"board-inner gl-display-flex gl-flex-direction-column gl-relative gl-h-full gl-rounded-base gl-bg-white"
@
filter-items=
"filterItems"
@
add-list=
"addList"
>
>
<h3
<template
slot=
"selected"
>
class=
"gl-font-base gl-px-5 gl-py-5 gl-m-0 gl-border-b-1 gl-border-b-solid gl-border-b-gray-100"
data-testid=
"board-add-column-form-title"
>
{{
$options
.
i18n
.
newLabelList
}}
</h3>
<div
class=
"gl-display-flex gl-flex-direction-column gl-h-full gl-overflow-hidden"
>
<!-- selectbox is here in EE -->
<p
class=
"gl-m-5"
>
{{
$options
.
i18n
.
formDescription
}}
</p>
<div
class=
"gl-px-5 gl-pb-4"
>
<label
class=
"gl-mb-2"
>
{{
$options
.
i18n
.
selected
}}
</label>
<div>
<gl-label
<gl-label
v-if=
"selectedLabel"
v-if=
"selectedLabel"
v-gl-tooltip
v-gl-tooltip
...
@@ -156,37 +115,10 @@ export default {
...
@@ -156,37 +115,10 @@ export default {
:background-color=
"selectedLabel.color"
:background-color=
"selectedLabel.color"
:scoped=
"showScopedLabels(selectedLabel)"
:scoped=
"showScopedLabels(selectedLabel)"
/>
/>
<div
v-else
class=
"gl-text-gray-500"
>
{{
$options
.
i18n
.
noLabelSelected
}}
</div>
</
template
>
</div>
</div>
<gl-form-group
class=
"gl-mx-5 gl-mb-3"
:label=
"$options.i18n.selectLabel"
label-for=
"board-available-labels"
>
<gl-search-box-by-type
id=
"board-available-labels"
v-model.trim=
"searchTerm"
debounce=
"250"
:placeholder=
"$options.i18n.searchPlaceholder"
@
input=
"filterLabels"
/>
</gl-form-group>
<div
v-if=
"labelsLoading"
class=
"gl-m-5"
>
<
template
slot=
"items"
>
<gl-skeleton-loader
:width=
"500"
:height=
"172"
>
<gl-form-radio-group
v-model=
"selectedId"
class=
"gl-overflow-y-auto gl-px-5 gl-pt-3"
>
<rect
width=
"480"
height=
"20"
x=
"10"
y=
"15"
rx=
"4"
/>
<rect
width=
"380"
height=
"20"
x=
"10"
y=
"50"
rx=
"4"
/>
<rect
width=
"430"
height=
"20"
x=
"10"
y=
"85"
rx=
"4"
/>
</gl-skeleton-loader>
</div>
<gl-form-radio-group
v-else
v-model=
"selectedLabelId"
class=
"gl-overflow-y-auto gl-px-5 gl-pt-3"
>
<label
<label
v-for=
"label in labels"
v-for=
"label in labels"
:key=
"label.id"
:key=
"label.id"
...
@@ -202,26 +134,6 @@ export default {
...
@@ -202,26 +134,6 @@ export default {
<span>
{{
label
.
title
}}
</span>
<span>
{{
label
.
title
}}
</span>
</label>
</label>
</gl-form-radio-group>
</gl-form-radio-group>
</div>
</
template
>
</board-add-new-column-form>
<div
class=
"gl-display-flex gl-p-3 gl-border-t-1 gl-border-t-solid gl-border-gray-100 gl-bg-gray-10"
>
<gl-button
data-testid=
"cancelAddNewColumn"
class=
"gl-ml-auto gl-mr-3"
@
click=
"setAddColumnFormVisibility(false)"
>
{{
$options
.
i18n
.
cancel
}}
</gl-button
>
<gl-button
data-testid=
"addNewColumnButton"
:disabled=
"!selectedLabelId"
variant=
"success"
class=
"gl-mr-4"
@
click=
"addList"
>
{{
$options
.
i18n
.
add
}}
</gl-button
>
</div>
</div>
</div>
</template>
</template>
app/assets/javascripts/boards/components/board_add_new_column_form.vue
0 → 100644
View file @
1d59a6fb
<
script
>
import
{
GlButton
,
GlFormGroup
,
GlSearchBoxByType
,
GlSkeletonLoader
}
from
'
@gitlab/ui
'
;
import
{
mapActions
}
from
'
vuex
'
;
import
{
__
}
from
'
~/locale
'
;
export
default
{
i18n
:
{
add
:
__
(
'
Add
'
),
cancel
:
__
(
'
Cancel
'
),
newList
:
__
(
'
New list
'
),
noneSelected
:
__
(
'
None
'
),
selected
:
__
(
'
Selected
'
),
},
components
:
{
GlButton
,
GlFormGroup
,
GlSearchBoxByType
,
GlSkeletonLoader
,
},
props
:
{
loading
:
{
type
:
Boolean
,
required
:
true
,
},
formDescription
:
{
type
:
String
,
required
:
true
,
},
searchLabel
:
{
type
:
String
,
required
:
true
,
},
searchPlaceholder
:
{
type
:
String
,
required
:
true
,
},
selectedId
:
{
type
:
[
Number
,
String
],
required
:
false
,
default
:
null
,
},
},
methods
:
{
...
mapActions
([
'
setAddColumnFormVisibility
'
]),
},
};
</
script
>
<
template
>
<div
class=
"board-add-new-list board gl-display-inline-block gl-h-full gl-px-3 gl-vertical-align-top gl-white-space-normal gl-flex-shrink-0"
data-testid=
"board-add-new-column"
data-qa-selector=
"board_add_new_list"
>
<div
class=
"board-inner gl-display-flex gl-flex-direction-column gl-relative gl-h-full gl-rounded-base gl-bg-white"
>
<h3
class=
"gl-font-base gl-px-5 gl-py-5 gl-m-0 gl-border-b-1 gl-border-b-solid gl-border-b-gray-100"
data-testid=
"board-add-column-form-title"
>
{{
$options
.
i18n
.
newList
}}
</h3>
<div
class=
"gl-display-flex gl-flex-direction-column gl-h-full gl-overflow-hidden"
>
<slot
name=
"select-list-type"
>
<div
class=
"gl-mb-5"
></div>
</slot>
<p
class=
"gl-px-5"
>
{{
formDescription
}}
</p>
<div
class=
"gl-px-5 gl-pb-4"
>
<label
class=
"gl-mb-2"
>
{{
$options
.
i18n
.
selected
}}
</label>
<slot
name=
"selected"
>
<div
class=
"gl-text-gray-500"
>
{{
$options
.
i18n
.
noneSelected
}}
</div>
</slot>
</div>
<gl-form-group
class=
"gl-mx-5 gl-mb-3"
:label=
"searchLabel"
label-for=
"board-available-column-entities"
>
<gl-search-box-by-type
id=
"board-available-column-entities"
debounce=
"250"
:placeholder=
"searchPlaceholder"
@
input=
"$emit('filter-items', $event)"
/>
</gl-form-group>
<div
v-if=
"loading"
class=
"gl-px-5"
>
<gl-skeleton-loader
:width=
"500"
:height=
"172"
>
<rect
width=
"480"
height=
"20"
x=
"10"
y=
"15"
rx=
"4"
/>
<rect
width=
"380"
height=
"20"
x=
"10"
y=
"50"
rx=
"4"
/>
<rect
width=
"430"
height=
"20"
x=
"10"
y=
"85"
rx=
"4"
/>
</gl-skeleton-loader>
</div>
<slot
v-else
name=
"items"
></slot>
</div>
<div
class=
"gl-display-flex gl-p-3 gl-border-t-1 gl-border-t-solid gl-border-gray-100 gl-bg-gray-10"
>
<gl-button
data-testid=
"cancelAddNewColumn"
class=
"gl-ml-auto gl-mr-3"
@
click=
"setAddColumnFormVisibility(false)"
>
{{
$options
.
i18n
.
cancel
}}
</gl-button
>
<gl-button
data-testid=
"addNewColumnButton"
:disabled=
"!selectedId"
variant=
"success"
class=
"gl-mr-4"
@
click=
"$emit('add-list')"
>
{{
$options
.
i18n
.
add
}}
</gl-button
>
</div>
</div>
</div>
</
template
>
app/assets/javascripts/boards/stores/actions.js
View file @
1d59a6fb
...
@@ -157,8 +157,8 @@ export default {
...
@@ -157,8 +157,8 @@ export default {
},
},
})
})
.
then
(({
data
})
=>
{
.
then
(({
data
})
=>
{
if
(
data
?
.
boardListCreate
?.
errors
.
length
)
{
if
(
data
.
boardListCreate
?.
errors
.
length
)
{
commit
(
types
.
CREATE_LIST_FAILURE
);
commit
(
types
.
CREATE_LIST_FAILURE
,
data
.
boardListCreate
.
errors
[
0
]
);
}
else
{
}
else
{
const
list
=
data
.
boardListCreate
?.
list
;
const
list
=
data
.
boardListCreate
?.
list
;
dispatch
(
'
addList
'
,
list
);
dispatch
(
'
addList
'
,
list
);
...
...
app/assets/javascripts/boards/stores/mutations.js
View file @
1d59a6fb
...
@@ -60,8 +60,11 @@ export default {
...
@@ -60,8 +60,11 @@ export default {
state
.
filterParams
=
filterParams
;
state
.
filterParams
=
filterParams
;
},
},
[
mutationTypes
.
CREATE_LIST_FAILURE
]:
(
state
)
=>
{
[
mutationTypes
.
CREATE_LIST_FAILURE
]:
(
state
.
error
=
s__
(
'
Boards|An error occurred while creating the list. Please try again.
'
);
state
,
error
=
s__
(
'
Boards|An error occurred while creating the list. Please try again.
'
),
)
=>
{
state
.
error
=
error
;
},
},
[
mutationTypes
.
RECEIVE_LABELS_REQUEST
]:
(
state
)
=>
{
[
mutationTypes
.
RECEIVE_LABELS_REQUEST
]:
(
state
)
=>
{
...
...
ee/app/assets/javascripts/boards/stores/actions.js
View file @
1d59a6fb
...
@@ -587,7 +587,7 @@ export default {
...
@@ -587,7 +587,7 @@ export default {
})
})
.
then
(({
data
})
=>
{
.
then
(({
data
})
=>
{
if
(
data
?.
epicBoardListCreate
?.
errors
.
length
)
{
if
(
data
?.
epicBoardListCreate
?.
errors
.
length
)
{
commit
(
types
.
CREATE_LIST_FAILURE
);
commit
(
types
.
CREATE_LIST_FAILURE
,
data
.
epicBoardListCreate
.
errors
[
0
]
);
}
else
{
}
else
{
const
list
=
data
.
epicBoardListCreate
?.
list
;
const
list
=
data
.
epicBoardListCreate
?.
list
;
dispatch
(
'
addList
'
,
list
);
dispatch
(
'
addList
'
,
list
);
...
...
ee/spec/frontend/boards/stores/actions_spec.js
View file @
1d59a6fb
...
@@ -1026,14 +1026,14 @@ describe('moveIssue', () => {
...
@@ -1026,14 +1026,14 @@ describe('moveIssue', () => {
data
:
{
data
:
{
epicBoardListCreate
:
{
epicBoardListCreate
:
{
list
:
{},
list
:
{},
errors
:
[
{
foo
:
'
bar
'
}
],
errors
:
[
'
foo
'
],
},
},
},
},
});
});
await
actions
.
createEpicList
({
getters
,
state
,
commit
,
dispatch
},
{
backlog
:
true
});
await
actions
.
createEpicList
({
getters
,
state
,
commit
,
dispatch
},
{
backlog
:
true
});
expect
(
commit
).
toHaveBeenCalledWith
(
types
.
CREATE_LIST_FAILURE
);
expect
(
commit
).
toHaveBeenCalledWith
(
types
.
CREATE_LIST_FAILURE
,
'
foo
'
);
});
});
it
(
'
highlights list and does not re-query if it already exists
'
,
async
()
=>
{
it
(
'
highlights list and does not re-query if it already exists
'
,
async
()
=>
{
...
...
locale/gitlab.pot
View file @
1d59a6fb
...
@@ -1330,7 +1330,7 @@ msgstr ""
...
@@ -1330,7 +1330,7 @@ msgstr ""
msgid "A job artifact is an archive of files and directories saved by a job when it finishes."
msgid "A job artifact is an archive of files and directories saved by a job when it finishes."
msgstr ""
msgstr ""
msgid "A label list displays
all
issues with the selected label."
msgid "A label list displays issues with the selected label."
msgstr ""
msgstr ""
msgid "A limit of %{ci_project_subscriptions_limit} subscriptions to or from a project applies."
msgid "A limit of %{ci_project_subscriptions_limit} subscriptions to or from a project applies."
...
@@ -20298,7 +20298,7 @@ msgstr ""
...
@@ -20298,7 +20298,7 @@ msgstr ""
msgid "New label"
msgid "New label"
msgstr ""
msgstr ""
msgid "New l
abel l
ist"
msgid "New list"
msgstr ""
msgstr ""
msgid "New merge request"
msgid "New merge request"
...
@@ -20520,9 +20520,6 @@ msgstr ""
...
@@ -20520,9 +20520,6 @@ msgstr ""
msgid "No label"
msgid "No label"
msgstr ""
msgstr ""
msgid "No label selected"
msgstr ""
msgid "No labels with such name or description"
msgid "No labels with such name or description"
msgstr ""
msgstr ""
...
...
spec/frontend/boards/components/board_add_new_column_form_spec.js
0 → 100644
View file @
1d59a6fb
import
{
GlFormGroup
,
GlSearchBoxByType
,
GlSkeletonLoader
}
from
'
@gitlab/ui
'
;
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
Vue
,
{
nextTick
}
from
'
vue
'
;
import
Vuex
from
'
vuex
'
;
import
{
extendedWrapper
}
from
'
helpers/vue_test_utils_helper
'
;
import
BoardAddNewColumnForm
from
'
~/boards/components/board_add_new_column_form.vue
'
;
import
defaultState
from
'
~/boards/stores/state
'
;
import
{
mockLabelList
}
from
'
../mock_data
'
;
Vue
.
use
(
Vuex
);
describe
(
'
Board card layout
'
,
()
=>
{
let
wrapper
;
const
createStore
=
({
actions
=
{},
getters
=
{},
state
=
{}
}
=
{})
=>
{
return
new
Vuex
.
Store
({
state
:
{
...
defaultState
,
...
state
,
},
actions
,
getters
,
});
};
const
mountComponent
=
({
loading
=
false
,
formDescription
=
''
,
searchLabel
=
''
,
searchPlaceholder
=
''
,
selectedId
,
actions
,
slots
,
}
=
{})
=>
{
wrapper
=
extendedWrapper
(
shallowMount
(
BoardAddNewColumnForm
,
{
stubs
:
{
GlFormGroup
:
true
,
},
propsData
:
{
loading
,
formDescription
,
searchLabel
,
searchPlaceholder
,
selectedId
,
},
slots
,
store
:
createStore
({
actions
:
{
setAddColumnFormVisibility
:
jest
.
fn
(),
...
actions
,
},
}),
}),
);
};
afterEach
(()
=>
{
wrapper
.
destroy
();
wrapper
=
null
;
});
const
formTitle
=
()
=>
wrapper
.
findByTestId
(
'
board-add-column-form-title
'
).
text
();
const
findSearchInput
=
()
=>
wrapper
.
find
(
GlSearchBoxByType
);
const
findSearchLabel
=
()
=>
wrapper
.
find
(
GlFormGroup
);
const
cancelButton
=
()
=>
wrapper
.
findByTestId
(
'
cancelAddNewColumn
'
);
const
submitButton
=
()
=>
wrapper
.
findByTestId
(
'
addNewColumnButton
'
);
it
(
'
shows form title & search input
'
,
()
=>
{
mountComponent
();
expect
(
formTitle
()).
toEqual
(
BoardAddNewColumnForm
.
i18n
.
newList
);
expect
(
findSearchInput
().
exists
()).
toBe
(
true
);
});
it
(
'
clicking cancel hides the form
'
,
()
=>
{
const
setAddColumnFormVisibility
=
jest
.
fn
();
mountComponent
({
actions
:
{
setAddColumnFormVisibility
,
},
});
cancelButton
().
vm
.
$emit
(
'
click
'
);
expect
(
setAddColumnFormVisibility
).
toHaveBeenCalledWith
(
expect
.
anything
(),
false
);
});
it
(
'
sets placeholder and description from props
'
,
()
=>
{
const
props
=
{
formDescription
:
'
Some description of a list
'
,
};
mountComponent
(
props
);
expect
(
wrapper
.
html
()).
toHaveText
(
props
.
formDescription
);
});
describe
(
'
items
'
,
()
=>
{
const
mountWithItems
=
(
loading
)
=>
mountComponent
({
loading
,
slots
:
{
items
:
'
<div class="item-slot">Some kind of list</div>
'
,
},
});
it
(
'
hides items slot and shows skeleton while loading
'
,
()
=>
{
mountWithItems
(
true
);
expect
(
wrapper
.
findComponent
(
GlSkeletonLoader
).
exists
()).
toBe
(
true
);
expect
(
wrapper
.
find
(
'
.item-slot
'
).
exists
()).
toBe
(
false
);
});
it
(
'
shows items slot and hides skeleton while not loading
'
,
()
=>
{
mountWithItems
(
false
);
expect
(
wrapper
.
findComponent
(
GlSkeletonLoader
).
exists
()).
toBe
(
false
);
expect
(
wrapper
.
find
(
'
.item-slot
'
).
exists
()).
toBe
(
true
);
});
});
describe
(
'
search box
'
,
()
=>
{
it
(
'
sets label and placeholder text from props
'
,
()
=>
{
const
props
=
{
searchLabel
:
'
Some items
'
,
searchPlaceholder
:
'
Search for an item
'
,
};
mountComponent
(
props
);
expect
(
findSearchLabel
().
attributes
(
'
label
'
)).
toEqual
(
props
.
searchLabel
);
expect
(
findSearchInput
().
attributes
(
'
placeholder
'
)).
toEqual
(
props
.
searchPlaceholder
);
});
it
(
'
emits filter event on input
'
,
()
=>
{
mountComponent
();
const
searchText
=
'
some text
'
;
findSearchInput
().
vm
.
$emit
(
'
input
'
,
searchText
);
expect
(
wrapper
.
emitted
(
'
filter-items
'
)).
toEqual
([[
searchText
]]);
});
});
describe
(
'
Add list button
'
,
()
=>
{
it
(
'
is disabled if no item is selected
'
,
()
=>
{
mountComponent
();
expect
(
submitButton
().
props
(
'
disabled
'
)).
toBe
(
true
);
});
it
(
'
emits add-list event on click
'
,
async
()
=>
{
mountComponent
({
selectedId
:
mockLabelList
.
label
.
id
,
});
await
nextTick
();
submitButton
().
vm
.
$emit
(
'
click
'
);
expect
(
wrapper
.
emitted
(
'
add-list
'
)).
toEqual
([[]]);
});
});
});
spec/frontend/boards/components/board_add_new_column_spec.js
View file @
1d59a6fb
import
{
GlSearchBoxByType
}
from
'
@gitlab/ui
'
;
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
Vue
,
{
nextTick
}
from
'
vue
'
;
import
Vue
,
{
nextTick
}
from
'
vue
'
;
import
Vuex
from
'
vuex
'
;
import
Vuex
from
'
vuex
'
;
import
{
extendedWrapper
}
from
'
helpers/vue_test_utils_helper
'
;
import
{
extendedWrapper
}
from
'
helpers/vue_test_utils_helper
'
;
import
BoardAddNewColumn
from
'
~/boards/components/board_add_new_column.vue
'
;
import
BoardAddNewColumn
from
'
~/boards/components/board_add_new_column.vue
'
;
import
BoardAddNewColumnForm
from
'
~/boards/components/board_add_new_column_form.vue
'
;
import
defaultState
from
'
~/boards/stores/state
'
;
import
defaultState
from
'
~/boards/stores/state
'
;
import
{
mockLabelList
}
from
'
../mock_data
'
;
import
{
mockLabelList
}
from
'
../mock_data
'
;
...
@@ -11,7 +11,6 @@ Vue.use(Vuex);
...
@@ -11,7 +11,6 @@ Vue.use(Vuex);
describe
(
'
Board card layout
'
,
()
=>
{
describe
(
'
Board card layout
'
,
()
=>
{
let
wrapper
;
let
wrapper
;
let
shouldUseGraphQL
;
const
createStore
=
({
actions
=
{},
getters
=
{},
state
=
{}
}
=
{})
=>
{
const
createStore
=
({
actions
=
{},
getters
=
{},
state
=
{}
}
=
{})
=>
{
return
new
Vuex
.
Store
({
return
new
Vuex
.
Store
({
...
@@ -25,19 +24,16 @@ describe('Board card layout', () => {
...
@@ -25,19 +24,16 @@ describe('Board card layout', () => {
};
};
const
mountComponent
=
({
const
mountComponent
=
({
selected
Label
Id
,
selectedId
,
labels
=
[],
labels
=
[],
getListByLabelId
=
jest
.
fn
(),
getListByLabelId
=
jest
.
fn
(),
actions
=
{},
actions
=
{},
}
=
{})
=>
{
}
=
{})
=>
{
wrapper
=
extendedWrapper
(
wrapper
=
extendedWrapper
(
shallowMount
(
BoardAddNewColumn
,
{
shallowMount
(
BoardAddNewColumn
,
{
stubs
:
{
GlFormGroup
:
true
,
},
data
()
{
data
()
{
return
{
return
{
selected
Label
Id
,
selectedId
,
};
};
},
},
store
:
createStore
({
store
:
createStore
({
...
@@ -47,12 +43,13 @@ describe('Board card layout', () => {
...
@@ -47,12 +43,13 @@ describe('Board card layout', () => {
...
actions
,
...
actions
,
},
},
getters
:
{
getters
:
{
shouldUseGraphQL
:
()
=>
shouldUseGraphQL
,
shouldUseGraphQL
:
()
=>
true
,
getListByLabelId
:
()
=>
getListByLabelId
,
getListByLabelId
:
()
=>
getListByLabelId
,
},
},
state
:
{
state
:
{
labels
,
labels
,
labelsLoading
:
false
,
labelsLoading
:
false
,
isEpicBoard
:
false
,
},
},
}),
}),
provide
:
{
provide
:
{
...
@@ -64,65 +61,32 @@ describe('Board card layout', () => {
...
@@ -64,65 +61,32 @@ describe('Board card layout', () => {
afterEach
(()
=>
{
afterEach
(()
=>
{
wrapper
.
destroy
();
wrapper
.
destroy
();
wrapper
=
null
;
});
const
formTitle
=
()
=>
wrapper
.
findByTestId
(
'
board-add-column-form-title
'
).
text
();
const
findSearchInput
=
()
=>
wrapper
.
find
(
GlSearchBoxByType
);
const
cancelButton
=
()
=>
wrapper
.
findByTestId
(
'
cancelAddNewColumn
'
);
const
submitButton
=
()
=>
wrapper
.
findByTestId
(
'
addNewColumnButton
'
);
beforeEach
(()
=>
{
shouldUseGraphQL
=
true
;
});
it
(
'
shows form title & search input
'
,
()
=>
{
mountComponent
();
expect
(
formTitle
()).
toEqual
(
BoardAddNewColumn
.
i18n
.
newLabelList
);
expect
(
findSearchInput
().
exists
()).
toBe
(
true
);
});
it
(
'
clicking cancel hides the form
'
,
()
=>
{
const
setAddColumnFormVisibility
=
jest
.
fn
();
mountComponent
({
actions
:
{
setAddColumnFormVisibility
,
},
});
cancelButton
().
vm
.
$emit
(
'
click
'
);
expect
(
setAddColumnFormVisibility
).
toHaveBeenCalledWith
(
expect
.
anything
(),
false
);
});
});
describe
(
'
Add list button
'
,
()
=>
{
describe
(
'
Add list button
'
,
()
=>
{
it
(
'
is disabled if no item is selected
'
,
()
=>
{
it
(
'
calls addList
'
,
async
()
=>
{
mountComponent
();
const
getListByLabelId
=
jest
.
fn
().
mockReturnValue
(
null
);
expect
(
submitButton
().
props
(
'
disabled
'
)).
toBe
(
true
);
});
it
(
'
adds a new list on click
'
,
async
()
=>
{
const
labelId
=
mockLabelList
.
label
.
id
;
const
highlightList
=
jest
.
fn
();
const
highlightList
=
jest
.
fn
();
const
createList
=
jest
.
fn
();
const
createList
=
jest
.
fn
();
mountComponent
({
mountComponent
({
labels
:
[
mockLabelList
.
label
],
labels
:
[
mockLabelList
.
label
],
selectedLabelId
:
labelId
,
selectedId
:
mockLabelList
.
label
.
id
,
getListByLabelId
,
actions
:
{
actions
:
{
createList
,
createList
,
highlightList
,
highlightList
,
},
},
});
});
await
nextTick
(
);
wrapper
.
findComponent
(
BoardAddNewColumnForm
).
vm
.
$emit
(
'
add-list
'
);
submitButton
().
vm
.
$emit
(
'
click
'
);
await
nextTick
(
);
expect
(
highlightList
).
not
.
toHaveBeenCalled
();
expect
(
highlightList
).
not
.
toHaveBeenCalled
();
expect
(
createList
).
toHaveBeenCalledWith
(
expect
.
anything
(),
{
labelId
});
expect
(
createList
).
toHaveBeenCalledWith
(
expect
.
anything
(),
{
labelId
:
mockLabelList
.
label
.
id
,
});
});
});
it
(
'
highlights existing list if trying to re-add
'
,
async
()
=>
{
it
(
'
highlights existing list if trying to re-add
'
,
async
()
=>
{
...
@@ -132,7 +96,7 @@ describe('Board card layout', () => {
...
@@ -132,7 +96,7 @@ describe('Board card layout', () => {
mountComponent
({
mountComponent
({
labels
:
[
mockLabelList
.
label
],
labels
:
[
mockLabelList
.
label
],
selected
Label
Id
:
mockLabelList
.
label
.
id
,
selectedId
:
mockLabelList
.
label
.
id
,
getListByLabelId
,
getListByLabelId
,
actions
:
{
actions
:
{
createList
,
createList
,
...
@@ -140,9 +104,9 @@ describe('Board card layout', () => {
...
@@ -140,9 +104,9 @@ describe('Board card layout', () => {
},
},
});
});
await
nextTick
(
);
wrapper
.
findComponent
(
BoardAddNewColumnForm
).
vm
.
$emit
(
'
add-list
'
);
submitButton
().
vm
.
$emit
(
'
click
'
);
await
nextTick
(
);
expect
(
highlightList
).
toHaveBeenCalledWith
(
expect
.
anything
(),
mockLabelList
.
id
);
expect
(
highlightList
).
toHaveBeenCalledWith
(
expect
.
anything
(),
mockLabelList
.
id
);
expect
(
createList
).
not
.
toHaveBeenCalled
();
expect
(
createList
).
not
.
toHaveBeenCalled
();
...
...
spec/frontend/boards/stores/actions_spec.js
View file @
1d59a6fb
...
@@ -293,7 +293,7 @@ describe('createIssueList', () => {
...
@@ -293,7 +293,7 @@ describe('createIssueList', () => {
data
:
{
data
:
{
boardListCreate
:
{
boardListCreate
:
{
list
:
{},
list
:
{},
errors
:
[
{
foo
:
'
bar
'
}
],
errors
:
[
'
foo
'
],
},
},
},
},
}),
}),
...
@@ -301,7 +301,7 @@ describe('createIssueList', () => {
...
@@ -301,7 +301,7 @@ describe('createIssueList', () => {
await
actions
.
createIssueList
({
getters
,
state
,
commit
,
dispatch
},
{
backlog
:
true
});
await
actions
.
createIssueList
({
getters
,
state
,
commit
,
dispatch
},
{
backlog
:
true
});
expect
(
commit
).
toHaveBeenCalledWith
(
types
.
CREATE_LIST_FAILURE
);
expect
(
commit
).
toHaveBeenCalledWith
(
types
.
CREATE_LIST_FAILURE
,
'
foo
'
);
});
});
it
(
'
highlights list and does not re-query if it already exists
'
,
async
()
=>
{
it
(
'
highlights list and does not re-query if it already exists
'
,
async
()
=>
{
...
...
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