FIX: Bookmark reminders and improvements changes (#9213)

* Cosmetic fixes for the bookmark modal
* Do not show "later today" when the later time will be > 5pm
* When a custom reminder time is selected, store it in localStorage. The next time the modal is opened, if the last datetime is > now, then a new tile with "Last" will be shown that lets the user reselect that same time.
* Also add an explicit "No Reminder" option that is selected by default
This commit is contained in:
Martin Brennan
2020-03-16 16:05:44 +10:00
committed by GitHub
parent a6e9057609
commit 4cce564b35
5 changed files with 134 additions and 30 deletions

View File

@ -19,22 +19,27 @@ function mockMomentTz(dateString) {
QUnit.test("showLaterToday when later today is tomorrow do not show", function(
assert
) {
mockMomentTz("2019-12-11T13:00:00Z");
mockMomentTz("2019-12-11T22:00:00");
assert.equal(BookmarkController.get("showLaterToday"), false);
});
QUnit.test("showLaterToday when later today is after 5pm", function(assert) {
mockMomentTz("2019-12-11T15:00:00");
assert.equal(BookmarkController.get("showLaterToday"), false);
});
QUnit.test(
"showLaterToday when later today is before the end of the day, show",
function(assert) {
mockMomentTz("2019-12-11T08:00:00Z");
mockMomentTz("2019-12-11T10:00:00");
assert.equal(BookmarkController.get("showLaterToday"), true);
}
);
QUnit.test("nextWeek gets next week correctly", function(assert) {
mockMomentTz("2019-12-11T08:00:00Z");
mockMomentTz("2019-12-11T08:00:00");
assert.equal(
BookmarkController.nextWeek().format("YYYY-MM-DD"),
@ -43,7 +48,7 @@ QUnit.test("nextWeek gets next week correctly", function(assert) {
});
QUnit.test("nextMonth gets next month correctly", function(assert) {
mockMomentTz("2019-12-11T08:00:00Z");
mockMomentTz("2019-12-11T08:00:00");
assert.equal(
BookmarkController.nextMonth().format("YYYY-MM-DD"),
@ -54,7 +59,7 @@ QUnit.test("nextMonth gets next month correctly", function(assert) {
QUnit.test(
"nextBusinessDay gets next business day of monday correctly if today is friday",
function(assert) {
mockMomentTz("2019-12-13T08:00:00Z");
mockMomentTz("2019-12-13T08:00:00");
assert.equal(
BookmarkController.nextBusinessDay().format("YYYY-MM-DD"),
@ -66,7 +71,7 @@ QUnit.test(
QUnit.test(
"nextBusinessDay gets next business day of monday correctly if today is saturday",
function(assert) {
mockMomentTz("2019-12-14T08:00:00Z");
mockMomentTz("2019-12-14T08:00:00");
assert.equal(
BookmarkController.nextBusinessDay().format("YYYY-MM-DD"),
@ -78,7 +83,7 @@ QUnit.test(
QUnit.test(
"nextBusinessDay gets next business day of monday correctly if today is sunday",
function(assert) {
mockMomentTz("2019-12-15T08:00:00Z");
mockMomentTz("2019-12-15T08:00:00");
assert.equal(
BookmarkController.nextBusinessDay().format("YYYY-MM-DD"),
@ -90,7 +95,7 @@ QUnit.test(
QUnit.test(
"nextBusinessDay gets next business day of thursday correctly if today is wednesday",
function(assert) {
mockMomentTz("2019-12-11T08:00:00Z");
mockMomentTz("2019-12-11T08:00:00");
assert.equal(
BookmarkController.nextBusinessDay().format("YYYY-MM-DD"),
@ -100,7 +105,7 @@ QUnit.test(
);
QUnit.test("tomorrow gets tomorrow correctly", function(assert) {
mockMomentTz("2019-12-11T08:00:00Z");
mockMomentTz("2019-12-11T08:00:00");
assert.equal(
BookmarkController.tomorrow().format("YYYY-MM-DD"),
@ -112,7 +117,7 @@ QUnit.test(
"startOfDay changes the time of the provided date to 8:00am correctly",
function(assert) {
let dt = moment.tz(
"2019-12-11T11:37:16Z",
"2019-12-11T11:37:16",
BookmarkController.currentUser.timezone
);
@ -126,11 +131,11 @@ QUnit.test(
QUnit.test(
"laterToday gets 3 hours from now and if before half-past, it sets the time to half-past",
function(assert) {
mockMomentTz("2019-12-11T08:13:00Z");
mockMomentTz("2019-12-11T08:13:00");
assert.equal(
BookmarkController.laterToday().format("YYYY-MM-DD HH:mm:ss"),
"2019-12-11 21:30:00"
"2019-12-11 11:30:00"
);
}
);
@ -138,11 +143,39 @@ QUnit.test(
QUnit.test(
"laterToday gets 3 hours from now and if after half-past, it rounds up to the next hour",
function(assert) {
mockMomentTz("2019-12-11T08:43:00Z");
mockMomentTz("2019-12-11T08:43:00");
assert.equal(
BookmarkController.laterToday().format("YYYY-MM-DD HH:mm:ss"),
"2019-12-11 22:00:00"
"2019-12-11 12:00:00"
);
}
);
QUnit.test(
"loadLastUsedCustomReminderDatetime fills the custom reminder date + time if present in localStorage",
function(assert) {
mockMomentTz("2019-12-11T08:00:00");
localStorage.lastCustomBookmarkReminderDate = "2019-12-12";
localStorage.lastCustomBookmarkReminderTime = "08:00";
BookmarkController.loadLastUsedCustomReminderDatetime();
assert.equal(BookmarkController.lastCustomReminderDate, "2019-12-12");
assert.equal(BookmarkController.lastCustomReminderTime, "08:00");
}
);
QUnit.test(
"loadLastUsedCustomReminderDatetime does not fills the custom reminder date + time if the datetime in localStorage is < now",
function(assert) {
mockMomentTz("2019-12-11T08:00:00");
localStorage.lastCustomBookmarkReminderDate = "2019-12-11";
localStorage.lastCustomBookmarkReminderTime = "07:00";
BookmarkController.loadLastUsedCustomReminderDatetime();
assert.equal(BookmarkController.lastCustomReminderDate, null);
assert.equal(BookmarkController.lastCustomReminderTime, null);
}
);