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
b712bfa7
Commit
b712bfa7
authored
Jan 24, 2022
by
Stanislav Lashmanov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor nextTick to use direct import from Vue package
RFC:
https://gitlab.com/gitlab-org/frontend/rfcs/-/issues/47
parent
eeceb35f
Changes
64
Show whitespace changes
Inline
Side-by-side
Showing
64 changed files
with
539 additions
and
590 deletions
+539
-590
spec/frontend/vue_mr_widget/components/mr_collapsible_extension_spec.js
...vue_mr_widget/components/mr_collapsible_extension_spec.js
+3
-2
spec/frontend/vue_mr_widget/components/mr_widget_author_spec.js
...rontend/vue_mr_widget/components/mr_widget_author_spec.js
+2
-1
spec/frontend/vue_mr_widget/components/mr_widget_expandable_section_spec.js
...mr_widget/components/mr_widget_expandable_section_spec.js
+3
-2
spec/frontend/vue_mr_widget/components/states/commit_edit_spec.js
...ntend/vue_mr_widget/components/states/commit_edit_spec.js
+5
-5
spec/frontend/vue_mr_widget/components/states/mr_widget_commit_message_dropdown_spec.js
...mponents/states/mr_widget_commit_message_dropdown_spec.js
+4
-4
spec/frontend/vue_mr_widget/components/states/mr_widget_commits_header_spec.js
...widget/components/states/mr_widget_commits_header_spec.js
+13
-19
spec/frontend/vue_mr_widget/components/states/mr_widget_conflicts_spec.js
...e_mr_widget/components/states/mr_widget_conflicts_spec.js
+3
-2
spec/frontend/vue_mr_widget/components/states/mr_widget_missing_branch_spec.js
...widget/components/states/mr_widget_missing_branch_spec.js
+3
-2
spec/frontend/vue_mr_widget/components/states/mr_widget_ready_to_merge_spec.js
...widget/components/states/mr_widget_ready_to_merge_spec.js
+1
-1
spec/frontend/vue_mr_widget/components/terraform/mr_widget_terraform_container_spec.js
...omponents/terraform/mr_widget_terraform_container_spec.js
+7
-7
spec/frontend/vue_shared/alert_details/alert_details_spec.js
spec/frontend/vue_shared/alert_details/alert_details_spec.js
+5
-5
spec/frontend/vue_shared/alert_details/alert_management_sidebar_todo_spec.js
...hared/alert_details/alert_management_sidebar_todo_spec.js
+5
-4
spec/frontend/vue_shared/alert_details/alert_metrics_spec.js
spec/frontend/vue_shared/alert_details/alert_metrics_spec.js
+2
-1
spec/frontend/vue_shared/alert_details/alert_status_spec.js
spec/frontend/vue_shared/alert_details/alert_status_spec.js
+2
-1
spec/frontend/vue_shared/alert_details/sidebar/alert_sidebar_assignees_spec.js
...red/alert_details/sidebar/alert_sidebar_assignees_spec.js
+9
-12
spec/frontend/vue_shared/alert_details/sidebar/alert_sidebar_status_spec.js
...shared/alert_details/sidebar/alert_sidebar_status_spec.js
+2
-1
spec/frontend/vue_shared/components/blob_viewers/simple_viewer_spec.js
.../vue_shared/components/blob_viewers/simple_viewer_spec.js
+6
-6
spec/frontend/vue_shared/components/chronic_duration_input_spec.js
...tend/vue_shared/components/chronic_duration_input_spec.js
+13
-12
spec/frontend/vue_shared/components/date_time_picker/date_time_picker_spec.js
...ared/components/date_time_picker/date_time_picker_spec.js
+115
-143
spec/frontend/vue_shared/components/deployment_instance/deployment_instance_spec.js
...omponents/deployment_instance/deployment_instance_spec.js
+12
-17
spec/frontend/vue_shared/components/diff_viewer/viewers/renamed_spec.js
...vue_shared/components/diff_viewer/viewers/renamed_spec.js
+9
-17
spec/frontend/vue_shared/components/dismissible_feedback_alert_spec.js
.../vue_shared/components/dismissible_feedback_alert_spec.js
+2
-1
spec/frontend/vue_shared/components/dropdown/dropdown_search_input_spec.js
..._shared/components/dropdown/dropdown_search_input_spec.js
+4
-4
spec/frontend/vue_shared/components/dropdown/dropdown_widget_spec.js
...nd/vue_shared/components/dropdown/dropdown_widget_spec.js
+3
-2
spec/frontend/vue_shared/components/dropdown_keyboard_navigation_spec.js
...ue_shared/components/dropdown_keyboard_navigation_spec.js
+2
-1
spec/frontend/vue_shared/components/filtered_search_bar/filtered_search_bar_root_spec.js
...ents/filtered_search_bar/filtered_search_bar_root_spec.js
+16
-17
spec/frontend/vue_shared/components/filtered_search_bar/tokens/author_token_spec.js
...omponents/filtered_search_bar/tokens/author_token_spec.js
+13
-13
spec/frontend/vue_shared/components/filtered_search_bar/tokens/base_token_spec.js
.../components/filtered_search_bar/tokens/base_token_spec.js
+3
-2
spec/frontend/vue_shared/components/filtered_search_bar/tokens/branch_token_spec.js
...omponents/filtered_search_bar/tokens/branch_token_spec.js
+3
-2
spec/frontend/vue_shared/components/filtered_search_bar/tokens/emoji_token_spec.js
...components/filtered_search_bar/tokens/emoji_token_spec.js
+5
-4
spec/frontend/vue_shared/components/filtered_search_bar/tokens/label_token_spec.js
...components/filtered_search_bar/tokens/label_token_spec.js
+4
-3
spec/frontend/vue_shared/components/filtered_search_bar/tokens/milestone_token_spec.js
...onents/filtered_search_bar/tokens/milestone_token_spec.js
+5
-4
spec/frontend/vue_shared/components/filtered_search_bar/tokens/release_token_spec.js
...mponents/filtered_search_bar/tokens/release_token_spec.js
+2
-1
spec/frontend/vue_shared/components/local_storage_sync_spec.js
...frontend/vue_shared/components/local_storage_sync_spec.js
+13
-14
spec/frontend/vue_shared/components/markdown/header_spec.js
spec/frontend/vue_shared/components/markdown/header_spec.js
+8
-11
spec/frontend/vue_shared/components/markdown/suggestion_diff_header_spec.js
...shared/components/markdown/suggestion_diff_header_spec.js
+5
-5
spec/frontend/vue_shared/components/modal_copy_button_spec.js
.../frontend/vue_shared/components/modal_copy_button_spec.js
+10
-11
spec/frontend/vue_shared/components/notes/noteable_warning_spec.js
...tend/vue_shared/components/notes/noteable_warning_spec.js
+8
-7
spec/frontend/vue_shared/components/paginated_table_with_search_and_tabs/paginated_table_with_search_and_tabs_spec.js
...rch_and_tabs/paginated_table_with_search_and_tabs_spec.js
+8
-7
spec/frontend/vue_shared/components/project_selector/project_selector_spec.js
...ared/components/project_selector/project_selector_spec.js
+21
-25
spec/frontend/vue_shared/components/registry/list_item_spec.js
...frontend/vue_shared/components/registry/list_item_spec.js
+4
-3
spec/frontend/vue_shared/components/sidebar/collapsed_calendar_icon_spec.js
...shared/components/sidebar/collapsed_calendar_icon_spec.js
+2
-1
spec/frontend/vue_shared/components/sidebar/date_picker_spec.js
...rontend/vue_shared/components/sidebar/date_picker_spec.js
+2
-1
spec/frontend/vue_shared/components/sidebar/issuable_move_dropdown_spec.js
..._shared/components/sidebar/issuable_move_dropdown_spec.js
+12
-11
spec/frontend/vue_shared/components/sidebar/labels_select_vue/dropdown_button_spec.js
...ponents/sidebar/labels_select_vue/dropdown_button_spec.js
+4
-5
spec/frontend/vue_shared/components/sidebar/labels_select_vue/dropdown_contents_create_view_spec.js
...r/labels_select_vue/dropdown_contents_create_view_spec.js
+29
-36
spec/frontend/vue_shared/components/sidebar/labels_select_vue/dropdown_contents_labels_view_spec.js
...r/labels_select_vue/dropdown_contents_labels_view_spec.js
+31
-37
spec/frontend/vue_shared/components/sidebar/labels_select_vue/dropdown_title_spec.js
...mponents/sidebar/labels_select_vue/dropdown_title_spec.js
+4
-5
spec/frontend/vue_shared/components/sidebar/labels_select_vue/dropdown_value_collapsed_spec.js
...idebar/labels_select_vue/dropdown_value_collapsed_spec.js
+2
-1
spec/frontend/vue_shared/components/sidebar/labels_select_vue/labels_select_root_spec.js
...ents/sidebar/labels_select_vue/labels_select_root_spec.js
+15
-18
spec/frontend/vue_shared/components/sidebar/toggle_sidebar_spec.js
...tend/vue_shared/components/sidebar/toggle_sidebar_spec.js
+2
-1
spec/frontend/vue_shared/components/split_button_spec.js
spec/frontend/vue_shared/components/split_button_spec.js
+5
-4
spec/frontend/vue_shared/components/upload_dropzone/upload_dropzone_spec.js
...shared/components/upload_dropzone/upload_dropzone_spec.js
+18
-24
spec/frontend/vue_shared/components/user_avatar/user_avatar_list_spec.js
...ue_shared/components/user_avatar/user_avatar_list_spec.js
+5
-5
spec/frontend/vue_shared/components/web_ide_link_spec.js
spec/frontend/vue_shared/components/web_ide_link_spec.js
+2
-2
spec/frontend/vue_shared/directives/track_event_spec.js
spec/frontend/vue_shared/directives/track_event_spec.js
+5
-6
spec/frontend/vue_shared/issuable/list/components/issuable_item_spec.js
...vue_shared/issuable/list/components/issuable_item_spec.js
+11
-10
spec/frontend/vue_shared/issuable/list/components/issuable_list_root_spec.js
...hared/issuable/list/components/issuable_list_root_spec.js
+8
-7
spec/frontend/vue_shared/issuable/show/components/issuable_body_spec.js
...vue_shared/issuable/show/components/issuable_body_spec.js
+6
-5
spec/frontend/vue_shared/issuable/show/components/issuable_edit_form_spec.js
...hared/issuable/show/components/issuable_edit_form_spec.js
+3
-2
spec/frontend/vue_shared/issuable/show/components/issuable_header_spec.js
...e_shared/issuable/show/components/issuable_header_spec.js
+3
-2
spec/frontend/vue_shared/issuable/show/components/issuable_title_spec.js
...ue_shared/issuable/show/components/issuable_title_spec.js
+3
-2
spec/frontend/vue_shared/issuable/sidebar/components/issuable_sidebar_root_spec.js
...issuable/sidebar/components/issuable_sidebar_root_spec.js
+2
-1
spec/frontend/vue_shared/new_namespace/components/welcome_spec.js
...ntend/vue_shared/new_namespace/components/welcome_spec.js
+2
-3
No files found.
spec/frontend/vue_mr_widget/components/mr_collapsible_extension_spec.js
View file @
b712bfa7
import
{
GlLoadingIcon
,
GlIcon
}
from
'
@gitlab/ui
'
;
import
{
GlLoadingIcon
,
GlIcon
}
from
'
@gitlab/ui
'
;
import
{
mount
}
from
'
@vue/test-utils
'
;
import
{
mount
}
from
'
@vue/test-utils
'
;
import
{
nextTick
}
from
'
vue
'
;
import
MrCollapsibleSection
from
'
~/vue_merge_request_widget/components/mr_collapsible_extension.vue
'
;
import
MrCollapsibleSection
from
'
~/vue_merge_request_widget/components/mr_collapsible_extension.vue
'
;
describe
(
'
Merge Request Collapsible Extension
'
,
()
=>
{
describe
(
'
Merge Request Collapsible Extension
'
,
()
=>
{
...
@@ -46,9 +47,9 @@ describe('Merge Request Collapsible Extension', () => {
...
@@ -46,9 +47,9 @@ describe('Merge Request Collapsible Extension', () => {
});
});
describe
(
'
onClick
'
,
()
=>
{
describe
(
'
onClick
'
,
()
=>
{
beforeEach
(()
=>
{
beforeEach
(
async
()
=>
{
wrapper
.
find
(
'
button
'
).
trigger
(
'
click
'
);
wrapper
.
find
(
'
button
'
).
trigger
(
'
click
'
);
return
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
});
});
it
(
'
rendes the provided slot
'
,
()
=>
{
it
(
'
rendes the provided slot
'
,
()
=>
{
...
...
spec/frontend/vue_mr_widget/components/mr_widget_author_spec.js
View file @
b712bfa7
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
nextTick
}
from
'
vue
'
;
import
MrWidgetAuthor
from
'
~/vue_merge_request_widget/components/mr_widget_author.vue
'
;
import
MrWidgetAuthor
from
'
~/vue_merge_request_widget/components/mr_widget_author.vue
'
;
window
.
gl
=
window
.
gl
||
{};
window
.
gl
=
window
.
gl
||
{};
...
@@ -50,7 +51,7 @@ describe('MrWidgetAuthor', () => {
...
@@ -50,7 +51,7 @@ describe('MrWidgetAuthor', () => {
},
},
});
});
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
expect
(
wrapper
.
find
(
'
img
'
).
attributes
(
'
src
'
)).
toBe
(
'
no_avatar.png
'
);
expect
(
wrapper
.
find
(
'
img
'
).
attributes
(
'
src
'
)).
toBe
(
'
no_avatar.png
'
);
});
});
...
...
spec/frontend/vue_mr_widget/components/mr_widget_expandable_section_spec.js
View file @
b712bfa7
import
{
GlButton
,
GlCollapse
,
GlIcon
}
from
'
@gitlab/ui
'
;
import
{
GlButton
,
GlCollapse
,
GlIcon
}
from
'
@gitlab/ui
'
;
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
nextTick
}
from
'
vue
'
;
import
MrCollapsibleSection
from
'
~/vue_merge_request_widget/components/mr_widget_expandable_section.vue
'
;
import
MrCollapsibleSection
from
'
~/vue_merge_request_widget/components/mr_widget_expandable_section.vue
'
;
describe
(
'
MrWidgetExpanableSection
'
,
()
=>
{
describe
(
'
MrWidgetExpanableSection
'
,
()
=>
{
...
@@ -43,9 +44,9 @@ describe('MrWidgetExpanableSection', () => {
...
@@ -43,9 +44,9 @@ describe('MrWidgetExpanableSection', () => {
});
});
describe
(
'
when collapse section is open
'
,
()
=>
{
describe
(
'
when collapse section is open
'
,
()
=>
{
beforeEach
(()
=>
{
beforeEach
(
async
()
=>
{
findButton
().
vm
.
$emit
(
'
click
'
);
findButton
().
vm
.
$emit
(
'
click
'
);
return
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
});
});
it
(
'
renders button with collapse text
'
,
()
=>
{
it
(
'
renders button with collapse text
'
,
()
=>
{
...
...
spec/frontend/vue_mr_widget/components/states/commit_edit_spec.js
View file @
b712bfa7
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
nextTick
}
from
'
vue
'
;
import
CommitEdit
from
'
~/vue_merge_request_widget/components/states/commit_edit.vue
'
;
import
CommitEdit
from
'
~/vue_merge_request_widget/components/states/commit_edit.vue
'
;
const
testCommitMessage
=
'
Test commit message
'
;
const
testCommitMessage
=
'
Test commit message
'
;
...
@@ -46,18 +47,17 @@ describe('Commits edit component', () => {
...
@@ -46,18 +47,17 @@ describe('Commits edit component', () => {
expect
(
findTextarea
().
element
.
value
).
toBe
(
testCommitMessage
);
expect
(
findTextarea
().
element
.
value
).
toBe
(
testCommitMessage
);
});
});
it
(
'
emits an input event and receives changed value
'
,
()
=>
{
it
(
'
emits an input event and receives changed value
'
,
async
()
=>
{
const
changedCommitMessage
=
'
Changed commit message
'
;
const
changedCommitMessage
=
'
Changed commit message
'
;
findTextarea
().
element
.
value
=
changedCommitMessage
;
findTextarea
().
element
.
value
=
changedCommitMessage
;
findTextarea
().
trigger
(
'
input
'
);
findTextarea
().
trigger
(
'
input
'
);
return
wrapper
.
vm
.
$nextTick
().
then
(()
=>
{
await
nextTick
();
expect
(
wrapper
.
emitted
().
input
[
0
]).
toEqual
([
changedCommitMessage
]);
expect
(
wrapper
.
emitted
().
input
[
0
]).
toEqual
([
changedCommitMessage
]);
expect
(
findTextarea
().
element
.
value
).
toBe
(
changedCommitMessage
);
expect
(
findTextarea
().
element
.
value
).
toBe
(
changedCommitMessage
);
});
});
});
});
});
describe
(
'
when slots are present
'
,
()
=>
{
describe
(
'
when slots are present
'
,
()
=>
{
beforeEach
(()
=>
{
beforeEach
(()
=>
{
...
...
spec/frontend/vue_mr_widget/components/states/mr_widget_commit_message_dropdown_spec.js
View file @
b712bfa7
import
{
GlDropdownItem
}
from
'
@gitlab/ui
'
;
import
{
GlDropdownItem
}
from
'
@gitlab/ui
'
;
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
nextTick
}
from
'
vue
'
;
import
CommitMessageDropdown
from
'
~/vue_merge_request_widget/components/states/commit_message_dropdown.vue
'
;
import
CommitMessageDropdown
from
'
~/vue_merge_request_widget/components/states/commit_message_dropdown.vue
'
;
const
commits
=
[
const
commits
=
[
...
@@ -51,11 +52,10 @@ describe('Commits message dropdown component', () => {
...
@@ -51,11 +52,10 @@ describe('Commits message dropdown component', () => {
expect
(
findFirstDropdownElement
().
text
()).
toContain
(
'
Commit 1
'
);
expect
(
findFirstDropdownElement
().
text
()).
toContain
(
'
Commit 1
'
);
});
});
it
(
'
should emit a commit title on selecting commit
'
,
()
=>
{
it
(
'
should emit a commit title on selecting commit
'
,
async
()
=>
{
findFirstDropdownElement
().
vm
.
$emit
(
'
click
'
);
findFirstDropdownElement
().
vm
.
$emit
(
'
click
'
);
return
wrapper
.
vm
.
$nextTick
().
then
(()
=>
{
await
nextTick
();
expect
(
wrapper
.
emitted
().
input
[
0
]).
toEqual
([
'
Update test.txt
'
]);
expect
(
wrapper
.
emitted
().
input
[
0
]).
toEqual
([
'
Update test.txt
'
]);
});
});
});
});
});
spec/frontend/vue_mr_widget/components/states/mr_widget_commits_header_spec.js
View file @
b712bfa7
import
{
mount
}
from
'
@vue/test-utils
'
;
import
{
mount
}
from
'
@vue/test-utils
'
;
import
{
GlSprintf
}
from
'
@gitlab/ui
'
;
import
{
GlSprintf
}
from
'
@gitlab/ui
'
;
import
{
nextTick
}
from
'
vue
'
;
import
CommitsHeader
from
'
~/vue_merge_request_widget/components/states/commits_header.vue
'
;
import
CommitsHeader
from
'
~/vue_merge_request_widget/components/states/commits_header.vue
'
;
describe
(
'
Commits header component
'
,
()
=>
{
describe
(
'
Commits header component
'
,
()
=>
{
...
@@ -58,16 +59,15 @@ describe('Commits header component', () => {
...
@@ -58,16 +59,15 @@ describe('Commits header component', () => {
expect
(
findCommitToggle
().
attributes
(
'
aria-label
'
)).
toBe
(
'
Expand
'
);
expect
(
findCommitToggle
().
attributes
(
'
aria-label
'
)).
toBe
(
'
Expand
'
);
});
});
it
(
'
has a chevron-right icon
'
,
()
=>
{
it
(
'
has a chevron-right icon
'
,
async
()
=>
{
createComponent
();
createComponent
();
// setData usage is discouraged. See https://gitlab.com/groups/gitlab-org/-/epics/7330 for details
// setData usage is discouraged. See https://gitlab.com/groups/gitlab-org/-/epics/7330 for details
// eslint-disable-next-line no-restricted-syntax
// eslint-disable-next-line no-restricted-syntax
wrapper
.
setData
({
expanded
:
false
});
wrapper
.
setData
({
expanded
:
false
});
return
wrapper
.
vm
.
$nextTick
().
then
(()
=>
{
await
nextTick
();
expect
(
findCommitToggle
().
props
(
'
icon
'
)).
toBe
(
'
chevron-right
'
);
expect
(
findCommitToggle
().
props
(
'
icon
'
)).
toBe
(
'
chevron-right
'
);
});
});
});
describe
(
'
when squash is disabled
'
,
()
=>
{
describe
(
'
when squash is disabled
'
,
()
=>
{
beforeEach
(()
=>
{
beforeEach
(()
=>
{
...
@@ -118,25 +118,19 @@ describe('Commits header component', () => {
...
@@ -118,25 +118,19 @@ describe('Commits header component', () => {
wrapper
.
setData
({
expanded
:
true
});
wrapper
.
setData
({
expanded
:
true
});
});
});
it
(
'
toggle has aria-label equal to collapse
'
,
(
done
)
=>
{
it
(
'
toggle has aria-label equal to collapse
'
,
async
(
)
=>
{
wrapper
.
vm
.
$nextTick
(()
=>
{
await
nextTick
();
expect
(
findCommitToggle
().
attributes
(
'
aria-label
'
)).
toBe
(
'
Collapse
'
);
expect
(
findCommitToggle
().
attributes
(
'
aria-label
'
)).
toBe
(
'
Collapse
'
);
done
();
});
});
});
it
(
'
has a chevron-down icon
'
,
(
done
)
=>
{
it
(
'
has a chevron-down icon
'
,
async
(
)
=>
{
wrapper
.
vm
.
$nextTick
(()
=>
{
await
nextTick
();
expect
(
findCommitToggle
().
props
(
'
icon
'
)).
toBe
(
'
chevron-down
'
);
expect
(
findCommitToggle
().
props
(
'
icon
'
)).
toBe
(
'
chevron-down
'
);
done
();
});
});
});
it
(
'
has a collapse text
'
,
(
done
)
=>
{
it
(
'
has a collapse text
'
,
async
(
)
=>
{
wrapper
.
vm
.
$nextTick
(()
=>
{
await
nextTick
();
expect
(
findHeaderWrapper
().
text
()).
toBe
(
'
Collapse
'
);
expect
(
findHeaderWrapper
().
text
()).
toBe
(
'
Collapse
'
);
done
();
});
});
});
});
});
});
});
spec/frontend/vue_mr_widget/components/states/mr_widget_conflicts_spec.js
View file @
b712bfa7
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
nextTick
}
from
'
vue
'
;
import
{
TEST_HOST
}
from
'
helpers/test_constants
'
;
import
{
TEST_HOST
}
from
'
helpers/test_constants
'
;
import
{
removeBreakLine
}
from
'
helpers/text_helper
'
;
import
{
removeBreakLine
}
from
'
helpers/text_helper
'
;
import
{
extendedWrapper
}
from
'
helpers/vue_test_utils_helper
'
;
import
{
extendedWrapper
}
from
'
helpers/vue_test_utils_helper
'
;
...
@@ -20,7 +21,7 @@ describe('MRWidgetConflicts', () => {
...
@@ -20,7 +21,7 @@ describe('MRWidgetConflicts', () => {
const
resolveConflictsBtnText
=
'
Resolve conflicts
'
;
const
resolveConflictsBtnText
=
'
Resolve conflicts
'
;
const
mergeLocallyBtnText
=
'
Merge locally
'
;
const
mergeLocallyBtnText
=
'
Merge locally
'
;
function
createComponent
(
propsData
=
{})
{
async
function
createComponent
(
propsData
=
{})
{
wrapper
=
extendedWrapper
(
wrapper
=
extendedWrapper
(
shallowMount
(
ConflictsComponent
,
{
shallowMount
(
ConflictsComponent
,
{
propsData
,
propsData
,
...
@@ -55,7 +56,7 @@ describe('MRWidgetConflicts', () => {
...
@@ -55,7 +56,7 @@ describe('MRWidgetConflicts', () => {
});
});
}
}
return
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
}
}
afterEach
(()
=>
{
afterEach
(()
=>
{
...
...
spec/frontend/vue_mr_widget/components/states/mr_widget_missing_branch_spec.js
View file @
b712bfa7
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
nextTick
}
from
'
vue
'
;
import
MissingBranchComponent
from
'
~/vue_merge_request_widget/components/states/mr_widget_missing_branch.vue
'
;
import
MissingBranchComponent
from
'
~/vue_merge_request_widget/components/states/mr_widget_missing_branch.vue
'
;
let
wrapper
;
let
wrapper
;
function
factory
(
sourceBranchRemoved
,
mergeRequestWidgetGraphql
)
{
async
function
factory
(
sourceBranchRemoved
,
mergeRequestWidgetGraphql
)
{
wrapper
=
shallowMount
(
MissingBranchComponent
,
{
wrapper
=
shallowMount
(
MissingBranchComponent
,
{
propsData
:
{
propsData
:
{
mr
:
{
sourceBranchRemoved
},
mr
:
{
sourceBranchRemoved
},
...
@@ -19,7 +20,7 @@ function factory(sourceBranchRemoved, mergeRequestWidgetGraphql) {
...
@@ -19,7 +20,7 @@ function factory(sourceBranchRemoved, mergeRequestWidgetGraphql) {
wrapper
.
setData
({
state
:
{
sourceBranchExists
:
!
sourceBranchRemoved
}
});
wrapper
.
setData
({
state
:
{
sourceBranchExists
:
!
sourceBranchRemoved
}
});
}
}
return
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
}
}
describe
(
'
MRWidgetMissingBranch
'
,
()
=>
{
describe
(
'
MRWidgetMissingBranch
'
,
()
=>
{
...
...
spec/frontend/vue_mr_widget/components/states/mr_widget_ready_to_merge_spec.js
View file @
b712bfa7
...
@@ -710,7 +710,7 @@ describe('ReadyToMerge', () => {
...
@@ -710,7 +710,7 @@ describe('ReadyToMerge', () => {
commitsWithoutMergeCommits
:
{},
commitsWithoutMergeCommits
:
{},
},
},
});
});
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
expect
(
findCommitEditElements
().
length
).
toBe
(
2
);
expect
(
findCommitEditElements
().
length
).
toBe
(
2
);
});
});
...
...
spec/frontend/vue_mr_widget/components/terraform/mr_widget_terraform_container_spec.js
View file @
b712bfa7
import
{
GlDeprecatedSkeletonLoading
as
GlSkeletonLoading
,
GlSprintf
}
from
'
@gitlab/ui
'
;
import
{
GlDeprecatedSkeletonLoading
as
GlSkeletonLoading
,
GlSprintf
}
from
'
@gitlab/ui
'
;
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
MockAdapter
from
'
axios-mock-adapter
'
;
import
MockAdapter
from
'
axios-mock-adapter
'
;
import
{
nextTick
}
from
'
vue
'
;
import
axios
from
'
~/lib/utils/axios_utils
'
;
import
axios
from
'
~/lib/utils/axios_utils
'
;
import
Poll
from
'
~/lib/utils/poll
'
;
import
Poll
from
'
~/lib/utils/poll
'
;
import
MrWidgetExpanableSection
from
'
~/vue_merge_request_widget/components/mr_widget_expandable_section.vue
'
;
import
MrWidgetExpanableSection
from
'
~/vue_merge_request_widget/components/mr_widget_expandable_section.vue
'
;
...
@@ -39,15 +40,14 @@ describe('MrWidgetTerraformConainer', () => {
...
@@ -39,15 +40,14 @@ describe('MrWidgetTerraformConainer', () => {
});
});
describe
(
'
when data is loading
'
,
()
=>
{
describe
(
'
when data is loading
'
,
()
=>
{
beforeEach
(()
=>
{
beforeEach
(
async
()
=>
{
mockPollingApi
(
200
,
plans
,
{});
mockPollingApi
(
200
,
plans
,
{});
return
mountWrapper
().
then
(()
=>
{
await
mountWrapper
();
// setData usage is discouraged. See https://gitlab.com/groups/gitlab-org/-/epics/7330 for details
// setData usage is discouraged. See https://gitlab.com/groups/gitlab-org/-/epics/7330 for details
// eslint-disable-next-line no-restricted-syntax
// eslint-disable-next-line no-restricted-syntax
wrapper
.
setData
({
loading
:
true
});
wrapper
.
setData
({
loading
:
true
});
return
wrapper
.
vm
.
$nextTick
();
await
nextTick
();
});
});
});
it
(
'
diplays loading skeleton
'
,
()
=>
{
it
(
'
diplays loading skeleton
'
,
()
=>
{
...
...
spec/frontend/vue_shared/alert_details/alert_details_spec.js
View file @
b712bfa7
...
@@ -2,6 +2,7 @@ import { GlAlert, GlLoadingIcon } from '@gitlab/ui';
...
@@ -2,6 +2,7 @@ import { GlAlert, GlLoadingIcon } from '@gitlab/ui';
import
{
mount
,
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
mount
,
shallowMount
}
from
'
@vue/test-utils
'
;
import
axios
from
'
axios
'
;
import
axios
from
'
axios
'
;
import
MockAdapter
from
'
axios-mock-adapter
'
;
import
MockAdapter
from
'
axios-mock-adapter
'
;
import
{
nextTick
}
from
'
vue
'
;
import
{
extendedWrapper
}
from
'
helpers/vue_test_utils_helper
'
;
import
{
extendedWrapper
}
from
'
helpers/vue_test_utils_helper
'
;
import
waitForPromises
from
'
helpers/wait_for_promises
'
;
import
waitForPromises
from
'
helpers/wait_for_promises
'
;
import
{
joinPaths
}
from
'
~/lib/utils/url_utility
'
;
import
{
joinPaths
}
from
'
~/lib/utils/url_utility
'
;
...
@@ -216,18 +217,17 @@ describe('AlertDetails', () => {
...
@@ -216,18 +217,17 @@ describe('AlertDetails', () => {
expect
(
findCreateIncidentBtn
().
exists
()).
toBe
(
false
);
expect
(
findCreateIncidentBtn
().
exists
()).
toBe
(
false
);
});
});
it
(
'
should display "Create incident" button when incident doesn
\'
t exist yet
'
,
()
=>
{
it
(
'
should display "Create incident" button when incident doesn
\'
t exist yet
'
,
async
()
=>
{
const
issue
=
null
;
const
issue
=
null
;
mountComponent
({
mountComponent
({
mountMethod
:
mount
,
mountMethod
:
mount
,
data
:
{
alert
:
{
...
mockAlert
,
issue
}
},
data
:
{
alert
:
{
...
mockAlert
,
issue
}
},
});
});
return
wrapper
.
vm
.
$nextTick
().
then
(()
=>
{
await
nextTick
();
expect
(
findViewIncidentBtn
().
exists
()).
toBe
(
false
);
expect
(
findViewIncidentBtn
().
exists
()).
toBe
(
false
);
expect
(
findCreateIncidentBtn
().
exists
()).
toBe
(
true
);
expect
(
findCreateIncidentBtn
().
exists
()).
toBe
(
true
);
});
});
});
it
(
'
calls `$apollo.mutate` with `createIssueQuery`
'
,
()
=>
{
it
(
'
calls `$apollo.mutate` with `createIssueQuery`
'
,
()
=>
{
const
issueIid
=
'
10
'
;
const
issueIid
=
'
10
'
;
...
...
spec/frontend/vue_shared/alert_details/alert_management_sidebar_todo_spec.js
View file @
b712bfa7
import
{
mount
}
from
'
@vue/test-utils
'
;
import
{
mount
}
from
'
@vue/test-utils
'
;
import
{
nextTick
}
from
'
vue
'
;
import
todoMarkDoneMutation
from
'
~/graphql_shared/mutations/todo_mark_done.mutation.graphql
'
;
import
todoMarkDoneMutation
from
'
~/graphql_shared/mutations/todo_mark_done.mutation.graphql
'
;
import
SidebarTodo
from
'
~/vue_shared/alert_details/components/sidebar/sidebar_todo.vue
'
;
import
SidebarTodo
from
'
~/vue_shared/alert_details/components/sidebar/sidebar_todo.vue
'
;
import
createAlertTodoMutation
from
'
~/vue_shared/alert_details/graphql/mutations/alert_todo_create.mutation.graphql
'
;
import
createAlertTodoMutation
from
'
~/vue_shared/alert_details/graphql/mutations/alert_todo_create.mutation.graphql
'
;
...
@@ -57,7 +58,7 @@ describe('Alert Details Sidebar To Do', () => {
...
@@ -57,7 +58,7 @@ describe('Alert Details Sidebar To Do', () => {
});
});
it
(
'
renders a button for adding a To-Do
'
,
async
()
=>
{
it
(
'
renders a button for adding a To-Do
'
,
async
()
=>
{
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
expect
(
findToDoButton
().
text
()).
toBe
(
'
Add a to do
'
);
expect
(
findToDoButton
().
text
()).
toBe
(
'
Add a to do
'
);
});
});
...
@@ -66,7 +67,7 @@ describe('Alert Details Sidebar To Do', () => {
...
@@ -66,7 +67,7 @@ describe('Alert Details Sidebar To Do', () => {
jest
.
spyOn
(
wrapper
.
vm
.
$apollo
,
'
mutate
'
).
mockResolvedValue
(
mockUpdatedMutationResult
);
jest
.
spyOn
(
wrapper
.
vm
.
$apollo
,
'
mutate
'
).
mockResolvedValue
(
mockUpdatedMutationResult
);
findToDoButton
().
trigger
(
'
click
'
);
findToDoButton
().
trigger
(
'
click
'
);
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
expect
(
wrapper
.
vm
.
$apollo
.
mutate
).
toHaveBeenCalledWith
({
expect
(
wrapper
.
vm
.
$apollo
.
mutate
).
toHaveBeenCalledWith
({
mutation
:
createAlertTodoMutation
,
mutation
:
createAlertTodoMutation
,
...
@@ -88,7 +89,7 @@ describe('Alert Details Sidebar To Do', () => {
...
@@ -88,7 +89,7 @@ describe('Alert Details Sidebar To Do', () => {
});
});
it
(
'
renders a Mark As Done button when todo is present
'
,
async
()
=>
{
it
(
'
renders a Mark As Done button when todo is present
'
,
async
()
=>
{
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
expect
(
findToDoButton
().
text
()).
toBe
(
'
Mark as done
'
);
expect
(
findToDoButton
().
text
()).
toBe
(
'
Mark as done
'
);
});
});
...
@@ -97,7 +98,7 @@ describe('Alert Details Sidebar To Do', () => {
...
@@ -97,7 +98,7 @@ describe('Alert Details Sidebar To Do', () => {
jest
.
spyOn
(
wrapper
.
vm
.
$apollo
,
'
mutate
'
).
mockResolvedValue
(
mockUpdatedMutationResult
);
jest
.
spyOn
(
wrapper
.
vm
.
$apollo
,
'
mutate
'
).
mockResolvedValue
(
mockUpdatedMutationResult
);
findToDoButton
().
trigger
(
'
click
'
);
findToDoButton
().
trigger
(
'
click
'
);
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
expect
(
wrapper
.
vm
.
$apollo
.
mutate
).
toHaveBeenCalledWith
({
expect
(
wrapper
.
vm
.
$apollo
.
mutate
).
toHaveBeenCalledWith
({
mutation
:
todoMarkDoneMutation
,
mutation
:
todoMarkDoneMutation
,
...
...
spec/frontend/vue_shared/alert_details/alert_metrics_spec.js
View file @
b712bfa7
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
axios
from
'
axios
'
;
import
axios
from
'
axios
'
;
import
MockAdapter
from
'
axios-mock-adapter
'
;
import
MockAdapter
from
'
axios-mock-adapter
'
;
import
{
nextTick
}
from
'
vue
'
;
import
waitForPromises
from
'
helpers/wait_for_promises
'
;
import
waitForPromises
from
'
helpers/wait_for_promises
'
;
import
MetricEmbed
from
'
~/monitoring/components/embeds/metric_embed.vue
'
;
import
MetricEmbed
from
'
~/monitoring/components/embeds/metric_embed.vue
'
;
import
AlertMetrics
from
'
~/vue_shared/alert_details/components/alert_metrics.vue
'
;
import
AlertMetrics
from
'
~/vue_shared/alert_details/components/alert_metrics.vue
'
;
...
@@ -53,7 +54,7 @@ describe('Alert Metrics', () => {
...
@@ -53,7 +54,7 @@ describe('Alert Metrics', () => {
mountComponent
({
props
:
{
dashboardUrl
:
'
metrics.url
'
}
});
mountComponent
({
props
:
{
dashboardUrl
:
'
metrics.url
'
}
});
await
waitForPromises
();
await
waitForPromises
();
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
expect
(
findEmptyState
().
exists
()).
toBe
(
false
);
expect
(
findEmptyState
().
exists
()).
toBe
(
false
);
expect
(
findChart
().
exists
()).
toBe
(
true
);
expect
(
findChart
().
exists
()).
toBe
(
true
);
...
...
spec/frontend/vue_shared/alert_details/alert_status_spec.js
View file @
b712bfa7
import
{
GlDropdown
,
GlDropdownItem
}
from
'
@gitlab/ui
'
;
import
{
GlDropdown
,
GlDropdownItem
}
from
'
@gitlab/ui
'
;
import
{
nextTick
}
from
'
vue
'
;
import
{
shallowMountExtended
}
from
'
helpers/vue_test_utils_helper
'
;
import
{
shallowMountExtended
}
from
'
helpers/vue_test_utils_helper
'
;
import
waitForPromises
from
'
helpers/wait_for_promises
'
;
import
waitForPromises
from
'
helpers/wait_for_promises
'
;
import
updateAlertStatusMutation
from
'
~/graphql_shared//mutations/alert_status_update.mutation.graphql
'
;
import
updateAlertStatusMutation
from
'
~/graphql_shared//mutations/alert_status_update.mutation.graphql
'
;
...
@@ -121,7 +122,7 @@ describe('AlertManagementStatus', () => {
...
@@ -121,7 +122,7 @@ describe('AlertManagementStatus', () => {
it
(
'
emits an error when triggered a second time
'
,
async
()
=>
{
it
(
'
emits an error when triggered a second time
'
,
async
()
=>
{
await
selectFirstStatusOption
();
await
selectFirstStatusOption
();
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
await
selectFirstStatusOption
();
await
selectFirstStatusOption
();
// Should emit two errors [0,1]
// Should emit two errors [0,1]
expect
(
wrapper
.
emitted
(
'
alert-error
'
).
length
>
1
).
toBe
(
true
);
expect
(
wrapper
.
emitted
(
'
alert-error
'
).
length
>
1
).
toBe
(
true
);
...
...
spec/frontend/vue_shared/alert_details/sidebar/alert_sidebar_assignees_spec.js
View file @
b712bfa7
import
{
GlDropdownItem
}
from
'
@gitlab/ui
'
;
import
{
GlDropdownItem
}
from
'
@gitlab/ui
'
;
import
axios
from
'
axios
'
;
import
axios
from
'
axios
'
;
import
MockAdapter
from
'
axios-mock-adapter
'
;
import
MockAdapter
from
'
axios-mock-adapter
'
;
import
{
nextTick
}
from
'
vue
'
;
import
{
shallowMountExtended
}
from
'
helpers/vue_test_utils_helper
'
;
import
{
shallowMountExtended
}
from
'
helpers/vue_test_utils_helper
'
;
import
SidebarAssignee
from
'
~/vue_shared/alert_details/components/sidebar/sidebar_assignee.vue
'
;
import
SidebarAssignee
from
'
~/vue_shared/alert_details/components/sidebar/sidebar_assignee.vue
'
;
import
SidebarAssignees
from
'
~/vue_shared/alert_details/components/sidebar/sidebar_assignees.vue
'
;
import
SidebarAssignees
from
'
~/vue_shared/alert_details/components/sidebar/sidebar_assignees.vue
'
;
...
@@ -112,7 +113,7 @@ describe('Alert Details Sidebar Assignees', () => {
...
@@ -112,7 +113,7 @@ describe('Alert Details Sidebar Assignees', () => {
// setData usage is discouraged. See https://gitlab.com/groups/gitlab-org/-/epics/7330 for details
// setData usage is discouraged. See https://gitlab.com/groups/gitlab-org/-/epics/7330 for details
// eslint-disable-next-line no-restricted-syntax
// eslint-disable-next-line no-restricted-syntax
wrapper
.
setData
({
isDropdownSearching
:
false
});
wrapper
.
setData
({
isDropdownSearching
:
false
});
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
expect
(
findDropdown
().
text
()).
toBe
(
'
Unassigned
'
);
expect
(
findDropdown
().
text
()).
toBe
(
'
Unassigned
'
);
});
});
...
@@ -126,7 +127,7 @@ describe('Alert Details Sidebar Assignees', () => {
...
@@ -126,7 +127,7 @@ describe('Alert Details Sidebar Assignees', () => {
// eslint-disable-next-line no-restricted-syntax
// eslint-disable-next-line no-restricted-syntax
wrapper
.
setData
({
isDropdownSearching
:
false
});
wrapper
.
setData
({
isDropdownSearching
:
false
});
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
wrapper
.
find
(
SidebarAssignee
).
vm
.
$emit
(
'
update-alert-assignees
'
,
'
root
'
);
wrapper
.
find
(
SidebarAssignee
).
vm
.
$emit
(
'
update-alert-assignees
'
,
'
root
'
);
expect
(
wrapper
.
vm
.
$apollo
.
mutate
).
toHaveBeenCalledWith
({
expect
(
wrapper
.
vm
.
$apollo
.
mutate
).
toHaveBeenCalledWith
({
...
@@ -139,7 +140,7 @@ describe('Alert Details Sidebar Assignees', () => {
...
@@ -139,7 +140,7 @@ describe('Alert Details Sidebar Assignees', () => {
});
});
});
});
it
(
'
emits an error when request contains error messages
'
,
()
=>
{
it
(
'
emits an error when request contains error messages
'
,
async
()
=>
{
// setData usage is discouraged. See https://gitlab.com/groups/gitlab-org/-/epics/7330 for details
// setData usage is discouraged. See https://gitlab.com/groups/gitlab-org/-/epics/7330 for details
// eslint-disable-next-line no-restricted-syntax
// eslint-disable-next-line no-restricted-syntax
wrapper
.
setData
({
isDropdownSearching
:
false
});
wrapper
.
setData
({
isDropdownSearching
:
false
});
...
@@ -153,16 +154,12 @@ describe('Alert Details Sidebar Assignees', () => {
...
@@ -153,16 +154,12 @@ describe('Alert Details Sidebar Assignees', () => {
};
};
jest
.
spyOn
(
wrapper
.
vm
.
$apollo
,
'
mutate
'
).
mockResolvedValue
(
errorMutationResult
);
jest
.
spyOn
(
wrapper
.
vm
.
$apollo
,
'
mutate
'
).
mockResolvedValue
(
errorMutationResult
);
return
wrapper
.
vm
.
$nextTick
()
await
nextTick
();
.
then
(()
=>
{
const
SideBarAssigneeItem
=
wrapper
.
findAll
(
SidebarAssignee
).
at
(
0
);
const
SideBarAssigneeItem
=
wrapper
.
findAll
(
SidebarAssignee
).
at
(
0
);
SideBarAssigneeItem
.
vm
.
$emit
(
'
update-alert-assignees
'
);
await
SideBarAssigneeItem
.
vm
.
$emit
(
'
update-alert-assignees
'
);
})
.
then
(()
=>
{
expect
(
wrapper
.
emitted
(
'
alert-error
'
)).
toBeDefined
();
expect
(
wrapper
.
emitted
(
'
alert-error
'
)).
toBeDefined
();
});
});
});
it
(
'
stops updating and cancels loading when the request fails
'
,
()
=>
{
it
(
'
stops updating and cancels loading when the request fails
'
,
()
=>
{
jest
.
spyOn
(
wrapper
.
vm
.
$apollo
,
'
mutate
'
).
mockReturnValue
(
Promise
.
reject
(
new
Error
()));
jest
.
spyOn
(
wrapper
.
vm
.
$apollo
,
'
mutate
'
).
mockReturnValue
(
Promise
.
reject
(
new
Error
()));
...
...
spec/frontend/vue_shared/alert_details/sidebar/alert_sidebar_status_spec.js
View file @
b712bfa7
import
{
GlDropdown
,
GlLoadingIcon
}
from
'
@gitlab/ui
'
;
import
{
GlDropdown
,
GlLoadingIcon
}
from
'
@gitlab/ui
'
;
import
{
nextTick
}
from
'
vue
'
;
import
{
shallowMountExtended
}
from
'
helpers/vue_test_utils_helper
'
;
import
{
shallowMountExtended
}
from
'
helpers/vue_test_utils_helper
'
;
import
AlertStatus
from
'
~/vue_shared/alert_details/components/alert_status.vue
'
;
import
AlertStatus
from
'
~/vue_shared/alert_details/components/alert_status.vue
'
;
import
AlertSidebarStatus
from
'
~/vue_shared/alert_details/components/sidebar/sidebar_status.vue
'
;
import
AlertSidebarStatus
from
'
~/vue_shared/alert_details/components/sidebar/sidebar_status.vue
'
;
...
@@ -75,7 +76,7 @@ describe('Alert Details Sidebar Status', () => {
...
@@ -75,7 +76,7 @@ describe('Alert Details Sidebar Status', () => {
loading
:
false
,
loading
:
false
,
});
});
findAlertStatus
().
vm
.
$emit
(
'
handle-updating
'
,
true
);
findAlertStatus
().
vm
.
$emit
(
'
handle-updating
'
,
true
);
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
expect
(
findStatusLoadingIcon
().
exists
()).
toBe
(
true
);
expect
(
findStatusLoadingIcon
().
exists
()).
toBe
(
true
);
});
});
...
...
spec/frontend/vue_shared/components/blob_viewers/simple_viewer_spec.js
View file @
b712bfa7
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
nextTick
}
from
'
vue
'
;
import
{
HIGHLIGHT_CLASS_NAME
}
from
'
~/vue_shared/components/blob_viewers/constants
'
;
import
{
HIGHLIGHT_CLASS_NAME
}
from
'
~/vue_shared/components/blob_viewers/constants
'
;
import
SimpleViewer
from
'
~/vue_shared/components/blob_viewers/simple_viewer.vue
'
;
import
SimpleViewer
from
'
~/vue_shared/components/blob_viewers/simple_viewer.vue
'
;
...
@@ -69,7 +70,7 @@ describe('Blob Simple Viewer component', () => {
...
@@ -69,7 +70,7 @@ describe('Blob Simple Viewer component', () => {
expect
(
linetoBeHighlighted
.
classes
()).
toContain
(
HIGHLIGHT_CLASS_NAME
);
expect
(
linetoBeHighlighted
.
classes
()).
toContain
(
HIGHLIGHT_CLASS_NAME
);
});
});
it
(
'
switches highlighting when another line is selected
'
,
()
=>
{
it
(
'
switches highlighting when another line is selected
'
,
async
()
=>
{
const
currentlyHighlighted
=
wrapper
.
find
(
'
#LC2
'
);
const
currentlyHighlighted
=
wrapper
.
find
(
'
#LC2
'
);
const
hash
=
'
#LC3
'
;
const
hash
=
'
#LC3
'
;
const
linetoBeHighlighted
=
wrapper
.
find
(
hash
);
const
linetoBeHighlighted
=
wrapper
.
find
(
hash
);
...
@@ -78,11 +79,10 @@ describe('Blob Simple Viewer component', () => {
...
@@ -78,11 +79,10 @@ describe('Blob Simple Viewer component', () => {
wrapper
.
vm
.
scrollToLine
(
hash
);
wrapper
.
vm
.
scrollToLine
(
hash
);
return
wrapper
.
vm
.
$nextTick
(()
=>
{
await
nextTick
();
expect
(
wrapper
.
vm
.
highlightedLine
).
toBe
(
linetoBeHighlighted
.
element
);
expect
(
wrapper
.
vm
.
highlightedLine
).
toBe
(
linetoBeHighlighted
.
element
);
expect
(
currentlyHighlighted
.
classes
()).
not
.
toContain
(
HIGHLIGHT_CLASS_NAME
);
expect
(
currentlyHighlighted
.
classes
()).
not
.
toContain
(
HIGHLIGHT_CLASS_NAME
);
expect
(
linetoBeHighlighted
.
classes
()).
toContain
(
HIGHLIGHT_CLASS_NAME
);
expect
(
linetoBeHighlighted
.
classes
()).
toContain
(
HIGHLIGHT_CLASS_NAME
);
});
});
});
});
});
});
});
spec/frontend/vue_shared/components/chronic_duration_input_spec.js
View file @
b712bfa7
import
{
mount
}
from
'
@vue/test-utils
'
;
import
{
mount
}
from
'
@vue/test-utils
'
;
import
{
nextTick
}
from
'
vue
'
;
import
ChronicDurationInput
from
'
~/vue_shared/components/chronic_duration_input.vue
'
;
import
ChronicDurationInput
from
'
~/vue_shared/components/chronic_duration_input.vue
'
;
const
MOCK_VALUE
=
2
*
3600
+
20
*
60
;
const
MOCK_VALUE
=
2
*
3600
+
20
*
60
;
...
@@ -48,7 +49,7 @@ describe('vue_shared/components/chronic_duration_input', () => {
...
@@ -48,7 +49,7 @@ describe('vue_shared/components/chronic_duration_input', () => {
describe
(
'
change
'
,
()
=>
{
describe
(
'
change
'
,
()
=>
{
const
createAndDispatch
=
async
(
initialValue
,
humanReadableInput
)
=>
{
const
createAndDispatch
=
async
(
initialValue
,
humanReadableInput
)
=>
{
createComponent
({
value
:
initialValue
});
createComponent
({
value
:
initialValue
});
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
textElement
.
value
=
humanReadableInput
;
textElement
.
value
=
humanReadableInput
;
textElement
.
dispatchEvent
(
new
Event
(
'
input
'
));
textElement
.
dispatchEvent
(
new
Event
(
'
input
'
));
};
};
...
@@ -118,7 +119,7 @@ describe('vue_shared/components/chronic_duration_input', () => {
...
@@ -118,7 +119,7 @@ describe('vue_shared/components/chronic_duration_input', () => {
it
(
'
emits valid with user input
'
,
async
()
=>
{
it
(
'
emits valid with user input
'
,
async
()
=>
{
textElement
.
value
=
'
1m10s
'
;
textElement
.
value
=
'
1m10s
'
;
textElement
.
dispatchEvent
(
new
Event
(
'
input
'
));
textElement
.
dispatchEvent
(
new
Event
(
'
input
'
));
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
expect
(
wrapper
.
emitted
(
'
valid
'
)).
toEqual
([
expect
(
wrapper
.
emitted
(
'
valid
'
)).
toEqual
([
[{
valid
:
true
,
feedback
:
''
}],
[{
valid
:
true
,
feedback
:
''
}],
...
@@ -133,7 +134,7 @@ describe('vue_shared/components/chronic_duration_input', () => {
...
@@ -133,7 +134,7 @@ describe('vue_shared/components/chronic_duration_input', () => {
textElement
.
value
=
''
;
textElement
.
value
=
''
;
textElement
.
dispatchEvent
(
new
Event
(
'
input
'
));
textElement
.
dispatchEvent
(
new
Event
(
'
input
'
));
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
expect
(
wrapper
.
emitted
(
'
valid
'
)).
toEqual
([
expect
(
wrapper
.
emitted
(
'
valid
'
)).
toEqual
([
[{
valid
:
true
,
feedback
:
''
}],
[{
valid
:
true
,
feedback
:
''
}],
...
@@ -151,7 +152,7 @@ describe('vue_shared/components/chronic_duration_input', () => {
...
@@ -151,7 +152,7 @@ describe('vue_shared/components/chronic_duration_input', () => {
it
(
'
emits invalid with user input
'
,
async
()
=>
{
it
(
'
emits invalid with user input
'
,
async
()
=>
{
textElement
.
value
=
'
gobbledygook
'
;
textElement
.
value
=
'
gobbledygook
'
;
textElement
.
dispatchEvent
(
new
Event
(
'
input
'
));
textElement
.
dispatchEvent
(
new
Event
(
'
input
'
));
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
expect
(
wrapper
.
emitted
(
'
valid
'
)).
toEqual
([
expect
(
wrapper
.
emitted
(
'
valid
'
)).
toEqual
([
[{
valid
:
true
,
feedback
:
''
}],
[{
valid
:
true
,
feedback
:
''
}],
...
@@ -186,7 +187,7 @@ describe('vue_shared/components/chronic_duration_input', () => {
...
@@ -186,7 +187,7 @@ describe('vue_shared/components/chronic_duration_input', () => {
it
(
'
emits valid with updated value
'
,
async
()
=>
{
it
(
'
emits valid with updated value
'
,
async
()
=>
{
wrapper
.
setProps
({
value
:
MOCK_VALUE
});
wrapper
.
setProps
({
value
:
MOCK_VALUE
});
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
expect
(
wrapper
.
emitted
(
'
valid
'
)).
toEqual
([
expect
(
wrapper
.
emitted
(
'
valid
'
)).
toEqual
([
[{
valid
:
null
,
feedback
:
''
}],
[{
valid
:
null
,
feedback
:
''
}],
...
@@ -210,7 +211,7 @@ describe('vue_shared/components/chronic_duration_input', () => {
...
@@ -210,7 +211,7 @@ describe('vue_shared/components/chronic_duration_input', () => {
it
(
'
emits valid when input is integer
'
,
async
()
=>
{
it
(
'
emits valid when input is integer
'
,
async
()
=>
{
textElement
.
value
=
'
2hr20min
'
;
textElement
.
value
=
'
2hr20min
'
;
textElement
.
dispatchEvent
(
new
Event
(
'
input
'
));
textElement
.
dispatchEvent
(
new
Event
(
'
input
'
));
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
expect
(
wrapper
.
emitted
(
'
change
'
)).
toEqual
([[
MOCK_VALUE
]]);
expect
(
wrapper
.
emitted
(
'
change
'
)).
toEqual
([[
MOCK_VALUE
]]);
expect
(
wrapper
.
emitted
(
'
valid
'
)).
toEqual
([
expect
(
wrapper
.
emitted
(
'
valid
'
)).
toEqual
([
...
@@ -228,7 +229,7 @@ describe('vue_shared/components/chronic_duration_input', () => {
...
@@ -228,7 +229,7 @@ describe('vue_shared/components/chronic_duration_input', () => {
it
(
'
emits valid when input is decimal
'
,
async
()
=>
{
it
(
'
emits valid when input is decimal
'
,
async
()
=>
{
textElement
.
value
=
'
1.5s
'
;
textElement
.
value
=
'
1.5s
'
;
textElement
.
dispatchEvent
(
new
Event
(
'
input
'
));
textElement
.
dispatchEvent
(
new
Event
(
'
input
'
));
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
expect
(
wrapper
.
emitted
(
'
change
'
)).
toEqual
([[
1.5
]]);
expect
(
wrapper
.
emitted
(
'
change
'
)).
toEqual
([[
1.5
]]);
expect
(
wrapper
.
emitted
(
'
valid
'
)).
toEqual
([
expect
(
wrapper
.
emitted
(
'
valid
'
)).
toEqual
([
...
@@ -252,7 +253,7 @@ describe('vue_shared/components/chronic_duration_input', () => {
...
@@ -252,7 +253,7 @@ describe('vue_shared/components/chronic_duration_input', () => {
it
(
'
emits valid when input is integer
'
,
async
()
=>
{
it
(
'
emits valid when input is integer
'
,
async
()
=>
{
textElement
.
value
=
'
2hr20min
'
;
textElement
.
value
=
'
2hr20min
'
;
textElement
.
dispatchEvent
(
new
Event
(
'
input
'
));
textElement
.
dispatchEvent
(
new
Event
(
'
input
'
));
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
expect
(
wrapper
.
emitted
(
'
change
'
)).
toEqual
([[
MOCK_VALUE
]]);
expect
(
wrapper
.
emitted
(
'
change
'
)).
toEqual
([[
MOCK_VALUE
]]);
expect
(
wrapper
.
emitted
(
'
valid
'
)).
toEqual
([
expect
(
wrapper
.
emitted
(
'
valid
'
)).
toEqual
([
...
@@ -270,7 +271,7 @@ describe('vue_shared/components/chronic_duration_input', () => {
...
@@ -270,7 +271,7 @@ describe('vue_shared/components/chronic_duration_input', () => {
it
(
'
emits invalid when input is decimal
'
,
async
()
=>
{
it
(
'
emits invalid when input is decimal
'
,
async
()
=>
{
textElement
.
value
=
'
1.5s
'
;
textElement
.
value
=
'
1.5s
'
;
textElement
.
dispatchEvent
(
new
Event
(
'
input
'
));
textElement
.
dispatchEvent
(
new
Event
(
'
input
'
));
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
expect
(
wrapper
.
emitted
(
'
change
'
)).
toBeUndefined
();
expect
(
wrapper
.
emitted
(
'
change
'
)).
toBeUndefined
();
expect
(
wrapper
.
emitted
(
'
valid
'
)).
toEqual
([
expect
(
wrapper
.
emitted
(
'
valid
'
)).
toEqual
([
...
@@ -318,7 +319,7 @@ describe('vue_shared/components/chronic_duration_input', () => {
...
@@ -318,7 +319,7 @@ describe('vue_shared/components/chronic_duration_input', () => {
// setData usage is discouraged. See https://gitlab.com/groups/gitlab-org/-/epics/7330 for details
// setData usage is discouraged. See https://gitlab.com/groups/gitlab-org/-/epics/7330 for details
// eslint-disable-next-line no-restricted-syntax
// eslint-disable-next-line no-restricted-syntax
wrapper
.
setData
({
value
:
MOCK_VALUE
});
wrapper
.
setData
({
value
:
MOCK_VALUE
});
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
expect
(
textElement
.
value
).
toBe
(
'
2 hrs 20 mins
'
);
expect
(
textElement
.
value
).
toBe
(
'
2 hrs 20 mins
'
);
expect
(
hiddenElement
.
value
).
toBe
(
MOCK_VALUE
.
toString
());
expect
(
hiddenElement
.
value
).
toBe
(
MOCK_VALUE
.
toString
());
...
@@ -329,7 +330,7 @@ describe('vue_shared/components/chronic_duration_input', () => {
...
@@ -329,7 +330,7 @@ describe('vue_shared/components/chronic_duration_input', () => {
it
(
'
passes user input to parent via v-model
'
,
async
()
=>
{
it
(
'
passes user input to parent via v-model
'
,
async
()
=>
{
textElement
.
value
=
'
2hr20min
'
;
textElement
.
value
=
'
2hr20min
'
;
textElement
.
dispatchEvent
(
new
Event
(
'
input
'
));
textElement
.
dispatchEvent
(
new
Event
(
'
input
'
));
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
expect
(
wrapper
.
findComponent
(
ChronicDurationInput
).
props
(
'
value
'
)).
toBe
(
MOCK_VALUE
);
expect
(
wrapper
.
findComponent
(
ChronicDurationInput
).
props
(
'
value
'
)).
toBe
(
MOCK_VALUE
);
expect
(
textElement
.
value
).
toBe
(
'
2hr20min
'
);
expect
(
textElement
.
value
).
toBe
(
'
2hr20min
'
);
...
@@ -377,7 +378,7 @@ describe('vue_shared/components/chronic_duration_input', () => {
...
@@ -377,7 +378,7 @@ describe('vue_shared/components/chronic_duration_input', () => {
it
(
'
creates form data with user-specified value
'
,
async
()
=>
{
it
(
'
creates form data with user-specified value
'
,
async
()
=>
{
textElement
.
value
=
'
1m10s
'
;
textElement
.
value
=
'
1m10s
'
;
textElement
.
dispatchEvent
(
new
Event
(
'
input
'
));
textElement
.
dispatchEvent
(
new
Event
(
'
input
'
));
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
const
formData
=
new
FormData
(
wrapper
.
find
(
'
[data-testid=myForm]
'
).
element
);
const
formData
=
new
FormData
(
wrapper
.
find
(
'
[data-testid=myForm]
'
).
element
);
const
iter
=
formData
.
entries
();
const
iter
=
formData
.
entries
();
...
...
spec/frontend/vue_shared/components/date_time_picker/date_time_picker_spec.js
View file @
b712bfa7
import
{
mount
}
from
'
@vue/test-utils
'
;
import
{
mount
}
from
'
@vue/test-utils
'
;
import
timezoneMock
from
'
timezone-mock
'
;
import
timezoneMock
from
'
timezone-mock
'
;
import
{
nextTick
}
from
'
vue
'
;
import
DateTimePicker
from
'
~/vue_shared/components/date_time_picker/date_time_picker.vue
'
;
import
DateTimePicker
from
'
~/vue_shared/components/date_time_picker/date_time_picker.vue
'
;
import
{
import
{
defaultTimeRanges
,
defaultTimeRanges
,
...
@@ -29,27 +30,24 @@ describe('DateTimePicker', () => {
...
@@ -29,27 +30,24 @@ describe('DateTimePicker', () => {
wrapper
.
destroy
();
wrapper
.
destroy
();
});
});
it
(
'
renders dropdown toggle button with selected text
'
,
()
=>
{
it
(
'
renders dropdown toggle button with selected text
'
,
async
()
=>
{
createComponent
();
createComponent
();
return
wrapper
.
vm
.
$nextTick
(()
=>
{
await
nextTick
();
expect
(
dropdownToggle
().
text
()).
toBe
(
defaultTimeRange
.
label
);
expect
(
dropdownToggle
().
text
()).
toBe
(
defaultTimeRange
.
label
);
});
});
});
it
(
'
renders dropdown toggle button with selected text and utc label
'
,
()
=>
{
it
(
'
renders dropdown toggle button with selected text and utc label
'
,
async
()
=>
{
createComponent
({
utc
:
true
});
createComponent
({
utc
:
true
});
return
wrapper
.
vm
.
$nextTick
(()
=>
{
await
nextTick
();
expect
(
dropdownToggle
().
text
()).
toContain
(
defaultTimeRange
.
label
);
expect
(
dropdownToggle
().
text
()).
toContain
(
defaultTimeRange
.
label
);
expect
(
dropdownToggle
().
text
()).
toContain
(
'
UTC
'
);
expect
(
dropdownToggle
().
text
()).
toContain
(
'
UTC
'
);
});
});
});
it
(
'
renders dropdown with 2 custom time range inputs
'
,
()
=>
{
it
(
'
renders dropdown with 2 custom time range inputs
'
,
async
()
=>
{
createComponent
();
createComponent
();
return
wrapper
.
vm
.
$nextTick
(()
=>
{
await
nextTick
();
expect
(
wrapper
.
findAll
(
'
input
'
).
length
).
toBe
(
2
);
expect
(
wrapper
.
findAll
(
'
input
'
).
length
).
toBe
(
2
);
});
});
});
describe
(
'
renders label with h/m/s truncated if possible
'
,
()
=>
{
describe
(
'
renders label with h/m/s truncated if possible
'
,
()
=>
{
[
[
...
@@ -80,34 +78,31 @@ describe('DateTimePicker', () => {
...
@@ -80,34 +78,31 @@ describe('DateTimePicker', () => {
label
:
'
2019-10-10 00:00:01 to 2019-10-10 00:00:01 UTC
'
,
label
:
'
2019-10-10 00:00:01 to 2019-10-10 00:00:01 UTC
'
,
},
},
].
forEach
(({
start
,
end
,
utc
,
label
})
=>
{
].
forEach
(({
start
,
end
,
utc
,
label
})
=>
{
it
(
`for start
${
start
}
, end
${
end
}
, and utc
${
utc
}
, label is
${
label
}
`
,
()
=>
{
it
(
`for start
${
start
}
, end
${
end
}
, and utc
${
utc
}
, label is
${
label
}
`
,
async
()
=>
{
createComponent
({
createComponent
({
value
:
{
start
,
end
},
value
:
{
start
,
end
},
utc
,
utc
,
});
});
return
wrapper
.
vm
.
$nextTick
(()
=>
{
await
nextTick
();
expect
(
dropdownToggle
().
text
()).
toBe
(
label
);
expect
(
dropdownToggle
().
text
()).
toBe
(
label
);
});
});
});
});
});
});
});
it
(
`renders dropdown with
${
optionsCount
}
(default) items in quick range`
,
()
=>
{
it
(
`renders dropdown with
${
optionsCount
}
(default) items in quick range`
,
async
()
=>
{
createComponent
();
createComponent
();
dropdownToggle
().
trigger
(
'
click
'
);
dropdownToggle
().
trigger
(
'
click
'
);
return
wrapper
.
vm
.
$nextTick
(()
=>
{
await
nextTick
();
expect
(
findQuickRangeItems
().
length
).
toBe
(
optionsCount
);
expect
(
findQuickRangeItems
().
length
).
toBe
(
optionsCount
);
});
});
});
it
(
'
renders dropdown with a default quick range item selected
'
,
()
=>
{
it
(
'
renders dropdown with a default quick range item selected
'
,
async
()
=>
{
createComponent
();
createComponent
();
dropdownToggle
().
trigger
(
'
click
'
);
dropdownToggle
().
trigger
(
'
click
'
);
return
wrapper
.
vm
.
$nextTick
(()
=>
{
await
nextTick
();
expect
(
wrapper
.
find
(
'
.dropdown-item.active
'
).
exists
()).
toBe
(
true
);
expect
(
wrapper
.
find
(
'
.dropdown-item.active
'
).
exists
()).
toBe
(
true
);
expect
(
wrapper
.
find
(
'
.dropdown-item.active
'
).
text
()).
toBe
(
defaultTimeRange
.
label
);
expect
(
wrapper
.
find
(
'
.dropdown-item.active
'
).
text
()).
toBe
(
defaultTimeRange
.
label
);
});
});
});
it
(
'
renders a disabled apply button on wrong input
'
,
()
=>
{
it
(
'
renders a disabled apply button on wrong input
'
,
()
=>
{
createComponent
({
createComponent
({
...
@@ -118,48 +113,40 @@ describe('DateTimePicker', () => {
...
@@ -118,48 +113,40 @@ describe('DateTimePicker', () => {
});
});
describe
(
'
user input
'
,
()
=>
{
describe
(
'
user input
'
,
()
=>
{
const
fillInputAndBlur
=
(
input
,
val
)
=>
{
const
fillInputAndBlur
=
async
(
input
,
val
)
=>
{
wrapper
.
find
(
input
).
setValue
(
val
);
wrapper
.
find
(
input
).
setValue
(
val
);
return
wrapper
.
vm
.
$nextTick
().
then
(()
=>
{
await
nextTick
();
wrapper
.
find
(
input
).
trigger
(
'
blur
'
);
wrapper
.
find
(
input
).
trigger
(
'
blur
'
);
return
wrapper
.
vm
.
$nextTick
();
await
nextTick
();
});
};
};
beforeEach
(()
=>
{
beforeEach
(
async
()
=>
{
createComponent
();
createComponent
();
return
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
});
});
it
(
'
displays inline error message if custom time range inputs are invalid
'
,
()
=>
{
it
(
'
displays inline error message if custom time range inputs are invalid
'
,
async
()
=>
{
return
fillInputAndBlur
(
'
#custom-time-from
'
,
'
2019-10-01abc
'
)
await
fillInputAndBlur
(
'
#custom-time-from
'
,
'
2019-10-01abc
'
);
.
then
(()
=>
fillInputAndBlur
(
'
#custom-time-to
'
,
'
2019-10-10abc
'
))
await
fillInputAndBlur
(
'
#custom-time-to
'
,
'
2019-10-10abc
'
);
.
then
(()
=>
{
expect
(
wrapper
.
findAll
(
'
.invalid-feedback
'
).
length
).
toBe
(
2
);
expect
(
wrapper
.
findAll
(
'
.invalid-feedback
'
).
length
).
toBe
(
2
);
});
});
});
it
(
'
keeps apply button disabled with invalid custom time range inputs
'
,
()
=>
{
it
(
'
keeps apply button disabled with invalid custom time range inputs
'
,
async
()
=>
{
return
fillInputAndBlur
(
'
#custom-time-from
'
,
'
2019-10-01abc
'
)
await
fillInputAndBlur
(
'
#custom-time-from
'
,
'
2019-10-01abc
'
);
.
then
(()
=>
fillInputAndBlur
(
'
#custom-time-to
'
,
'
2019-09-19
'
))
await
fillInputAndBlur
(
'
#custom-time-to
'
,
'
2019-09-19
'
);
.
then
(()
=>
{
expect
(
applyButtonElement
().
getAttribute
(
'
disabled
'
)).
toBe
(
'
disabled
'
);
expect
(
applyButtonElement
().
getAttribute
(
'
disabled
'
)).
toBe
(
'
disabled
'
);
});
});
});
it
(
'
enables apply button with valid custom time range inputs
'
,
()
=>
{
it
(
'
enables apply button with valid custom time range inputs
'
,
async
()
=>
{
return
fillInputAndBlur
(
'
#custom-time-from
'
,
'
2019-10-01
'
)
await
fillInputAndBlur
(
'
#custom-time-from
'
,
'
2019-10-01
'
);
.
then
(()
=>
fillInputAndBlur
(
'
#custom-time-to
'
,
'
2019-10-19
'
))
await
fillInputAndBlur
(
'
#custom-time-to
'
,
'
2019-10-19
'
);
.
then
(()
=>
{
expect
(
applyButtonElement
().
getAttribute
(
'
disabled
'
)).
toBeNull
();
expect
(
applyButtonElement
().
getAttribute
(
'
disabled
'
)).
toBeNull
();
});
});
});
describe
(
'
when "apply" is clicked
'
,
()
=>
{
describe
(
'
when "apply" is clicked
'
,
()
=>
{
it
(
'
emits iso dates
'
,
()
=>
{
it
(
'
emits iso dates
'
,
async
()
=>
{
return
fillInputAndBlur
(
'
#custom-time-from
'
,
'
2019-10-01 00:00:00
'
)
await
fillInputAndBlur
(
'
#custom-time-from
'
,
'
2019-10-01 00:00:00
'
);
.
then
(()
=>
fillInputAndBlur
(
'
#custom-time-to
'
,
'
2019-10-19 00:00:00
'
))
await
fillInputAndBlur
(
'
#custom-time-to
'
,
'
2019-10-19 00:00:00
'
);
.
then
(()
=>
{
applyButtonElement
().
click
();
applyButtonElement
().
click
();
expect
(
wrapper
.
emitted
().
input
).
toHaveLength
(
1
);
expect
(
wrapper
.
emitted
().
input
).
toHaveLength
(
1
);
...
@@ -170,12 +157,10 @@ describe('DateTimePicker', () => {
...
@@ -170,12 +157,10 @@ describe('DateTimePicker', () => {
},
},
]);
]);
});
});
});
it
(
'
emits iso dates, for dates without time of day
'
,
()
=>
{
it
(
'
emits iso dates, for dates without time of day
'
,
async
()
=>
{
return
fillInputAndBlur
(
'
#custom-time-from
'
,
'
2019-10-01
'
)
await
fillInputAndBlur
(
'
#custom-time-from
'
,
'
2019-10-01
'
);
.
then
(()
=>
fillInputAndBlur
(
'
#custom-time-to
'
,
'
2019-10-19
'
))
await
fillInputAndBlur
(
'
#custom-time-to
'
,
'
2019-10-19
'
);
.
then
(()
=>
{
applyButtonElement
().
click
();
applyButtonElement
().
click
();
expect
(
wrapper
.
emitted
().
input
).
toHaveLength
(
1
);
expect
(
wrapper
.
emitted
().
input
).
toHaveLength
(
1
);
...
@@ -186,7 +171,6 @@ describe('DateTimePicker', () => {
...
@@ -186,7 +171,6 @@ describe('DateTimePicker', () => {
},
},
]);
]);
});
});
});
describe
(
'
when timezone is different
'
,
()
=>
{
describe
(
'
when timezone is different
'
,
()
=>
{
beforeAll
(()
=>
{
beforeAll
(()
=>
{
...
@@ -196,10 +180,9 @@ describe('DateTimePicker', () => {
...
@@ -196,10 +180,9 @@ describe('DateTimePicker', () => {
timezoneMock
.
unregister
();
timezoneMock
.
unregister
();
});
});
it
(
'
emits iso dates
'
,
()
=>
{
it
(
'
emits iso dates
'
,
async
()
=>
{
return
fillInputAndBlur
(
'
#custom-time-from
'
,
'
2019-10-01 00:00:00
'
)
await
fillInputAndBlur
(
'
#custom-time-from
'
,
'
2019-10-01 00:00:00
'
);
.
then
(()
=>
fillInputAndBlur
(
'
#custom-time-to
'
,
'
2019-10-19 12:00:00
'
))
await
fillInputAndBlur
(
'
#custom-time-to
'
,
'
2019-10-19 12:00:00
'
);
.
then
(()
=>
{
applyButtonElement
().
click
();
applyButtonElement
().
click
();
expect
(
wrapper
.
emitted
().
input
).
toHaveLength
(
1
);
expect
(
wrapper
.
emitted
().
input
).
toHaveLength
(
1
);
...
@@ -210,15 +193,12 @@ describe('DateTimePicker', () => {
...
@@ -210,15 +193,12 @@ describe('DateTimePicker', () => {
},
},
]);
]);
});
});
});
it
(
'
emits iso dates with utc format
'
,
()
=>
{
it
(
'
emits iso dates with utc format
'
,
async
()
=>
{
wrapper
.
setProps
({
utc
:
true
});
wrapper
.
setProps
({
utc
:
true
});
return
wrapper
.
vm
await
nextTick
();
.
$nextTick
()
await
fillInputAndBlur
(
'
#custom-time-from
'
,
'
2019-10-01 00:00:00
'
);
.
then
(()
=>
fillInputAndBlur
(
'
#custom-time-from
'
,
'
2019-10-01 00:00:00
'
))
await
fillInputAndBlur
(
'
#custom-time-to
'
,
'
2019-10-19 12:00:00
'
);
.
then
(()
=>
fillInputAndBlur
(
'
#custom-time-to
'
,
'
2019-10-19 12:00:00
'
))
.
then
(()
=>
{
applyButtonElement
().
click
();
applyButtonElement
().
click
();
expect
(
wrapper
.
emitted
().
input
).
toHaveLength
(
1
);
expect
(
wrapper
.
emitted
().
input
).
toHaveLength
(
1
);
...
@@ -231,18 +211,16 @@ describe('DateTimePicker', () => {
...
@@ -231,18 +211,16 @@ describe('DateTimePicker', () => {
});
});
});
});
});
});
});
it
(
'
unchecks quick range when text is input is clicked
'
,
()
=>
{
it
(
'
unchecks quick range when text is input is clicked
'
,
async
()
=>
{
const
findActiveItems
=
()
=>
const
findActiveItems
=
()
=>
findQuickRangeItems
().
filter
((
w
)
=>
w
.
classes
().
includes
(
'
active
'
));
findQuickRangeItems
().
filter
((
w
)
=>
w
.
classes
().
includes
(
'
active
'
));
expect
(
findActiveItems
().
length
).
toBe
(
1
);
expect
(
findActiveItems
().
length
).
toBe
(
1
);
return
fillInputAndBlur
(
'
#custom-time-from
'
,
'
2019-10-01
'
).
then
(()
=>
{
await
fillInputAndBlur
(
'
#custom-time-from
'
,
'
2019-10-01
'
);
expect
(
findActiveItems
().
length
).
toBe
(
0
);
expect
(
findActiveItems
().
length
).
toBe
(
0
);
});
});
});
it
(
'
emits dates in an object when a is clicked
'
,
()
=>
{
it
(
'
emits dates in an object when a is clicked
'
,
()
=>
{
findQuickRangeItems
()
findQuickRangeItems
()
...
@@ -257,18 +235,16 @@ describe('DateTimePicker', () => {
...
@@ -257,18 +235,16 @@ describe('DateTimePicker', () => {
});
});
});
});
it
(
'
hides the popover with cancel button
'
,
()
=>
{
it
(
'
hides the popover with cancel button
'
,
async
()
=>
{
dropdownToggle
().
trigger
(
'
click
'
);
dropdownToggle
().
trigger
(
'
click
'
);
return
wrapper
.
vm
.
$nextTick
(()
=>
{
await
nextTick
();
cancelButton
().
trigger
(
'
click
'
);
cancelButton
().
trigger
(
'
click
'
);
return
wrapper
.
vm
.
$nextTick
(()
=>
{
await
nextTick
();
expect
(
dropdownMenu
().
classes
(
'
show
'
)).
toBe
(
false
);
expect
(
dropdownMenu
().
classes
(
'
show
'
)).
toBe
(
false
);
});
});
});
});
});
});
describe
(
'
when using non-default time windows
'
,
()
=>
{
describe
(
'
when using non-default time windows
'
,
()
=>
{
const
MOCK_NOW
=
Date
.
UTC
(
2020
,
0
,
23
,
20
);
const
MOCK_NOW
=
Date
.
UTC
(
2020
,
0
,
23
,
20
);
...
@@ -293,7 +269,7 @@ describe('DateTimePicker', () => {
...
@@ -293,7 +269,7 @@ describe('DateTimePicker', () => {
jest
.
spyOn
(
Date
,
'
now
'
).
mockImplementation
(()
=>
MOCK_NOW
);
jest
.
spyOn
(
Date
,
'
now
'
).
mockImplementation
(()
=>
MOCK_NOW
);
});
});
it
(
'
renders dropdown with a label in the quick range
'
,
()
=>
{
it
(
'
renders dropdown with a label in the quick range
'
,
async
()
=>
{
createComponent
({
createComponent
({
value
:
{
value
:
{
duration
:
{
seconds
:
60
*
5
},
duration
:
{
seconds
:
60
*
5
},
...
@@ -301,12 +277,11 @@ describe('DateTimePicker', () => {
...
@@ -301,12 +277,11 @@ describe('DateTimePicker', () => {
options
:
otherTimeRanges
,
options
:
otherTimeRanges
,
});
});
dropdownToggle
().
trigger
(
'
click
'
);
dropdownToggle
().
trigger
(
'
click
'
);
return
wrapper
.
vm
.
$nextTick
(()
=>
{
await
nextTick
();
expect
(
dropdownToggle
().
text
()).
toBe
(
'
5 minutes
'
);
expect
(
dropdownToggle
().
text
()).
toBe
(
'
5 minutes
'
);
});
});
});
it
(
'
renders dropdown with a label in the quick range and utc label
'
,
()
=>
{
it
(
'
renders dropdown with a label in the quick range and utc label
'
,
async
()
=>
{
createComponent
({
createComponent
({
value
:
{
value
:
{
duration
:
{
seconds
:
60
*
5
},
duration
:
{
seconds
:
60
*
5
},
...
@@ -315,12 +290,11 @@ describe('DateTimePicker', () => {
...
@@ -315,12 +290,11 @@ describe('DateTimePicker', () => {
options
:
otherTimeRanges
,
options
:
otherTimeRanges
,
});
});
dropdownToggle
().
trigger
(
'
click
'
);
dropdownToggle
().
trigger
(
'
click
'
);
return
wrapper
.
vm
.
$nextTick
(()
=>
{
await
nextTick
();
expect
(
dropdownToggle
().
text
()).
toBe
(
'
5 minutes UTC
'
);
expect
(
dropdownToggle
().
text
()).
toBe
(
'
5 minutes UTC
'
);
});
});
});
it
(
'
renders dropdown with quick range items
'
,
()
=>
{
it
(
'
renders dropdown with quick range items
'
,
async
()
=>
{
createComponent
({
createComponent
({
value
:
{
value
:
{
duration
:
{
seconds
:
60
*
2
},
duration
:
{
seconds
:
60
*
2
},
...
@@ -328,7 +302,7 @@ describe('DateTimePicker', () => {
...
@@ -328,7 +302,7 @@ describe('DateTimePicker', () => {
options
:
otherTimeRanges
,
options
:
otherTimeRanges
,
});
});
dropdownToggle
().
trigger
(
'
click
'
);
dropdownToggle
().
trigger
(
'
click
'
);
return
wrapper
.
vm
.
$nextTick
(()
=>
{
await
nextTick
();
const
items
=
findQuickRangeItems
();
const
items
=
findQuickRangeItems
();
expect
(
items
.
length
).
toBe
(
Object
.
keys
(
otherTimeRanges
).
length
);
expect
(
items
.
length
).
toBe
(
Object
.
keys
(
otherTimeRanges
).
length
);
...
@@ -341,18 +315,16 @@ describe('DateTimePicker', () => {
...
@@ -341,18 +315,16 @@ describe('DateTimePicker', () => {
expect
(
items
.
at
(
2
).
text
()).
toBe
(
'
5 minutes
'
);
expect
(
items
.
at
(
2
).
text
()).
toBe
(
'
5 minutes
'
);
expect
(
items
.
at
(
2
).
classes
()).
not
.
toContain
(
'
active
'
);
expect
(
items
.
at
(
2
).
classes
()).
not
.
toContain
(
'
active
'
);
});
});
});
it
(
'
renders dropdown with a label not in the quick range
'
,
()
=>
{
it
(
'
renders dropdown with a label not in the quick range
'
,
async
()
=>
{
createComponent
({
createComponent
({
value
:
{
value
:
{
duration
:
{
seconds
:
60
*
4
},
duration
:
{
seconds
:
60
*
4
},
},
},
});
});
dropdownToggle
().
trigger
(
'
click
'
);
dropdownToggle
().
trigger
(
'
click
'
);
return
wrapper
.
vm
.
$nextTick
(()
=>
{
await
nextTick
();
expect
(
dropdownToggle
().
text
()).
toBe
(
'
2020-01-23 19:56:00 to 2020-01-23 20:00:00
'
);
expect
(
dropdownToggle
().
text
()).
toBe
(
'
2020-01-23 19:56:00 to 2020-01-23 20:00:00
'
);
});
});
});
});
});
});
});
spec/frontend/vue_shared/components/deployment_instance/deployment_instance_spec.js
View file @
b712bfa7
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
nextTick
}
from
'
vue
'
;
import
DeployBoardInstance
from
'
~/vue_shared/components/deployment_instance.vue
'
;
import
DeployBoardInstance
from
'
~/vue_shared/components/deployment_instance.vue
'
;
import
{
folder
}
from
'
./mock_data
'
;
import
{
folder
}
from
'
./mock_data
'
;
...
@@ -28,17 +29,15 @@ describe('Deploy Board Instance', () => {
...
@@ -28,17 +29,15 @@ describe('Deploy Board Instance', () => {
expect
(
wrapper
.
attributes
(
'
title
'
)).
toEqual
(
'
This is a pod
'
);
expect
(
wrapper
.
attributes
(
'
title
'
)).
toEqual
(
'
This is a pod
'
);
});
});
it
(
'
should render a div without tooltip data
'
,
(
done
)
=>
{
it
(
'
should render a div without tooltip data
'
,
async
(
)
=>
{
wrapper
=
createComponent
({
wrapper
=
createComponent
({
status
:
'
deploying
'
,
status
:
'
deploying
'
,
tooltipText
:
''
,
tooltipText
:
''
,
});
});
wrapper
.
vm
.
$nextTick
(()
=>
{
await
nextTick
();
expect
(
wrapper
.
classes
(
'
deployment-instance-deploying
'
)).
toBe
(
true
);
expect
(
wrapper
.
classes
(
'
deployment-instance-deploying
'
)).
toBe
(
true
);
expect
(
wrapper
.
attributes
(
'
title
'
)).
toEqual
(
''
);
expect
(
wrapper
.
attributes
(
'
title
'
)).
toEqual
(
''
);
done
();
});
});
});
it
(
'
should have a log path computed with a pod name as a parameter
'
,
()
=>
{
it
(
'
should have a log path computed with a pod name as a parameter
'
,
()
=>
{
...
@@ -58,15 +57,13 @@ describe('Deploy Board Instance', () => {
...
@@ -58,15 +57,13 @@ describe('Deploy Board Instance', () => {
wrapper
.
destroy
();
wrapper
.
destroy
();
});
});
it
(
'
should render a div with canary class when stable prop is provided as false
'
,
(
done
)
=>
{
it
(
'
should render a div with canary class when stable prop is provided as false
'
,
async
(
)
=>
{
wrapper
=
createComponent
({
wrapper
=
createComponent
({
stable
:
false
,
stable
:
false
,
});
});
wrapper
.
vm
.
$nextTick
(()
=>
{
await
nextTick
();
expect
(
wrapper
.
classes
(
'
deployment-instance-canary
'
)).
toBe
(
true
);
expect
(
wrapper
.
classes
(
'
deployment-instance-canary
'
)).
toBe
(
true
);
done
();
});
});
});
});
});
...
@@ -75,17 +72,15 @@ describe('Deploy Board Instance', () => {
...
@@ -75,17 +72,15 @@ describe('Deploy Board Instance', () => {
wrapper
.
destroy
();
wrapper
.
destroy
();
});
});
it
(
'
should not be a link without a logsPath prop
'
,
(
done
)
=>
{
it
(
'
should not be a link without a logsPath prop
'
,
async
(
)
=>
{
wrapper
=
createComponent
({
wrapper
=
createComponent
({
stable
:
false
,
stable
:
false
,
logsPath
:
''
,
logsPath
:
''
,
});
});
wrapper
.
vm
.
$nextTick
(()
=>
{
await
nextTick
();
expect
(
wrapper
.
vm
.
computedLogPath
).
toBeNull
();
expect
(
wrapper
.
vm
.
computedLogPath
).
toBeNull
();
expect
(
wrapper
.
vm
.
isLink
).
toBeFalsy
();
expect
(
wrapper
.
vm
.
isLink
).
toBeFalsy
();
done
();
});
});
});
it
(
'
should render a link without href if path is not passed
'
,
()
=>
{
it
(
'
should render a link without href if path is not passed
'
,
()
=>
{
...
...
spec/frontend/vue_shared/components/diff_viewer/viewers/renamed_spec.js
View file @
b712bfa7
import
{
shallowMount
,
mount
}
from
'
@vue/test-utils
'
;
import
{
shallowMount
,
mount
}
from
'
@vue/test-utils
'
;
import
Vue
from
'
vue
'
;
import
Vue
,
{
nextTick
}
from
'
vue
'
;
import
Vuex
from
'
vuex
'
;
import
Vuex
from
'
vuex
'
;
import
{
import
{
TRANSITION_LOAD_START
,
TRANSITION_LOAD_START
,
...
@@ -126,17 +126,16 @@ describe('Renamed Diff Viewer', () => {
...
@@ -126,17 +126,16 @@ describe('Renamed Diff Viewer', () => {
store
=
null
;
store
=
null
;
});
});
it
(
'
calls the switchToFullDiffFromRenamedFile action when the method is triggered
'
,
()
=>
{
it
(
'
calls the switchToFullDiffFromRenamedFile action when the method is triggered
'
,
async
()
=>
{
store
.
dispatch
.
mockResolvedValue
();
store
.
dispatch
.
mockResolvedValue
();
wrapper
.
vm
.
switchToFull
();
wrapper
.
vm
.
switchToFull
();
return
wrapper
.
vm
.
$nextTick
().
then
(()
=>
{
await
nextTick
();
expect
(
store
.
dispatch
).
toHaveBeenCalledWith
(
'
diffs/switchToFullDiffFromRenamedFile
'
,
{
expect
(
store
.
dispatch
).
toHaveBeenCalledWith
(
'
diffs/switchToFullDiffFromRenamedFile
'
,
{
diffFile
,
diffFile
,
});
});
});
});
});
it
.
each
`
it
.
each
`
after | resolvePromise | resolution
after | resolvePromise | resolution
...
@@ -144,7 +143,7 @@ describe('Renamed Diff Viewer', () => {
...
@@ -144,7 +143,7 @@ describe('Renamed Diff Viewer', () => {
${
STATE_ERRORED
}
|
${
'
mockRejectedValue
'
}
|
${
'
rejected
'
}
${
STATE_ERRORED
}
|
${
'
mockRejectedValue
'
}
|
${
'
rejected
'
}
`
(
`
(
'
moves through the correct states during a $resolution request
'
,
'
moves through the correct states during a $resolution request
'
,
({
after
,
resolvePromise
})
=>
{
async
({
after
,
resolvePromise
})
=>
{
store
.
dispatch
[
resolvePromise
]();
store
.
dispatch
[
resolvePromise
]();
expect
(
wrapper
.
vm
.
state
).
toEqual
(
STATE_IDLING
);
expect
(
wrapper
.
vm
.
state
).
toEqual
(
STATE_IDLING
);
...
@@ -153,16 +152,9 @@ describe('Renamed Diff Viewer', () => {
...
@@ -153,16 +152,9 @@ describe('Renamed Diff Viewer', () => {
expect
(
wrapper
.
vm
.
state
).
toEqual
(
STATE_LOADING
);
expect
(
wrapper
.
vm
.
state
).
toEqual
(
STATE_LOADING
);
return
(
await
nextTick
();
// This tick is needed for when the action (promise) finishes
wrapper
.
vm
await
nextTick
();
// This tick waits for the state change in the promise .then/.catch to bubble into the component
// This tick is needed for when the action (promise) finishes
.
$nextTick
()
// This tick waits for the state change in the promise .then/.catch to bubble into the component
.
then
(()
=>
wrapper
.
vm
.
$nextTick
())
.
then
(()
=>
{
expect
(
wrapper
.
vm
.
state
).
toEqual
(
after
);
expect
(
wrapper
.
vm
.
state
).
toEqual
(
after
);
})
);
},
},
);
);
});
});
...
...
spec/frontend/vue_shared/components/dismissible_feedback_alert_spec.js
View file @
b712bfa7
import
{
GlAlert
,
GlSprintf
}
from
'
@gitlab/ui
'
;
import
{
GlAlert
,
GlSprintf
}
from
'
@gitlab/ui
'
;
import
{
mount
,
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
mount
,
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
nextTick
}
from
'
vue
'
;
import
{
useLocalStorageSpy
}
from
'
helpers/local_storage_helper
'
;
import
{
useLocalStorageSpy
}
from
'
helpers/local_storage_helper
'
;
import
Component
from
'
~/vue_shared/components/dismissible_feedback_alert.vue
'
;
import
Component
from
'
~/vue_shared/components/dismissible_feedback_alert.vue
'
;
...
@@ -64,7 +65,7 @@ describe('Dismissible Feedback Alert', () => {
...
@@ -64,7 +65,7 @@ describe('Dismissible Feedback Alert', () => {
it
(
'
should not show the alert once dismissed
'
,
async
()
=>
{
it
(
'
should not show the alert once dismissed
'
,
async
()
=>
{
localStorage
.
setItem
(
STORAGE_DISMISSAL_KEY
,
'
true
'
);
localStorage
.
setItem
(
STORAGE_DISMISSAL_KEY
,
'
true
'
);
createFullComponent
();
createFullComponent
();
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
expect
(
findAlert
().
exists
()).
toBe
(
false
);
expect
(
findAlert
().
exists
()).
toBe
(
false
);
});
});
...
...
spec/frontend/vue_shared/components/dropdown/dropdown_search_input_spec.js
View file @
b712bfa7
import
{
mount
}
from
'
@vue/test-utils
'
;
import
{
mount
}
from
'
@vue/test-utils
'
;
import
{
nextTick
}
from
'
vue
'
;
import
DropdownSearchInputComponent
from
'
~/vue_shared/components/dropdown/dropdown_search_input.vue
'
;
import
DropdownSearchInputComponent
from
'
~/vue_shared/components/dropdown/dropdown_search_input.vue
'
;
describe
(
'
DropdownSearchInputComponent
'
,
()
=>
{
describe
(
'
DropdownSearchInputComponent
'
,
()
=>
{
...
@@ -36,16 +37,15 @@ describe('DropdownSearchInputComponent', () => {
...
@@ -36,16 +37,15 @@ describe('DropdownSearchInputComponent', () => {
expect
(
findInputEl
().
attributes
(
'
placeholder
'
)).
toBe
(
defaultProps
.
placeholderText
);
expect
(
findInputEl
().
attributes
(
'
placeholder
'
)).
toBe
(
defaultProps
.
placeholderText
);
});
});
it
(
'
focuses input element when focused property equals true
'
,
()
=>
{
it
(
'
focuses input element when focused property equals true
'
,
async
()
=>
{
const
inputEl
=
findInputEl
().
element
;
const
inputEl
=
findInputEl
().
element
;
jest
.
spyOn
(
inputEl
,
'
focus
'
);
jest
.
spyOn
(
inputEl
,
'
focus
'
);
wrapper
.
setProps
({
focused
:
true
});
wrapper
.
setProps
({
focused
:
true
});
return
wrapper
.
vm
.
$nextTick
().
then
(()
=>
{
await
nextTick
();
expect
(
inputEl
.
focus
).
toHaveBeenCalled
();
expect
(
inputEl
.
focus
).
toHaveBeenCalled
();
});
});
});
});
});
});
});
spec/frontend/vue_shared/components/dropdown/dropdown_widget_spec.js
View file @
b712bfa7
import
{
GlDropdown
,
GlSearchBoxByType
,
GlDropdownItem
}
from
'
@gitlab/ui
'
;
import
{
GlDropdown
,
GlSearchBoxByType
,
GlDropdownItem
}
from
'
@gitlab/ui
'
;
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
nextTick
}
from
'
vue
'
;
import
DropdownWidget
from
'
~/vue_shared/components/dropdown/dropdown_widget/dropdown_widget.vue
'
;
import
DropdownWidget
from
'
~/vue_shared/components/dropdown/dropdown_widget/dropdown_widget.vue
'
;
describe
(
'
DropdownWidget component
'
,
()
=>
{
describe
(
'
DropdownWidget component
'
,
()
=>
{
...
@@ -53,7 +54,7 @@ describe('DropdownWidget component', () => {
...
@@ -53,7 +54,7 @@ describe('DropdownWidget component', () => {
describe
(
'
when dropdown is open
'
,
()
=>
{
describe
(
'
when dropdown is open
'
,
()
=>
{
beforeEach
(
async
()
=>
{
beforeEach
(
async
()
=>
{
findDropdown
().
vm
.
$emit
(
'
show
'
);
findDropdown
().
vm
.
$emit
(
'
show
'
);
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
});
});
it
(
'
emits search event when typing in search box
'
,
()
=>
{
it
(
'
emits search event when typing in search box
'
,
()
=>
{
...
@@ -69,7 +70,7 @@ describe('DropdownWidget component', () => {
...
@@ -69,7 +70,7 @@ describe('DropdownWidget component', () => {
it
(
'
emits set-option event when clicking on an option
'
,
async
()
=>
{
it
(
'
emits set-option event when clicking on an option
'
,
async
()
=>
{
wrapper
.
findAll
(
'
[data-testid="unselected-option"]
'
).
at
(
1
).
trigger
(
'
click
'
);
wrapper
.
findAll
(
'
[data-testid="unselected-option"]
'
).
at
(
1
).
trigger
(
'
click
'
);
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
expect
(
wrapper
.
emitted
(
'
set-option
'
)).
toEqual
([[
wrapper
.
props
().
options
[
1
]]]);
expect
(
wrapper
.
emitted
(
'
set-option
'
)).
toEqual
([[
wrapper
.
props
().
options
[
1
]]]);
});
});
...
...
spec/frontend/vue_shared/components/dropdown_keyboard_navigation_spec.js
View file @
b712bfa7
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
nextTick
}
from
'
vue
'
;
import
DropdownKeyboardNavigation
from
'
~/vue_shared/components/dropdown_keyboard_navigation.vue
'
;
import
DropdownKeyboardNavigation
from
'
~/vue_shared/components/dropdown_keyboard_navigation.vue
'
;
import
{
UP_KEY_CODE
,
DOWN_KEY_CODE
,
TAB_KEY_CODE
}
from
'
~/lib/utils/keycodes
'
;
import
{
UP_KEY_CODE
,
DOWN_KEY_CODE
,
TAB_KEY_CODE
}
from
'
~/lib/utils/keycodes
'
;
...
@@ -53,7 +54,7 @@ describe('DropdownKeyboardNavigation', () => {
...
@@ -53,7 +54,7 @@ describe('DropdownKeyboardNavigation', () => {
it
(
'
should $emit @change with the default index when max changes
'
,
async
()
=>
{
it
(
'
should $emit @change with the default index when max changes
'
,
async
()
=>
{
wrapper
.
setProps
({
max
:
20
});
wrapper
.
setProps
({
max
:
20
});
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
// The first @change`call happens on created() so we test for the second [1]
// The first @change`call happens on created() so we test for the second [1]
expect
(
wrapper
.
emitted
(
'
change
'
)[
1
]).
toStrictEqual
([
MOCK_DEFAULT_INDEX
]);
expect
(
wrapper
.
emitted
(
'
change
'
)[
1
]).
toStrictEqual
([
MOCK_DEFAULT_INDEX
]);
});
});
...
...
spec/frontend/vue_shared/components/filtered_search_bar/filtered_search_bar_root_spec.js
View file @
b712bfa7
...
@@ -8,6 +8,7 @@ import {
...
@@ -8,6 +8,7 @@ import {
}
from
'
@gitlab/ui
'
;
}
from
'
@gitlab/ui
'
;
import
{
shallowMount
,
mount
}
from
'
@vue/test-utils
'
;
import
{
shallowMount
,
mount
}
from
'
@vue/test-utils
'
;
import
{
nextTick
}
from
'
vue
'
;
import
RecentSearchesService
from
'
~/filtered_search/services/recent_searches_service
'
;
import
RecentSearchesService
from
'
~/filtered_search/services/recent_searches_service
'
;
import
RecentSearchesStore
from
'
~/filtered_search/stores/recent_searches_store
'
;
import
RecentSearchesStore
from
'
~/filtered_search/stores/recent_searches_store
'
;
import
{
SortDirection
}
from
'
~/vue_shared/components/filtered_search_bar/constants
'
;
import
{
SortDirection
}
from
'
~/vue_shared/components/filtered_search_bar/constants
'
;
...
@@ -172,7 +173,7 @@ describe('FilteredSearchBarRoot', () => {
...
@@ -172,7 +173,7 @@ describe('FilteredSearchBarRoot', () => {
recentSearches
:
[{
foo
:
'
bar
'
},
'
foo
'
],
recentSearches
:
[{
foo
:
'
bar
'
},
'
foo
'
],
});
});
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
expect
(
wrapper
.
vm
.
filteredRecentSearches
).
toHaveLength
(
1
);
expect
(
wrapper
.
vm
.
filteredRecentSearches
).
toHaveLength
(
1
);
expect
(
wrapper
.
vm
.
filteredRecentSearches
[
0
]).
toEqual
({
foo
:
'
bar
'
});
expect
(
wrapper
.
vm
.
filteredRecentSearches
[
0
]).
toEqual
({
foo
:
'
bar
'
});
...
@@ -188,7 +189,7 @@ describe('FilteredSearchBarRoot', () => {
...
@@ -188,7 +189,7 @@ describe('FilteredSearchBarRoot', () => {
],
],
});
});
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
expect
(
wrapper
.
vm
.
filteredRecentSearches
).
toHaveLength
(
2
);
expect
(
wrapper
.
vm
.
filteredRecentSearches
).
toHaveLength
(
2
);
expect
(
uniqueTokens
).
toHaveBeenCalled
();
expect
(
uniqueTokens
).
toHaveBeenCalled
();
...
@@ -199,7 +200,7 @@ describe('FilteredSearchBarRoot', () => {
...
@@ -199,7 +200,7 @@ describe('FilteredSearchBarRoot', () => {
recentSearchesStorageKey
:
''
,
recentSearchesStorageKey
:
''
,
});
});
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
expect
(
wrapper
.
vm
.
filteredRecentSearches
).
not
.
toBeDefined
();
expect
(
wrapper
.
vm
.
filteredRecentSearches
).
not
.
toBeDefined
();
});
});
...
@@ -208,7 +209,7 @@ describe('FilteredSearchBarRoot', () => {
...
@@ -208,7 +209,7 @@ describe('FilteredSearchBarRoot', () => {
describe
(
'
watchers
'
,
()
=>
{
describe
(
'
watchers
'
,
()
=>
{
describe
(
'
filterValue
'
,
()
=>
{
describe
(
'
filterValue
'
,
()
=>
{
it
(
'
emits component event `onFilter` with empty array and false when filter was never selected
'
,
()
=>
{
it
(
'
emits component event `onFilter` with empty array and false when filter was never selected
'
,
async
()
=>
{
wrapper
=
createComponent
({
initialFilterValue
:
[
tokenValueEmpty
]
});
wrapper
=
createComponent
({
initialFilterValue
:
[
tokenValueEmpty
]
});
// setData usage is discouraged. See https://gitlab.com/groups/gitlab-org/-/epics/7330 for details
// setData usage is discouraged. See https://gitlab.com/groups/gitlab-org/-/epics/7330 for details
// eslint-disable-next-line no-restricted-syntax
// eslint-disable-next-line no-restricted-syntax
...
@@ -217,12 +218,11 @@ describe('FilteredSearchBarRoot', () => {
...
@@ -217,12 +218,11 @@ describe('FilteredSearchBarRoot', () => {
filterValue
:
[
tokenValueEmpty
],
filterValue
:
[
tokenValueEmpty
],
});
});
return
wrapper
.
vm
.
$nextTick
(()
=>
{
await
nextTick
();
expect
(
wrapper
.
emitted
(
'
onFilter
'
)[
0
]).
toEqual
([[],
false
]);
expect
(
wrapper
.
emitted
(
'
onFilter
'
)[
0
]).
toEqual
([[],
false
]);
});
});
});
it
(
'
emits component event `onFilter` with empty array and true when initially selected filter value was cleared
'
,
()
=>
{
it
(
'
emits component event `onFilter` with empty array and true when initially selected filter value was cleared
'
,
async
()
=>
{
wrapper
=
createComponent
({
initialFilterValue
:
[
tokenValueLabel
]
});
wrapper
=
createComponent
({
initialFilterValue
:
[
tokenValueLabel
]
});
// setData usage is discouraged. See https://gitlab.com/groups/gitlab-org/-/epics/7330 for details
// setData usage is discouraged. See https://gitlab.com/groups/gitlab-org/-/epics/7330 for details
// eslint-disable-next-line no-restricted-syntax
// eslint-disable-next-line no-restricted-syntax
...
@@ -231,12 +231,11 @@ describe('FilteredSearchBarRoot', () => {
...
@@ -231,12 +231,11 @@ describe('FilteredSearchBarRoot', () => {
filterValue
:
[
tokenValueEmpty
],
filterValue
:
[
tokenValueEmpty
],
});
});
return
wrapper
.
vm
.
$nextTick
(()
=>
{
await
nextTick
();
expect
(
wrapper
.
emitted
(
'
onFilter
'
)[
0
]).
toEqual
([[],
true
]);
expect
(
wrapper
.
emitted
(
'
onFilter
'
)[
0
]).
toEqual
([[],
true
]);
});
});
});
});
});
});
});
describe
(
'
methods
'
,
()
=>
{
describe
(
'
methods
'
,
()
=>
{
describe
(
'
setupRecentSearch
'
,
()
=>
{
describe
(
'
setupRecentSearch
'
,
()
=>
{
...
@@ -336,7 +335,7 @@ describe('FilteredSearchBarRoot', () => {
...
@@ -336,7 +335,7 @@ describe('FilteredSearchBarRoot', () => {
filterValue
:
mockFilters
,
filterValue
:
mockFilters
,
});
});
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
});
});
it
(
'
calls `uniqueTokens` on `filterValue` prop to remove duplicates
'
,
()
=>
{
it
(
'
calls `uniqueTokens` on `filterValue` prop to remove duplicates
'
,
()
=>
{
...
@@ -395,7 +394,7 @@ describe('FilteredSearchBarRoot', () => {
...
@@ -395,7 +394,7 @@ describe('FilteredSearchBarRoot', () => {
});
});
describe
(
'
template
'
,
()
=>
{
describe
(
'
template
'
,
()
=>
{
beforeEach
(()
=>
{
beforeEach
(
async
()
=>
{
// setData usage is discouraged. See https://gitlab.com/groups/gitlab-org/-/epics/7330 for details
// setData usage is discouraged. See https://gitlab.com/groups/gitlab-org/-/epics/7330 for details
// eslint-disable-next-line no-restricted-syntax
// eslint-disable-next-line no-restricted-syntax
wrapper
.
setData
({
wrapper
.
setData
({
...
@@ -404,7 +403,7 @@ describe('FilteredSearchBarRoot', () => {
...
@@ -404,7 +403,7 @@ describe('FilteredSearchBarRoot', () => {
recentSearches
:
mockHistoryItems
,
recentSearches
:
mockHistoryItems
,
});
});
return
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
});
});
it
(
'
renders gl-filtered-search component
'
,
()
=>
{
it
(
'
renders gl-filtered-search component
'
,
()
=>
{
...
@@ -439,7 +438,7 @@ describe('FilteredSearchBarRoot', () => {
...
@@ -439,7 +438,7 @@ describe('FilteredSearchBarRoot', () => {
const
wrapperFullMount
=
createComponent
({
sortOptions
:
mockSortOptions
,
shallow
:
false
});
const
wrapperFullMount
=
createComponent
({
sortOptions
:
mockSortOptions
,
shallow
:
false
});
wrapperFullMount
.
vm
.
recentSearchesStore
.
addRecentSearch
(
mockHistoryItems
[
0
]);
wrapperFullMount
.
vm
.
recentSearchesStore
.
addRecentSearch
(
mockHistoryItems
[
0
]);
await
wrapperFullMount
.
vm
.
$
nextTick
();
await
nextTick
();
const
searchHistoryItemsEl
=
wrapperFullMount
.
findAll
(
const
searchHistoryItemsEl
=
wrapperFullMount
.
findAll
(
'
.gl-search-box-by-click-menu .gl-search-box-by-click-history-item
'
,
'
.gl-search-box-by-click-menu .gl-search-box-by-click-history-item
'
,
...
@@ -462,7 +461,7 @@ describe('FilteredSearchBarRoot', () => {
...
@@ -462,7 +461,7 @@ describe('FilteredSearchBarRoot', () => {
wrapperFullMount
.
vm
.
recentSearchesStore
.
addRecentSearch
([
tokenValueMembership
]);
wrapperFullMount
.
vm
.
recentSearchesStore
.
addRecentSearch
([
tokenValueMembership
]);
await
wrapperFullMount
.
vm
.
$
nextTick
();
await
nextTick
();
expect
(
wrapperFullMount
.
find
(
GlDropdownItem
).
text
()).
toBe
(
'
Membership := Direct
'
);
expect
(
wrapperFullMount
.
find
(
GlDropdownItem
).
text
()).
toBe
(
'
Membership := Direct
'
);
...
@@ -480,7 +479,7 @@ describe('FilteredSearchBarRoot', () => {
...
@@ -480,7 +479,7 @@ describe('FilteredSearchBarRoot', () => {
wrapperFullMount
.
vm
.
recentSearchesStore
.
addRecentSearch
([
tokenValueMembership
]);
wrapperFullMount
.
vm
.
recentSearchesStore
.
addRecentSearch
([
tokenValueMembership
]);
await
wrapperFullMount
.
vm
.
$
nextTick
();
await
nextTick
();
expect
(
wrapperFullMount
.
find
(
GlDropdownItem
).
text
()).
toBe
(
'
Membership := exclude
'
);
expect
(
wrapperFullMount
.
find
(
GlDropdownItem
).
text
()).
toBe
(
'
Membership := exclude
'
);
...
...
spec/frontend/vue_shared/components/filtered_search_bar/tokens/author_token_spec.js
View file @
b712bfa7
...
@@ -6,6 +6,7 @@ import {
...
@@ -6,6 +6,7 @@ import {
}
from
'
@gitlab/ui
'
;
}
from
'
@gitlab/ui
'
;
import
{
mount
}
from
'
@vue/test-utils
'
;
import
{
mount
}
from
'
@vue/test-utils
'
;
import
MockAdapter
from
'
axios-mock-adapter
'
;
import
MockAdapter
from
'
axios-mock-adapter
'
;
import
{
nextTick
}
from
'
vue
'
;
import
waitForPromises
from
'
helpers/wait_for_promises
'
;
import
waitForPromises
from
'
helpers/wait_for_promises
'
;
import
createFlash
from
'
~/flash
'
;
import
createFlash
from
'
~/flash
'
;
import
axios
from
'
~/lib/utils/axios_utils
'
;
import
axios
from
'
~/lib/utils/axios_utils
'
;
...
@@ -167,7 +168,7 @@ describe('AuthorToken', () => {
...
@@ -167,7 +168,7 @@ describe('AuthorToken', () => {
const
tokenSegments
=
wrapper
.
findAllComponents
(
GlFilteredSearchTokenSegment
);
const
tokenSegments
=
wrapper
.
findAllComponents
(
GlFilteredSearchTokenSegment
);
const
suggestionsSegment
=
tokenSegments
.
at
(
2
);
const
suggestionsSegment
=
tokenSegments
.
at
(
2
);
suggestionsSegment
.
vm
.
$emit
(
'
activate
'
);
suggestionsSegment
.
vm
.
$emit
(
'
activate
'
);
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
};
};
it
(
'
renders base-token component
'
,
()
=>
{
it
(
'
renders base-token component
'
,
()
=>
{
...
@@ -185,14 +186,14 @@ describe('AuthorToken', () => {
...
@@ -185,14 +186,14 @@ describe('AuthorToken', () => {
});
});
});
});
it
(
'
renders token item when value is selected
'
,
()
=>
{
it
(
'
renders token item when value is selected
'
,
async
()
=>
{
wrapper
=
createComponent
({
wrapper
=
createComponent
({
value
:
{
data
:
mockAuthors
[
0
].
username
},
value
:
{
data
:
mockAuthors
[
0
].
username
},
data
:
{
authors
:
mockAuthors
},
data
:
{
authors
:
mockAuthors
},
stubs
:
{
Portal
:
true
},
stubs
:
{
Portal
:
true
},
});
});
return
wrapper
.
vm
.
$nextTick
(()
=>
{
await
nextTick
();
const
tokenSegments
=
wrapper
.
findAll
(
GlFilteredSearchTokenSegment
);
const
tokenSegments
=
wrapper
.
findAll
(
GlFilteredSearchTokenSegment
);
expect
(
tokenSegments
).
toHaveLength
(
3
);
// Author, =, "Administrator"
expect
(
tokenSegments
).
toHaveLength
(
3
);
// Author, =, "Administrator"
...
@@ -202,7 +203,6 @@ describe('AuthorToken', () => {
...
@@ -202,7 +203,6 @@ describe('AuthorToken', () => {
expect
(
tokenValue
.
findComponent
(
GlAvatar
).
props
(
'
src
'
)).
toBe
(
mockAuthors
[
0
].
avatar_url
);
expect
(
tokenValue
.
findComponent
(
GlAvatar
).
props
(
'
src
'
)).
toBe
(
mockAuthors
[
0
].
avatar_url
);
expect
(
tokenValue
.
text
()).
toBe
(
mockAuthors
[
0
].
name
);
// "Administrator"
expect
(
tokenValue
.
text
()).
toBe
(
mockAuthors
[
0
].
name
);
// "Administrator"
});
});
});
it
(
'
renders token value with correct avatarUrl from author object
'
,
async
()
=>
{
it
(
'
renders token value with correct avatarUrl from author object
'
,
async
()
=>
{
const
getAvatarEl
=
()
=>
const
getAvatarEl
=
()
=>
...
@@ -220,7 +220,7 @@ describe('AuthorToken', () => {
...
@@ -220,7 +220,7 @@ describe('AuthorToken', () => {
stubs
:
{
Portal
:
true
},
stubs
:
{
Portal
:
true
},
});
});
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
expect
(
getAvatarEl
().
props
(
'
src
'
)).
toBe
(
mockAuthors
[
0
].
avatar_url
);
expect
(
getAvatarEl
().
props
(
'
src
'
)).
toBe
(
mockAuthors
[
0
].
avatar_url
);
...
@@ -236,7 +236,7 @@ describe('AuthorToken', () => {
...
@@ -236,7 +236,7 @@ describe('AuthorToken', () => {
],
],
});
});
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
expect
(
getAvatarEl
().
props
(
'
src
'
)).
toBe
(
mockAuthors
[
0
].
avatar_url
);
expect
(
getAvatarEl
().
props
(
'
src
'
)).
toBe
(
mockAuthors
[
0
].
avatar_url
);
});
});
...
@@ -268,7 +268,7 @@ describe('AuthorToken', () => {
...
@@ -268,7 +268,7 @@ describe('AuthorToken', () => {
const
tokenSegments
=
wrapper
.
findAll
(
GlFilteredSearchTokenSegment
);
const
tokenSegments
=
wrapper
.
findAll
(
GlFilteredSearchTokenSegment
);
const
suggestionsSegment
=
tokenSegments
.
at
(
2
);
const
suggestionsSegment
=
tokenSegments
.
at
(
2
);
suggestionsSegment
.
vm
.
$emit
(
'
activate
'
);
suggestionsSegment
.
vm
.
$emit
(
'
activate
'
);
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
expect
(
wrapper
.
find
(
GlDropdownDivider
).
exists
()).
toBe
(
false
);
expect
(
wrapper
.
find
(
GlDropdownDivider
).
exists
()).
toBe
(
false
);
});
});
...
@@ -323,7 +323,7 @@ describe('AuthorToken', () => {
...
@@ -323,7 +323,7 @@ describe('AuthorToken', () => {
it
(
'
does not show current user while searching
'
,
async
()
=>
{
it
(
'
does not show current user while searching
'
,
async
()
=>
{
wrapper
.
findComponent
(
BaseToken
).
vm
.
handleInput
({
data
:
'
foo
'
});
wrapper
.
findComponent
(
BaseToken
).
vm
.
handleInput
({
data
:
'
foo
'
});
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
expect
(
wrapper
.
findComponent
(
GlFilteredSearchSuggestion
).
exists
()).
toBe
(
false
);
expect
(
wrapper
.
findComponent
(
GlFilteredSearchSuggestion
).
exists
()).
toBe
(
false
);
});
});
...
...
spec/frontend/vue_shared/components/filtered_search_bar/tokens/base_token_spec.js
View file @
b712bfa7
import
{
GlFilteredSearchToken
,
GlLoadingIcon
}
from
'
@gitlab/ui
'
;
import
{
GlFilteredSearchToken
,
GlLoadingIcon
}
from
'
@gitlab/ui
'
;
import
{
mount
}
from
'
@vue/test-utils
'
;
import
{
mount
}
from
'
@vue/test-utils
'
;
import
{
nextTick
}
from
'
vue
'
;
import
{
import
{
mockRegularLabel
,
mockRegularLabel
,
mockLabels
,
mockLabels
,
...
@@ -202,7 +203,7 @@ describe('BaseToken', () => {
...
@@ -202,7 +203,7 @@ describe('BaseToken', () => {
jest
.
useFakeTimers
();
jest
.
useFakeTimers
();
findGlFilteredSearchToken
().
vm
.
$emit
(
'
input
'
,
{
data
:
'
foo
'
});
findGlFilteredSearchToken
().
vm
.
$emit
(
'
input
'
,
{
data
:
'
foo
'
});
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
jest
.
runAllTimers
();
jest
.
runAllTimers
();
...
@@ -221,7 +222,7 @@ describe('BaseToken', () => {
...
@@ -221,7 +222,7 @@ describe('BaseToken', () => {
jest
.
useFakeTimers
();
jest
.
useFakeTimers
();
findGlFilteredSearchToken
().
vm
.
$emit
(
'
input
'
,
{
data
:
'
foo
'
});
findGlFilteredSearchToken
().
vm
.
$emit
(
'
input
'
,
{
data
:
'
foo
'
});
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
jest
.
runAllTimers
();
jest
.
runAllTimers
();
...
...
spec/frontend/vue_shared/components/filtered_search_bar/tokens/branch_token_spec.js
View file @
b712bfa7
...
@@ -6,6 +6,7 @@ import {
...
@@ -6,6 +6,7 @@ import {
}
from
'
@gitlab/ui
'
;
}
from
'
@gitlab/ui
'
;
import
{
mount
}
from
'
@vue/test-utils
'
;
import
{
mount
}
from
'
@vue/test-utils
'
;
import
MockAdapter
from
'
axios-mock-adapter
'
;
import
MockAdapter
from
'
axios-mock-adapter
'
;
import
{
nextTick
}
from
'
vue
'
;
import
waitForPromises
from
'
helpers/wait_for_promises
'
;
import
waitForPromises
from
'
helpers/wait_for_promises
'
;
import
createFlash
from
'
~/flash
'
;
import
createFlash
from
'
~/flash
'
;
...
@@ -115,7 +116,7 @@ describe('BranchToken', () => {
...
@@ -115,7 +116,7 @@ describe('BranchToken', () => {
const
tokenSegments
=
wrapper
.
findAll
(
GlFilteredSearchTokenSegment
);
const
tokenSegments
=
wrapper
.
findAll
(
GlFilteredSearchTokenSegment
);
const
suggestionsSegment
=
tokenSegments
.
at
(
2
);
const
suggestionsSegment
=
tokenSegments
.
at
(
2
);
suggestionsSegment
.
vm
.
$emit
(
'
activate
'
);
suggestionsSegment
.
vm
.
$emit
(
'
activate
'
);
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
}
}
beforeEach
(
async
()
=>
{
beforeEach
(
async
()
=>
{
...
@@ -127,7 +128,7 @@ describe('BranchToken', () => {
...
@@ -127,7 +128,7 @@ describe('BranchToken', () => {
branches
:
mockBranches
,
branches
:
mockBranches
,
});
});
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
});
});
it
(
'
renders gl-filtered-search-token component
'
,
()
=>
{
it
(
'
renders gl-filtered-search-token component
'
,
()
=>
{
...
...
spec/frontend/vue_shared/components/filtered_search_bar/tokens/emoji_token_spec.js
View file @
b712bfa7
...
@@ -6,6 +6,7 @@ import {
...
@@ -6,6 +6,7 @@ import {
}
from
'
@gitlab/ui
'
;
}
from
'
@gitlab/ui
'
;
import
{
mount
}
from
'
@vue/test-utils
'
;
import
{
mount
}
from
'
@vue/test-utils
'
;
import
MockAdapter
from
'
axios-mock-adapter
'
;
import
MockAdapter
from
'
axios-mock-adapter
'
;
import
{
nextTick
}
from
'
vue
'
;
import
waitForPromises
from
'
helpers/wait_for_promises
'
;
import
waitForPromises
from
'
helpers/wait_for_promises
'
;
import
createFlash
from
'
~/flash
'
;
import
createFlash
from
'
~/flash
'
;
import
axios
from
'
~/lib/utils/axios_utils
'
;
import
axios
from
'
~/lib/utils/axios_utils
'
;
...
@@ -129,7 +130,7 @@ describe('EmojiToken', () => {
...
@@ -129,7 +130,7 @@ describe('EmojiToken', () => {
emojis
:
mockEmojis
,
emojis
:
mockEmojis
,
});
});
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
});
});
it
(
'
renders gl-filtered-search-token component
'
,
()
=>
{
it
(
'
renders gl-filtered-search-token component
'
,
()
=>
{
...
@@ -152,7 +153,7 @@ describe('EmojiToken', () => {
...
@@ -152,7 +153,7 @@ describe('EmojiToken', () => {
const
tokenSegments
=
wrapper
.
findAll
(
GlFilteredSearchTokenSegment
);
const
tokenSegments
=
wrapper
.
findAll
(
GlFilteredSearchTokenSegment
);
const
suggestionsSegment
=
tokenSegments
.
at
(
2
);
const
suggestionsSegment
=
tokenSegments
.
at
(
2
);
suggestionsSegment
.
vm
.
$emit
(
'
activate
'
);
suggestionsSegment
.
vm
.
$emit
(
'
activate
'
);
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
const
suggestions
=
wrapper
.
findAll
(
GlFilteredSearchSuggestion
);
const
suggestions
=
wrapper
.
findAll
(
GlFilteredSearchSuggestion
);
...
@@ -171,7 +172,7 @@ describe('EmojiToken', () => {
...
@@ -171,7 +172,7 @@ describe('EmojiToken', () => {
const
tokenSegments
=
wrapper
.
findAll
(
GlFilteredSearchTokenSegment
);
const
tokenSegments
=
wrapper
.
findAll
(
GlFilteredSearchTokenSegment
);
const
suggestionsSegment
=
tokenSegments
.
at
(
2
);
const
suggestionsSegment
=
tokenSegments
.
at
(
2
);
suggestionsSegment
.
vm
.
$emit
(
'
activate
'
);
suggestionsSegment
.
vm
.
$emit
(
'
activate
'
);
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
expect
(
wrapper
.
find
(
GlFilteredSearchSuggestion
).
exists
()).
toBe
(
false
);
expect
(
wrapper
.
find
(
GlFilteredSearchSuggestion
).
exists
()).
toBe
(
false
);
expect
(
wrapper
.
find
(
GlDropdownDivider
).
exists
()).
toBe
(
false
);
expect
(
wrapper
.
find
(
GlDropdownDivider
).
exists
()).
toBe
(
false
);
...
@@ -186,7 +187,7 @@ describe('EmojiToken', () => {
...
@@ -186,7 +187,7 @@ describe('EmojiToken', () => {
const
tokenSegments
=
wrapper
.
findAll
(
GlFilteredSearchTokenSegment
);
const
tokenSegments
=
wrapper
.
findAll
(
GlFilteredSearchTokenSegment
);
const
suggestionsSegment
=
tokenSegments
.
at
(
2
);
const
suggestionsSegment
=
tokenSegments
.
at
(
2
);
suggestionsSegment
.
vm
.
$emit
(
'
activate
'
);
suggestionsSegment
.
vm
.
$emit
(
'
activate
'
);
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
const
suggestions
=
wrapper
.
findAll
(
GlFilteredSearchSuggestion
);
const
suggestions
=
wrapper
.
findAll
(
GlFilteredSearchSuggestion
);
...
...
spec/frontend/vue_shared/components/filtered_search_bar/tokens/label_token_spec.js
View file @
b712bfa7
...
@@ -5,6 +5,7 @@ import {
...
@@ -5,6 +5,7 @@ import {
}
from
'
@gitlab/ui
'
;
}
from
'
@gitlab/ui
'
;
import
{
mount
}
from
'
@vue/test-utils
'
;
import
{
mount
}
from
'
@vue/test-utils
'
;
import
MockAdapter
from
'
axios-mock-adapter
'
;
import
MockAdapter
from
'
axios-mock-adapter
'
;
import
{
nextTick
}
from
'
vue
'
;
import
waitForPromises
from
'
helpers/wait_for_promises
'
;
import
waitForPromises
from
'
helpers/wait_for_promises
'
;
import
{
import
{
mockRegularLabel
,
mockRegularLabel
,
...
@@ -150,7 +151,7 @@ describe('LabelToken', () => {
...
@@ -150,7 +151,7 @@ describe('LabelToken', () => {
labels
:
mockLabels
,
labels
:
mockLabels
,
});
});
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
});
});
it
(
'
renders base-token component
'
,
()
=>
{
it
(
'
renders base-token component
'
,
()
=>
{
...
@@ -182,7 +183,7 @@ describe('LabelToken', () => {
...
@@ -182,7 +183,7 @@ describe('LabelToken', () => {
const
tokenSegments
=
wrapper
.
findAll
(
GlFilteredSearchTokenSegment
);
const
tokenSegments
=
wrapper
.
findAll
(
GlFilteredSearchTokenSegment
);
const
suggestionsSegment
=
tokenSegments
.
at
(
2
);
const
suggestionsSegment
=
tokenSegments
.
at
(
2
);
suggestionsSegment
.
vm
.
$emit
(
'
activate
'
);
suggestionsSegment
.
vm
.
$emit
(
'
activate
'
);
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
const
suggestions
=
wrapper
.
findAll
(
GlFilteredSearchSuggestion
);
const
suggestions
=
wrapper
.
findAll
(
GlFilteredSearchSuggestion
);
...
@@ -201,7 +202,7 @@ describe('LabelToken', () => {
...
@@ -201,7 +202,7 @@ describe('LabelToken', () => {
const
tokenSegments
=
wrapper
.
findAll
(
GlFilteredSearchTokenSegment
);
const
tokenSegments
=
wrapper
.
findAll
(
GlFilteredSearchTokenSegment
);
const
suggestionsSegment
=
tokenSegments
.
at
(
2
);
const
suggestionsSegment
=
tokenSegments
.
at
(
2
);
suggestionsSegment
.
vm
.
$emit
(
'
activate
'
);
suggestionsSegment
.
vm
.
$emit
(
'
activate
'
);
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
expect
(
wrapper
.
find
(
GlFilteredSearchSuggestion
).
exists
()).
toBe
(
false
);
expect
(
wrapper
.
find
(
GlFilteredSearchSuggestion
).
exists
()).
toBe
(
false
);
expect
(
wrapper
.
find
(
GlDropdownDivider
).
exists
()).
toBe
(
false
);
expect
(
wrapper
.
find
(
GlDropdownDivider
).
exists
()).
toBe
(
false
);
...
...
spec/frontend/vue_shared/components/filtered_search_bar/tokens/milestone_token_spec.js
View file @
b712bfa7
...
@@ -6,6 +6,7 @@ import {
...
@@ -6,6 +6,7 @@ import {
}
from
'
@gitlab/ui
'
;
}
from
'
@gitlab/ui
'
;
import
{
mount
}
from
'
@vue/test-utils
'
;
import
{
mount
}
from
'
@vue/test-utils
'
;
import
MockAdapter
from
'
axios-mock-adapter
'
;
import
MockAdapter
from
'
axios-mock-adapter
'
;
import
{
nextTick
}
from
'
vue
'
;
import
waitForPromises
from
'
helpers/wait_for_promises
'
;
import
waitForPromises
from
'
helpers/wait_for_promises
'
;
import
createFlash
from
'
~/flash
'
;
import
createFlash
from
'
~/flash
'
;
import
axios
from
'
~/lib/utils/axios_utils
'
;
import
axios
from
'
~/lib/utils/axios_utils
'
;
...
@@ -127,7 +128,7 @@ describe('MilestoneToken', () => {
...
@@ -127,7 +128,7 @@ describe('MilestoneToken', () => {
milestones
:
mockMilestones
,
milestones
:
mockMilestones
,
});
});
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
});
});
it
(
'
renders gl-filtered-search-token component
'
,
()
=>
{
it
(
'
renders gl-filtered-search-token component
'
,
()
=>
{
...
@@ -150,7 +151,7 @@ describe('MilestoneToken', () => {
...
@@ -150,7 +151,7 @@ describe('MilestoneToken', () => {
const
tokenSegments
=
wrapper
.
findAll
(
GlFilteredSearchTokenSegment
);
const
tokenSegments
=
wrapper
.
findAll
(
GlFilteredSearchTokenSegment
);
const
suggestionsSegment
=
tokenSegments
.
at
(
2
);
const
suggestionsSegment
=
tokenSegments
.
at
(
2
);
suggestionsSegment
.
vm
.
$emit
(
'
activate
'
);
suggestionsSegment
.
vm
.
$emit
(
'
activate
'
);
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
const
suggestions
=
wrapper
.
findAll
(
GlFilteredSearchSuggestion
);
const
suggestions
=
wrapper
.
findAll
(
GlFilteredSearchSuggestion
);
...
@@ -169,7 +170,7 @@ describe('MilestoneToken', () => {
...
@@ -169,7 +170,7 @@ describe('MilestoneToken', () => {
const
tokenSegments
=
wrapper
.
findAll
(
GlFilteredSearchTokenSegment
);
const
tokenSegments
=
wrapper
.
findAll
(
GlFilteredSearchTokenSegment
);
const
suggestionsSegment
=
tokenSegments
.
at
(
2
);
const
suggestionsSegment
=
tokenSegments
.
at
(
2
);
suggestionsSegment
.
vm
.
$emit
(
'
activate
'
);
suggestionsSegment
.
vm
.
$emit
(
'
activate
'
);
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
expect
(
wrapper
.
find
(
GlFilteredSearchSuggestion
).
exists
()).
toBe
(
false
);
expect
(
wrapper
.
find
(
GlFilteredSearchSuggestion
).
exists
()).
toBe
(
false
);
expect
(
wrapper
.
find
(
GlDropdownDivider
).
exists
()).
toBe
(
false
);
expect
(
wrapper
.
find
(
GlDropdownDivider
).
exists
()).
toBe
(
false
);
...
@@ -184,7 +185,7 @@ describe('MilestoneToken', () => {
...
@@ -184,7 +185,7 @@ describe('MilestoneToken', () => {
const
tokenSegments
=
wrapper
.
findAll
(
GlFilteredSearchTokenSegment
);
const
tokenSegments
=
wrapper
.
findAll
(
GlFilteredSearchTokenSegment
);
const
suggestionsSegment
=
tokenSegments
.
at
(
2
);
const
suggestionsSegment
=
tokenSegments
.
at
(
2
);
suggestionsSegment
.
vm
.
$emit
(
'
activate
'
);
suggestionsSegment
.
vm
.
$emit
(
'
activate
'
);
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
const
suggestions
=
wrapper
.
findAll
(
GlFilteredSearchSuggestion
);
const
suggestions
=
wrapper
.
findAll
(
GlFilteredSearchSuggestion
);
...
...
spec/frontend/vue_shared/components/filtered_search_bar/tokens/release_token_spec.js
View file @
b712bfa7
import
{
GlFilteredSearchToken
,
GlFilteredSearchTokenSegment
}
from
'
@gitlab/ui
'
;
import
{
GlFilteredSearchToken
,
GlFilteredSearchTokenSegment
}
from
'
@gitlab/ui
'
;
import
{
mount
}
from
'
@vue/test-utils
'
;
import
{
mount
}
from
'
@vue/test-utils
'
;
import
{
nextTick
}
from
'
vue
'
;
import
waitForPromises
from
'
helpers/wait_for_promises
'
;
import
waitForPromises
from
'
helpers/wait_for_promises
'
;
import
createFlash
from
'
~/flash
'
;
import
createFlash
from
'
~/flash
'
;
import
ReleaseToken
from
'
~/vue_shared/components/filtered_search_bar/tokens/release_token.vue
'
;
import
ReleaseToken
from
'
~/vue_shared/components/filtered_search_bar/tokens/release_token.vue
'
;
...
@@ -31,7 +32,7 @@ describe('ReleaseToken', () => {
...
@@ -31,7 +32,7 @@ describe('ReleaseToken', () => {
it
(
'
renders release value
'
,
async
()
=>
{
it
(
'
renders release value
'
,
async
()
=>
{
wrapper
=
createComponent
({
value
:
{
data
:
id
}
});
wrapper
=
createComponent
({
value
:
{
data
:
id
}
});
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
const
tokenSegments
=
wrapper
.
findAllComponents
(
GlFilteredSearchTokenSegment
);
const
tokenSegments
=
wrapper
.
findAllComponents
(
GlFilteredSearchTokenSegment
);
...
...
spec/frontend/vue_shared/components/local_storage_sync_spec.js
View file @
b712bfa7
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
nextTick
}
from
'
vue
'
;
import
LocalStorageSync
from
'
~/vue_shared/components/local_storage_sync.vue
'
;
import
LocalStorageSync
from
'
~/vue_shared/components/local_storage_sync.vue
'
;
describe
(
'
Local Storage Sync
'
,
()
=>
{
describe
(
'
Local Storage Sync
'
,
()
=>
{
...
@@ -49,7 +50,7 @@ describe('Local Storage Sync', () => {
...
@@ -49,7 +50,7 @@ describe('Local Storage Sync', () => {
it
.
each
(
'
foo
'
,
3
,
true
,
[
'
foo
'
,
'
bar
'
],
{
foo
:
'
bar
'
})(
it
.
each
(
'
foo
'
,
3
,
true
,
[
'
foo
'
,
'
bar
'
],
{
foo
:
'
bar
'
})(
'
saves updated value to localStorage
'
,
'
saves updated value to localStorage
'
,
(
newValue
)
=>
{
async
(
newValue
)
=>
{
createComponent
({
createComponent
({
props
:
{
props
:
{
storageKey
,
storageKey
,
...
@@ -59,9 +60,8 @@ describe('Local Storage Sync', () => {
...
@@ -59,9 +60,8 @@ describe('Local Storage Sync', () => {
wrapper
.
setProps
({
value
:
newValue
});
wrapper
.
setProps
({
value
:
newValue
});
return
wrapper
.
vm
.
$nextTick
().
then
(()
=>
{
await
nextTick
();
expect
(
localStorage
.
getItem
(
storageKey
)).
toBe
(
String
(
newValue
));
expect
(
localStorage
.
getItem
(
storageKey
)).
toBe
(
String
(
newValue
));
});
},
},
);
);
...
@@ -109,7 +109,7 @@ describe('Local Storage Sync', () => {
...
@@ -109,7 +109,7 @@ describe('Local Storage Sync', () => {
expect
(
localStorage
.
getItem
(
storageKey
)).
toBe
(
savedValue
);
expect
(
localStorage
.
getItem
(
storageKey
)).
toBe
(
savedValue
);
});
});
it
(
'
updating the value updates localStorage
'
,
()
=>
{
it
(
'
updating the value updates localStorage
'
,
async
()
=>
{
createComponent
({
createComponent
({
props
:
{
props
:
{
storageKey
,
storageKey
,
...
@@ -122,10 +122,9 @@ describe('Local Storage Sync', () => {
...
@@ -122,10 +122,9 @@ describe('Local Storage Sync', () => {
value
:
newValue
,
value
:
newValue
,
});
});
return
wrapper
.
vm
.
$nextTick
().
then
(()
=>
{
await
nextTick
();
expect
(
localStorage
.
getItem
(
storageKey
)).
toBe
(
newValue
);
expect
(
localStorage
.
getItem
(
storageKey
)).
toBe
(
newValue
);
});
});
});
it
(
'
persists the value by default
'
,
async
()
=>
{
it
(
'
persists the value by default
'
,
async
()
=>
{
const
persistedValue
=
'
persisted
'
;
const
persistedValue
=
'
persisted
'
;
...
@@ -137,7 +136,7 @@ describe('Local Storage Sync', () => {
...
@@ -137,7 +136,7 @@ describe('Local Storage Sync', () => {
});
});
wrapper
.
setProps
({
value
:
persistedValue
});
wrapper
.
setProps
({
value
:
persistedValue
});
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
expect
(
localStorage
.
getItem
(
storageKey
)).
toBe
(
persistedValue
);
expect
(
localStorage
.
getItem
(
storageKey
)).
toBe
(
persistedValue
);
});
});
...
@@ -151,7 +150,7 @@ describe('Local Storage Sync', () => {
...
@@ -151,7 +150,7 @@ describe('Local Storage Sync', () => {
});
});
wrapper
.
setProps
({
persist
:
false
,
value
:
notPersistedValue
});
wrapper
.
setProps
({
persist
:
false
,
value
:
notPersistedValue
});
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
expect
(
localStorage
.
getItem
(
storageKey
)).
not
.
toBe
(
notPersistedValue
);
expect
(
localStorage
.
getItem
(
storageKey
)).
not
.
toBe
(
notPersistedValue
);
});
});
});
});
...
@@ -172,7 +171,7 @@ describe('Local Storage Sync', () => {
...
@@ -172,7 +171,7 @@ describe('Local Storage Sync', () => {
${{
foo
:
'
bar
'
}
} |
${
'
{"foo":"bar"}
'
}
${{
foo
:
'
bar
'
}
} |
${
'
{"foo":"bar"}
'
}
`
(
'
given $value
'
,
({
value
,
serializedValue
})
=>
{
`
(
'
given $value
'
,
({
value
,
serializedValue
})
=>
{
describe
(
'
is a new value
'
,
()
=>
{
describe
(
'
is a new value
'
,
()
=>
{
beforeEach
(()
=>
{
beforeEach
(
async
()
=>
{
createComponent
({
createComponent
({
props
:
{
props
:
{
storageKey
,
storageKey
,
...
@@ -183,7 +182,7 @@ describe('Local Storage Sync', () => {
...
@@ -183,7 +182,7 @@ describe('Local Storage Sync', () => {
wrapper
.
setProps
({
value
});
wrapper
.
setProps
({
value
});
return
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
});
});
it
(
'
serializes the value correctly to localStorage
'
,
()
=>
{
it
(
'
serializes the value correctly to localStorage
'
,
()
=>
{
...
@@ -253,7 +252,7 @@ describe('Local Storage Sync', () => {
...
@@ -253,7 +252,7 @@ describe('Local Storage Sync', () => {
value
,
value
,
});
});
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
expect
(
localStorage
.
getItem
(
storageKey
)).
toBe
(
value
);
expect
(
localStorage
.
getItem
(
storageKey
)).
toBe
(
value
);
...
@@ -261,7 +260,7 @@ describe('Local Storage Sync', () => {
...
@@ -261,7 +260,7 @@ describe('Local Storage Sync', () => {
clear
:
true
,
clear
:
true
,
});
});
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
expect
(
localStorage
.
getItem
(
storageKey
)).
toBe
(
null
);
expect
(
localStorage
.
getItem
(
storageKey
)).
toBe
(
null
);
});
});
...
...
spec/frontend/vue_shared/components/markdown/header_spec.js
View file @
b712bfa7
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
$
from
'
jquery
'
;
import
$
from
'
jquery
'
;
import
{
nextTick
}
from
'
vue
'
;
import
HeaderComponent
from
'
~/vue_shared/components/markdown/header.vue
'
;
import
HeaderComponent
from
'
~/vue_shared/components/markdown/header.vue
'
;
import
ToolbarButton
from
'
~/vue_shared/components/markdown/toolbar_button.vue
'
;
import
ToolbarButton
from
'
~/vue_shared/components/markdown/toolbar_button.vue
'
;
...
@@ -84,21 +85,17 @@ describe('Markdown field header component', () => {
...
@@ -84,21 +85,17 @@ describe('Markdown field header component', () => {
expect
(
wrapper
.
find
(
'
li:nth-child(2)
'
).
classes
()).
toContain
(
'
active
'
);
expect
(
wrapper
.
find
(
'
li:nth-child(2)
'
).
classes
()).
toContain
(
'
active
'
);
});
});
it
(
'
emits toggle markdown event when clicking preview
'
,
()
=>
{
it
(
'
emits toggle markdown event when clicking preview
'
,
async
()
=>
{
wrapper
.
find
(
'
.js-preview-link
'
).
trigger
(
'
click
'
);
wrapper
.
find
(
'
.js-preview-link
'
).
trigger
(
'
click
'
);
return
wrapper
.
vm
await
nextTick
();
.
$nextTick
()
.
then
(()
=>
{
expect
(
wrapper
.
emitted
(
'
preview-markdown
'
).
length
).
toEqual
(
1
);
expect
(
wrapper
.
emitted
(
'
preview-markdown
'
).
length
).
toEqual
(
1
);
wrapper
.
find
(
'
.js-write-link
'
).
trigger
(
'
click
'
);
wrapper
.
find
(
'
.js-write-link
'
).
trigger
(
'
click
'
);
return
wrapper
.
vm
.
$nextTick
();
})
await
nextTick
();
.
then
(()
=>
{
expect
(
wrapper
.
emitted
(
'
write-markdown
'
).
length
).
toEqual
(
1
);
expect
(
wrapper
.
emitted
(
'
write-markdown
'
).
length
).
toEqual
(
1
);
});
});
});
it
(
'
does not emit toggle markdown event when triggered from another form
'
,
()
=>
{
it
(
'
does not emit toggle markdown event when triggered from another form
'
,
()
=>
{
$
(
document
).
triggerHandler
(
'
markdown-preview:show
'
,
[
$
(
document
).
triggerHandler
(
'
markdown-preview:show
'
,
[
...
...
spec/frontend/vue_shared/components/markdown/suggestion_diff_header_spec.js
View file @
b712bfa7
import
{
GlLoadingIcon
}
from
'
@gitlab/ui
'
;
import
{
GlLoadingIcon
}
from
'
@gitlab/ui
'
;
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
nextTick
}
from
'
vue
'
;
import
{
createMockDirective
,
getBinding
}
from
'
helpers/vue_mock_directive
'
;
import
{
createMockDirective
,
getBinding
}
from
'
helpers/vue_mock_directive
'
;
import
ApplySuggestion
from
'
~/vue_shared/components/markdown/apply_suggestion.vue
'
;
import
ApplySuggestion
from
'
~/vue_shared/components/markdown/apply_suggestion.vue
'
;
import
SuggestionDiffHeader
from
'
~/vue_shared/components/markdown/suggestion_diff_header.vue
'
;
import
SuggestionDiffHeader
from
'
~/vue_shared/components/markdown/suggestion_diff_header.vue
'
;
...
@@ -103,17 +104,16 @@ describe('Suggestion Diff component', () => {
...
@@ -103,17 +104,16 @@ describe('Suggestion Diff component', () => {
expect
(
wrapper
.
text
()).
toContain
(
'
Applying suggestion...
'
);
expect
(
wrapper
.
text
()).
toContain
(
'
Applying suggestion...
'
);
});
});
it
(
'
when callback of apply is called, hides loading
'
,
()
=>
{
it
(
'
when callback of apply is called, hides loading
'
,
async
()
=>
{
const
[
callback
]
=
wrapper
.
emitted
().
apply
[
0
];
const
[
callback
]
=
wrapper
.
emitted
().
apply
[
0
];
callback
();
callback
();
return
wrapper
.
vm
.
$nextTick
().
then
(()
=>
{
await
nextTick
();
expect
(
findApplyButton
().
exists
()).
toBe
(
true
);
expect
(
findApplyButton
().
exists
()).
toBe
(
true
);
expect
(
findLoading
().
exists
()).
toBe
(
false
);
expect
(
findLoading
().
exists
()).
toBe
(
false
);
});
});
});
});
});
describe
(
'
when add to batch is clicked
'
,
()
=>
{
describe
(
'
when add to batch is clicked
'
,
()
=>
{
it
(
'
emits addToBatch
'
,
()
=>
{
it
(
'
emits addToBatch
'
,
()
=>
{
...
...
spec/frontend/vue_shared/components/modal_copy_button_spec.js
View file @
b712bfa7
import
{
shallowMount
,
createWrapper
}
from
'
@vue/test-utils
'
;
import
{
shallowMount
,
createWrapper
}
from
'
@vue/test-utils
'
;
import
{
nextTick
}
from
'
vue
'
;
import
{
BV_HIDE_TOOLTIP
}
from
'
~/lib/utils/constants
'
;
import
{
BV_HIDE_TOOLTIP
}
from
'
~/lib/utils/constants
'
;
import
ModalCopyButton
from
'
~/vue_shared/components/modal_copy_button.vue
'
;
import
ModalCopyButton
from
'
~/vue_shared/components/modal_copy_button.vue
'
;
...
@@ -20,7 +21,7 @@ describe('modal copy button', () => {
...
@@ -20,7 +21,7 @@ describe('modal copy button', () => {
});
});
describe
(
'
clipboard
'
,
()
=>
{
describe
(
'
clipboard
'
,
()
=>
{
it
(
'
should fire a `success` event on click
'
,
()
=>
{
it
(
'
should fire a `success` event on click
'
,
async
()
=>
{
const
root
=
createWrapper
(
wrapper
.
vm
.
$root
);
const
root
=
createWrapper
(
wrapper
.
vm
.
$root
);
document
.
execCommand
=
jest
.
fn
(()
=>
true
);
document
.
execCommand
=
jest
.
fn
(()
=>
true
);
window
.
getSelection
=
jest
.
fn
(()
=>
({
window
.
getSelection
=
jest
.
fn
(()
=>
({
...
@@ -29,20 +30,18 @@ describe('modal copy button', () => {
...
@@ -29,20 +30,18 @@ describe('modal copy button', () => {
}));
}));
wrapper
.
trigger
(
'
click
'
);
wrapper
.
trigger
(
'
click
'
);
return
wrapper
.
vm
.
$nextTick
().
then
(()
=>
{
await
nextTick
();
expect
(
wrapper
.
emitted
().
success
).
not
.
toBeEmpty
();
expect
(
wrapper
.
emitted
().
success
).
not
.
toBeEmpty
();
expect
(
document
.
execCommand
).
toHaveBeenCalledWith
(
'
copy
'
);
expect
(
document
.
execCommand
).
toHaveBeenCalledWith
(
'
copy
'
);
expect
(
root
.
emitted
(
BV_HIDE_TOOLTIP
)).
toEqual
([[
'
test-id
'
]]);
expect
(
root
.
emitted
(
BV_HIDE_TOOLTIP
)).
toEqual
([[
'
test-id
'
]]);
});
});
});
it
(
"
should propagate the clipboard error event if execCommand doesn't work
"
,
async
()
=>
{
it
(
"
should propagate the clipboard error event if execCommand doesn't work
"
,
()
=>
{
document
.
execCommand
=
jest
.
fn
(()
=>
false
);
document
.
execCommand
=
jest
.
fn
(()
=>
false
);
wrapper
.
trigger
(
'
click
'
);
wrapper
.
trigger
(
'
click
'
);
return
wrapper
.
vm
.
$nextTick
().
then
(()
=>
{
await
nextTick
();
expect
(
wrapper
.
emitted
().
error
).
not
.
toBeEmpty
();
expect
(
wrapper
.
emitted
().
error
).
not
.
toBeEmpty
();
expect
(
document
.
execCommand
).
toHaveBeenCalledWith
(
'
copy
'
);
expect
(
document
.
execCommand
).
toHaveBeenCalledWith
(
'
copy
'
);
});
});
});
});
});
});
});
spec/frontend/vue_shared/components/notes/noteable_warning_spec.js
View file @
b712bfa7
import
{
GlIcon
}
from
'
@gitlab/ui
'
;
import
{
GlIcon
}
from
'
@gitlab/ui
'
;
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
nextTick
}
from
'
vue
'
;
import
NoteableWarning
from
'
~/vue_shared/components/notes/noteable_warning.vue
'
;
import
NoteableWarning
from
'
~/vue_shared/components/notes/noteable_warning.vue
'
;
describe
(
'
Issue Warning Component
'
,
()
=>
{
describe
(
'
Issue Warning Component
'
,
()
=>
{
...
@@ -64,7 +65,7 @@ describe('Issue Warning Component', () => {
...
@@ -64,7 +65,7 @@ describe('Issue Warning Component', () => {
expect
(
findConfidentialBlock
().
exists
()).
toBe
(
true
);
expect
(
findConfidentialBlock
().
exists
()).
toBe
(
true
);
expect
(
findConfidentialBlock
().
element
).
toMatchSnapshot
();
expect
(
findConfidentialBlock
().
element
).
toMatchSnapshot
();
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
expect
(
findConfidentialBlock
(
wrapper
).
text
()).
toContain
(
'
This is a confidential issue.
'
);
expect
(
findConfidentialBlock
(
wrapper
).
text
()).
toContain
(
'
This is a confidential issue.
'
);
});
});
...
@@ -154,15 +155,15 @@ describe('Issue Warning Component', () => {
...
@@ -154,15 +155,15 @@ describe('Issue Warning Component', () => {
noteableType
:
'
Epic
'
,
noteableType
:
'
Epic
'
,
});
});
await
wrapperLocked
.
vm
.
$
nextTick
();
await
nextTick
();
expect
(
findLockedBlock
(
wrapperLocked
).
text
()).
toContain
(
'
This epic is locked.
'
);
expect
(
findLockedBlock
(
wrapperLocked
).
text
()).
toContain
(
'
This epic is locked.
'
);
await
wrapperConfidential
.
vm
.
$
nextTick
();
await
nextTick
();
expect
(
findConfidentialBlock
(
wrapperConfidential
).
text
()).
toContain
(
expect
(
findConfidentialBlock
(
wrapperConfidential
).
text
()).
toContain
(
'
This is a confidential epic.
'
,
'
This is a confidential epic.
'
,
);
);
await
wrapperLockedAndConfidential
.
vm
.
$
nextTick
();
await
nextTick
();
expect
(
findLockedAndConfidentialBlock
(
wrapperLockedAndConfidential
).
text
()).
toContain
(
expect
(
findLockedAndConfidentialBlock
(
wrapperLockedAndConfidential
).
text
()).
toContain
(
'
This epic is confidential and locked.
'
,
'
This epic is confidential and locked.
'
,
);
);
...
@@ -179,15 +180,15 @@ describe('Issue Warning Component', () => {
...
@@ -179,15 +180,15 @@ describe('Issue Warning Component', () => {
noteableType
:
'
MergeRequest
'
,
noteableType
:
'
MergeRequest
'
,
});
});
await
wrapperLocked
.
vm
.
$
nextTick
();
await
nextTick
();
expect
(
findLockedBlock
(
wrapperLocked
).
text
()).
toContain
(
'
This merge request is locked.
'
);
expect
(
findLockedBlock
(
wrapperLocked
).
text
()).
toContain
(
'
This merge request is locked.
'
);
await
wrapperConfidential
.
vm
.
$
nextTick
();
await
nextTick
();
expect
(
findConfidentialBlock
(
wrapperConfidential
).
text
()).
toContain
(
expect
(
findConfidentialBlock
(
wrapperConfidential
).
text
()).
toContain
(
'
This is a confidential merge request.
'
,
'
This is a confidential merge request.
'
,
);
);
await
wrapperLockedAndConfidential
.
vm
.
$
nextTick
();
await
nextTick
();
expect
(
findLockedAndConfidentialBlock
(
wrapperLockedAndConfidential
).
text
()).
toContain
(
expect
(
findLockedAndConfidentialBlock
(
wrapperLockedAndConfidential
).
text
()).
toContain
(
'
This merge request is confidential and locked.
'
,
'
This merge request is confidential and locked.
'
,
);
);
...
...
spec/frontend/vue_shared/components/paginated_table_with_search_and_tabs/paginated_table_with_search_and_tabs_spec.js
View file @
b712bfa7
import
{
GlAlert
,
GlBadge
,
GlPagination
,
GlTabs
,
GlTab
}
from
'
@gitlab/ui
'
;
import
{
GlAlert
,
GlBadge
,
GlPagination
,
GlTabs
,
GlTab
}
from
'
@gitlab/ui
'
;
import
{
mount
}
from
'
@vue/test-utils
'
;
import
{
mount
}
from
'
@vue/test-utils
'
;
import
{
nextTick
}
from
'
vue
'
;
import
Tracking
from
'
~/tracking
'
;
import
Tracking
from
'
~/tracking
'
;
import
{
OPERATOR_IS_ONLY
}
from
'
~/vue_shared/components/filtered_search_bar/constants
'
;
import
{
OPERATOR_IS_ONLY
}
from
'
~/vue_shared/components/filtered_search_bar/constants
'
;
import
FilteredSearchBar
from
'
~/vue_shared/components/filtered_search_bar/filtered_search_bar_root.vue
'
;
import
FilteredSearchBar
from
'
~/vue_shared/components/filtered_search_bar/filtered_search_bar_root.vue
'
;
...
@@ -219,21 +220,21 @@ describe('AlertManagementEmptyState', () => {
...
@@ -219,21 +220,21 @@ describe('AlertManagementEmptyState', () => {
it
(
'
returns prevPage button
'
,
async
()
=>
{
it
(
'
returns prevPage button
'
,
async
()
=>
{
findPagination
().
vm
.
$emit
(
'
input
'
,
3
);
findPagination
().
vm
.
$emit
(
'
input
'
,
3
);
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
expect
(
findPagination
().
findAll
(
'
.page-item
'
).
at
(
0
).
text
()).
toBe
(
'
Prev
'
);
expect
(
findPagination
().
findAll
(
'
.page-item
'
).
at
(
0
).
text
()).
toBe
(
'
Prev
'
);
});
});
it
(
'
returns prevPage number
'
,
async
()
=>
{
it
(
'
returns prevPage number
'
,
async
()
=>
{
findPagination
().
vm
.
$emit
(
'
input
'
,
3
);
findPagination
().
vm
.
$emit
(
'
input
'
,
3
);
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
expect
(
wrapper
.
vm
.
previousPage
).
toBe
(
2
);
expect
(
wrapper
.
vm
.
previousPage
).
toBe
(
2
);
});
});
it
(
'
returns 0 when it is the first page
'
,
async
()
=>
{
it
(
'
returns 0 when it is the first page
'
,
async
()
=>
{
findPagination
().
vm
.
$emit
(
'
input
'
,
1
);
findPagination
().
vm
.
$emit
(
'
input
'
,
1
);
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
expect
(
wrapper
.
vm
.
previousPage
).
toBe
(
0
);
expect
(
wrapper
.
vm
.
previousPage
).
toBe
(
0
);
});
});
});
});
...
@@ -242,7 +243,7 @@ describe('AlertManagementEmptyState', () => {
...
@@ -242,7 +243,7 @@ describe('AlertManagementEmptyState', () => {
it
(
'
returns nextPage button
'
,
async
()
=>
{
it
(
'
returns nextPage button
'
,
async
()
=>
{
findPagination
().
vm
.
$emit
(
'
input
'
,
3
);
findPagination
().
vm
.
$emit
(
'
input
'
,
3
);
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
expect
(
findPagination
().
findAll
(
'
.page-item
'
).
at
(
1
).
text
()).
toBe
(
'
Next
'
);
expect
(
findPagination
().
findAll
(
'
.page-item
'
).
at
(
1
).
text
()).
toBe
(
'
Next
'
);
});
});
...
@@ -257,14 +258,14 @@ describe('AlertManagementEmptyState', () => {
...
@@ -257,14 +258,14 @@ describe('AlertManagementEmptyState', () => {
});
});
findPagination
().
vm
.
$emit
(
'
input
'
,
1
);
findPagination
().
vm
.
$emit
(
'
input
'
,
1
);
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
expect
(
wrapper
.
vm
.
nextPage
).
toBe
(
2
);
expect
(
wrapper
.
vm
.
nextPage
).
toBe
(
2
);
});
});
it
(
'
returns `null` when currentPage is already last page
'
,
async
()
=>
{
it
(
'
returns `null` when currentPage is already last page
'
,
async
()
=>
{
findStatusTabs
().
vm
.
$emit
(
'
input
'
,
1
);
findStatusTabs
().
vm
.
$emit
(
'
input
'
,
1
);
findPagination
().
vm
.
$emit
(
'
input
'
,
1
);
findPagination
().
vm
.
$emit
(
'
input
'
,
1
);
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
expect
(
wrapper
.
vm
.
nextPage
).
toBeNull
();
expect
(
wrapper
.
vm
.
nextPage
).
toBeNull
();
});
});
});
});
...
@@ -319,7 +320,7 @@ describe('AlertManagementEmptyState', () => {
...
@@ -319,7 +320,7 @@ describe('AlertManagementEmptyState', () => {
searchTerm
,
searchTerm
,
});
});
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
expect
(
wrapper
.
vm
.
filteredSearchValue
).
toEqual
([
searchTerm
]);
expect
(
wrapper
.
vm
.
filteredSearchValue
).
toEqual
([
searchTerm
]);
});
});
...
...
spec/frontend/vue_shared/components/project_selector/project_selector_spec.js
View file @
b712bfa7
import
{
GlSearchBoxByType
,
GlInfiniteScroll
}
from
'
@gitlab/ui
'
;
import
{
GlSearchBoxByType
,
GlInfiniteScroll
}
from
'
@gitlab/ui
'
;
import
{
mount
}
from
'
@vue/test-utils
'
;
import
{
mount
}
from
'
@vue/test-utils
'
;
import
{
head
}
from
'
lodash
'
;
import
{
head
}
from
'
lodash
'
;
import
Vue
from
'
vue
'
;
import
Vue
,
{
nextTick
}
from
'
vue
'
;
import
mockProjects
from
'
test_fixtures_static/projects.json
'
;
import
mockProjects
from
'
test_fixtures_static/projects.json
'
;
import
{
trimText
}
from
'
helpers/text_helper
'
;
import
{
trimText
}
from
'
helpers/text_helper
'
;
import
ProjectListItem
from
'
~/vue_shared/components/project_selector/project_list_item.vue
'
;
import
ProjectListItem
from
'
~/vue_shared/components/project_selector/project_list_item.vue
'
;
...
@@ -77,32 +77,30 @@ describe('ProjectSelector component', () => {
...
@@ -77,32 +77,30 @@ describe('ProjectSelector component', () => {
expect
(
vm
.
$emit
).
toHaveBeenCalledWith
(
'
projectClicked
'
,
head
(
searchResults
));
expect
(
vm
.
$emit
).
toHaveBeenCalledWith
(
'
projectClicked
'
,
head
(
searchResults
));
});
});
it
(
`shows a "no results" message if showNoResultsMessage === true`
,
()
=>
{
it
(
`shows a "no results" message if showNoResultsMessage === true`
,
async
()
=>
{
wrapper
.
setProps
({
showNoResultsMessage
:
true
});
wrapper
.
setProps
({
showNoResultsMessage
:
true
});
return
vm
.
$nextTick
().
then
(()
=>
{
await
nextTick
();
const
noResultsEl
=
wrapper
.
find
(
'
.js-no-results-message
'
);
const
noResultsEl
=
wrapper
.
find
(
'
.js-no-results-message
'
);
expect
(
noResultsEl
.
exists
()).
toBe
(
true
);
expect
(
noResultsEl
.
exists
()).
toBe
(
true
);
expect
(
trimText
(
noResultsEl
.
text
())).
toEqual
(
'
Sorry, no projects matched your search
'
);
expect
(
trimText
(
noResultsEl
.
text
())).
toEqual
(
'
Sorry, no projects matched your search
'
);
});
});
});
it
(
`shows a "minimum search query" message if showMinimumSearchQueryMessage === true`
,
()
=>
{
it
(
`shows a "minimum search query" message if showMinimumSearchQueryMessage === true`
,
async
()
=>
{
wrapper
.
setProps
({
showMinimumSearchQueryMessage
:
true
});
wrapper
.
setProps
({
showMinimumSearchQueryMessage
:
true
});
return
vm
.
$nextTick
().
then
(()
=>
{
await
nextTick
();
const
minimumSearchEl
=
wrapper
.
find
(
'
.js-minimum-search-query-message
'
);
const
minimumSearchEl
=
wrapper
.
find
(
'
.js-minimum-search-query-message
'
);
expect
(
minimumSearchEl
.
exists
()).
toBe
(
true
);
expect
(
minimumSearchEl
.
exists
()).
toBe
(
true
);
expect
(
trimText
(
minimumSearchEl
.
text
())).
toEqual
(
'
Enter at least three characters to search
'
);
expect
(
trimText
(
minimumSearchEl
.
text
())).
toEqual
(
'
Enter at least three characters to search
'
);
});
});
});
it
(
`shows a error message if showSearchErrorMessage === true`
,
()
=>
{
it
(
`shows a error message if showSearchErrorMessage === true`
,
async
()
=>
{
wrapper
.
setProps
({
showSearchErrorMessage
:
true
});
wrapper
.
setProps
({
showSearchErrorMessage
:
true
});
return
vm
.
$nextTick
().
then
(()
=>
{
await
nextTick
();
const
errorMessageEl
=
wrapper
.
find
(
'
.js-search-error-message
'
);
const
errorMessageEl
=
wrapper
.
find
(
'
.js-search-error-message
'
);
expect
(
errorMessageEl
.
exists
()).
toBe
(
true
);
expect
(
errorMessageEl
.
exists
()).
toBe
(
true
);
...
@@ -110,7 +108,6 @@ describe('ProjectSelector component', () => {
...
@@ -110,7 +108,6 @@ describe('ProjectSelector component', () => {
'
Something went wrong, unable to search projects
'
,
'
Something went wrong, unable to search projects
'
,
);
);
});
});
});
describe
(
'
the search results legend
'
,
()
=>
{
describe
(
'
the search results legend
'
,
()
=>
{
it
.
each
`
it
.
each
`
...
@@ -121,7 +118,7 @@ describe('ProjectSelector component', () => {
...
@@ -121,7 +118,7 @@ describe('ProjectSelector component', () => {
${
2
}
|
${
3
}
|
${
'
Showing 2 of 3 projects
'
}
${
2
}
|
${
3
}
|
${
'
Showing 2 of 3 projects
'
}
`
(
`
(
'
is "$expected" given $count results are showing out of $total
'
,
'
is "$expected" given $count results are showing out of $total
'
,
({
count
,
total
,
expected
})
=>
{
async
({
count
,
total
,
expected
})
=>
{
search
(
'
gitlab ui
'
);
search
(
'
gitlab ui
'
);
wrapper
.
setProps
({
wrapper
.
setProps
({
...
@@ -129,9 +126,8 @@ describe('ProjectSelector component', () => {
...
@@ -129,9 +126,8 @@ describe('ProjectSelector component', () => {
totalResults
:
total
,
totalResults
:
total
,
});
});
return
wrapper
.
vm
.
$nextTick
().
then
(()
=>
{
await
nextTick
();
expect
(
findLegendText
()).
toBe
(
expected
);
expect
(
findLegendText
()).
toBe
(
expected
);
});
},
},
);
);
...
...
spec/frontend/vue_shared/components/registry/list_item_spec.js
View file @
b712bfa7
import
{
GlButton
}
from
'
@gitlab/ui
'
;
import
{
GlButton
}
from
'
@gitlab/ui
'
;
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
nextTick
}
from
'
vue
'
;
import
component
from
'
~/vue_shared/components/registry/list_item.vue
'
;
import
component
from
'
~/vue_shared/components/registry/list_item.vue
'
;
describe
(
'
list item
'
,
()
=>
{
describe
(
'
list item
'
,
()
=>
{
...
@@ -70,10 +71,10 @@ describe('list item', () => {
...
@@ -70,10 +71,10 @@ describe('list item', () => {
it
(
'
are visible when details is shown
'
,
async
()
=>
{
it
(
'
are visible when details is shown
'
,
async
()
=>
{
mountComponent
({},
slotMocks
);
mountComponent
({},
slotMocks
);
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
findToggleDetailsButton
().
vm
.
$emit
(
'
click
'
);
findToggleDetailsButton
().
vm
.
$emit
(
'
click
'
);
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
slotNames
.
forEach
((
name
)
=>
{
slotNames
.
forEach
((
name
)
=>
{
expect
(
findDetailsSlot
(
name
).
exists
()).
toBe
(
true
);
expect
(
findDetailsSlot
(
name
).
exists
()).
toBe
(
true
);
});
});
...
@@ -90,7 +91,7 @@ describe('list item', () => {
...
@@ -90,7 +91,7 @@ describe('list item', () => {
describe
(
'
details toggle button
'
,
()
=>
{
describe
(
'
details toggle button
'
,
()
=>
{
it
(
'
is visible when at least one details slot exists
'
,
async
()
=>
{
it
(
'
is visible when at least one details slot exists
'
,
async
()
=>
{
mountComponent
({},
{
'
details-foo
'
:
'
<span></span>
'
});
mountComponent
({},
{
'
details-foo
'
:
'
<span></span>
'
});
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
expect
(
findToggleDetailsButton
().
exists
()).
toBe
(
true
);
expect
(
findToggleDetailsButton
().
exists
()).
toBe
(
true
);
});
});
...
...
spec/frontend/vue_shared/components/sidebar/collapsed_calendar_icon_spec.js
View file @
b712bfa7
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
GlIcon
}
from
'
@gitlab/ui
'
;
import
{
GlIcon
}
from
'
@gitlab/ui
'
;
import
{
nextTick
}
from
'
vue
'
;
import
{
createMockDirective
,
getBinding
}
from
'
helpers/vue_mock_directive
'
;
import
{
createMockDirective
,
getBinding
}
from
'
helpers/vue_mock_directive
'
;
import
CollapsedCalendarIcon
from
'
~/vue_shared/components/sidebar/collapsed_calendar_icon.vue
'
;
import
CollapsedCalendarIcon
from
'
~/vue_shared/components/sidebar/collapsed_calendar_icon.vue
'
;
...
@@ -61,7 +62,7 @@ describe('CollapsedCalendarIcon', () => {
...
@@ -61,7 +62,7 @@ describe('CollapsedCalendarIcon', () => {
it
(
'
emits click event when container is clicked
'
,
async
()
=>
{
it
(
'
emits click event when container is clicked
'
,
async
()
=>
{
wrapper
.
trigger
(
'
click
'
);
wrapper
.
trigger
(
'
click
'
);
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
expect
(
wrapper
.
emitted
(
'
click
'
)[
0
]).
toBeDefined
();
expect
(
wrapper
.
emitted
(
'
click
'
)[
0
]).
toBeDefined
();
});
});
...
...
spec/frontend/vue_shared/components/sidebar/date_picker_spec.js
View file @
b712bfa7
import
{
GlLoadingIcon
}
from
'
@gitlab/ui
'
;
import
{
GlLoadingIcon
}
from
'
@gitlab/ui
'
;
import
{
mount
}
from
'
@vue/test-utils
'
;
import
{
mount
}
from
'
@vue/test-utils
'
;
import
{
nextTick
}
from
'
vue
'
;
import
DatePicker
from
'
~/vue_shared/components/pikaday.vue
'
;
import
DatePicker
from
'
~/vue_shared/components/pikaday.vue
'
;
import
SidebarDatePicker
from
'
~/vue_shared/components/sidebar/date_picker.vue
'
;
import
SidebarDatePicker
from
'
~/vue_shared/components/sidebar/date_picker.vue
'
;
...
@@ -79,7 +80,7 @@ describe('SidebarDatePicker', () => {
...
@@ -79,7 +80,7 @@ describe('SidebarDatePicker', () => {
it
(
'
should enable editing when edit button is clicked
'
,
async
()
=>
{
it
(
'
should enable editing when edit button is clicked
'
,
async
()
=>
{
findEditButton
().
trigger
(
'
click
'
);
findEditButton
().
trigger
(
'
click
'
);
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
expect
(
wrapper
.
vm
.
editing
).
toBe
(
true
);
expect
(
wrapper
.
vm
.
editing
).
toBe
(
true
);
});
});
...
...
spec/frontend/vue_shared/components/sidebar/issuable_move_dropdown_spec.js
View file @
b712bfa7
...
@@ -10,6 +10,7 @@ import {
...
@@ -10,6 +10,7 @@ import {
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
MockAdapter
from
'
axios-mock-adapter
'
;
import
MockAdapter
from
'
axios-mock-adapter
'
;
import
{
nextTick
}
from
'
vue
'
;
import
axios
from
'
~/lib/utils/axios_utils
'
;
import
axios
from
'
~/lib/utils/axios_utils
'
;
import
IssuableMoveDropdown
from
'
~/vue_shared/components/sidebar/issuable_move_dropdown.vue
'
;
import
IssuableMoveDropdown
from
'
~/vue_shared/components/sidebar/issuable_move_dropdown.vue
'
;
...
@@ -74,7 +75,7 @@ describe('IssuableMoveDropdown', () => {
...
@@ -74,7 +75,7 @@ describe('IssuableMoveDropdown', () => {
searchKey
:
'
foo
'
,
searchKey
:
'
foo
'
,
});
});
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
expect
(
wrapper
.
vm
.
fetchProjects
).
toHaveBeenCalledWith
(
'
foo
'
);
expect
(
wrapper
.
vm
.
fetchProjects
).
toHaveBeenCalledWith
(
'
foo
'
);
});
});
...
@@ -151,7 +152,7 @@ describe('IssuableMoveDropdown', () => {
...
@@ -151,7 +152,7 @@ describe('IssuableMoveDropdown', () => {
selectedProject
,
selectedProject
,
});
});
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
expect
(
wrapper
.
vm
.
isSelectedProject
(
project
)).
toBe
(
returnValue
);
expect
(
wrapper
.
vm
.
isSelectedProject
(
project
)).
toBe
(
returnValue
);
},
},
...
@@ -164,7 +165,7 @@ describe('IssuableMoveDropdown', () => {
...
@@ -164,7 +165,7 @@ describe('IssuableMoveDropdown', () => {
selectedProject
:
null
,
selectedProject
:
null
,
});
});
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
expect
(
wrapper
.
vm
.
isSelectedProject
(
mockProjects
[
0
])).
toBe
(
false
);
expect
(
wrapper
.
vm
.
isSelectedProject
(
mockProjects
[
0
])).
toBe
(
false
);
});
});
...
@@ -218,7 +219,7 @@ describe('IssuableMoveDropdown', () => {
...
@@ -218,7 +219,7 @@ describe('IssuableMoveDropdown', () => {
projectsListLoading
:
true
,
projectsListLoading
:
true
,
});
});
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
expect
(
findDropdownEl
().
find
(
GlLoadingIcon
).
exists
()).
toBe
(
true
);
expect
(
findDropdownEl
().
find
(
GlLoadingIcon
).
exists
()).
toBe
(
true
);
});
});
...
@@ -231,7 +232,7 @@ describe('IssuableMoveDropdown', () => {
...
@@ -231,7 +232,7 @@ describe('IssuableMoveDropdown', () => {
selectedProject
:
mockProjects
[
0
],
selectedProject
:
mockProjects
[
0
],
});
});
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
const
dropdownItems
=
wrapper
.
findAll
(
GlDropdownItem
);
const
dropdownItems
=
wrapper
.
findAll
(
GlDropdownItem
);
...
@@ -251,7 +252,7 @@ describe('IssuableMoveDropdown', () => {
...
@@ -251,7 +252,7 @@ describe('IssuableMoveDropdown', () => {
});
});
// Wait for `searchKey` watcher to run.
// Wait for `searchKey` watcher to run.
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
// setData usage is discouraged. See https://gitlab.com/groups/gitlab-org/-/epics/7330 for details
// setData usage is discouraged. See https://gitlab.com/groups/gitlab-org/-/epics/7330 for details
// eslint-disable-next-line no-restricted-syntax
// eslint-disable-next-line no-restricted-syntax
...
@@ -260,7 +261,7 @@ describe('IssuableMoveDropdown', () => {
...
@@ -260,7 +261,7 @@ describe('IssuableMoveDropdown', () => {
projectsListLoading
:
false
,
projectsListLoading
:
false
,
});
});
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
const
dropdownContentEl
=
wrapper
.
find
(
'
[data-testid="content"]
'
);
const
dropdownContentEl
=
wrapper
.
find
(
'
[data-testid="content"]
'
);
...
@@ -276,7 +277,7 @@ describe('IssuableMoveDropdown', () => {
...
@@ -276,7 +277,7 @@ describe('IssuableMoveDropdown', () => {
projectsListLoadFailed
:
true
,
projectsListLoadFailed
:
true
,
});
});
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
const
dropdownContentEl
=
wrapper
.
find
(
'
[data-testid="content"]
'
);
const
dropdownContentEl
=
wrapper
.
find
(
'
[data-testid="content"]
'
);
...
@@ -295,7 +296,7 @@ describe('IssuableMoveDropdown', () => {
...
@@ -295,7 +296,7 @@ describe('IssuableMoveDropdown', () => {
selectedProject
:
mockProjects
[
0
],
selectedProject
:
mockProjects
[
0
],
});
});
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
expect
(
expect
(
wrapper
.
find
(
'
[data-testid="footer"]
'
).
find
(
GlButton
).
attributes
(
'
disabled
'
),
wrapper
.
find
(
'
[data-testid="footer"]
'
).
find
(
GlButton
).
attributes
(
'
disabled
'
),
...
@@ -352,7 +353,7 @@ describe('IssuableMoveDropdown', () => {
...
@@ -352,7 +353,7 @@ describe('IssuableMoveDropdown', () => {
projects
:
mockProjects
,
projects
:
mockProjects
,
});
});
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
wrapper
.
findAll
(
GlDropdownItem
).
at
(
0
).
vm
.
$emit
(
'
click
'
,
mockEvent
);
wrapper
.
findAll
(
GlDropdownItem
).
at
(
0
).
vm
.
$emit
(
'
click
'
,
mockEvent
);
...
@@ -366,7 +367,7 @@ describe('IssuableMoveDropdown', () => {
...
@@ -366,7 +367,7 @@ describe('IssuableMoveDropdown', () => {
selectedProject
:
mockProjects
[
0
],
selectedProject
:
mockProjects
[
0
],
});
});
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
wrapper
.
find
(
'
[data-testid="footer"]
'
).
find
(
GlButton
).
vm
.
$emit
(
'
click
'
);
wrapper
.
find
(
'
[data-testid="footer"]
'
).
find
(
GlButton
).
vm
.
$emit
(
'
click
'
);
...
...
spec/frontend/vue_shared/components/sidebar/labels_select_vue/dropdown_button_spec.js
View file @
b712bfa7
import
{
GlIcon
,
GlButton
}
from
'
@gitlab/ui
'
;
import
{
GlIcon
,
GlButton
}
from
'
@gitlab/ui
'
;
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
Vue
from
'
vue
'
;
import
Vue
,
{
nextTick
}
from
'
vue
'
;
import
Vuex
from
'
vuex
'
;
import
Vuex
from
'
vuex
'
;
import
DropdownButton
from
'
~/vue_shared/components/sidebar/labels_select_vue/dropdown_button.vue
'
;
import
DropdownButton
from
'
~/vue_shared/components/sidebar/labels_select_vue/dropdown_button.vue
'
;
...
@@ -71,14 +71,13 @@ describe('DropdownButton', () => {
...
@@ -71,14 +71,13 @@ describe('DropdownButton', () => {
expect
(
dropdownTextEl
.
text
()).
toBe
(
'
Label
'
);
expect
(
dropdownTextEl
.
text
()).
toBe
(
'
Label
'
);
});
});
it
(
'
renders provided button text element
'
,
()
=>
{
it
(
'
renders provided button text element
'
,
async
()
=>
{
store
.
state
.
dropdownButtonText
=
'
Custom label
'
;
store
.
state
.
dropdownButtonText
=
'
Custom label
'
;
const
dropdownTextEl
=
findDropdownText
();
const
dropdownTextEl
=
findDropdownText
();
return
wrapper
.
vm
.
$nextTick
().
then
(()
=>
{
await
nextTick
();
expect
(
dropdownTextEl
.
text
()).
toBe
(
'
Custom label
'
);
expect
(
dropdownTextEl
.
text
()).
toBe
(
'
Custom label
'
);
});
});
});
it
(
'
renders chevron icon element
'
,
()
=>
{
it
(
'
renders chevron icon element
'
,
()
=>
{
const
iconEl
=
findDropdownIcon
();
const
iconEl
=
findDropdownIcon
();
...
...
spec/frontend/vue_shared/components/sidebar/labels_select_vue/dropdown_contents_create_view_spec.js
View file @
b712bfa7
import
{
GlButton
,
GlFormInput
,
GlLink
,
GlLoadingIcon
}
from
'
@gitlab/ui
'
;
import
{
GlButton
,
GlFormInput
,
GlLink
,
GlLoadingIcon
}
from
'
@gitlab/ui
'
;
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
Vue
from
'
vue
'
;
import
Vue
,
{
nextTick
}
from
'
vue
'
;
import
Vuex
from
'
vuex
'
;
import
Vuex
from
'
vuex
'
;
import
DropdownContentsCreateView
from
'
~/vue_shared/components/sidebar/labels_select_vue/dropdown_contents_create_view.vue
'
;
import
DropdownContentsCreateView
from
'
~/vue_shared/components/sidebar/labels_select_vue/dropdown_contents_create_view.vue
'
;
...
@@ -42,7 +42,7 @@ describe('DropdownContentsCreateView', () => {
...
@@ -42,7 +42,7 @@ describe('DropdownContentsCreateView', () => {
expect
(
wrapper
.
vm
.
disableCreate
).
toBe
(
true
);
expect
(
wrapper
.
vm
.
disableCreate
).
toBe
(
true
);
});
});
it
(
'
returns `true` when `labelCreateInProgress` is true
'
,
()
=>
{
it
(
'
returns `true` when `labelCreateInProgress` is true
'
,
async
()
=>
{
// setData usage is discouraged. See https://gitlab.com/groups/gitlab-org/-/epics/7330 for details
// setData usage is discouraged. See https://gitlab.com/groups/gitlab-org/-/epics/7330 for details
// eslint-disable-next-line no-restricted-syntax
// eslint-disable-next-line no-restricted-syntax
wrapper
.
setData
({
wrapper
.
setData
({
...
@@ -51,12 +51,11 @@ describe('DropdownContentsCreateView', () => {
...
@@ -51,12 +51,11 @@ describe('DropdownContentsCreateView', () => {
});
});
wrapper
.
vm
.
$store
.
dispatch
(
'
requestCreateLabel
'
);
wrapper
.
vm
.
$store
.
dispatch
(
'
requestCreateLabel
'
);
return
wrapper
.
vm
.
$nextTick
(()
=>
{
await
nextTick
();
expect
(
wrapper
.
vm
.
disableCreate
).
toBe
(
true
);
expect
(
wrapper
.
vm
.
disableCreate
).
toBe
(
true
);
});
});
});
it
(
'
returns `false` when label title and color is defined and create request is not already in progress
'
,
()
=>
{
it
(
'
returns `false` when label title and color is defined and create request is not already in progress
'
,
async
()
=>
{
// setData usage is discouraged. See https://gitlab.com/groups/gitlab-org/-/epics/7330 for details
// setData usage is discouraged. See https://gitlab.com/groups/gitlab-org/-/epics/7330 for details
// eslint-disable-next-line no-restricted-syntax
// eslint-disable-next-line no-restricted-syntax
wrapper
.
setData
({
wrapper
.
setData
({
...
@@ -64,11 +63,10 @@ describe('DropdownContentsCreateView', () => {
...
@@ -64,11 +63,10 @@ describe('DropdownContentsCreateView', () => {
selectedColor
:
'
#ff0000
'
,
selectedColor
:
'
#ff0000
'
,
});
});
return
wrapper
.
vm
.
$nextTick
(()
=>
{
await
nextTick
();
expect
(
wrapper
.
vm
.
disableCreate
).
toBe
(
false
);
expect
(
wrapper
.
vm
.
disableCreate
).
toBe
(
false
);
});
});
});
});
});
describe
(
'
suggestedColors
'
,
()
=>
{
describe
(
'
suggestedColors
'
,
()
=>
{
it
(
'
returns array of color objects containing color code and name
'
,
()
=>
{
it
(
'
returns array of color objects containing color code and name
'
,
()
=>
{
...
@@ -101,7 +99,7 @@ describe('DropdownContentsCreateView', () => {
...
@@ -101,7 +99,7 @@ describe('DropdownContentsCreateView', () => {
});
});
describe
(
'
handleCreateClick
'
,
()
=>
{
describe
(
'
handleCreateClick
'
,
()
=>
{
it
(
'
calls action `createLabel` with object containing `labelTitle` & `selectedColor`
'
,
()
=>
{
it
(
'
calls action `createLabel` with object containing `labelTitle` & `selectedColor`
'
,
async
()
=>
{
jest
.
spyOn
(
wrapper
.
vm
,
'
createLabel
'
).
mockImplementation
();
jest
.
spyOn
(
wrapper
.
vm
,
'
createLabel
'
).
mockImplementation
();
// setData usage is discouraged. See https://gitlab.com/groups/gitlab-org/-/epics/7330 for details
// setData usage is discouraged. See https://gitlab.com/groups/gitlab-org/-/epics/7330 for details
// eslint-disable-next-line no-restricted-syntax
// eslint-disable-next-line no-restricted-syntax
...
@@ -112,7 +110,7 @@ describe('DropdownContentsCreateView', () => {
...
@@ -112,7 +110,7 @@ describe('DropdownContentsCreateView', () => {
wrapper
.
vm
.
handleCreateClick
();
wrapper
.
vm
.
handleCreateClick
();
return
wrapper
.
vm
.
$nextTick
(()
=>
{
await
nextTick
();
expect
(
wrapper
.
vm
.
createLabel
).
toHaveBeenCalledWith
(
expect
(
wrapper
.
vm
.
createLabel
).
toHaveBeenCalledWith
(
expect
.
objectContaining
({
expect
.
objectContaining
({
title
:
'
Foo
'
,
title
:
'
Foo
'
,
...
@@ -122,7 +120,6 @@ describe('DropdownContentsCreateView', () => {
...
@@ -122,7 +120,6 @@ describe('DropdownContentsCreateView', () => {
});
});
});
});
});
});
});
describe
(
'
template
'
,
()
=>
{
describe
(
'
template
'
,
()
=>
{
it
(
'
renders component container element with class "labels-select-contents-create"
'
,
()
=>
{
it
(
'
renders component container element with class "labels-select-contents-create"
'
,
()
=>
{
...
@@ -169,17 +166,15 @@ describe('DropdownContentsCreateView', () => {
...
@@ -169,17 +166,15 @@ describe('DropdownContentsCreateView', () => {
});
});
});
});
it
(
'
renders color input element
'
,
()
=>
{
it
(
'
renders color input element
'
,
async
()
=>
{
// setData usage is discouraged. See https://gitlab.com/groups/gitlab-org/-/epics/7330 for details
// setData usage is discouraged. See https://gitlab.com/groups/gitlab-org/-/epics/7330 for details
// eslint-disable-next-line no-restricted-syntax
// eslint-disable-next-line no-restricted-syntax
wrapper
.
setData
({
wrapper
.
setData
({
selectedColor
:
'
#ff0000
'
,
selectedColor
:
'
#ff0000
'
,
});
});
return
wrapper
.
vm
.
$nextTick
(()
=>
{
await
nextTick
();
const
colorPreviewEl
=
wrapper
.
find
(
const
colorPreviewEl
=
wrapper
.
find
(
'
.color-input-container > .dropdown-label-color-preview
'
);
'
.color-input-container > .dropdown-label-color-preview
'
,
);
const
colorInputEl
=
wrapper
.
find
(
'
.color-input-container
'
).
find
(
GlFormInput
);
const
colorInputEl
=
wrapper
.
find
(
'
.color-input-container
'
).
find
(
GlFormInput
);
expect
(
colorPreviewEl
.
exists
()).
toBe
(
true
);
expect
(
colorPreviewEl
.
exists
()).
toBe
(
true
);
...
@@ -188,7 +183,6 @@ describe('DropdownContentsCreateView', () => {
...
@@ -188,7 +183,6 @@ describe('DropdownContentsCreateView', () => {
expect
(
colorInputEl
.
attributes
(
'
placeholder
'
)).
toBe
(
'
Use custom color #FF0000
'
);
expect
(
colorInputEl
.
attributes
(
'
placeholder
'
)).
toBe
(
'
Use custom color #FF0000
'
);
expect
(
colorInputEl
.
attributes
(
'
value
'
)).
toBe
(
'
#ff0000
'
);
expect
(
colorInputEl
.
attributes
(
'
value
'
)).
toBe
(
'
#ff0000
'
);
});
});
});
it
(
'
renders create button element
'
,
()
=>
{
it
(
'
renders create button element
'
,
()
=>
{
const
createBtnEl
=
wrapper
.
find
(
'
.dropdown-actions
'
).
findAll
(
GlButton
).
at
(
0
);
const
createBtnEl
=
wrapper
.
find
(
'
.dropdown-actions
'
).
findAll
(
GlButton
).
at
(
0
);
...
@@ -197,16 +191,15 @@ describe('DropdownContentsCreateView', () => {
...
@@ -197,16 +191,15 @@ describe('DropdownContentsCreateView', () => {
expect
(
createBtnEl
.
text
()).
toContain
(
'
Create
'
);
expect
(
createBtnEl
.
text
()).
toContain
(
'
Create
'
);
});
});
it
(
'
shows gl-loading-icon within create button element when `labelCreateInProgress` is `true`
'
,
()
=>
{
it
(
'
shows gl-loading-icon within create button element when `labelCreateInProgress` is `true`
'
,
async
()
=>
{
wrapper
.
vm
.
$store
.
dispatch
(
'
requestCreateLabel
'
);
wrapper
.
vm
.
$store
.
dispatch
(
'
requestCreateLabel
'
);
return
wrapper
.
vm
.
$nextTick
(()
=>
{
await
nextTick
();
const
loadingIconEl
=
wrapper
.
find
(
'
.dropdown-actions
'
).
find
(
GlLoadingIcon
);
const
loadingIconEl
=
wrapper
.
find
(
'
.dropdown-actions
'
).
find
(
GlLoadingIcon
);
expect
(
loadingIconEl
.
exists
()).
toBe
(
true
);
expect
(
loadingIconEl
.
exists
()).
toBe
(
true
);
expect
(
loadingIconEl
.
isVisible
()).
toBe
(
true
);
expect
(
loadingIconEl
.
isVisible
()).
toBe
(
true
);
});
});
});
it
(
'
renders cancel button element
'
,
()
=>
{
it
(
'
renders cancel button element
'
,
()
=>
{
const
cancelBtnEl
=
wrapper
.
find
(
'
.dropdown-actions
'
).
findAll
(
GlButton
).
at
(
1
);
const
cancelBtnEl
=
wrapper
.
find
(
'
.dropdown-actions
'
).
findAll
(
GlButton
).
at
(
1
);
...
...
spec/frontend/vue_shared/components/sidebar/labels_select_vue/dropdown_contents_labels_view_spec.js
View file @
b712bfa7
...
@@ -6,7 +6,7 @@ import {
...
@@ -6,7 +6,7 @@ import {
GlLink
,
GlLink
,
}
from
'
@gitlab/ui
'
;
}
from
'
@gitlab/ui
'
;
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
Vue
from
'
vue
'
;
import
Vue
,
{
nextTick
}
from
'
vue
'
;
import
Vuex
from
'
vuex
'
;
import
Vuex
from
'
vuex
'
;
import
{
UP_KEY_CODE
,
DOWN_KEY_CODE
,
ENTER_KEY_CODE
,
ESC_KEY_CODE
}
from
'
~/lib/utils/keycodes
'
;
import
{
UP_KEY_CODE
,
DOWN_KEY_CODE
,
ENTER_KEY_CODE
,
ESC_KEY_CODE
}
from
'
~/lib/utils/keycodes
'
;
import
DropdownContentsLabelsView
from
'
~/vue_shared/components/sidebar/labels_select_vue/dropdown_contents_labels_view.vue
'
;
import
DropdownContentsLabelsView
from
'
~/vue_shared/components/sidebar/labels_select_vue/dropdown_contents_labels_view.vue
'
;
...
@@ -114,7 +114,7 @@ describe('DropdownContentsLabelsView', () => {
...
@@ -114,7 +114,7 @@ describe('DropdownContentsLabelsView', () => {
wrapper
.
vm
.
$store
.
dispatch
(
'
receiveLabelsSuccess
'
,
labels
);
wrapper
.
vm
.
$store
.
dispatch
(
'
receiveLabelsSuccess
'
,
labels
);
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
expect
(
wrapper
.
vm
.
showNoMatchingResultsMessage
).
toBe
(
returnValue
);
expect
(
wrapper
.
vm
.
showNoMatchingResultsMessage
).
toBe
(
returnValue
);
},
},
...
@@ -249,7 +249,7 @@ describe('DropdownContentsLabelsView', () => {
...
@@ -249,7 +249,7 @@ describe('DropdownContentsLabelsView', () => {
expect
(
wrapper
.
vm
.
toggleDropdownContents
).
toHaveBeenCalled
();
expect
(
wrapper
.
vm
.
toggleDropdownContents
).
toHaveBeenCalled
();
});
});
it
(
'
calls action `scrollIntoViewIfNeeded` in next tick when any key is pressed
'
,
()
=>
{
it
(
'
calls action `scrollIntoViewIfNeeded` in next tick when any key is pressed
'
,
async
()
=>
{
jest
.
spyOn
(
wrapper
.
vm
,
'
scrollIntoViewIfNeeded
'
).
mockImplementation
();
jest
.
spyOn
(
wrapper
.
vm
,
'
scrollIntoViewIfNeeded
'
).
mockImplementation
();
// setData usage is discouraged. See https://gitlab.com/groups/gitlab-org/-/epics/7330 for details
// setData usage is discouraged. See https://gitlab.com/groups/gitlab-org/-/epics/7330 for details
// eslint-disable-next-line no-restricted-syntax
// eslint-disable-next-line no-restricted-syntax
...
@@ -261,11 +261,10 @@ describe('DropdownContentsLabelsView', () => {
...
@@ -261,11 +261,10 @@ describe('DropdownContentsLabelsView', () => {
keyCode
:
DOWN_KEY_CODE
,
keyCode
:
DOWN_KEY_CODE
,
});
});
return
wrapper
.
vm
.
$nextTick
(()
=>
{
await
nextTick
();
expect
(
wrapper
.
vm
.
scrollIntoViewIfNeeded
).
toHaveBeenCalled
();
expect
(
wrapper
.
vm
.
scrollIntoViewIfNeeded
).
toHaveBeenCalled
();
});
});
});
});
});
describe
(
'
handleLabelClick
'
,
()
=>
{
describe
(
'
handleLabelClick
'
,
()
=>
{
beforeEach
(()
=>
{
beforeEach
(()
=>
{
...
@@ -294,16 +293,15 @@ describe('DropdownContentsLabelsView', () => {
...
@@ -294,16 +293,15 @@ describe('DropdownContentsLabelsView', () => {
expect
(
wrapper
.
find
(
GlIntersectionObserver
).
exists
()).
toBe
(
true
);
expect
(
wrapper
.
find
(
GlIntersectionObserver
).
exists
()).
toBe
(
true
);
});
});
it
(
'
renders gl-loading-icon component when `labelsFetchInProgress` prop is true
'
,
()
=>
{
it
(
'
renders gl-loading-icon component when `labelsFetchInProgress` prop is true
'
,
async
()
=>
{
wrapper
.
vm
.
$store
.
dispatch
(
'
requestLabels
'
);
wrapper
.
vm
.
$store
.
dispatch
(
'
requestLabels
'
);
return
wrapper
.
vm
.
$nextTick
(()
=>
{
await
nextTick
();
const
loadingIconEl
=
findLoadingIcon
();
const
loadingIconEl
=
findLoadingIcon
();
expect
(
loadingIconEl
.
exists
()).
toBe
(
true
);
expect
(
loadingIconEl
.
exists
()).
toBe
(
true
);
expect
(
loadingIconEl
.
attributes
(
'
class
'
)).
toContain
(
'
labels-fetch-loading
'
);
expect
(
loadingIconEl
.
attributes
(
'
class
'
)).
toContain
(
'
labels-fetch-loading
'
);
});
});
});
it
(
'
renders dropdown title element
'
,
()
=>
{
it
(
'
renders dropdown title element
'
,
()
=>
{
const
titleEl
=
findDropdownTitle
();
const
titleEl
=
findDropdownTitle
();
...
@@ -339,39 +337,37 @@ describe('DropdownContentsLabelsView', () => {
...
@@ -339,39 +337,37 @@ describe('DropdownContentsLabelsView', () => {
expect
(
wrapper
.
findAll
(
LabelItem
)).
toHaveLength
(
mockLabels
.
length
);
expect
(
wrapper
.
findAll
(
LabelItem
)).
toHaveLength
(
mockLabels
.
length
);
});
});
it
(
'
renders label element with `highlight` set to true when value of `currentHighlightItem` is more than -1
'
,
()
=>
{
it
(
'
renders label element with `highlight` set to true when value of `currentHighlightItem` is more than -1
'
,
async
()
=>
{
// setData usage is discouraged. See https://gitlab.com/groups/gitlab-org/-/epics/7330 for details
// setData usage is discouraged. See https://gitlab.com/groups/gitlab-org/-/epics/7330 for details
// eslint-disable-next-line no-restricted-syntax
// eslint-disable-next-line no-restricted-syntax
wrapper
.
setData
({
wrapper
.
setData
({
currentHighlightItem
:
0
,
currentHighlightItem
:
0
,
});
});
return
wrapper
.
vm
.
$nextTick
(()
=>
{
await
nextTick
();
const
labelItemEl
=
findDropdownContent
().
find
(
LabelItem
);
const
labelItemEl
=
findDropdownContent
().
find
(
LabelItem
);
expect
(
labelItemEl
.
attributes
(
'
highlight
'
)).
toBe
(
'
true
'
);
expect
(
labelItemEl
.
attributes
(
'
highlight
'
)).
toBe
(
'
true
'
);
});
});
});
it
(
'
renders element containing "No matching results" when `searchKey` does not match with any label
'
,
()
=>
{
it
(
'
renders element containing "No matching results" when `searchKey` does not match with any label
'
,
async
()
=>
{
// setData usage is discouraged. See https://gitlab.com/groups/gitlab-org/-/epics/7330 for details
// setData usage is discouraged. See https://gitlab.com/groups/gitlab-org/-/epics/7330 for details
// eslint-disable-next-line no-restricted-syntax
// eslint-disable-next-line no-restricted-syntax
wrapper
.
setData
({
wrapper
.
setData
({
searchKey
:
'
abc
'
,
searchKey
:
'
abc
'
,
});
});
return
wrapper
.
vm
.
$nextTick
(()
=>
{
await
nextTick
();
const
noMatchEl
=
findDropdownContent
().
find
(
'
li
'
);
const
noMatchEl
=
findDropdownContent
().
find
(
'
li
'
);
expect
(
noMatchEl
.
isVisible
()).
toBe
(
true
);
expect
(
noMatchEl
.
isVisible
()).
toBe
(
true
);
expect
(
noMatchEl
.
text
()).
toContain
(
'
No matching results
'
);
expect
(
noMatchEl
.
text
()).
toContain
(
'
No matching results
'
);
});
});
});
it
(
'
renders empty content while loading
'
,
()
=>
{
it
(
'
renders empty content while loading
'
,
async
()
=>
{
wrapper
.
vm
.
$store
.
state
.
labelsFetchInProgress
=
true
;
wrapper
.
vm
.
$store
.
state
.
labelsFetchInProgress
=
true
;
return
wrapper
.
vm
.
$nextTick
(()
=>
{
await
nextTick
();
const
dropdownContent
=
findDropdownContent
();
const
dropdownContent
=
findDropdownContent
();
const
loadingIcon
=
findLoadingIcon
();
const
loadingIcon
=
findLoadingIcon
();
...
@@ -380,7 +376,6 @@ describe('DropdownContentsLabelsView', () => {
...
@@ -380,7 +376,6 @@ describe('DropdownContentsLabelsView', () => {
expect
(
loadingIcon
.
exists
()).
toBe
(
true
);
expect
(
loadingIcon
.
exists
()).
toBe
(
true
);
expect
(
loadingIcon
.
isVisible
()).
toBe
(
true
);
expect
(
loadingIcon
.
isVisible
()).
toBe
(
true
);
});
});
});
it
(
'
renders footer list items
'
,
()
=>
{
it
(
'
renders footer list items
'
,
()
=>
{
const
footerLinks
=
findDropdownFooter
().
findAll
(
GlLink
);
const
footerLinks
=
findDropdownFooter
().
findAll
(
GlLink
);
...
@@ -393,15 +388,14 @@ describe('DropdownContentsLabelsView', () => {
...
@@ -393,15 +388,14 @@ describe('DropdownContentsLabelsView', () => {
expect
(
manageLabelsLink
.
text
()).
toBe
(
'
Manage labels
'
);
expect
(
manageLabelsLink
.
text
()).
toBe
(
'
Manage labels
'
);
});
});
it
(
'
does not render "Create label" footer link when `state.allowLabelCreate` is `false`
'
,
()
=>
{
it
(
'
does not render "Create label" footer link when `state.allowLabelCreate` is `false`
'
,
async
()
=>
{
wrapper
.
vm
.
$store
.
state
.
allowLabelCreate
=
false
;
wrapper
.
vm
.
$store
.
state
.
allowLabelCreate
=
false
;
return
wrapper
.
vm
.
$nextTick
(()
=>
{
await
nextTick
();
const
createLabelLink
=
findDropdownFooter
().
findAll
(
GlLink
).
at
(
0
);
const
createLabelLink
=
findDropdownFooter
().
findAll
(
GlLink
).
at
(
0
);
expect
(
createLabelLink
.
text
()).
not
.
toBe
(
'
Create label
'
);
expect
(
createLabelLink
.
text
()).
not
.
toBe
(
'
Create label
'
);
});
});
});
it
(
'
does not render footer list items when `state.variant` is "standalone"
'
,
()
=>
{
it
(
'
does not render footer list items when `state.variant` is "standalone"
'
,
()
=>
{
createComponent
({
...
mockConfig
,
variant
:
'
standalone
'
});
createComponent
({
...
mockConfig
,
variant
:
'
standalone
'
});
...
...
spec/frontend/vue_shared/components/sidebar/labels_select_vue/dropdown_title_spec.js
View file @
b712bfa7
import
{
GlButton
,
GlLoadingIcon
}
from
'
@gitlab/ui
'
;
import
{
GlButton
,
GlLoadingIcon
}
from
'
@gitlab/ui
'
;
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
Vue
from
'
vue
'
;
import
Vue
,
{
nextTick
}
from
'
vue
'
;
import
Vuex
from
'
vuex
'
;
import
Vuex
from
'
vuex
'
;
import
DropdownTitle
from
'
~/vue_shared/components/sidebar/labels_select_vue/dropdown_title.vue
'
;
import
DropdownTitle
from
'
~/vue_shared/components/sidebar/labels_select_vue/dropdown_title.vue
'
;
...
@@ -47,14 +47,13 @@ describe('DropdownTitle', () => {
...
@@ -47,14 +47,13 @@ describe('DropdownTitle', () => {
expect
(
editBtnEl
.
text
()).
toBe
(
'
Edit
'
);
expect
(
editBtnEl
.
text
()).
toBe
(
'
Edit
'
);
});
});
it
(
'
renders loading icon element when `labelsSelectInProgress` prop is true
'
,
()
=>
{
it
(
'
renders loading icon element when `labelsSelectInProgress` prop is true
'
,
async
()
=>
{
wrapper
.
setProps
({
wrapper
.
setProps
({
labelsSelectInProgress
:
true
,
labelsSelectInProgress
:
true
,
});
});
return
wrapper
.
vm
.
$nextTick
(()
=>
{
await
nextTick
();
expect
(
wrapper
.
find
(
GlLoadingIcon
).
isVisible
()).
toBe
(
true
);
expect
(
wrapper
.
find
(
GlLoadingIcon
).
isVisible
()).
toBe
(
true
);
});
});
});
});
});
});
});
spec/frontend/vue_shared/components/sidebar/labels_select_vue/dropdown_value_collapsed_spec.js
View file @
b712bfa7
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
GlIcon
}
from
'
@gitlab/ui
'
;
import
{
GlIcon
}
from
'
@gitlab/ui
'
;
import
{
nextTick
}
from
'
vue
'
;
import
{
createMockDirective
,
getBinding
}
from
'
helpers/vue_mock_directive
'
;
import
{
createMockDirective
,
getBinding
}
from
'
helpers/vue_mock_directive
'
;
import
DropdownValueCollapsedComponent
from
'
~/vue_shared/components/sidebar/labels_select_vue/dropdown_value_collapsed.vue
'
;
import
DropdownValueCollapsedComponent
from
'
~/vue_shared/components/sidebar/labels_select_vue/dropdown_value_collapsed.vue
'
;
...
@@ -42,7 +43,7 @@ describe('DropdownValueCollapsedComponent', () => {
...
@@ -42,7 +43,7 @@ describe('DropdownValueCollapsedComponent', () => {
wrapper
.
trigger
(
'
click
'
);
wrapper
.
trigger
(
'
click
'
);
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
expect
(
wrapper
.
emitted
(
'
onValueClick
'
)[
0
]).
toBeDefined
();
expect
(
wrapper
.
emitted
(
'
onValueClick
'
)[
0
]).
toBeDefined
();
});
});
...
...
spec/frontend/vue_shared/components/sidebar/labels_select_vue/labels_select_root_spec.js
View file @
b712bfa7
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
Vue
from
'
vue
'
;
import
Vue
,
{
nextTick
}
from
'
vue
'
;
import
Vuex
from
'
vuex
'
;
import
Vuex
from
'
vuex
'
;
import
{
isInViewport
}
from
'
~/lib/utils/common_utils
'
;
import
{
isInViewport
}
from
'
~/lib/utils/common_utils
'
;
...
@@ -139,27 +139,26 @@ describe('LabelsSelectRoot', () => {
...
@@ -139,27 +139,26 @@ describe('LabelsSelectRoot', () => {
${
'
embedded
'
}
|
${
'
is-embedded
'
}
${
'
embedded
'
}
|
${
'
is-embedded
'
}
`
(
`
(
'
renders component root element with CSS class `$cssClass` when `state.variant` is "$variant"
'
,
'
renders component root element with CSS class `$cssClass` when `state.variant` is "$variant"
'
,
({
variant
,
cssClass
})
=>
{
async
({
variant
,
cssClass
})
=>
{
createComponent
({
createComponent
({
...
mockConfig
,
...
mockConfig
,
variant
,
variant
,
});
});
return
wrapper
.
vm
.
$nextTick
(()
=>
{
await
nextTick
();
expect
(
wrapper
.
classes
()).
toContain
(
cssClass
);
expect
(
wrapper
.
classes
()).
toContain
(
cssClass
);
});
},
},
);
);
it
(
'
renders `dropdown-value-collapsed` component when `allowLabelCreate` prop is `true`
'
,
async
()
=>
{
it
(
'
renders `dropdown-value-collapsed` component when `allowLabelCreate` prop is `true`
'
,
async
()
=>
{
createComponent
();
createComponent
();
await
wrapper
.
vm
.
$
nextTick
;
await
nextTick
;
expect
(
wrapper
.
find
(
DropdownValueCollapsed
).
exists
()).
toBe
(
true
);
expect
(
wrapper
.
find
(
DropdownValueCollapsed
).
exists
()).
toBe
(
true
);
});
});
it
(
'
renders `dropdown-title` component
'
,
async
()
=>
{
it
(
'
renders `dropdown-title` component
'
,
async
()
=>
{
createComponent
();
createComponent
();
await
wrapper
.
vm
.
$
nextTick
;
await
nextTick
;
expect
(
wrapper
.
find
(
DropdownTitle
).
exists
()).
toBe
(
true
);
expect
(
wrapper
.
find
(
DropdownTitle
).
exists
()).
toBe
(
true
);
});
});
...
@@ -167,7 +166,7 @@ describe('LabelsSelectRoot', () => {
...
@@ -167,7 +166,7 @@ describe('LabelsSelectRoot', () => {
createComponent
(
mockConfig
,
{
createComponent
(
mockConfig
,
{
default
:
'
None
'
,
default
:
'
None
'
,
});
});
await
wrapper
.
vm
.
$
nextTick
;
await
nextTick
;
const
valueComp
=
wrapper
.
find
(
DropdownValue
);
const
valueComp
=
wrapper
.
find
(
DropdownValue
);
...
@@ -178,14 +177,14 @@ describe('LabelsSelectRoot', () => {
...
@@ -178,14 +177,14 @@ describe('LabelsSelectRoot', () => {
it
(
'
renders `dropdown-button` component when `showDropdownButton` prop is `true`
'
,
async
()
=>
{
it
(
'
renders `dropdown-button` component when `showDropdownButton` prop is `true`
'
,
async
()
=>
{
createComponent
();
createComponent
();
wrapper
.
vm
.
$store
.
dispatch
(
'
toggleDropdownButton
'
);
wrapper
.
vm
.
$store
.
dispatch
(
'
toggleDropdownButton
'
);
await
wrapper
.
vm
.
$
nextTick
;
await
nextTick
;
expect
(
wrapper
.
find
(
DropdownButton
).
exists
()).
toBe
(
true
);
expect
(
wrapper
.
find
(
DropdownButton
).
exists
()).
toBe
(
true
);
});
});
it
(
'
renders `dropdown-contents` component when `showDropdownButton` & `showDropdownContents` prop is `true`
'
,
async
()
=>
{
it
(
'
renders `dropdown-contents` component when `showDropdownButton` & `showDropdownContents` prop is `true`
'
,
async
()
=>
{
createComponent
();
createComponent
();
wrapper
.
vm
.
$store
.
dispatch
(
'
toggleDropdownContents
'
);
wrapper
.
vm
.
$store
.
dispatch
(
'
toggleDropdownContents
'
);
await
wrapper
.
vm
.
$
nextTick
;
await
nextTick
;
expect
(
wrapper
.
find
(
DropdownContents
).
exists
()).
toBe
(
true
);
expect
(
wrapper
.
find
(
DropdownContents
).
exists
()).
toBe
(
true
);
});
});
...
@@ -198,23 +197,21 @@ describe('LabelsSelectRoot', () => {
...
@@ -198,23 +197,21 @@ describe('LabelsSelectRoot', () => {
wrapper
.
vm
.
$store
.
dispatch
(
'
toggleDropdownContents
'
);
wrapper
.
vm
.
$store
.
dispatch
(
'
toggleDropdownContents
'
);
});
});
it
(
'
set direction when out of viewport
'
,
()
=>
{
it
(
'
set direction when out of viewport
'
,
async
()
=>
{
isInViewport
.
mockImplementation
(()
=>
false
);
isInViewport
.
mockImplementation
(()
=>
false
);
wrapper
.
vm
.
setContentIsOnViewport
(
wrapper
.
vm
.
$store
.
state
);
wrapper
.
vm
.
setContentIsOnViewport
(
wrapper
.
vm
.
$store
.
state
);
return
wrapper
.
vm
.
$nextTick
().
then
(()
=>
{
await
nextTick
();
expect
(
wrapper
.
find
(
DropdownContents
).
props
(
'
renderOnTop
'
)).
toBe
(
true
);
expect
(
wrapper
.
find
(
DropdownContents
).
props
(
'
renderOnTop
'
)).
toBe
(
true
);
});
});
});
it
(
'
does not set direction when inside of viewport
'
,
()
=>
{
it
(
'
does not set direction when inside of viewport
'
,
async
()
=>
{
isInViewport
.
mockImplementation
(()
=>
true
);
isInViewport
.
mockImplementation
(()
=>
true
);
wrapper
.
vm
.
setContentIsOnViewport
(
wrapper
.
vm
.
$store
.
state
);
wrapper
.
vm
.
setContentIsOnViewport
(
wrapper
.
vm
.
$store
.
state
);
return
wrapper
.
vm
.
$nextTick
().
then
(()
=>
{
await
nextTick
();
expect
(
wrapper
.
find
(
DropdownContents
).
props
(
'
renderOnTop
'
)).
toBe
(
false
);
expect
(
wrapper
.
find
(
DropdownContents
).
props
(
'
renderOnTop
'
)).
toBe
(
false
);
});
});
});
},
},
);
);
});
});
...
...
spec/frontend/vue_shared/components/sidebar/toggle_sidebar_spec.js
View file @
b712bfa7
import
{
GlButton
}
from
'
@gitlab/ui
'
;
import
{
GlButton
}
from
'
@gitlab/ui
'
;
import
{
mount
,
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
mount
,
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
nextTick
}
from
'
vue
'
;
import
ToggleSidebar
from
'
~/vue_shared/components/sidebar/toggle_sidebar.vue
'
;
import
ToggleSidebar
from
'
~/vue_shared/components/sidebar/toggle_sidebar.vue
'
;
describe
(
'
ToggleSidebar
'
,
()
=>
{
describe
(
'
ToggleSidebar
'
,
()
=>
{
...
@@ -38,7 +39,7 @@ describe('ToggleSidebar', () => {
...
@@ -38,7 +39,7 @@ describe('ToggleSidebar', () => {
createComponent
({
mountFn
:
mount
});
createComponent
({
mountFn
:
mount
});
findGlButton
().
trigger
(
'
click
'
);
findGlButton
().
trigger
(
'
click
'
);
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
expect
(
wrapper
.
emitted
(
'
toggle
'
)[
0
]).
toBeDefined
();
expect
(
wrapper
.
emitted
(
'
toggle
'
)[
0
]).
toBeDefined
();
});
});
...
...
spec/frontend/vue_shared/components/split_button_spec.js
View file @
b712bfa7
import
{
GlDropdown
,
GlDropdownItem
}
from
'
@gitlab/ui
'
;
import
{
GlDropdown
,
GlDropdownItem
}
from
'
@gitlab/ui
'
;
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
nextTick
}
from
'
vue
'
;
import
SplitButton
from
'
~/vue_shared/components/split_button.vue
'
;
import
SplitButton
from
'
~/vue_shared/components/split_button.vue
'
;
const
mockActionItems
=
[
const
mockActionItems
=
[
...
@@ -27,15 +28,15 @@ describe('SplitButton', () => {
...
@@ -27,15 +28,15 @@ describe('SplitButton', () => {
const
findDropdown
=
()
=>
wrapper
.
find
(
GlDropdown
);
const
findDropdown
=
()
=>
wrapper
.
find
(
GlDropdown
);
const
findDropdownItem
=
(
index
=
0
)
=>
findDropdown
().
findAll
(
GlDropdownItem
).
at
(
index
);
const
findDropdownItem
=
(
index
=
0
)
=>
findDropdown
().
findAll
(
GlDropdownItem
).
at
(
index
);
const
selectItem
=
(
index
)
=>
{
const
selectItem
=
async
(
index
)
=>
{
findDropdownItem
(
index
).
vm
.
$emit
(
'
click
'
);
findDropdownItem
(
index
).
vm
.
$emit
(
'
click
'
);
return
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
};
};
const
clickToggleButton
=
()
=>
{
const
clickToggleButton
=
async
()
=>
{
findDropdown
().
vm
.
$emit
(
'
click
'
);
findDropdown
().
vm
.
$emit
(
'
click
'
);
return
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
};
};
it
(
'
fails for empty actionItems
'
,
()
=>
{
it
(
'
fails for empty actionItems
'
,
()
=>
{
...
...
spec/frontend/vue_shared/components/upload_dropzone/upload_dropzone_spec.js
View file @
b712bfa7
import
{
GlIcon
,
GlSprintf
}
from
'
@gitlab/ui
'
;
import
{
GlIcon
,
GlSprintf
}
from
'
@gitlab/ui
'
;
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
nextTick
}
from
'
vue
'
;
import
UploadDropzone
from
'
~/vue_shared/components/upload_dropzone/upload_dropzone.vue
'
;
import
UploadDropzone
from
'
~/vue_shared/components/upload_dropzone/upload_dropzone.vue
'
;
jest
.
mock
(
'
~/flash
'
);
jest
.
mock
(
'
~/flash
'
);
...
@@ -84,49 +85,42 @@ describe('Upload dropzone component', () => {
...
@@ -84,49 +85,42 @@ describe('Upload dropzone component', () => {
$
{
'
contains text
'
}
|
${
mockDragEvent
({
types
:
[
'
text
'
]
})}
$
{
'
contains text
'
}
|
${
mockDragEvent
({
types
:
[
'
text
'
]
})}
${
'
contains files and text
'
}
|
${
mockDragEvent
({
types
:
[
'
Files
'
,
'
text
'
]
})}
${
'
contains files and text
'
}
|
${
mockDragEvent
({
types
:
[
'
Files
'
,
'
text
'
]
})}
${
'
contains files
'
}
|
${
mockDragEvent
({
types
:
[
'
Files
'
]
})}
${
'
contains files
'
}
|
${
mockDragEvent
({
types
:
[
'
Files
'
]
})}
`
(
'
renders correct template when drag event $description
'
,
({
eventPayload
})
=>
{
`
(
'
renders correct template when drag event $description
'
,
async
({
eventPayload
})
=>
{
createComponent
();
createComponent
();
wrapper
.
trigger
(
'
dragenter
'
,
eventPayload
);
wrapper
.
trigger
(
'
dragenter
'
,
eventPayload
);
return
wrapper
.
vm
.
$nextTick
().
then
(()
=>
{
await
nextTick
();
expect
(
wrapper
.
element
).
toMatchSnapshot
();
expect
(
wrapper
.
element
).
toMatchSnapshot
();
});
});
});
it
(
'
renders correct template when dragging stops
'
,
()
=>
{
it
(
'
renders correct template when dragging stops
'
,
async
()
=>
{
createComponent
();
createComponent
();
wrapper
.
trigger
(
'
dragenter
'
);
wrapper
.
trigger
(
'
dragenter
'
);
return
wrapper
.
vm
.
$nextTick
()
await
nextTick
();
.
then
(()
=>
{
wrapper
.
trigger
(
'
dragleave
'
);
wrapper
.
trigger
(
'
dragleave
'
);
return
wrapper
.
vm
.
$nextTick
();
})
await
nextTick
();
.
then
(()
=>
{
expect
(
wrapper
.
element
).
toMatchSnapshot
();
expect
(
wrapper
.
element
).
toMatchSnapshot
();
});
});
});
});
});
describe
(
'
when dropping
'
,
()
=>
{
describe
(
'
when dropping
'
,
()
=>
{
it
(
'
emits upload event
'
,
()
=>
{
it
(
'
emits upload event
'
,
async
()
=>
{
createComponent
();
createComponent
();
const
mockFile
=
{
name
:
'
test
'
,
type
:
'
image/jpg
'
};
const
mockFile
=
{
name
:
'
test
'
,
type
:
'
image/jpg
'
};
const
mockEvent
=
mockDragEvent
({
files
:
[
mockFile
]
});
const
mockEvent
=
mockDragEvent
({
files
:
[
mockFile
]
});
wrapper
.
trigger
(
'
dragenter
'
,
mockEvent
);
wrapper
.
trigger
(
'
dragenter
'
,
mockEvent
);
return
wrapper
.
vm
.
$nextTick
()
await
nextTick
();
.
then
(()
=>
{
wrapper
.
trigger
(
'
drop
'
,
mockEvent
);
wrapper
.
trigger
(
'
drop
'
,
mockEvent
);
return
wrapper
.
vm
.
$nextTick
();
})
await
nextTick
();
.
then
(()
=>
{
expect
(
wrapper
.
emitted
().
change
[
0
]).
toEqual
([[
mockFile
]]);
expect
(
wrapper
.
emitted
().
change
[
0
]).
toEqual
([[
mockFile
]]);
});
});
});
});
});
describe
(
'
ondrop
'
,
()
=>
{
describe
(
'
ondrop
'
,
()
=>
{
const
mockData
=
{
dragCounter
:
1
,
isDragDataValid
:
true
};
const
mockData
=
{
dragCounter
:
1
,
isDragDataValid
:
true
};
...
...
spec/frontend/vue_shared/components/user_avatar/user_avatar_list_spec.js
View file @
b712bfa7
import
{
GlButton
}
from
'
@gitlab/ui
'
;
import
{
GlButton
}
from
'
@gitlab/ui
'
;
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
nextTick
}
from
'
vue
'
;
import
{
TEST_HOST
}
from
'
spec/test_constants
'
;
import
{
TEST_HOST
}
from
'
spec/test_constants
'
;
import
UserAvatarLink
from
'
~/vue_shared/components/user_avatar/user_avatar_link.vue
'
;
import
UserAvatarLink
from
'
~/vue_shared/components/user_avatar/user_avatar_link.vue
'
;
import
UserAvatarList
from
'
~/vue_shared/components/user_avatar/user_avatar_list.vue
'
;
import
UserAvatarList
from
'
~/vue_shared/components/user_avatar/user_avatar_list.vue
'
;
...
@@ -142,15 +143,14 @@ describe('UserAvatarList', () => {
...
@@ -142,15 +143,14 @@ describe('UserAvatarList', () => {
expect
(
links
.
length
).
toEqual
(
props
.
items
.
length
);
expect
(
links
.
length
).
toEqual
(
props
.
items
.
length
);
});
});
it
(
'
with collapse clicked, it renders avatars up to breakpoint
'
,
()
=>
{
it
(
'
with collapse clicked, it renders avatars up to breakpoint
'
,
async
()
=>
{
clickButton
();
clickButton
();
return
wrapper
.
vm
.
$nextTick
(()
=>
{
await
nextTick
();
const
links
=
wrapper
.
findAll
(
UserAvatarLink
);
const
links
=
wrapper
.
findAll
(
UserAvatarLink
);
expect
(
links
.
length
).
toEqual
(
TEST_BREAKPOINT
);
expect
(
links
.
length
).
toEqual
(
TEST_BREAKPOINT
);
});
});
});
});
});
});
});
});
});
spec/frontend/vue_shared/components/web_ide_link_spec.js
View file @
b712bfa7
...
@@ -213,7 +213,7 @@ describe('Web IDE link component', () => {
...
@@ -213,7 +213,7 @@ describe('Web IDE link component', () => {
findLocalStorageSync
().
vm
.
$emit
(
'
input
'
,
ACTION_GITPOD
.
key
);
findLocalStorageSync
().
vm
.
$emit
(
'
input
'
,
ACTION_GITPOD
.
key
);
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
expect
(
findActionsButton
().
props
(
'
selectedKey
'
)).
toBe
(
ACTION_GITPOD
.
key
);
expect
(
findActionsButton
().
props
(
'
selectedKey
'
)).
toBe
(
ACTION_GITPOD
.
key
);
});
});
...
@@ -223,7 +223,7 @@ describe('Web IDE link component', () => {
...
@@ -223,7 +223,7 @@ describe('Web IDE link component', () => {
findActionsButton
().
vm
.
$emit
(
'
select
'
,
ACTION_GITPOD
.
key
);
findActionsButton
().
vm
.
$emit
(
'
select
'
,
ACTION_GITPOD
.
key
);
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
expect
(
findActionsButton
().
props
(
'
selectedKey
'
)).
toBe
(
ACTION_GITPOD
.
key
);
expect
(
findActionsButton
().
props
(
'
selectedKey
'
)).
toBe
(
ACTION_GITPOD
.
key
);
expect
(
findLocalStorageSync
().
props
(
'
value
'
)).
toBe
(
ACTION_GITPOD
.
key
);
expect
(
findLocalStorageSync
().
props
(
'
value
'
)).
toBe
(
ACTION_GITPOD
.
key
);
...
...
spec/frontend/vue_shared/directives/track_event_spec.js
View file @
b712bfa7
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
Vue
from
'
vue
'
;
import
Vue
,
{
nextTick
}
from
'
vue
'
;
import
Tracking
from
'
~/tracking
'
;
import
Tracking
from
'
~/tracking
'
;
import
TrackEvent
from
'
~/vue_shared/directives/track_event
'
;
import
TrackEvent
from
'
~/vue_shared/directives/track_event
'
;
...
@@ -31,7 +31,7 @@ describe('Error Tracking directive', () => {
...
@@ -31,7 +31,7 @@ describe('Error Tracking directive', () => {
expect
(
Tracking
.
event
).
not
.
toHaveBeenCalled
();
expect
(
Tracking
.
event
).
not
.
toHaveBeenCalled
();
});
});
it
(
'
should track event on click if tracking info provided
'
,
()
=>
{
it
(
'
should track event on click if tracking info provided
'
,
async
()
=>
{
const
trackingOptions
=
{
const
trackingOptions
=
{
category
:
'
Tracking
'
,
category
:
'
Tracking
'
,
action
:
'
click_trackable_btn
'
,
action
:
'
click_trackable_btn
'
,
...
@@ -43,9 +43,8 @@ describe('Error Tracking directive', () => {
...
@@ -43,9 +43,8 @@ describe('Error Tracking directive', () => {
wrapper
.
setData
({
trackingOptions
});
wrapper
.
setData
({
trackingOptions
});
const
{
category
,
action
,
label
,
property
,
value
}
=
trackingOptions
;
const
{
category
,
action
,
label
,
property
,
value
}
=
trackingOptions
;
return
wrapper
.
vm
.
$nextTick
(()
=>
{
await
nextTick
();
button
.
trigger
(
'
click
'
);
button
.
trigger
(
'
click
'
);
expect
(
Tracking
.
event
).
toHaveBeenCalledWith
(
category
,
action
,
{
label
,
property
,
value
});
expect
(
Tracking
.
event
).
toHaveBeenCalledWith
(
category
,
action
,
{
label
,
property
,
value
});
});
});
});
});
});
spec/frontend/vue_shared/issuable/list/components/issuable_item_spec.js
View file @
b712bfa7
import
{
GlLink
,
GlLabel
,
GlIcon
,
GlFormCheckbox
,
GlSprintf
}
from
'
@gitlab/ui
'
;
import
{
GlLink
,
GlLabel
,
GlIcon
,
GlFormCheckbox
,
GlSprintf
}
from
'
@gitlab/ui
'
;
import
{
nextTick
}
from
'
vue
'
;
import
{
useFakeDate
}
from
'
helpers/fake_date
'
;
import
{
useFakeDate
}
from
'
helpers/fake_date
'
;
import
{
shallowMountExtended
as
shallowMount
}
from
'
helpers/vue_test_utils_helper
'
;
import
{
shallowMountExtended
as
shallowMount
}
from
'
helpers/vue_test_utils_helper
'
;
import
IssuableItem
from
'
~/vue_shared/issuable/list/components/issuable_item.vue
'
;
import
IssuableItem
from
'
~/vue_shared/issuable/list/components/issuable_item.vue
'
;
...
@@ -76,7 +77,7 @@ describe('IssuableItem', () => {
...
@@ -76,7 +77,7 @@ describe('IssuableItem', () => {
},
},
});
});
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
expect
(
wrapper
.
vm
.
authorId
).
toBe
(
returnValue
);
expect
(
wrapper
.
vm
.
authorId
).
toBe
(
returnValue
);
},
},
...
@@ -100,7 +101,7 @@ describe('IssuableItem', () => {
...
@@ -100,7 +101,7 @@ describe('IssuableItem', () => {
},
},
});
});
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
expect
(
wrapper
.
vm
.
isIssuableUrlExternal
).
toBe
(
returnValue
);
expect
(
wrapper
.
vm
.
isIssuableUrlExternal
).
toBe
(
returnValue
);
},
},
...
@@ -122,7 +123,7 @@ describe('IssuableItem', () => {
...
@@ -122,7 +123,7 @@ describe('IssuableItem', () => {
},
},
});
});
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
expect
(
wrapper
.
vm
.
labels
).
toEqual
(
mockLabels
);
expect
(
wrapper
.
vm
.
labels
).
toEqual
(
mockLabels
);
});
});
...
@@ -135,7 +136,7 @@ describe('IssuableItem', () => {
...
@@ -135,7 +136,7 @@ describe('IssuableItem', () => {
},
},
});
});
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
expect
(
wrapper
.
vm
.
labels
).
toEqual
([]);
expect
(
wrapper
.
vm
.
labels
).
toEqual
([]);
});
});
...
@@ -224,7 +225,7 @@ describe('IssuableItem', () => {
...
@@ -224,7 +225,7 @@ describe('IssuableItem', () => {
enableLabelPermalinks
:
false
,
enableLabelPermalinks
:
false
,
});
});
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
expect
(
wrapper
.
vm
.
labelTarget
(
mockRegularLabel
)).
toBe
(
'
#
'
);
expect
(
wrapper
.
vm
.
labelTarget
(
mockRegularLabel
)).
toBe
(
'
#
'
);
});
});
...
@@ -248,7 +249,7 @@ describe('IssuableItem', () => {
...
@@ -248,7 +249,7 @@ describe('IssuableItem', () => {
},
},
});
});
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
const
titleEl
=
wrapper
.
find
(
'
[data-testid="issuable-title"]
'
);
const
titleEl
=
wrapper
.
find
(
'
[data-testid="issuable-title"]
'
);
...
@@ -264,7 +265,7 @@ describe('IssuableItem', () => {
...
@@ -264,7 +265,7 @@ describe('IssuableItem', () => {
showCheckbox
:
true
,
showCheckbox
:
true
,
});
});
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
expect
(
wrapper
.
find
(
GlFormCheckbox
).
exists
()).
toBe
(
true
);
expect
(
wrapper
.
find
(
GlFormCheckbox
).
exists
()).
toBe
(
true
);
expect
(
wrapper
.
find
(
GlFormCheckbox
).
attributes
(
'
checked
'
)).
not
.
toBeDefined
();
expect
(
wrapper
.
find
(
GlFormCheckbox
).
attributes
(
'
checked
'
)).
not
.
toBeDefined
();
...
@@ -273,7 +274,7 @@ describe('IssuableItem', () => {
...
@@ -273,7 +274,7 @@ describe('IssuableItem', () => {
checked
:
true
,
checked
:
true
,
});
});
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
expect
(
wrapper
.
find
(
GlFormCheckbox
).
attributes
(
'
checked
'
)).
toBe
(
'
true
'
);
expect
(
wrapper
.
find
(
GlFormCheckbox
).
attributes
(
'
checked
'
)).
toBe
(
'
true
'
);
});
});
...
@@ -286,7 +287,7 @@ describe('IssuableItem', () => {
...
@@ -286,7 +287,7 @@ describe('IssuableItem', () => {
},
},
});
});
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
expect
(
wrapper
.
find
(
'
[data-testid="issuable-title"]
'
).
find
(
GlLink
).
attributes
(
'
target
'
)).
toBe
(
expect
(
wrapper
.
find
(
'
[data-testid="issuable-title"]
'
).
find
(
GlLink
).
attributes
(
'
target
'
)).
toBe
(
'
_blank
'
,
'
_blank
'
,
...
@@ -301,7 +302,7 @@ describe('IssuableItem', () => {
...
@@ -301,7 +302,7 @@ describe('IssuableItem', () => {
},
},
});
});
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
const
confidentialEl
=
wrapper
.
find
(
'
[data-testid="issuable-title"]
'
).
find
(
GlIcon
);
const
confidentialEl
=
wrapper
.
find
(
'
[data-testid="issuable-title"]
'
).
find
(
GlIcon
);
...
...
spec/frontend/vue_shared/issuable/list/components/issuable_list_root_spec.js
View file @
b712bfa7
...
@@ -2,6 +2,7 @@ import { GlAlert, GlKeysetPagination, GlSkeletonLoading, GlPagination } from '@g
...
@@ -2,6 +2,7 @@ import { GlAlert, GlKeysetPagination, GlSkeletonLoading, GlPagination } from '@g
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
VueDraggable
from
'
vuedraggable
'
;
import
VueDraggable
from
'
vuedraggable
'
;
import
{
nextTick
}
from
'
vue
'
;
import
{
TEST_HOST
}
from
'
helpers/test_constants
'
;
import
{
TEST_HOST
}
from
'
helpers/test_constants
'
;
import
IssuableItem
from
'
~/vue_shared/issuable/list/components/issuable_item.vue
'
;
import
IssuableItem
from
'
~/vue_shared/issuable/list/components/issuable_item.vue
'
;
...
@@ -77,7 +78,7 @@ describe('IssuableListRoot', () => {
...
@@ -77,7 +78,7 @@ describe('IssuableListRoot', () => {
currentPage
,
currentPage
,
});
});
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
expect
(
wrapper
.
vm
.
skeletonItemCount
).
toBe
(
returnValue
);
expect
(
wrapper
.
vm
.
skeletonItemCount
).
toBe
(
returnValue
);
},
},
...
@@ -96,7 +97,7 @@ describe('IssuableListRoot', () => {
...
@@ -96,7 +97,7 @@ describe('IssuableListRoot', () => {
issuables
,
issuables
,
});
});
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
// setData usage is discouraged. See https://gitlab.com/groups/gitlab-org/-/epics/7330 for details
// setData usage is discouraged. See https://gitlab.com/groups/gitlab-org/-/epics/7330 for details
// eslint-disable-next-line no-restricted-syntax
// eslint-disable-next-line no-restricted-syntax
...
@@ -104,7 +105,7 @@ describe('IssuableListRoot', () => {
...
@@ -104,7 +105,7 @@ describe('IssuableListRoot', () => {
checkedIssuables
,
checkedIssuables
,
});
});
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
expect
(
wrapper
.
vm
.
allIssuablesChecked
).
toBe
(
returnValue
);
expect
(
wrapper
.
vm
.
allIssuablesChecked
).
toBe
(
returnValue
);
},
},
...
@@ -119,7 +120,7 @@ describe('IssuableListRoot', () => {
...
@@ -119,7 +120,7 @@ describe('IssuableListRoot', () => {
checkedIssuables
:
mockCheckedIssuables
,
checkedIssuables
:
mockCheckedIssuables
,
});
});
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
expect
(
wrapper
.
vm
.
bulkEditIssuables
).
toHaveLength
(
mIssuables
.
length
);
expect
(
wrapper
.
vm
.
bulkEditIssuables
).
toHaveLength
(
mIssuables
.
length
);
});
});
...
@@ -137,7 +138,7 @@ describe('IssuableListRoot', () => {
...
@@ -137,7 +138,7 @@ describe('IssuableListRoot', () => {
issuables
:
[
mockIssuables
[
0
]],
issuables
:
[
mockIssuables
[
0
]],
});
});
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
expect
(
Object
.
keys
(
wrapper
.
vm
.
checkedIssuables
)).
toHaveLength
(
1
);
expect
(
Object
.
keys
(
wrapper
.
vm
.
checkedIssuables
)).
toHaveLength
(
1
);
expect
(
wrapper
.
vm
.
checkedIssuables
[
mockIssuables
[
0
].
iid
]).
toEqual
({
expect
(
wrapper
.
vm
.
checkedIssuables
[
mockIssuables
[
0
].
iid
]).
toEqual
({
...
@@ -160,7 +161,7 @@ describe('IssuableListRoot', () => {
...
@@ -160,7 +161,7 @@ describe('IssuableListRoot', () => {
urlParams
,
urlParams
,
});
});
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
expect
(
global
.
window
.
location
.
href
).
toBe
(
expect
(
global
.
window
.
location
.
href
).
toBe
(
`
${
TEST_HOST
}
/?state=
${
urlParams
.
state
}
&sort=
${
urlParams
.
sort
}
&page=
${
urlParams
.
page
}
&search=
${
urlParams
.
search
}
`
,
`
${
TEST_HOST
}
/?state=
${
urlParams
.
state
}
&sort=
${
urlParams
.
sort
}
&page=
${
urlParams
.
page
}
&search=
${
urlParams
.
search
}
`
,
...
@@ -192,7 +193,7 @@ describe('IssuableListRoot', () => {
...
@@ -192,7 +193,7 @@ describe('IssuableListRoot', () => {
},
},
});
});
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
expect
(
wrapper
.
vm
.
issuableChecked
(
mockIssuables
[
0
])).
toBe
(
true
);
expect
(
wrapper
.
vm
.
issuableChecked
(
mockIssuables
[
0
])).
toBe
(
true
);
});
});
...
...
spec/frontend/vue_shared/issuable/show/components/issuable_body_spec.js
View file @
b712bfa7
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
nextTick
}
from
'
vue
'
;
import
{
useFakeDate
}
from
'
helpers/fake_date
'
;
import
{
useFakeDate
}
from
'
helpers/fake_date
'
;
import
IssuableBody
from
'
~/vue_shared/issuable/show/components/issuable_body.vue
'
;
import
IssuableBody
from
'
~/vue_shared/issuable/show/components/issuable_body.vue
'
;
...
@@ -68,7 +69,7 @@ describe('IssuableBody', () => {
...
@@ -68,7 +69,7 @@ describe('IssuableBody', () => {
},
},
});
});
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
expect
(
wrapper
.
vm
.
isUpdated
).
toBe
(
returnValue
);
expect
(
wrapper
.
vm
.
isUpdated
).
toBe
(
returnValue
);
},
},
...
@@ -90,13 +91,13 @@ describe('IssuableBody', () => {
...
@@ -90,13 +91,13 @@ describe('IssuableBody', () => {
editFormVisible
:
true
,
editFormVisible
:
true
,
});
});
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
wrapper
.
setProps
({
wrapper
.
setProps
({
editFormVisible
:
false
,
editFormVisible
:
false
,
});
});
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
expect
(
wrapper
.
vm
.
initTaskList
).
toHaveBeenCalled
();
expect
(
wrapper
.
vm
.
initTaskList
).
toHaveBeenCalled
();
});
});
...
@@ -182,7 +183,7 @@ describe('IssuableBody', () => {
...
@@ -182,7 +183,7 @@ describe('IssuableBody', () => {
editFormVisible
:
true
,
editFormVisible
:
true
,
});
});
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
const
editFormEl
=
wrapper
.
find
(
IssuableEditForm
);
const
editFormEl
=
wrapper
.
find
(
IssuableEditForm
);
expect
(
editFormEl
.
exists
()).
toBe
(
true
);
expect
(
editFormEl
.
exists
()).
toBe
(
true
);
...
@@ -221,7 +222,7 @@ describe('IssuableBody', () => {
...
@@ -221,7 +222,7 @@ describe('IssuableBody', () => {
editFormVisible
:
true
,
editFormVisible
:
true
,
});
});
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
const
issuableEditForm
=
wrapper
.
find
(
IssuableEditForm
);
const
issuableEditForm
=
wrapper
.
find
(
IssuableEditForm
);
...
...
spec/frontend/vue_shared/issuable/show/components/issuable_edit_form_spec.js
View file @
b712bfa7
import
{
GlFormInput
}
from
'
@gitlab/ui
'
;
import
{
GlFormInput
}
from
'
@gitlab/ui
'
;
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
nextTick
}
from
'
vue
'
;
import
IssuableEditForm
from
'
~/vue_shared/issuable/show/components/issuable_edit_form.vue
'
;
import
IssuableEditForm
from
'
~/vue_shared/issuable/show/components/issuable_edit_form.vue
'
;
import
IssuableEventHub
from
'
~/vue_shared/issuable/show/event_hub
'
;
import
IssuableEventHub
from
'
~/vue_shared/issuable/show/event_hub
'
;
import
MarkdownField
from
'
~/vue_shared/components/markdown/field.vue
'
;
import
MarkdownField
from
'
~/vue_shared/components/markdown/field.vue
'
;
...
@@ -52,7 +53,7 @@ describe('IssuableEditForm', () => {
...
@@ -52,7 +53,7 @@ describe('IssuableEditForm', () => {
},
},
});
});
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
expect
(
wrapper
.
vm
.
title
).
toBe
(
'
Foo
'
);
expect
(
wrapper
.
vm
.
title
).
toBe
(
'
Foo
'
);
expect
(
wrapper
.
vm
.
description
).
toBe
(
'
Foobar
'
);
expect
(
wrapper
.
vm
.
description
).
toBe
(
'
Foobar
'
);
...
@@ -67,7 +68,7 @@ describe('IssuableEditForm', () => {
...
@@ -67,7 +68,7 @@ describe('IssuableEditForm', () => {
},
},
});
});
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
expect
(
wrapper
.
vm
.
title
).
toBe
(
''
);
expect
(
wrapper
.
vm
.
title
).
toBe
(
''
);
expect
(
wrapper
.
vm
.
description
).
toBe
(
''
);
expect
(
wrapper
.
vm
.
description
).
toBe
(
''
);
...
...
spec/frontend/vue_shared/issuable/show/components/issuable_header_spec.js
View file @
b712bfa7
import
{
GlIcon
,
GlAvatarLabeled
}
from
'
@gitlab/ui
'
;
import
{
GlIcon
,
GlAvatarLabeled
}
from
'
@gitlab/ui
'
;
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
nextTick
}
from
'
vue
'
;
import
{
extendedWrapper
}
from
'
helpers/vue_test_utils_helper
'
;
import
{
extendedWrapper
}
from
'
helpers/vue_test_utils_helper
'
;
import
IssuableHeader
from
'
~/vue_shared/issuable/show/components/issuable_header.vue
'
;
import
IssuableHeader
from
'
~/vue_shared/issuable/show/components/issuable_header.vue
'
;
...
@@ -78,7 +79,7 @@ describe('IssuableHeader', () => {
...
@@ -78,7 +79,7 @@ describe('IssuableHeader', () => {
blocked
:
true
,
blocked
:
true
,
});
});
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
const
blockedEl
=
wrapper
.
findByTestId
(
'
blocked
'
);
const
blockedEl
=
wrapper
.
findByTestId
(
'
blocked
'
);
...
@@ -91,7 +92,7 @@ describe('IssuableHeader', () => {
...
@@ -91,7 +92,7 @@ describe('IssuableHeader', () => {
confidential
:
true
,
confidential
:
true
,
});
});
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
const
confidentialEl
=
wrapper
.
findByTestId
(
'
confidential
'
);
const
confidentialEl
=
wrapper
.
findByTestId
(
'
confidential
'
);
...
...
spec/frontend/vue_shared/issuable/show/components/issuable_title_spec.js
View file @
b712bfa7
import
{
GlIcon
,
GlButton
,
GlIntersectionObserver
}
from
'
@gitlab/ui
'
;
import
{
GlIcon
,
GlButton
,
GlIntersectionObserver
}
from
'
@gitlab/ui
'
;
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
nextTick
}
from
'
vue
'
;
import
{
createMockDirective
,
getBinding
}
from
'
helpers/vue_mock_directive
'
;
import
{
createMockDirective
,
getBinding
}
from
'
helpers/vue_mock_directive
'
;
import
IssuableTitle
from
'
~/vue_shared/issuable/show/components/issuable_title.vue
'
;
import
IssuableTitle
from
'
~/vue_shared/issuable/show/components/issuable_title.vue
'
;
...
@@ -64,7 +65,7 @@ describe('IssuableTitle', () => {
...
@@ -64,7 +65,7 @@ describe('IssuableTitle', () => {
},
},
});
});
await
wrapperWithTitle
.
vm
.
$
nextTick
();
await
nextTick
();
const
titleEl
=
wrapperWithTitle
.
find
(
'
h2
'
);
const
titleEl
=
wrapperWithTitle
.
find
(
'
h2
'
);
expect
(
titleEl
.
exists
()).
toBe
(
true
);
expect
(
titleEl
.
exists
()).
toBe
(
true
);
...
@@ -90,7 +91,7 @@ describe('IssuableTitle', () => {
...
@@ -90,7 +91,7 @@ describe('IssuableTitle', () => {
stickyTitleVisible
:
true
,
stickyTitleVisible
:
true
,
});
});
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
const
stickyHeaderEl
=
wrapper
.
find
(
'
[data-testid="header"]
'
);
const
stickyHeaderEl
=
wrapper
.
find
(
'
[data-testid="header"]
'
);
expect
(
stickyHeaderEl
.
exists
()).
toBe
(
true
);
expect
(
stickyHeaderEl
.
exists
()).
toBe
(
true
);
...
...
spec/frontend/vue_shared/issuable/sidebar/components/issuable_sidebar_root_spec.js
View file @
b712bfa7
import
{
GlBreakpointInstance
as
bp
}
from
'
@gitlab/ui/dist/utils
'
;
import
{
GlBreakpointInstance
as
bp
}
from
'
@gitlab/ui/dist/utils
'
;
import
Cookies
from
'
js-cookie
'
;
import
Cookies
from
'
js-cookie
'
;
import
{
nextTick
}
from
'
vue
'
;
import
{
shallowMountExtended
}
from
'
helpers/vue_test_utils_helper
'
;
import
{
shallowMountExtended
}
from
'
helpers/vue_test_utils_helper
'
;
import
IssuableSidebarRoot
from
'
~/vue_shared/issuable/sidebar/components/issuable_sidebar_root.vue
'
;
import
IssuableSidebarRoot
from
'
~/vue_shared/issuable/sidebar/components/issuable_sidebar_root.vue
'
;
...
@@ -88,7 +89,7 @@ describe('IssuableSidebarRoot', () => {
...
@@ -88,7 +89,7 @@ describe('IssuableSidebarRoot', () => {
jest
.
spyOn
(
bp
,
'
isDesktop
'
).
mockReturnValue
(
breakpoint
===
'
lg
'
||
breakpoint
===
'
xl
'
);
jest
.
spyOn
(
bp
,
'
isDesktop
'
).
mockReturnValue
(
breakpoint
===
'
lg
'
||
breakpoint
===
'
xl
'
);
window
.
dispatchEvent
(
new
Event
(
'
resize
'
));
window
.
dispatchEvent
(
new
Event
(
'
resize
'
));
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
assertPageLayoutClasses
({
isExpanded
:
isExpandedValue
});
assertPageLayoutClasses
({
isExpanded
:
isExpandedValue
});
},
},
...
...
spec/frontend/vue_shared/new_namespace/components/welcome_spec.js
View file @
b712bfa7
...
@@ -37,10 +37,9 @@ describe('Welcome page', () => {
...
@@ -37,10 +37,9 @@ describe('Welcome page', () => {
const
link
=
wrapper
.
find
(
'
a
'
);
const
link
=
wrapper
.
find
(
'
a
'
);
link
.
trigger
(
'
click
'
);
link
.
trigger
(
'
click
'
);
await
nextTick
();
await
nextTick
();
return
wrapper
.
vm
.
$nextTick
().
then
(()
=>
{
await
nextTick
();
expect
(
trackingSpy
).
toHaveBeenCalledWith
(
undefined
,
'
click_tab
'
,
{
label
:
'
test
'
});
expect
(
trackingSpy
).
toHaveBeenCalledWith
(
undefined
,
'
click_tab
'
,
{
label
:
'
test
'
});
});
});
});
it
(
'
renders footer slot if provided
'
,
()
=>
{
it
(
'
renders footer slot if provided
'
,
()
=>
{
const
DUMMY
=
'
Test message
'
;
const
DUMMY
=
'
Test message
'
;
...
...
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