mirror of
https://github.com/discourse/discourse.git
synced 2024-12-04 11:43:43 +08:00
5268568d23
This PR removes the user reminder topic timers, because that system has been supplanted and improved by bookmark reminders. The option is removed from the UI and all existing user reminder topic timers are migrated to bookmark reminders. Migration does this: * Get all topic_timers with status_type 5 (reminders) * Gets all bookmarks where the user ID and topic ID match * Loops through the found topic timers * If there is no bookmark for the OP of the topic, then we just create a bookmark with a reminder * If there is a bookmark for the OP of the topic and it does **not** have a reminder set, then just update it with the topic timer reminder * If there is a bookmark for the OP of the topic with a reminder then just discard the topic timer * Cancels all outstanding user reminder topic timers * **Trashes (not deletes) all user reminder topic timers** Notes: * For now I have left the user reminder topic timer job class in place; this is so the jobs can be cancelled in the migration. It and the specs will be deleted in the next PR. * At a later date I will write a migration to delete all trashed user topic timers. They are not deleted here in case there are data issues and they need to be recovered. * A future PR will change the UI of the topic timer modal to make it look more like the bookmark modal.
235 lines
8.4 KiB
JavaScript
235 lines
8.4 KiB
JavaScript
import selectKit from "helpers/select-kit-helper";
|
|
import { acceptance, updateCurrentUser } from "helpers/qunit-helpers";
|
|
|
|
acceptance("Topic - Edit timer", {
|
|
loggedIn: true,
|
|
pretend(server, helper) {
|
|
server.post("/t/280/timer", () =>
|
|
helper.response({
|
|
success: "OK",
|
|
execute_at: new Date(
|
|
new Date().getTime() + 1 * 60 * 60 * 1000
|
|
).toISOString(),
|
|
duration: 1,
|
|
based_on_last_post: false,
|
|
closed: false,
|
|
category_id: null,
|
|
})
|
|
);
|
|
},
|
|
});
|
|
|
|
QUnit.test("default", async (assert) => {
|
|
updateCurrentUser({ moderator: true });
|
|
const futureDateInputSelector = selectKit(".future-date-input-selector");
|
|
|
|
await visit("/t/internationalization-localization");
|
|
await click(".toggle-admin-menu");
|
|
await click(".topic-admin-status-update button");
|
|
|
|
assert.equal(futureDateInputSelector.header().label(), "Select a timeframe");
|
|
assert.equal(futureDateInputSelector.header().value(), null);
|
|
});
|
|
|
|
QUnit.test("autoclose - specific time", async (assert) => {
|
|
updateCurrentUser({ moderator: true });
|
|
const futureDateInputSelector = selectKit(".future-date-input-selector");
|
|
|
|
await visit("/t/internationalization-localization");
|
|
await click(".toggle-admin-menu");
|
|
await click(".topic-admin-status-update button");
|
|
|
|
await futureDateInputSelector.expand();
|
|
await futureDateInputSelector.selectRowByValue("next_week");
|
|
|
|
assert.ok(futureDateInputSelector.header().label().includes("Next week"));
|
|
assert.equal(futureDateInputSelector.header().value(), "next_week");
|
|
|
|
const regex = /will automatically close in/g;
|
|
const html = find(".future-date-input .topic-status-info").html().trim();
|
|
assert.ok(regex.test(html));
|
|
});
|
|
|
|
QUnit.skip("autoclose", async (assert) => {
|
|
updateCurrentUser({ moderator: true });
|
|
const futureDateInputSelector = selectKit(".future-date-input-selector");
|
|
|
|
await visit("/t/internationalization-localization");
|
|
await click(".toggle-admin-menu");
|
|
await click(".topic-admin-status-update button");
|
|
|
|
await futureDateInputSelector.expand();
|
|
await futureDateInputSelector.selectRowByValue("next_week");
|
|
|
|
assert.ok(futureDateInputSelector.header().label().includes("Next week"));
|
|
assert.equal(futureDateInputSelector.header().value(), "next_week");
|
|
|
|
const regex1 = /will automatically close in/g;
|
|
const html1 = find(".future-date-input .topic-status-info").html().trim();
|
|
assert.ok(regex1.test(html1));
|
|
|
|
await futureDateInputSelector.expand();
|
|
await futureDateInputSelector.selectRowByValue("pick_date_and_time");
|
|
|
|
await fillIn(".future-date-input .date-picker", "2099-11-24");
|
|
|
|
assert.ok(
|
|
futureDateInputSelector.header().label().includes("Pick date and time")
|
|
);
|
|
assert.equal(futureDateInputSelector.header().value(), "pick_date_and_time");
|
|
|
|
const regex2 = /will automatically close in/g;
|
|
const html2 = find(".future-date-input .topic-status-info").html().trim();
|
|
assert.ok(regex2.test(html2));
|
|
|
|
await futureDateInputSelector.expand();
|
|
await futureDateInputSelector.selectRowByValue("set_based_on_last_post");
|
|
|
|
await fillIn(".future-date-input input[type=number]", "2");
|
|
|
|
assert.ok(
|
|
futureDateInputSelector
|
|
.header()
|
|
.label()
|
|
.includes("Close based on last post")
|
|
);
|
|
assert.equal(
|
|
futureDateInputSelector.header().value(),
|
|
"set_based_on_last_post"
|
|
);
|
|
|
|
const regex3 = /This topic will close.*after the last reply/g;
|
|
const html3 = find(".future-date-input .topic-status-info").html().trim();
|
|
assert.ok(regex3.test(html3));
|
|
});
|
|
|
|
QUnit.test("close temporarily", async (assert) => {
|
|
updateCurrentUser({ moderator: true });
|
|
const timerType = selectKit(".select-kit.timer-type");
|
|
const futureDateInputSelector = selectKit(".future-date-input-selector");
|
|
|
|
await visit("/t/internationalization-localization");
|
|
await click(".toggle-admin-menu");
|
|
await click(".topic-admin-status-update button");
|
|
|
|
await timerType.expand();
|
|
await timerType.selectRowByValue("open");
|
|
|
|
assert.equal(futureDateInputSelector.header().label(), "Select a timeframe");
|
|
assert.equal(futureDateInputSelector.header().value(), null);
|
|
|
|
await futureDateInputSelector.expand();
|
|
await futureDateInputSelector.selectRowByValue("next_week");
|
|
|
|
assert.ok(futureDateInputSelector.header().label().includes("Next week"));
|
|
assert.equal(futureDateInputSelector.header().value(), "next_week");
|
|
|
|
const regex1 = /will automatically open in/g;
|
|
const html1 = find(".future-date-input .topic-status-info").html().trim();
|
|
assert.ok(regex1.test(html1));
|
|
|
|
await futureDateInputSelector.expand();
|
|
await futureDateInputSelector.selectRowByValue("pick_date_and_time");
|
|
|
|
await fillIn(".future-date-input .date-picker", "2099-11-24");
|
|
|
|
assert.equal(futureDateInputSelector.header().label(), "Pick date and time");
|
|
assert.equal(futureDateInputSelector.header().value(), "pick_date_and_time");
|
|
|
|
const regex2 = /will automatically open in/g;
|
|
const html2 = find(".future-date-input .topic-status-info").html().trim();
|
|
assert.ok(regex2.test(html2));
|
|
});
|
|
|
|
QUnit.test("schedule", async (assert) => {
|
|
updateCurrentUser({ moderator: true });
|
|
const timerType = selectKit(".select-kit.timer-type");
|
|
const categoryChooser = selectKit(".modal-body .category-chooser");
|
|
const futureDateInputSelector = selectKit(".future-date-input-selector");
|
|
|
|
await visit("/t/internationalization-localization");
|
|
await click(".toggle-admin-menu");
|
|
await click(".topic-admin-status-update button");
|
|
|
|
await timerType.expand();
|
|
await timerType.selectRowByValue("publish_to_category");
|
|
|
|
assert.equal(categoryChooser.header().label(), "uncategorized");
|
|
assert.equal(categoryChooser.header().value(), null);
|
|
|
|
assert.equal(futureDateInputSelector.header().label(), "Select a timeframe");
|
|
assert.equal(futureDateInputSelector.header().value(), null);
|
|
|
|
await categoryChooser.expand();
|
|
await categoryChooser.selectRowByValue("7");
|
|
|
|
await futureDateInputSelector.expand();
|
|
await futureDateInputSelector.selectRowByValue("next_week");
|
|
|
|
assert.ok(futureDateInputSelector.header().label().includes("Next week"));
|
|
assert.equal(futureDateInputSelector.header().value(), "next_week");
|
|
|
|
const regex = /will be published to #dev/g;
|
|
const text = find(".future-date-input .topic-status-info").text().trim();
|
|
assert.ok(regex.test(text));
|
|
});
|
|
|
|
QUnit.test("TL4 can't auto-delete", async (assert) => {
|
|
updateCurrentUser({ moderator: false, admin: false, trust_level: 4 });
|
|
|
|
await visit("/t/internationalization-localization");
|
|
await click(".toggle-admin-menu");
|
|
await click(".topic-admin-status-update button");
|
|
|
|
const timerType = selectKit(".select-kit.timer-type");
|
|
|
|
await timerType.expand();
|
|
|
|
assert.ok(!timerType.rowByValue("delete").exists());
|
|
});
|
|
|
|
QUnit.test("auto delete", async (assert) => {
|
|
updateCurrentUser({ moderator: true });
|
|
const timerType = selectKit(".select-kit.timer-type");
|
|
const futureDateInputSelector = selectKit(".future-date-input-selector");
|
|
|
|
await visit("/t/internationalization-localization");
|
|
await click(".toggle-admin-menu");
|
|
await click(".topic-admin-status-update button");
|
|
|
|
await timerType.expand();
|
|
await timerType.selectRowByValue("delete");
|
|
|
|
assert.equal(futureDateInputSelector.header().label(), "Select a timeframe");
|
|
assert.equal(futureDateInputSelector.header().value(), null);
|
|
|
|
await futureDateInputSelector.expand();
|
|
await futureDateInputSelector.selectRowByValue("two_weeks");
|
|
|
|
assert.ok(futureDateInputSelector.header().label().includes("Two Weeks"));
|
|
assert.equal(futureDateInputSelector.header().value(), "two_weeks");
|
|
|
|
const regex = /will be automatically deleted/g;
|
|
const html = find(".future-date-input .topic-status-info").html().trim();
|
|
assert.ok(regex.test(html));
|
|
});
|
|
|
|
QUnit.test("Inline delete timer", async (assert) => {
|
|
updateCurrentUser({ moderator: true });
|
|
const futureDateInputSelector = selectKit(".future-date-input-selector");
|
|
|
|
await visit("/t/internationalization-localization");
|
|
await click(".toggle-admin-menu");
|
|
await click(".topic-admin-status-update button");
|
|
await futureDateInputSelector.expand();
|
|
await futureDateInputSelector.selectRowByValue("next_week");
|
|
await click(".modal-footer button.btn-primary");
|
|
|
|
const removeTimerButton = find(".topic-status-info .topic-timer-remove");
|
|
assert.equal(removeTimerButton.attr("title"), "remove timer");
|
|
|
|
await click(".topic-status-info .topic-timer-remove");
|
|
const topicStatusInfo = find(".topic-status-info .topic-timer-remove");
|
|
assert.equal(topicStatusInfo.length, 0);
|
|
});
|