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
6651bc38
Commit
6651bc38
authored
Sep 07, 2021
by
Ammar Alakkad
Committed by
Jose Ivan Vargas
Sep 07, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace projects storage placeholder with usage-graph
parent
958aa425
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
56 additions
and
10 deletions
+56
-10
app/assets/javascripts/projects/storage_counter/components/app.vue
...s/javascripts/projects/storage_counter/components/app.vue
+11
-4
app/assets/javascripts/projects/storage_counter/utils.js
app/assets/javascripts/projects/storage_counter/utils.js
+1
-0
spec/frontend/projects/storage_counter/app_spec.js
spec/frontend/projects/storage_counter/app_spec.js
+25
-6
spec/frontend/projects/storage_counter/mock_data.js
spec/frontend/projects/storage_counter/mock_data.js
+19
-0
No files found.
app/assets/javascripts/projects/storage_counter/components/app.vue
View file @
6651bc38
<
script
>
import
{
GlAlert
}
from
'
@gitlab/ui
'
;
import
{
s__
}
from
'
~/locale
'
;
import
UsageGraph
from
'
~/vue_shared/components/storage_counter/usage_graph.vue
'
;
import
getProjectStorageCount
from
'
../queries/project_storage.query.graphql
'
;
import
{
parseGetProjectStorageResults
}
from
'
../utils
'
;
...
...
@@ -8,6 +9,7 @@ export default {
name
:
'
StorageCounterApp
'
,
components
:
{
GlAlert
,
UsageGraph
,
},
inject
:
[
'
projectPath
'
],
apollo
:
{
...
...
@@ -43,8 +45,13 @@ export default {
};
</
script
>
<
template
>
<div>
<gl-alert
v-if=
"error"
variant=
"danger"
@
dismiss=
"clearError"
>
{{
error
}}
</gl-alert>
<div
v-else
>
{{
$options
.
i18n
.
placeholder
}}
</div>
<div
v-if=
"project.statistics"
class=
"gl-w-full"
>
<usage-graph
:root-storage-statistics=
"project.statistics"
:limit=
"0"
/>
</div>
</div>
</
template
>
app/assets/javascripts/projects/storage_counter/utils.js
View file @
6651bc38
...
...
@@ -60,5 +60,6 @@ export const parseGetProjectStorageResults = (data) => {
totalUsage
:
numberToHumanSize
(
storageSize
),
storageTypes
,
},
statistics
:
projectStatistics
,
};
};
spec/frontend/projects/storage_counter/app_spec.js
View file @
6651bc38
...
...
@@ -4,18 +4,18 @@ import VueApollo from 'vue-apollo';
import
createMockApollo
from
'
helpers/mock_apollo_helper
'
;
import
StorageCounterApp
from
'
~/projects/storage_counter/components/app.vue
'
;
import
getProjectStorageCount
from
'
~/projects/storage_counter/queries/project_storage.query.graphql
'
;
import
UsageGraph
from
'
~/vue_shared/components/storage_counter/usage_graph.vue
'
;
import
{
projectStorageCountResponse
}
from
'
./mock_data
'
;
const
localVue
=
createLocalVue
();
describe
(
'
Storage counter app
'
,
()
=>
{
let
wrapper
;
const
createMockApolloProvider
=
()
=>
{
const
createMockApolloProvider
=
(
{
mutationMock
}
)
=>
{
localVue
.
use
(
VueApollo
);
const
requestHandlers
=
[
[
getProjectStorageCount
,
jest
.
fn
().
mockRejectedValue
(
new
Error
(
'
GraphQL error
'
))],
];
const
requestHandlers
=
[[
getProjectStorageCount
,
mutationMock
]];
return
createMockApollo
(
requestHandlers
);
};
...
...
@@ -36,6 +36,7 @@ describe('Storage counter app', () => {
};
const
findAlert
=
()
=>
wrapper
.
findComponent
(
GlAlert
);
const
findUsageGraph
=
()
=>
wrapper
.
findComponent
(
UsageGraph
);
beforeEach
(()
=>
{
createComponent
();
...
...
@@ -50,10 +51,10 @@ describe('Storage counter app', () => {
});
describe
(
'
handling apollo fetching error
'
,
()
=>
{
let
mockApollo
;
const
mutationMock
=
jest
.
fn
().
mockRejectedValue
(
new
Error
(
'
GraphQL error
'
))
;
beforeEach
(()
=>
{
mockApollo
=
createMockApolloProvider
(
);
const
mockApollo
=
createMockApolloProvider
({
mutationMock
}
);
createComponent
({
mockApollo
});
});
...
...
@@ -61,4 +62,22 @@ describe('Storage counter app', () => {
expect
(
findAlert
().
exists
()).
toBe
(
true
);
});
});
describe
(
'
rendering <usage-graph />
'
,
()
=>
{
const
mutationMock
=
jest
.
fn
().
mockResolvedValue
(
projectStorageCountResponse
);
beforeEach
(()
=>
{
const
mockApollo
=
createMockApolloProvider
({
mutationMock
});
createComponent
({
mockApollo
});
});
it
(
'
renders usage-graph component if project.statistics exists
'
,
()
=>
{
expect
(
findUsageGraph
().
exists
()).
toBe
(
true
);
});
it
(
'
passes project.statistics to usage-graph component
'
,
()
=>
{
const
{
__typename
,
...
statistics
}
=
projectStorageCountResponse
.
data
.
project
.
statistics
;
expect
(
findUsageGraph
().
props
(
'
rootStorageStatistics
'
)).
toMatchObject
(
statistics
);
});
});
});
spec/frontend/projects/storage_counter/mock_data.js
0 → 100644
View file @
6651bc38
export
const
projectStorageCountResponse
=
{
data
:
{
project
:
{
id
:
'
gid://gitlab/Project/20
'
,
statistics
:
{
buildArtifactsSize
:
400000
,
lfsObjectsSize
:
4800000
,
packagesSize
:
3800000
,
repositorySize
:
39000000
,
snippetsSize
:
0
,
storageSize
:
39930000
,
uploadsSize
:
0
,
wikiSize
:
300000
,
__typename
:
'
ProjectStatistics
'
,
},
__typename
:
'
Project
'
,
},
},
};
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