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
Show 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 {
...
@@ -52,7 +52,7 @@ export default {
return
this
.
repo
.
pagination
.
total
>
this
.
repo
.
pagination
.
perPage
;
return
this
.
repo
.
pagination
.
total
>
this
.
repo
.
pagination
.
perPage
;
},
},
modalTitle
()
{
modalTitle
()
{
if
(
this
.
singleItem
ToBeDeleted
!==
null
||
this
.
itemsToBeDeleted
.
length
===
1
)
{
if
(
this
.
singleItem
Selected
)
{
return
s__
(
'
ContainerRegistry|Remove image
'
);
return
s__
(
'
ContainerRegistry|Remove image
'
);
}
}
return
s__
(
'
ContainerRegistry|Remove images
'
);
return
s__
(
'
ContainerRegistry|Remove images
'
);
...
@@ -60,7 +60,7 @@ export default {
...
@@ -60,7 +60,7 @@ export default {
modalDescription
()
{
modalDescription
()
{
const
selectedCount
=
this
.
itemsToBeDeleted
.
length
;
const
selectedCount
=
this
.
itemsToBeDeleted
.
length
;
if
(
this
.
singleItem
ToBeDeleted
!==
null
||
selectedCount
===
1
)
{
if
(
this
.
singleItem
Selected
)
{
const
{
tag
}
=
const
{
tag
}
=
this
.
singleItemToBeDeleted
!==
null
this
.
singleItemToBeDeleted
!==
null
?
this
.
repo
.
list
[
this
.
singleItemToBeDeleted
]
?
this
.
repo
.
list
[
this
.
singleItemToBeDeleted
]
...
@@ -79,6 +79,9 @@ export default {
...
@@ -79,6 +79,9 @@ export default {
{
count
:
selectedCount
},
{
count
:
selectedCount
},
);
);
},
},
singleItemSelected
()
{
return
this
.
singleItemToBeDeleted
!==
null
||
this
.
itemsToBeDeleted
.
length
===
1
;
},
},
},
methods
:
{
methods
:
{
...
mapActions
([
'
fetchList
'
,
'
deleteItems
'
]),
...
mapActions
([
'
fetchList
'
,
'
deleteItems
'
]),
...
...
spec/javascripts/registry/components/table_registry_spec.js
View file @
237f434c
import
Vue
from
'
vue
'
;
import
Vue
from
'
vue
'
;
import
tableRegistry
from
'
~/registry/components/table_registry.vue
'
;
import
tableRegistry
from
'
~/registry/components/table_registry.vue
'
;
import
store
from
'
~/registry/stores
'
;
import
store
from
'
~/registry/stores
'
;
import
{
mountComponentWithStore
}
from
'
spec/helpers/vue_mount_component_helper
'
;
import
{
repoPropsData
}
from
'
../mock_data
'
;
import
{
repoPropsData
}
from
'
../mock_data
'
;
const
[
firstImage
,
secondImage
]
=
repoPropsData
.
list
;
const
[
firstImage
,
secondImage
]
=
repoPropsData
.
list
;
describe
(
'
table registry
'
,
()
=>
{
describe
(
'
table registry
'
,
()
=>
{
let
vm
;
let
vm
;
let
Component
;
const
Component
=
Vue
.
extend
(
tableRegistry
)
;
const
bulkDeletePath
=
'
path
'
;
const
bulkDeletePath
=
'
path
'
;
const
findDeleteBtn
=
()
=>
vm
.
$el
.
querySelector
(
'
.js-delete-registry
'
);
const
findDeleteBtn
=
()
=>
vm
.
$el
.
querySelector
(
'
.js-delete-registry
'
);
...
@@ -15,17 +16,19 @@ describe('table registry', () => {
...
@@ -15,17 +16,19 @@ describe('table registry', () => {
const
findSelectAllCheckbox
=
()
=>
vm
.
$el
.
querySelector
(
'
.js-select-all-checkbox > input
'
);
const
findSelectAllCheckbox
=
()
=>
vm
.
$el
.
querySelector
(
'
.js-select-all-checkbox > input
'
);
const
findAllRowCheckboxes
=
()
=>
const
findAllRowCheckboxes
=
()
=>
Array
.
from
(
vm
.
$el
.
querySelectorAll
(
'
.js-select-checkbox input
'
));
Array
.
from
(
vm
.
$el
.
querySelectorAll
(
'
.js-select-checkbox input
'
));
const
confirmationModal
=
(
child
=
''
)
=>
document
.
querySelector
(
`#
${
vm
.
modalId
}
${
child
}
`
);
const
createComponent
=
()
=>
{
const
createComponent
=
()
=>
{
Component
=
Vue
.
extend
(
tableRegistry
);
vm
=
mountComponentWithStore
(
Component
,
{
vm
=
new
Component
({
store
,
store
,
props
Data
:
{
props
:
{
repo
:
repoPropsData
,
repo
:
repoPropsData
,
},
},
})
.
$mount
()
;
});
};
};
const
toggleSelectAll
=
()
=>
vm
.
selectAll
();
beforeEach
(()
=>
{
beforeEach
(()
=>
{
createComponent
();
createComponent
();
});
});
...
@@ -34,6 +37,7 @@ describe('table registry', () => {
...
@@ -34,6 +37,7 @@ describe('table registry', () => {
vm
.
$destroy
();
vm
.
$destroy
();
});
});
describe
(
'
rendering
'
,
()
=>
{
it
(
'
should render a table with the registry list
'
,
()
=>
{
it
(
'
should render a table with the registry list
'
,
()
=>
{
expect
(
vm
.
$el
.
querySelectorAll
(
'
table tbody tr
'
).
length
).
toEqual
(
repoPropsData
.
list
.
length
);
expect
(
vm
.
$el
.
querySelectorAll
(
'
table tbody tr
'
).
length
).
toEqual
(
repoPropsData
.
list
.
length
);
});
});
...
@@ -49,16 +53,12 @@ describe('table registry', () => {
...
@@ -49,16 +53,12 @@ describe('table registry', () => {
expect
(
textRendered
).
toContain
(
repoPropsData
.
list
[
0
].
layers
);
expect
(
textRendered
).
toContain
(
repoPropsData
.
list
[
0
].
layers
);
expect
(
textRendered
).
toContain
(
repoPropsData
.
list
[
0
].
size
);
expect
(
textRendered
).
toContain
(
repoPropsData
.
list
[
0
].
size
);
});
});
describe
(
'
multi select
'
,
()
=>
{
beforeEach
(()
=>
{
vm
.
itemsToBeDeleted
=
[];
});
});
describe
(
'
multi select
'
,
()
=>
{
it
(
'
should support multiselect and selecting a row should enable delete button
'
,
done
=>
{
it
(
'
should support multiselect and selecting a row should enable delete button
'
,
done
=>
{
findSelectAllCheckbox
().
click
();
findSelectAllCheckbox
().
click
();
toggleSelectAll
();
vm
.
selectAll
();
expect
(
findSelectAllCheckbox
().
checked
).
toBe
(
true
);
expect
(
findSelectAllCheckbox
().
checked
).
toBe
(
true
);
...
@@ -70,7 +70,7 @@ describe('table registry', () => {
...
@@ -70,7 +70,7 @@ describe('table registry', () => {
it
(
'
selecting all checkbox should select all rows and enable delete button
'
,
done
=>
{
it
(
'
selecting all checkbox should select all rows and enable delete button
'
,
done
=>
{
findSelectAllCheckbox
().
click
();
findSelectAllCheckbox
().
click
();
vm
.
s
electAll
();
toggleS
electAll
();
Vue
.
nextTick
(()
=>
{
Vue
.
nextTick
(()
=>
{
const
checkedValues
=
findAllRowCheckboxes
().
filter
(
x
=>
x
.
checked
);
const
checkedValues
=
findAllRowCheckboxes
().
filter
(
x
=>
x
.
checked
);
...
@@ -82,8 +82,8 @@ describe('table registry', () => {
...
@@ -82,8 +82,8 @@ describe('table registry', () => {
it
(
'
deselecting select all checkbox should deselect all rows and disable delete button
'
,
done
=>
{
it
(
'
deselecting select all checkbox should deselect all rows and disable delete button
'
,
done
=>
{
findSelectAllCheckbox
().
click
();
findSelectAllCheckbox
().
click
();
vm
.
s
electAll
();
// Select them all on
toggleS
electAll
();
// Select them all on
vm
.
s
electAll
();
// Select them all off
toggleS
electAll
();
// Select them all off
Vue
.
nextTick
(()
=>
{
Vue
.
nextTick
(()
=>
{
const
checkedValues
=
findAllRowCheckboxes
().
filter
(
x
=>
x
.
checked
);
const
checkedValues
=
findAllRowCheckboxes
().
filter
(
x
=>
x
.
checked
);
...
@@ -95,7 +95,7 @@ describe('table registry', () => {
...
@@ -95,7 +95,7 @@ describe('table registry', () => {
it
(
'
should delete multiple items when multiple items are selected
'
,
done
=>
{
it
(
'
should delete multiple items when multiple items are selected
'
,
done
=>
{
findSelectAllCheckbox
().
click
();
findSelectAllCheckbox
().
click
();
vm
.
s
electAll
();
toggleS
electAll
();
Vue
.
nextTick
(()
=>
{
Vue
.
nextTick
(()
=>
{
expect
(
vm
.
itemsToBeDeleted
).
toEqual
([
0
,
1
]);
expect
(
vm
.
itemsToBeDeleted
).
toEqual
([
0
,
1
]);
...
@@ -105,8 +105,8 @@ describe('table registry', () => {
...
@@ -105,8 +105,8 @@ describe('table registry', () => {
spyOn
(
vm
,
'
deleteItems
'
).
and
.
returnValue
(
Promise
.
resolve
());
spyOn
(
vm
,
'
deleteItems
'
).
and
.
returnValue
(
Promise
.
resolve
());
Vue
.
nextTick
(()
=>
{
Vue
.
nextTick
(()
=>
{
const
modal
=
document
.
querySelector
(
`#
${
vm
.
modalId
}
`
);
const
modal
=
confirmationModal
(
);
document
.
querySelector
(
`#
${
vm
.
modalId
}
.btn-danger`
).
click
();
confirmationModal
(
'
.btn-danger
'
).
click
();
expect
(
modal
).
toExist
();
expect
(
modal
).
toExist
();
...
@@ -146,7 +146,7 @@ describe('table registry', () => {
...
@@ -146,7 +146,7 @@ describe('table registry', () => {
spyOn
(
vm
,
'
deleteItems
'
).
and
.
returnValue
(
Promise
.
resolve
());
spyOn
(
vm
,
'
deleteItems
'
).
and
.
returnValue
(
Promise
.
resolve
());
Vue
.
nextTick
(()
=>
{
Vue
.
nextTick
(()
=>
{
document
.
querySelector
(
`#
${
vm
.
modalId
}
.btn-danger`
).
click
();
confirmationModal
(
'
.btn-danger
'
).
click
();
expect
(
vm
.
itemsToBeDeleted
).
toEqual
([]);
expect
(
vm
.
itemsToBeDeleted
).
toEqual
([]);
expect
(
vm
.
deleteItems
).
toHaveBeenCalledWith
({
expect
(
vm
.
deleteItems
).
toHaveBeenCalledWith
({
...
@@ -164,4 +164,27 @@ describe('table registry', () => {
...
@@ -164,4 +164,27 @@ describe('table registry', () => {
expect
(
vm
.
$el
.
querySelector
(
'
.gl-pagination
'
)).
toBeDefined
();
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