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
0
Merge Requests
0
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
Jérome Perrin
gitlab-ce
Commits
c34a47c3
Commit
c34a47c3
authored
Sep 26, 2017
by
Filipa Lacerda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adds tests for new table component
Fixes eslint problems
parent
485cb91c
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
101 additions
and
89 deletions
+101
-89
app/assets/javascripts/registry/components/app.vue
app/assets/javascripts/registry/components/app.vue
+1
-1
app/assets/javascripts/registry/components/collapsible_container.vue
...javascripts/registry/components/collapsible_container.vue
+3
-1
app/assets/javascripts/registry/components/table_registry.vue
...assets/javascripts/registry/components/table_registry.vue
+6
-3
spec/javascripts/registry/components/app_spec.js
spec/javascripts/registry/components/app_spec.js
+2
-2
spec/javascripts/registry/components/collapsible_container_spec.js
...scripts/registry/components/collapsible_container_spec.js
+7
-80
spec/javascripts/registry/components/table_registry_spec.js
spec/javascripts/registry/components/table_registry_spec.js
+49
-0
spec/javascripts/registry/getters_spec.js
spec/javascripts/registry/getters_spec.js
+0
-0
spec/javascripts/registry/mock_data.js
spec/javascripts/registry/mock_data.js
+31
-0
spec/javascripts/registry/stores/actions_spec.js
spec/javascripts/registry/stores/actions_spec.js
+1
-1
spec/javascripts/registry/stores/mutations_spec.js
spec/javascripts/registry/stores/mutations_spec.js
+1
-1
No files found.
app/assets/javascripts/registry/components/app.vue
View file @
c34a47c3
...
@@ -37,7 +37,7 @@
...
@@ -37,7 +37,7 @@
},
},
mounted
()
{
mounted
()
{
this
.
fetchRepos
()
this
.
fetchRepos
()
.
catch
(()
=>
Flash
(
errorMessages
Types
.
FETCH_REPOS
));
.
catch
(()
=>
Flash
(
errorMessages
[
errorMessagesTypes
.
FETCH_REPOS
]
));
},
},
};
};
</
script
>
</
script
>
...
...
app/assets/javascripts/registry/components/collapsible_container.vue
View file @
c34a47c3
<
script
>
<
script
>
/* globals Flash */
import
{
mapActions
}
from
'
vuex
'
;
import
{
mapActions
}
from
'
vuex
'
;
import
{
n__
,
s__
}
from
'
../../locale
'
;
import
'
../../flash
'
;
import
clipboardButton
from
'
../../vue_shared/components/clipboard_button.vue
'
;
import
clipboardButton
from
'
../../vue_shared/components/clipboard_button.vue
'
;
import
loadingIcon
from
'
../../vue_shared/components/loading_icon.vue
'
;
import
loadingIcon
from
'
../../vue_shared/components/loading_icon.vue
'
;
import
tooltip
from
'
../../vue_shared/directives/tooltip
'
;
import
tooltip
from
'
../../vue_shared/directives/tooltip
'
;
...
@@ -37,6 +38,7 @@
...
@@ -37,6 +38,7 @@
toggleRepo
()
{
toggleRepo
()
{
this
.
isOpen
=
!
this
.
isOpen
;
this
.
isOpen
=
!
this
.
isOpen
;
if
(
this
.
isOpen
)
{
if
(
this
.
isOpen
)
{
this
.
fetchList
({
repo
:
this
.
repo
})
this
.
fetchList
({
repo
:
this
.
repo
})
.
catch
(()
=>
this
.
showError
(
errorMessagesTypes
.
FETCH_REGISTRY
));
.
catch
(()
=>
this
.
showError
(
errorMessagesTypes
.
FETCH_REGISTRY
));
...
...
app/assets/javascripts/registry/components/table_registry.vue
View file @
c34a47c3
<
script
>
<
script
>
/* globals Flash */
import
{
mapActions
}
from
'
vuex
'
;
import
{
mapActions
}
from
'
vuex
'
;
import
{
n__
,
s__
}
from
'
../../locale
'
;
import
{
n__
}
from
'
../../locale
'
;
import
'
../../flash
'
;
import
clipboardButton
from
'
../../vue_shared/components/clipboard_button.vue
'
;
import
clipboardButton
from
'
../../vue_shared/components/clipboard_button.vue
'
;
import
tablePagination
from
'
../../vue_shared/components/table_pagination.vue
'
;
import
tablePagination
from
'
../../vue_shared/components/table_pagination.vue
'
;
import
tooltip
from
'
../../vue_shared/directives/tooltip
'
;
import
tooltip
from
'
../../vue_shared/directives/tooltip
'
;
...
@@ -39,14 +41,15 @@
...
@@ -39,14 +41,15 @@
const
pluralize
=
n__
(
'
layer
'
,
'
layers
'
,
item
.
layers
);
const
pluralize
=
n__
(
'
layer
'
,
'
layers
'
,
item
.
layers
);
return
`
${
item
.
layers
}
${
pluralize
}
`
;
return
`
${
item
.
layers
}
${
pluralize
}
`
;
},
},
handleDeleteRegistry
(
registry
)
{
handleDeleteRegistry
(
registry
)
{
this
.
deleteRegistry
(
registry
)
this
.
deleteRegistry
(
registry
)
.
then
(()
=>
this
.
fetchList
({
repo
:
this
.
repo
}))
.
then
(()
=>
this
.
fetchList
({
repo
:
this
.
repo
}))
.
catch
(()
=>
this
.
showError
(
errorMessagesTypes
.
DELETE_REGISTRY
));
.
catch
(()
=>
this
.
showError
(
errorMessagesTypes
.
DELETE_REGISTRY
));
},
},
onPageChange
(
pageNumber
)
{
onPageChange
(
pageNumber
)
{
this
.
fetchList
({
repo
:
this
.
repo
,
page
})
this
.
fetchList
({
repo
:
this
.
repo
,
page
:
pageNumber
})
.
catch
(()
=>
this
.
showError
(
errorMessagesTypes
.
FETCH_REGISTRY
));
.
catch
(()
=>
this
.
showError
(
errorMessagesTypes
.
FETCH_REGISTRY
));
},
},
...
...
spec/javascripts/registry/components/app_spec.js
View file @
c34a47c3
import
Vue
from
'
vue
'
;
import
Vue
from
'
vue
'
;
import
registry
from
'
~/registry/components/app.vue
'
;
import
registry
from
'
~/registry/components/app.vue
'
;
import
mountComponent
from
'
../../helpers/vue_mount_component_helper
'
;
import
mountComponent
from
'
../../helpers/vue_mount_component_helper
'
;
import
{
reposServerResponse
}
from
'
../
stores/
mock_data
'
;
import
{
reposServerResponse
}
from
'
../mock_data
'
;
describe
(
'
Registry List
'
,
()
=>
{
describe
(
'
Registry List
'
,
()
=>
{
let
vm
;
let
vm
;
...
@@ -59,7 +59,7 @@ describe('Registry List', () => {
...
@@ -59,7 +59,7 @@ describe('Registry List', () => {
it
(
'
should open the container
'
,
(
done
)
=>
{
it
(
'
should open the container
'
,
(
done
)
=>
{
setTimeout
(()
=>
{
setTimeout
(()
=>
{
Vue
.
nextTick
(()
=>
{
Vue
.
nextTick
(()
=>
{
vm
.
$el
.
querySelector
(
'
.
container-image a
'
).
click
();
vm
.
$el
.
querySelector
(
'
.
js-toggle-repo
'
).
click
();
Vue
.
nextTick
(()
=>
{
Vue
.
nextTick
(()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.js-toggle-repo i
'
).
className
).
toEqual
(
'
fa fa-chevron-up
'
);
expect
(
vm
.
$el
.
querySelector
(
'
.js-toggle-repo i
'
).
className
).
toEqual
(
'
fa fa-chevron-up
'
);
done
();
done
();
...
...
spec/javascripts/registry/components/collapsible_container_spec.js
View file @
c34a47c3
import
Vue
from
'
vue
'
;
import
Vue
from
'
vue
'
;
import
collapsibleComponent
from
'
~/registry/components/collapsible_container.vue
'
;
import
collapsibleComponent
from
'
~/registry/components/collapsible_container.vue
'
;
import
mountComponent
from
'
../../helpers/vue_mount_component_helper
'
;
import
store
from
'
~/registry/stores
'
;
import
{
repoPropsData
}
from
'
../mock_data
'
;
describe
(
'
collapsible registry container
'
,
()
=>
{
describe
(
'
collapsible registry container
'
,
()
=>
{
let
vm
;
let
vm
;
let
Component
;
let
Component
;
let
mockData
;
beforeEach
(()
=>
{
beforeEach
(()
=>
{
Component
=
Vue
.
extend
(
collapsibleComponent
);
Component
=
Vue
.
extend
(
collapsibleComponent
);
mockData
=
{
vm
=
new
Component
({
canDelete
:
true
,
store
,
destroyPath
:
'
path
'
,
propsData
:
{
id
:
'
123
'
,
repo
:
repoPropsData
,
isLoading
:
false
,
list
:
[
{
tag
:
'
centos6
'
,
revision
:
'
b118ab5b0e90b7cb5127db31d5321ac14961d097516a8e0e72084b6cdc783b43
'
,
shortRevision
:
'
b118ab5b0
'
,
size
:
19
,
layers
:
10
,
location
:
'
location
'
,
createdAt
:
1505828744434
,
destroyPath
:
'
path
'
,
canDelete
:
true
,
},
],
location
:
'
location
'
,
name
:
'
foo
'
,
tagsPath
:
'
path
'
,
pagination
:
{
perPage
:
5
,
page
:
1
,
total
:
13
,
totalPages
:
1
,
nextPage
:
null
,
previousPage
:
null
,
},
},
};
}).
$mount
();
vm
=
mountComponent
(
Component
,
{
repo
:
mockData
});
});
});
afterEach
(()
=>
{
afterEach
(()
=>
{
...
@@ -80,52 +55,4 @@ describe('collapsible registry container', () => {
...
@@ -80,52 +55,4 @@ describe('collapsible registry container', () => {
expect
(
vm
.
$el
.
querySelector
(
'
.js-remove-repo
'
)).
toBeDefined
();
expect
(
vm
.
$el
.
querySelector
(
'
.js-remove-repo
'
)).
toBeDefined
();
});
});
});
});
describe
(
'
registry list
'
,
()
=>
{
it
(
'
should render a table with the registry list
'
,
(
done
)
=>
{
vm
.
$el
.
querySelector
(
'
.js-toggle-repo
'
).
click
();
Vue
.
nextTick
(()
=>
{
expect
(
vm
.
$el
.
querySelectorAll
(
'
table tbody tr
'
).
length
,
).
toEqual
(
mockData
.
list
.
length
);
done
();
});
});
it
(
'
should render registry tag
'
,
(
done
)
=>
{
vm
.
$el
.
querySelector
(
'
.js-toggle-repo
'
).
click
();
Vue
.
nextTick
(()
=>
{
const
textRendered
=
vm
.
$el
.
querySelector
(
'
.table tbody tr
'
).
textContent
.
trim
().
replace
(
/
\s\s
+/g
,
'
'
);
expect
(
textRendered
).
toContain
(
mockData
.
list
[
0
].
tag
);
expect
(
textRendered
).
toContain
(
mockData
.
list
[
0
].
shortRevision
);
expect
(
textRendered
).
toContain
(
mockData
.
list
[
0
].
layers
);
expect
(
textRendered
).
toContain
(
mockData
.
list
[
0
].
size
);
done
();
});
});
it
(
'
should be possible to delete a registry
'
,
(
done
)
=>
{
vm
.
$el
.
querySelector
(
'
.js-toggle-repo
'
).
click
();
Vue
.
nextTick
(()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.table tbody tr .js-delete-registry
'
),
).
toBeDefined
();
done
();
});
});
describe
(
'
pagination
'
,
()
=>
{
it
(
'
should be possible to change the page
'
,
(
done
)
=>
{
vm
.
$el
.
querySelector
(
'
.js-toggle-repo
'
).
click
();
Vue
.
nextTick
(()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.gl-pagination
'
)).
toBeDefined
();
done
();
});
});
});
});
});
});
spec/javascripts/registry/components/table_registry_spec.js
0 → 100644
View file @
c34a47c3
import
Vue
from
'
vue
'
;
import
tableRegistry
from
'
~/registry/components/table_registry.vue
'
;
import
store
from
'
~/registry/stores
'
;
import
{
repoPropsData
}
from
'
../mock_data
'
;
describe
(
'
table registry
'
,
()
=>
{
let
vm
;
let
Component
;
beforeEach
(()
=>
{
Component
=
Vue
.
extend
(
tableRegistry
);
vm
=
new
Component
({
store
,
propsData
:
{
repo
:
repoPropsData
,
},
}).
$mount
();
});
afterEach
(()
=>
{
vm
.
$destroy
();
});
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
,
'
'
);
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
);
});
it
(
'
should be possible to delete a registry
'
,
()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.table tbody tr .js-delete-registry
'
),
).
toBeDefined
();
});
describe
(
'
pagination
'
,
()
=>
{
it
(
'
should be possible to change the page
'
,
()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.gl-pagination
'
)).
toBeDefined
();
});
});
});
spec/javascripts/registry/
stores/
getters_spec.js
→
spec/javascripts/registry/getters_spec.js
View file @
c34a47c3
File moved
spec/javascripts/registry/
stores/
mock_data.js
→
spec/javascripts/registry/mock_data.js
View file @
c34a47c3
...
@@ -89,3 +89,34 @@ export const parsedRegistryServerResponse = [
...
@@ -89,3 +89,34 @@ export const parsedRegistryServerResponse = [
canDelete
:
false
,
canDelete
:
false
,
},
},
];
];
export
const
repoPropsData
=
{
canDelete
:
true
,
destroyPath
:
'
path
'
,
id
:
'
123
'
,
isLoading
:
false
,
list
:
[
{
tag
:
'
centos6
'
,
revision
:
'
b118ab5b0e90b7cb5127db31d5321ac14961d097516a8e0e72084b6cdc783b43
'
,
shortRevision
:
'
b118ab5b0
'
,
size
:
19
,
layers
:
10
,
location
:
'
location
'
,
createdAt
:
1505828744434
,
destroyPath
:
'
path
'
,
canDelete
:
true
,
},
],
location
:
'
location
'
,
name
:
'
foo
'
,
tagsPath
:
'
path
'
,
pagination
:
{
perPage
:
5
,
page
:
1
,
total
:
13
,
totalPages
:
1
,
nextPage
:
null
,
previousPage
:
null
,
},
};
spec/javascripts/registry/stores/actions_spec.js
View file @
c34a47c3
...
@@ -9,7 +9,7 @@ import {
...
@@ -9,7 +9,7 @@ import {
reposServerResponse
,
reposServerResponse
,
registryServerResponse
,
registryServerResponse
,
parsedReposServerResponse
,
parsedReposServerResponse
,
}
from
'
./mock_data
'
;
}
from
'
.
.
/mock_data
'
;
Vue
.
use
(
VueResource
);
Vue
.
use
(
VueResource
);
...
...
spec/javascripts/registry/stores/mutations_spec.js
View file @
c34a47c3
...
@@ -6,7 +6,7 @@ import {
...
@@ -6,7 +6,7 @@ import {
registryServerResponse
,
registryServerResponse
,
parsedReposServerResponse
,
parsedReposServerResponse
,
parsedRegistryServerResponse
,
parsedRegistryServerResponse
,
}
from
'
./mock_data
'
;
}
from
'
.
.
/mock_data
'
;
describe
(
'
Mutations Registry Store
'
,
()
=>
{
describe
(
'
Mutations Registry Store
'
,
()
=>
{
let
mockState
;
let
mockState
;
...
...
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