FIX: Don't show the Later This Week option in date pickers on Sundays
This commit is contained in:
parent
ed9e63b00e
commit
814781780d
|
@ -209,6 +209,34 @@ discourseModule(
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
componentTest("doesn't show 'Later This Week' on Sundays", {
|
||||||
|
/* We need this test to avoid regressions.
|
||||||
|
We tend to write such conditions and think that
|
||||||
|
they mean the beginning of business week
|
||||||
|
(Monday, Tuesday and Wednesday in this specific case):
|
||||||
|
|
||||||
|
if (date.day < 3) {
|
||||||
|
...
|
||||||
|
}
|
||||||
|
|
||||||
|
In fact, Sunday will pass this check too, because
|
||||||
|
in moment.js 0 stands for Sunday. */
|
||||||
|
|
||||||
|
template: hbs`{{future-date-input-selector}}`,
|
||||||
|
|
||||||
|
beforeEach() {
|
||||||
|
const timezone = moment.tz.guess();
|
||||||
|
this.clock = fakeTime("2100-04-25 18:00:00", timezone, true); // Sunday evening
|
||||||
|
},
|
||||||
|
|
||||||
|
async test(assert) {
|
||||||
|
await this.subject.expand();
|
||||||
|
const options = getOptions();
|
||||||
|
const laterThisWeek = I18n.t("topic.auto_update_input.later_this_week");
|
||||||
|
assert.not(options.includes(laterThisWeek));
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
componentTest("doesn't show 'Next Month' on the last day of the month", {
|
componentTest("doesn't show 'Next Month' on the last day of the month", {
|
||||||
template: hbs`{{future-date-input-selector}}`,
|
template: hbs`{{future-date-input-selector}}`,
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@ export const TIMEFRAMES = [
|
||||||
buildTimeframe({
|
buildTimeframe({
|
||||||
id: "later_this_week",
|
id: "later_this_week",
|
||||||
format: "ddd, h a",
|
format: "ddd, h a",
|
||||||
enabled: (opts) => !opts.canScheduleToday && opts.day < 4,
|
enabled: (opts) => !opts.canScheduleToday && opts.day > 0 && opts.day < 4,
|
||||||
when: (time, timeOfDay) => time.add(2, "day").hour(timeOfDay).minute(0),
|
when: (time, timeOfDay) => time.add(2, "day").hour(timeOfDay).minute(0),
|
||||||
}),
|
}),
|
||||||
buildTimeframe({
|
buildTimeframe({
|
||||||
|
|
Loading…
Reference in New Issue