Skip to content

Commit

Permalink
References ansible#15005: 24 hour format
Browse files Browse the repository at this point in the history
  • Loading branch information
aeter committed May 14, 2024
1 parent 946bbe3 commit c119cc7
Show file tree
Hide file tree
Showing 32 changed files with 132 additions and 135 deletions.
28 changes: 14 additions & 14 deletions awx/ui/src/components/Schedule/ScheduleAdd/ScheduleAdd.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ describe('<ScheduleAdd />', () => {
frequency: [],
name: 'Run once schedule',
startDate: '2020-03-25',
startTime: '10:00 AM',
startTime: '10:00',
timezone: 'America/New_York',
});
});
Expand All @@ -148,7 +148,7 @@ describe('<ScheduleAdd />', () => {
},
name: 'Run every 10 minutes 10 times',
startDate: '2020-03-25',
startTime: '10:30 AM',
startTime: '10:30',
timezone: 'America/New_York',
});
});
Expand All @@ -171,12 +171,12 @@ describe('<ScheduleAdd />', () => {
end: 'onDate',
interval: 1,
endDate: '2020-03-26',
endTime: '10:45 AM',
endTime: '10:45',
},
},
name: 'Run every hour until date',
startDate: '2020-03-25',
startTime: '10:45 AM',
startTime: '10:45',
timezone: 'America/New_York',
});
});
Expand All @@ -202,7 +202,7 @@ describe('<ScheduleAdd />', () => {
},
name: 'Run daily',
startDate: '2020-03-25',
startTime: '10:45 AM',
startTime: '10:45',
timezone: 'America/New_York',
});
});
Expand Down Expand Up @@ -230,7 +230,7 @@ describe('<ScheduleAdd />', () => {
},
name: 'Run weekly on mon/wed/fri',
startDate: '2020-03-25',
startTime: '10:45 AM',
startTime: '10:45',
timezone: 'America/New_York',
});
});
Expand All @@ -257,7 +257,7 @@ describe('<ScheduleAdd />', () => {
},
},
name: 'Run on the first day of the month',
startTime: '10:45 AM',
startTime: '10:45',
startDate: '2020-04-01',
timezone: 'America/New_York',
});
Expand All @@ -280,7 +280,7 @@ describe('<ScheduleAdd />', () => {
month: {
end: 'never',
endDate: '2020-03-26',
endTime: '11:00 AM',
endTime: '11:00',
interval: 1,
occurrences: 1,
runOn: 'the',
Expand All @@ -290,7 +290,7 @@ describe('<ScheduleAdd />', () => {
},
name: 'Run monthly on the last Tuesday',
startDate: '2020-03-31',
startTime: '11:00 AM',
startTime: '11:00',
timezone: 'America/New_York',
});
});
Expand Down Expand Up @@ -320,7 +320,7 @@ describe('<ScheduleAdd />', () => {
},
name: 'Yearly on the first day of March',
startDate: '2020-03-01',
startTime: '12:00 AM',
startTime: '00:00',
timezone: 'America/New_York',
});
});
Expand Down Expand Up @@ -351,7 +351,7 @@ describe('<ScheduleAdd />', () => {
},
name: 'Yearly on the second Friday in April',
startDate: '2020-04-10',
startTime: '11:15 AM',
startTime: '11:15',
timezone: 'America/New_York',
});
});
Expand Down Expand Up @@ -382,7 +382,7 @@ describe('<ScheduleAdd />', () => {
},
name: 'Yearly on the first weekday in October',
startDate: '2020-04-10',
startTime: '11:15 AM',
startTime: '11:15',
timezone: 'America/New_York',
});
});
Expand Down Expand Up @@ -469,7 +469,7 @@ describe('<ScheduleAdd />', () => {
inventory: { name: 'inventory', id: 45 },
credentials: [{ name: 'cred 1', id: 10 }],
startDate: '2021-01-28',
startTime: '2:15 PM',
startTime: '14:15',
timezone: 'America/New_York',
});
});
Expand Down Expand Up @@ -539,7 +539,7 @@ describe('<ScheduleAdd />', () => {
frequency: [],
name: 'Run once schedule',
startDate: '2020-03-25',
startTime: '10:00 AM',
startTime: '10:00',
timezone: 'America/New_York',
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ function getEndValue(type, options, timezone) {

const date = DateTime.fromFormat(
`${options.endDate} ${options.endTime}`,
'yyyy-MM-dd h:mm a',
'yyyy-MM-dd HH:mm',
{
zone: timezone,
}
Expand Down
28 changes: 14 additions & 14 deletions awx/ui/src/components/Schedule/ScheduleEdit/ScheduleEdit.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ describe('<ScheduleEdit />', () => {
frequency: [],
name: 'Run once schedule',
startDate: '2020-03-25',
startTime: '10:00 AM',
startTime: '10:00',
timezone: 'America/New_York',
});
});
Expand All @@ -227,7 +227,7 @@ describe('<ScheduleEdit />', () => {
},
name: 'Run every 10 minutes 10 times',
startDate: '2020-03-25',
startTime: '10:30 AM',
startTime: '10:30',
timezone: 'America/New_York',
});
});
Expand All @@ -248,13 +248,13 @@ describe('<ScheduleEdit />', () => {
hour: {
end: 'onDate',
endDate: '2020-03-26',
endTime: '10:45 AM',
endTime: '10:45',
interval: 1,
},
},
name: 'Run every hour until date',
startDate: '2020-03-25',
startTime: '10:45 AM',
startTime: '10:45',
timezone: 'America/New_York',
});
});
Expand All @@ -280,7 +280,7 @@ describe('<ScheduleEdit />', () => {
},
name: 'Run daily',
startDate: '2020-03-25',
startTime: '10:45 AM',
startTime: '10:45',
timezone: 'America/New_York',
});
});
Expand All @@ -307,7 +307,7 @@ describe('<ScheduleEdit />', () => {
},
name: 'Run weekly on mon/wed/fri',
startDate: '2020-03-25',
startTime: '10:45 AM',
startTime: '10:45',
timezone: 'America/New_York',
});
});
Expand All @@ -334,7 +334,7 @@ describe('<ScheduleEdit />', () => {
},
name: 'Run on the first day of the month',
startDate: '2020-04-01',
startTime: '10:45 AM',
startTime: '10:45',
timezone: 'America/New_York',
});
});
Expand All @@ -355,7 +355,7 @@ describe('<ScheduleEdit />', () => {
month: {
end: 'never',
endDate: '2020-03-26',
endTime: '11:00 AM',
endTime: '11:00',
interval: 1,
occurrences: 1,
runOn: 'the',
Expand All @@ -365,7 +365,7 @@ describe('<ScheduleEdit />', () => {
},
name: 'Run monthly on the last Tuesday',
startDate: '2020-03-31',
startTime: '11:00 AM',
startTime: '11:00',
timezone: 'America/New_York',
});
});
Expand Down Expand Up @@ -393,7 +393,7 @@ describe('<ScheduleEdit />', () => {
},
},
name: 'Yearly on the first day of March',
startTime: '12:00 AM',
startTime: '00:00',
startDate: '2020-03-01',
timezone: 'America/New_York',
});
Expand Down Expand Up @@ -423,7 +423,7 @@ describe('<ScheduleEdit />', () => {
},
},
name: 'Yearly on the second Friday in April',
startTime: '11:15 AM',
startTime: '11:15',
startDate: '2020-04-10',
timezone: 'America/New_York',
});
Expand Down Expand Up @@ -453,7 +453,7 @@ describe('<ScheduleEdit />', () => {
},
},
name: 'Yearly on the first weekday in October',
startTime: '11:15 AM',
startTime: '11:15',
startDate: '2020-04-10',
timezone: 'America/New_York',
});
Expand Down Expand Up @@ -542,7 +542,7 @@ describe('<ScheduleEdit />', () => {
frequency: [],
skip_tags: '',
startDate: '2021-01-28',
startTime: '2:15 PM',
startTime: '14:15',
timezone: 'America/New_York',
credentials: [
{ id: 3, name: 'Credential 3', kind: 'ssh', url: '' },
Expand Down Expand Up @@ -727,7 +727,7 @@ describe('<ScheduleEdit />', () => {
frequencyOptions: {},
name: 'Run once schedule',
startDate: '2020-03-25',
startTime: '10:00 AM',
startTime: '10:00',
timezone: 'America/New_York',
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ describe('ScheduleListItem', () => {
test('Next run correctly shown', () => {
expect(wrapper.find('Td').at(4).prop('dataLabel')).toBe('Next Run');
expect(wrapper.find('Td').at(4).text()).toBe(
'Next Run2/20/2020, 12:00:00 AM'
'Next Run2020-02-20, 00:00:00'
);
});

Expand Down Expand Up @@ -158,7 +158,7 @@ describe('ScheduleListItem', () => {
test('Next run correctly shown', () => {
expect(wrapper.find('Td').at(4).prop('dataLabel')).toBe('Next Run');
expect(wrapper.find('Td').at(4).text()).toBe(
'Next Run2/20/2020, 12:00:00 AM'
'Next Run2020-02-20, 00:00:00'
);
});
test('Edit button hidden', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ describe('<ScheduleOccurrences>', () => {
expect(wrapper.find('MultiButtonToggle').props().value).toBe('utc');
expect(wrapper.find('dd').children().length).toBe(2);
expect(wrapper.find('dd').children().at(0).text()).toBe(
'3/16/2020, 4:00:00 AM'
'2020-03-16, 04:00:00'
);
expect(wrapper.find('dd').children().at(1).text()).toBe(
'3/30/2020, 4:00:00 AM'
'2020-03-30, 04:00:00'
);
});
});
Expand Down
2 changes: 1 addition & 1 deletion awx/ui/src/components/Schedule/shared/DateTimePicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ function DateTimePicker({ dateFieldName, timeFieldName, label }) {
onChange={onDateChange}
/>
<TimePicker
placeholder="hh:mm AM/PM"
stepMinutes={15}
aria-label={
timeFieldName.startsWith('start') ? t`Start time` : t`End time`
}
time={timeField.value}
{...timeField}
is24Hour
onChange={(_, time) => timeHelpers.setValue(time)}
/>
</DateTimeGroup>
Expand Down
10 changes: 5 additions & 5 deletions awx/ui/src/components/Schedule/shared/DateTimePicker.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe('<DateTimePicker/>', () => {
await act(async () => {
wrapper = mountWithContexts(
<Formik
initialValues={{ startDate: '2021-05-26', startTime: '2:15 PM' }}
initialValues={{ startDate: '2021-05-26', startTime: '14:15' }}
>
<DateTimePicker
dateFieldName="startDate"
Expand All @@ -24,13 +24,13 @@ describe('<DateTimePicker/>', () => {
expect(wrapper.find('DatePicker')).toHaveLength(1);
expect(wrapper.find('DatePicker').prop('value')).toBe('2021-05-26');
expect(wrapper.find('TimePicker')).toHaveLength(1);
expect(wrapper.find('TimePicker').prop('value')).toBe('2:15 PM');
expect(wrapper.find('TimePicker').prop('value')).toBe('14:15');
});
test('should update values properly', async () => {
await act(async () => {
wrapper = mountWithContexts(
<Formik
initialValues={{ startDate: '2021-05-26', startTime: '2:15 PM' }}
initialValues={{ startDate: '2021-05-26', startTime: '14:15' }}
>
<DateTimePicker
dateFieldName="startDate"
Expand All @@ -47,10 +47,10 @@ describe('<DateTimePicker/>', () => {
'2021-05-29',
new Date('Sat May 29 2021 00:00:00 GMT-0400 (Eastern Daylight Time)')
);
wrapper.find('TimePicker').prop('onChange')(null, '7:15 PM');
wrapper.find('TimePicker').prop('onChange')(null, '19:15');
});
wrapper.update();
expect(wrapper.find('DatePicker').prop('value')).toBe('2021-05-29');
expect(wrapper.find('TimePicker').prop('value')).toBe('7:15 PM');
expect(wrapper.find('TimePicker').prop('value')).toBe('19:15');
});
});
4 changes: 2 additions & 2 deletions awx/ui/src/components/Schedule/shared/ScheduleForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -426,11 +426,11 @@ function ScheduleForm({
if (
DateTime.fromFormat(
`${values.startDate} ${values.startTime}`,
'yyyy-LL-dd h:mm a'
'yyyy-LL-dd HH:mm'
).toMillis() >=
DateTime.fromFormat(
`${options.endDate} ${options.endTime}`,
'yyyy-LL-dd h:mm a'
'yyyy-LL-dd HH:mm'
).toMillis()
) {
freqErrors.endDate = t`Please select an end date/time that comes after the start date/time.`;
Expand Down
6 changes: 3 additions & 3 deletions awx/ui/src/components/Schedule/shared/ScheduleForm.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ const nonRRuleValuesMatch = () => {
wrapper.find('DatePicker[aria-label="Start date"]').prop('value')
).toBe('2020-04-02');
expect(wrapper.find('TimePicker[aria-label="Start time"]').prop('time')).toBe(
'2:45 PM'
'14:45'
);
expect(wrapper.find('select#schedule-timezone').prop('value')).toBe(
'America/New_York'
Expand Down Expand Up @@ -903,7 +903,7 @@ describe('<ScheduleForm />', () => {

test('should create schedule with the same start and end date provided that the end date is at a later time', async () => {
const today = DateTime.now().toFormat('yyyy-LL-dd');
const laterTime = DateTime.now().plus({ hours: 1 }).toFormat('h:mm a');
const laterTime = DateTime.now().plus({ hours: 1 }).toFormat('HH:mm');
await act(async () => {
wrapper.find('DatePicker[aria-label="End date"]').prop('onChange')(
null,
Expand Down Expand Up @@ -1428,7 +1428,7 @@ describe('<ScheduleForm />', () => {
).toBe('2021-01-01');
expect(
wrapper.find('TimePicker[aria-label="End time"]').prop('value')
).toBe('12:00 AM');
).toBe('00:00');
});

test('initially renders expected fields and values with existing schedule that runs every month on the last weekday', async () => {
Expand Down
4 changes: 2 additions & 2 deletions awx/ui/src/components/Schedule/shared/buildRuleObj.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ window.RRule = RRule;
window.DateTime = DateTime;

const parseTime = (time) => [
DateTime.fromFormat(time, 'h:mm a').hour,
DateTime.fromFormat(time, 'h:mm a').minute,
DateTime.fromFormat(time, 'HH:mm').hour,
DateTime.fromFormat(time, 'HH:mm').minute,
];

export function buildDtStartObj(values) {
Expand Down
Loading

0 comments on commit c119cc7

Please sign in to comment.