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
a797d196
Commit
a797d196
authored
Oct 25, 2021
by
Nicolò Maria Mezzopera
Committed by
Natalia Tepluhina
Oct 25, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor and connect package list for GraphQl implementation
parent
8cd2e168
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
413 additions
and
192 deletions
+413
-192
app/assets/javascripts/packages_and_registries/package_registry/components/list/app.vue
...s_and_registries/package_registry/components/list/app.vue
+51
-8
app/assets/javascripts/packages_and_registries/package_registry/components/list/packages_list.vue
...stries/package_registry/components/list/packages_list.vue
+45
-40
app/assets/javascripts/packages_and_registries/package_registry/constants.js
...pts/packages_and_registries/package_registry/constants.js
+1
-6
app/assets/javascripts/packages_and_registries/package_registry/graphql/queries/get_packages.query.graphql
...ckage_registry/graphql/queries/get_packages.query.graphql
+29
-2
app/assets/javascripts/packages_and_registries/package_registry/utils.js
...scripts/packages_and_registries/package_registry/utils.js
+3
-0
spec/frontend/packages_and_registries/package_registry/components/list/__snapshots__/app_spec.js.snap
...e_registry/components/list/__snapshots__/app_spec.js.snap
+57
-0
spec/frontend/packages_and_registries/package_registry/components/list/app_spec.js
...d_registries/package_registry/components/list/app_spec.js
+87
-10
spec/frontend/packages_and_registries/package_registry/components/list/packages_list_spec.js
...es/package_registry/components/list/packages_list_spec.js
+125
-124
spec/frontend/packages_and_registries/package_registry/mock_data.js
...end/packages_and_registries/package_registry/mock_data.js
+15
-2
No files found.
app/assets/javascripts/packages_and_registries/package_registry/components/list/app.vue
View file @
a797d196
...
@@ -4,7 +4,7 @@
...
@@ -4,7 +4,7 @@
* For a complete overview of the plan please check: https://gitlab.com/gitlab-org/gitlab/-/issues/330846
* For a complete overview of the plan please check: https://gitlab.com/gitlab-org/gitlab/-/issues/330846
* This work is behind feature flag: https://gitlab.com/gitlab-org/gitlab/-/issues/341136
* This work is behind feature flag: https://gitlab.com/gitlab-org/gitlab/-/issues/341136
*/
*/
//
import { GlEmptyState, GlLink, GlSprintf } from '@gitlab/ui';
import
{
GlEmptyState
,
GlLink
,
GlSprintf
}
from
'
@gitlab/ui
'
;
import
createFlash
from
'
~/flash
'
;
import
createFlash
from
'
~/flash
'
;
import
{
historyReplaceState
}
from
'
~/lib/utils/common_utils
'
;
import
{
historyReplaceState
}
from
'
~/lib/utils/common_utils
'
;
import
{
s__
}
from
'
~/locale
'
;
import
{
s__
}
from
'
~/locale
'
;
...
@@ -15,17 +15,18 @@ import {
...
@@ -15,17 +15,18 @@ import {
PROJECT_RESOURCE_TYPE
,
PROJECT_RESOURCE_TYPE
,
GROUP_RESOURCE_TYPE
,
GROUP_RESOURCE_TYPE
,
LIST_QUERY_DEBOUNCE_TIME
,
LIST_QUERY_DEBOUNCE_TIME
,
GRAPHQL_PAGE_SIZE
,
}
from
'
~/packages_and_registries/package_registry/constants
'
;
}
from
'
~/packages_and_registries/package_registry/constants
'
;
import
PackageTitle
from
'
./package_title.vue
'
;
import
PackageTitle
from
'
./package_title.vue
'
;
import
PackageSearch
from
'
./package_search.vue
'
;
import
PackageSearch
from
'
./package_search.vue
'
;
//
import PackageList from './packages_list.vue';
import
PackageList
from
'
./packages_list.vue
'
;
export
default
{
export
default
{
components
:
{
components
:
{
//
GlEmptyState,
GlEmptyState
,
//
GlLink,
GlLink
,
//
GlSprintf,
GlSprintf
,
//
PackageList,
PackageList
,
PackageTitle
,
PackageTitle
,
PackageSearch
,
PackageSearch
,
},
},
...
@@ -64,17 +65,24 @@ export default {
...
@@ -64,17 +65,24 @@ export default {
groupSort
:
this
.
isGroupPage
?
this
.
sort
:
undefined
,
groupSort
:
this
.
isGroupPage
?
this
.
sort
:
undefined
,
packageName
:
this
.
filters
?.
packageName
,
packageName
:
this
.
filters
?.
packageName
,
packageType
:
this
.
filters
?.
packageType
,
packageType
:
this
.
filters
?.
packageType
,
first
:
GRAPHQL_PAGE_SIZE
,
};
};
},
},
graphqlResource
()
{
graphqlResource
()
{
return
this
.
isGroupPage
?
GROUP_RESOURCE_TYPE
:
PROJECT_RESOURCE_TYPE
;
return
this
.
isGroupPage
?
GROUP_RESOURCE_TYPE
:
PROJECT_RESOURCE_TYPE
;
},
},
pageInfo
()
{
return
this
.
packages
?.
pageInfo
??
{};
},
packagesCount
()
{
packagesCount
()
{
return
this
.
packages
?.
count
;
return
this
.
packages
?.
count
;
},
},
hasFilters
()
{
hasFilters
()
{
return
this
.
filters
.
packageName
&&
this
.
filters
.
packageType
;
return
this
.
filters
.
packageName
&&
this
.
filters
.
packageType
;
},
},
emptySearch
()
{
return
!
this
.
filters
.
packageName
&&
!
this
.
filters
.
packageType
;
},
emptyStateTitle
()
{
emptyStateTitle
()
{
return
this
.
emptySearch
return
this
.
emptySearch
?
this
.
$options
.
i18n
.
emptyPageTitle
?
this
.
$options
.
i18n
.
emptyPageTitle
...
@@ -99,6 +107,35 @@ export default {
...
@@ -99,6 +107,35 @@ export default {
this
.
sort
=
sort
;
this
.
sort
=
sort
;
this
.
filters
=
{
...
filters
};
this
.
filters
=
{
...
filters
};
},
},
updateQuery
(
_
,
{
fetchMoreResult
})
{
return
fetchMoreResult
;
},
fetchNextPage
()
{
const
variables
=
{
...
this
.
queryVariables
,
first
:
GRAPHQL_PAGE_SIZE
,
last
:
null
,
after
:
this
.
pageInfo
?.
endCursor
,
};
this
.
$apollo
.
queries
.
packages
.
fetchMore
({
variables
,
updateQuery
:
this
.
updateQuery
,
});
},
fetchPreviousPage
()
{
const
variables
=
{
...
this
.
queryVariables
,
first
:
null
,
last
:
GRAPHQL_PAGE_SIZE
,
before
:
this
.
pageInfo
?.
startCursor
,
};
this
.
$apollo
.
queries
.
packages
.
fetchMore
({
variables
,
updateQuery
:
this
.
updateQuery
,
});
},
},
},
i18n
:
{
i18n
:
{
widenFilters
:
s__
(
'
PackageRegistry|To widen your search, change or remove the filters above.
'
),
widenFilters
:
s__
(
'
PackageRegistry|To widen your search, change or remove the filters above.
'
),
...
@@ -116,7 +153,13 @@ export default {
...
@@ -116,7 +153,13 @@ export default {
<package-title
:help-url=
"packageHelpUrl"
:count=
"packagesCount"
/>
<package-title
:help-url=
"packageHelpUrl"
:count=
"packagesCount"
/>
<package-search
@
update=
"handleSearchUpdate"
/>
<package-search
@
update=
"handleSearchUpdate"
/>
<!--
<package-list
@
page:changed=
"onPageChanged"
@
package:delete=
"onPackageDeleteRequest"
>
<package-list
:list=
"packages.nodes"
:is-loading=
"$apollo.queries.packages.loading"
:page-info=
"pageInfo"
@
prev-page=
"fetchPreviousPage"
@
next-page=
"fetchNextPage"
>
<template
#empty-state
>
<template
#empty-state
>
<gl-empty-state
:title=
"emptyStateTitle"
:svg-path=
"emptyListIllustration"
>
<gl-empty-state
:title=
"emptyStateTitle"
:svg-path=
"emptyListIllustration"
>
<template
#description
>
<template
#description
>
...
@@ -129,6 +172,6 @@ export default {
...
@@ -129,6 +172,6 @@ export default {
</template>
</template>
</gl-empty-state>
</gl-empty-state>
</template>
</template>
</package-list>
-->
</package-list>
</div>
</div>
</template>
</template>
app/assets/javascripts/packages_and_registries/package_registry/components/list/packages_list.vue
View file @
a797d196
<
script
>
<
script
>
import
{
GlPagination
,
GlModal
,
GlSprintf
}
from
'
@gitlab/ui
'
;
import
{
GlModal
,
GlSprintf
,
GlKeysetPagination
}
from
'
@gitlab/ui
'
;
import
{
mapState
,
mapGetters
}
from
'
vuex
'
;
import
{
s__
}
from
'
~/locale
'
;
import
{
s__
}
from
'
~/locale
'
;
import
PackagesListRow
from
'
~/packages
/shared/components
/package_list_row.vue
'
;
import
PackagesListRow
from
'
~/packages
_and_registries/package_registry/components/list
/package_list_row.vue
'
;
import
PackagesListLoader
from
'
~/packages/shared/components/packages_list_loader.vue
'
;
import
PackagesListLoader
from
'
~/packages/shared/components/packages_list_loader.vue
'
;
import
{
TrackingActions
}
from
'
~/packages/shared/constants
'
;
import
{
import
{
packageTypeToTrackCategory
}
from
'
~/packages/shared/utils
'
;
DELETE_PACKAGE_TRACKING_ACTION
,
REQUEST_DELETE_PACKAGE_TRACKING_ACTION
,
CANCEL_DELETE_PACKAGE_TRACKING_ACTION
,
}
from
'
~/packages_and_registries/package_registry/constants
'
;
import
{
packageTypeToTrackCategory
}
from
'
~/packages_and_registries/package_registry/utils
'
;
import
Tracking
from
'
~/tracking
'
;
import
Tracking
from
'
~/tracking
'
;
export
default
{
export
default
{
components
:
{
components
:
{
GlPagination
,
Gl
Keyset
Pagination
,
GlModal
,
GlModal
,
GlSprintf
,
GlSprintf
,
PackagesListLoader
,
PackagesListLoader
,
PackagesListRow
,
PackagesListRow
,
},
},
mixins
:
[
Tracking
.
mixin
()],
mixins
:
[
Tracking
.
mixin
()],
props
:
{
list
:
{
type
:
Array
,
required
:
false
,
default
:
()
=>
[],
},
isLoading
:
{
type
:
Boolean
,
required
:
false
,
default
:
false
,
},
pageInfo
:
{
type
:
Object
,
required
:
true
,
},
},
data
()
{
data
()
{
return
{
return
{
itemToBeDeleted
:
null
,
itemToBeDeleted
:
null
,
};
};
},
},
computed
:
{
computed
:
{
...
mapState
({
perPage
:
(
state
)
=>
state
.
pagination
.
perPage
,
totalItems
:
(
state
)
=>
state
.
pagination
.
total
,
page
:
(
state
)
=>
state
.
pagination
.
page
,
isGroupPage
:
(
state
)
=>
state
.
config
.
isGroupPage
,
isLoading
:
'
isLoading
'
,
}),
...
mapGetters
({
list
:
'
getList
'
}),
currentPage
:
{
get
()
{
return
this
.
page
;
},
set
(
value
)
{
this
.
$emit
(
'
page:changed
'
,
value
);
},
},
isListEmpty
()
{
isListEmpty
()
{
return
!
this
.
list
||
this
.
list
.
length
===
0
;
return
!
this
.
list
||
this
.
list
.
length
===
0
;
},
},
modalAction
()
{
return
s__
(
'
PackageRegistry|Delete package
'
);
},
deletePackageName
()
{
deletePackageName
()
{
return
this
.
itemToBeDeleted
?.
name
??
''
;
return
this
.
itemToBeDeleted
?.
name
??
''
;
},
},
tracking
()
{
tracking
()
{
const
category
=
this
.
itemToBeDeleted
const
category
=
this
.
itemToBeDeleted
?
packageTypeToTrackCategory
(
this
.
itemToBeDeleted
.
package
_t
ype
)
?
packageTypeToTrackCategory
(
this
.
itemToBeDeleted
.
package
T
ype
)
:
undefined
;
:
undefined
;
return
{
return
{
category
,
category
,
};
};
},
},
showPagination
()
{
return
this
.
pageInfo
.
hasPreviousPage
||
this
.
pageInfo
.
hasNextPage
;
},
},
},
methods
:
{
methods
:
{
setItemToBeDeleted
(
item
)
{
setItemToBeDeleted
(
item
)
{
this
.
itemToBeDeleted
=
{
...
item
};
this
.
itemToBeDeleted
=
{
...
item
};
this
.
track
(
TrackingActions
.
REQUEST_DELETE_PACKAGE
);
this
.
track
(
REQUEST_DELETE_PACKAGE_TRACKING_ACTION
);
this
.
$refs
.
packageListDeleteModal
.
show
();
this
.
$refs
.
packageListDeleteModal
.
show
();
},
},
deleteItemConfirmation
()
{
deleteItemConfirmation
()
{
this
.
$emit
(
'
package:delete
'
,
this
.
itemToBeDeleted
);
this
.
$emit
(
'
package:delete
'
,
this
.
itemToBeDeleted
);
this
.
track
(
TrackingActions
.
DELETE_PACKAGE
);
this
.
track
(
DELETE_PACKAGE_TRACKING_ACTION
);
this
.
itemToBeDeleted
=
null
;
this
.
itemToBeDeleted
=
null
;
},
},
deleteItemCanceled
()
{
deleteItemCanceled
()
{
this
.
track
(
TrackingActions
.
CANCEL_DELETE_PACKAGE
);
this
.
track
(
CANCEL_DELETE_PACKAGE_TRACKING_ACTION
);
this
.
itemToBeDeleted
=
null
;
this
.
itemToBeDeleted
=
null
;
},
},
},
},
...
@@ -77,6 +81,7 @@ export default {
...
@@ -77,6 +81,7 @@ export default {
deleteModalContent
:
s__
(
deleteModalContent
:
s__
(
'
PackageRegistry|You are about to delete %{name}, this operation is irreversible, are you sure?
'
,
'
PackageRegistry|You are about to delete %{name}, this operation is irreversible, are you sure?
'
,
),
),
modalAction
:
s__
(
'
PackageRegistry|Delete package
'
),
},
},
};
};
</
script
>
</
script
>
...
@@ -95,19 +100,19 @@ export default {
...
@@ -95,19 +100,19 @@ export default {
v-for=
"packageEntity in list"
v-for=
"packageEntity in list"
:key=
"packageEntity.id"
:key=
"packageEntity.id"
:package-entity=
"packageEntity"
:package-entity=
"packageEntity"
:package-link=
"packageEntity._links.web_path"
:is-group=
"isGroupPage"
@
packageToDelete=
"setItemToBeDeleted"
@
packageToDelete=
"setItemToBeDeleted"
/>
/>
</div>
</div>
<gl-pagination
<div
class=
"gl-display-flex gl-justify-content-center"
>
v-model=
"currentPage"
<gl-keyset-pagination
:per-page=
"perPage"
v-if=
"showPagination"
:total-items=
"totalItems"
v-bind=
"pageInfo"
align=
"center"
class=
"gl-mt-3"
class=
"gl-w-full gl-mt-3"
@
prev=
"$emit('prev-page')"
@
next=
"$emit('next-page')"
/>
/>
</div>
<gl-modal
<gl-modal
ref=
"packageListDeleteModal"
ref=
"packageListDeleteModal"
...
@@ -116,8 +121,8 @@ export default {
...
@@ -116,8 +121,8 @@ export default {
@
ok=
"deleteItemConfirmation"
@
ok=
"deleteItemConfirmation"
@
cancel=
"deleteItemCanceled"
@
cancel=
"deleteItemCanceled"
>
>
<template
#modal-title
>
{{
modalAction
}}
</
template
>
<template
#modal-title
>
{{
$options
.
i18n
.
modalAction
}}
</
template
>
<
template
#modal-ok
>
{{
modalAction
}}
</
template
>
<
template
#modal-ok
>
{{
$options
.
i18n
.
modalAction
}}
</
template
>
<gl-sprintf
:message=
"$options.i18n.deleteModalContent"
>
<gl-sprintf
:message=
"$options.i18n.deleteModalContent"
>
<
template
#name
>
<
template
#name
>
<strong>
{{
deletePackageName
}}
</strong>
<strong>
{{
deletePackageName
}}
</strong>
...
...
app/assets/javascripts/packages_and_registries/package_registry/constants.js
View file @
a797d196
...
@@ -59,12 +59,6 @@ export const TRACKING_ACTION_COPY_COMPOSER_REGISTRY_INCLUDE_COMMAND =
...
@@ -59,12 +59,6 @@ export const TRACKING_ACTION_COPY_COMPOSER_REGISTRY_INCLUDE_COMMAND =
export
const
TRACKING_ACTION_COPY_COMPOSER_PACKAGE_INCLUDE_COMMAND
=
export
const
TRACKING_ACTION_COPY_COMPOSER_PACKAGE_INCLUDE_COMMAND
=
'
copy_composer_package_include_command
'
;
'
copy_composer_package_include_command
'
;
export
const
TrackingCategories
=
{
[
PACKAGE_TYPE_MAVEN
]:
'
MavenPackages
'
,
[
PACKAGE_TYPE_NPM
]:
'
NpmPackages
'
,
[
PACKAGE_TYPE_CONAN
]:
'
ConanPackages
'
,
};
export
const
SHOW_DELETE_SUCCESS_ALERT
=
'
showSuccessDeleteAlert
'
;
export
const
SHOW_DELETE_SUCCESS_ALERT
=
'
showSuccessDeleteAlert
'
;
export
const
DELETE_PACKAGE_ERROR_MESSAGE
=
s__
(
export
const
DELETE_PACKAGE_ERROR_MESSAGE
=
s__
(
'
PackageRegistry|Something went wrong while deleting the package.
'
,
'
PackageRegistry|Something went wrong while deleting the package.
'
,
...
@@ -93,3 +87,4 @@ export const INSTANCE_PACKAGE_ENDPOINT_TYPE = 'instance';
...
@@ -93,3 +87,4 @@ export const INSTANCE_PACKAGE_ENDPOINT_TYPE = 'instance';
export
const
PROJECT_RESOURCE_TYPE
=
'
project
'
;
export
const
PROJECT_RESOURCE_TYPE
=
'
project
'
;
export
const
GROUP_RESOURCE_TYPE
=
'
group
'
;
export
const
GROUP_RESOURCE_TYPE
=
'
group
'
;
export
const
LIST_QUERY_DEBOUNCE_TIME
=
50
;
export
const
LIST_QUERY_DEBOUNCE_TIME
=
50
;
export
const
GRAPHQL_PAGE_SIZE
=
20
;
app/assets/javascripts/packages_and_registries/package_registry/graphql/queries/get_packages.query.graphql
View file @
a797d196
#import "~/packages_and_registries/package_registry/graphql/fragments/package_data.fragment.graphql"
#import "~/packages_and_registries/package_registry/graphql/fragments/package_data.fragment.graphql"
#import "~/graphql_shared/fragments/pageInfo.fragment.graphql"
query
getPackages
(
query
getPackages
(
$fullPath
:
ID
!
$fullPath
:
ID
!
...
@@ -7,21 +8,47 @@ query getPackages(
...
@@ -7,21 +8,47 @@ query getPackages(
$groupSort
:
PackageGroupSort
$groupSort
:
PackageGroupSort
$packageName
:
String
$packageName
:
String
$packageType
:
PackageTypeEnum
$packageType
:
PackageTypeEnum
$first
:
Int
$last
:
Int
$after
:
String
$before
:
String
)
{
)
{
project
(
fullPath
:
$fullPath
)
@skip
(
if
:
$isGroupPage
)
{
project
(
fullPath
:
$fullPath
)
@skip
(
if
:
$isGroupPage
)
{
packages
(
sort
:
$sort
,
packageName
:
$packageName
,
packageType
:
$packageType
)
{
packages
(
sort
:
$sort
packageName
:
$packageName
packageType
:
$packageType
after
:
$after
before
:
$before
first
:
$first
last
:
$last
)
{
count
count
nodes
{
nodes
{
...
PackageData
...
PackageData
}
}
pageInfo
{
...
PageInfo
}
}
}
}
}
group
(
fullPath
:
$fullPath
)
@include
(
if
:
$isGroupPage
)
{
group
(
fullPath
:
$fullPath
)
@include
(
if
:
$isGroupPage
)
{
packages
(
sort
:
$groupSort
,
packageName
:
$packageName
,
packageType
:
$packageType
)
{
packages
(
sort
:
$groupSort
packageName
:
$packageName
packageType
:
$packageType
after
:
$after
before
:
$before
first
:
$first
last
:
$last
)
{
count
count
nodes
{
nodes
{
...
PackageData
...
PackageData
}
}
pageInfo
{
...
PageInfo
}
}
}
}
}
}
}
app/assets/javascripts/packages_and_registries/package_registry/utils.js
View file @
a797d196
import
{
capitalize
}
from
'
lodash
'
;
import
{
s__
}
from
'
~/locale
'
;
import
{
s__
}
from
'
~/locale
'
;
import
{
import
{
PACKAGE_TYPE_CONAN
,
PACKAGE_TYPE_CONAN
,
...
@@ -38,3 +39,5 @@ export const getPackageTypeLabel = (packageType) => {
...
@@ -38,3 +39,5 @@ export const getPackageTypeLabel = (packageType) => {
return
null
;
return
null
;
}
}
};
};
export
const
packageTypeToTrackCategory
=
(
type
)
=>
`UI::
${
capitalize
(
type
)}
Packages`
;
spec/frontend/packages_and_registries/package_registry/components/list/__snapshots__/app_spec.js.snap
View file @
a797d196
...
@@ -8,5 +8,62 @@ exports[`PackagesListApp renders 1`] = `
...
@@ -8,5 +8,62 @@ exports[`PackagesListApp renders 1`] = `
/>
/>
<package-search-stub />
<package-search-stub />
<div>
<section
class="row empty-state text-center"
>
<div
class="col-12"
>
<div
class="svg-250 svg-content"
>
<img
alt=""
class="gl-max-w-full"
role="img"
src="emptyListIllustration"
/>
</div>
</div>
<div
class="col-12"
>
<div
class="text-content gl-mx-auto gl-my-0 gl-p-5"
>
<h1
class="h4"
>
There are no packages yet
</h1>
<p>
Learn how to
<b-link-stub
class="gl-link"
event="click"
href="emptyListHelpUrl"
routertag="a"
target="_blank"
>
publish and share your packages
</b-link-stub>
with GitLab.
</p>
<div
class="gl-display-flex gl-flex-wrap gl-justify-content-center"
>
<!---->
<!---->
</div>
</div>
</div>
</section>
</div>
</div>
</div>
`;
`;
spec/frontend/packages_and_registries/package_registry/components/list/app_spec.js
View file @
a797d196
...
@@ -2,22 +2,25 @@ import { GlEmptyState, GlSprintf, GlLink } from '@gitlab/ui';
...
@@ -2,22 +2,25 @@ import { GlEmptyState, GlSprintf, GlLink } from '@gitlab/ui';
import
{
createLocalVue
}
from
'
@vue/test-utils
'
;
import
{
createLocalVue
}
from
'
@vue/test-utils
'
;
import
VueApollo
from
'
vue-apollo
'
;
import
VueApollo
from
'
vue-apollo
'
;
import
{
nextTick
}
from
'
vue
'
;
import
{
shallowMountExtended
}
from
'
helpers/vue_test_utils_helper
'
;
import
{
shallowMountExtended
}
from
'
helpers/vue_test_utils_helper
'
;
import
createMockApollo
from
'
helpers/mock_apollo_helper
'
;
import
createMockApollo
from
'
helpers/mock_apollo_helper
'
;
import
waitForPromises
from
'
helpers/wait_for_promises
'
;
import
waitForPromises
from
'
helpers/wait_for_promises
'
;
import
PackageListApp
from
'
~/packages_and_registries/package_registry/components/list/app.vue
'
;
import
PackageListApp
from
'
~/packages_and_registries/package_registry/components/list/app.vue
'
;
import
PackageTitle
from
'
~/packages_and_registries/package_registry/components/list/package_title.vue
'
;
import
PackageTitle
from
'
~/packages_and_registries/package_registry/components/list/package_title.vue
'
;
import
PackageSearch
from
'
~/packages_and_registries/package_registry/components/list/package_search.vue
'
;
import
PackageSearch
from
'
~/packages_and_registries/package_registry/components/list/package_search.vue
'
;
import
OriginalPackageList
from
'
~/packages_and_registries/package_registry/components/list/packages_list.vue
'
;
import
{
import
{
PROJECT_RESOURCE_TYPE
,
PROJECT_RESOURCE_TYPE
,
GROUP_RESOURCE_TYPE
,
GROUP_RESOURCE_TYPE
,
LIST_QUERY_DEBOUNCE_TIME
,
LIST_QUERY_DEBOUNCE_TIME
,
GRAPHQL_PAGE_SIZE
,
}
from
'
~/packages_and_registries/package_registry/constants
'
;
}
from
'
~/packages_and_registries/package_registry/constants
'
;
import
getPackagesQuery
from
'
~/packages_and_registries/package_registry/graphql/queries/get_packages.query.graphql
'
;
import
getPackagesQuery
from
'
~/packages_and_registries/package_registry/graphql/queries/get_packages.query.graphql
'
;
import
{
packagesListQuery
}
from
'
../../mock_data
'
;
import
{
packagesListQuery
,
packageData
,
pagination
}
from
'
../../mock_data
'
;
jest
.
mock
(
'
~/lib/utils/common_utils
'
);
jest
.
mock
(
'
~/lib/utils/common_utils
'
);
jest
.
mock
(
'
~/flash
'
);
jest
.
mock
(
'
~/flash
'
);
...
@@ -39,11 +42,19 @@ describe('PackagesListApp', () => {
...
@@ -39,11 +42,19 @@ describe('PackagesListApp', () => {
const
PackageList
=
{
const
PackageList
=
{
name
:
'
package-list
'
,
name
:
'
package-list
'
,
template
:
'
<div><slot name="empty-state"></slot></div>
'
,
template
:
'
<div><slot name="empty-state"></slot></div>
'
,
props
:
OriginalPackageList
.
props
,
};
};
const
GlLoadingIcon
=
{
name
:
'
gl-loading-icon
'
,
template
:
'
<div>loading</div>
'
};
const
GlLoadingIcon
=
{
name
:
'
gl-loading-icon
'
,
template
:
'
<div>loading</div>
'
};
const
searchPayload
=
{
sort
:
'
VERSION_DESC
'
,
filters
:
{
packageName
:
'
foo
'
,
packageType
:
'
CONAN
'
},
};
const
findPackageTitle
=
()
=>
wrapper
.
findComponent
(
PackageTitle
);
const
findPackageTitle
=
()
=>
wrapper
.
findComponent
(
PackageTitle
);
const
findSearch
=
()
=>
wrapper
.
findComponent
(
PackageSearch
);
const
findSearch
=
()
=>
wrapper
.
findComponent
(
PackageSearch
);
const
findListComponent
=
()
=>
wrapper
.
findComponent
(
PackageList
);
const
findEmptyState
=
()
=>
wrapper
.
findComponent
(
GlEmptyState
);
const
mountComponent
=
({
const
mountComponent
=
({
resolver
=
jest
.
fn
().
mockResolvedValue
(
packagesListQuery
()),
resolver
=
jest
.
fn
().
mockResolvedValue
(
packagesListQuery
()),
...
@@ -105,25 +116,55 @@ describe('PackagesListApp', () => {
...
@@ -105,25 +116,55 @@ describe('PackagesListApp', () => {
const
resolver
=
jest
.
fn
().
mockResolvedValue
(
packagesListQuery
());
const
resolver
=
jest
.
fn
().
mockResolvedValue
(
packagesListQuery
());
mountComponent
({
resolver
});
mountComponent
({
resolver
});
const
payload
=
{
findSearch
().
vm
.
$emit
(
'
update
'
,
searchPayload
);
sort
:
'
VERSION_DESC
'
,
filters
:
{
packageName
:
'
foo
'
,
packageType
:
'
CONAN
'
},
};
findSearch
().
vm
.
$emit
(
'
update
'
,
payload
);
await
waitForDebouncedApollo
();
await
waitForDebouncedApollo
();
jest
.
advanceTimersByTime
(
LIST_QUERY_DEBOUNCE_TIME
);
jest
.
advanceTimersByTime
(
LIST_QUERY_DEBOUNCE_TIME
);
expect
(
resolver
).
toHaveBeenCalledWith
(
expect
(
resolver
).
toHaveBeenCalledWith
(
expect
.
objectContaining
({
expect
.
objectContaining
({
groupSort
:
p
ayload
.
sort
,
groupSort
:
searchP
ayload
.
sort
,
...
p
ayload
.
filters
,
...
searchP
ayload
.
filters
,
}),
}),
);
);
});
});
});
});
describe
(
'
list component
'
,
()
=>
{
let
resolver
;
beforeEach
(()
=>
{
resolver
=
jest
.
fn
().
mockResolvedValue
(
packagesListQuery
());
mountComponent
({
resolver
});
return
waitForDebouncedApollo
();
});
it
(
'
exists and has the right props
'
,
()
=>
{
expect
(
findListComponent
().
props
()).
toMatchObject
({
list
:
expect
.
arrayContaining
([
expect
.
objectContaining
({
id
:
packageData
().
id
})]),
isLoading
:
false
,
pageInfo
:
expect
.
objectContaining
({
endCursor
:
pagination
().
endCursor
}),
});
});
it
(
'
when list emits next-page fetches the next set of records
'
,
()
=>
{
findListComponent
().
vm
.
$emit
(
'
next-page
'
);
expect
(
resolver
).
toHaveBeenCalledWith
(
expect
.
objectContaining
({
after
:
pagination
().
endCursor
,
first
:
GRAPHQL_PAGE_SIZE
}),
);
});
it
(
'
when list emits prev-page fetches the prev set of records
'
,
()
=>
{
findListComponent
().
vm
.
$emit
(
'
prev-page
'
);
expect
(
resolver
).
toHaveBeenCalledWith
(
expect
.
objectContaining
({
before
:
pagination
().
startCursor
,
last
:
GRAPHQL_PAGE_SIZE
}),
);
});
});
describe
.
each
`
describe
.
each
`
type | sortType
type | sortType
${
PROJECT_RESOURCE_TYPE
}
|
${
'
sort
'
}
${
PROJECT_RESOURCE_TYPE
}
|
${
'
sort
'
}
...
@@ -136,7 +177,7 @@ describe('PackagesListApp', () => {
...
@@ -136,7 +177,7 @@ describe('PackagesListApp', () => {
beforeEach
(()
=>
{
beforeEach
(()
=>
{
provide
=
{
...
defaultProvide
,
isGroupPage
};
provide
=
{
...
defaultProvide
,
isGroupPage
};
resolver
=
jest
.
fn
().
mockResolvedValue
(
packagesListQuery
(
type
));
resolver
=
jest
.
fn
().
mockResolvedValue
(
packagesListQuery
(
{
type
}
));
mountComponent
({
provide
,
resolver
});
mountComponent
({
provide
,
resolver
});
return
waitForDebouncedApollo
();
return
waitForDebouncedApollo
();
});
});
...
@@ -151,4 +192,40 @@ describe('PackagesListApp', () => {
...
@@ -151,4 +192,40 @@ describe('PackagesListApp', () => {
);
);
});
});
});
});
describe
(
'
empty state
'
,
()
=>
{
beforeEach
(()
=>
{
const
resolver
=
jest
.
fn
().
mockResolvedValue
(
packagesListQuery
({
extend
:
{
nodes
:
[]
}
}));
mountComponent
({
resolver
});
return
waitForDebouncedApollo
();
});
it
(
'
generate the correct empty list link
'
,
()
=>
{
const
link
=
findListComponent
().
findComponent
(
GlLink
);
expect
(
link
.
attributes
(
'
href
'
)).
toBe
(
defaultProvide
.
emptyListHelpUrl
);
expect
(
link
.
text
()).
toBe
(
'
publish and share your packages
'
);
});
it
(
'
includes the right content on the default tab
'
,
()
=>
{
expect
(
findEmptyState
().
text
()).
toContain
(
PackageListApp
.
i18n
.
emptyPageTitle
);
});
});
describe
(
'
filter without results
'
,
()
=>
{
beforeEach
(
async
()
=>
{
mountComponent
();
await
waitForDebouncedApollo
();
findSearch
().
vm
.
$emit
(
'
update
'
,
searchPayload
);
return
nextTick
();
});
it
(
'
should show specific empty message
'
,
()
=>
{
expect
(
findEmptyState
().
text
()).
toContain
(
PackageListApp
.
i18n
.
noResultsTitle
);
expect
(
findEmptyState
().
text
()).
toContain
(
PackageListApp
.
i18n
.
widenFilters
);
});
});
});
});
spec/frontend/packages_and_registries/package_registry/components/list/packages_list_spec.js
View file @
a797d196
import
{
GlTable
,
GlPagination
,
GlModal
}
from
'
@gitlab/ui
'
;
import
{
GlKeysetPagination
,
GlModal
,
GlSprintf
}
from
'
@gitlab/ui
'
;
import
{
mount
,
createLocalVue
}
from
'
@vue/test-utils
'
;
import
{
nextTick
}
from
'
vue
'
;
import
{
last
}
from
'
lodash
'
;
import
{
shallowMountExtended
}
from
'
helpers/vue_test_utils_helper
'
;
import
Vuex
from
'
vuex
'
;
import
stubChildren
from
'
helpers/stub_children
'
;
import
{
packageList
}
from
'
jest/packages/mock_data
'
;
import
PackagesListRow
from
'
~/packages/shared/components/package_list_row.vue
'
;
import
PackagesListRow
from
'
~/packages/shared/components/package_list_row.vue
'
;
import
PackagesListLoader
from
'
~/packages/shared/components/packages_list_loader.vue
'
;
import
PackagesListLoader
from
'
~/packages/shared/components/packages_list_loader.vue
'
;
import
{
TrackingActions
}
from
'
~/packages/shared/constants
'
;
import
{
import
*
as
SharedUtils
from
'
~/packages/shared/utils
'
;
DELETE_PACKAGE_TRACKING_ACTION
,
REQUEST_DELETE_PACKAGE_TRACKING_ACTION
,
CANCEL_DELETE_PACKAGE_TRACKING_ACTION
,
}
from
'
~/packages_and_registries/package_registry/constants
'
;
import
PackagesList
from
'
~/packages_and_registries/package_registry/components/list/packages_list.vue
'
;
import
PackagesList
from
'
~/packages_and_registries/package_registry/components/list/packages_list.vue
'
;
import
Tracking
from
'
~/tracking
'
;
import
Tracking
from
'
~/tracking
'
;
import
{
packageData
}
from
'
../../mock_data
'
;
const
localVue
=
createLocalVue
();
localVue
.
use
(
Vuex
);
describe
(
'
packages_list
'
,
()
=>
{
describe
(
'
packages_list
'
,
()
=>
{
let
wrapper
;
let
wrapper
;
let
store
;
const
firstPackage
=
packageData
();
const
secondPackage
=
{
...
packageData
(),
id
:
'
gid://gitlab/Packages::Package/112
'
,
name
:
'
second-package
'
,
};
const
defaultProps
=
{
list
:
[
firstPackage
,
secondPackage
],
isLoading
:
false
,
pageInfo
:
{},
};
const
EmptySlotStub
=
{
name
:
'
empty-slot-stub
'
,
template
:
'
<div>bar</div>
'
};
const
EmptySlotStub
=
{
name
:
'
empty-slot-stub
'
,
template
:
'
<div>bar</div>
'
};
const
GlModalStub
=
{
name
:
GlModal
.
name
,
template
:
'
<div><slot></slot></div>
'
,
methods
:
{
show
:
jest
.
fn
()
},
};
const
findPackagesListLoader
=
()
=>
wrapper
.
find
(
PackagesListLoader
);
const
findPackagesListLoader
=
()
=>
wrapper
.
findComponent
(
PackagesListLoader
);
const
findPackageListPagination
=
()
=>
wrapper
.
find
(
GlPagination
);
const
findPackageListPagination
=
()
=>
wrapper
.
findComponent
(
GlKeysetPagination
);
const
findPackageListDeleteModal
=
()
=>
wrapper
.
find
(
GlModal
);
const
findPackageListDeleteModal
=
()
=>
wrapper
.
findComponent
(
GlModalStub
);
const
findEmptySlot
=
()
=>
wrapper
.
find
(
EmptySlotStub
);
const
findEmptySlot
=
()
=>
wrapper
.
findComponent
(
EmptySlotStub
);
const
findPackagesListRow
=
()
=>
wrapper
.
find
(
PackagesListRow
);
const
findPackagesListRow
=
()
=>
wrapper
.
findComponent
(
PackagesListRow
);
const
createStore
=
(
isGroupPage
,
packages
,
isLoading
)
=>
{
const
mountComponent
=
(
props
)
=>
{
const
state
=
{
wrapper
=
shallowMountExtended
(
PackagesList
,
{
isLoading
,
propsData
:
{
packages
,
...
defaultProps
,
pagination
:
{
...
props
,
perPage
:
1
,
total
:
1
,
page
:
1
,
},
},
config
:
{
stubs
:
{
isGroupPage
,
GlModal
:
GlModalStub
,
},
GlSprintf
,
sorting
:
{
orderBy
:
'
version
'
,
sort
:
'
desc
'
,
},
},
};
slots
:
{
store
=
new
Vuex
.
Store
({
'
empty-state
'
:
EmptySlotStub
,
state
,
getters
:
{
getList
:
()
=>
packages
,
},
},
});
});
store
.
dispatch
=
jest
.
fn
();
};
};
const
mountComponent
=
({
beforeEach
(()
=>
{
isGroupPage
=
false
,
GlModalStub
.
methods
.
show
.
mockReset
();
packages
=
packageList
,
isLoading
=
false
,
...
options
}
=
{})
=>
{
createStore
(
isGroupPage
,
packages
,
isLoading
);
wrapper
=
mount
(
PackagesList
,
{
localVue
,
store
,
stubs
:
{
...
stubChildren
(
PackagesList
),
GlTable
,
GlModal
,
},
...
options
,
});
});
};
afterEach
(()
=>
{
afterEach
(()
=>
{
wrapper
.
destroy
();
wrapper
.
destroy
();
wrapper
=
null
;
});
});
describe
(
'
when is loading
'
,
()
=>
{
describe
(
'
when is loading
'
,
()
=>
{
beforeEach
(()
=>
{
beforeEach
(()
=>
{
mountComponent
({
mountComponent
({
isLoading
:
true
});
packages
:
[],
isLoading
:
true
,
});
});
});
it
(
'
shows skeleton loader
when loading
'
,
()
=>
{
it
(
'
shows skeleton loader
'
,
()
=>
{
expect
(
findPackagesListLoader
().
exists
()).
toBe
(
true
);
expect
(
findPackagesListLoader
().
exists
()).
toBe
(
true
);
});
});
it
(
'
does not show the rows
'
,
()
=>
{
expect
(
findPackagesListRow
().
exists
()).
toBe
(
false
);
});
it
(
'
does not show the pagination
'
,
()
=>
{
expect
(
findPackageListPagination
().
exists
()).
toBe
(
false
);
});
});
});
describe
(
'
when is not loading
'
,
()
=>
{
describe
(
'
when is not loading
'
,
()
=>
{
...
@@ -95,74 +88,68 @@ describe('packages_list', () => {
...
@@ -95,74 +88,68 @@ describe('packages_list', () => {
mountComponent
();
mountComponent
();
});
});
it
(
'
does not show skeleton loader
when not loading
'
,
()
=>
{
it
(
'
does not show skeleton loader
'
,
()
=>
{
expect
(
findPackagesListLoader
().
exists
()).
toBe
(
false
);
expect
(
findPackagesListLoader
().
exists
()).
toBe
(
false
);
});
});
});
describe
(
'
layout
'
,
()
=>
{
it
(
'
shows the rows
'
,
()
=>
{
beforeEach
(()
=>
{
expect
(
findPackagesListRow
().
exists
()).
toBe
(
true
);
mountComponent
(
);
}
);
});
});
describe
(
'
layout
'
,
()
=>
{
it
(
'
contains a pagination component
'
,
()
=>
{
it
(
'
contains a pagination component
'
,
()
=>
{
const
sorting
=
findPackageListPagination
();
mountComponent
({
pageInfo
:
{
hasPreviousPage
:
true
}
});
expect
(
sorting
.
exists
()).
toBe
(
true
);
expect
(
findPackageListPagination
().
exists
()).
toBe
(
true
);
});
});
it
(
'
contains a modal component
'
,
()
=>
{
it
(
'
contains a modal component
'
,
()
=>
{
const
sorting
=
findPackageListDeleteModal
();
mountComponent
();
expect
(
sorting
.
exists
()).
toBe
(
true
);
expect
(
findPackageListDeleteModal
().
exists
()).
toBe
(
true
);
});
});
});
});
describe
(
'
when the user can destroy the package
'
,
()
=>
{
describe
(
'
when the user can destroy the package
'
,
()
=>
{
beforeEach
(()
=>
{
beforeEach
(()
=>
{
mountComponent
();
mountComponent
();
findPackagesListRow
().
vm
.
$emit
(
'
packageToDelete
'
,
firstPackage
);
return
nextTick
();
});
});
it
(
'
setItemToBeDeleted sets itemToBeDeleted and open
the modal
'
,
()
=>
{
it
(
'
deleting a package opens
the modal
'
,
()
=>
{
const
mockModalShow
=
jest
.
spyOn
(
wrapper
.
vm
.
$refs
.
packageListDeleteModal
,
'
show
'
);
expect
(
findPackageListDeleteModal
().
text
()).
toContain
(
firstPackage
.
name
);
const
item
=
last
(
wrapper
.
vm
.
list
);
}
);
findPackagesListRow
().
vm
.
$emit
(
'
packageToDelete
'
,
item
);
it
(
'
confirming delete empties itemsToBeDeleted
'
,
async
()
=>
{
findPackageListDeleteModal
().
vm
.
$emit
(
'
ok
'
);
return
wrapper
.
vm
.
$nextTick
().
then
(()
=>
{
await
nextTick
();
expect
(
wrapper
.
vm
.
itemToBeDeleted
).
toEqual
(
item
);
expect
(
mockModalShow
).
toHaveBeenCalled
();
});
});
it
(
'
deleteItemConfirmation resets itemToBeDeleted
'
,
()
=>
{
expect
(
findPackageListDeleteModal
().
text
()).
not
.
toContain
(
firstPackage
.
name
);
wrapper
.
setData
({
itemToBeDeleted
:
1
});
wrapper
.
vm
.
deleteItemConfirmation
();
expect
(
wrapper
.
vm
.
itemToBeDeleted
).
toEqual
(
null
);
});
});
it
(
'
deleteItemConfirmation emit package:delete
'
,
()
=>
{
it
(
'
confirming on the modal emits package:delete
'
,
async
()
=>
{
const
itemToBeDeleted
=
{
id
:
2
};
findPackageListDeleteModal
().
vm
.
$emit
(
'
ok
'
);
wrapper
.
setData
({
itemToBeDeleted
});
wrapper
.
vm
.
deleteItemConfirmation
();
await
nextTick
();
return
wrapper
.
vm
.
$nextTick
(()
=>
{
expect
(
wrapper
.
emitted
(
'
package:delete
'
)[
0
]).
toEqual
([
itemToBeDeleted
]);
expect
(
wrapper
.
emitted
(
'
package:delete
'
)[
0
]).
toEqual
([
firstPackage
]);
});
});
});
it
(
'
deleteItemCanceled resets itemToBeDeleted
'
,
()
=>
{
it
(
'
cancel event resets itemToBeDeleted
'
,
async
()
=>
{
wrapper
.
setData
({
itemToBeDeleted
:
1
});
findPackageListDeleteModal
().
vm
.
$emit
(
'
cancel
'
);
wrapper
.
vm
.
deleteItemCanceled
();
expect
(
wrapper
.
vm
.
itemToBeDeleted
).
toEqual
(
null
);
await
nextTick
();
expect
(
findPackageListDeleteModal
().
text
()).
not
.
toContain
(
firstPackage
.
name
);
});
});
});
});
describe
(
'
when the list is empty
'
,
()
=>
{
describe
(
'
when the list is empty
'
,
()
=>
{
beforeEach
(()
=>
{
beforeEach
(()
=>
{
mountComponent
({
mountComponent
({
list
:
[]
});
packages
:
[],
slots
:
{
'
empty-state
'
:
EmptySlotStub
,
},
});
});
});
it
(
'
show the empty slot
'
,
()
=>
{
it
(
'
show the empty slot
'
,
()
=>
{
...
@@ -171,45 +158,59 @@ describe('packages_list', () => {
...
@@ -171,45 +158,59 @@ describe('packages_list', () => {
});
});
});
});
describe
(
'
pagination component
'
,
()
=>
{
describe
(
'
pagination
'
,
()
=>
{
let
pagination
;
let
modelEvent
;
beforeEach
(()
=>
{
beforeEach
(()
=>
{
mountComponent
();
mountComponent
({
pageInfo
:
{
hasPreviousPage
:
true
}
});
pagination
=
findPackageListPagination
();
});
// retrieve the event used by v-model, a more sturdy approach than hardcoding it
modelEvent
=
pagination
.
vm
.
$options
.
model
.
event
;
it
(
'
emits prev-page events when the prev event is fired
'
,
()
=>
{
findPackageListPagination
().
vm
.
$emit
(
'
prev
'
);
expect
(
wrapper
.
emitted
(
'
prev-page
'
)).
toEqual
([[]]);
});
});
it
(
'
emits page:changed events when the page changes
'
,
()
=>
{
it
(
'
emits next-page events when the next event is fired
'
,
()
=>
{
pagination
.
vm
.
$emit
(
modelEvent
,
2
);
findPackageListPagination
().
vm
.
$emit
(
'
next
'
);
expect
(
wrapper
.
emitted
(
'
page:changed
'
)).
toEqual
([[
2
]]);
expect
(
wrapper
.
emitted
(
'
next-page
'
)).
toEqual
([[]]);
});
});
});
});
describe
(
'
tracking
'
,
()
=>
{
describe
(
'
tracking
'
,
()
=>
{
let
eventSpy
;
let
eventSpy
;
let
utilSpy
;
const
category
=
'
UI::NpmPackages
'
;
const
category
=
'
foo
'
;
beforeEach
(()
=>
{
beforeEach
(()
=>
{
mountComponent
();
eventSpy
=
jest
.
spyOn
(
Tracking
,
'
event
'
);
eventSpy
=
jest
.
spyOn
(
Tracking
,
'
event
'
);
utilSpy
=
jest
.
spyOn
(
SharedUtils
,
'
packageTypeToTrackCategory
'
).
mockReturnValue
(
category
);
mountComponent
();
wrapper
.
setData
({
itemToBeDeleted
:
{
package_type
:
'
conan
'
}
});
findPackagesListRow
().
vm
.
$emit
(
'
packageToDelete
'
,
firstPackage
);
return
nextTick
();
});
});
it
(
'
tracking category calls packageTypeToTrackCategory
'
,
()
=>
{
it
(
'
requesting the delete tracks the right action
'
,
()
=>
{
expect
(
wrapper
.
vm
.
tracking
.
category
).
toBe
(
category
);
expect
(
eventSpy
).
toHaveBeenCalledWith
(
expect
(
utilSpy
).
toHaveBeenCalledWith
(
'
conan
'
);
category
,
REQUEST_DELETE_PACKAGE_TRACKING_ACTION
,
expect
.
any
(
Object
),
);
});
});
it
(
'
deleteItemConfirmation calls event
'
,
()
=>
{
it
(
'
confirming delete tracks the right action
'
,
()
=>
{
wrapper
.
vm
.
deleteItemConfirmation
();
findPackageListDeleteModal
().
vm
.
$emit
(
'
ok
'
);
expect
(
eventSpy
).
toHaveBeenCalledWith
(
category
,
DELETE_PACKAGE_TRACKING_ACTION
,
expect
.
any
(
Object
),
);
});
it
(
'
canceling delete tracks the right action
'
,
()
=>
{
findPackageListDeleteModal
().
vm
.
$emit
(
'
cancel
'
);
expect
(
eventSpy
).
toHaveBeenCalledWith
(
expect
(
eventSpy
).
toHaveBeenCalledWith
(
category
,
category
,
TrackingActions
.
DELETE_PACKAGE
,
CANCEL_DELETE_PACKAGE_TRACKING_ACTION
,
expect
.
any
(
Object
),
expect
.
any
(
Object
),
);
);
});
});
...
...
spec/frontend/packages_and_registries/package_registry/mock_data.js
View file @
a797d196
import
capitalize
from
'
lodash/capitalize
'
;
export
const
packageTags
=
()
=>
[
export
const
packageTags
=
()
=>
[
{
id
:
'
gid://gitlab/Packages::Tag/87
'
,
name
:
'
bananas_9
'
,
__typename
:
'
PackageTag
'
},
{
id
:
'
gid://gitlab/Packages::Tag/87
'
,
name
:
'
bananas_9
'
,
__typename
:
'
PackageTag
'
},
{
id
:
'
gid://gitlab/Packages::Tag/86
'
,
name
:
'
bananas_8
'
,
__typename
:
'
PackageTag
'
},
{
id
:
'
gid://gitlab/Packages::Tag/86
'
,
name
:
'
bananas_8
'
,
__typename
:
'
PackageTag
'
},
...
@@ -156,6 +158,15 @@ export const nugetMetadata = () => ({
...
@@ -156,6 +158,15 @@ export const nugetMetadata = () => ({
projectUrl
:
'
projectUrl
'
,
projectUrl
:
'
projectUrl
'
,
});
});
export
const
pagination
=
(
extend
)
=>
({
endCursor
:
'
eyJpZCI6IjIwNSIsIm5hbWUiOiJteS9jb21wYW55L2FwcC9teS1hcHAifQ
'
,
hasNextPage
:
true
,
hasPreviousPage
:
true
,
startCursor
:
'
eyJpZCI6IjI0NyIsIm5hbWUiOiJ2ZXJzaW9uX3Rlc3QxIn0
'
,
__typename
:
'
PageInfo
'
,
...
extend
,
});
export
const
packageDetailsQuery
=
(
extendPackage
)
=>
({
export
const
packageDetailsQuery
=
(
extendPackage
)
=>
({
data
:
{
data
:
{
package
:
{
package
:
{
...
@@ -256,7 +267,7 @@ export const packageDestroyFileMutationError = () => ({
...
@@ -256,7 +267,7 @@ export const packageDestroyFileMutationError = () => ({
],
],
});
});
export
const
packagesListQuery
=
(
type
=
'
group
'
)
=>
({
export
const
packagesListQuery
=
(
{
type
=
'
group
'
,
extend
=
{},
extendPagination
=
{}
}
=
{}
)
=>
({
data
:
{
data
:
{
[
type
]:
{
[
type
]:
{
packages
:
{
packages
:
{
...
@@ -277,9 +288,11 @@ export const packagesListQuery = (type = 'group') => ({
...
@@ -277,9 +288,11 @@ export const packagesListQuery = (type = 'group') => ({
pipelines
:
{
nodes
:
[]
},
pipelines
:
{
nodes
:
[]
},
},
},
],
],
pageInfo
:
pagination
(
extendPagination
),
__typename
:
'
PackageConnection
'
,
__typename
:
'
PackageConnection
'
,
},
},
__typename
:
'
Group
'
,
...
extend
,
__typename
:
capitalize
(
type
),
},
},
},
},
});
});
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