Commit 8d5273b2 authored by Ammar Alakkad's avatar Ammar Alakkad

Show all storage types in project's storage usage

Changelog: other
parent 05914949
...@@ -14,10 +14,6 @@ export const parseGetProjectStorageResults = (data, helpLinks) => { ...@@ -14,10 +14,6 @@ export const parseGetProjectStorageResults = (data, helpLinks) => {
} }
const { storageSize, ...storageStatistics } = projectStatistics; const { storageSize, ...storageStatistics } = projectStatistics;
const storageTypes = PROJECT_STORAGE_TYPES.reduce((types, currentType) => { const storageTypes = PROJECT_STORAGE_TYPES.reduce((types, currentType) => {
if (!storageStatistics[currentType.id]) {
return types;
}
const helpPathKey = currentType.id.replace(`Size`, `HelpPagePath`); const helpPathKey = currentType.id.replace(`Size`, `HelpPagePath`);
const helpPath = helpLinks[helpPathKey]; const helpPath = helpLinks[helpPathKey];
......
...@@ -65,5 +65,31 @@ RSpec.describe 'Projects (JavaScript fixtures)', type: :controller do ...@@ -65,5 +65,31 @@ RSpec.describe 'Projects (JavaScript fixtures)', type: :controller do
expect_graphql_errors_to_be_empty expect_graphql_errors_to_be_empty
end end
end end
context 'project storage count query' do
before do
project.statistics.update!(
repository_size: 3900000,
lfs_objects_size: 4800000,
build_artifacts_size: 400000,
pipeline_artifacts_size: 400000,
wiki_size: 300000,
packages_size: 3800000,
uploads_size: 900000
)
end
base_input_path = 'projects/storage_counter/queries/'
base_output_path = 'graphql/projects/storage_counter/'
query_name = 'project_storage.query.graphql'
it "#{base_output_path}#{query_name}.json" do
query = get_graphql_query_as_string("#{base_input_path}#{query_name}")
post_graphql(query, current_user: user, variables: { fullPath: project.full_path })
expect_graphql_errors_to_be_empty
end
end
end end
end end
export const mockGetProjectStorageCountGraphQLResponse = { import mockGetProjectStorageCountGraphQLResponse from 'test_fixtures/graphql/projects/storage_counter/project_storage.query.graphql.json';
data: {
project: { export { mockGetProjectStorageCountGraphQLResponse };
id: 'gid://gitlab/Project/20',
statistics: {
buildArtifactsSize: 400000.0,
pipelineArtifactsSize: 25000.0,
lfsObjectsSize: 4800000.0,
packagesSize: 3800000.0,
repositorySize: 3900000.0,
snippetsSize: 1200000.0,
storageSize: 15300000.0,
uploadsSize: 900000.0,
wikiSize: 300000.0,
__typename: 'ProjectStatistics',
},
__typename: 'Project',
},
},
};
export const mockEmptyResponse = { data: { project: null } }; export const mockEmptyResponse = { data: { project: null } };
...@@ -37,7 +20,7 @@ export const defaultProvideValues = { ...@@ -37,7 +20,7 @@ export const defaultProvideValues = {
export const projectData = { export const projectData = {
storage: { storage: {
totalUsage: '14.6 MiB', totalUsage: '13.8 MiB',
storageTypes: [ storageTypes: [
{ {
storageType: { storageType: {
...@@ -84,7 +67,7 @@ export const projectData = { ...@@ -84,7 +67,7 @@ export const projectData = {
description: 'Shared bits of code and text.', description: 'Shared bits of code and text.',
helpPath: '/snippets', helpPath: '/snippets',
}, },
value: 1200000, value: 0,
}, },
{ {
storageType: { storageType: {
......
...@@ -14,4 +14,21 @@ describe('parseGetProjectStorageResults', () => { ...@@ -14,4 +14,21 @@ describe('parseGetProjectStorageResults', () => {
), ),
).toMatchObject(projectData); ).toMatchObject(projectData);
}); });
it('includes storage type with size of 0 in returned value', () => {
const mockedResponse = mockGetProjectStorageCountGraphQLResponse.data;
// ensuring a specific storage type item has size of 0
mockedResponse.project.statistics.repositorySize = 0;
const response = parseGetProjectStorageResults(mockedResponse, defaultProvideValues.helpLinks);
expect(response.storage.storageTypes).toEqual(
expect.arrayContaining([
{
storageType: expect.any(Object),
value: 0,
},
]),
);
});
}); });
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment