Commit 1fee3ab3 authored by Ezekiel Kigbo's avatar Ezekiel Kigbo

Merge branch 'tr-chrome-schedule-date-fix' into 'master'

Fix on-call edit form formatting issue

See merge request gitlab-org/gitlab!56717
parents 395abc98 27934e2b
...@@ -198,12 +198,6 @@ export default { ...@@ -198,12 +198,6 @@ export default {
class="gl-w-full" class="gl-w-full"
:value="formattedDate" :value="formattedDate"
:placeholder="__(`YYYY-MM-DD`)" :placeholder="__(`YYYY-MM-DD`)"
@blur="
$emit('update-rotation-form', {
type: 'startsAt.date',
value: $event.target.value,
})
"
/> />
</template> </template>
</gl-datepicker> </gl-datepicker>
...@@ -261,12 +255,6 @@ export default { ...@@ -261,12 +255,6 @@ export default {
class="gl-w-full" class="gl-w-full"
:value="formattedDate" :value="formattedDate"
:placeholder="__(`YYYY-MM-DD`)" :placeholder="__(`YYYY-MM-DD`)"
@blur="
$emit('update-rotation-form', {
type: 'endsAt.date',
value: $event.target.value,
})
"
/> />
</template> </template>
</gl-datepicker> </gl-datepicker>
...@@ -326,7 +314,7 @@ export default { ...@@ -326,7 +314,7 @@ export default {
class="gl-px-3" class="gl-px-3"
> >
<gl-dropdown-item <gl-dropdown-item
v-for="time in $options.HOURS_IN_DAY" v-for="(_, time) in $options.HOURS_IN_DAY"
:key="time" :key="time"
:is-checked="form.restrictedTo.startTime === time" :is-checked="form.restrictedTo.startTime === time"
is-check-item is-check-item
...@@ -346,7 +334,7 @@ export default { ...@@ -346,7 +334,7 @@ export default {
class="gl-px-3" class="gl-px-3"
> >
<gl-dropdown-item <gl-dropdown-item
v-for="time in $options.HOURS_IN_DAY" v-for="(_, time) in $options.HOURS_IN_DAY"
:key="time" :key="time"
:is-checked="form.restrictedTo.endTime === time" :is-checked="form.restrictedTo.endTime === time"
is-check-item is-check-item
......
...@@ -73,7 +73,7 @@ export const parseRotationDate = (dateTimeString, scheduleTimezone) => { ...@@ -73,7 +73,7 @@ export const parseRotationDate = (dateTimeString, scheduleTimezone) => {
month: '2-digit', month: '2-digit',
day: '2-digit', day: '2-digit',
hour: '2-digit', hour: '2-digit',
hour12: false, // The time picker uses 24 hour time hourCycle: 'h23',
timeZone: scheduleTimezone, timeZone: scheduleTimezone,
timeZoneName: 'long', timeZoneName: 'long',
}; };
......
...@@ -31,14 +31,21 @@ describe('getParticipantsForSave', () => { ...@@ -31,14 +31,21 @@ describe('getParticipantsForSave', () => {
}); });
describe('parseRotationDate', () => { describe('parseRotationDate', () => {
const scheduleTimezone = 'Pacific/Honolulu'; // UTC -10
it('parses a rotation date according to the supplied timezone', () => { it('parses a rotation date according to the supplied timezone', () => {
const dateTimeString = '2021-01-12T05:04:56.333Z'; const dateTimeString = '2021-01-12T05:04:56.333Z';
const scheduleTimezone = 'Pacific/Honolulu';
const rotationDate = parseRotationDate(dateTimeString, scheduleTimezone); const rotationDate = parseRotationDate(dateTimeString, scheduleTimezone);
expect(rotationDate).toStrictEqual({ date: new Date('2021-01-11T00:00:00.000Z'), time: 19 }); expect(rotationDate).toStrictEqual({ date: new Date('2021-01-11T00:00:00.000Z'), time: 19 });
}); });
it('parses a rotation date at midnight without exceeding 24 hours', () => {
const dateTimeString = '2021-01-12T10:00:00.000Z';
const rotationDate = parseRotationDate(dateTimeString, scheduleTimezone);
expect(rotationDate).toStrictEqual({ date: new Date('2021-01-12T00:00:00.000Z'), time: 0 });
});
}); });
describe('parseHour', () => { describe('parseHour', () => {
......
...@@ -227,8 +227,8 @@ describe('AddEditRotationForm', () => { ...@@ -227,8 +227,8 @@ describe('AddEditRotationForm', () => {
findRestrictedToOptions().at(timeTo).vm.$emit('click'); findRestrictedToOptions().at(timeTo).vm.$emit('click');
const emittedEvent = wrapper.emitted('update-rotation-form'); const emittedEvent = wrapper.emitted('update-rotation-form');
expect(emittedEvent).toHaveLength(2); expect(emittedEvent).toHaveLength(2);
expect(emittedEvent[0][0]).toEqual({ type: 'restrictedTo.startTime', value: timeFrom + 1 }); expect(emittedEvent[0][0]).toEqual({ type: 'restrictedTo.startTime', value: timeFrom });
expect(emittedEvent[1][0]).toEqual({ type: 'restrictedTo.endTime', value: timeTo + 1 }); expect(emittedEvent[1][0]).toEqual({ type: 'restrictedTo.endTime', value: timeTo });
}); });
it('should add a checkmark to a selected restricted FROM time', async () => { it('should add a checkmark to a selected restricted FROM time', async () => {
...@@ -241,16 +241,8 @@ describe('AddEditRotationForm', () => { ...@@ -241,16 +241,8 @@ describe('AddEditRotationForm', () => {
}, },
}, },
}); });
expect( expect(findRestrictedFromOptions().at(timeFrom).props('isChecked')).toBe(true);
findRestrictedFromOptions() expect(findRestrictedToOptions().at(timeTo).props('isChecked')).toBe(true);
.at(timeFrom - 1)
.props('isChecked'),
).toBe(true);
expect(
findRestrictedToOptions()
.at(timeTo - 1)
.props('isChecked'),
).toBe(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