Commit 386687c9 authored by David O'Regan's avatar David O'Regan

Merge branch '324713-description' into 'master'

Fix: Add description to oncall schedules view

See merge request gitlab-org/gitlab!56796
parents 4bcf8dc8 19ce23ad
...@@ -93,15 +93,12 @@ export default { ...@@ -93,15 +93,12 @@ export default {
}; };
}, },
computed: { computed: {
selectedTimezone() { loading() {
return this.timezones.find((tz) => tz.identifier === this.schedule.timezone); return this.$apollo.queries.rotations.loading;
}, },
offset() { offset() {
return selectedTimezoneFormattedOffset(this.selectedTimezone.formatted_offset); return selectedTimezoneFormattedOffset(this.selectedTimezone.formatted_offset);
}, },
timeframe() {
return getTimeframeForWeeksView(this.timeframeStartDate);
},
scheduleRange() { scheduleRange() {
switch (this.presetType) { switch (this.presetType) {
case PRESET_TYPES.DAYS: case PRESET_TYPES.DAYS:
...@@ -120,8 +117,17 @@ export default { ...@@ -120,8 +117,17 @@ export default {
return ''; return '';
} }
}, },
loading() { scheduleInfo() {
return this.$apollo.queries.rotations.loading; if (this.schedule.description) {
return `${this.schedule.description} | ${this.offset} ${this.schedule.timezone}`;
}
return `${this.schedule.timezone} | ${this.offset}`;
},
selectedTimezone() {
return this.timezones.find((tz) => tz.identifier === this.schedule.timezone);
},
timeframe() {
return getTimeframeForWeeksView(this.timeframeStartDate);
}, },
}, },
methods: { methods: {
...@@ -194,7 +200,7 @@ export default { ...@@ -194,7 +200,7 @@ export default {
</div> </div>
</template> </template>
<p class="gl-text-gray-500 gl-mb-5" data-testid="scheduleBody"> <p class="gl-text-gray-500 gl-mb-5" data-testid="scheduleBody">
{{ schedule.timezone }} | {{ offset }} {{ scheduleInfo }}
</p> </p>
<div class="gl-display-flex gl-justify-content-space-between gl-mb-3"> <div class="gl-display-flex gl-justify-content-space-between gl-mb-3">
<div class="gl-display-flex gl-align-items-center"> <div class="gl-display-flex gl-align-items-center">
......
---
title: Allow oncall schedule to display description
merge_request: 56796
author:
type: fixed
...@@ -70,12 +70,12 @@ describe('On-call schedule', () => { ...@@ -70,12 +70,12 @@ describe('On-call schedule', () => {
afterEach(() => { afterEach(() => {
wrapper.destroy(); wrapper.destroy();
wrapper = null;
}); });
const findScheduleHeader = () => wrapper.findByTestId('scheduleHeader'); const findScheduleHeader = () => wrapper.findByTestId('scheduleHeader');
const findRotationsHeader = () => wrapper.findByTestId('rotationsHeader'); const findRotationsHeader = () => wrapper.findByTestId('rotationsHeader');
const findSchedule = () => wrapper.findByTestId('scheduleBody'); const findSchedule = () => wrapper.findByTestId('scheduleBody');
const findScheduleDescription = () => findSchedule().text();
const findRotations = () => wrapper.findByTestId('rotationsBody'); const findRotations = () => wrapper.findByTestId('rotationsBody');
const findRotationsShiftPreset = () => wrapper.findByTestId('shift-preset-change'); const findRotationsShiftPreset = () => wrapper.findByTestId('shift-preset-change');
const findAddRotationsBtn = () => findRotationsHeader().find(GlButton); const findAddRotationsBtn = () => findRotationsHeader().find(GlButton);
...@@ -88,12 +88,23 @@ describe('On-call schedule', () => { ...@@ -88,12 +88,23 @@ describe('On-call schedule', () => {
expect(findScheduleHeader().text()).toBe(mockSchedule.name); expect(findScheduleHeader().text()).toBe(mockSchedule.name);
}); });
it('shows timezone info', () => { describe('Timeframe schedule card header information', () => {
const timezone = lastTz.identifier; const timezone = lastTz.identifier;
const offset = `(UTC ${lastTz.formatted_offset})`; const offset = `(UTC ${lastTz.formatted_offset})`;
const description = findSchedule().text();
expect(description).toContain(timezone); it('shows timezone info', () => {
expect(description).toContain(offset); expect(findScheduleDescription()).toContain(timezone);
expect(findScheduleDescription()).toContain(offset);
});
it('shows schedule description if present', () => {
expect(findScheduleDescription()).toContain(mockSchedule.description);
});
it('does not show schedule description if none present', () => {
createComponent({ schedule: { ...mockSchedule, description: null }, loading: false });
expect(findScheduleDescription()).not.toContain(mockSchedule.description);
});
}); });
it('renders rotations header', () => { it('renders rotations header', () => {
......
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