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
237f434c
Commit
237f434c
authored
Jul 18, 2019
by
Nick Kipling
Committed by
Nathan Friend
Jul 30, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updating with suggestions as per review
parent
b5d50025
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
58 additions
and
32 deletions
+58
-32
app/assets/javascripts/registry/components/table_registry.vue
...assets/javascripts/registry/components/table_registry.vue
+5
-2
spec/javascripts/registry/components/table_registry_spec.js
spec/javascripts/registry/components/table_registry_spec.js
+53
-30
No files found.
app/assets/javascripts/registry/components/table_registry.vue
View file @
237f434c
...
...
@@ -52,7 +52,7 @@ export default {
return
this
.
repo
.
pagination
.
total
>
this
.
repo
.
pagination
.
perPage
;
},
modalTitle
()
{
if
(
this
.
singleItem
ToBeDeleted
!==
null
||
this
.
itemsToBeDeleted
.
length
===
1
)
{
if
(
this
.
singleItem
Selected
)
{
return
s__
(
'
ContainerRegistry|Remove image
'
);
}
return
s__
(
'
ContainerRegistry|Remove images
'
);
...
...
@@ -60,7 +60,7 @@ export default {
modalDescription
()
{
const
selectedCount
=
this
.
itemsToBeDeleted
.
length
;
if
(
this
.
singleItem
ToBeDeleted
!==
null
||
selectedCount
===
1
)
{
if
(
this
.
singleItem
Selected
)
{
const
{
tag
}
=
this
.
singleItemToBeDeleted
!==
null
?
this
.
repo
.
list
[
this
.
singleItemToBeDeleted
]
...
...
@@ -79,6 +79,9 @@ export default {
{
count
:
selectedCount
},
);
},
singleItemSelected
()
{
return
this
.
singleItemToBeDeleted
!==
null
||
this
.
itemsToBeDeleted
.
length
===
1
;
},
},
methods
:
{
...
mapActions
([
'
fetchList
'
,
'
deleteItems
'
]),
...
...
spec/javascripts/registry/components/table_registry_spec.js
View file @
237f434c
import
Vue
from
'
vue
'
;
import
tableRegistry
from
'
~/registry/components/table_registry.vue
'
;
import
store
from
'
~/registry/stores
'
;
import
{
mountComponentWithStore
}
from
'
spec/helpers/vue_mount_component_helper
'
;
import
{
repoPropsData
}
from
'
../mock_data
'
;
const
[
firstImage
,
secondImage
]
=
repoPropsData
.
list
;
describe
(
'
table registry
'
,
()
=>
{
let
vm
;
let
Component
;
const
Component
=
Vue
.
extend
(
tableRegistry
)
;
const
bulkDeletePath
=
'
path
'
;
const
findDeleteBtn
=
()
=>
vm
.
$el
.
querySelector
(
'
.js-delete-registry
'
);
...
...
@@ -15,17 +16,19 @@ describe('table registry', () => {
const
findSelectAllCheckbox
=
()
=>
vm
.
$el
.
querySelector
(
'
.js-select-all-checkbox > input
'
);
const
findAllRowCheckboxes
=
()
=>
Array
.
from
(
vm
.
$el
.
querySelectorAll
(
'
.js-select-checkbox input
'
));
const
confirmationModal
=
(
child
=
''
)
=>
document
.
querySelector
(
`#
${
vm
.
modalId
}
${
child
}
`
);
const
createComponent
=
()
=>
{
Component
=
Vue
.
extend
(
tableRegistry
);
vm
=
new
Component
({
vm
=
mountComponentWithStore
(
Component
,
{
store
,
props
Data
:
{
props
:
{
repo
:
repoPropsData
,
},
})
.
$mount
()
;
});
};
const
toggleSelectAll
=
()
=>
vm
.
selectAll
();
beforeEach
(()
=>
{
createComponent
();
});
...
...
@@ -34,31 +37,28 @@ describe('table registry', () => {
vm
.
$destroy
();
});
it
(
'
should render a table with the registry list
'
,
()
=>
{
expect
(
vm
.
$el
.
querySelectorAll
(
'
table tbody tr
'
).
length
).
toEqual
(
repoPropsData
.
list
.
length
);
});
describe
(
'
rendering
'
,
()
=>
{
it
(
'
should render a table with the registry list
'
,
()
=>
{
expect
(
vm
.
$el
.
querySelectorAll
(
'
table tbody tr
'
).
length
).
toEqual
(
repoPropsData
.
list
.
length
);
});
it
(
'
should render registry tag
'
,
()
=>
{
const
textRendered
=
vm
.
$el
.
querySelector
(
'
.table tbody tr
'
)
.
textContent
.
trim
()
.
replace
(
/
\s\s
+/g
,
'
'
);
it
(
'
should render registry tag
'
,
()
=>
{
const
textRendered
=
vm
.
$el
.
querySelector
(
'
.table tbody tr
'
)
.
textContent
.
trim
()
.
replace
(
/
\s\s
+/g
,
'
'
);
expect
(
textRendered
).
toContain
(
repoPropsData
.
list
[
0
].
tag
);
expect
(
textRendered
).
toContain
(
repoPropsData
.
list
[
0
].
shortRevision
);
expect
(
textRendered
).
toContain
(
repoPropsData
.
list
[
0
].
layers
);
expect
(
textRendered
).
toContain
(
repoPropsData
.
list
[
0
].
size
);
expect
(
textRendered
).
toContain
(
repoPropsData
.
list
[
0
].
tag
);
expect
(
textRendered
).
toContain
(
repoPropsData
.
list
[
0
].
shortRevision
);
expect
(
textRendered
).
toContain
(
repoPropsData
.
list
[
0
].
layers
);
expect
(
textRendered
).
toContain
(
repoPropsData
.
list
[
0
].
size
);
});
});
describe
(
'
multi select
'
,
()
=>
{
beforeEach
(()
=>
{
vm
.
itemsToBeDeleted
=
[];
});
it
(
'
should support multiselect and selecting a row should enable delete button
'
,
done
=>
{
findSelectAllCheckbox
().
click
();
vm
.
selectAll
();
toggleSelectAll
();
expect
(
findSelectAllCheckbox
().
checked
).
toBe
(
true
);
...
...
@@ -70,7 +70,7 @@ describe('table registry', () => {
it
(
'
selecting all checkbox should select all rows and enable delete button
'
,
done
=>
{
findSelectAllCheckbox
().
click
();
vm
.
s
electAll
();
toggleS
electAll
();
Vue
.
nextTick
(()
=>
{
const
checkedValues
=
findAllRowCheckboxes
().
filter
(
x
=>
x
.
checked
);
...
...
@@ -82,8 +82,8 @@ describe('table registry', () => {
it
(
'
deselecting select all checkbox should deselect all rows and disable delete button
'
,
done
=>
{
findSelectAllCheckbox
().
click
();
vm
.
s
electAll
();
// Select them all on
vm
.
s
electAll
();
// Select them all off
toggleS
electAll
();
// Select them all on
toggleS
electAll
();
// Select them all off
Vue
.
nextTick
(()
=>
{
const
checkedValues
=
findAllRowCheckboxes
().
filter
(
x
=>
x
.
checked
);
...
...
@@ -95,7 +95,7 @@ describe('table registry', () => {
it
(
'
should delete multiple items when multiple items are selected
'
,
done
=>
{
findSelectAllCheckbox
().
click
();
vm
.
s
electAll
();
toggleS
electAll
();
Vue
.
nextTick
(()
=>
{
expect
(
vm
.
itemsToBeDeleted
).
toEqual
([
0
,
1
]);
...
...
@@ -105,8 +105,8 @@ describe('table registry', () => {
spyOn
(
vm
,
'
deleteItems
'
).
and
.
returnValue
(
Promise
.
resolve
());
Vue
.
nextTick
(()
=>
{
const
modal
=
document
.
querySelector
(
`#
${
vm
.
modalId
}
`
);
document
.
querySelector
(
`#
${
vm
.
modalId
}
.btn-danger`
).
click
();
const
modal
=
confirmationModal
(
);
confirmationModal
(
'
.btn-danger
'
).
click
();
expect
(
modal
).
toExist
();
...
...
@@ -146,7 +146,7 @@ describe('table registry', () => {
spyOn
(
vm
,
'
deleteItems
'
).
and
.
returnValue
(
Promise
.
resolve
());
Vue
.
nextTick
(()
=>
{
document
.
querySelector
(
`#
${
vm
.
modalId
}
.btn-danger`
).
click
();
confirmationModal
(
'
.btn-danger
'
).
click
();
expect
(
vm
.
itemsToBeDeleted
).
toEqual
([]);
expect
(
vm
.
deleteItems
).
toHaveBeenCalledWith
({
...
...
@@ -164,4 +164,27 @@ describe('table registry', () => {
expect
(
vm
.
$el
.
querySelector
(
'
.gl-pagination
'
)).
toBeDefined
();
});
});
describe
(
'
modal content
'
,
()
=>
{
it
(
'
should show the singular title and image name when deleting a single image
'
,
done
=>
{
findDeleteBtnRow
().
click
();
Vue
.
nextTick
(()
=>
{
expect
(
vm
.
modalTitle
).
toBe
(
'
Remove image
'
);
expect
(
vm
.
modalDescription
).
toContain
(
firstImage
.
tag
);
done
();
});
});
it
(
'
should show the plural title and image count when deleting more than one image
'
,
done
=>
{
findSelectAllCheckbox
().
click
();
toggleSelectAll
();
Vue
.
nextTick
(()
=>
{
expect
(
vm
.
modalTitle
).
toBe
(
'
Remove images
'
);
expect
(
vm
.
modalDescription
).
toContain
(
'
<b>2</b> images
'
);
done
();
});
});
});
});
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