Commit 205cb0c6 authored by Filipa Lacerda's avatar Filipa Lacerda Committed by Tim Zallmann

Hides shared runner limit when user has minutes

parent 84e79476
......@@ -50,8 +50,16 @@ export const isJobStuck = state =>
(!_.isEmpty(state.job.runners) && state.job.runners.available === false);
// ee-only start
/**
* Shared runners limit is only rendered when
* used quota is bigger or equal than the limit
*
* @returns {Boolean}
*/
export const shouldRenderSharedRunnerLimitWarning = state =>
state.job.runners && state.job.runners.quota && state.job.runners.quota.used;
!_.isEmpty(state.job.runners) &&
!_.isEmpty(state.job.runners.quota) &&
state.job.runners.quota.used >= state.job.runners.quota.limit;
// ee-only end
// prevent babel-plugin-rewire from generating an invalid default during karma tests
......
---
title: Fixes warning for used minutes in runner showing when user still has minutes
merge_request: 7843
author:
type: fixed
......@@ -25,5 +25,17 @@ describe 'Jobs', :clean_gitlab_redis_shared_state do
expect(page).to have_content('You have used all your shared Runners pipeline minutes.')
end
end
context 'job project is not over shared runners limit' do
let(:group) { create(:group, :with_not_used_build_minutes_limit) }
let(:project) { create(:project, :repository, namespace: group, shared_runners_enabled: true) }
it 'does not display a warning message' do
visit project_job_path(project, job)
wait_for_requests
expect(page).not_to have_content('You have used all your shared Runners pipeline minutes.')
end
end
end
end
......@@ -210,4 +210,56 @@ describe('Job Store Getters', () => {
});
});
});
describe('shouldRenderSharedRunnerLimitWarning', () => {
describe('without runners information', () => {
it('returns false', () => {
expect(getters.shouldRenderSharedRunnerLimitWarning(localState)).toEqual(false);
});
});
describe('with runners information', () => {
describe('when used quota is less than limit', () => {
it('returns false', () => {
localState.job.runners = {
quota: {
used: 33,
limit: 2000,
},
available: true,
online: true,
};
expect(getters.shouldRenderSharedRunnerLimitWarning(localState)).toEqual(false);
});
});
describe('when used quota is equal to limit', () => {
it('returns true', () => {
localState.job.runners = {
quota: {
used: 2000,
limit: 2000,
},
available: true,
online: true,
};
expect(getters.shouldRenderSharedRunnerLimitWarning(localState)).toEqual(true);
});
});
describe('when used quota is bigger than limit', () => {
it('returns true', () => {
localState.job.runners = {
quota: {
used: 2002,
limit: 2000,
},
available: true,
online: true,
};
expect(getters.shouldRenderSharedRunnerLimitWarning(localState)).toEqual(true);
});
});
});
});
});
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