Commit 2edc507b authored by Lee Tickett's avatar Lee Tickett

Observe limit to hours setting in timelog report

Changelog: added
parent f7a0dae4
...@@ -14,6 +14,13 @@ export default { ...@@ -14,6 +14,13 @@ export default {
GlTable, GlTable,
}, },
inject: ['issuableId', 'issuableType'], inject: ['issuableId', 'issuableType'],
props: {
limitToHours: {
type: Boolean,
default: false,
required: false,
},
},
data() { data() {
return { report: [], isLoading: true }; return { report: [], isLoading: true };
}, },
...@@ -60,7 +67,10 @@ export default { ...@@ -60,7 +67,10 @@ export default {
}, },
formatTimeSpent(seconds) { formatTimeSpent(seconds) {
const negative = seconds < 0; const negative = seconds < 0;
return (negative ? '- ' : '') + stringifyTime(parseSeconds(seconds)); return (
(negative ? '- ' : '') +
stringifyTime(parseSeconds(seconds, { limitToHours: this.limitToHours }))
);
}, },
}, },
fields: [ fields: [
......
...@@ -180,7 +180,7 @@ export default { ...@@ -180,7 +180,7 @@ export default {
:title="__('Time tracking report')" :title="__('Time tracking report')"
:hide-footer="true" :hide-footer="true"
> >
<time-tracking-report /> <time-tracking-report :limit-to-hours="limitToHours" />
</gl-modal> </gl-modal>
<transition name="help-state-toggle"> <transition name="help-state-toggle">
<time-tracking-help-state v-if="showHelpState" /> <time-tracking-help-state v-if="showHelpState" />
......
---
title: Observe limit to hours setting in timelog report
merge_request: 61849
author: Lee Tickett @leetickett
type: added
import { GlLoadingIcon } from '@gitlab/ui'; import { GlLoadingIcon } from '@gitlab/ui';
import { getAllByRole } from '@testing-library/dom'; import { getAllByRole, getByRole } from '@testing-library/dom';
import { shallowMount, createLocalVue, mount } from '@vue/test-utils'; import { shallowMount, createLocalVue, mount } from '@vue/test-utils';
import VueApollo from 'vue-apollo'; import VueApollo from 'vue-apollo';
import createMockApollo from 'helpers/mock_apollo_helper'; import createMockApollo from 'helpers/mock_apollo_helper';
...@@ -25,6 +25,7 @@ describe('Issuable Time Tracking Report', () => { ...@@ -25,6 +25,7 @@ describe('Issuable Time Tracking Report', () => {
queryHandler = successIssueQueryHandler, queryHandler = successIssueQueryHandler,
issuableType = 'issue', issuableType = 'issue',
mountFunction = shallowMount, mountFunction = shallowMount,
limitToHours = false,
} = {}) => { } = {}) => {
fakeApollo = createMockApollo([ fakeApollo = createMockApollo([
[getIssueTimelogsQuery, queryHandler], [getIssueTimelogsQuery, queryHandler],
...@@ -35,6 +36,7 @@ describe('Issuable Time Tracking Report', () => { ...@@ -35,6 +36,7 @@ describe('Issuable Time Tracking Report', () => {
issuableId: 1, issuableId: 1,
issuableType, issuableType,
}, },
propsData: { limitToHours },
localVue, localVue,
apolloProvider: fakeApollo, apolloProvider: fakeApollo,
}); });
...@@ -94,4 +96,30 @@ describe('Issuable Time Tracking Report', () => { ...@@ -94,4 +96,30 @@ describe('Issuable Time Tracking Report', () => {
expect(getAllByRole(wrapper.element, 'row', { name: /Administrator/i })).toHaveLength(3); expect(getAllByRole(wrapper.element, 'row', { name: /Administrator/i })).toHaveLength(3);
}); });
}); });
describe('observes `limit display of time tracking units to hours` setting', () => {
describe('when false', () => {
beforeEach(() => {
mountComponent({ limitToHours: false, mountFunction: mount });
});
it('renders correct results', async () => {
await waitForPromises();
expect(getByRole(wrapper.element, 'columnheader', { name: /1d 30m/i })).not.toBeNull();
});
});
describe('when true', () => {
beforeEach(() => {
mountComponent({ limitToHours: true, mountFunction: mount });
});
it('renders correct results', async () => {
await waitForPromises();
expect(getByRole(wrapper.element, 'columnheader', { name: /8h 30m/i })).not.toBeNull();
});
});
});
}); });
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