mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FEATURE: Bookmark reminder type changes and bugfixes (#9329)
New Reminder Types ------------------------------------- * Add a "later this week" reminder which is today + 2 days, will not show if we are on the days Thu-Sun * Add a "start of next business week" reminder which is 8am Monday Bugfixes and Tweaks -------------------------------------- * Move dates out of translation for reminder types and yield HTML for tap-tile for more customizable content and styling * Make sure double clicking the bookmark icon in quick access takes users to the new bookmarks-with-reminders page * Sane default to 8am (start of day) for custom reminder with no time
This commit is contained in:
@@ -6,6 +6,7 @@ moduleFor("controller:bookmark", {
|
||||
beforeEach() {
|
||||
logIn();
|
||||
BookmarkController = this.subject({ currentUser: User.current() });
|
||||
BookmarkController.onShow();
|
||||
},
|
||||
|
||||
afterEach() {
|
||||
@@ -58,54 +59,34 @@ 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:00");
|
||||
QUnit.test("laterThisWeek gets 2 days from now", function(assert) {
|
||||
mockMomentTz("2019-12-10T08:00:00");
|
||||
|
||||
assert.equal(
|
||||
BookmarkController.nextBusinessDay().format("YYYY-MM-DD"),
|
||||
"2019-12-16"
|
||||
);
|
||||
}
|
||||
);
|
||||
assert.equal(
|
||||
BookmarkController.laterThisWeek().format("YYYY-MM-DD"),
|
||||
"2019-12-12"
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test(
|
||||
"nextBusinessDay gets next business day of monday correctly if today is saturday",
|
||||
function(assert) {
|
||||
mockMomentTz("2019-12-14T08:00:00");
|
||||
QUnit.test("laterThisWeek returns null if we are at Thursday already", function(
|
||||
assert
|
||||
) {
|
||||
mockMomentTz("2019-12-12T08:00:00");
|
||||
|
||||
assert.equal(
|
||||
BookmarkController.nextBusinessDay().format("YYYY-MM-DD"),
|
||||
"2019-12-16"
|
||||
);
|
||||
}
|
||||
);
|
||||
assert.equal(BookmarkController.laterThisWeek(), null);
|
||||
});
|
||||
|
||||
QUnit.test(
|
||||
"nextBusinessDay gets next business day of monday correctly if today is sunday",
|
||||
function(assert) {
|
||||
mockMomentTz("2019-12-15T08:00:00");
|
||||
QUnit.test("showLaterThisWeek returns true if < Thursday", function(assert) {
|
||||
mockMomentTz("2019-12-10T08:00:00");
|
||||
|
||||
assert.equal(
|
||||
BookmarkController.nextBusinessDay().format("YYYY-MM-DD"),
|
||||
"2019-12-16"
|
||||
);
|
||||
}
|
||||
);
|
||||
assert.equal(BookmarkController.showLaterThisWeek, true);
|
||||
});
|
||||
|
||||
QUnit.test(
|
||||
"nextBusinessDay gets next business day of thursday correctly if today is wednesday",
|
||||
function(assert) {
|
||||
mockMomentTz("2019-12-11T08:00:00");
|
||||
|
||||
assert.equal(
|
||||
BookmarkController.nextBusinessDay().format("YYYY-MM-DD"),
|
||||
"2019-12-12"
|
||||
);
|
||||
}
|
||||
);
|
||||
QUnit.test("showLaterThisWeek returns false if > Thursday", function(assert) {
|
||||
mockMomentTz("2019-12-12T08:00:00");
|
||||
|
||||
assert.equal(BookmarkController.showLaterThisWeek, false);
|
||||
});
|
||||
QUnit.test("tomorrow gets tomorrow correctly", function(assert) {
|
||||
mockMomentTz("2019-12-11T08:00:00");
|
||||
|
||||
@@ -154,6 +135,27 @@ QUnit.test(
|
||||
}
|
||||
);
|
||||
|
||||
QUnit.test(
|
||||
"reminderAt - custom - defaults to 8:00am if the time is not selected",
|
||||
function(assert) {
|
||||
BookmarkController.customReminderDate = "2028-12-12";
|
||||
BookmarkController.selectedReminderType =
|
||||
BookmarkController.reminderTypes.CUSTOM;
|
||||
const reminderAt = BookmarkController.reminderAt();
|
||||
assert.equal(BookmarkController.customReminderTime, "08:00");
|
||||
assert.equal(
|
||||
reminderAt.toString(),
|
||||
moment
|
||||
.tz(
|
||||
"2028-12-12 08:00",
|
||||
BookmarkController.currentUser.resolvedTimezone()
|
||||
)
|
||||
.toString(),
|
||||
"the custom date and time are parsed correctly with default time"
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
QUnit.test(
|
||||
"loadLastUsedCustomReminderDatetime fills the custom reminder date + time if present in localStorage",
|
||||
function(assert) {
|
||||
|
||||
Reference in New Issue
Block a user