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
b8618652
Commit
b8618652
authored
Jan 25, 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
79f66000
Changes
55
Show whitespace changes
Inline
Side-by-side
Showing
55 changed files
with
739 additions
and
1095 deletions
+739
-1095
ee/spec/frontend/analytics/devops_reports/devops_adoption/components/devops_adoption_overview_table_spec.js
...doption/components/devops_adoption_overview_table_spec.js
+2
-1
ee/spec/frontend/analytics/group_analytics/components/group_activity_card_spec.js
...cs/group_analytics/components/group_activity_card_spec.js
+21
-31
ee/spec/frontend/epic/components/sidebar_items/sidebar_todo_spec.js
...ontend/epic/components/sidebar_items/sidebar_todo_spec.js
+5
-9
ee/spec/frontend/group_member_contributions/components/app_spec.js
...rontend/group_member_contributions/components/app_spec.js
+11
-13
ee/spec/frontend/iterations/components/iteration_report_issues_spec.js
...end/iterations/components/iteration_report_issues_spec.js
+3
-2
ee/spec/frontend/operations/components/dashboard/dashboard_spec.js
...rontend/operations/components/dashboard/dashboard_spec.js
+35
-62
ee/spec/frontend/security_configuration/corpus_management/corpus_management_spec.js
...configuration/corpus_management/corpus_management_spec.js
+5
-5
ee/spec/frontend/vue_shared/components/notes/system_note_spec.js
.../frontend/vue_shared/components/notes/system_note_spec.js
+13
-16
spec/frontend/batch_comments/components/drafts_count_spec.js
spec/frontend/batch_comments/components/drafts_count_spec.js
+4
-7
spec/frontend/batch_comments/components/publish_button_spec.js
...frontend/batch_comments/components/publish_button_spec.js
+4
-7
spec/frontend/clusters/forms/components/integration_form_spec.js
...ontend/clusters/forms/components/integration_form_spec.js
+15
-25
spec/frontend/create_cluster/eks_cluster/components/service_credentials_form_spec.js
...r/eks_cluster/components/service_credentials_form_spec.js
+6
-7
spec/frontend/design_management/components/design_presentation_spec.js
.../design_management/components/design_presentation_spec.js
+49
-68
spec/frontend/diffs/components/settings_dropdown_spec.js
spec/frontend/diffs/components/settings_dropdown_spec.js
+3
-4
spec/frontend/filtered_search/recent_searches_root_spec.js
spec/frontend/filtered_search/recent_searches_root_spec.js
+3
-2
spec/frontend/groups/components/app_spec.js
spec/frontend/groups/components/app_spec.js
+29
-35
spec/frontend/groups/components/groups_spec.js
spec/frontend/groups/components/groups_spec.js
+12
-14
spec/frontend/ide/components/activity_bar_spec.js
spec/frontend/ide/components/activity_bar_spec.js
+4
-7
spec/frontend/ide/components/commit_sidebar/actions_spec.js
spec/frontend/ide/components/commit_sidebar/actions_spec.js
+11
-18
spec/frontend/ide/components/commit_sidebar/list_item_spec.js
.../frontend/ide/components/commit_sidebar/list_item_spec.js
+10
-21
spec/frontend/ide/components/commit_sidebar/message_field_spec.js
...ntend/ide/components/commit_sidebar/message_field_spec.js
+50
-88
spec/frontend/ide/components/commit_sidebar/new_merge_request_option_spec.js
...omponents/commit_sidebar/new_merge_request_option_spec.js
+16
-36
spec/frontend/ide/components/file_row_extra_spec.js
spec/frontend/ide/components/file_row_extra_spec.js
+25
-49
spec/frontend/ide/components/file_templates/bar_spec.js
spec/frontend/ide/components/file_templates/bar_spec.js
+11
-17
spec/frontend/ide/components/ide_status_bar_spec.js
spec/frontend/ide/components/ide_status_bar_spec.js
+5
-9
spec/frontend/ide/components/ide_tree_list_spec.js
spec/frontend/ide/components/ide_tree_list_spec.js
+5
-8
spec/frontend/ide/components/jobs/detail_spec.js
spec/frontend/ide/components/jobs/detail_spec.js
+11
-18
spec/frontend/ide/components/jobs/item_spec.js
spec/frontend/ide/components/jobs/item_spec.js
+4
-7
spec/frontend/ide/components/nav_dropdown_button_spec.js
spec/frontend/ide/components/nav_dropdown_button_spec.js
+10
-22
spec/frontend/ide/components/nav_dropdown_spec.js
spec/frontend/ide/components/nav_dropdown_spec.js
+7
-16
spec/frontend/ide/components/new_dropdown/button_spec.js
spec/frontend/ide/components/new_dropdown/button_spec.js
+7
-13
spec/frontend/ide/components/new_dropdown/modal_spec.js
spec/frontend/ide/components/new_dropdown/modal_spec.js
+7
-10
spec/frontend/ide/components/repo_editor_spec.js
spec/frontend/ide/components/repo_editor_spec.js
+14
-14
spec/frontend/ide/components/shared/tokened_input_spec.js
spec/frontend/ide/components/shared/tokened_input_spec.js
+4
-8
spec/frontend/issues/show/components/description_spec.js
spec/frontend/issues/show/components/description_spec.js
+34
-51
spec/frontend/notebook/cells/code_spec.js
spec/frontend/notebook/cells/code_spec.js
+5
-5
spec/frontend/notebook/cells/markdown_spec.js
spec/frontend/notebook/cells/markdown_spec.js
+35
-36
spec/frontend/popovers/index_spec.js
spec/frontend/popovers/index_spec.js
+8
-9
spec/frontend/prometheus_alerts/components/reset_key_spec.js
spec/frontend/prometheus_alerts/components/reset_key_spec.js
+19
-25
spec/frontend/repository/components/last_commit_spec.js
spec/frontend/repository/components/last_commit_spec.js
+13
-12
spec/frontend/repository/components/preview/index_spec.js
spec/frontend/repository/components/preview/index_spec.js
+10
-15
spec/frontend/repository/components/table/index_spec.js
spec/frontend/repository/components/table/index_spec.js
+7
-7
spec/frontend/repository/components/table/row_spec.js
spec/frontend/repository/components/table/row_spec.js
+37
-47
spec/frontend/repository/components/tree_content_spec.js
spec/frontend/repository/components/tree_content_spec.js
+7
-6
spec/frontend/serverless/components/functions_spec.js
spec/frontend/serverless/components/functions_spec.js
+5
-6
spec/frontend/snippets/components/snippet_blob_view_spec.js
spec/frontend/snippets/components/snippet_blob_view_spec.js
+15
-23
spec/frontend/tooltips/index_spec.js
spec/frontend/tooltips/index_spec.js
+8
-7
spec/frontend/vue_shared/components/diff_viewer/viewers/image_diff_viewer_spec.js
.../components/diff_viewer/viewers/image_diff_viewer_spec.js
+30
-40
spec/frontend/vue_shared/components/file_finder/index_spec.js
.../frontend/vue_shared/components/file_finder/index_spec.js
+9
-17
spec/frontend/vue_shared/components/file_finder/item_spec.js
spec/frontend/vue_shared/components/file_finder/item_spec.js
+20
-33
spec/frontend/vue_shared/components/gl_modal_vuex_spec.js
spec/frontend/vue_shared/components/gl_modal_vuex_spec.js
+7
-17
spec/frontend/vue_shared/components/markdown/field_spec.js
spec/frontend/vue_shared/components/markdown/field_spec.js
+31
-46
spec/frontend/vue_shared/components/project_avatar/default_spec.js
...tend/vue_shared/components/project_avatar/default_spec.js
+11
-19
spec/frontend/vue_shared/issuable/list/components/issuable_bulk_edit_sidebar_spec.js
...suable/list/components/issuable_bulk_edit_sidebar_spec.js
+3
-2
spec/frontend_integration/ide/ide_integration_spec.js
spec/frontend_integration/ide/ide_integration_spec.js
+4
-3
No files found.
ee/spec/frontend/analytics/devops_reports/devops_adoption/components/devops_adoption_overview_table_spec.js
View file @
b8618652
import
{
GlButton
,
GlIcon
,
GlBadge
,
GlProgressBar
,
GlLink
}
from
'
@gitlab/ui
'
;
import
{
GlButton
,
GlIcon
,
GlBadge
,
GlProgressBar
,
GlLink
}
from
'
@gitlab/ui
'
;
import
{
nextTick
}
from
'
vue
'
;
import
DevopsAdoptionDeleteModal
from
'
ee/analytics/devops_reports/devops_adoption/components/devops_adoption_delete_modal.vue
'
;
import
DevopsAdoptionDeleteModal
from
'
ee/analytics/devops_reports/devops_adoption/components/devops_adoption_delete_modal.vue
'
;
import
DevopsAdoptionOverviewTable
from
'
ee/analytics/devops_reports/devops_adoption/components/devops_adoption_overview_table.vue
'
;
import
DevopsAdoptionOverviewTable
from
'
ee/analytics/devops_reports/devops_adoption/components/devops_adoption_overview_table.vue
'
;
import
{
DEVOPS_ADOPTION_TABLE_CONFIGURATION
}
from
'
ee/analytics/devops_reports/devops_adoption/constants
'
;
import
{
DEVOPS_ADOPTION_TABLE_CONFIGURATION
}
from
'
ee/analytics/devops_reports/devops_adoption/constants
'
;
...
@@ -186,7 +187,7 @@ describe('DevopsAdoptionOverviewTable', () => {
...
@@ -186,7 +187,7 @@ describe('DevopsAdoptionOverviewTable', () => {
const
deleteButton
=
findColSubComponent
(
TABLE_TEST_IDS_ACTIONS
,
GlButton
);
const
deleteButton
=
findColSubComponent
(
TABLE_TEST_IDS_ACTIONS
,
GlButton
);
deleteButton
.
vm
.
$emit
(
'
click
'
);
deleteButton
.
vm
.
$emit
(
'
click
'
);
await
deleteButton
.
vm
.
$
nextTick
();
await
nextTick
();
});
});
it
(
'
renders delete modal
'
,
()
=>
{
it
(
'
renders delete modal
'
,
()
=>
{
...
...
ee/spec/frontend/analytics/group_analytics/components/group_activity_card_spec.js
View file @
b8618652
...
@@ -2,6 +2,7 @@ import { GlDeprecatedSkeletonLoading as GlSkeletonLoading } from '@gitlab/ui';
...
@@ -2,6 +2,7 @@ import { GlDeprecatedSkeletonLoading as GlSkeletonLoading } from '@gitlab/ui';
import
{
GlSingleStat
}
from
'
@gitlab/ui/dist/charts
'
;
import
{
GlSingleStat
}
from
'
@gitlab/ui/dist/charts
'
;
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
GroupActivityCard
from
'
ee/analytics/group_analytics/components/group_activity_card.vue
'
;
import
GroupActivityCard
from
'
ee/analytics/group_analytics/components/group_activity_card.vue
'
;
import
Api
from
'
ee/api
'
;
import
Api
from
'
ee/api
'
;
import
waitForPromises
from
'
helpers/wait_for_promises
'
;
import
waitForPromises
from
'
helpers/wait_for_promises
'
;
...
@@ -48,40 +49,32 @@ describe('GroupActivity component', () => {
...
@@ -48,40 +49,32 @@ describe('GroupActivity component', () => {
const
findAllSkeletonLoaders
=
()
=>
wrapper
.
findAllComponents
(
GlSkeletonLoading
);
const
findAllSkeletonLoaders
=
()
=>
wrapper
.
findAllComponents
(
GlSkeletonLoading
);
const
findAllSingleStats
=
()
=>
wrapper
.
findAllComponents
(
GlSingleStat
);
const
findAllSingleStats
=
()
=>
wrapper
.
findAllComponents
(
GlSingleStat
);
it
(
'
fetches the metrics and updates isLoading properly
'
,
()
=>
{
it
(
'
fetches the metrics and updates isLoading properly
'
,
async
()
=>
{
createComponent
();
createComponent
();
expect
(
wrapper
.
vm
.
isLoading
).
toBe
(
true
);
expect
(
wrapper
.
vm
.
isLoading
).
toBe
(
true
);
return
wrapper
.
vm
await
nextTick
();
.
$nextTick
()
.
then
(()
=>
{
expect
(
Api
.
groupActivityMergeRequestsCount
).
toHaveBeenCalledWith
(
TEST_GROUP_ID
);
expect
(
Api
.
groupActivityMergeRequestsCount
).
toHaveBeenCalledWith
(
TEST_GROUP_ID
);
expect
(
Api
.
groupActivityIssuesCount
).
toHaveBeenCalledWith
(
TEST_GROUP_ID
);
expect
(
Api
.
groupActivityIssuesCount
).
toHaveBeenCalledWith
(
TEST_GROUP_ID
);
expect
(
Api
.
groupActivityNewMembersCount
).
toHaveBeenCalledWith
(
TEST_GROUP_ID
);
expect
(
Api
.
groupActivityNewMembersCount
).
toHaveBeenCalledWith
(
TEST_GROUP_ID
);
waitForPromises
();
await
waitForPromises
();
})
.
then
(()
=>
{
expect
(
wrapper
.
vm
.
isLoading
).
toBe
(
false
);
expect
(
wrapper
.
vm
.
isLoading
).
toBe
(
false
);
expect
(
wrapper
.
vm
.
metrics
.
mergeRequests
.
value
).
toBe
(
10
);
expect
(
wrapper
.
vm
.
metrics
.
mergeRequests
.
value
).
toBe
(
10
);
expect
(
wrapper
.
vm
.
metrics
.
issues
.
value
).
toBe
(
20
);
expect
(
wrapper
.
vm
.
metrics
.
issues
.
value
).
toBe
(
20
);
expect
(
wrapper
.
vm
.
metrics
.
newMembers
.
value
).
toBe
(
30
);
expect
(
wrapper
.
vm
.
metrics
.
newMembers
.
value
).
toBe
(
30
);
});
});
});
it
(
'
updates the loading state properly
'
,
()
=>
{
it
(
'
updates the loading state properly
'
,
async
()
=>
{
createComponent
();
createComponent
();
expect
(
findAllSkeletonLoaders
()).
toHaveLength
(
3
);
expect
(
findAllSkeletonLoaders
()).
toHaveLength
(
3
);
return
wrapper
.
vm
await
nextTick
();
.
$nextTick
()
await
waitForPromises
();
.
then
(
waitForPromises
)
.
then
(()
=>
{
expect
(
findAllSkeletonLoaders
()).
toHaveLength
(
0
);
expect
(
findAllSkeletonLoaders
()).
toHaveLength
(
0
);
});
});
});
describe
(
'
metrics
'
,
()
=>
{
describe
(
'
metrics
'
,
()
=>
{
beforeEach
(()
=>
{
beforeEach
(()
=>
{
...
@@ -93,16 +86,13 @@ describe('GroupActivity component', () => {
...
@@ -93,16 +86,13 @@ describe('GroupActivity component', () => {
${
0
}
|
${
10
}
|
${
'
Merge Requests opened
'
}
${
0
}
|
${
10
}
|
${
'
Merge Requests opened
'
}
${
1
}
|
${
20
}
|
${
'
Issues opened
'
}
${
1
}
|
${
20
}
|
${
'
Issues opened
'
}
${
2
}
|
${
30
}
|
${
'
Members added
'
}
${
2
}
|
${
30
}
|
${
'
Members added
'
}
`
(
'
renders a GlSingleStat for "$title"
'
,
({
index
,
value
,
title
})
=>
{
`
(
'
renders a GlSingleStat for "$title"
'
,
async
({
index
,
value
,
title
})
=>
{
const
singleStat
=
findAllSingleStats
().
at
(
index
);
const
singleStat
=
findAllSingleStats
().
at
(
index
);
return
wrapper
.
vm
await
nextTick
();
.
$nextTick
()
await
waitForPromises
();
.
then
(
waitForPromises
)
.
then
(()
=>
{
expect
(
singleStat
.
props
(
'
value
'
)).
toBe
(
`
${
value
}
`
);
expect
(
singleStat
.
props
(
'
value
'
)).
toBe
(
`
${
value
}
`
);
expect
(
singleStat
.
props
(
'
title
'
)).
toBe
(
title
);
expect
(
singleStat
.
props
(
'
title
'
)).
toBe
(
title
);
});
});
});
});
});
});
});
ee/spec/frontend/epic/components/sidebar_items/sidebar_todo_spec.js
View file @
b8618652
import
Vue
from
'
vue
'
;
import
Vue
,
{
nextTick
}
from
'
vue
'
;
import
SidebarTodo
from
'
ee/epic/components/sidebar_items/sidebar_todo.vue
'
;
import
SidebarTodo
from
'
ee/epic/components/sidebar_items/sidebar_todo.vue
'
;
import
createStore
from
'
ee/epic/store
'
;
import
createStore
from
'
ee/epic/store
'
;
...
@@ -31,16 +31,12 @@ describe('SidebarTodoComponent', () => {
...
@@ -31,16 +31,12 @@ describe('SidebarTodoComponent', () => {
});
});
describe
(
'
template
'
,
()
=>
{
describe
(
'
template
'
,
()
=>
{
it
(
'
renders component container element with classes `block` & `todo` when `isUserSignedIn` & `sidebarCollapsed` is `true`
'
,
(
done
)
=>
{
it
(
'
renders component container element with classes `block` & `todo` when `isUserSignedIn` & `sidebarCollapsed` is `true`
'
,
async
(
)
=>
{
vm
.
sidebarCollapsed
=
true
;
vm
.
sidebarCollapsed
=
true
;
vm
.
$nextTick
()
await
nextTick
();
.
then
(()
=>
{
expect
(
vm
.
$el
.
classList
.
contains
(
'
block
'
)).
toBe
(
true
);
expect
(
vm
.
$el
.
classList
.
contains
(
'
block
'
)).
toBe
(
true
);
expect
(
vm
.
$el
.
classList
.
contains
(
'
todo
'
)).
toBe
(
true
);
expect
(
vm
.
$el
.
classList
.
contains
(
'
todo
'
)).
toBe
(
true
);
})
.
then
(
done
)
.
catch
(
done
.
fail
);
});
});
it
(
'
renders Todo toggle button element
'
,
()
=>
{
it
(
'
renders Todo toggle button element
'
,
()
=>
{
...
...
ee/spec/frontend/group_member_contributions/components/app_spec.js
View file @
b8618652
import
Vue
from
'
vue
'
;
import
Vue
,
{
nextTick
}
from
'
vue
'
;
import
AppComponent
from
'
ee/group_member_contributions/components/app.vue
'
;
import
AppComponent
from
'
ee/group_member_contributions/components/app.vue
'
;
import
GroupMemberStore
from
'
ee/group_member_contributions/store/group_member_store
'
;
import
GroupMemberStore
from
'
ee/group_member_contributions/store/group_member_store
'
;
...
@@ -48,10 +48,10 @@ describe('AppComponent', () => {
...
@@ -48,10 +48,10 @@ describe('AppComponent', () => {
expect
(
vm
.
$el
.
querySelector
(
'
h3
'
).
innerText
.
trim
()).
toBe
(
'
Contributions per group member
'
);
expect
(
vm
.
$el
.
querySelector
(
'
h3
'
).
innerText
.
trim
()).
toBe
(
'
Contributions per group member
'
);
});
});
it
(
'
shows loading icon when isLoading prop is true
'
,
()
=>
{
it
(
'
shows loading icon when isLoading prop is true
'
,
async
()
=>
{
vm
.
store
.
state
.
isLoading
=
true
;
vm
.
store
.
state
.
isLoading
=
true
;
return
vm
.
$nextTick
().
then
(()
=>
{
await
nextTick
();
const
loadingEl
=
vm
.
$el
.
querySelector
(
'
.loading-animation
'
);
const
loadingEl
=
vm
.
$el
.
querySelector
(
'
.loading-animation
'
);
expect
(
loadingEl
).
not
.
toBeNull
();
expect
(
loadingEl
).
not
.
toBeNull
();
...
@@ -59,14 +59,12 @@ describe('AppComponent', () => {
...
@@ -59,14 +59,12 @@ describe('AppComponent', () => {
'
Loading contribution stats for group members
'
,
'
Loading contribution stats for group members
'
,
);
);
});
});
});
it
(
'
renders table container element
'
,
()
=>
{
it
(
'
renders table container element
'
,
async
()
=>
{
vm
.
store
.
state
.
isLoading
=
false
;
vm
.
store
.
state
.
isLoading
=
false
;
return
vm
.
$nextTick
().
then
(()
=>
{
await
nextTick
();
expect
(
vm
.
$el
.
querySelector
(
'
table.table.gl-sortable
'
)).
not
.
toBeNull
();
expect
(
vm
.
$el
.
querySelector
(
'
table.table.gl-sortable
'
)).
not
.
toBeNull
();
});
});
});
});
});
});
});
ee/spec/frontend/iterations/components/iteration_report_issues_spec.js
View file @
b8618652
...
@@ -9,6 +9,7 @@ import {
...
@@ -9,6 +9,7 @@ import {
GlTable
,
GlTable
,
}
from
'
@gitlab/ui
'
;
}
from
'
@gitlab/ui
'
;
import
{
mount
,
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
mount
,
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
nextTick
}
from
'
vue
'
;
import
IterationReportIssues
from
'
ee/iterations/components/iteration_report_issues.vue
'
;
import
IterationReportIssues
from
'
ee/iterations/components/iteration_report_issues.vue
'
;
import
{
Namespace
}
from
'
ee/iterations/constants
'
;
import
{
Namespace
}
from
'
ee/iterations/constants
'
;
...
@@ -183,9 +184,9 @@ describe('Iterations report issues', () => {
...
@@ -183,9 +184,9 @@ describe('Iterations report issues', () => {
});
});
const
findPagination
=
()
=>
wrapper
.
findComponent
(
GlPagination
);
const
findPagination
=
()
=>
wrapper
.
findComponent
(
GlPagination
);
const
setPage
=
(
page
)
=>
{
const
setPage
=
async
(
page
)
=>
{
findPagination
().
vm
.
$emit
(
'
input
'
,
page
);
findPagination
().
vm
.
$emit
(
'
input
'
,
page
);
return
findPagination
().
vm
.
$
nextTick
();
await
nextTick
();
};
};
it
(
'
passes prev, next, and current page props
'
,
()
=>
{
it
(
'
passes prev, next, and current page props
'
,
()
=>
{
...
...
ee/spec/frontend/operations/components/dashboard/dashboard_spec.js
View file @
b8618652
import
{
GlEmptyState
}
from
'
@gitlab/ui
'
;
import
{
GlEmptyState
}
from
'
@gitlab/ui
'
;
import
{
mount
}
from
'
@vue/test-utils
'
;
import
{
mount
}
from
'
@vue/test-utils
'
;
import
Vue
from
'
vue
'
;
import
Vue
,
{
nextTick
}
from
'
vue
'
;
import
MockAdapter
from
'
axios-mock-adapter
'
;
import
MockAdapter
from
'
axios-mock-adapter
'
;
import
Vuex
from
'
vuex
'
;
import
Vuex
from
'
vuex
'
;
import
Dashboard
from
'
ee/operations/components/dashboard/dashboard.vue
'
;
import
Dashboard
from
'
ee/operations/components/dashboard/dashboard.vue
'
;
...
@@ -67,28 +67,21 @@ describe('dashboard component', () => {
...
@@ -67,28 +67,21 @@ describe('dashboard component', () => {
});
});
describe
(
'
when a project is added
'
,
()
=>
{
describe
(
'
when a project is added
'
,
()
=>
{
it
(
'
immediately requests the project list again
'
,
()
=>
{
it
(
'
immediately requests the project list again
'
,
async
()
=>
{
mockAxios
.
reset
();
mockAxios
.
reset
();
mockAxios
.
onGet
(
mockListEndpoint
).
replyOnce
(
200
,
{
projects
:
mockProjectData
(
2
)
});
mockAxios
.
onGet
(
mockListEndpoint
).
replyOnce
(
200
,
{
projects
:
mockProjectData
(
2
)
});
mockAxios
.
onPost
(
mockAddEndpoint
).
replyOnce
(
200
,
{
added
:
[
1
],
invalid
:
[]
});
mockAxios
.
onPost
(
mockAddEndpoint
).
replyOnce
(
200
,
{
added
:
[
1
],
invalid
:
[]
});
return
wrapper
.
vm
await
nextTick
();
.
$nextTick
()
.
then
(()
=>
{
wrapper
.
vm
.
projectClicked
({
id
:
1
});
wrapper
.
vm
.
projectClicked
({
id
:
1
});
})
await
waitForPromises
();
.
then
(
waitForPromises
)
.
then
(()
=>
{
wrapper
.
vm
.
onOk
();
wrapper
.
vm
.
onOk
();
})
await
waitForPromises
();
.
then
(
waitForPromises
)
.
then
(()
=>
{
expect
(
store
.
state
.
projects
.
length
).
toEqual
(
2
);
expect
(
store
.
state
.
projects
.
length
).
toEqual
(
2
);
expect
(
wrapper
.
findAllComponents
(
Project
).
length
).
toEqual
(
2
);
expect
(
wrapper
.
findAllComponents
(
Project
).
length
).
toEqual
(
2
);
});
});
});
});
});
});
});
describe
(
'
wrapped components
'
,
()
=>
{
describe
(
'
wrapped components
'
,
()
=>
{
describe
(
'
dashboard project component
'
,
()
=>
{
describe
(
'
dashboard project component
'
,
()
=>
{
...
@@ -144,66 +137,46 @@ describe('dashboard component', () => {
...
@@ -144,66 +137,46 @@ describe('dashboard component', () => {
store
.
state
.
selectedProjects
=
mockProjectData
(
1
);
store
.
state
.
selectedProjects
=
mockProjectData
(
1
);
});
});
it
(
'
clears state when adding a valid project
'
,
()
=>
{
it
(
'
clears state when adding a valid project
'
,
async
()
=>
{
mockAxios
.
onPost
(
mockAddEndpoint
).
replyOnce
(
200
,
{
added
:
[
1
],
invalid
:
[]
});
mockAxios
.
onPost
(
mockAddEndpoint
).
replyOnce
(
200
,
{
added
:
[
1
],
invalid
:
[]
});
return
wrapper
.
vm
await
nextTick
();
.
$nextTick
()
.
then
(()
=>
{
wrapper
.
vm
.
onOk
();
wrapper
.
vm
.
onOk
();
})
await
waitForPromises
();
.
then
(
waitForPromises
)
.
then
(()
=>
{
expect
(
store
.
state
.
projectSearchResults
).
toHaveLength
(
0
);
expect
(
store
.
state
.
projectSearchResults
).
toHaveLength
(
0
);
expect
(
store
.
state
.
selectedProjects
).
toHaveLength
(
0
);
expect
(
store
.
state
.
selectedProjects
).
toHaveLength
(
0
);
});
});
});
it
(
'
clears state when adding an invalid project
'
,
()
=>
{
it
(
'
clears state when adding an invalid project
'
,
async
()
=>
{
mockAxios
.
onPost
(
mockAddEndpoint
).
replyOnce
(
200
,
{
added
:
[],
invalid
:
[
1
]
});
mockAxios
.
onPost
(
mockAddEndpoint
).
replyOnce
(
200
,
{
added
:
[],
invalid
:
[
1
]
});
return
wrapper
.
vm
await
nextTick
();
.
$nextTick
()
.
then
(()
=>
{
wrapper
.
vm
.
onOk
();
wrapper
.
vm
.
onOk
();
})
await
waitForPromises
();
.
then
(
waitForPromises
)
.
then
(()
=>
{
expect
(
store
.
state
.
projectSearchResults
).
toHaveLength
(
0
);
expect
(
store
.
state
.
projectSearchResults
).
toHaveLength
(
0
);
expect
(
store
.
state
.
selectedProjects
).
toHaveLength
(
0
);
expect
(
store
.
state
.
selectedProjects
).
toHaveLength
(
0
);
});
});
});
it
(
'
clears state when canceled
'
,
()
=>
{
it
(
'
clears state when canceled
'
,
async
()
=>
{
return
wrapper
.
vm
await
nextTick
();
.
$nextTick
()
.
then
(()
=>
{
wrapper
.
vm
.
onCancel
();
wrapper
.
vm
.
onCancel
();
})
await
waitForPromises
();
.
then
(
waitForPromises
)
.
then
(()
=>
{
expect
(
store
.
state
.
projectSearchResults
).
toHaveLength
(
0
);
expect
(
store
.
state
.
projectSearchResults
).
toHaveLength
(
0
);
expect
(
store
.
state
.
selectedProjects
).
toHaveLength
(
0
);
expect
(
store
.
state
.
selectedProjects
).
toHaveLength
(
0
);
});
});
});
it
(
'
clears state on error
'
,
()
=>
{
it
(
'
clears state on error
'
,
async
()
=>
{
mockAxios
.
onPost
(
mockAddEndpoint
).
replyOnce
(
500
,
{});
mockAxios
.
onPost
(
mockAddEndpoint
).
replyOnce
(
500
,
{});
return
wrapper
.
vm
await
nextTick
();
.
$nextTick
()
.
then
(()
=>
{
expect
(
store
.
state
.
projectSearchResults
.
length
).
not
.
toBe
(
0
);
expect
(
store
.
state
.
projectSearchResults
.
length
).
not
.
toBe
(
0
);
expect
(
store
.
state
.
selectedProjects
.
length
).
not
.
toBe
(
0
);
expect
(
store
.
state
.
selectedProjects
.
length
).
not
.
toBe
(
0
);
wrapper
.
vm
.
onOk
();
wrapper
.
vm
.
onOk
();
})
await
waitForPromises
();
.
then
(
waitForPromises
)
.
then
(()
=>
{
expect
(
store
.
state
.
projectSearchResults
).
toHaveLength
(
0
);
expect
(
store
.
state
.
projectSearchResults
).
toHaveLength
(
0
);
expect
(
store
.
state
.
selectedProjects
).
toHaveLength
(
0
);
expect
(
store
.
state
.
selectedProjects
).
toHaveLength
(
0
);
});
});
});
});
});
describe
(
'
when no projects have been added
'
,
()
=>
{
describe
(
'
when no projects have been added
'
,
()
=>
{
beforeEach
(()
=>
{
beforeEach
(()
=>
{
...
...
ee/spec/frontend/security_configuration/corpus_management/corpus_management_spec.js
View file @
b8618652
import
{
merge
}
from
'
lodash
'
;
import
{
merge
}
from
'
lodash
'
;
import
{
GlLoadingIcon
,
GlKeysetPagination
}
from
'
@gitlab/ui
'
;
import
{
GlLoadingIcon
,
GlKeysetPagination
}
from
'
@gitlab/ui
'
;
import
Vue
from
'
vue
'
;
import
Vue
,
{
nextTick
}
from
'
vue
'
;
import
VueApollo
from
'
vue-apollo
'
;
import
VueApollo
from
'
vue-apollo
'
;
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
...
@@ -51,14 +51,14 @@ describe('EE - CorpusManagement', () => {
...
@@ -51,14 +51,14 @@ describe('EE - CorpusManagement', () => {
const
findPagination
=
()
=>
wrapper
.
findComponent
(
GlKeysetPagination
);
const
findPagination
=
()
=>
wrapper
.
findComponent
(
GlKeysetPagination
);
const
nextPage
=
(
cursor
)
=>
{
const
nextPage
=
async
(
cursor
)
=>
{
findPagination
().
vm
.
$emit
(
'
next
'
,
cursor
);
findPagination
().
vm
.
$emit
(
'
next
'
,
cursor
);
return
findPagination
().
vm
.
$
nextTick
();
await
nextTick
();
};
};
const
prevPage
=
(
cursor
)
=>
{
const
prevPage
=
async
(
cursor
)
=>
{
findPagination
().
vm
.
$emit
(
'
prev
'
,
cursor
);
findPagination
().
vm
.
$emit
(
'
prev
'
,
cursor
);
return
findPagination
().
vm
.
$
nextTick
();
await
nextTick
();
};
};
const
createComponentFactory
=
(
mountFn
=
shallowMount
)
=>
(
options
=
{})
=>
{
const
createComponentFactory
=
(
mountFn
=
shallowMount
)
=>
(
options
=
{})
=>
{
...
...
ee/spec/frontend/vue_shared/components/notes/system_note_spec.js
View file @
b8618652
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
axios
from
'
~/lib/utils/axios_utils
'
;
import
axios
from
'
~/lib/utils/axios_utils
'
;
import
createStore
from
'
~/notes/stores
'
;
import
createStore
from
'
~/notes/stores
'
;
...
@@ -76,16 +77,14 @@ describe('system note component', () => {
...
@@ -76,16 +77,14 @@ describe('system note component', () => {
expect
(
findDescriptionVersion
().
exists
()).
toBe
(
false
);
expect
(
findDescriptionVersion
().
exists
()).
toBe
(
false
);
});
});
it
(
'
click on button to toggle description diff displays description diff with delete icon button
'
,
(
done
)
=>
{
it
(
'
click on button to toggle description diff displays description diff with delete icon button
'
,
async
(
)
=>
{
mockFetchDiff
();
mockFetchDiff
();
expect
(
findDescriptionVersion
().
exists
()).
toBe
(
false
);
expect
(
findDescriptionVersion
().
exists
()).
toBe
(
false
);
const
button
=
findBlankBtn
();
const
button
=
findBlankBtn
();
button
.
trigger
(
'
click
'
);
button
.
trigger
(
'
click
'
);
return
wrapper
.
vm
await
nextTick
();
.
$nextTick
()
await
waitForPromises
();
.
then
(()
=>
waitForPromises
())
.
then
(()
=>
{
expect
(
findDescriptionVersion
().
exists
()).
toBe
(
true
);
expect
(
findDescriptionVersion
().
exists
()).
toBe
(
true
);
expect
(
findDescriptionVersion
().
html
()).
toContain
(
diffData
);
expect
(
findDescriptionVersion
().
html
()).
toContain
(
diffData
);
expect
(
expect
(
...
@@ -95,8 +94,6 @@ describe('system note component', () => {
...
@@ -95,8 +94,6 @@ describe('system note component', () => {
)
)
.
exists
(),
.
exists
(),
).
toBe
(
true
);
).
toBe
(
true
);
done
();
});
});
});
describe
(
'
click on delete icon button
'
,
()
=>
{
describe
(
'
click on delete icon button
'
,
()
=>
{
...
...
spec/frontend/batch_comments/components/drafts_count_spec.js
View file @
b8618652
import
Vue
from
'
vue
'
;
import
Vue
,
{
nextTick
}
from
'
vue
'
;
import
{
mountComponentWithStore
}
from
'
helpers/vue_mount_component_helper
'
;
import
{
mountComponentWithStore
}
from
'
helpers/vue_mount_component_helper
'
;
import
DraftsCount
from
'
~/batch_comments/components/drafts_count.vue
'
;
import
DraftsCount
from
'
~/batch_comments/components/drafts_count.vue
'
;
import
{
createStore
}
from
'
~/batch_comments/stores
'
;
import
{
createStore
}
from
'
~/batch_comments/stores
'
;
...
@@ -27,17 +27,14 @@ describe('Batch comments drafts count component', () => {
...
@@ -27,17 +27,14 @@ describe('Batch comments drafts count component', () => {
expect
(
vm
.
$el
.
textContent
).
toContain
(
'
1
'
);
expect
(
vm
.
$el
.
textContent
).
toContain
(
'
1
'
);
});
});
it
(
'
renders screen reader text
'
,
(
done
)
=>
{
it
(
'
renders screen reader text
'
,
async
(
)
=>
{
const
el
=
vm
.
$el
.
querySelector
(
'
.sr-only
'
);
const
el
=
vm
.
$el
.
querySelector
(
'
.sr-only
'
);
expect
(
el
.
textContent
).
toContain
(
'
draft
'
);
expect
(
el
.
textContent
).
toContain
(
'
draft
'
);
vm
.
$store
.
state
.
batchComments
.
drafts
.
push
(
'
comment 2
'
);
vm
.
$store
.
state
.
batchComments
.
drafts
.
push
(
'
comment 2
'
);
vm
.
$nextTick
(()
=>
{
await
nextTick
();
expect
(
el
.
textContent
).
toContain
(
'
drafts
'
);
expect
(
el
.
textContent
).
toContain
(
'
drafts
'
);
done
();
});
});
});
});
});
spec/frontend/batch_comments/components/publish_button_spec.js
View file @
b8618652
import
Vue
from
'
vue
'
;
import
Vue
,
{
nextTick
}
from
'
vue
'
;
import
{
mountComponentWithStore
}
from
'
helpers/vue_mount_component_helper
'
;
import
{
mountComponentWithStore
}
from
'
helpers/vue_mount_component_helper
'
;
import
PublishButton
from
'
~/batch_comments/components/publish_button.vue
'
;
import
PublishButton
from
'
~/batch_comments/components/publish_button.vue
'
;
import
{
createStore
}
from
'
~/batch_comments/stores
'
;
import
{
createStore
}
from
'
~/batch_comments/stores
'
;
...
@@ -29,13 +29,10 @@ describe('Batch comments publish button component', () => {
...
@@ -29,13 +29,10 @@ describe('Batch comments publish button component', () => {
expect
(
vm
.
$store
.
dispatch
).
toHaveBeenCalledWith
(
'
batchComments/publishReview
'
,
undefined
);
expect
(
vm
.
$store
.
dispatch
).
toHaveBeenCalledWith
(
'
batchComments/publishReview
'
,
undefined
);
});
});
it
(
'
sets loading when isPublishing is true
'
,
(
done
)
=>
{
it
(
'
sets loading when isPublishing is true
'
,
async
(
)
=>
{
vm
.
$store
.
state
.
batchComments
.
isPublishing
=
true
;
vm
.
$store
.
state
.
batchComments
.
isPublishing
=
true
;
vm
.
$nextTick
(()
=>
{
await
nextTick
();
expect
(
vm
.
$el
.
getAttribute
(
'
disabled
'
)).
toBe
(
'
disabled
'
);
expect
(
vm
.
$el
.
getAttribute
(
'
disabled
'
)).
toBe
(
'
disabled
'
);
done
();
});
});
});
});
});
spec/frontend/clusters/forms/components/integration_form_spec.js
View file @
b8618652
import
{
GlToggle
,
GlButton
}
from
'
@gitlab/ui
'
;
import
{
GlToggle
,
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
IntegrationForm
from
'
~/clusters/forms/components/integration_form.vue
'
;
import
IntegrationForm
from
'
~/clusters/forms/components/integration_form.vue
'
;
import
{
createStore
}
from
'
~/clusters/forms/stores/index
'
;
import
{
createStore
}
from
'
~/clusters/forms/stores/index
'
;
...
@@ -75,32 +75,22 @@ describe('ClusterIntegrationForm', () => {
...
@@ -75,32 +75,22 @@ describe('ClusterIntegrationForm', () => {
describe
(
'
reactivity
'
,
()
=>
{
describe
(
'
reactivity
'
,
()
=>
{
beforeEach
(()
=>
createWrapper
());
beforeEach
(()
=>
createWrapper
());
it
(
'
enables the submit button on changing toggle to different value
'
,
()
=>
{
it
(
'
enables the submit button on changing toggle to different value
'
,
async
()
=>
{
return
wrapper
.
vm
await
nextTick
();
.
$nextTick
()
.
then
(()
=>
{
// setData is a bad approach because it changes the internal implementation which we should not touch
// setData is a bad approach because it changes the internal implementation which we should not touch
// but our GlFormInput lacks the ability to set a new value.
// but our GlFormInput lacks the ability to set a new value.
// 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
({
toggleEnabled
:
!
defaultStoreValues
.
enabled
});
await
wrapper
.
setData
({
toggleEnabled
:
!
defaultStoreValues
.
enabled
});
})
.
then
(()
=>
{
expect
(
findSubmitButton
().
props
(
'
disabled
'
)).
toBe
(
false
);
expect
(
findSubmitButton
().
props
(
'
disabled
'
)).
toBe
(
false
);
});
});
});
it
(
'
enables the submit button on changing input values
'
,
()
=>
{
it
(
'
enables the submit button on changing input values
'
,
async
()
=>
{
return
wrapper
.
vm
await
nextTick
();
.
$nextTick
()
.
then
(()
=>
{
// 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
({
envScope
:
`
${
defaultStoreValues
.
environmentScope
}
1`
});
await
wrapper
.
setData
({
envScope
:
`
${
defaultStoreValues
.
environmentScope
}
1`
});
})
.
then
(()
=>
{
expect
(
findSubmitButton
().
props
(
'
disabled
'
)).
toBe
(
false
);
expect
(
findSubmitButton
().
props
(
'
disabled
'
)).
toBe
(
false
);
});
});
});
});
});
});
});
spec/frontend/create_cluster/eks_cluster/components/service_credentials_form_spec.js
View file @
b8618652
import
{
GlButton
}
from
'
@gitlab/ui
'
;
import
{
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
ServiceCredentialsForm
from
'
~/create_cluster/eks_cluster/components/service_credentials_form.vue
'
;
import
ServiceCredentialsForm
from
'
~/create_cluster/eks_cluster/components/service_credentials_form.vue
'
;
import
eksClusterState
from
'
~/create_cluster/eks_cluster/store/state
'
;
import
eksClusterState
from
'
~/create_cluster/eks_cluster/store/state
'
;
...
@@ -65,15 +65,14 @@ describe('ServiceCredentialsForm', () => {
...
@@ -65,15 +65,14 @@ describe('ServiceCredentialsForm', () => {
expect
(
findSubmitButton
().
attributes
(
'
disabled
'
)).
toBeTruthy
();
expect
(
findSubmitButton
().
attributes
(
'
disabled
'
)).
toBeTruthy
();
});
});
it
(
'
enables submit button when role ARN is not provided
'
,
()
=>
{
it
(
'
enables submit button when role ARN is not provided
'
,
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
vm
.
setData
({
roleArn
:
'
123
'
});
vm
.
setData
({
roleArn
:
'
123
'
});
return
vm
.
vm
.
$nextTick
().
then
(()
=>
{
await
nextTick
();
expect
(
findSubmitButton
().
attributes
(
'
disabled
'
)).
toBeFalsy
();
expect
(
findSubmitButton
().
attributes
(
'
disabled
'
)).
toBeFalsy
();
});
});
});
it
(
'
dispatches createRole action when submit button is clicked
'
,
()
=>
{
it
(
'
dispatches createRole action when submit button is clicked
'
,
()
=>
{
// 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
...
@@ -86,14 +85,14 @@ describe('ServiceCredentialsForm', () => {
...
@@ -86,14 +85,14 @@ describe('ServiceCredentialsForm', () => {
});
});
describe
(
'
when is creating role
'
,
()
=>
{
describe
(
'
when is creating role
'
,
()
=>
{
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
vm
.
setData
({
roleArn
:
'
123
'
});
// set role ARN to enable button
vm
.
setData
({
roleArn
:
'
123
'
});
// set role ARN to enable button
state
.
isCreatingRole
=
true
;
state
.
isCreatingRole
=
true
;
return
vm
.
vm
.
$
nextTick
();
await
nextTick
();
});
});
it
(
'
disables submit button
'
,
()
=>
{
it
(
'
disables submit button
'
,
()
=>
{
...
...
spec/frontend/design_management/components/design_presentation_spec.js
View file @
b8618652
...
@@ -74,7 +74,7 @@ describe('Design management design presentation component', () => {
...
@@ -74,7 +74,7 @@ describe('Design management design presentation component', () => {
.
mockReturnValue
((
childDimensions
.
height
-
viewportDimensions
.
height
)
*
scrollTopPerc
);
.
mockReturnValue
((
childDimensions
.
height
-
viewportDimensions
.
height
)
*
scrollTopPerc
);
}
}
function
clickDragExplore
(
startCoords
,
endCoords
,
{
useTouchEvents
,
mouseup
}
=
{})
{
async
function
clickDragExplore
(
startCoords
,
endCoords
,
{
useTouchEvents
,
mouseup
}
=
{})
{
const
event
=
useTouchEvents
const
event
=
useTouchEvents
?
{
?
{
mousedown
:
'
touchstart
'
,
mousedown
:
'
touchstart
'
,
...
@@ -96,24 +96,17 @@ describe('Design management design presentation component', () => {
...
@@ -96,24 +96,17 @@ describe('Design management design presentation component', () => {
clientX
:
startCoords
.
clientX
,
clientX
:
startCoords
.
clientX
,
clientY
:
startCoords
.
clientY
,
clientY
:
startCoords
.
clientY
,
});
});
return
wrapper
.
vm
await
nextTick
();
.
$nextTick
()
.
then
(()
=>
{
addCommentOverlay
.
trigger
(
event
.
mousemove
,
{
addCommentOverlay
.
trigger
(
event
.
mousemove
,
{
clientX
:
endCoords
.
clientX
,
clientX
:
endCoords
.
clientX
,
clientY
:
endCoords
.
clientY
,
clientY
:
endCoords
.
clientY
,
});
});
return
nextTick
();
await
nextTick
();
})
.
then
(()
=>
{
if
(
mouseup
)
{
if
(
mouseup
)
{
addCommentOverlay
.
trigger
(
event
.
mouseup
);
addCommentOverlay
.
trigger
(
event
.
mouseup
);
return
nextTick
();
await
nextTick
();
}
}
return
undefined
;
});
}
}
beforeEach
(()
=>
{
beforeEach
(()
=>
{
...
@@ -125,7 +118,7 @@ describe('Design management design presentation component', () => {
...
@@ -125,7 +118,7 @@ describe('Design management design presentation component', () => {
window
.
gon
=
originalGon
;
window
.
gon
=
originalGon
;
});
});
it
(
'
renders image and overlay when image provided
'
,
()
=>
{
it
(
'
renders image and overlay when image provided
'
,
async
()
=>
{
createComponent
(
createComponent
(
{
{
image
:
'
test.jpg
'
,
image
:
'
test.jpg
'
,
...
@@ -134,20 +127,18 @@ describe('Design management design presentation component', () => {
...
@@ -134,20 +127,18 @@ describe('Design management design presentation component', () => {
mockOverlayData
,
mockOverlayData
,
);
);
return
nextTick
().
then
(()
=>
{
await
nextTick
();
expect
(
wrapper
.
element
).
toMatchSnapshot
();
expect
(
wrapper
.
element
).
toMatchSnapshot
();
});
});
});
it
(
'
renders empty state when no image provided
'
,
()
=>
{
it
(
'
renders empty state when no image provided
'
,
async
()
=>
{
createComponent
();
createComponent
();
return
nextTick
().
then
(()
=>
{
await
nextTick
();
expect
(
wrapper
.
element
).
toMatchSnapshot
();
expect
(
wrapper
.
element
).
toMatchSnapshot
();
});
});
});
it
(
'
openCommentForm event emits correct data
'
,
()
=>
{
it
(
'
openCommentForm event emits correct data
'
,
async
()
=>
{
createComponent
(
createComponent
(
{
{
image
:
'
test.jpg
'
,
image
:
'
test.jpg
'
,
...
@@ -158,15 +149,14 @@ describe('Design management design presentation component', () => {
...
@@ -158,15 +149,14 @@ describe('Design management design presentation component', () => {
wrapper
.
vm
.
openCommentForm
({
x
:
1
,
y
:
1
});
wrapper
.
vm
.
openCommentForm
({
x
:
1
,
y
:
1
});
return
nextTick
().
then
(()
=>
{
await
nextTick
();
expect
(
wrapper
.
emitted
(
'
openCommentForm
'
)).
toEqual
([
expect
(
wrapper
.
emitted
(
'
openCommentForm
'
)).
toEqual
([
[{
...
mockOverlayData
.
overlayDimensions
,
x
:
1
,
y
:
1
}],
[{
...
mockOverlayData
.
overlayDimensions
,
x
:
1
,
y
:
1
}],
]);
]);
});
});
});
describe
(
'
currentCommentForm
'
,
()
=>
{
describe
(
'
currentCommentForm
'
,
()
=>
{
it
(
'
is null when isAnnotating is false
'
,
()
=>
{
it
(
'
is null when isAnnotating is false
'
,
async
()
=>
{
createComponent
(
createComponent
(
{
{
image
:
'
test.jpg
'
,
image
:
'
test.jpg
'
,
...
@@ -175,13 +165,12 @@ describe('Design management design presentation component', () => {
...
@@ -175,13 +165,12 @@ describe('Design management design presentation component', () => {
mockOverlayData
,
mockOverlayData
,
);
);
return
nextTick
().
then
(()
=>
{
await
nextTick
();
expect
(
wrapper
.
vm
.
currentCommentForm
).
toBeNull
();
expect
(
wrapper
.
vm
.
currentCommentForm
).
toBeNull
();
expect
(
wrapper
.
element
).
toMatchSnapshot
();
expect
(
wrapper
.
element
).
toMatchSnapshot
();
});
});
});
it
(
'
is null when isAnnotating is true but annotation position is falsey
'
,
()
=>
{
it
(
'
is null when isAnnotating is true but annotation position is falsey
'
,
async
()
=>
{
createComponent
(
createComponent
(
{
{
image
:
'
test.jpg
'
,
image
:
'
test.jpg
'
,
...
@@ -191,13 +180,12 @@ describe('Design management design presentation component', () => {
...
@@ -191,13 +180,12 @@ describe('Design management design presentation component', () => {
mockOverlayData
,
mockOverlayData
,
);
);
return
nextTick
().
then
(()
=>
{
await
nextTick
();
expect
(
wrapper
.
vm
.
currentCommentForm
).
toBeNull
();
expect
(
wrapper
.
vm
.
currentCommentForm
).
toBeNull
();
expect
(
wrapper
.
element
).
toMatchSnapshot
();
expect
(
wrapper
.
element
).
toMatchSnapshot
();
});
});
});
it
(
'
is equal to current annotation position when isAnnotating is true
'
,
()
=>
{
it
(
'
is equal to current annotation position when isAnnotating is true
'
,
async
()
=>
{
createComponent
(
createComponent
(
{
{
image
:
'
test.jpg
'
,
image
:
'
test.jpg
'
,
...
@@ -215,7 +203,7 @@ describe('Design management design presentation component', () => {
...
@@ -215,7 +203,7 @@ describe('Design management design presentation component', () => {
},
},
);
);
return
nextTick
().
then
(()
=>
{
await
nextTick
();
expect
(
wrapper
.
vm
.
currentCommentForm
).
toEqual
({
expect
(
wrapper
.
vm
.
currentCommentForm
).
toEqual
({
x
:
1
,
x
:
1
,
y
:
1
,
y
:
1
,
...
@@ -225,7 +213,6 @@ describe('Design management design presentation component', () => {
...
@@ -225,7 +213,6 @@ describe('Design management design presentation component', () => {
expect
(
wrapper
.
element
).
toMatchSnapshot
();
expect
(
wrapper
.
element
).
toMatchSnapshot
();
});
});
});
});
});
describe
(
'
setOverlayPosition
'
,
()
=>
{
describe
(
'
setOverlayPosition
'
,
()
=>
{
beforeEach
(()
=>
{
beforeEach
(()
=>
{
...
@@ -388,7 +375,7 @@ describe('Design management design presentation component', () => {
...
@@ -388,7 +375,7 @@ describe('Design management design presentation component', () => {
});
});
describe
(
'
onImageResize
'
,
()
=>
{
describe
(
'
onImageResize
'
,
()
=>
{
beforeEach
(()
=>
{
beforeEach
(
async
()
=>
{
createComponent
(
createComponent
(
{
{
image
:
'
test.jpg
'
,
image
:
'
test.jpg
'
,
...
@@ -401,7 +388,7 @@ describe('Design management design presentation component', () => {
...
@@ -401,7 +388,7 @@ describe('Design management design presentation component', () => {
jest
.
spyOn
(
wrapper
.
vm
,
'
scaleZoomFocalPoint
'
);
jest
.
spyOn
(
wrapper
.
vm
,
'
scaleZoomFocalPoint
'
);
jest
.
spyOn
(
wrapper
.
vm
,
'
scrollToFocalPoint
'
);
jest
.
spyOn
(
wrapper
.
vm
,
'
scrollToFocalPoint
'
);
wrapper
.
vm
.
onImageResize
({
width
:
10
,
height
:
10
});
wrapper
.
vm
.
onImageResize
({
width
:
10
,
height
:
10
});
return
nextTick
();
await
nextTick
();
});
});
it
(
'
sets zoom focal point on initial load
'
,
()
=>
{
it
(
'
sets zoom focal point on initial load
'
,
()
=>
{
...
@@ -409,14 +396,13 @@ describe('Design management design presentation component', () => {
...
@@ -409,14 +396,13 @@ describe('Design management design presentation component', () => {
expect
(
wrapper
.
vm
.
initialLoad
).
toBe
(
false
);
expect
(
wrapper
.
vm
.
initialLoad
).
toBe
(
false
);
});
});
it
(
'
calls scaleZoomFocalPoint and scrollToFocalPoint after initial load
'
,
()
=>
{
it
(
'
calls scaleZoomFocalPoint and scrollToFocalPoint after initial load
'
,
async
()
=>
{
wrapper
.
vm
.
onImageResize
({
width
:
10
,
height
:
10
});
wrapper
.
vm
.
onImageResize
({
width
:
10
,
height
:
10
});
return
nextTick
().
then
(()
=>
{
await
nextTick
();
expect
(
wrapper
.
vm
.
scaleZoomFocalPoint
).
toHaveBeenCalled
();
expect
(
wrapper
.
vm
.
scaleZoomFocalPoint
).
toHaveBeenCalled
();
expect
(
wrapper
.
vm
.
scrollToFocalPoint
).
toHaveBeenCalled
();
expect
(
wrapper
.
vm
.
scrollToFocalPoint
).
toHaveBeenCalled
();
});
});
});
});
});
describe
(
'
onPresentationMousedown
'
,
()
=>
{
describe
(
'
onPresentationMousedown
'
,
()
=>
{
it
.
each
`
it
.
each
`
...
@@ -498,7 +484,7 @@ describe('Design management design presentation component', () => {
...
@@ -498,7 +484,7 @@ describe('Design management design presentation component', () => {
);
);
});
});
it
(
'
opens a comment form if design was not dragged
'
,
()
=>
{
it
(
'
opens a comment form if design was not dragged
'
,
async
()
=>
{
const
addCommentOverlay
=
findOverlayCommentButton
();
const
addCommentOverlay
=
findOverlayCommentButton
();
const
startCoords
=
{
const
startCoords
=
{
clientX
:
1
,
clientX
:
1
,
...
@@ -510,16 +496,11 @@ describe('Design management design presentation component', () => {
...
@@ -510,16 +496,11 @@ describe('Design management design presentation component', () => {
clientY
:
startCoords
.
clientY
,
clientY
:
startCoords
.
clientY
,
});
});
return
wrapper
.
vm
await
nextTick
();
.
$nextTick
()
.
then
(()
=>
{
addCommentOverlay
.
trigger
(
'
mouseup
'
);
addCommentOverlay
.
trigger
(
'
mouseup
'
);
return
nextTick
();
await
nextTick
();
})
.
then
(()
=>
{
expect
(
wrapper
.
emitted
(
'
openCommentForm
'
)).
toBeDefined
();
expect
(
wrapper
.
emitted
(
'
openCommentForm
'
)).
toBeDefined
();
});
});
});
describe
(
'
when clicking and dragging
'
,
()
=>
{
describe
(
'
when clicking and dragging
'
,
()
=>
{
it
.
each
`
it
.
each
`
...
...
spec/frontend/diffs/components/settings_dropdown_spec.js
View file @
b8618652
import
{
mount
}
from
'
@vue/test-utils
'
;
import
{
mount
}
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
SettingsDropdown
from
'
~/diffs/components/settings_dropdown.vue
'
;
import
SettingsDropdown
from
'
~/diffs/components/settings_dropdown.vue
'
;
...
@@ -10,7 +11,6 @@ import createDiffsStore from '../create_diffs_store';
...
@@ -10,7 +11,6 @@ import createDiffsStore from '../create_diffs_store';
describe
(
'
Diff settings dropdown component
'
,
()
=>
{
describe
(
'
Diff settings dropdown component
'
,
()
=>
{
let
wrapper
;
let
wrapper
;
let
vm
;
let
store
;
let
store
;
function
createComponent
(
extendStore
=
()
=>
{})
{
function
createComponent
(
extendStore
=
()
=>
{})
{
...
@@ -23,7 +23,6 @@ describe('Diff settings dropdown component', () => {
...
@@ -23,7 +23,6 @@ describe('Diff settings dropdown component', () => {
store
,
store
,
}),
}),
);
);
vm
=
wrapper
.
vm
;
}
}
function
getFileByFileCheckbox
(
vueWrapper
)
{
function
getFileByFileCheckbox
(
vueWrapper
)
{
...
@@ -142,7 +141,7 @@ describe('Diff settings dropdown component', () => {
...
@@ -142,7 +141,7 @@ describe('Diff settings dropdown component', () => {
checkbox
.
trigger
(
'
click
'
);
checkbox
.
trigger
(
'
click
'
);
await
vm
.
$
nextTick
();
await
nextTick
();
expect
(
store
.
dispatch
).
toHaveBeenCalledWith
(
'
diffs/setShowWhitespace
'
,
{
expect
(
store
.
dispatch
).
toHaveBeenCalledWith
(
'
diffs/setShowWhitespace
'
,
{
showWhitespace
:
!
checked
,
showWhitespace
:
!
checked
,
...
@@ -185,7 +184,7 @@ describe('Diff settings dropdown component', () => {
...
@@ -185,7 +184,7 @@ describe('Diff settings dropdown component', () => {
getFileByFileCheckbox
(
wrapper
).
trigger
(
'
click
'
);
getFileByFileCheckbox
(
wrapper
).
trigger
(
'
click
'
);
await
vm
.
$
nextTick
();
await
nextTick
();
expect
(
store
.
dispatch
).
toHaveBeenCalledWith
(
'
diffs/setFileByFile
'
,
{
expect
(
store
.
dispatch
).
toHaveBeenCalledWith
(
'
diffs/setFileByFile
'
,
{
fileByFile
:
setting
,
fileByFile
:
setting
,
...
...
spec/frontend/filtered_search/recent_searches_root_spec.js
View file @
b8618652
import
{
nextTick
}
from
'
vue
'
;
import
{
setHTMLFixture
}
from
'
helpers/fixtures
'
;
import
{
setHTMLFixture
}
from
'
helpers/fixtures
'
;
import
RecentSearchesRoot
from
'
~/filtered_search/recent_searches_root
'
;
import
RecentSearchesRoot
from
'
~/filtered_search/recent_searches_root
'
;
...
@@ -10,7 +11,7 @@ describe('RecentSearchesRoot', () => {
...
@@ -10,7 +11,7 @@ describe('RecentSearchesRoot', () => {
let
vm
;
let
vm
;
let
containerEl
;
let
containerEl
;
beforeEach
(()
=>
{
beforeEach
(
async
()
=>
{
setHTMLFixture
(
`
setHTMLFixture
(
`
<div id="
${
containerId
}
">
<div id="
${
containerId
}
">
<div id="
${
dropdownElementId
}
"></div>
<div id="
${
dropdownElementId
}
"></div>
...
@@ -33,7 +34,7 @@ describe('RecentSearchesRoot', () => {
...
@@ -33,7 +34,7 @@ describe('RecentSearchesRoot', () => {
RecentSearchesRoot
.
prototype
.
render
.
call
(
recentSearchesRootMockInstance
);
RecentSearchesRoot
.
prototype
.
render
.
call
(
recentSearchesRootMockInstance
);
vm
=
recentSearchesRootMockInstance
.
vm
;
vm
=
recentSearchesRootMockInstance
.
vm
;
return
vm
.
$
nextTick
();
await
nextTick
();
});
});
afterEach
(()
=>
{
afterEach
(()
=>
{
...
...
spec/frontend/groups/components/app_spec.js
View file @
b8618652
import
{
GlModal
,
GlLoadingIcon
}
from
'
@gitlab/ui
'
;
import
{
GlModal
,
GlLoadingIcon
}
from
'
@gitlab/ui
'
;
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
AxiosMockAdapter
from
'
axios-mock-adapter
'
;
import
AxiosMockAdapter
from
'
axios-mock-adapter
'
;
import
Vue
from
'
vue
'
;
import
Vue
,
{
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
appComponent
from
'
~/groups/components/app.vue
'
;
import
appComponent
from
'
~/groups/components/app.vue
'
;
...
@@ -58,7 +58,7 @@ describe('AppComponent', () => {
...
@@ -58,7 +58,7 @@ describe('AppComponent', () => {
wrapper
=
null
;
wrapper
=
null
;
});
});
beforeEach
(()
=>
{
beforeEach
(
async
()
=>
{
mock
=
new
AxiosMockAdapter
(
axios
);
mock
=
new
AxiosMockAdapter
(
axios
);
mock
.
onGet
(
'
/dashboard/groups.json
'
).
reply
(
200
,
mockGroups
);
mock
.
onGet
(
'
/dashboard/groups.json
'
).
reply
(
200
,
mockGroups
);
Vue
.
component
(
'
GroupFolder
'
,
groupFolderComponent
);
Vue
.
component
(
'
GroupFolder
'
,
groupFolderComponent
);
...
@@ -66,7 +66,7 @@ describe('AppComponent', () => {
...
@@ -66,7 +66,7 @@ describe('AppComponent', () => {
createShallowComponent
();
createShallowComponent
();
getGroupsSpy
=
jest
.
spyOn
(
vm
.
service
,
'
getGroups
'
);
getGroupsSpy
=
jest
.
spyOn
(
vm
.
service
,
'
getGroups
'
);
return
vm
.
$
nextTick
();
await
nextTick
();
});
});
describe
(
'
computed
'
,
()
=>
{
describe
(
'
computed
'
,
()
=>
{
...
@@ -397,43 +397,40 @@ describe('AppComponent', () => {
...
@@ -397,43 +397,40 @@ describe('AppComponent', () => {
});
});
describe
(
'
created
'
,
()
=>
{
describe
(
'
created
'
,
()
=>
{
it
(
'
should bind event listeners on eventHub
'
,
()
=>
{
it
(
'
should bind event listeners on eventHub
'
,
async
()
=>
{
jest
.
spyOn
(
eventHub
,
'
$on
'
).
mockImplementation
(()
=>
{});
jest
.
spyOn
(
eventHub
,
'
$on
'
).
mockImplementation
(()
=>
{});
createShallowComponent
();
createShallowComponent
();
return
vm
.
$nextTick
().
then
(()
=>
{
await
nextTick
();
expect
(
eventHub
.
$on
).
toHaveBeenCalledWith
(
'
fetchPage
'
,
expect
.
any
(
Function
));
expect
(
eventHub
.
$on
).
toHaveBeenCalledWith
(
'
fetchPage
'
,
expect
.
any
(
Function
));
expect
(
eventHub
.
$on
).
toHaveBeenCalledWith
(
'
toggleChildren
'
,
expect
.
any
(
Function
));
expect
(
eventHub
.
$on
).
toHaveBeenCalledWith
(
'
toggleChildren
'
,
expect
.
any
(
Function
));
expect
(
eventHub
.
$on
).
toHaveBeenCalledWith
(
'
showLeaveGroupModal
'
,
expect
.
any
(
Function
));
expect
(
eventHub
.
$on
).
toHaveBeenCalledWith
(
'
showLeaveGroupModal
'
,
expect
.
any
(
Function
));
expect
(
eventHub
.
$on
).
toHaveBeenCalledWith
(
'
updatePagination
'
,
expect
.
any
(
Function
));
expect
(
eventHub
.
$on
).
toHaveBeenCalledWith
(
'
updatePagination
'
,
expect
.
any
(
Function
));
expect
(
eventHub
.
$on
).
toHaveBeenCalledWith
(
'
updateGroups
'
,
expect
.
any
(
Function
));
expect
(
eventHub
.
$on
).
toHaveBeenCalledWith
(
'
updateGroups
'
,
expect
.
any
(
Function
));
});
});
});
it
(
'
should initialize `searchEmptyMessage` prop with correct string when `hideProjects` is `false`
'
,
()
=>
{
it
(
'
should initialize `searchEmptyMessage` prop with correct string when `hideProjects` is `false`
'
,
async
()
=>
{
createShallowComponent
();
createShallowComponent
();
return
vm
.
$nextTick
().
then
(()
=>
{
await
nextTick
();
expect
(
vm
.
searchEmptyMessage
).
toBe
(
'
No groups or projects matched your search
'
);
expect
(
vm
.
searchEmptyMessage
).
toBe
(
'
No groups or projects matched your search
'
);
});
});
});
it
(
'
should initialize `searchEmptyMessage` prop with correct string when `hideProjects` is `true`
'
,
()
=>
{
it
(
'
should initialize `searchEmptyMessage` prop with correct string when `hideProjects` is `true`
'
,
async
()
=>
{
createShallowComponent
(
true
);
createShallowComponent
(
true
);
return
vm
.
$nextTick
().
then
(()
=>
{
await
nextTick
();
expect
(
vm
.
searchEmptyMessage
).
toBe
(
'
No groups matched your search
'
);
expect
(
vm
.
searchEmptyMessage
).
toBe
(
'
No groups matched your search
'
);
});
});
});
});
});
describe
(
'
beforeDestroy
'
,
()
=>
{
describe
(
'
beforeDestroy
'
,
()
=>
{
it
(
'
should unbind event listeners on eventHub
'
,
()
=>
{
it
(
'
should unbind event listeners on eventHub
'
,
async
()
=>
{
jest
.
spyOn
(
eventHub
,
'
$off
'
).
mockImplementation
(()
=>
{});
jest
.
spyOn
(
eventHub
,
'
$off
'
).
mockImplementation
(()
=>
{});
createShallowComponent
();
createShallowComponent
();
wrapper
.
destroy
();
wrapper
.
destroy
();
return
vm
.
$nextTick
().
then
(()
=>
{
await
nextTick
();
expect
(
eventHub
.
$off
).
toHaveBeenCalledWith
(
'
fetchPage
'
,
expect
.
any
(
Function
));
expect
(
eventHub
.
$off
).
toHaveBeenCalledWith
(
'
fetchPage
'
,
expect
.
any
(
Function
));
expect
(
eventHub
.
$off
).
toHaveBeenCalledWith
(
'
toggleChildren
'
,
expect
.
any
(
Function
));
expect
(
eventHub
.
$off
).
toHaveBeenCalledWith
(
'
toggleChildren
'
,
expect
.
any
(
Function
));
expect
(
eventHub
.
$off
).
toHaveBeenCalledWith
(
'
showLeaveGroupModal
'
,
expect
.
any
(
Function
));
expect
(
eventHub
.
$off
).
toHaveBeenCalledWith
(
'
showLeaveGroupModal
'
,
expect
.
any
(
Function
));
...
@@ -441,23 +438,20 @@ describe('AppComponent', () => {
...
@@ -441,23 +438,20 @@ describe('AppComponent', () => {
expect
(
eventHub
.
$off
).
toHaveBeenCalledWith
(
'
updateGroups
'
,
expect
.
any
(
Function
));
expect
(
eventHub
.
$off
).
toHaveBeenCalledWith
(
'
updateGroups
'
,
expect
.
any
(
Function
));
});
});
});
});
});
describe
(
'
template
'
,
()
=>
{
describe
(
'
template
'
,
()
=>
{
it
(
'
should render loading icon
'
,
()
=>
{
it
(
'
should render loading icon
'
,
async
()
=>
{
vm
.
isLoading
=
true
;
vm
.
isLoading
=
true
;
return
vm
.
$nextTick
().
then
(()
=>
{
await
nextTick
();
expect
(
wrapper
.
find
(
GlLoadingIcon
).
exists
()).
toBe
(
true
);
expect
(
wrapper
.
find
(
GlLoadingIcon
).
exists
()).
toBe
(
true
);
});
});
});
it
(
'
should render groups tree
'
,
()
=>
{
it
(
'
should render groups tree
'
,
async
()
=>
{
vm
.
store
.
state
.
groups
=
[
mockParentGroupItem
];
vm
.
store
.
state
.
groups
=
[
mockParentGroupItem
];
vm
.
isLoading
=
false
;
vm
.
isLoading
=
false
;
return
vm
.
$nextTick
().
then
(()
=>
{
await
nextTick
();
expect
(
vm
.
$el
.
querySelector
(
'
.groups-list-tree-container
'
)).
toBeDefined
();
expect
(
vm
.
$el
.
querySelector
(
'
.groups-list-tree-container
'
)).
toBeDefined
();
});
});
});
it
(
'
renders modal confirmation dialog
'
,
()
=>
{
it
(
'
renders modal confirmation dialog
'
,
()
=>
{
createShallowComponent
();
createShallowComponent
();
...
...
spec/frontend/groups/components/groups_spec.js
View file @
b8618652
import
Vue
from
'
vue
'
;
import
Vue
,
{
nextTick
}
from
'
vue
'
;
import
mountComponent
from
'
helpers/vue_mount_component_helper
'
;
import
mountComponent
from
'
helpers/vue_mount_component_helper
'
;
import
groupFolderComponent
from
'
~/groups/components/group_folder.vue
'
;
import
groupFolderComponent
from
'
~/groups/components/group_folder.vue
'
;
...
@@ -21,13 +21,13 @@ const createComponent = (searchEmpty = false) => {
...
@@ -21,13 +21,13 @@ const createComponent = (searchEmpty = false) => {
describe
(
'
GroupsComponent
'
,
()
=>
{
describe
(
'
GroupsComponent
'
,
()
=>
{
let
vm
;
let
vm
;
beforeEach
(()
=>
{
beforeEach
(
async
()
=>
{
Vue
.
component
(
'
GroupFolder
'
,
groupFolderComponent
);
Vue
.
component
(
'
GroupFolder
'
,
groupFolderComponent
);
Vue
.
component
(
'
GroupItem
'
,
groupItemComponent
);
Vue
.
component
(
'
GroupItem
'
,
groupItemComponent
);
vm
=
createComponent
();
vm
=
createComponent
();
return
vm
.
$
nextTick
();
await
nextTick
();
});
});
afterEach
(()
=>
{
afterEach
(()
=>
{
...
@@ -52,20 +52,18 @@ describe('GroupsComponent', () => {
...
@@ -52,20 +52,18 @@ describe('GroupsComponent', () => {
});
});
describe
(
'
template
'
,
()
=>
{
describe
(
'
template
'
,
()
=>
{
it
(
'
should render component template correctly
'
,
()
=>
{
it
(
'
should render component template correctly
'
,
async
()
=>
{
return
vm
.
$nextTick
().
then
(()
=>
{
await
nextTick
();
expect
(
vm
.
$el
.
querySelector
(
'
.groups-list-tree-container
'
)).
toBeDefined
();
expect
(
vm
.
$el
.
querySelector
(
'
.groups-list-tree-container
'
)).
toBeDefined
();
expect
(
vm
.
$el
.
querySelector
(
'
.group-list-tree
'
)).
toBeDefined
();
expect
(
vm
.
$el
.
querySelector
(
'
.group-list-tree
'
)).
toBeDefined
();
expect
(
vm
.
$el
.
querySelector
(
'
.gl-pagination
'
)).
toBeDefined
();
expect
(
vm
.
$el
.
querySelector
(
'
.gl-pagination
'
)).
toBeDefined
();
expect
(
vm
.
$el
.
querySelectorAll
(
'
.has-no-search-results
'
).
length
).
toBe
(
0
);
expect
(
vm
.
$el
.
querySelectorAll
(
'
.has-no-search-results
'
).
length
).
toBe
(
0
);
});
});
});
it
(
'
should render empty search message when `searchEmpty` is `true`
'
,
()
=>
{
it
(
'
should render empty search message when `searchEmpty` is `true`
'
,
async
()
=>
{
vm
.
searchEmpty
=
true
;
vm
.
searchEmpty
=
true
;
return
vm
.
$nextTick
().
then
(()
=>
{
await
nextTick
();
expect
(
vm
.
$el
.
querySelector
(
'
.has-no-search-results
'
)).
toBeDefined
();
expect
(
vm
.
$el
.
querySelector
(
'
.has-no-search-results
'
)).
toBeDefined
();
});
});
});
});
});
});
});
spec/frontend/ide/components/activity_bar_spec.js
View file @
b8618652
import
Vue
from
'
vue
'
;
import
Vue
,
{
nextTick
}
from
'
vue
'
;
import
{
createComponentWithStore
}
from
'
helpers/vue_mount_component_helper
'
;
import
{
createComponentWithStore
}
from
'
helpers/vue_mount_component_helper
'
;
import
ActivityBar
from
'
~/ide/components/activity_bar.vue
'
;
import
ActivityBar
from
'
~/ide/components/activity_bar.vue
'
;
import
{
leftSidebarViews
}
from
'
~/ide/constants
'
;
import
{
leftSidebarViews
}
from
'
~/ide/constants
'
;
...
@@ -61,14 +61,11 @@ describe('IDE activity bar', () => {
...
@@ -61,14 +61,11 @@ describe('IDE activity bar', () => {
expect
(
vm
.
$el
.
querySelector
(
'
.js-ide-edit-mode
'
).
classList
).
toContain
(
'
active
'
);
expect
(
vm
.
$el
.
querySelector
(
'
.js-ide-edit-mode
'
).
classList
).
toContain
(
'
active
'
);
});
});
it
(
'
sets commit item active
'
,
(
done
)
=>
{
it
(
'
sets commit item active
'
,
async
(
)
=>
{
vm
.
$store
.
state
.
currentActivityView
=
leftSidebarViews
.
commit
.
name
;
vm
.
$store
.
state
.
currentActivityView
=
leftSidebarViews
.
commit
.
name
;
vm
.
$nextTick
(()
=>
{
await
nextTick
();
expect
(
vm
.
$el
.
querySelector
(
'
.js-ide-commit-mode
'
).
classList
).
toContain
(
'
active
'
);
expect
(
vm
.
$el
.
querySelector
(
'
.js-ide-commit-mode
'
).
classList
).
toContain
(
'
active
'
);
done
();
});
});
});
});
});
...
...
spec/frontend/ide/components/commit_sidebar/actions_spec.js
View file @
b8618652
import
Vue
from
'
vue
'
;
import
Vue
,
{
nextTick
}
from
'
vue
'
;
import
{
createComponentWithStore
}
from
'
helpers/vue_mount_component_helper
'
;
import
{
createComponentWithStore
}
from
'
helpers/vue_mount_component_helper
'
;
import
{
projectData
,
branches
}
from
'
jest/ide/mock_data
'
;
import
{
projectData
,
branches
}
from
'
jest/ide/mock_data
'
;
import
commitActions
from
'
~/ide/components/commit_sidebar/actions.vue
'
;
import
commitActions
from
'
~/ide/components/commit_sidebar/actions.vue
'
;
...
@@ -71,15 +71,12 @@ describe('IDE commit sidebar actions', () => {
...
@@ -71,15 +71,12 @@ describe('IDE commit sidebar actions', () => {
expect
(
findText
()).
toContain
(
'
Commit to main branch
'
);
expect
(
findText
()).
toContain
(
'
Commit to main branch
'
);
});
});
it
(
'
hides merge request option when project merge requests are disabled
'
,
(
done
)
=>
{
it
(
'
hides merge request option when project merge requests are disabled
'
,
async
(
)
=>
{
createComponent
({
hasMR
:
false
});
createComponent
({
hasMR
:
false
});
vm
.
$nextTick
(()
=>
{
await
nextTick
();
expect
(
findRadios
().
length
).
toBe
(
2
);
expect
(
findRadios
().
length
).
toBe
(
2
);
expect
(
findText
()).
not
.
toContain
(
'
Create a new branch and merge request
'
);
expect
(
findText
()).
not
.
toContain
(
'
Create a new branch and merge request
'
);
done
();
});
});
});
describe
(
'
currentBranchText
'
,
()
=>
{
describe
(
'
currentBranchText
'
,
()
=>
{
...
@@ -105,22 +102,18 @@ describe('IDE commit sidebar actions', () => {
...
@@ -105,22 +102,18 @@ describe('IDE commit sidebar actions', () => {
expect
(
vm
.
$store
.
dispatch
).
not
.
toHaveBeenCalled
();
expect
(
vm
.
$store
.
dispatch
).
not
.
toHaveBeenCalled
();
});
});
it
(
'
calls again after staged changes
'
,
(
done
)
=>
{
it
(
'
calls again after staged changes
'
,
async
(
)
=>
{
createComponent
({
currentBranchId
:
null
});
createComponent
({
currentBranchId
:
null
});
vm
.
$store
.
state
.
currentBranchId
=
'
main
'
;
vm
.
$store
.
state
.
currentBranchId
=
'
main
'
;
vm
.
$store
.
state
.
changedFiles
.
push
({});
vm
.
$store
.
state
.
changedFiles
.
push
({});
vm
.
$store
.
state
.
stagedFiles
.
push
({});
vm
.
$store
.
state
.
stagedFiles
.
push
({});
vm
.
$nextTick
()
await
nextTick
();
.
then
(()
=>
{
expect
(
vm
.
$store
.
dispatch
).
toHaveBeenCalledWith
(
expect
(
vm
.
$store
.
dispatch
).
toHaveBeenCalledWith
(
ACTION_UPDATE_COMMIT_ACTION
,
ACTION_UPDATE_COMMIT_ACTION
,
expect
.
anything
(),
expect
.
anything
(),
);
);
})
.
then
(
done
)
.
catch
(
done
.
fail
);
});
});
it
.
each
`
it
.
each
`
...
...
spec/frontend/ide/components/commit_sidebar/list_item_spec.js
View file @
b8618652
import
Vue
from
'
vue
'
;
import
Vue
,
{
nextTick
}
from
'
vue
'
;
import
{
trimText
}
from
'
helpers/text_helper
'
;
import
{
trimText
}
from
'
helpers/text_helper
'
;
import
{
createComponentWithStore
}
from
'
helpers/vue_mount_component_helper
'
;
import
{
createComponentWithStore
}
from
'
helpers/vue_mount_component_helper
'
;
import
listItem
from
'
~/ide/components/commit_sidebar/list_item.vue
'
;
import
listItem
from
'
~/ide/components/commit_sidebar/list_item.vue
'
;
...
@@ -41,26 +41,18 @@ describe('Multi-file editor commit sidebar list item', () => {
...
@@ -41,26 +41,18 @@ describe('Multi-file editor commit sidebar list item', () => {
expect
(
findPathText
()).
toContain
(
f
.
path
);
expect
(
findPathText
()).
toContain
(
f
.
path
);
});
});
it
(
'
correctly renders renamed entries
'
,
(
done
)
=>
{
it
(
'
correctly renders renamed entries
'
,
async
(
)
=>
{
Vue
.
set
(
vm
.
file
,
'
prevName
'
,
'
Old name
'
);
Vue
.
set
(
vm
.
file
,
'
prevName
'
,
'
Old name
'
);
vm
.
$nextTick
()
await
nextTick
();
.
then
(()
=>
{
expect
(
findPathText
()).
toEqual
(
`Old name →
${
f
.
name
}
`
);
expect
(
findPathText
()).
toEqual
(
`Old name →
${
f
.
name
}
`
);
})
.
then
(
done
)
.
catch
(
done
.
fail
);
});
});
it
(
'
correctly renders entry, the name of which did not change after rename (as within a folder)
'
,
(
done
)
=>
{
it
(
'
correctly renders entry, the name of which did not change after rename (as within a folder)
'
,
async
(
)
=>
{
Vue
.
set
(
vm
.
file
,
'
prevName
'
,
f
.
name
);
Vue
.
set
(
vm
.
file
,
'
prevName
'
,
f
.
name
);
vm
.
$nextTick
()
await
nextTick
();
.
then
(()
=>
{
expect
(
findPathText
()).
toEqual
(
f
.
name
);
expect
(
findPathText
()).
toEqual
(
f
.
name
);
})
.
then
(
done
)
.
catch
(
done
.
fail
);
});
});
it
(
'
opens a closed file in the editor when clicking the file path
'
,
(
done
)
=>
{
it
(
'
opens a closed file in the editor when clicking the file path
'
,
(
done
)
=>
{
...
@@ -134,14 +126,11 @@ describe('Multi-file editor commit sidebar list item', () => {
...
@@ -134,14 +126,11 @@ describe('Multi-file editor commit sidebar list item', () => {
expect
(
vm
.
$el
.
querySelector
(
'
.is-active
'
)).
toBe
(
null
);
expect
(
vm
.
$el
.
querySelector
(
'
.is-active
'
)).
toBe
(
null
);
});
});
it
(
'
adds active class when keys match
'
,
(
done
)
=>
{
it
(
'
adds active class when keys match
'
,
async
(
)
=>
{
vm
.
keyPrefix
=
'
staged
'
;
vm
.
keyPrefix
=
'
staged
'
;
vm
.
$nextTick
(()
=>
{
await
nextTick
();
expect
(
vm
.
$el
.
querySelector
(
'
.is-active
'
)).
not
.
toBe
(
null
);
expect
(
vm
.
$el
.
querySelector
(
'
.is-active
'
)).
not
.
toBe
(
null
);
done
();
});
});
});
});
});
});
});
spec/frontend/ide/components/commit_sidebar/message_field_spec.js
View file @
b8618652
import
Vue
from
'
vue
'
;
import
Vue
,
{
nextTick
}
from
'
vue
'
;
import
createComponent
from
'
helpers/vue_mount_component_helper
'
;
import
createComponent
from
'
helpers/vue_mount_component_helper
'
;
import
CommitMessageField
from
'
~/ide/components/commit_sidebar/message_field.vue
'
;
import
CommitMessageField
from
'
~/ide/components/commit_sidebar/message_field.vue
'
;
...
@@ -23,34 +23,23 @@ describe('IDE commit message field', () => {
...
@@ -23,34 +23,23 @@ describe('IDE commit message field', () => {
vm
.
$destroy
();
vm
.
$destroy
();
});
});
it
(
'
adds is-focused class on focus
'
,
(
done
)
=>
{
it
(
'
adds is-focused class on focus
'
,
async
(
)
=>
{
vm
.
$el
.
querySelector
(
'
textarea
'
).
focus
();
vm
.
$el
.
querySelector
(
'
textarea
'
).
focus
();
vm
.
$nextTick
(()
=>
{
await
nextTick
();
expect
(
vm
.
$el
.
querySelector
(
'
.is-focused
'
)).
not
.
toBeNull
();
expect
(
vm
.
$el
.
querySelector
(
'
.is-focused
'
)).
not
.
toBeNull
();
done
();
});
});
});
it
(
'
removed is-focused class on blur
'
,
(
done
)
=>
{
it
(
'
removed is-focused class on blur
'
,
async
(
)
=>
{
vm
.
$el
.
querySelector
(
'
textarea
'
).
focus
();
vm
.
$el
.
querySelector
(
'
textarea
'
).
focus
();
vm
.
$nextTick
()
await
nextTick
();
.
then
(()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.is-focused
'
)).
not
.
toBeNull
();
expect
(
vm
.
$el
.
querySelector
(
'
.is-focused
'
)).
not
.
toBeNull
();
vm
.
$el
.
querySelector
(
'
textarea
'
).
blur
();
vm
.
$el
.
querySelector
(
'
textarea
'
).
blur
();
return
vm
.
$nextTick
();
await
nextTick
();
})
.
then
(()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.is-focused
'
)).
toBeNull
();
expect
(
vm
.
$el
.
querySelector
(
'
.is-focused
'
)).
toBeNull
();
done
();
})
.
then
(
done
)
.
catch
(
done
.
fail
);
});
});
it
(
'
emits input event on input
'
,
()
=>
{
it
(
'
emits input event on input
'
,
()
=>
{
...
@@ -66,27 +55,22 @@ describe('IDE commit message field', () => {
...
@@ -66,27 +55,22 @@ describe('IDE commit message field', () => {
describe
(
'
highlights
'
,
()
=>
{
describe
(
'
highlights
'
,
()
=>
{
describe
(
'
subject line
'
,
()
=>
{
describe
(
'
subject line
'
,
()
=>
{
it
(
'
does not highlight less than 50 characters
'
,
(
done
)
=>
{
it
(
'
does not highlight less than 50 characters
'
,
async
(
)
=>
{
vm
.
text
=
'
text less than 50 chars
'
;
vm
.
text
=
'
text less than 50 chars
'
;
vm
.
$nextTick
()
await
nextTick
();
.
then
(()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.highlights span
'
).
textContent
).
toContain
(
expect
(
vm
.
$el
.
querySelector
(
'
.highlights span
'
).
textContent
).
toContain
(
'
text less than 50 chars
'
,
'
text less than 50 chars
'
,
);
);
expect
(
vm
.
$el
.
querySelector
(
'
mark
'
).
style
.
display
).
toBe
(
'
none
'
);
expect
(
vm
.
$el
.
querySelector
(
'
mark
'
).
style
.
display
).
toBe
(
'
none
'
);
})
.
then
(
done
)
.
catch
(
done
.
fail
);
});
});
it
(
'
highlights characters over 50 length
'
,
(
done
)
=>
{
it
(
'
highlights characters over 50 length
'
,
async
(
)
=>
{
vm
.
text
=
vm
.
text
=
'
text less than 50 chars that should not highlighted. text more than 50 should be highlighted
'
;
'
text less than 50 chars that should not highlighted. text more than 50 should be highlighted
'
;
vm
.
$nextTick
()
await
nextTick
();
.
then
(()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.highlights span
'
).
textContent
).
toContain
(
expect
(
vm
.
$el
.
querySelector
(
'
.highlights span
'
).
textContent
).
toContain
(
'
text less than 50 chars that should not highlighte
'
,
'
text less than 50 chars that should not highlighte
'
,
);
);
...
@@ -95,76 +79,54 @@ describe('IDE commit message field', () => {
...
@@ -95,76 +79,54 @@ describe('IDE commit message field', () => {
expect
(
vm
.
$el
.
querySelector
(
'
mark
'
).
textContent
).
toBe
(
expect
(
vm
.
$el
.
querySelector
(
'
mark
'
).
textContent
).
toBe
(
'
d. text more than 50 should be highlighted
'
,
'
d. text more than 50 should be highlighted
'
,
);
);
})
.
then
(
done
)
.
catch
(
done
.
fail
);
});
});
});
});
describe
(
'
body text
'
,
()
=>
{
describe
(
'
body text
'
,
()
=>
{
it
(
'
does not highlight body text less tan 72 characters
'
,
(
done
)
=>
{
it
(
'
does not highlight body text less tan 72 characters
'
,
async
(
)
=>
{
vm
.
text
=
'
subject line
\n
body content
'
;
vm
.
text
=
'
subject line
\n
body content
'
;
vm
.
$nextTick
()
await
nextTick
();
.
then
(()
=>
{
expect
(
vm
.
$el
.
querySelectorAll
(
'
.highlights span
'
).
length
).
toBe
(
2
);
expect
(
vm
.
$el
.
querySelectorAll
(
'
.highlights span
'
).
length
).
toBe
(
2
);
expect
(
vm
.
$el
.
querySelectorAll
(
'
mark
'
)[
1
].
style
.
display
).
toBe
(
'
none
'
);
expect
(
vm
.
$el
.
querySelectorAll
(
'
mark
'
)[
1
].
style
.
display
).
toBe
(
'
none
'
);
})
.
then
(
done
)
.
catch
(
done
.
fail
);
});
});
it
(
'
highlights body text more than 72 characters
'
,
(
done
)
=>
{
it
(
'
highlights body text more than 72 characters
'
,
async
(
)
=>
{
vm
.
text
=
vm
.
text
=
'
subject line
\n
body content that will be highlighted when it is more than 72 characters in length
'
;
'
subject line
\n
body content that will be highlighted when it is more than 72 characters in length
'
;
vm
.
$nextTick
()
await
nextTick
();
.
then
(()
=>
{
expect
(
vm
.
$el
.
querySelectorAll
(
'
.highlights span
'
).
length
).
toBe
(
2
);
expect
(
vm
.
$el
.
querySelectorAll
(
'
.highlights span
'
).
length
).
toBe
(
2
);
expect
(
vm
.
$el
.
querySelectorAll
(
'
mark
'
)[
1
].
style
.
display
).
not
.
toBe
(
'
none
'
);
expect
(
vm
.
$el
.
querySelectorAll
(
'
mark
'
)[
1
].
style
.
display
).
not
.
toBe
(
'
none
'
);
expect
(
vm
.
$el
.
querySelectorAll
(
'
mark
'
)[
1
].
textContent
).
toBe
(
'
in length
'
);
expect
(
vm
.
$el
.
querySelectorAll
(
'
mark
'
)[
1
].
textContent
).
toBe
(
'
in length
'
);
})
.
then
(
done
)
.
catch
(
done
.
fail
);
});
});
it
(
'
highlights body text & subject line
'
,
(
done
)
=>
{
it
(
'
highlights body text & subject line
'
,
async
(
)
=>
{
vm
.
text
=
vm
.
text
=
'
text less than 50 chars that should not highlighted
\n
body content that will be highlighted when it is more than 72 characters in length
'
;
'
text less than 50 chars that should not highlighted
\n
body content that will be highlighted when it is more than 72 characters in length
'
;
vm
.
$nextTick
()
await
nextTick
();
.
then
(()
=>
{
expect
(
vm
.
$el
.
querySelectorAll
(
'
.highlights span
'
).
length
).
toBe
(
2
);
expect
(
vm
.
$el
.
querySelectorAll
(
'
.highlights span
'
).
length
).
toBe
(
2
);
expect
(
vm
.
$el
.
querySelectorAll
(
'
mark
'
).
length
).
toBe
(
2
);
expect
(
vm
.
$el
.
querySelectorAll
(
'
mark
'
).
length
).
toBe
(
2
);
expect
(
vm
.
$el
.
querySelectorAll
(
'
mark
'
)[
0
].
textContent
).
toContain
(
'
d
'
);
expect
(
vm
.
$el
.
querySelectorAll
(
'
mark
'
)[
0
].
textContent
).
toContain
(
'
d
'
);
expect
(
vm
.
$el
.
querySelectorAll
(
'
mark
'
)[
1
].
textContent
).
toBe
(
'
in length
'
);
expect
(
vm
.
$el
.
querySelectorAll
(
'
mark
'
)[
1
].
textContent
).
toBe
(
'
in length
'
);
})
.
then
(
done
)
.
catch
(
done
.
fail
);
});
});
});
});
});
});
describe
(
'
scrolling textarea
'
,
()
=>
{
describe
(
'
scrolling textarea
'
,
()
=>
{
it
(
'
updates transform of highlights
'
,
(
done
)
=>
{
it
(
'
updates transform of highlights
'
,
async
(
)
=>
{
vm
.
text
=
'
subject line
\n\n\n\n\n\n\n\n\n\n\n
body content
'
;
vm
.
text
=
'
subject line
\n\n\n\n\n\n\n\n\n\n\n
body content
'
;
vm
.
$nextTick
()
await
nextTick
();
.
then
(()
=>
{
vm
.
$el
.
querySelector
(
'
textarea
'
).
scrollTo
(
0
,
50
);
vm
.
$el
.
querySelector
(
'
textarea
'
).
scrollTo
(
0
,
50
);
vm
.
handleScroll
();
vm
.
handleScroll
();
})
.
then
(
vm
.
$nextTick
)
await
nextTick
();
.
then
(()
=>
{
expect
(
vm
.
scrollTop
).
toBe
(
50
);
expect
(
vm
.
scrollTop
).
toBe
(
50
);
expect
(
vm
.
$el
.
querySelector
(
'
.highlights
'
).
style
.
transform
).
toBe
(
expect
(
vm
.
$el
.
querySelector
(
'
.highlights
'
).
style
.
transform
).
toBe
(
'
translate3d(0, -50px, 0)
'
);
'
translate3d(0, -50px, 0)
'
,
);
})
.
then
(
done
)
.
catch
(
done
.
fail
);
});
});
});
});
});
});
spec/frontend/ide/components/commit_sidebar/new_merge_request_option_spec.js
View file @
b8618652
import
Vue
from
'
vue
'
;
import
Vue
,
{
nextTick
}
from
'
vue
'
;
import
{
createComponentWithStore
}
from
'
helpers/vue_mount_component_helper
'
;
import
{
createComponentWithStore
}
from
'
helpers/vue_mount_component_helper
'
;
import
{
projectData
,
branches
}
from
'
jest/ide/mock_data
'
;
import
{
projectData
,
branches
}
from
'
jest/ide/mock_data
'
;
import
NewMergeRequestOption
from
'
~/ide/components/commit_sidebar/new_merge_request_option.vue
'
;
import
NewMergeRequestOption
from
'
~/ide/components/commit_sidebar/new_merge_request_option.vue
'
;
...
@@ -72,15 +72,11 @@ describe('create new MR checkbox', () => {
...
@@ -72,15 +72,11 @@ describe('create new MR checkbox', () => {
expect
(
vm
.
$el
.
textContent
).
not
.
toBe
(
''
);
expect
(
vm
.
$el
.
textContent
).
not
.
toBe
(
''
);
});
});
it
(
'
has new MR
'
,
(
done
)
=>
{
it
(
'
has new MR
'
,
async
(
)
=>
{
setMR
();
setMR
();
vm
.
$nextTick
()
await
nextTick
();
.
then
(()
=>
{
expect
(
vm
.
$el
.
textContent
).
not
.
toBe
(
''
);
expect
(
vm
.
$el
.
textContent
).
not
.
toBe
(
''
);
})
.
then
(
done
)
.
catch
(
done
.
fail
);
});
});
});
});
...
@@ -96,15 +92,11 @@ describe('create new MR checkbox', () => {
...
@@ -96,15 +92,11 @@ describe('create new MR checkbox', () => {
expect
(
vm
.
$el
.
textContent
).
toBe
(
''
);
expect
(
vm
.
$el
.
textContent
).
toBe
(
''
);
});
});
it
(
'
has new MR
'
,
(
done
)
=>
{
it
(
'
has new MR
'
,
async
(
)
=>
{
setMR
();
setMR
();
vm
.
$nextTick
()
await
nextTick
();
.
then
(()
=>
{
expect
(
vm
.
$el
.
textContent
).
toBe
(
''
);
expect
(
vm
.
$el
.
textContent
).
toBe
(
''
);
})
.
then
(
done
)
.
catch
(
done
.
fail
);
});
});
});
});
});
});
...
@@ -121,15 +113,11 @@ describe('create new MR checkbox', () => {
...
@@ -121,15 +113,11 @@ describe('create new MR checkbox', () => {
expect
(
vm
.
$el
.
textContent
).
not
.
toBe
(
''
);
expect
(
vm
.
$el
.
textContent
).
not
.
toBe
(
''
);
});
});
it
(
'
is rendered if MR exists
'
,
(
done
)
=>
{
it
(
'
is rendered if MR exists
'
,
async
(
)
=>
{
setMR
();
setMR
();
vm
.
$nextTick
()
await
nextTick
();
.
then
(()
=>
{
expect
(
vm
.
$el
.
textContent
).
not
.
toBe
(
''
);
expect
(
vm
.
$el
.
textContent
).
not
.
toBe
(
''
);
})
.
then
(
done
)
.
catch
(
done
.
fail
);
});
});
});
});
...
@@ -144,15 +132,11 @@ describe('create new MR checkbox', () => {
...
@@ -144,15 +132,11 @@ describe('create new MR checkbox', () => {
expect
(
vm
.
$el
.
textContent
).
not
.
toBe
(
''
);
expect
(
vm
.
$el
.
textContent
).
not
.
toBe
(
''
);
});
});
it
(
'
is hidden if MR exists
'
,
(
done
)
=>
{
it
(
'
is hidden if MR exists
'
,
async
(
)
=>
{
setMR
();
setMR
();
vm
.
$nextTick
()
await
nextTick
();
.
then
(()
=>
{
expect
(
vm
.
$el
.
textContent
).
toBe
(
''
);
expect
(
vm
.
$el
.
textContent
).
toBe
(
''
);
})
.
then
(
done
)
.
catch
(
done
.
fail
);
});
});
});
});
});
});
...
@@ -168,15 +152,11 @@ describe('create new MR checkbox', () => {
...
@@ -168,15 +152,11 @@ describe('create new MR checkbox', () => {
expect
(
vm
.
$el
.
textContent
).
not
.
toBe
(
''
);
expect
(
vm
.
$el
.
textContent
).
not
.
toBe
(
''
);
});
});
it
(
'
is hidden if MR exists
'
,
(
done
)
=>
{
it
(
'
is hidden if MR exists
'
,
async
(
)
=>
{
setMR
();
setMR
();
vm
.
$nextTick
()
await
nextTick
();
.
then
(()
=>
{
expect
(
vm
.
$el
.
textContent
).
toBe
(
''
);
expect
(
vm
.
$el
.
textContent
).
toBe
(
''
);
})
.
then
(
done
)
.
catch
(
done
.
fail
);
});
});
it
(
'
shows enablded checkbox
'
,
()
=>
{
it
(
'
shows enablded checkbox
'
,
()
=>
{
...
...
spec/frontend/ide/components/file_row_extra_spec.js
View file @
b8618652
import
Vue
from
'
vue
'
;
import
Vue
,
{
nextTick
}
from
'
vue
'
;
import
{
createComponentWithStore
}
from
'
helpers/vue_mount_component_helper
'
;
import
{
createComponentWithStore
}
from
'
helpers/vue_mount_component_helper
'
;
import
FileRowExtra
from
'
~/ide/components/file_row_extra.vue
'
;
import
FileRowExtra
from
'
~/ide/components/file_row_extra.vue
'
;
import
{
createStore
}
from
'
~/ide/stores
'
;
import
{
createStore
}
from
'
~/ide/stores
'
;
...
@@ -70,28 +70,22 @@ describe('IDE extra file row component', () => {
...
@@ -70,28 +70,22 @@ describe('IDE extra file row component', () => {
expect
(
vm
.
$el
.
querySelector
(
'
.ide-tree-changes
'
)).
toBe
(
null
);
expect
(
vm
.
$el
.
querySelector
(
'
.ide-tree-changes
'
)).
toBe
(
null
);
});
});
it
(
'
does not show when tree is open
'
,
(
done
)
=>
{
it
(
'
does not show when tree is open
'
,
async
(
)
=>
{
vm
.
file
.
type
=
'
tree
'
;
vm
.
file
.
type
=
'
tree
'
;
vm
.
file
.
opened
=
true
;
vm
.
file
.
opened
=
true
;
changesCount
=
1
;
changesCount
=
1
;
vm
.
$nextTick
(()
=>
{
await
nextTick
();
expect
(
vm
.
$el
.
querySelector
(
'
.ide-tree-changes
'
)).
toBe
(
null
);
expect
(
vm
.
$el
.
querySelector
(
'
.ide-tree-changes
'
)).
toBe
(
null
);
done
();
});
});
});
it
(
'
shows for trees with changes
'
,
(
done
)
=>
{
it
(
'
shows for trees with changes
'
,
async
(
)
=>
{
vm
.
file
.
type
=
'
tree
'
;
vm
.
file
.
type
=
'
tree
'
;
vm
.
file
.
opened
=
false
;
vm
.
file
.
opened
=
false
;
changesCount
=
1
;
changesCount
=
1
;
vm
.
$nextTick
(()
=>
{
await
nextTick
();
expect
(
vm
.
$el
.
querySelector
(
'
.ide-tree-changes
'
)).
not
.
toBe
(
null
);
expect
(
vm
.
$el
.
querySelector
(
'
.ide-tree-changes
'
)).
not
.
toBe
(
null
);
done
();
});
});
});
});
});
...
@@ -100,55 +94,40 @@ describe('IDE extra file row component', () => {
...
@@ -100,55 +94,40 @@ describe('IDE extra file row component', () => {
expect
(
vm
.
$el
.
querySelector
(
'
.file-changed-icon
'
)).
toBe
(
null
);
expect
(
vm
.
$el
.
querySelector
(
'
.file-changed-icon
'
)).
toBe
(
null
);
});
});
it
(
'
shows when file is changed
'
,
(
done
)
=>
{
it
(
'
shows when file is changed
'
,
async
(
)
=>
{
vm
.
file
.
changed
=
true
;
vm
.
file
.
changed
=
true
;
vm
.
$nextTick
(()
=>
{
await
nextTick
();
expect
(
vm
.
$el
.
querySelector
(
'
.file-changed-icon
'
)).
not
.
toBe
(
null
);
expect
(
vm
.
$el
.
querySelector
(
'
.file-changed-icon
'
)).
not
.
toBe
(
null
);
done
();
});
});
});
it
(
'
shows when file is staged
'
,
(
done
)
=>
{
it
(
'
shows when file is staged
'
,
async
(
)
=>
{
vm
.
file
.
staged
=
true
;
vm
.
file
.
staged
=
true
;
vm
.
$nextTick
(()
=>
{
await
nextTick
();
expect
(
vm
.
$el
.
querySelector
(
'
.file-changed-icon
'
)).
not
.
toBe
(
null
);
expect
(
vm
.
$el
.
querySelector
(
'
.file-changed-icon
'
)).
not
.
toBe
(
null
);
done
();
});
});
});
it
(
'
shows when file is a tempFile
'
,
(
done
)
=>
{
it
(
'
shows when file is a tempFile
'
,
async
(
)
=>
{
vm
.
file
.
tempFile
=
true
;
vm
.
file
.
tempFile
=
true
;
vm
.
$nextTick
(()
=>
{
await
nextTick
();
expect
(
vm
.
$el
.
querySelector
(
'
.file-changed-icon
'
)).
not
.
toBe
(
null
);
expect
(
vm
.
$el
.
querySelector
(
'
.file-changed-icon
'
)).
not
.
toBe
(
null
);
done
();
});
});
});
it
(
'
shows when file is renamed
'
,
(
done
)
=>
{
it
(
'
shows when file is renamed
'
,
async
(
)
=>
{
vm
.
file
.
prevPath
=
'
original-file
'
;
vm
.
file
.
prevPath
=
'
original-file
'
;
vm
.
$nextTick
(()
=>
{
await
nextTick
();
expect
(
vm
.
$el
.
querySelector
(
'
.file-changed-icon
'
)).
not
.
toBe
(
null
);
expect
(
vm
.
$el
.
querySelector
(
'
.file-changed-icon
'
)).
not
.
toBe
(
null
);
done
();
});
});
});
it
(
'
hides when file is renamed
'
,
(
done
)
=>
{
it
(
'
hides when file is renamed
'
,
async
(
)
=>
{
vm
.
file
.
prevPath
=
'
original-file
'
;
vm
.
file
.
prevPath
=
'
original-file
'
;
vm
.
file
.
type
=
'
tree
'
;
vm
.
file
.
type
=
'
tree
'
;
vm
.
$nextTick
(()
=>
{
await
nextTick
();
expect
(
vm
.
$el
.
querySelector
(
'
.file-changed-icon
'
)).
toBe
(
null
);
expect
(
vm
.
$el
.
querySelector
(
'
.file-changed-icon
'
)).
toBe
(
null
);
done
();
});
});
});
});
});
...
@@ -157,14 +136,11 @@ describe('IDE extra file row component', () => {
...
@@ -157,14 +136,11 @@ describe('IDE extra file row component', () => {
expect
(
vm
.
$el
.
querySelector
(
'
[data-testid="git-merge-icon"]
'
)).
toBe
(
null
);
expect
(
vm
.
$el
.
querySelector
(
'
[data-testid="git-merge-icon"]
'
)).
toBe
(
null
);
});
});
it
(
'
shows when a merge request change
'
,
(
done
)
=>
{
it
(
'
shows when a merge request change
'
,
async
(
)
=>
{
vm
.
file
.
mrChange
=
true
;
vm
.
file
.
mrChange
=
true
;
vm
.
$nextTick
(()
=>
{
await
nextTick
();
expect
(
vm
.
$el
.
querySelector
(
'
[data-testid="git-merge-icon"]
'
)).
not
.
toBe
(
null
);
expect
(
vm
.
$el
.
querySelector
(
'
[data-testid="git-merge-icon"]
'
)).
not
.
toBe
(
null
);
done
();
});
});
});
});
});
});
});
spec/frontend/ide/components/file_templates/bar_spec.js
View file @
b8618652
import
Vue
from
'
vue
'
;
import
Vue
,
{
nextTick
}
from
'
vue
'
;
import
{
mountComponentWithStore
}
from
'
helpers/vue_mount_component_helper
'
;
import
{
mountComponentWithStore
}
from
'
helpers/vue_mount_component_helper
'
;
import
Bar
from
'
~/ide/components/file_templates/bar.vue
'
;
import
Bar
from
'
~/ide/components/file_templates/bar.vue
'
;
import
{
createStore
}
from
'
~/ide/stores
'
;
import
{
createStore
}
from
'
~/ide/stores
'
;
...
@@ -46,7 +46,7 @@ describe('IDE file templates bar component', () => {
...
@@ -46,7 +46,7 @@ describe('IDE file templates bar component', () => {
});
});
describe
(
'
template dropdown
'
,
()
=>
{
describe
(
'
template dropdown
'
,
()
=>
{
beforeEach
(
(
done
)
=>
{
beforeEach
(
async
(
)
=>
{
vm
.
$store
.
state
.
fileTemplates
.
templates
=
[
vm
.
$store
.
state
.
fileTemplates
.
templates
=
[
{
{
name
:
'
test
'
,
name
:
'
test
'
,
...
@@ -57,7 +57,7 @@ describe('IDE file templates bar component', () => {
...
@@ -57,7 +57,7 @@ describe('IDE file templates bar component', () => {
key
:
'
gitlab_ci_ymls
'
,
key
:
'
gitlab_ci_ymls
'
,
};
};
vm
.
$nextTick
(
done
);
await
nextTick
(
);
});
});
it
(
'
renders dropdown component
'
,
()
=>
{
it
(
'
renders dropdown component
'
,
()
=>
{
...
@@ -75,14 +75,11 @@ describe('IDE file templates bar component', () => {
...
@@ -75,14 +75,11 @@ describe('IDE file templates bar component', () => {
});
});
});
});
it
(
'
shows undo button if updateSuccess is true
'
,
(
done
)
=>
{
it
(
'
shows undo button if updateSuccess is true
'
,
async
(
)
=>
{
vm
.
$store
.
state
.
fileTemplates
.
updateSuccess
=
true
;
vm
.
$store
.
state
.
fileTemplates
.
updateSuccess
=
true
;
vm
.
$nextTick
(()
=>
{
await
nextTick
();
expect
(
vm
.
$el
.
querySelector
(
'
.btn-default
'
).
style
.
display
).
not
.
toBe
(
'
none
'
);
expect
(
vm
.
$el
.
querySelector
(
'
.btn-default
'
).
style
.
display
).
not
.
toBe
(
'
none
'
);
done
();
});
});
});
it
(
'
calls undoFileTemplate when clicking undo button
'
,
()
=>
{
it
(
'
calls undoFileTemplate when clicking undo button
'
,
()
=>
{
...
@@ -93,7 +90,7 @@ describe('IDE file templates bar component', () => {
...
@@ -93,7 +90,7 @@ describe('IDE file templates bar component', () => {
expect
(
vm
.
undoFileTemplate
).
toHaveBeenCalled
();
expect
(
vm
.
undoFileTemplate
).
toHaveBeenCalled
();
});
});
it
(
'
calls setSelectedTemplateType if activeFile name matches a template
'
,
(
done
)
=>
{
it
(
'
calls setSelectedTemplateType if activeFile name matches a template
'
,
async
(
)
=>
{
const
fileName
=
'
.gitlab-ci.yml
'
;
const
fileName
=
'
.gitlab-ci.yml
'
;
jest
.
spyOn
(
vm
,
'
setSelectedTemplateType
'
).
mockImplementation
(()
=>
{});
jest
.
spyOn
(
vm
,
'
setSelectedTemplateType
'
).
mockImplementation
(()
=>
{});
...
@@ -101,13 +98,10 @@ describe('IDE file templates bar component', () => {
...
@@ -101,13 +98,10 @@ describe('IDE file templates bar component', () => {
vm
.
setInitialType
();
vm
.
setInitialType
();
vm
.
$nextTick
(()
=>
{
await
nextTick
();
expect
(
vm
.
setSelectedTemplateType
).
toHaveBeenCalledWith
({
expect
(
vm
.
setSelectedTemplateType
).
toHaveBeenCalledWith
({
name
:
fileName
,
name
:
fileName
,
key
:
'
gitlab_ci_ymls
'
,
key
:
'
gitlab_ci_ymls
'
,
});
});
done
();
});
});
});
});
});
spec/frontend/ide/components/ide_status_bar_spec.js
View file @
b8618652
import
_
from
'
lodash
'
;
import
_
from
'
lodash
'
;
import
Vue
from
'
vue
'
;
import
Vue
,
{
nextTick
}
from
'
vue
'
;
import
{
TEST_HOST
}
from
'
helpers/test_constants
'
;
import
{
TEST_HOST
}
from
'
helpers/test_constants
'
;
import
{
createComponentWithStore
}
from
'
helpers/vue_mount_component_helper
'
;
import
{
createComponentWithStore
}
from
'
helpers/vue_mount_component_helper
'
;
import
IdeStatusBar
from
'
~/ide/components/ide_status_bar.vue
'
;
import
IdeStatusBar
from
'
~/ide/components/ide_status_bar.vue
'
;
...
@@ -73,7 +73,7 @@ describe('ideStatusBar', () => {
...
@@ -73,7 +73,7 @@ describe('ideStatusBar', () => {
});
});
describe
(
'
pipeline status
'
,
()
=>
{
describe
(
'
pipeline status
'
,
()
=>
{
it
(
'
opens right sidebar on clicking icon
'
,
(
done
)
=>
{
it
(
'
opens right sidebar on clicking icon
'
,
async
(
)
=>
{
jest
.
spyOn
(
vm
,
'
openRightPane
'
).
mockImplementation
(()
=>
{});
jest
.
spyOn
(
vm
,
'
openRightPane
'
).
mockImplementation
(()
=>
{});
Vue
.
set
(
vm
.
$store
.
state
.
pipelines
,
'
latestPipeline
'
,
{
Vue
.
set
(
vm
.
$store
.
state
.
pipelines
,
'
latestPipeline
'
,
{
details
:
{
details
:
{
...
@@ -88,14 +88,10 @@ describe('ideStatusBar', () => {
...
@@ -88,14 +88,10 @@ describe('ideStatusBar', () => {
},
},
});
});
vm
.
$nextTick
()
await
nextTick
();
.
then
(()
=>
{
vm
.
$el
.
querySelector
(
'
.ide-status-pipeline button
'
).
click
();
vm
.
$el
.
querySelector
(
'
.ide-status-pipeline button
'
).
click
();
expect
(
vm
.
openRightPane
).
toHaveBeenCalledWith
(
rightSidebarViews
.
pipelines
);
expect
(
vm
.
openRightPane
).
toHaveBeenCalledWith
(
rightSidebarViews
.
pipelines
);
})
.
then
(
done
)
.
catch
(
done
.
fail
);
});
});
});
});
...
...
spec/frontend/ide/components/ide_tree_list_spec.js
View file @
b8618652
import
Vue
from
'
vue
'
;
import
Vue
,
{
nextTick
}
from
'
vue
'
;
import
{
createComponentWithStore
}
from
'
helpers/vue_mount_component_helper
'
;
import
{
createComponentWithStore
}
from
'
helpers/vue_mount_component_helper
'
;
import
IdeTreeList
from
'
~/ide/components/ide_tree_list.vue
'
;
import
IdeTreeList
from
'
~/ide/components/ide_tree_list.vue
'
;
import
{
createStore
}
from
'
~/ide/stores
'
;
import
{
createStore
}
from
'
~/ide/stores
'
;
...
@@ -48,15 +48,12 @@ describe('IDE tree list', () => {
...
@@ -48,15 +48,12 @@ describe('IDE tree list', () => {
expect
(
vm
.
$emit
).
toHaveBeenCalledWith
(
'
tree-ready
'
);
expect
(
vm
.
$emit
).
toHaveBeenCalledWith
(
'
tree-ready
'
);
});
});
it
(
'
renders loading indicator
'
,
(
done
)
=>
{
it
(
'
renders loading indicator
'
,
async
(
)
=>
{
store
.
state
.
trees
[
'
abcproject/main
'
].
loading
=
true
;
store
.
state
.
trees
[
'
abcproject/main
'
].
loading
=
true
;
vm
.
$nextTick
(()
=>
{
await
nextTick
();
expect
(
vm
.
$el
.
querySelector
(
'
.multi-file-loading-container
'
)).
not
.
toBeNull
();
expect
(
vm
.
$el
.
querySelector
(
'
.multi-file-loading-container
'
)).
not
.
toBeNull
();
expect
(
vm
.
$el
.
querySelectorAll
(
'
.multi-file-loading-container
'
).
length
).
toBe
(
3
);
expect
(
vm
.
$el
.
querySelectorAll
(
'
.multi-file-loading-container
'
).
length
).
toBe
(
3
);
done
();
});
});
});
it
(
'
renders list of files
'
,
()
=>
{
it
(
'
renders list of files
'
,
()
=>
{
...
...
spec/frontend/ide/components/jobs/detail_spec.js
View file @
b8618652
import
Vue
from
'
vue
'
;
import
Vue
,
{
nextTick
}
from
'
vue
'
;
import
{
TEST_HOST
}
from
'
helpers/test_constants
'
;
import
{
TEST_HOST
}
from
'
helpers/test_constants
'
;
import
{
createComponentWithStore
}
from
'
helpers/vue_mount_component_helper
'
;
import
{
createComponentWithStore
}
from
'
helpers/vue_mount_component_helper
'
;
import
JobDetail
from
'
~/ide/components/jobs/detail.vue
'
;
import
JobDetail
from
'
~/ide/components/jobs/detail.vue
'
;
...
@@ -48,14 +48,11 @@ describe('IDE jobs detail view', () => {
...
@@ -48,14 +48,11 @@ describe('IDE jobs detail view', () => {
expect
(
vm
.
$el
.
querySelector
(
'
.bash
'
).
textContent
).
toContain
(
'
testing
'
);
expect
(
vm
.
$el
.
querySelector
(
'
.bash
'
).
textContent
).
toContain
(
'
testing
'
);
});
});
it
(
'
renders empty message output
'
,
(
done
)
=>
{
it
(
'
renders empty message output
'
,
async
(
)
=>
{
vm
.
$store
.
state
.
pipelines
.
detailJob
.
output
=
''
;
vm
.
$store
.
state
.
pipelines
.
detailJob
.
output
=
''
;
vm
.
$nextTick
(()
=>
{
await
nextTick
();
expect
(
vm
.
$el
.
querySelector
(
'
.bash
'
).
textContent
).
toContain
(
'
No messages were logged
'
);
expect
(
vm
.
$el
.
querySelector
(
'
.bash
'
).
textContent
).
toContain
(
'
No messages were logged
'
);
done
();
});
});
});
it
(
'
renders loading icon
'
,
()
=>
{
it
(
'
renders loading icon
'
,
()
=>
{
...
@@ -68,14 +65,11 @@ describe('IDE jobs detail view', () => {
...
@@ -68,14 +65,11 @@ describe('IDE jobs detail view', () => {
expect
(
vm
.
$el
.
querySelector
(
'
.bash
'
).
style
.
display
).
toBe
(
'
none
'
);
expect
(
vm
.
$el
.
querySelector
(
'
.bash
'
).
style
.
display
).
toBe
(
'
none
'
);
});
});
it
(
'
hide loading icon when isLoading is false
'
,
(
done
)
=>
{
it
(
'
hide loading icon when isLoading is false
'
,
async
(
)
=>
{
vm
.
$store
.
state
.
pipelines
.
detailJob
.
isLoading
=
false
;
vm
.
$store
.
state
.
pipelines
.
detailJob
.
isLoading
=
false
;
vm
.
$nextTick
(()
=>
{
await
nextTick
();
expect
(
vm
.
$el
.
querySelector
(
'
.build-loader-animation
'
).
style
.
display
).
toBe
(
'
none
'
);
expect
(
vm
.
$el
.
querySelector
(
'
.build-loader-animation
'
).
style
.
display
).
toBe
(
'
none
'
);
done
();
});
});
});
it
(
'
resets detailJob when clicking header button
'
,
()
=>
{
it
(
'
resets detailJob when clicking header button
'
,
()
=>
{
...
@@ -107,19 +101,18 @@ describe('IDE jobs detail view', () => {
...
@@ -107,19 +101,18 @@ describe('IDE jobs detail view', () => {
fnName | btnName | scrollPos
fnName | btnName | scrollPos
${
'
scrollDown
'
}
|
${
'
down
'
}
|
${
0
}
${
'
scrollDown
'
}
|
${
'
down
'
}
|
${
0
}
${
'
scrollUp
'
}
|
${
'
up
'
}
|
${
1
}
${
'
scrollUp
'
}
|
${
'
up
'
}
|
${
1
}
`
(
'
triggers $fnName when clicking $btnName button
'
,
({
fnName
,
scrollPos
})
=>
{
`
(
'
triggers $fnName when clicking $btnName button
'
,
async
({
fnName
,
scrollPos
})
=>
{
jest
.
spyOn
(
vm
,
fnName
).
mockImplementation
();
jest
.
spyOn
(
vm
,
fnName
).
mockImplementation
();
vm
=
vm
.
$mount
();
vm
=
vm
.
$mount
();
vm
.
scrollPos
=
scrollPos
;
vm
.
scrollPos
=
scrollPos
;
return
vm
.
$nextTick
().
then
(()
=>
{
await
nextTick
();
vm
.
$el
.
querySelector
(
'
.btn-scroll:not([disabled])
'
).
click
();
vm
.
$el
.
querySelector
(
'
.btn-scroll:not([disabled])
'
).
click
();
expect
(
vm
[
fnName
]).
toHaveBeenCalled
();
expect
(
vm
[
fnName
]).
toHaveBeenCalled
();
});
});
});
});
});
describe
(
'
scrollDown
'
,
()
=>
{
describe
(
'
scrollDown
'
,
()
=>
{
beforeEach
(()
=>
{
beforeEach
(()
=>
{
...
...
spec/frontend/ide/components/jobs/item_spec.js
View file @
b8618652
import
Vue
from
'
vue
'
;
import
Vue
,
{
nextTick
}
from
'
vue
'
;
import
mountComponent
from
'
helpers/vue_mount_component_helper
'
;
import
mountComponent
from
'
helpers/vue_mount_component_helper
'
;
import
JobItem
from
'
~/ide/components/jobs/item.vue
'
;
import
JobItem
from
'
~/ide/components/jobs/item.vue
'
;
import
{
jobs
}
from
'
../../mock_data
'
;
import
{
jobs
}
from
'
../../mock_data
'
;
...
@@ -27,13 +27,10 @@ describe('IDE jobs item', () => {
...
@@ -27,13 +27,10 @@ describe('IDE jobs item', () => {
expect
(
vm
.
$el
.
querySelector
(
'
[data-testid="status_success_borderless-icon"]
'
)).
not
.
toBe
(
null
);
expect
(
vm
.
$el
.
querySelector
(
'
[data-testid="status_success_borderless-icon"]
'
)).
not
.
toBe
(
null
);
});
});
it
(
'
does not render view logs button if not started
'
,
(
done
)
=>
{
it
(
'
does not render view logs button if not started
'
,
async
(
)
=>
{
vm
.
job
.
started
=
false
;
vm
.
job
.
started
=
false
;
vm
.
$nextTick
(()
=>
{
await
nextTick
();
expect
(
vm
.
$el
.
querySelector
(
'
.btn
'
)).
toBe
(
null
);
expect
(
vm
.
$el
.
querySelector
(
'
.btn
'
)).
toBe
(
null
);
done
();
});
});
});
});
});
spec/frontend/ide/components/nav_dropdown_button_spec.js
View file @
b8618652
import
Vue
from
'
vue
'
;
import
Vue
,
{
nextTick
}
from
'
vue
'
;
import
{
trimText
}
from
'
helpers/text_helper
'
;
import
{
trimText
}
from
'
helpers/text_helper
'
;
import
{
mountComponentWithStore
}
from
'
helpers/vue_mount_component_helper
'
;
import
{
mountComponentWithStore
}
from
'
helpers/vue_mount_component_helper
'
;
import
NavDropdownButton
from
'
~/ide/components/nav_dropdown_button.vue
'
;
import
NavDropdownButton
from
'
~/ide/components/nav_dropdown_button.vue
'
;
...
@@ -36,38 +36,26 @@ describe('NavDropdown', () => {
...
@@ -36,38 +36,26 @@ describe('NavDropdown', () => {
expect
(
trimText
(
vm
.
$el
.
textContent
)).
toEqual
(
'
- -
'
);
expect
(
trimText
(
vm
.
$el
.
textContent
)).
toEqual
(
'
- -
'
);
});
});
it
(
'
renders branch name, if state has currentBranchId
'
,
(
done
)
=>
{
it
(
'
renders branch name, if state has currentBranchId
'
,
async
(
)
=>
{
vm
.
$store
.
state
.
currentBranchId
=
TEST_BRANCH_ID
;
vm
.
$store
.
state
.
currentBranchId
=
TEST_BRANCH_ID
;
vm
.
$nextTick
()
await
nextTick
();
.
then
(()
=>
{
expect
(
trimText
(
vm
.
$el
.
textContent
)).
toEqual
(
`
${
TEST_BRANCH_ID
}
-`
);
expect
(
trimText
(
vm
.
$el
.
textContent
)).
toEqual
(
`
${
TEST_BRANCH_ID
}
-`
);
})
.
then
(
done
)
.
catch
(
done
.
fail
);
});
});
it
(
'
renders mr id, if state has currentMergeRequestId
'
,
(
done
)
=>
{
it
(
'
renders mr id, if state has currentMergeRequestId
'
,
async
(
)
=>
{
vm
.
$store
.
state
.
currentMergeRequestId
=
TEST_MR_ID
;
vm
.
$store
.
state
.
currentMergeRequestId
=
TEST_MR_ID
;
vm
.
$nextTick
()
await
nextTick
();
.
then
(()
=>
{
expect
(
trimText
(
vm
.
$el
.
textContent
)).
toEqual
(
`- !
${
TEST_MR_ID
}
`
);
expect
(
trimText
(
vm
.
$el
.
textContent
)).
toEqual
(
`- !
${
TEST_MR_ID
}
`
);
})
.
then
(
done
)
.
catch
(
done
.
fail
);
});
});
it
(
'
renders branch and mr, if state has both
'
,
(
done
)
=>
{
it
(
'
renders branch and mr, if state has both
'
,
async
(
)
=>
{
vm
.
$store
.
state
.
currentBranchId
=
TEST_BRANCH_ID
;
vm
.
$store
.
state
.
currentBranchId
=
TEST_BRANCH_ID
;
vm
.
$store
.
state
.
currentMergeRequestId
=
TEST_MR_ID
;
vm
.
$store
.
state
.
currentMergeRequestId
=
TEST_MR_ID
;
vm
.
$nextTick
()
await
nextTick
();
.
then
(()
=>
{
expect
(
trimText
(
vm
.
$el
.
textContent
)).
toEqual
(
`
${
TEST_BRANCH_ID
}
!
${
TEST_MR_ID
}
`
);
expect
(
trimText
(
vm
.
$el
.
textContent
)).
toEqual
(
`
${
TEST_BRANCH_ID
}
!
${
TEST_MR_ID
}
`
);
})
.
then
(
done
)
.
catch
(
done
.
fail
);
});
});
it
(
'
shows icons
'
,
()
=>
{
it
(
'
shows icons
'
,
()
=>
{
...
...
spec/frontend/ide/components/nav_dropdown_spec.js
View file @
b8618652
import
{
mount
}
from
'
@vue/test-utils
'
;
import
{
mount
}
from
'
@vue/test-utils
'
;
import
$
from
'
jquery
'
;
import
$
from
'
jquery
'
;
import
{
nextTick
}
from
'
vue
'
;
import
NavDropdown
from
'
~/ide/components/nav_dropdown.vue
'
;
import
NavDropdown
from
'
~/ide/components/nav_dropdown.vue
'
;
import
{
PERMISSION_READ_MR
}
from
'
~/ide/constants
'
;
import
{
PERMISSION_READ_MR
}
from
'
~/ide/constants
'
;
import
{
createStore
}
from
'
~/ide/stores
'
;
import
{
createStore
}
from
'
~/ide/stores
'
;
...
@@ -58,29 +59,19 @@ describe('IDE NavDropdown', () => {
...
@@ -58,29 +59,19 @@ describe('IDE NavDropdown', () => {
expect
(
findNavForm
().
exists
()).
toBe
(
false
);
expect
(
findNavForm
().
exists
()).
toBe
(
false
);
});
});
it
(
'
renders nav form when show.bs.dropdown
'
,
(
done
)
=>
{
it
(
'
renders nav form when show.bs.dropdown
'
,
async
(
)
=>
{
showDropdown
();
showDropdown
();
wrapper
.
vm
await
nextTick
();
.
$nextTick
()
.
then
(()
=>
{
expect
(
findNavForm
().
exists
()).
toBe
(
true
);
expect
(
findNavForm
().
exists
()).
toBe
(
true
);
})
.
then
(
done
)
.
catch
(
done
.
fail
);
});
});
it
(
'
destroys nav form when closed
'
,
(
done
)
=>
{
it
(
'
destroys nav form when closed
'
,
async
(
)
=>
{
showDropdown
();
showDropdown
();
hideDropdown
();
hideDropdown
();
wrapper
.
vm
await
nextTick
();
.
$nextTick
()
.
then
(()
=>
{
expect
(
findNavForm
().
exists
()).
toBe
(
false
);
expect
(
findNavForm
().
exists
()).
toBe
(
false
);
})
.
then
(
done
)
.
catch
(
done
.
fail
);
});
});
it
(
'
renders merge request icon
'
,
()
=>
{
it
(
'
renders merge request icon
'
,
()
=>
{
...
...
spec/frontend/ide/components/new_dropdown/button_spec.js
View file @
b8618652
import
Vue
from
'
vue
'
;
import
Vue
,
{
nextTick
}
from
'
vue
'
;
import
mountComponent
from
'
helpers/vue_mount_component_helper
'
;
import
mountComponent
from
'
helpers/vue_mount_component_helper
'
;
import
Button
from
'
~/ide/components/new_dropdown/button.vue
'
;
import
Button
from
'
~/ide/components/new_dropdown/button.vue
'
;
...
@@ -37,14 +37,11 @@ describe('IDE new entry dropdown button component', () => {
...
@@ -37,14 +37,11 @@ describe('IDE new entry dropdown button component', () => {
expect
(
vm
.
$emit
).
toHaveBeenCalledWith
(
'
click
'
);
expect
(
vm
.
$emit
).
toHaveBeenCalledWith
(
'
click
'
);
});
});
it
(
'
hides label if showLabel is false
'
,
(
done
)
=>
{
it
(
'
hides label if showLabel is false
'
,
async
(
)
=>
{
vm
.
showLabel
=
false
;
vm
.
showLabel
=
false
;
vm
.
$nextTick
(()
=>
{
await
nextTick
();
expect
(
vm
.
$el
.
textContent
).
not
.
toContain
(
'
Testing
'
);
expect
(
vm
.
$el
.
textContent
).
not
.
toContain
(
'
Testing
'
);
done
();
});
});
});
describe
(
'
tooltipTitle
'
,
()
=>
{
describe
(
'
tooltipTitle
'
,
()
=>
{
...
@@ -52,14 +49,11 @@ describe('IDE new entry dropdown button component', () => {
...
@@ -52,14 +49,11 @@ describe('IDE new entry dropdown button component', () => {
expect
(
vm
.
tooltipTitle
).
toBe
(
''
);
expect
(
vm
.
tooltipTitle
).
toBe
(
''
);
});
});
it
(
'
returns label
'
,
(
done
)
=>
{
it
(
'
returns label
'
,
async
(
)
=>
{
vm
.
showLabel
=
false
;
vm
.
showLabel
=
false
;
vm
.
$nextTick
(()
=>
{
await
nextTick
();
expect
(
vm
.
tooltipTitle
).
toBe
(
'
Testing
'
);
expect
(
vm
.
tooltipTitle
).
toBe
(
'
Testing
'
);
done
();
});
});
});
});
});
});
});
spec/frontend/ide/components/new_dropdown/modal_spec.js
View file @
b8618652
import
Vue
from
'
vue
'
;
import
Vue
,
{
nextTick
}
from
'
vue
'
;
import
{
createComponentWithStore
}
from
'
helpers/vue_mount_component_helper
'
;
import
{
createComponentWithStore
}
from
'
helpers/vue_mount_component_helper
'
;
import
createFlash
from
'
~/flash
'
;
import
createFlash
from
'
~/flash
'
;
import
modal
from
'
~/ide/components/new_dropdown/modal.vue
'
;
import
modal
from
'
~/ide/components/new_dropdown/modal.vue
'
;
...
@@ -19,14 +19,14 @@ describe('new file modal component', () => {
...
@@ -19,14 +19,14 @@ describe('new file modal component', () => {
${
'
tree
'
}
|
${
'
Create new directory
'
}
|
${
'
Create directory
'
}
|
${
false
}
${
'
tree
'
}
|
${
'
Create new directory
'
}
|
${
'
Create directory
'
}
|
${
false
}
${
'
blob
'
}
|
${
'
Create new file
'
}
|
${
'
Create file
'
}
|
${
true
}
${
'
blob
'
}
|
${
'
Create new file
'
}
|
${
'
Create file
'
}
|
${
true
}
`
(
'
$entryType
'
,
({
entryType
,
modalTitle
,
btnTitle
,
showsFileTemplates
})
=>
{
`
(
'
$entryType
'
,
({
entryType
,
modalTitle
,
btnTitle
,
showsFileTemplates
})
=>
{
beforeEach
(
(
done
)
=>
{
beforeEach
(
async
(
)
=>
{
const
store
=
createStore
();
const
store
=
createStore
();
vm
=
createComponentWithStore
(
Component
,
store
).
$mount
();
vm
=
createComponentWithStore
(
Component
,
store
).
$mount
();
vm
.
open
(
entryType
);
vm
.
open
(
entryType
);
vm
.
name
=
'
testing
'
;
vm
.
name
=
'
testing
'
;
vm
.
$nextTick
(
done
);
await
nextTick
(
);
});
});
afterEach
(()
=>
{
afterEach
(()
=>
{
...
@@ -71,16 +71,13 @@ describe('new file modal component', () => {
...
@@ -71,16 +71,13 @@ describe('new file modal component', () => {
${
'
blob
'
}
|
${
'
Rename file
'
}
|
${
'
Rename file
'
}
${
'
blob
'
}
|
${
'
Rename file
'
}
|
${
'
Rename file
'
}
`
(
`
(
'
renders title and button for renaming $entryType
'
,
'
renders title and button for renaming $entryType
'
,
({
entryType
,
modalTitle
,
btnTitle
},
done
)
=>
{
async
({
entryType
,
modalTitle
,
btnTitle
}
)
=>
{
vm
.
$store
.
state
.
entries
[
'
test-path
'
].
type
=
entryType
;
vm
.
$store
.
state
.
entries
[
'
test-path
'
].
type
=
entryType
;
vm
.
open
(
'
rename
'
,
'
test-path
'
);
vm
.
open
(
'
rename
'
,
'
test-path
'
);
vm
.
$nextTick
(()
=>
{
await
nextTick
();
expect
(
document
.
querySelector
(
'
.modal-title
'
).
textContent
.
trim
()).
toBe
(
modalTitle
);
expect
(
document
.
querySelector
(
'
.modal-title
'
).
textContent
.
trim
()).
toBe
(
modalTitle
);
expect
(
document
.
querySelector
(
'
.btn-success
'
).
textContent
.
trim
()).
toBe
(
btnTitle
);
expect
(
document
.
querySelector
(
'
.btn-success
'
).
textContent
.
trim
()).
toBe
(
btnTitle
);
done
();
});
},
},
);
);
...
...
spec/frontend/ide/components/repo_editor_spec.js
View file @
b8618652
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
{
editor
as
monacoEditor
,
Range
}
from
'
monaco-editor
'
;
import
{
editor
as
monacoEditor
,
Range
}
from
'
monaco-editor
'
;
import
Vue
from
'
vue
'
;
import
Vue
,
{
nextTick
}
from
'
vue
'
;
import
Vuex
from
'
vuex
'
;
import
Vuex
from
'
vuex
'
;
import
'
~/behaviors/markdown/render_gfm
'
;
import
'
~/behaviors/markdown/render_gfm
'
;
import
waitForPromises
from
'
helpers/wait_for_promises
'
;
import
waitForPromises
from
'
helpers/wait_for_promises
'
;
...
@@ -367,17 +367,17 @@ describe('RepoEditor', () => {
...
@@ -367,17 +367,17 @@ describe('RepoEditor', () => {
expect
(
vm
.
$store
.
state
.
panelResizing
).
toBe
(
false
);
// default value
expect
(
vm
.
$store
.
state
.
panelResizing
).
toBe
(
false
);
// default value
vm
.
$store
.
state
.
panelResizing
=
true
;
vm
.
$store
.
state
.
panelResizing
=
true
;
await
vm
.
$
nextTick
();
await
nextTick
();
expect
(
updateDimensionsSpy
).
not
.
toHaveBeenCalled
();
expect
(
updateDimensionsSpy
).
not
.
toHaveBeenCalled
();
vm
.
$store
.
state
.
panelResizing
=
false
;
vm
.
$store
.
state
.
panelResizing
=
false
;
await
vm
.
$
nextTick
();
await
nextTick
();
expect
(
updateDimensionsSpy
).
toHaveBeenCalledTimes
(
1
);
expect
(
updateDimensionsSpy
).
toHaveBeenCalledTimes
(
1
);
vm
.
$store
.
state
.
panelResizing
=
true
;
vm
.
$store
.
state
.
panelResizing
=
true
;
await
vm
.
$
nextTick
();
await
nextTick
();
expect
(
updateDimensionsSpy
).
toHaveBeenCalledTimes
(
1
);
expect
(
updateDimensionsSpy
).
toHaveBeenCalledTimes
(
1
);
});
});
...
@@ -387,12 +387,12 @@ describe('RepoEditor', () => {
...
@@ -387,12 +387,12 @@ describe('RepoEditor', () => {
expect
(
vm
.
$store
.
state
.
rightPane
.
isOpen
).
toBe
(
false
);
// default value
expect
(
vm
.
$store
.
state
.
rightPane
.
isOpen
).
toBe
(
false
);
// default value
vm
.
$store
.
state
.
rightPane
.
isOpen
=
true
;
vm
.
$store
.
state
.
rightPane
.
isOpen
=
true
;
await
vm
.
$
nextTick
();
await
nextTick
();
expect
(
updateDimensionsSpy
).
toHaveBeenCalledTimes
(
1
);
expect
(
updateDimensionsSpy
).
toHaveBeenCalledTimes
(
1
);
vm
.
$store
.
state
.
rightPane
.
isOpen
=
false
;
vm
.
$store
.
state
.
rightPane
.
isOpen
=
false
;
await
vm
.
$
nextTick
();
await
nextTick
();
expect
(
updateDimensionsSpy
).
toHaveBeenCalledTimes
(
2
);
expect
(
updateDimensionsSpy
).
toHaveBeenCalledTimes
(
2
);
});
});
...
@@ -411,7 +411,7 @@ describe('RepoEditor', () => {
...
@@ -411,7 +411,7 @@ describe('RepoEditor', () => {
`
(
'
tabs in $mode are $isVisible
'
,
async
({
mode
,
isVisible
}
=
{})
=>
{
`
(
'
tabs in $mode are $isVisible
'
,
async
({
mode
,
isVisible
}
=
{})
=>
{
vm
.
$store
.
state
.
currentActivityView
=
leftSidebarViews
[
mode
].
name
;
vm
.
$store
.
state
.
currentActivityView
=
leftSidebarViews
[
mode
].
name
;
await
vm
.
$
nextTick
();
await
nextTick
();
expect
(
wrapper
.
find
(
'
.nav-links
'
).
exists
()).
toBe
(
isVisible
);
expect
(
wrapper
.
find
(
'
.nav-links
'
).
exists
()).
toBe
(
isVisible
);
});
});
});
});
...
@@ -436,7 +436,7 @@ describe('RepoEditor', () => {
...
@@ -436,7 +436,7 @@ describe('RepoEditor', () => {
});
});
changeViewMode
(
FILE_VIEW_MODE_PREVIEW
);
changeViewMode
(
FILE_VIEW_MODE_PREVIEW
);
await
vm
.
$
nextTick
();
await
nextTick
();
});
});
it
(
'
do not show the editor
'
,
()
=>
{
it
(
'
do not show the editor
'
,
()
=>
{
...
@@ -448,7 +448,7 @@ describe('RepoEditor', () => {
...
@@ -448,7 +448,7 @@ describe('RepoEditor', () => {
expect
(
updateDimensionsSpy
).
not
.
toHaveBeenCalled
();
expect
(
updateDimensionsSpy
).
not
.
toHaveBeenCalled
();
changeViewMode
(
FILE_VIEW_MODE_EDITOR
);
changeViewMode
(
FILE_VIEW_MODE_EDITOR
);
await
vm
.
$
nextTick
();
await
nextTick
();
expect
(
updateDimensionsSpy
).
toHaveBeenCalled
();
expect
(
updateDimensionsSpy
).
toHaveBeenCalled
();
});
});
...
@@ -460,7 +460,7 @@ describe('RepoEditor', () => {
...
@@ -460,7 +460,7 @@ describe('RepoEditor', () => {
jest
.
spyOn
(
vm
,
'
shouldHideEditor
'
,
'
get
'
).
mockReturnValue
(
true
);
jest
.
spyOn
(
vm
,
'
shouldHideEditor
'
,
'
get
'
).
mockReturnValue
(
true
);
vm
.
initEditor
();
vm
.
initEditor
();
await
vm
.
$
nextTick
();
await
nextTick
();
};
};
it
(
'
does not fetch file information for temp entries
'
,
async
()
=>
{
it
(
'
does not fetch file information for temp entries
'
,
async
()
=>
{
...
@@ -511,20 +511,20 @@ describe('RepoEditor', () => {
...
@@ -511,20 +511,20 @@ describe('RepoEditor', () => {
const
origFile
=
vm
.
file
;
const
origFile
=
vm
.
file
;
vm
.
file
.
pending
=
true
;
vm
.
file
.
pending
=
true
;
await
vm
.
$
nextTick
();
await
nextTick
();
wrapper
.
setProps
({
wrapper
.
setProps
({
file
:
file
(
'
testing
'
),
file
:
file
(
'
testing
'
),
});
});
vm
.
file
.
content
=
'
foo
'
;
// need to prevent full cycle of initEditor
vm
.
file
.
content
=
'
foo
'
;
// need to prevent full cycle of initEditor
await
vm
.
$
nextTick
();
await
nextTick
();
expect
(
vm
.
removePendingTab
).
toHaveBeenCalledWith
(
origFile
);
expect
(
vm
.
removePendingTab
).
toHaveBeenCalledWith
(
origFile
);
});
});
it
(
'
does not call initEditor if the file did not change
'
,
async
()
=>
{
it
(
'
does not call initEditor if the file did not change
'
,
async
()
=>
{
Vue
.
set
(
vm
,
'
file
'
,
vm
.
file
);
Vue
.
set
(
vm
,
'
file
'
,
vm
.
file
);
await
vm
.
$
nextTick
();
await
nextTick
();
expect
(
vm
.
initEditor
).
not
.
toHaveBeenCalled
();
expect
(
vm
.
initEditor
).
not
.
toHaveBeenCalled
();
});
});
...
@@ -538,7 +538,7 @@ describe('RepoEditor', () => {
...
@@ -538,7 +538,7 @@ describe('RepoEditor', () => {
key
:
'
new
'
,
key
:
'
new
'
,
},
},
});
});
await
vm
.
$
nextTick
();
await
nextTick
();
expect
(
vm
.
initEditor
).
toHaveBeenCalled
();
expect
(
vm
.
initEditor
).
toHaveBeenCalled
();
});
});
...
...
spec/frontend/ide/components/shared/tokened_input_spec.js
View file @
b8618652
import
Vue
from
'
vue
'
;
import
Vue
,
{
nextTick
}
from
'
vue
'
;
import
mountComponent
from
'
helpers/vue_mount_component_helper
'
;
import
mountComponent
from
'
helpers/vue_mount_component_helper
'
;
import
TokenedInput
from
'
~/ide/components/shared/tokened_input.vue
'
;
import
TokenedInput
from
'
~/ide/components/shared/tokened_input.vue
'
;
...
@@ -54,15 +54,11 @@ describe('IDE shared/TokenedInput', () => {
...
@@ -54,15 +54,11 @@ describe('IDE shared/TokenedInput', () => {
expect
(
vm
.
$refs
.
input
).
toHaveValue
(
TEST_VALUE
);
expect
(
vm
.
$refs
.
input
).
toHaveValue
(
TEST_VALUE
);
});
});
it
(
'
renders placeholder, when tokens are empty
'
,
(
done
)
=>
{
it
(
'
renders placeholder, when tokens are empty
'
,
async
(
)
=>
{
vm
.
tokens
=
[];
vm
.
tokens
=
[];
vm
.
$nextTick
()
await
nextTick
();
.
then
(()
=>
{
expect
(
vm
.
$refs
.
input
).
toHaveAttr
(
'
placeholder
'
,
TEST_PLACEHOLDER
);
expect
(
vm
.
$refs
.
input
).
toHaveAttr
(
'
placeholder
'
,
TEST_PLACEHOLDER
);
})
.
then
(
done
)
.
catch
(
done
.
fail
);
});
});
it
(
'
triggers "removeToken" on token click
'
,
()
=>
{
it
(
'
triggers "removeToken" on token click
'
,
()
=>
{
...
...
spec/frontend/issues/show/components/description_spec.js
View file @
b8618652
import
$
from
'
jquery
'
;
import
$
from
'
jquery
'
;
import
Vue
from
'
vue
'
;
import
Vue
,
{
nextTick
}
from
'
vue
'
;
import
'
~/behaviors/markdown/render_gfm
'
;
import
'
~/behaviors/markdown/render_gfm
'
;
import
{
TEST_HOST
}
from
'
helpers/test_constants
'
;
import
{
TEST_HOST
}
from
'
helpers/test_constants
'
;
import
mountComponent
from
'
helpers/vue_mount_component_helper
'
;
import
mountComponent
from
'
helpers/vue_mount_component_helper
'
;
...
@@ -36,52 +36,38 @@ describe('Description component', () => {
...
@@ -36,52 +36,38 @@ describe('Description component', () => {
$
(
'
.issuable-meta .flash-container
'
).
remove
();
$
(
'
.issuable-meta .flash-container
'
).
remove
();
});
});
it
(
'
doesnt animate first description changes
'
,
()
=>
{
it
(
'
doesnt animate first description changes
'
,
async
()
=>
{
vm
.
descriptionHtml
=
'
changed
'
;
vm
.
descriptionHtml
=
'
changed
'
;
return
vm
.
$nextTick
().
then
(()
=>
{
await
nextTick
();
expect
(
expect
(
vm
.
$el
.
querySelector
(
'
.md
'
).
classList
.
contains
(
'
issue-realtime-pre-pulse
'
)).
toBeFalsy
();
vm
.
$el
.
querySelector
(
'
.md
'
).
classList
.
contains
(
'
issue-realtime-pre-pulse
'
),
).
toBeFalsy
();
jest
.
runAllTimers
();
jest
.
runAllTimers
();
return
vm
.
$nextTick
();
});
});
});
it
(
'
animates description changes on live update
'
,
()
=>
{
it
(
'
animates description changes on live update
'
,
async
()
=>
{
vm
.
descriptionHtml
=
'
changed
'
;
vm
.
descriptionHtml
=
'
changed
'
;
return
vm
await
nextTick
();
.
$nextTick
()
.
then
(()
=>
{
vm
.
descriptionHtml
=
'
changed second time
'
;
vm
.
descriptionHtml
=
'
changed second time
'
;
return
vm
.
$nextTick
();
await
nextTick
();
})
expect
(
vm
.
$el
.
querySelector
(
'
.md
'
).
classList
.
contains
(
'
issue-realtime-pre-pulse
'
)).
toBeTruthy
();
.
then
(()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.md
'
).
classList
.
contains
(
'
issue-realtime-pre-pulse
'
),
).
toBeTruthy
();
jest
.
runAllTimers
();
jest
.
runAllTimers
();
return
vm
.
$nextTick
();
await
nextTick
();
})
.
then
(()
=>
{
expect
(
expect
(
vm
.
$el
.
querySelector
(
'
.md
'
).
classList
.
contains
(
'
issue-realtime-trigger-pulse
'
),
vm
.
$el
.
querySelector
(
'
.md
'
).
classList
.
contains
(
'
issue-realtime-trigger-pulse
'
),
).
toBeTruthy
();
).
toBeTruthy
();
});
});
});
it
(
'
applies syntax highlighting and math when description changed
'
,
()
=>
{
it
(
'
applies syntax highlighting and math when description changed
'
,
async
()
=>
{
const
vmSpy
=
jest
.
spyOn
(
vm
,
'
renderGFM
'
);
const
vmSpy
=
jest
.
spyOn
(
vm
,
'
renderGFM
'
);
const
prototypeSpy
=
jest
.
spyOn
(
$
.
prototype
,
'
renderGFM
'
);
const
prototypeSpy
=
jest
.
spyOn
(
$
.
prototype
,
'
renderGFM
'
);
vm
.
descriptionHtml
=
'
changed
'
;
vm
.
descriptionHtml
=
'
changed
'
;
return
vm
.
$nextTick
().
then
(()
=>
{
await
nextTick
();
expect
(
vm
.
$refs
[
'
gfm-content
'
]).
toBeDefined
();
expect
(
vm
.
$refs
[
'
gfm-content
'
]).
toBeDefined
();
expect
(
vmSpy
).
toHaveBeenCalled
();
expect
(
vmSpy
).
toHaveBeenCalled
();
expect
(
prototypeSpy
).
toHaveBeenCalled
();
expect
(
prototypeSpy
).
toHaveBeenCalled
();
expect
(
$
.
prototype
.
renderGFM
).
toHaveBeenCalled
();
expect
(
$
.
prototype
.
renderGFM
).
toHaveBeenCalled
();
});
});
});
it
(
'
sets data-update-url
'
,
()
=>
{
it
(
'
sets data-update-url
'
,
()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
textarea
'
).
dataset
.
updateUrl
).
toEqual
(
TEST_HOST
);
expect
(
vm
.
$el
.
querySelector
(
'
textarea
'
).
dataset
.
updateUrl
).
toEqual
(
TEST_HOST
);
...
@@ -123,34 +109,31 @@ describe('Description component', () => {
...
@@ -123,34 +109,31 @@ describe('Description component', () => {
});
});
describe
(
'
taskStatus
'
,
()
=>
{
describe
(
'
taskStatus
'
,
()
=>
{
it
(
'
adds full taskStatus
'
,
()
=>
{
it
(
'
adds full taskStatus
'
,
async
()
=>
{
vm
.
taskStatus
=
'
1 of 1
'
;
vm
.
taskStatus
=
'
1 of 1
'
;
return
vm
.
$nextTick
().
then
(()
=>
{
await
nextTick
();
expect
(
document
.
querySelector
(
'
.issuable-meta #task_status
'
).
textContent
.
trim
()).
toBe
(
expect
(
document
.
querySelector
(
'
.issuable-meta #task_status
'
).
textContent
.
trim
()).
toBe
(
'
1 of 1
'
,
'
1 of 1
'
,
);
);
});
});
});
it
(
'
adds short taskStatus
'
,
()
=>
{
it
(
'
adds short taskStatus
'
,
async
()
=>
{
vm
.
taskStatus
=
'
1 of 1
'
;
vm
.
taskStatus
=
'
1 of 1
'
;
return
vm
.
$nextTick
().
then
(()
=>
{
await
nextTick
();
expect
(
document
.
querySelector
(
'
.issuable-meta #task_status_short
'
).
textContent
.
trim
()).
toBe
(
expect
(
document
.
querySelector
(
'
.issuable-meta #task_status_short
'
).
textContent
.
trim
()).
toBe
(
'
1/1 task
'
,
'
1/1 task
'
,
);
);
});
});
});
it
(
'
clears task status text when no tasks are present
'
,
()
=>
{
it
(
'
clears task status text when no tasks are present
'
,
async
()
=>
{
vm
.
taskStatus
=
'
0 of 0
'
;
vm
.
taskStatus
=
'
0 of 0
'
;
return
vm
.
$nextTick
().
then
(()
=>
{
await
nextTick
();
expect
(
document
.
querySelector
(
'
.issuable-meta #task_status
'
).
textContent
.
trim
()).
toBe
(
''
);
expect
(
document
.
querySelector
(
'
.issuable-meta #task_status
'
).
textContent
.
trim
()).
toBe
(
''
);
});
});
});
});
});
describe
(
'
taskListUpdateStarted
'
,
()
=>
{
describe
(
'
taskListUpdateStarted
'
,
()
=>
{
it
(
'
emits event to parent
'
,
()
=>
{
it
(
'
emits event to parent
'
,
()
=>
{
...
...
spec/frontend/notebook/cells/code_spec.js
View file @
b8618652
import
Vue
from
'
vue
'
;
import
Vue
,
{
nextTick
}
from
'
vue
'
;
import
fixture
from
'
test_fixtures/blob/notebook/basic.json
'
;
import
fixture
from
'
test_fixtures/blob/notebook/basic.json
'
;
import
CodeComponent
from
'
~/notebook/cells/code.vue
'
;
import
CodeComponent
from
'
~/notebook/cells/code.vue
'
;
...
@@ -58,12 +58,12 @@ describe('Code component', () => {
...
@@ -58,12 +58,12 @@ describe('Code component', () => {
describe
(
'
with string for output
'
,
()
=>
{
describe
(
'
with string for output
'
,
()
=>
{
// NBFormat Version 4.1 allows outputs.text to be a string
// NBFormat Version 4.1 allows outputs.text to be a string
beforeEach
(()
=>
{
beforeEach
(
async
()
=>
{
const
cell
=
json
.
cells
[
2
];
const
cell
=
json
.
cells
[
2
];
cell
.
outputs
[
0
].
text
=
cell
.
outputs
[
0
].
text
.
join
(
''
);
cell
.
outputs
[
0
].
text
=
cell
.
outputs
[
0
].
text
.
join
(
''
);
vm
=
setupComponent
(
cell
);
vm
=
setupComponent
(
cell
);
return
vm
.
$
nextTick
();
await
nextTick
();
});
});
it
(
'
does not render output prompt
'
,
()
=>
{
it
(
'
does not render output prompt
'
,
()
=>
{
...
@@ -76,12 +76,12 @@ describe('Code component', () => {
...
@@ -76,12 +76,12 @@ describe('Code component', () => {
});
});
describe
(
'
with string for cell.source
'
,
()
=>
{
describe
(
'
with string for cell.source
'
,
()
=>
{
beforeEach
(()
=>
{
beforeEach
(
async
()
=>
{
const
cell
=
json
.
cells
[
0
];
const
cell
=
json
.
cells
[
0
];
cell
.
source
=
cell
.
source
.
join
(
''
);
cell
.
source
=
cell
.
source
.
join
(
''
);
vm
=
setupComponent
(
cell
);
vm
=
setupComponent
(
cell
);
return
vm
.
$
nextTick
();
await
nextTick
();
});
});
it
(
'
renders the same input as when cell.source is an array
'
,
()
=>
{
it
(
'
renders the same input as when cell.source is an array
'
,
()
=>
{
...
...
spec/frontend/notebook/cells/markdown_spec.js
View file @
b8618652
import
{
mount
}
from
'
@vue/test-utils
'
;
import
{
mount
}
from
'
@vue/test-utils
'
;
import
katex
from
'
katex
'
;
import
katex
from
'
katex
'
;
import
Vue
from
'
vue
'
;
import
Vue
,
{
nextTick
}
from
'
vue
'
;
import
markdownTableJson
from
'
test_fixtures/blob/notebook/markdown-table.json
'
;
import
markdownTableJson
from
'
test_fixtures/blob/notebook/markdown-table.json
'
;
import
basicJson
from
'
test_fixtures/blob/notebook/basic.json
'
;
import
basicJson
from
'
test_fixtures/blob/notebook/basic.json
'
;
import
mathJson
from
'
test_fixtures/blob/notebook/math.json
'
;
import
mathJson
from
'
test_fixtures/blob/notebook/math.json
'
;
...
@@ -37,7 +37,7 @@ describe('Markdown component', () => {
...
@@ -37,7 +37,7 @@ describe('Markdown component', () => {
let
cell
;
let
cell
;
let
json
;
let
json
;
beforeEach
(()
=>
{
beforeEach
(
async
()
=>
{
json
=
basicJson
;
json
=
basicJson
;
// eslint-disable-next-line prefer-destructuring
// eslint-disable-next-line prefer-destructuring
...
@@ -45,7 +45,7 @@ describe('Markdown component', () => {
...
@@ -45,7 +45,7 @@ describe('Markdown component', () => {
vm
=
buildCellComponent
(
cell
);
vm
=
buildCellComponent
(
cell
);
return
vm
.
$
nextTick
();
await
nextTick
();
});
});
it
(
'
does not render prompt
'
,
()
=>
{
it
(
'
does not render prompt
'
,
()
=>
{
...
@@ -67,7 +67,7 @@ describe('Markdown component', () => {
...
@@ -67,7 +67,7 @@ describe('Markdown component', () => {
],
],
});
});
await
vm
.
$
nextTick
();
await
nextTick
();
expect
(
vm
.
$el
.
querySelector
(
'
a
'
).
getAttribute
(
'
href
'
)).
toBeNull
();
expect
(
vm
.
$el
.
querySelector
(
'
a
'
).
getAttribute
(
'
href
'
)).
toBeNull
();
});
});
...
@@ -77,7 +77,7 @@ describe('Markdown component', () => {
...
@@ -77,7 +77,7 @@ describe('Markdown component', () => {
source
:
[
'
<a href="test.js" data-remote=true data-type="script" class="xss-link">XSS</a>
\n
'
],
source
:
[
'
<a href="test.js" data-remote=true data-type="script" class="xss-link">XSS</a>
\n
'
],
});
});
await
vm
.
$
nextTick
();
await
nextTick
();
expect
(
findLink
().
getAttribute
(
'
data-remote
'
)).
toBe
(
null
);
expect
(
findLink
().
getAttribute
(
'
data-remote
'
)).
toBe
(
null
);
expect
(
findLink
().
getAttribute
(
'
data-type
'
)).
toBe
(
null
);
expect
(
findLink
().
getAttribute
(
'
data-type
'
)).
toBe
(
null
);
});
});
...
@@ -99,7 +99,7 @@ describe('Markdown component', () => {
...
@@ -99,7 +99,7 @@ describe('Markdown component', () => {
])(
'
%s
'
,
async
([
testMd
,
mustContain
])
=>
{
])(
'
%s
'
,
async
([
testMd
,
mustContain
])
=>
{
vm
=
buildMarkdownComponent
([
testMd
],
'
/raw/
'
);
vm
=
buildMarkdownComponent
([
testMd
],
'
/raw/
'
);
await
vm
.
$
nextTick
();
await
nextTick
();
expect
(
vm
.
$el
.
innerHTML
).
toContain
(
mustContain
);
expect
(
vm
.
$el
.
innerHTML
).
toContain
(
mustContain
);
});
});
...
@@ -110,10 +110,10 @@ describe('Markdown component', () => {
...
@@ -110,10 +110,10 @@ describe('Markdown component', () => {
json
=
markdownTableJson
;
json
=
markdownTableJson
;
});
});
it
(
'
renders images and text
'
,
()
=>
{
it
(
'
renders images and text
'
,
async
()
=>
{
vm
=
buildCellComponent
(
json
.
cells
[
0
]);
vm
=
buildCellComponent
(
json
.
cells
[
0
]);
return
vm
.
$nextTick
().
then
(()
=>
{
await
nextTick
();
const
images
=
vm
.
$el
.
querySelectorAll
(
'
img
'
);
const
images
=
vm
.
$el
.
querySelectorAll
(
'
img
'
);
expect
(
images
.
length
).
toBe
(
5
);
expect
(
images
.
length
).
toBe
(
5
);
...
@@ -134,7 +134,6 @@ describe('Markdown component', () => {
...
@@ -134,7 +134,6 @@ describe('Markdown component', () => {
expect
(
columns
[
4
].
innerHTML
).
toContain
(
'
<img src="https://www.google.com/
'
);
expect
(
columns
[
4
].
innerHTML
).
toContain
(
'
<img src="https://www.google.com/
'
);
});
});
});
});
});
describe
(
'
katex
'
,
()
=>
{
describe
(
'
katex
'
,
()
=>
{
beforeEach
(()
=>
{
beforeEach
(()
=>
{
...
@@ -144,28 +143,28 @@ describe('Markdown component', () => {
...
@@ -144,28 +143,28 @@ describe('Markdown component', () => {
it
(
'
renders multi-line katex
'
,
async
()
=>
{
it
(
'
renders multi-line katex
'
,
async
()
=>
{
vm
=
buildCellComponent
(
json
.
cells
[
0
]);
vm
=
buildCellComponent
(
json
.
cells
[
0
]);
await
vm
.
$
nextTick
();
await
nextTick
();
expect
(
vm
.
$el
.
querySelector
(
'
.katex
'
)).
not
.
toBeNull
();
expect
(
vm
.
$el
.
querySelector
(
'
.katex
'
)).
not
.
toBeNull
();
});
});
it
(
'
renders inline katex
'
,
async
()
=>
{
it
(
'
renders inline katex
'
,
async
()
=>
{
vm
=
buildCellComponent
(
json
.
cells
[
1
]);
vm
=
buildCellComponent
(
json
.
cells
[
1
]);
await
vm
.
$
nextTick
();
await
nextTick
();
expect
(
vm
.
$el
.
querySelector
(
'
p:first-child .katex
'
)).
not
.
toBeNull
();
expect
(
vm
.
$el
.
querySelector
(
'
p:first-child .katex
'
)).
not
.
toBeNull
();
});
});
it
(
'
renders multiple inline katex
'
,
async
()
=>
{
it
(
'
renders multiple inline katex
'
,
async
()
=>
{
vm
=
buildCellComponent
(
json
.
cells
[
1
]);
vm
=
buildCellComponent
(
json
.
cells
[
1
]);
await
vm
.
$
nextTick
();
await
nextTick
();
expect
(
vm
.
$el
.
querySelectorAll
(
'
p:nth-child(2) .katex
'
)).
toHaveLength
(
4
);
expect
(
vm
.
$el
.
querySelectorAll
(
'
p:nth-child(2) .katex
'
)).
toHaveLength
(
4
);
});
});
it
(
'
output cell in case of katex error
'
,
async
()
=>
{
it
(
'
output cell in case of katex error
'
,
async
()
=>
{
vm
=
buildMarkdownComponent
([
'
Some invalid $a & b$ inline formula $b & c$
\n
'
,
'
\n
'
]);
vm
=
buildMarkdownComponent
([
'
Some invalid $a & b$ inline formula $b & c$
\n
'
,
'
\n
'
]);
await
vm
.
$
nextTick
();
await
nextTick
();
// expect one paragraph with no katex formula in it
// expect one paragraph with no katex formula in it
expect
(
vm
.
$el
.
querySelectorAll
(
'
p
'
)).
toHaveLength
(
1
);
expect
(
vm
.
$el
.
querySelectorAll
(
'
p
'
)).
toHaveLength
(
1
);
expect
(
vm
.
$el
.
querySelectorAll
(
'
p .katex
'
)).
toHaveLength
(
0
);
expect
(
vm
.
$el
.
querySelectorAll
(
'
p .katex
'
)).
toHaveLength
(
0
);
...
@@ -177,7 +176,7 @@ describe('Markdown component', () => {
...
@@ -177,7 +176,7 @@ describe('Markdown component', () => {
'
\n
'
,
'
\n
'
,
]);
]);
await
vm
.
$
nextTick
();
await
nextTick
();
// expect one paragraph with no katex formula in it
// expect one paragraph with no katex formula in it
expect
(
vm
.
$el
.
querySelectorAll
(
'
p
'
)).
toHaveLength
(
1
);
expect
(
vm
.
$el
.
querySelectorAll
(
'
p
'
)).
toHaveLength
(
1
);
expect
(
vm
.
$el
.
querySelectorAll
(
'
p .katex
'
)).
toHaveLength
(
1
);
expect
(
vm
.
$el
.
querySelectorAll
(
'
p .katex
'
)).
toHaveLength
(
1
);
...
@@ -186,7 +185,7 @@ describe('Markdown component', () => {
...
@@ -186,7 +185,7 @@ describe('Markdown component', () => {
it
(
'
renders math formula in list object
'
,
async
()
=>
{
it
(
'
renders math formula in list object
'
,
async
()
=>
{
vm
=
buildMarkdownComponent
([
"
- list with inline $a=2$ inline formula $a' + b = c$
\n
"
,
'
\n
'
]);
vm
=
buildMarkdownComponent
([
"
- list with inline $a=2$ inline formula $a' + b = c$
\n
"
,
'
\n
'
]);
await
vm
.
$
nextTick
();
await
nextTick
();
// expect one list with a katex formula in it
// expect one list with a katex formula in it
expect
(
vm
.
$el
.
querySelectorAll
(
'
li
'
)).
toHaveLength
(
1
);
expect
(
vm
.
$el
.
querySelectorAll
(
'
li
'
)).
toHaveLength
(
1
);
expect
(
vm
.
$el
.
querySelectorAll
(
'
li .katex
'
)).
toHaveLength
(
2
);
expect
(
vm
.
$el
.
querySelectorAll
(
'
li .katex
'
)).
toHaveLength
(
2
);
...
@@ -195,7 +194,7 @@ describe('Markdown component', () => {
...
@@ -195,7 +194,7 @@ describe('Markdown component', () => {
it
(
"
renders math formula with tick ' in it
"
,
async
()
=>
{
it
(
"
renders math formula with tick ' in it
"
,
async
()
=>
{
vm
=
buildMarkdownComponent
([
"
- list with inline $a=2$ inline formula $a' + b = c$
\n
"
,
'
\n
'
]);
vm
=
buildMarkdownComponent
([
"
- list with inline $a=2$ inline formula $a' + b = c$
\n
"
,
'
\n
'
]);
await
vm
.
$
nextTick
();
await
nextTick
();
// expect one list with a katex formula in it
// expect one list with a katex formula in it
expect
(
vm
.
$el
.
querySelectorAll
(
'
li
'
)).
toHaveLength
(
1
);
expect
(
vm
.
$el
.
querySelectorAll
(
'
li
'
)).
toHaveLength
(
1
);
expect
(
vm
.
$el
.
querySelectorAll
(
'
li .katex
'
)).
toHaveLength
(
2
);
expect
(
vm
.
$el
.
querySelectorAll
(
'
li .katex
'
)).
toHaveLength
(
2
);
...
@@ -204,7 +203,7 @@ describe('Markdown component', () => {
...
@@ -204,7 +203,7 @@ describe('Markdown component', () => {
it
(
'
renders math formula with less-than-operator < in it
'
,
async
()
=>
{
it
(
'
renders math formula with less-than-operator < in it
'
,
async
()
=>
{
vm
=
buildMarkdownComponent
([
'
- list with inline $a=2$ inline formula $a + b < c$
\n
'
,
'
\n
'
]);
vm
=
buildMarkdownComponent
([
'
- list with inline $a=2$ inline formula $a + b < c$
\n
'
,
'
\n
'
]);
await
vm
.
$
nextTick
();
await
nextTick
();
// expect one list with a katex formula in it
// expect one list with a katex formula in it
expect
(
vm
.
$el
.
querySelectorAll
(
'
li
'
)).
toHaveLength
(
1
);
expect
(
vm
.
$el
.
querySelectorAll
(
'
li
'
)).
toHaveLength
(
1
);
expect
(
vm
.
$el
.
querySelectorAll
(
'
li .katex
'
)).
toHaveLength
(
2
);
expect
(
vm
.
$el
.
querySelectorAll
(
'
li .katex
'
)).
toHaveLength
(
2
);
...
@@ -213,7 +212,7 @@ describe('Markdown component', () => {
...
@@ -213,7 +212,7 @@ describe('Markdown component', () => {
it
(
'
renders math formula with greater-than-operator > in it
'
,
async
()
=>
{
it
(
'
renders math formula with greater-than-operator > in it
'
,
async
()
=>
{
vm
=
buildMarkdownComponent
([
'
- list with inline $a=2$ inline formula $a + b > c$
\n
'
,
'
\n
'
]);
vm
=
buildMarkdownComponent
([
'
- list with inline $a=2$ inline formula $a + b > c$
\n
'
,
'
\n
'
]);
await
vm
.
$
nextTick
();
await
nextTick
();
// expect one list with a katex formula in it
// expect one list with a katex formula in it
expect
(
vm
.
$el
.
querySelectorAll
(
'
li
'
)).
toHaveLength
(
1
);
expect
(
vm
.
$el
.
querySelectorAll
(
'
li
'
)).
toHaveLength
(
1
);
expect
(
vm
.
$el
.
querySelectorAll
(
'
li .katex
'
)).
toHaveLength
(
2
);
expect
(
vm
.
$el
.
querySelectorAll
(
'
li .katex
'
)).
toHaveLength
(
2
);
...
...
spec/frontend/popovers/index_spec.js
View file @
b8618652
import
{
nextTick
}
from
'
vue
'
;
import
{
initPopovers
,
dispose
,
destroy
}
from
'
~/popovers
'
;
import
{
initPopovers
,
dispose
,
destroy
}
from
'
~/popovers
'
;
describe
(
'
popovers/index.js
'
,
()
=>
{
describe
(
'
popovers/index.js
'
,
()
=>
{
let
popoversApp
;
const
createPopoverTarget
=
(
trigger
=
'
hover
'
)
=>
{
const
createPopoverTarget
=
(
trigger
=
'
hover
'
)
=>
{
const
target
=
document
.
createElement
(
'
button
'
);
const
target
=
document
.
createElement
(
'
button
'
);
const
dataset
=
{
const
dataset
=
{
...
@@ -22,7 +21,7 @@ describe('popovers/index.js', () => {
...
@@ -22,7 +21,7 @@ describe('popovers/index.js', () => {
};
};
const
buildPopoversApp
=
()
=>
{
const
buildPopoversApp
=
()
=>
{
popoversApp
=
initPopovers
(
'
[data-toggle="popover"]
'
);
initPopovers
(
'
[data-toggle="popover"]
'
);
};
};
const
triggerEvent
=
(
target
,
eventName
=
'
mouseenter
'
)
=>
{
const
triggerEvent
=
(
target
,
eventName
=
'
mouseenter
'
)
=>
{
...
@@ -44,7 +43,7 @@ describe('popovers/index.js', () => {
...
@@ -44,7 +43,7 @@ describe('popovers/index.js', () => {
triggerEvent
(
target
);
triggerEvent
(
target
);
await
popoversApp
.
$
nextTick
();
await
nextTick
();
const
html
=
document
.
querySelector
(
'
.gl-popover
'
).
innerHTML
;
const
html
=
document
.
querySelector
(
'
.gl-popover
'
).
innerHTML
;
expect
(
document
.
querySelector
(
'
.gl-popover
'
)).
not
.
toBe
(
null
);
expect
(
document
.
querySelector
(
'
.gl-popover
'
)).
not
.
toBe
(
null
);
...
@@ -59,7 +58,7 @@ describe('popovers/index.js', () => {
...
@@ -59,7 +58,7 @@ describe('popovers/index.js', () => {
buildPopoversApp
();
buildPopoversApp
();
triggerEvent
(
target
,
trigger
);
triggerEvent
(
target
,
trigger
);
await
popoversApp
.
$
nextTick
();
await
nextTick
();
expect
(
document
.
querySelector
(
'
.gl-popover
'
)).
not
.
toBe
(
null
);
expect
(
document
.
querySelector
(
'
.gl-popover
'
)).
not
.
toBe
(
null
);
expect
(
document
.
querySelector
(
'
.gl-popover
'
).
innerHTML
).
toContain
(
'
default title
'
);
expect
(
document
.
querySelector
(
'
.gl-popover
'
).
innerHTML
).
toContain
(
'
default title
'
);
...
@@ -73,7 +72,7 @@ describe('popovers/index.js', () => {
...
@@ -73,7 +72,7 @@ describe('popovers/index.js', () => {
const
trigger
=
'
click
'
;
const
trigger
=
'
click
'
;
const
target
=
createPopoverTarget
(
trigger
);
const
target
=
createPopoverTarget
(
trigger
);
triggerEvent
(
target
,
trigger
);
triggerEvent
(
target
,
trigger
);
await
popoversApp
.
$
nextTick
();
await
nextTick
();
expect
(
document
.
querySelector
(
'
.gl-popover
'
)).
not
.
toBe
(
null
);
expect
(
document
.
querySelector
(
'
.gl-popover
'
)).
not
.
toBe
(
null
);
});
});
...
@@ -86,17 +85,17 @@ describe('popovers/index.js', () => {
...
@@ -86,17 +85,17 @@ describe('popovers/index.js', () => {
buildPopoversApp
();
buildPopoversApp
();
triggerEvent
(
target
);
triggerEvent
(
target
);
triggerEvent
(
createPopoverTarget
());
triggerEvent
(
createPopoverTarget
());
await
popoversApp
.
$
nextTick
();
await
nextTick
();
expect
(
document
.
querySelectorAll
(
'
.gl-popover
'
)).
toHaveLength
(
2
);
expect
(
document
.
querySelectorAll
(
'
.gl-popover
'
)).
toHaveLength
(
2
);
dispose
([
fakeTarget
]);
dispose
([
fakeTarget
]);
await
popoversApp
.
$
nextTick
();
await
nextTick
();
expect
(
document
.
querySelectorAll
(
'
.gl-popover
'
)).
toHaveLength
(
2
);
expect
(
document
.
querySelectorAll
(
'
.gl-popover
'
)).
toHaveLength
(
2
);
dispose
([
target
]);
dispose
([
target
]);
await
popoversApp
.
$
nextTick
();
await
nextTick
();
expect
(
document
.
querySelectorAll
(
'
.gl-popover
'
)).
toHaveLength
(
1
);
expect
(
document
.
querySelectorAll
(
'
.gl-popover
'
)).
toHaveLength
(
1
);
});
});
...
...
spec/frontend/prometheus_alerts/components/reset_key_spec.js
View file @
b8618652
import
{
GlModal
}
from
'
@gitlab/ui
'
;
import
{
GlModal
}
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
waitForPromises
from
'
helpers/wait_for_promises
'
;
import
waitForPromises
from
'
helpers/wait_for_promises
'
;
import
axios
from
'
~/lib/utils/axios_utils
'
;
import
axios
from
'
~/lib/utils/axios_utils
'
;
import
ResetKey
from
'
~/prometheus_alerts/components/reset_key.vue
'
;
import
ResetKey
from
'
~/prometheus_alerts/components/reset_key.vue
'
;
...
@@ -45,29 +46,24 @@ describe('ResetKey', () => {
...
@@ -45,29 +46,24 @@ describe('ResetKey', () => {
expect
(
vm
.
find
(
'
.js-reset-auth-key
'
).
text
()).
toEqual
(
'
Reset key
'
);
expect
(
vm
.
find
(
'
.js-reset-auth-key
'
).
text
()).
toEqual
(
'
Reset key
'
);
});
});
it
(
'
reset updates key
'
,
()
=>
{
it
(
'
reset updates key
'
,
async
()
=>
{
mock
.
onPost
(
propsData
.
changeKeyUrl
).
replyOnce
(
200
,
{
token
:
'
newToken
'
});
mock
.
onPost
(
propsData
.
changeKeyUrl
).
replyOnce
(
200
,
{
token
:
'
newToken
'
});
vm
.
find
(
GlModal
).
vm
.
$emit
(
'
ok
'
);
vm
.
find
(
GlModal
).
vm
.
$emit
(
'
ok
'
);
return
vm
.
vm
await
nextTick
();
.
$nextTick
()
await
waitForPromises
();
.
then
(
waitForPromises
)
.
then
(()
=>
{
expect
(
vm
.
vm
.
authorizationKey
).
toEqual
(
'
newToken
'
);
expect
(
vm
.
vm
.
authorizationKey
).
toEqual
(
'
newToken
'
);
expect
(
vm
.
find
(
'
#authorization-key
'
).
attributes
(
'
value
'
)).
toEqual
(
'
newToken
'
);
expect
(
vm
.
find
(
'
#authorization-key
'
).
attributes
(
'
value
'
)).
toEqual
(
'
newToken
'
);
});
});
});
it
(
'
reset key failure shows error
'
,
()
=>
{
it
(
'
reset key failure shows error
'
,
async
()
=>
{
mock
.
onPost
(
propsData
.
changeKeyUrl
).
replyOnce
(
500
);
mock
.
onPost
(
propsData
.
changeKeyUrl
).
replyOnce
(
500
);
vm
.
find
(
GlModal
).
vm
.
$emit
(
'
ok
'
);
vm
.
find
(
GlModal
).
vm
.
$emit
(
'
ok
'
);
return
vm
.
vm
await
nextTick
();
.
$nextTick
()
await
waitForPromises
();
.
then
(
waitForPromises
)
.
then
(()
=>
{
expect
(
vm
.
find
(
'
#authorization-key
'
).
attributes
(
'
value
'
)).
toEqual
(
expect
(
vm
.
find
(
'
#authorization-key
'
).
attributes
(
'
value
'
)).
toEqual
(
propsData
.
initialAuthorizationKey
,
propsData
.
initialAuthorizationKey
,
);
);
...
@@ -77,7 +73,6 @@ describe('ResetKey', () => {
...
@@ -77,7 +73,6 @@ describe('ResetKey', () => {
);
);
});
});
});
});
});
describe
(
'
authorization key has not been set
'
,
()
=>
{
describe
(
'
authorization key has not been set
'
,
()
=>
{
beforeEach
(()
=>
{
beforeEach
(()
=>
{
...
@@ -92,14 +87,13 @@ describe('ResetKey', () => {
...
@@ -92,14 +87,13 @@ describe('ResetKey', () => {
expect
(
vm
.
find
(
'
#authorization-key
'
).
attributes
(
'
value
'
)).
toEqual
(
''
);
expect
(
vm
.
find
(
'
#authorization-key
'
).
attributes
(
'
value
'
)).
toEqual
(
''
);
});
});
it
(
'
Generate key button triggers key change
'
,
()
=>
{
it
(
'
Generate key button triggers key change
'
,
async
()
=>
{
mock
.
onPost
(
propsData
.
changeKeyUrl
).
replyOnce
(
200
,
{
token
:
'
newToken
'
});
mock
.
onPost
(
propsData
.
changeKeyUrl
).
replyOnce
(
200
,
{
token
:
'
newToken
'
});
vm
.
find
(
'
.js-reset-auth-key
'
).
vm
.
$emit
(
'
click
'
);
vm
.
find
(
'
.js-reset-auth-key
'
).
vm
.
$emit
(
'
click
'
);
return
waitForPromises
().
then
(()
=>
{
await
waitForPromises
();
expect
(
vm
.
find
(
'
#authorization-key
'
).
attributes
(
'
value
'
)).
toEqual
(
'
newToken
'
);
expect
(
vm
.
find
(
'
#authorization-key
'
).
attributes
(
'
value
'
)).
toEqual
(
'
newToken
'
);
});
});
});
});
});
});
});
spec/frontend/repository/components/last_commit_spec.js
View file @
b8618652
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
LastCommit
from
'
~/repository/components/last_commit.vue
'
;
import
LastCommit
from
'
~/repository/components/last_commit.vue
'
;
import
UserAvatarLink
from
'
~/vue_shared/components/user_avatar/user_avatar_link.vue
'
;
import
UserAvatarLink
from
'
~/vue_shared/components/user_avatar/user_avatar_link.vue
'
;
...
@@ -63,7 +64,7 @@ describe('Repository last commit component', () => {
...
@@ -63,7 +64,7 @@ describe('Repository last commit component', () => {
`
(
'
$label when loading icon $loading is true
'
,
async
({
loading
})
=>
{
`
(
'
$label when loading icon $loading is true
'
,
async
({
loading
})
=>
{
factory
(
createCommitData
(),
loading
);
factory
(
createCommitData
(),
loading
);
await
vm
.
vm
.
$
nextTick
();
await
nextTick
();
expect
(
vm
.
find
(
GlLoadingIcon
).
exists
()).
toBe
(
loading
);
expect
(
vm
.
find
(
GlLoadingIcon
).
exists
()).
toBe
(
loading
);
});
});
...
@@ -71,7 +72,7 @@ describe('Repository last commit component', () => {
...
@@ -71,7 +72,7 @@ describe('Repository last commit component', () => {
it
(
'
renders commit widget
'
,
async
()
=>
{
it
(
'
renders commit widget
'
,
async
()
=>
{
factory
();
factory
();
await
vm
.
vm
.
$
nextTick
();
await
nextTick
();
expect
(
vm
.
element
).
toMatchSnapshot
();
expect
(
vm
.
element
).
toMatchSnapshot
();
});
});
...
@@ -79,7 +80,7 @@ describe('Repository last commit component', () => {
...
@@ -79,7 +80,7 @@ describe('Repository last commit component', () => {
it
(
'
renders short commit ID
'
,
async
()
=>
{
it
(
'
renders short commit ID
'
,
async
()
=>
{
factory
();
factory
();
await
vm
.
vm
.
$
nextTick
();
await
nextTick
();
expect
(
vm
.
find
(
'
[data-testid="last-commit-id-label"]
'
).
text
()).
toEqual
(
'
12345678
'
);
expect
(
vm
.
find
(
'
[data-testid="last-commit-id-label"]
'
).
text
()).
toEqual
(
'
12345678
'
);
});
});
...
@@ -87,7 +88,7 @@ describe('Repository last commit component', () => {
...
@@ -87,7 +88,7 @@ describe('Repository last commit component', () => {
it
(
'
hides pipeline components when pipeline does not exist
'
,
async
()
=>
{
it
(
'
hides pipeline components when pipeline does not exist
'
,
async
()
=>
{
factory
(
createCommitData
({
pipeline
:
null
}));
factory
(
createCommitData
({
pipeline
:
null
}));
await
vm
.
vm
.
$
nextTick
();
await
nextTick
();
expect
(
vm
.
find
(
'
.js-commit-pipeline
'
).
exists
()).
toBe
(
false
);
expect
(
vm
.
find
(
'
.js-commit-pipeline
'
).
exists
()).
toBe
(
false
);
});
});
...
@@ -95,7 +96,7 @@ describe('Repository last commit component', () => {
...
@@ -95,7 +96,7 @@ describe('Repository last commit component', () => {
it
(
'
renders pipeline components
'
,
async
()
=>
{
it
(
'
renders pipeline components
'
,
async
()
=>
{
factory
();
factory
();
await
vm
.
vm
.
$
nextTick
();
await
nextTick
();
expect
(
vm
.
find
(
'
.js-commit-pipeline
'
).
exists
()).
toBe
(
true
);
expect
(
vm
.
find
(
'
.js-commit-pipeline
'
).
exists
()).
toBe
(
true
);
});
});
...
@@ -103,7 +104,7 @@ describe('Repository last commit component', () => {
...
@@ -103,7 +104,7 @@ describe('Repository last commit component', () => {
it
(
'
hides author component when author does not exist
'
,
async
()
=>
{
it
(
'
hides author component when author does not exist
'
,
async
()
=>
{
factory
(
createCommitData
({
author
:
null
}));
factory
(
createCommitData
({
author
:
null
}));
await
vm
.
vm
.
$
nextTick
();
await
nextTick
();
expect
(
vm
.
find
(
'
.js-user-link
'
).
exists
()).
toBe
(
false
);
expect
(
vm
.
find
(
'
.js-user-link
'
).
exists
()).
toBe
(
false
);
expect
(
vm
.
find
(
UserAvatarLink
).
exists
()).
toBe
(
false
);
expect
(
vm
.
find
(
UserAvatarLink
).
exists
()).
toBe
(
false
);
...
@@ -112,7 +113,7 @@ describe('Repository last commit component', () => {
...
@@ -112,7 +113,7 @@ describe('Repository last commit component', () => {
it
(
'
does not render description expander when description is null
'
,
async
()
=>
{
it
(
'
does not render description expander when description is null
'
,
async
()
=>
{
factory
(
createCommitData
({
descriptionHtml
:
null
}));
factory
(
createCommitData
({
descriptionHtml
:
null
}));
await
vm
.
vm
.
$
nextTick
();
await
nextTick
();
expect
(
vm
.
find
(
'
.text-expander
'
).
exists
()).
toBe
(
false
);
expect
(
vm
.
find
(
'
.text-expander
'
).
exists
()).
toBe
(
false
);
expect
(
vm
.
find
(
'
.commit-row-description
'
).
exists
()).
toBe
(
false
);
expect
(
vm
.
find
(
'
.commit-row-description
'
).
exists
()).
toBe
(
false
);
...
@@ -121,11 +122,11 @@ describe('Repository last commit component', () => {
...
@@ -121,11 +122,11 @@ describe('Repository last commit component', () => {
it
(
'
expands commit description when clicking expander
'
,
async
()
=>
{
it
(
'
expands commit description when clicking expander
'
,
async
()
=>
{
factory
(
createCommitData
({
descriptionHtml
:
'
Test description
'
}));
factory
(
createCommitData
({
descriptionHtml
:
'
Test description
'
}));
await
vm
.
vm
.
$
nextTick
();
await
nextTick
();
vm
.
find
(
'
.text-expander
'
).
vm
.
$emit
(
'
click
'
);
vm
.
find
(
'
.text-expander
'
).
vm
.
$emit
(
'
click
'
);
await
vm
.
vm
.
$
nextTick
();
await
nextTick
();
expect
(
vm
.
find
(
'
.commit-row-description
'
).
isVisible
()).
toBe
(
true
);
expect
(
vm
.
find
(
'
.commit-row-description
'
).
isVisible
()).
toBe
(
true
);
expect
(
vm
.
find
(
'
.text-expander
'
).
classes
(
'
open
'
)).
toBe
(
true
);
expect
(
vm
.
find
(
'
.text-expander
'
).
classes
(
'
open
'
)).
toBe
(
true
);
...
@@ -134,7 +135,7 @@ describe('Repository last commit component', () => {
...
@@ -134,7 +135,7 @@ describe('Repository last commit component', () => {
it
(
'
strips the first newline of the description
'
,
async
()
=>
{
it
(
'
strips the first newline of the description
'
,
async
()
=>
{
factory
(
createCommitData
({
descriptionHtml
:
'

Update ADOPTERS.md
'
}));
factory
(
createCommitData
({
descriptionHtml
:
'

Update ADOPTERS.md
'
}));
await
vm
.
vm
.
$
nextTick
();
await
nextTick
();
expect
(
vm
.
find
(
'
.commit-row-description
'
).
html
()).
toBe
(
expect
(
vm
.
find
(
'
.commit-row-description
'
).
html
()).
toBe
(
'
<pre class="commit-row-description gl-mb-3">Update ADOPTERS.md</pre>
'
,
'
<pre class="commit-row-description gl-mb-3">Update ADOPTERS.md</pre>
'
,
...
@@ -144,7 +145,7 @@ describe('Repository last commit component', () => {
...
@@ -144,7 +145,7 @@ describe('Repository last commit component', () => {
it
(
'
renders the signature HTML as returned by the backend
'
,
async
()
=>
{
it
(
'
renders the signature HTML as returned by the backend
'
,
async
()
=>
{
factory
(
createCommitData
({
signatureHtml
:
'
<button>Verified</button>
'
}));
factory
(
createCommitData
({
signatureHtml
:
'
<button>Verified</button>
'
}));
await
vm
.
vm
.
$
nextTick
();
await
nextTick
();
expect
(
vm
.
element
).
toMatchSnapshot
();
expect
(
vm
.
element
).
toMatchSnapshot
();
});
});
...
@@ -152,7 +153,7 @@ describe('Repository last commit component', () => {
...
@@ -152,7 +153,7 @@ describe('Repository last commit component', () => {
it
(
'
sets correct CSS class if the commit message is empty
'
,
async
()
=>
{
it
(
'
sets correct CSS class if the commit message is empty
'
,
async
()
=>
{
factory
(
createCommitData
({
message
:
''
}));
factory
(
createCommitData
({
message
:
''
}));
await
vm
.
vm
.
$
nextTick
();
await
nextTick
();
expect
(
vm
.
find
(
'
.item-title
'
).
classes
()).
toContain
(
emptyMessageClass
);
expect
(
vm
.
find
(
'
.item-title
'
).
classes
()).
toContain
(
emptyMessageClass
);
});
});
...
...
spec/frontend/repository/components/preview/index_spec.js
View file @
b8618652
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
{
handleLocationHash
}
from
'
~/lib/utils/common_utils
'
;
import
{
handleLocationHash
}
from
'
~/lib/utils/common_utils
'
;
import
Preview
from
'
~/repository/components/preview/index.vue
'
;
import
Preview
from
'
~/repository/components/preview/index.vue
'
;
...
@@ -28,7 +29,7 @@ describe('Repository file preview component', () => {
...
@@ -28,7 +29,7 @@ describe('Repository file preview component', () => {
vm
.
destroy
();
vm
.
destroy
();
});
});
it
(
'
renders file HTML
'
,
()
=>
{
it
(
'
renders file HTML
'
,
async
()
=>
{
factory
({
factory
({
webPath
:
'
http://test.com
'
,
webPath
:
'
http://test.com
'
,
name
:
'
README.md
'
,
name
:
'
README.md
'
,
...
@@ -38,12 +39,11 @@ describe('Repository file preview component', () => {
...
@@ -38,12 +39,11 @@ describe('Repository file preview component', () => {
// eslint-disable-next-line no-restricted-syntax
// eslint-disable-next-line no-restricted-syntax
vm
.
setData
({
readme
:
{
html
:
'
<div class="blob">test</div>
'
}
});
vm
.
setData
({
readme
:
{
html
:
'
<div class="blob">test</div>
'
}
});
return
vm
.
vm
.
$nextTick
(()
=>
{
await
nextTick
();
expect
(
vm
.
element
).
toMatchSnapshot
();
expect
(
vm
.
element
).
toMatchSnapshot
();
});
});
});
it
(
'
handles hash after render
'
,
()
=>
{
it
(
'
handles hash after render
'
,
async
()
=>
{
factory
({
factory
({
webPath
:
'
http://test.com
'
,
webPath
:
'
http://test.com
'
,
name
:
'
README.md
'
,
name
:
'
README.md
'
,
...
@@ -53,15 +53,11 @@ describe('Repository file preview component', () => {
...
@@ -53,15 +53,11 @@ describe('Repository file preview component', () => {
// eslint-disable-next-line no-restricted-syntax
// eslint-disable-next-line no-restricted-syntax
vm
.
setData
({
readme
:
{
html
:
'
<div class="blob">test</div>
'
}
});
vm
.
setData
({
readme
:
{
html
:
'
<div class="blob">test</div>
'
}
});
return
vm
.
vm
await
nextTick
();
.
$nextTick
()
.
then
(
vm
.
vm
.
$nextTick
())
.
then
(()
=>
{
expect
(
handleLocationHash
).
toHaveBeenCalled
();
expect
(
handleLocationHash
).
toHaveBeenCalled
();
});
});
});
it
(
'
renders loading icon
'
,
()
=>
{
it
(
'
renders loading icon
'
,
async
()
=>
{
factory
({
factory
({
webPath
:
'
http://test.com
'
,
webPath
:
'
http://test.com
'
,
name
:
'
README.md
'
,
name
:
'
README.md
'
,
...
@@ -71,8 +67,7 @@ describe('Repository file preview component', () => {
...
@@ -71,8 +67,7 @@ describe('Repository file preview component', () => {
// eslint-disable-next-line no-restricted-syntax
// eslint-disable-next-line no-restricted-syntax
vm
.
setData
({
loading
:
1
});
vm
.
setData
({
loading
:
1
});
return
vm
.
vm
.
$nextTick
(()
=>
{
await
nextTick
();
expect
(
vm
.
find
(
GlLoadingIcon
).
exists
()).
toBe
(
true
);
expect
(
vm
.
find
(
GlLoadingIcon
).
exists
()).
toBe
(
true
);
});
});
});
});
});
spec/frontend/repository/components/table/index_spec.js
View file @
b8618652
import
{
GlDeprecatedSkeletonLoading
as
GlSkeletonLoading
,
GlButton
}
from
'
@gitlab/ui
'
;
import
{
GlDeprecatedSkeletonLoading
as
GlSkeletonLoading
,
GlButton
}
from
'
@gitlab/ui
'
;
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
nextTick
}
from
'
vue
'
;
import
Table
from
'
~/repository/components/table/index.vue
'
;
import
Table
from
'
~/repository/components/table/index.vue
'
;
import
TableRow
from
'
~/repository/components/table/row.vue
'
;
import
TableRow
from
'
~/repository/components/table/row.vue
'
;
...
@@ -86,19 +87,18 @@ describe('Repository table component', () => {
...
@@ -86,19 +87,18 @@ describe('Repository table component', () => {
${
'
/
'
}
|
${
'
main
'
}
${
'
/
'
}
|
${
'
main
'
}
${
'
app/assets
'
}
|
${
'
main
'
}
${
'
app/assets
'
}
|
${
'
main
'
}
${
'
/
'
}
|
${
'
test
'
}
${
'
/
'
}
|
${
'
test
'
}
`
(
'
renders table caption for $ref in $path
'
,
({
path
,
ref
})
=>
{
`
(
'
renders table caption for $ref in $path
'
,
async
({
path
,
ref
})
=>
{
factory
({
path
});
factory
({
path
});
// 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
vm
.
setData
({
ref
});
vm
.
setData
({
ref
});
return
vm
.
vm
.
$nextTick
(()
=>
{
await
nextTick
();
expect
(
vm
.
find
(
'
.table
'
).
attributes
(
'
aria-label
'
)).
toEqual
(
expect
(
vm
.
find
(
'
.table
'
).
attributes
(
'
aria-label
'
)).
toEqual
(
`Files, directories, and submodules in the path
${
path
}
for commit reference
${
ref
}
`
,
`Files, directories, and submodules in the path
${
path
}
for commit reference
${
ref
}
`
,
);
);
});
});
});
it
(
'
shows loading icon
'
,
()
=>
{
it
(
'
shows loading icon
'
,
()
=>
{
factory
({
path
:
'
/
'
,
isLoading
:
true
});
factory
({
path
:
'
/
'
,
isLoading
:
true
});
...
@@ -140,7 +140,7 @@ describe('Repository table component', () => {
...
@@ -140,7 +140,7 @@ describe('Repository table component', () => {
showMoreButton
().
vm
.
$emit
(
'
click
'
);
showMoreButton
().
vm
.
$emit
(
'
click
'
);
await
vm
.
vm
.
$
nextTick
();
await
nextTick
();
expect
(
vm
.
emitted
(
'
showMore
'
)).
toHaveLength
(
1
);
expect
(
vm
.
emitted
(
'
showMore
'
)).
toHaveLength
(
1
);
});
});
...
...
spec/frontend/repository/components/table/row_spec.js
View file @
b8618652
import
{
GlBadge
,
GlLink
,
GlIcon
,
GlIntersectionObserver
}
from
'
@gitlab/ui
'
;
import
{
GlBadge
,
GlLink
,
GlIcon
,
GlIntersectionObserver
}
from
'
@gitlab/ui
'
;
import
{
shallowMount
,
RouterLinkStub
}
from
'
@vue/test-utils
'
;
import
{
shallowMount
,
RouterLinkStub
}
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
TableRow
from
'
~/repository/components/table/row.vue
'
;
import
TableRow
from
'
~/repository/components/table/row.vue
'
;
import
FileIcon
from
'
~/vue_shared/components/file_icon.vue
'
;
import
FileIcon
from
'
~/vue_shared/components/file_icon.vue
'
;
...
@@ -53,7 +54,7 @@ describe('Repository table row component', () => {
...
@@ -53,7 +54,7 @@ describe('Repository table row component', () => {
vm
.
destroy
();
vm
.
destroy
();
});
});
it
(
'
renders table row
'
,
()
=>
{
it
(
'
renders table row
'
,
async
()
=>
{
factory
({
factory
({
id
:
'
1
'
,
id
:
'
1
'
,
sha
:
'
123
'
,
sha
:
'
123
'
,
...
@@ -62,12 +63,11 @@ describe('Repository table row component', () => {
...
@@ -62,12 +63,11 @@ describe('Repository table row component', () => {
currentPath
:
'
/
'
,
currentPath
:
'
/
'
,
});
});
return
vm
.
vm
.
$nextTick
().
then
(()
=>
{
await
nextTick
();
expect
(
vm
.
element
).
toMatchSnapshot
();
expect
(
vm
.
element
).
toMatchSnapshot
();
});
});
});
it
(
'
renders a symlink table row
'
,
()
=>
{
it
(
'
renders a symlink table row
'
,
async
()
=>
{
factory
({
factory
({
id
:
'
1
'
,
id
:
'
1
'
,
sha
:
'
123
'
,
sha
:
'
123
'
,
...
@@ -77,12 +77,11 @@ describe('Repository table row component', () => {
...
@@ -77,12 +77,11 @@ describe('Repository table row component', () => {
mode
:
FILE_SYMLINK_MODE
,
mode
:
FILE_SYMLINK_MODE
,
});
});
return
vm
.
vm
.
$nextTick
().
then
(()
=>
{
await
nextTick
();
expect
(
vm
.
element
).
toMatchSnapshot
();
expect
(
vm
.
element
).
toMatchSnapshot
();
});
});
});
it
(
'
renders table row for path with special character
'
,
()
=>
{
it
(
'
renders table row for path with special character
'
,
async
()
=>
{
factory
({
factory
({
id
:
'
1
'
,
id
:
'
1
'
,
sha
:
'
123
'
,
sha
:
'
123
'
,
...
@@ -91,10 +90,9 @@ describe('Repository table row component', () => {
...
@@ -91,10 +90,9 @@ describe('Repository table row component', () => {
currentPath
:
'
test$
'
,
currentPath
:
'
test$
'
,
});
});
return
vm
.
vm
.
$nextTick
().
then
(()
=>
{
await
nextTick
();
expect
(
vm
.
element
).
toMatchSnapshot
();
expect
(
vm
.
element
).
toMatchSnapshot
();
});
});
});
it
(
'
renders a gl-hover-load directive
'
,
()
=>
{
it
(
'
renders a gl-hover-load directive
'
,
()
=>
{
factory
({
factory
({
...
@@ -116,7 +114,7 @@ describe('Repository table row component', () => {
...
@@ -116,7 +114,7 @@ describe('Repository table row component', () => {
${
'
tree
'
}
|
${
RouterLinkStub
}
|
${
'
RouterLink
'
}
${
'
tree
'
}
|
${
RouterLinkStub
}
|
${
'
RouterLink
'
}
${
'
blob
'
}
|
${
RouterLinkStub
}
|
${
'
RouterLink
'
}
${
'
blob
'
}
|
${
RouterLinkStub
}
|
${
'
RouterLink
'
}
${
'
commit
'
}
|
${
'
a
'
}
|
${
'
hyperlink
'
}
${
'
commit
'
}
|
${
'
a
'
}
|
${
'
hyperlink
'
}
`
(
'
renders a $componentName for type $type
'
,
({
type
,
component
})
=>
{
`
(
'
renders a $componentName for type $type
'
,
async
({
type
,
component
})
=>
{
factory
({
factory
({
id
:
'
1
'
,
id
:
'
1
'
,
sha
:
'
123
'
,
sha
:
'
123
'
,
...
@@ -125,16 +123,15 @@ describe('Repository table row component', () => {
...
@@ -125,16 +123,15 @@ describe('Repository table row component', () => {
currentPath
:
'
/
'
,
currentPath
:
'
/
'
,
});
});
return
vm
.
vm
.
$nextTick
().
then
(()
=>
{
await
nextTick
();
expect
(
vm
.
find
(
component
).
exists
()).
toBe
(
true
);
expect
(
vm
.
find
(
component
).
exists
()).
toBe
(
true
);
});
});
});
it
.
each
`
it
.
each
`
path
path
${
'
test#
'
}
${
'
test#
'
}
${
'
Änderungen
'
}
${
'
Änderungen
'
}
`
(
'
renders link for $path
'
,
({
path
})
=>
{
`
(
'
renders link for $path
'
,
async
({
path
})
=>
{
factory
({
factory
({
id
:
'
1
'
,
id
:
'
1
'
,
sha
:
'
123
'
,
sha
:
'
123
'
,
...
@@ -143,14 +140,13 @@ describe('Repository table row component', () => {
...
@@ -143,14 +140,13 @@ describe('Repository table row component', () => {
currentPath
:
'
/
'
,
currentPath
:
'
/
'
,
});
});
return
vm
.
vm
.
$nextTick
().
then
(()
=>
{
await
nextTick
();
expect
(
vm
.
find
({
ref
:
'
link
'
}).
props
(
'
to
'
)).
toEqual
({
expect
(
vm
.
find
({
ref
:
'
link
'
}).
props
(
'
to
'
)).
toEqual
({
path
:
`/-/tree/main/
${
encodeURIComponent
(
path
)}
`
,
path
:
`/-/tree/main/
${
encodeURIComponent
(
path
)}
`
,
});
});
});
});
});
it
(
'
renders link for directory with hash
'
,
()
=>
{
it
(
'
renders link for directory with hash
'
,
async
()
=>
{
factory
({
factory
({
id
:
'
1
'
,
id
:
'
1
'
,
sha
:
'
123
'
,
sha
:
'
123
'
,
...
@@ -159,12 +155,11 @@ describe('Repository table row component', () => {
...
@@ -159,12 +155,11 @@ describe('Repository table row component', () => {
currentPath
:
'
/
'
,
currentPath
:
'
/
'
,
});
});
return
vm
.
vm
.
$nextTick
().
then
(()
=>
{
await
nextTick
();
expect
(
vm
.
find
(
'
.tree-item-link
'
).
props
(
'
to
'
)).
toEqual
({
path
:
'
/-/tree/main/test%23
'
});
expect
(
vm
.
find
(
'
.tree-item-link
'
).
props
(
'
to
'
)).
toEqual
({
path
:
'
/-/tree/main/test%23
'
});
});
});
});
it
(
'
renders commit ID for submodule
'
,
()
=>
{
it
(
'
renders commit ID for submodule
'
,
async
()
=>
{
factory
({
factory
({
id
:
'
1
'
,
id
:
'
1
'
,
sha
:
'
123
'
,
sha
:
'
123
'
,
...
@@ -173,12 +168,11 @@ describe('Repository table row component', () => {
...
@@ -173,12 +168,11 @@ describe('Repository table row component', () => {
currentPath
:
'
/
'
,
currentPath
:
'
/
'
,
});
});
return
vm
.
vm
.
$nextTick
().
then
(()
=>
{
await
nextTick
();
expect
(
vm
.
find
(
'
.commit-sha
'
).
text
()).
toContain
(
'
1
'
);
expect
(
vm
.
find
(
'
.commit-sha
'
).
text
()).
toContain
(
'
1
'
);
});
});
});
it
(
'
renders link with href
'
,
()
=>
{
it
(
'
renders link with href
'
,
async
()
=>
{
factory
({
factory
({
id
:
'
1
'
,
id
:
'
1
'
,
sha
:
'
123
'
,
sha
:
'
123
'
,
...
@@ -188,12 +182,11 @@ describe('Repository table row component', () => {
...
@@ -188,12 +182,11 @@ describe('Repository table row component', () => {
currentPath
:
'
/
'
,
currentPath
:
'
/
'
,
});
});
return
vm
.
vm
.
$nextTick
().
then
(()
=>
{
await
nextTick
();
expect
(
vm
.
find
(
'
a
'
).
attributes
(
'
href
'
)).
toEqual
(
'
https://test.com
'
);
expect
(
vm
.
find
(
'
a
'
).
attributes
(
'
href
'
)).
toEqual
(
'
https://test.com
'
);
});
});
});
it
(
'
renders LFS badge
'
,
()
=>
{
it
(
'
renders LFS badge
'
,
async
()
=>
{
factory
({
factory
({
id
:
'
1
'
,
id
:
'
1
'
,
sha
:
'
123
'
,
sha
:
'
123
'
,
...
@@ -203,12 +196,11 @@ describe('Repository table row component', () => {
...
@@ -203,12 +196,11 @@ describe('Repository table row component', () => {
lfsOid
:
'
1
'
,
lfsOid
:
'
1
'
,
});
});
return
vm
.
vm
.
$nextTick
().
then
(()
=>
{
await
nextTick
();
expect
(
vm
.
find
(
GlBadge
).
exists
()).
toBe
(
true
);
expect
(
vm
.
find
(
GlBadge
).
exists
()).
toBe
(
true
);
});
});
});
it
(
'
renders commit and web links with href for submodule
'
,
()
=>
{
it
(
'
renders commit and web links with href for submodule
'
,
async
()
=>
{
factory
({
factory
({
id
:
'
1
'
,
id
:
'
1
'
,
sha
:
'
123
'
,
sha
:
'
123
'
,
...
@@ -219,13 +211,12 @@ describe('Repository table row component', () => {
...
@@ -219,13 +211,12 @@ describe('Repository table row component', () => {
currentPath
:
'
/
'
,
currentPath
:
'
/
'
,
});
});
return
vm
.
vm
.
$nextTick
().
then
(()
=>
{
await
nextTick
();
expect
(
vm
.
find
(
'
a
'
).
attributes
(
'
href
'
)).
toEqual
(
'
https://test.com
'
);
expect
(
vm
.
find
(
'
a
'
).
attributes
(
'
href
'
)).
toEqual
(
'
https://test.com
'
);
expect
(
vm
.
find
(
GlLink
).
attributes
(
'
href
'
)).
toEqual
(
'
https://test.com/commit
'
);
expect
(
vm
.
find
(
GlLink
).
attributes
(
'
href
'
)).
toEqual
(
'
https://test.com/commit
'
);
});
});
});
it
(
'
renders lock icon
'
,
()
=>
{
it
(
'
renders lock icon
'
,
async
()
=>
{
factory
({
factory
({
id
:
'
1
'
,
id
:
'
1
'
,
sha
:
'
123
'
,
sha
:
'
123
'
,
...
@@ -234,11 +225,10 @@ describe('Repository table row component', () => {
...
@@ -234,11 +225,10 @@ describe('Repository table row component', () => {
currentPath
:
'
/
'
,
currentPath
:
'
/
'
,
});
});
return
vm
.
vm
.
$nextTick
().
then
(()
=>
{
await
nextTick
();
expect
(
vm
.
find
(
GlIcon
).
exists
()).
toBe
(
true
);
expect
(
vm
.
find
(
GlIcon
).
exists
()).
toBe
(
true
);
expect
(
vm
.
find
(
GlIcon
).
props
(
'
name
'
)).
toBe
(
'
lock
'
);
expect
(
vm
.
find
(
GlIcon
).
props
(
'
name
'
)).
toBe
(
'
lock
'
);
});
});
});
it
(
'
renders loading icon when path is loading
'
,
()
=>
{
it
(
'
renders loading icon when path is loading
'
,
()
=>
{
factory
({
factory
({
...
...
spec/frontend/repository/components/tree_content_spec.js
View file @
b8618652
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
nextTick
}
from
'
vue
'
;
import
paginatedTreeQuery
from
'
shared_queries/repository/paginated_tree.query.graphql
'
;
import
paginatedTreeQuery
from
'
shared_queries/repository/paginated_tree.query.graphql
'
;
import
FilePreview
from
'
~/repository/components/preview/index.vue
'
;
import
FilePreview
from
'
~/repository/components/preview/index.vue
'
;
import
FileTable
from
'
~/repository/components/table/index.vue
'
;
import
FileTable
from
'
~/repository/components/table/index.vue
'
;
...
@@ -50,7 +51,7 @@ describe('Repository table component', () => {
...
@@ -50,7 +51,7 @@ describe('Repository table component', () => {
// eslint-disable-next-line no-restricted-syntax
// eslint-disable-next-line no-restricted-syntax
vm
.
setData
({
entries
:
{
blobs
:
[{
name
:
'
README.md
'
}]
}
});
vm
.
setData
({
entries
:
{
blobs
:
[{
name
:
'
README.md
'
}]
}
});
await
vm
.
vm
.
$
nextTick
();
await
nextTick
();
expect
(
vm
.
find
(
FilePreview
).
exists
()).
toBe
(
true
);
expect
(
vm
.
find
(
FilePreview
).
exists
()).
toBe
(
true
);
});
});
...
@@ -60,7 +61,7 @@ describe('Repository table component', () => {
...
@@ -60,7 +61,7 @@ describe('Repository table component', () => {
jest
.
spyOn
(
vm
.
vm
,
'
fetchFiles
'
).
mockImplementation
(()
=>
{});
jest
.
spyOn
(
vm
.
vm
,
'
fetchFiles
'
).
mockImplementation
(()
=>
{});
await
vm
.
vm
.
$
nextTick
();
await
nextTick
();
expect
(
vm
.
vm
.
fetchFiles
).
toHaveBeenCalled
();
expect
(
vm
.
vm
.
fetchFiles
).
toHaveBeenCalled
();
expect
(
resetRequestedCommits
).
toHaveBeenCalled
();
expect
(
resetRequestedCommits
).
toHaveBeenCalled
();
...
@@ -111,7 +112,7 @@ describe('Repository table component', () => {
...
@@ -111,7 +112,7 @@ describe('Repository table component', () => {
it
(
'
is changes hasShowMore to false when "showMore" event is emitted
'
,
async
()
=>
{
it
(
'
is changes hasShowMore to false when "showMore" event is emitted
'
,
async
()
=>
{
findFileTable
().
vm
.
$emit
(
'
showMore
'
);
findFileTable
().
vm
.
$emit
(
'
showMore
'
);
await
vm
.
vm
.
$
nextTick
();
await
nextTick
();
expect
(
vm
.
vm
.
hasShowMore
).
toBe
(
false
);
expect
(
vm
.
vm
.
hasShowMore
).
toBe
(
false
);
});
});
...
@@ -119,7 +120,7 @@ describe('Repository table component', () => {
...
@@ -119,7 +120,7 @@ describe('Repository table component', () => {
it
(
'
changes clickedShowMore when "showMore" event is emitted
'
,
async
()
=>
{
it
(
'
changes clickedShowMore when "showMore" event is emitted
'
,
async
()
=>
{
findFileTable
().
vm
.
$emit
(
'
showMore
'
);
findFileTable
().
vm
.
$emit
(
'
showMore
'
);
await
vm
.
vm
.
$
nextTick
();
await
nextTick
();
expect
(
vm
.
vm
.
clickedShowMore
).
toBe
(
true
);
expect
(
vm
.
vm
.
clickedShowMore
).
toBe
(
true
);
});
});
...
@@ -140,7 +141,7 @@ describe('Repository table component', () => {
...
@@ -140,7 +141,7 @@ describe('Repository table component', () => {
// eslint-disable-next-line no-restricted-syntax
// eslint-disable-next-line no-restricted-syntax
vm
.
setData
({
fetchCounter
:
5
,
clickedShowMore
:
false
});
vm
.
setData
({
fetchCounter
:
5
,
clickedShowMore
:
false
});
await
vm
.
vm
.
$
nextTick
();
await
nextTick
();
expect
(
vm
.
vm
.
hasShowMore
).
toBe
(
false
);
expect
(
vm
.
vm
.
hasShowMore
).
toBe
(
false
);
});
});
...
@@ -161,7 +162,7 @@ describe('Repository table component', () => {
...
@@ -161,7 +162,7 @@ describe('Repository table component', () => {
// eslint-disable-next-line no-restricted-syntax
// eslint-disable-next-line no-restricted-syntax
vm
.
setData
({
entries
:
{
blobs
},
pagesLoaded
});
vm
.
setData
({
entries
:
{
blobs
},
pagesLoaded
});
await
vm
.
vm
.
$
nextTick
();
await
nextTick
();
expect
(
findFileTable
().
props
(
'
hasMore
'
)).
toBe
(
limitReached
);
expect
(
findFileTable
().
props
(
'
hasMore
'
)).
toBe
(
limitReached
);
});
});
...
...
spec/frontend/serverless/components/functions_spec.js
View file @
b8618652
import
{
GlLoadingIcon
}
from
'
@gitlab/ui
'
;
import
{
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
AxiosMockAdapter
from
'
axios-mock-adapter
'
;
import
AxiosMockAdapter
from
'
axios-mock-adapter
'
;
import
Vuex
from
'
vuex
'
;
import
Vuex
from
'
vuex
'
;
import
{
TEST_HOST
}
from
'
helpers/test_constants
'
;
import
{
TEST_HOST
}
from
'
helpers/test_constants
'
;
...
@@ -73,15 +73,14 @@ describe('functionsComponent', () => {
...
@@ -73,15 +73,14 @@ describe('functionsComponent', () => {
expect
(
component
.
find
(
'
.js-functions-loader
'
).
exists
()).
toBe
(
true
);
expect
(
component
.
find
(
'
.js-functions-loader
'
).
exists
()).
toBe
(
true
);
});
});
it
(
'
should render the functions list
'
,
()
=>
{
it
(
'
should render the functions list
'
,
async
()
=>
{
store
=
createStore
({
clustersPath
:
'
clustersPath
'
,
helpPath
:
'
helpPath
'
,
statusPath
});
store
=
createStore
({
clustersPath
:
'
clustersPath
'
,
helpPath
:
'
helpPath
'
,
statusPath
});
component
=
shallowMount
(
functionsComponent
,
{
store
});
component
=
shallowMount
(
functionsComponent
,
{
store
});
component
.
vm
.
$store
.
dispatch
(
'
receiveFunctionsSuccess
'
,
mockServerlessFunctions
);
await
component
.
vm
.
$store
.
dispatch
(
'
receiveFunctionsSuccess
'
,
mockServerlessFunctions
);
return
component
.
vm
.
$nextTick
().
then
(()
=>
{
await
nextTick
();
expect
(
component
.
find
(
EnvironmentRow
).
exists
()).
toBe
(
true
);
expect
(
component
.
find
(
EnvironmentRow
).
exists
()).
toBe
(
true
);
});
});
});
});
});
spec/frontend/snippets/components/snippet_blob_view_spec.js
View file @
b8618652
...
@@ -86,22 +86,18 @@ describe('Blob Embeddable', () => {
...
@@ -86,22 +86,18 @@ describe('Blob Embeddable', () => {
expect
(
wrapper
.
find
(
RichViewer
).
exists
()).
toBe
(
true
);
expect
(
wrapper
.
find
(
RichViewer
).
exists
()).
toBe
(
true
);
});
});
it
(
'
correctly switches viewer type
'
,
()
=>
{
it
(
'
correctly switches viewer type
'
,
async
()
=>
{
createComponent
();
createComponent
();
expect
(
wrapper
.
find
(
SimpleViewer
).
exists
()).
toBe
(
true
);
expect
(
wrapper
.
find
(
SimpleViewer
).
exists
()).
toBe
(
true
);
wrapper
.
vm
.
switchViewer
(
RichViewerMock
.
type
);
wrapper
.
vm
.
switchViewer
(
RichViewerMock
.
type
);
return
wrapper
.
vm
await
nextTick
();
.
$nextTick
()
.
then
(()
=>
{
expect
(
wrapper
.
find
(
RichViewer
).
exists
()).
toBe
(
true
);
expect
(
wrapper
.
find
(
RichViewer
).
exists
()).
toBe
(
true
);
wrapper
.
vm
.
switchViewer
(
SimpleViewerMock
.
type
);
await
wrapper
.
vm
.
switchViewer
(
SimpleViewerMock
.
type
);
})
.
then
(()
=>
{
expect
(
wrapper
.
find
(
SimpleViewer
).
exists
()).
toBe
(
true
);
expect
(
wrapper
.
find
(
SimpleViewer
).
exists
()).
toBe
(
true
);
});
});
});
it
(
'
passes information about render error down to blob header
'
,
()
=>
{
it
(
'
passes information about render error down to blob header
'
,
()
=>
{
createComponent
({
createComponent
({
...
@@ -191,26 +187,22 @@ describe('Blob Embeddable', () => {
...
@@ -191,26 +187,22 @@ describe('Blob Embeddable', () => {
});
});
describe
(
'
switchViewer()
'
,
()
=>
{
describe
(
'
switchViewer()
'
,
()
=>
{
it
(
'
switches to the passed viewer
'
,
()
=>
{
it
(
'
switches to the passed viewer
'
,
async
()
=>
{
createComponent
();
createComponent
();
wrapper
.
vm
.
switchViewer
(
RichViewerMock
.
type
);
wrapper
.
vm
.
switchViewer
(
RichViewerMock
.
type
);
return
wrapper
.
vm
.
$nextTick
()
await
nextTick
();
.
then
(()
=>
{
expect
(
wrapper
.
vm
.
activeViewerType
).
toBe
(
RichViewerMock
.
type
);
expect
(
wrapper
.
vm
.
activeViewerType
).
toBe
(
RichViewerMock
.
type
);
expect
(
wrapper
.
find
(
RichViewer
).
exists
()).
toBe
(
true
);
expect
(
wrapper
.
find
(
RichViewer
).
exists
()).
toBe
(
true
);
wrapper
.
vm
.
switchViewer
(
SimpleViewerMock
.
type
);
await
wrapper
.
vm
.
switchViewer
(
SimpleViewerMock
.
type
);
})
.
then
(()
=>
{
expect
(
wrapper
.
vm
.
activeViewerType
).
toBe
(
SimpleViewerMock
.
type
);
expect
(
wrapper
.
vm
.
activeViewerType
).
toBe
(
SimpleViewerMock
.
type
);
expect
(
wrapper
.
find
(
SimpleViewer
).
exists
()).
toBe
(
true
);
expect
(
wrapper
.
find
(
SimpleViewer
).
exists
()).
toBe
(
true
);
});
});
});
});
});
});
});
});
});
describe
(
'
functionality
'
,
()
=>
{
describe
(
'
functionality
'
,
()
=>
{
describe
(
'
render error
'
,
()
=>
{
describe
(
'
render error
'
,
()
=>
{
...
...
spec/frontend/tooltips/index_spec.js
View file @
b8618652
import
{
nextTick
}
from
'
vue
'
;
import
{
import
{
add
,
add
,
initTooltips
,
initTooltips
,
...
@@ -57,7 +58,7 @@ describe('tooltips/index.js', () => {
...
@@ -57,7 +58,7 @@ describe('tooltips/index.js', () => {
triggerEvent
(
target
);
triggerEvent
(
target
);
await
tooltipsApp
.
$
nextTick
();
await
nextTick
();
expect
(
document
.
querySelector
(
'
.gl-tooltip
'
)).
not
.
toBe
(
null
);
expect
(
document
.
querySelector
(
'
.gl-tooltip
'
)).
not
.
toBe
(
null
);
expect
(
document
.
querySelector
(
'
.gl-tooltip
'
).
innerHTML
).
toContain
(
'
default title
'
);
expect
(
document
.
querySelector
(
'
.gl-tooltip
'
).
innerHTML
).
toContain
(
'
default title
'
);
...
@@ -69,7 +70,7 @@ describe('tooltips/index.js', () => {
...
@@ -69,7 +70,7 @@ describe('tooltips/index.js', () => {
buildTooltipsApp
();
buildTooltipsApp
();
triggerEvent
(
target
,
'
click
'
);
triggerEvent
(
target
,
'
click
'
);
await
tooltipsApp
.
$
nextTick
();
await
nextTick
();
expect
(
document
.
querySelector
(
'
.gl-tooltip
'
)).
not
.
toBe
(
null
);
expect
(
document
.
querySelector
(
'
.gl-tooltip
'
)).
not
.
toBe
(
null
);
expect
(
document
.
querySelector
(
'
.gl-tooltip
'
).
innerHTML
).
toContain
(
'
default title
'
);
expect
(
document
.
querySelector
(
'
.gl-tooltip
'
).
innerHTML
).
toContain
(
'
default title
'
);
...
@@ -83,7 +84,7 @@ describe('tooltips/index.js', () => {
...
@@ -83,7 +84,7 @@ describe('tooltips/index.js', () => {
buildTooltipsApp
();
buildTooltipsApp
();
add
([
target
],
{
title
:
'
custom title
'
});
add
([
target
],
{
title
:
'
custom title
'
});
await
tooltipsApp
.
$
nextTick
();
await
nextTick
();
expect
(
document
.
querySelector
(
'
.gl-tooltip
'
)).
not
.
toBe
(
null
);
expect
(
document
.
querySelector
(
'
.gl-tooltip
'
)).
not
.
toBe
(
null
);
expect
(
document
.
querySelector
(
'
.gl-tooltip
'
).
innerHTML
).
toContain
(
'
custom title
'
);
expect
(
document
.
querySelector
(
'
.gl-tooltip
'
).
innerHTML
).
toContain
(
'
custom title
'
);
...
@@ -97,13 +98,13 @@ describe('tooltips/index.js', () => {
...
@@ -97,13 +98,13 @@ describe('tooltips/index.js', () => {
buildTooltipsApp
();
buildTooltipsApp
();
triggerEvent
(
target
);
triggerEvent
(
target
);
await
tooltipsApp
.
$
nextTick
();
await
nextTick
();
expect
(
document
.
querySelector
(
'
.gl-tooltip
'
)).
not
.
toBe
(
null
);
expect
(
document
.
querySelector
(
'
.gl-tooltip
'
)).
not
.
toBe
(
null
);
dispose
([
target
]);
dispose
([
target
]);
await
tooltipsApp
.
$
nextTick
();
await
nextTick
();
expect
(
document
.
querySelector
(
'
.gl-tooltip
'
)).
toBe
(
null
);
expect
(
document
.
querySelector
(
'
.gl-tooltip
'
)).
toBe
(
null
);
});
});
...
@@ -122,7 +123,7 @@ describe('tooltips/index.js', () => {
...
@@ -122,7 +123,7 @@ describe('tooltips/index.js', () => {
buildTooltipsApp
();
buildTooltipsApp
();
await
tooltipsApp
.
$
nextTick
();
await
nextTick
();
jest
.
spyOn
(
tooltipsApp
,
'
triggerEvent
'
);
jest
.
spyOn
(
tooltipsApp
,
'
triggerEvent
'
);
...
@@ -137,7 +138,7 @@ describe('tooltips/index.js', () => {
...
@@ -137,7 +138,7 @@ describe('tooltips/index.js', () => {
buildTooltipsApp
();
buildTooltipsApp
();
await
tooltipsApp
.
$
nextTick
();
await
nextTick
();
jest
.
spyOn
(
tooltipsApp
,
'
fixTitle
'
);
jest
.
spyOn
(
tooltipsApp
,
'
fixTitle
'
);
...
...
spec/frontend/vue_shared/components/diff_viewer/viewers/image_diff_viewer_spec.js
View file @
b8618652
import
{
mount
}
from
'
@vue/test-utils
'
;
import
{
mount
}
from
'
@vue/test-utils
'
;
import
Vue
from
'
vue
'
;
import
Vue
,
{
nextTick
}
from
'
vue
'
;
import
{
compileToFunctions
}
from
'
vue-template-compiler
'
;
import
{
compileToFunctions
}
from
'
vue-template-compiler
'
;
import
{
GREEN_BOX_IMAGE_URL
,
RED_BOX_IMAGE_URL
}
from
'
spec/test_constants
'
;
import
{
GREEN_BOX_IMAGE_URL
,
RED_BOX_IMAGE_URL
}
from
'
spec/test_constants
'
;
...
@@ -51,10 +51,10 @@ describe('ImageDiffViewer', () => {
...
@@ -51,10 +51,10 @@ describe('ImageDiffViewer', () => {
wrapper
.
destroy
();
wrapper
.
destroy
();
});
});
it
(
'
renders image diff for replaced
'
,
(
done
)
=>
{
it
(
'
renders image diff for replaced
'
,
async
(
)
=>
{
createComponent
({
...
allProps
});
createComponent
({
...
allProps
});
vm
.
$nextTick
(()
=>
{
await
nextTick
();
const
metaInfoElements
=
vm
.
$el
.
querySelectorAll
(
'
.image-info
'
);
const
metaInfoElements
=
vm
.
$el
.
querySelectorAll
(
'
.image-info
'
);
expect
(
vm
.
$el
.
querySelector
(
'
.added img
'
).
getAttribute
(
'
src
'
)).
toBe
(
GREEN_BOX_IMAGE_URL
);
expect
(
vm
.
$el
.
querySelector
(
'
.added img
'
).
getAttribute
(
'
src
'
)).
toBe
(
GREEN_BOX_IMAGE_URL
);
...
@@ -73,9 +73,6 @@ describe('ImageDiffViewer', () => {
...
@@ -73,9 +73,6 @@ describe('ImageDiffViewer', () => {
expect
(
metaInfoElements
.
length
).
toBe
(
2
);
expect
(
metaInfoElements
.
length
).
toBe
(
2
);
expect
(
metaInfoElements
[
0
]).
toHaveText
(
'
2.00 KiB
'
);
expect
(
metaInfoElements
[
0
]).
toHaveText
(
'
2.00 KiB
'
);
expect
(
metaInfoElements
[
1
]).
toHaveText
(
'
1.00 KiB
'
);
expect
(
metaInfoElements
[
1
]).
toHaveText
(
'
1.00 KiB
'
);
done
();
});
});
});
it
(
'
renders image diff for new
'
,
(
done
)
=>
{
it
(
'
renders image diff for new
'
,
(
done
)
=>
{
...
@@ -151,13 +148,11 @@ describe('ImageDiffViewer', () => {
...
@@ -151,13 +148,11 @@ describe('ImageDiffViewer', () => {
});
});
});
});
it
(
'
switches to Swipe Mode
'
,
(
done
)
=>
{
it
(
'
switches to Swipe Mode
'
,
async
(
)
=>
{
vm
.
$el
.
querySelector
(
'
.view-modes-menu li:nth-child(2)
'
).
click
();
vm
.
$el
.
querySelector
(
'
.view-modes-menu li:nth-child(2)
'
).
click
();
vm
.
$nextTick
(()
=>
{
await
nextTick
();
expect
(
vm
.
$el
.
querySelector
(
'
.view-modes-menu li.active
'
).
textContent
.
trim
()).
toBe
(
'
Swipe
'
);
expect
(
vm
.
$el
.
querySelector
(
'
.view-modes-menu li.active
'
).
textContent
.
trim
()).
toBe
(
'
Swipe
'
);
done
();
});
});
});
});
});
...
@@ -170,29 +165,24 @@ describe('ImageDiffViewer', () => {
...
@@ -170,29 +165,24 @@ describe('ImageDiffViewer', () => {
});
});
});
});
it
(
'
switches to Onion Skin Mode
'
,
(
done
)
=>
{
it
(
'
switches to Onion Skin Mode
'
,
async
(
)
=>
{
vm
.
$el
.
querySelector
(
'
.view-modes-menu li:nth-child(3)
'
).
click
();
vm
.
$el
.
querySelector
(
'
.view-modes-menu li:nth-child(3)
'
).
click
();
vm
.
$nextTick
(()
=>
{
await
nextTick
();
expect
(
vm
.
$el
.
querySelector
(
'
.view-modes-menu li.active
'
).
textContent
.
trim
()).
toBe
(
expect
(
vm
.
$el
.
querySelector
(
'
.view-modes-menu li.active
'
).
textContent
.
trim
()).
toBe
(
'
Onion skin
'
,
'
Onion skin
'
,
);
);
done
();
});
});
});
it
(
'
has working drag handler
'
,
(
done
)
=>
{
it
(
'
has working drag handler
'
,
async
(
)
=>
{
vm
.
$el
.
querySelector
(
'
.view-modes-menu li:nth-child(3)
'
).
click
();
vm
.
$el
.
querySelector
(
'
.view-modes-menu li:nth-child(3)
'
).
click
();
vm
.
$nextTick
(()
=>
{
await
nextTick
();
dragSlider
(
vm
.
$el
.
querySelector
(
'
.dragger
'
),
document
,
20
);
dragSlider
(
vm
.
$el
.
querySelector
(
'
.dragger
'
),
document
,
20
);
vm
.
$nextTick
(()
=>
{
await
nextTick
();
expect
(
vm
.
$el
.
querySelector
(
'
.dragger
'
).
style
.
left
).
toBe
(
'
20px
'
);
expect
(
vm
.
$el
.
querySelector
(
'
.dragger
'
).
style
.
left
).
toBe
(
'
20px
'
);
expect
(
vm
.
$el
.
querySelector
(
'
.added.frame
'
).
style
.
opacity
).
toBe
(
'
0.2
'
);
expect
(
vm
.
$el
.
querySelector
(
'
.added.frame
'
).
style
.
opacity
).
toBe
(
'
0.2
'
);
done
();
});
});
});
});
});
});
});
});
spec/frontend/vue_shared/components/file_finder/index_spec.js
View file @
b8618652
import
Mousetrap
from
'
mousetrap
'
;
import
Mousetrap
from
'
mousetrap
'
;
import
Vue
from
'
vue
'
;
import
Vue
,
{
nextTick
}
from
'
vue
'
;
import
waitForPromises
from
'
helpers/wait_for_promises
'
;
import
waitForPromises
from
'
helpers/wait_for_promises
'
;
import
{
file
}
from
'
jest/ide/helpers
'
;
import
{
file
}
from
'
jest/ide/helpers
'
;
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
'
;
...
@@ -310,34 +310,26 @@ describe('File finder item spec', () => {
...
@@ -310,34 +310,26 @@ describe('File finder item spec', () => {
});
});
describe
(
'
keyboard shortcuts
'
,
()
=>
{
describe
(
'
keyboard shortcuts
'
,
()
=>
{
beforeEach
(
(
done
)
=>
{
beforeEach
(
async
(
)
=>
{
createComponent
();
createComponent
();
jest
.
spyOn
(
vm
,
'
toggle
'
).
mockImplementation
(()
=>
{});
jest
.
spyOn
(
vm
,
'
toggle
'
).
mockImplementation
(()
=>
{});
vm
.
$nextTick
(
done
);
await
nextTick
(
);
});
});
it
(
'
calls toggle on `t` key press
'
,
(
done
)
=>
{
it
(
'
calls toggle on `t` key press
'
,
async
(
)
=>
{
Mousetrap
.
trigger
(
'
t
'
);
Mousetrap
.
trigger
(
'
t
'
);
vm
.
$nextTick
()
await
nextTick
();
.
then
(()
=>
{
expect
(
vm
.
toggle
).
toHaveBeenCalled
();
expect
(
vm
.
toggle
).
toHaveBeenCalled
();
})
.
then
(
done
)
.
catch
(
done
.
fail
);
});
});
it
(
'
calls toggle on `mod+p` key press
'
,
(
done
)
=>
{
it
(
'
calls toggle on `mod+p` key press
'
,
async
(
)
=>
{
Mousetrap
.
trigger
(
'
mod+p
'
);
Mousetrap
.
trigger
(
'
mod+p
'
);
vm
.
$nextTick
()
await
nextTick
();
.
then
(()
=>
{
expect
(
vm
.
toggle
).
toHaveBeenCalled
();
expect
(
vm
.
toggle
).
toHaveBeenCalled
();
})
.
then
(
done
)
.
catch
(
done
.
fail
);
});
});
it
(
'
always allows `mod+p` to trigger toggle
'
,
()
=>
{
it
(
'
always allows `mod+p` to trigger toggle
'
,
()
=>
{
...
...
spec/frontend/vue_shared/components/file_finder/item_spec.js
View file @
b8618652
import
Vue
from
'
vue
'
;
import
Vue
,
{
nextTick
}
from
'
vue
'
;
import
createComponent
from
'
helpers/vue_mount_component_helper
'
;
import
createComponent
from
'
helpers/vue_mount_component_helper
'
;
import
{
file
}
from
'
jest/ide/helpers
'
;
import
{
file
}
from
'
jest/ide/helpers
'
;
import
ItemComponent
from
'
~/vue_shared/components/file_finder/item.vue
'
;
import
ItemComponent
from
'
~/vue_shared/components/file_finder/item.vue
'
;
...
@@ -37,14 +37,11 @@ describe('File finder item spec', () => {
...
@@ -37,14 +37,11 @@ describe('File finder item spec', () => {
expect
(
vm
.
$el
.
classList
).
toContain
(
'
is-focused
'
);
expect
(
vm
.
$el
.
classList
).
toContain
(
'
is-focused
'
);
});
});
it
(
'
does not have is-focused class when not focused
'
,
(
done
)
=>
{
it
(
'
does not have is-focused class when not focused
'
,
async
(
)
=>
{
vm
.
focused
=
false
;
vm
.
focused
=
false
;
vm
.
$nextTick
(()
=>
{
await
nextTick
();
expect
(
vm
.
$el
.
classList
).
not
.
toContain
(
'
is-focused
'
);
expect
(
vm
.
$el
.
classList
).
not
.
toContain
(
'
is-focused
'
);
done
();
});
});
});
});
});
...
@@ -53,24 +50,18 @@ describe('File finder item spec', () => {
...
@@ -53,24 +50,18 @@ describe('File finder item spec', () => {
expect
(
vm
.
$el
.
querySelector
(
'
.diff-changed-stats
'
)).
toBe
(
null
);
expect
(
vm
.
$el
.
querySelector
(
'
.diff-changed-stats
'
)).
toBe
(
null
);
});
});
it
(
'
renders when a changed file
'
,
(
done
)
=>
{
it
(
'
renders when a changed file
'
,
async
(
)
=>
{
vm
.
file
.
changed
=
true
;
vm
.
file
.
changed
=
true
;
vm
.
$nextTick
(()
=>
{
await
nextTick
();
expect
(
vm
.
$el
.
querySelector
(
'
.diff-changed-stats
'
)).
not
.
toBe
(
null
);
expect
(
vm
.
$el
.
querySelector
(
'
.diff-changed-stats
'
)).
not
.
toBe
(
null
);
done
();
});
});
});
it
(
'
renders when a temp file
'
,
(
done
)
=>
{
it
(
'
renders when a temp file
'
,
async
(
)
=>
{
vm
.
file
.
tempFile
=
true
;
vm
.
file
.
tempFile
=
true
;
vm
.
$nextTick
(()
=>
{
await
nextTick
();
expect
(
vm
.
$el
.
querySelector
(
'
.diff-changed-stats
'
)).
not
.
toBe
(
null
);
expect
(
vm
.
$el
.
querySelector
(
'
.diff-changed-stats
'
)).
not
.
toBe
(
null
);
done
();
});
});
});
});
});
...
@@ -85,56 +76,52 @@ describe('File finder item spec', () => {
...
@@ -85,56 +76,52 @@ describe('File finder item spec', () => {
describe
(
'
path
'
,
()
=>
{
describe
(
'
path
'
,
()
=>
{
let
el
;
let
el
;
beforeEach
(
(
done
)
=>
{
beforeEach
(
async
(
)
=>
{
vm
.
searchText
=
'
file
'
;
vm
.
searchText
=
'
file
'
;
el
=
vm
.
$el
.
querySelector
(
'
.diff-changed-file-path
'
);
el
=
vm
.
$el
.
querySelector
(
'
.diff-changed-file-path
'
);
vm
.
$nextTick
(
done
);
nextTick
(
);
});
});
it
(
'
highlights text
'
,
()
=>
{
it
(
'
highlights text
'
,
()
=>
{
expect
(
el
.
querySelectorAll
(
'
.highlighted
'
).
length
).
toBe
(
4
);
expect
(
el
.
querySelectorAll
(
'
.highlighted
'
).
length
).
toBe
(
4
);
});
});
it
(
'
adds ellipsis to long text
'
,
(
done
)
=>
{
it
(
'
adds ellipsis to long text
'
,
async
(
)
=>
{
vm
.
file
.
path
=
new
Array
(
70
)
vm
.
file
.
path
=
new
Array
(
70
)
.
fill
()
.
fill
()
.
map
((
_
,
i
)
=>
`
${
i
}
-`
)
.
map
((
_
,
i
)
=>
`
${
i
}
-`
)
.
join
(
''
);
.
join
(
''
);
vm
.
$nextTick
(()
=>
{
await
nextTick
();
expect
(
el
.
textContent
).
toBe
(
`...
${
vm
.
file
.
path
.
substr
(
vm
.
file
.
path
.
length
-
60
)}
`
);
expect
(
el
.
textContent
).
toBe
(
`...
${
vm
.
file
.
path
.
substr
(
vm
.
file
.
path
.
length
-
60
)}
`
);
done
();
});
});
});
});
});
describe
(
'
name
'
,
()
=>
{
describe
(
'
name
'
,
()
=>
{
let
el
;
let
el
;
beforeEach
(
(
done
)
=>
{
beforeEach
(
async
(
)
=>
{
vm
.
searchText
=
'
file
'
;
vm
.
searchText
=
'
file
'
;
el
=
vm
.
$el
.
querySelector
(
'
.diff-changed-file-name
'
);
el
=
vm
.
$el
.
querySelector
(
'
.diff-changed-file-name
'
);
vm
.
$nextTick
(
done
);
await
nextTick
(
);
});
});
it
(
'
highlights text
'
,
()
=>
{
it
(
'
highlights text
'
,
()
=>
{
expect
(
el
.
querySelectorAll
(
'
.highlighted
'
).
length
).
toBe
(
4
);
expect
(
el
.
querySelectorAll
(
'
.highlighted
'
).
length
).
toBe
(
4
);
});
});
it
(
'
does not add ellipsis to long text
'
,
(
done
)
=>
{
it
(
'
does not add ellipsis to long text
'
,
async
(
)
=>
{
vm
.
file
.
name
=
new
Array
(
70
)
vm
.
file
.
name
=
new
Array
(
70
)
.
fill
()
.
fill
()
.
map
((
_
,
i
)
=>
`
${
i
}
-`
)
.
map
((
_
,
i
)
=>
`
${
i
}
-`
)
.
join
(
''
);
.
join
(
''
);
vm
.
$nextTick
(()
=>
{
await
nextTick
();
expect
(
el
.
textContent
).
not
.
toBe
(
`...
${
vm
.
file
.
name
.
substr
(
vm
.
file
.
name
.
length
-
60
)}
`
);
expect
(
el
.
textContent
).
not
.
toBe
(
`...
${
vm
.
file
.
name
.
substr
(
vm
.
file
.
name
.
length
-
60
)}
`
);
done
();
});
});
});
});
});
});
});
spec/frontend/vue_shared/components/gl_modal_vuex_spec.js
View file @
b8618652
import
{
GlModal
}
from
'
@gitlab/ui
'
;
import
{
GlModal
}
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
{
BV_SHOW_MODAL
,
BV_HIDE_MODAL
}
from
'
~/lib/utils/constants
'
;
import
{
BV_SHOW_MODAL
,
BV_HIDE_MODAL
}
from
'
~/lib/utils/constants
'
;
import
GlModalVuex
from
'
~/vue_shared/components/gl_modal_vuex.vue
'
;
import
GlModalVuex
from
'
~/vue_shared/components/gl_modal_vuex.vue
'
;
...
@@ -118,7 +118,7 @@ describe('GlModalVuex', () => {
...
@@ -118,7 +118,7 @@ describe('GlModalVuex', () => {
expect
(
actions
.
hide
).
toHaveBeenCalledTimes
(
1
);
expect
(
actions
.
hide
).
toHaveBeenCalledTimes
(
1
);
});
});
it
(
'
calls bootstrap show when isVisible changes
'
,
(
done
)
=>
{
it
(
'
calls bootstrap show when isVisible changes
'
,
async
(
)
=>
{
state
.
isVisible
=
false
;
state
.
isVisible
=
false
;
factory
();
factory
();
...
@@ -126,16 +126,11 @@ describe('GlModalVuex', () => {
...
@@ -126,16 +126,11 @@ describe('GlModalVuex', () => {
state
.
isVisible
=
true
;
state
.
isVisible
=
true
;
wrapper
.
vm
await
nextTick
();
.
$nextTick
()
.
then
(()
=>
{
expect
(
rootEmit
).
toHaveBeenCalledWith
(
BV_SHOW_MODAL
,
TEST_MODAL_ID
);
expect
(
rootEmit
).
toHaveBeenCalledWith
(
BV_SHOW_MODAL
,
TEST_MODAL_ID
);
})
.
then
(
done
)
.
catch
(
done
.
fail
);
});
});
it
(
'
calls bootstrap hide when isVisible changes
'
,
(
done
)
=>
{
it
(
'
calls bootstrap hide when isVisible changes
'
,
async
(
)
=>
{
state
.
isVisible
=
true
;
state
.
isVisible
=
true
;
factory
();
factory
();
...
@@ -143,13 +138,8 @@ describe('GlModalVuex', () => {
...
@@ -143,13 +138,8 @@ describe('GlModalVuex', () => {
state
.
isVisible
=
false
;
state
.
isVisible
=
false
;
wrapper
.
vm
await
nextTick
();
.
$nextTick
()
.
then
(()
=>
{
expect
(
rootEmit
).
toHaveBeenCalledWith
(
BV_HIDE_MODAL
,
TEST_MODAL_ID
);
expect
(
rootEmit
).
toHaveBeenCalledWith
(
BV_HIDE_MODAL
,
TEST_MODAL_ID
);
})
.
then
(
done
)
.
catch
(
done
.
fail
);
});
});
it
.
each
([
'
ok
'
,
'
cancel
'
])(
it
.
each
([
'
ok
'
,
'
cancel
'
])(
...
...
spec/frontend/vue_shared/components/markdown/field_spec.js
View file @
b8618652
...
@@ -100,117 +100,102 @@ describe('Markdown field component', () => {
...
@@ -100,117 +100,102 @@ describe('Markdown field component', () => {
axiosMock
.
onPost
(
markdownPreviewPath
).
reply
(
200
,
{
body
:
previewHTML
});
axiosMock
.
onPost
(
markdownPreviewPath
).
reply
(
200
,
{
body
:
previewHTML
});
});
});
it
(
'
sets preview link as active
'
,
()
=>
{
it
(
'
sets preview link as active
'
,
async
()
=>
{
previewLink
=
getPreviewLink
();
previewLink
=
getPreviewLink
();
previewLink
.
trigger
(
'
click
'
);
previewLink
.
trigger
(
'
click
'
);
return
subject
.
vm
.
$nextTick
().
then
(()
=>
{
await
nextTick
();
expect
(
previewLink
.
element
.
parentNode
.
classList
.
contains
(
'
active
'
)).
toBeTruthy
();
expect
(
previewLink
.
element
.
parentNode
.
classList
.
contains
(
'
active
'
)).
toBeTruthy
();
});
});
});
it
(
'
shows preview loading text
'
,
()
=>
{
it
(
'
shows preview loading text
'
,
async
()
=>
{
previewLink
=
getPreviewLink
();
previewLink
=
getPreviewLink
();
previewLink
.
trigger
(
'
click
'
);
previewLink
.
trigger
(
'
click
'
);
return
subject
.
vm
.
$nextTick
(()
=>
{
await
nextTick
();
expect
(
subject
.
find
(
'
.md-preview-holder
'
).
element
.
textContent
.
trim
()).
toContain
(
expect
(
subject
.
find
(
'
.md-preview-holder
'
).
element
.
textContent
.
trim
()).
toContain
(
'
Loading…
'
);
'
Loading…
'
,
);
});
});
});
it
(
'
renders markdown preview and GFM
'
,
()
=>
{
it
(
'
renders markdown preview and GFM
'
,
async
()
=>
{
const
renderGFMSpy
=
jest
.
spyOn
(
$
.
fn
,
'
renderGFM
'
);
const
renderGFMSpy
=
jest
.
spyOn
(
$
.
fn
,
'
renderGFM
'
);
previewLink
=
getPreviewLink
();
previewLink
=
getPreviewLink
();
previewLink
.
trigger
(
'
click
'
);
previewLink
.
trigger
(
'
click
'
);
return
axios
.
waitFor
(
markdownPreviewPath
).
then
(()
=>
{
await
axios
.
waitFor
(
markdownPreviewPath
);
expect
(
subject
.
find
(
'
.md-preview-holder
'
).
element
.
innerHTML
).
toContain
(
previewHTML
);
expect
(
subject
.
find
(
'
.md-preview-holder
'
).
element
.
innerHTML
).
toContain
(
previewHTML
);
expect
(
renderGFMSpy
).
toHaveBeenCalled
();
expect
(
renderGFMSpy
).
toHaveBeenCalled
();
});
});
});
it
(
'
calls video.pause() on comment input when isSubmitting is changed to true
'
,
()
=>
{
it
(
'
calls video.pause() on comment input when isSubmitting is changed to true
'
,
async
()
=>
{
previewLink
=
getPreviewLink
();
previewLink
=
getPreviewLink
();
previewLink
.
trigger
(
'
click
'
);
previewLink
.
trigger
(
'
click
'
);
let
callPause
;
await
axios
.
waitFor
(
markdownPreviewPath
);
return
axios
.
waitFor
(
markdownPreviewPath
)
.
then
(()
=>
{
const
video
=
getVideo
();
const
video
=
getVideo
();
callPause
=
jest
.
spyOn
(
video
.
element
,
'
pause
'
).
mockImplementation
(()
=>
true
);
const
callPause
=
jest
.
spyOn
(
video
.
element
,
'
pause
'
).
mockImplementation
(()
=>
true
);
subject
.
setProps
({
isSubmitting
:
true
});
subject
.
setProps
({
isSubmitting
:
true
});
return
subject
.
vm
.
$nextTick
();
await
nextTick
();
})
.
then
(()
=>
{
expect
(
callPause
).
toHaveBeenCalled
();
expect
(
callPause
).
toHaveBeenCalled
();
});
});
});
it
(
'
clicking already active write or preview link does nothing
'
,
async
()
=>
{
it
(
'
clicking already active write or preview link does nothing
'
,
async
()
=>
{
writeLink
=
getWriteLink
();
writeLink
=
getWriteLink
();
previewLink
=
getPreviewLink
();
previewLink
=
getPreviewLink
();
writeLink
.
trigger
(
'
click
'
);
writeLink
.
trigger
(
'
click
'
);
await
subject
.
vm
.
$
nextTick
();
await
nextTick
();
assertMarkdownTabs
(
true
,
writeLink
,
previewLink
,
subject
);
assertMarkdownTabs
(
true
,
writeLink
,
previewLink
,
subject
);
writeLink
.
trigger
(
'
click
'
);
writeLink
.
trigger
(
'
click
'
);
await
subject
.
vm
.
$
nextTick
();
await
nextTick
();
assertMarkdownTabs
(
true
,
writeLink
,
previewLink
,
subject
);
assertMarkdownTabs
(
true
,
writeLink
,
previewLink
,
subject
);
previewLink
.
trigger
(
'
click
'
);
previewLink
.
trigger
(
'
click
'
);
await
subject
.
vm
.
$
nextTick
();
await
nextTick
();
assertMarkdownTabs
(
false
,
writeLink
,
previewLink
,
subject
);
assertMarkdownTabs
(
false
,
writeLink
,
previewLink
,
subject
);
previewLink
.
trigger
(
'
click
'
);
previewLink
.
trigger
(
'
click
'
);
await
subject
.
vm
.
$
nextTick
();
await
nextTick
();
assertMarkdownTabs
(
false
,
writeLink
,
previewLink
,
subject
);
assertMarkdownTabs
(
false
,
writeLink
,
previewLink
,
subject
);
});
});
});
});
describe
(
'
markdown buttons
'
,
()
=>
{
describe
(
'
markdown buttons
'
,
()
=>
{
it
(
'
converts single words
'
,
()
=>
{
it
(
'
converts single words
'
,
async
()
=>
{
const
textarea
=
subject
.
find
(
'
textarea
'
).
element
;
const
textarea
=
subject
.
find
(
'
textarea
'
).
element
;
textarea
.
setSelectionRange
(
0
,
7
);
textarea
.
setSelectionRange
(
0
,
7
);
const
markdownButton
=
getMarkdownButton
();
const
markdownButton
=
getMarkdownButton
();
markdownButton
.
trigger
(
'
click
'
);
markdownButton
.
trigger
(
'
click
'
);
return
subject
.
vm
.
$nextTick
(()
=>
{
await
nextTick
();
expect
(
textarea
.
value
).
toContain
(
'
**testing**
'
);
expect
(
textarea
.
value
).
toContain
(
'
**testing**
'
);
});
});
});
it
(
'
converts a line
'
,
()
=>
{
it
(
'
converts a line
'
,
async
()
=>
{
const
textarea
=
subject
.
find
(
'
textarea
'
).
element
;
const
textarea
=
subject
.
find
(
'
textarea
'
).
element
;
textarea
.
setSelectionRange
(
0
,
0
);
textarea
.
setSelectionRange
(
0
,
0
);
const
markdownButton
=
getAllMarkdownButtons
().
wrappers
[
5
];
const
markdownButton
=
getAllMarkdownButtons
().
wrappers
[
5
];
markdownButton
.
trigger
(
'
click
'
);
markdownButton
.
trigger
(
'
click
'
);
return
subject
.
vm
.
$nextTick
(()
=>
{
await
nextTick
();
expect
(
textarea
.
value
).
toContain
(
'
- testing
'
);
expect
(
textarea
.
value
).
toContain
(
'
- testing
'
);
});
});
});
it
(
'
converts multiple lines
'
,
()
=>
{
it
(
'
converts multiple lines
'
,
async
()
=>
{
const
textarea
=
subject
.
find
(
'
textarea
'
).
element
;
const
textarea
=
subject
.
find
(
'
textarea
'
).
element
;
textarea
.
setSelectionRange
(
0
,
50
);
textarea
.
setSelectionRange
(
0
,
50
);
const
markdownButton
=
getAllMarkdownButtons
().
wrappers
[
5
];
const
markdownButton
=
getAllMarkdownButtons
().
wrappers
[
5
];
markdownButton
.
trigger
(
'
click
'
);
markdownButton
.
trigger
(
'
click
'
);
return
subject
.
vm
.
$nextTick
(()
=>
{
await
nextTick
();
expect
(
textarea
.
value
).
toContain
(
'
- testing
\n
- 123
'
);
expect
(
textarea
.
value
).
toContain
(
'
- testing
\n
- 123
'
);
});
});
});
});
});
it
(
'
should render attach a file button
'
,
()
=>
{
it
(
'
should render attach a file button
'
,
()
=>
{
expect
(
getAttachButton
().
text
()).
toBe
(
'
Attach a file
'
);
expect
(
getAttachButton
().
text
()).
toBe
(
'
Attach a file
'
);
...
@@ -229,7 +214,7 @@ describe('Markdown field component', () => {
...
@@ -229,7 +214,7 @@ describe('Markdown field component', () => {
// Do something to trigger rerendering the class
// Do something to trigger rerendering the class
subject
.
setProps
({
wrapperClasses
:
'
foo
'
});
subject
.
setProps
({
wrapperClasses
:
'
foo
'
});
await
subject
.
vm
.
$
nextTick
();
await
nextTick
();
});
});
it
(
'
should have rerendered classes and kept gfm-form
'
,
()
=>
{
it
(
'
should have rerendered classes and kept gfm-form
'
,
()
=>
{
...
...
spec/frontend/vue_shared/components/project_avatar/default_spec.js
View file @
b8618652
import
Vue
from
'
vue
'
;
import
Vue
,
{
nextTick
}
from
'
vue
'
;
import
mountComponent
from
'
helpers/vue_mount_component_helper
'
;
import
mountComponent
from
'
helpers/vue_mount_component_helper
'
;
import
{
projectData
}
from
'
jest/ide/mock_data
'
;
import
{
projectData
}
from
'
jest/ide/mock_data
'
;
import
{
TEST_HOST
}
from
'
spec/test_constants
'
;
import
{
TEST_HOST
}
from
'
spec/test_constants
'
;
...
@@ -19,7 +19,7 @@ describe('ProjectAvatarDefault component', () => {
...
@@ -19,7 +19,7 @@ describe('ProjectAvatarDefault component', () => {
vm
.
$destroy
();
vm
.
$destroy
();
});
});
it
(
'
renders identicon if project has no avatar_url
'
,
(
done
)
=>
{
it
(
'
renders identicon if project has no avatar_url
'
,
async
(
)
=>
{
const
expectedText
=
getFirstCharacterCapitalized
(
projectData
.
name
);
const
expectedText
=
getFirstCharacterCapitalized
(
projectData
.
name
);
vm
.
project
=
{
vm
.
project
=
{
...
@@ -27,18 +27,14 @@ describe('ProjectAvatarDefault component', () => {
...
@@ -27,18 +27,14 @@ describe('ProjectAvatarDefault component', () => {
avatar_url
:
null
,
avatar_url
:
null
,
};
};
vm
.
$nextTick
()
await
nextTick
();
.
then
(()
=>
{
const
identiconEl
=
vm
.
$el
.
querySelector
(
'
.identicon
'
);
const
identiconEl
=
vm
.
$el
.
querySelector
(
'
.identicon
'
);
expect
(
identiconEl
).
not
.
toBe
(
null
);
expect
(
identiconEl
).
not
.
toBe
(
null
);
expect
(
identiconEl
.
textContent
.
trim
()).
toEqual
(
expectedText
);
expect
(
identiconEl
.
textContent
.
trim
()).
toEqual
(
expectedText
);
})
.
then
(
done
)
.
catch
(
done
.
fail
);
});
});
it
(
'
renders avatar image if project has avatar_url
'
,
(
done
)
=>
{
it
(
'
renders avatar image if project has avatar_url
'
,
async
(
)
=>
{
const
avatarUrl
=
`
${
TEST_HOST
}
/images/home/nasa.svg`
;
const
avatarUrl
=
`
${
TEST_HOST
}
/images/home/nasa.svg`
;
vm
.
project
=
{
vm
.
project
=
{
...
@@ -46,13 +42,9 @@ describe('ProjectAvatarDefault component', () => {
...
@@ -46,13 +42,9 @@ describe('ProjectAvatarDefault component', () => {
avatar_url
:
avatarUrl
,
avatar_url
:
avatarUrl
,
};
};
vm
.
$nextTick
()
await
nextTick
();
.
then
(()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.avatar
'
)).
not
.
toBeNull
();
expect
(
vm
.
$el
.
querySelector
(
'
.avatar
'
)).
not
.
toBeNull
();
expect
(
vm
.
$el
.
querySelector
(
'
.identicon
'
)).
toBeNull
();
expect
(
vm
.
$el
.
querySelector
(
'
.identicon
'
)).
toBeNull
();
expect
(
vm
.
$el
.
querySelector
(
'
img
'
)).
toHaveAttr
(
'
src
'
,
avatarUrl
);
expect
(
vm
.
$el
.
querySelector
(
'
img
'
)).
toHaveAttr
(
'
src
'
,
avatarUrl
);
})
.
then
(
done
)
.
catch
(
done
.
fail
);
});
});
});
});
spec/frontend/vue_shared/issuable/list/components/issuable_bulk_edit_sidebar_spec.js
View file @
b8618652
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
nextTick
}
from
'
vue
'
;
import
IssuableBulkEditSidebar
from
'
~/vue_shared/issuable/list/components/issuable_bulk_edit_sidebar.vue
'
;
import
IssuableBulkEditSidebar
from
'
~/vue_shared/issuable/list/components/issuable_bulk_edit_sidebar.vue
'
;
const
createComponent
=
({
expanded
=
true
}
=
{})
=>
const
createComponent
=
({
expanded
=
true
}
=
{})
=>
...
@@ -48,7 +49,7 @@ describe('IssuableBulkEditSidebar', () => {
...
@@ -48,7 +49,7 @@ describe('IssuableBulkEditSidebar', () => {
expanded
,
expanded
,
});
});
await
wrappeCustom
.
vm
.
$
nextTick
();
await
nextTick
();
expect
(
document
.
querySelector
(
'
.layout-page
'
).
classList
.
contains
(
layoutPageClass
)).
toBe
(
expect
(
document
.
querySelector
(
'
.layout-page
'
).
classList
.
contains
(
layoutPageClass
)).
toBe
(
true
,
true
,
...
@@ -78,7 +79,7 @@ describe('IssuableBulkEditSidebar', () => {
...
@@ -78,7 +79,7 @@ describe('IssuableBulkEditSidebar', () => {
expanded
,
expanded
,
});
});
await
wrappeCustom
.
vm
.
$
nextTick
();
await
nextTick
();
expect
(
wrappeCustom
.
classes
()).
toContain
(
layoutPageClass
);
expect
(
wrappeCustom
.
classes
()).
toContain
(
layoutPageClass
);
...
...
spec/frontend_integration/ide/ide_integration_spec.js
View file @
b8618652
import
{
nextTick
}
from
'
vue
'
;
import
{
setTestTimeout
}
from
'
helpers/timeout
'
;
import
{
setTestTimeout
}
from
'
helpers/timeout
'
;
import
waitForPromises
from
'
helpers/wait_for_promises
'
;
import
waitForPromises
from
'
helpers/wait_for_promises
'
;
import
{
waitForText
}
from
'
helpers/wait_for_text
'
;
import
{
waitForText
}
from
'
helpers/wait_for_text
'
;
...
@@ -134,7 +135,7 @@ describe('WebIDE', () => {
...
@@ -134,7 +135,7 @@ describe('WebIDE', () => {
describe
(
'
when editor position changes
'
,
()
=>
{
describe
(
'
when editor position changes
'
,
()
=>
{
beforeEach
(
async
()
=>
{
beforeEach
(
async
()
=>
{
editor
.
setPosition
({
lineNumber
:
4
,
column
:
10
});
editor
.
setPosition
({
lineNumber
:
4
,
column
:
10
});
await
vm
.
$
nextTick
();
await
nextTick
();
});
});
it
(
'
shows new line position
'
,
()
=>
{
it
(
'
shows new line position
'
,
()
=>
{
...
@@ -145,7 +146,7 @@ describe('WebIDE', () => {
...
@@ -145,7 +146,7 @@ describe('WebIDE', () => {
it
(
'
updates after rename
'
,
async
()
=>
{
it
(
'
updates after rename
'
,
async
()
=>
{
await
ideHelper
.
renameFile
(
'
README.md
'
,
'
READMEZ.txt
'
);
await
ideHelper
.
renameFile
(
'
README.md
'
,
'
READMEZ.txt
'
);
await
ideHelper
.
waitForEditorModelChange
(
editor
);
await
ideHelper
.
waitForEditorModelChange
(
editor
);
await
vm
.
$
nextTick
();
await
nextTick
();
expect
(
statusBar
).
toHaveText
(
'
1:1
'
);
expect
(
statusBar
).
toHaveText
(
'
1:1
'
);
expect
(
statusBar
).
toHaveText
(
'
plaintext
'
);
expect
(
statusBar
).
toHaveText
(
'
plaintext
'
);
...
@@ -166,7 +167,7 @@ describe('WebIDE', () => {
...
@@ -166,7 +167,7 @@ describe('WebIDE', () => {
await
ideHelper
.
closeFile
(
'
README.md
'
);
await
ideHelper
.
closeFile
(
'
README.md
'
);
await
ideHelper
.
openFile
(
'
README.md
'
);
await
ideHelper
.
openFile
(
'
README.md
'
);
await
ideHelper
.
waitForMonacoEditor
();
await
ideHelper
.
waitForMonacoEditor
();
await
vm
.
$
nextTick
();
await
nextTick
();
expect
(
statusBar
).
toHaveText
(
'
4:10
'
);
expect
(
statusBar
).
toHaveText
(
'
4:10
'
);
expect
(
statusBar
).
toHaveText
(
'
markdown
'
);
expect
(
statusBar
).
toHaveText
(
'
markdown
'
);
...
...
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