Commit e397e0d5 authored by Jacques Erasmus's avatar Jacques Erasmus

Merge branch '330845-observe-limit-to-hours' into 'master'

Observe "limit to hours" for issuable time tracking report

See merge request gitlab-org/gitlab!61849
parents 0e9c5063 2edc507b
......@@ -14,6 +14,13 @@ export default {
GlTable,
},
inject: ['issuableId', 'issuableType'],
props: {
limitToHours: {
type: Boolean,
default: false,
required: false,
},
},
data() {
return { report: [], isLoading: true };
},
......@@ -60,7 +67,10 @@ export default {
},
formatTimeSpent(seconds) {
const negative = seconds < 0;
return (negative ? '- ' : '') + stringifyTime(parseSeconds(seconds));
return (
(negative ? '- ' : '') +
stringifyTime(parseSeconds(seconds, { limitToHours: this.limitToHours }))
);
},
},
fields: [
......
......@@ -180,7 +180,7 @@ export default {
:title="__('Time tracking report')"
:hide-footer="true"
>
<time-tracking-report />
<time-tracking-report :limit-to-hours="limitToHours" />
</gl-modal>
<transition name="help-state-toggle">
<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 { getAllByRole } from '@testing-library/dom';
import { getAllByRole, getByRole } from '@testing-library/dom';
import { shallowMount, createLocalVue, mount } from '@vue/test-utils';
import VueApollo from 'vue-apollo';
import createMockApollo from 'helpers/mock_apollo_helper';
......@@ -25,6 +25,7 @@ describe('Issuable Time Tracking Report', () => {
queryHandler = successIssueQueryHandler,
issuableType = 'issue',
mountFunction = shallowMount,
limitToHours = false,
} = {}) => {
fakeApollo = createMockApollo([
[getIssueTimelogsQuery, queryHandler],
......@@ -35,6 +36,7 @@ describe('Issuable Time Tracking Report', () => {
issuableId: 1,
issuableType,
},
propsData: { limitToHours },
localVue,
apolloProvider: fakeApollo,
});
......@@ -94,4 +96,30 @@ describe('Issuable Time Tracking Report', () => {
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