2019-06-06 16:47:10 +08:00
|
|
|
import selectKit from "helpers/select-kit-helper";
|
2019-06-14 20:54:20 +08:00
|
|
|
import { acceptance, updateCurrentUser } from "helpers/qunit-helpers";
|
2019-06-06 16:47:10 +08:00
|
|
|
|
2018-07-26 18:16:32 +08:00
|
|
|
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
|
|
|
|
})
|
|
|
|
);
|
|
|
|
}
|
|
|
|
});
|
2018-07-26 09:48:38 +08:00
|
|
|
|
2018-07-26 18:16:32 +08:00
|
|
|
QUnit.test("default", async assert => {
|
2020-07-17 04:06:27 +08:00
|
|
|
updateCurrentUser({ moderator: true });
|
2017-12-22 20:08:12 +08:00
|
|
|
const timerType = selectKit(".select-kit.timer-type");
|
|
|
|
const futureDateInputSelector = selectKit(".future-date-input-selector");
|
|
|
|
|
2018-07-26 18:16:32 +08:00
|
|
|
await visit("/t/internationalization-localization");
|
|
|
|
await click(".toggle-admin-menu");
|
|
|
|
await click(".topic-admin-status-update button");
|
2017-11-24 09:48:45 +08:00
|
|
|
|
2020-02-03 21:22:14 +08:00
|
|
|
assert.equal(futureDateInputSelector.header().label(), "Select a timeframe");
|
2018-07-26 18:16:32 +08:00
|
|
|
assert.equal(futureDateInputSelector.header().value(), null);
|
2017-11-24 09:48:45 +08:00
|
|
|
|
2018-07-26 18:16:32 +08:00
|
|
|
await click("#private-topic-timer");
|
2017-11-24 09:48:45 +08:00
|
|
|
|
2020-02-03 21:22:14 +08:00
|
|
|
assert.equal(timerType.header().label(), "Remind Me");
|
2018-07-26 18:16:32 +08:00
|
|
|
assert.equal(timerType.header().value(), "reminder");
|
2017-12-22 20:08:12 +08:00
|
|
|
|
2020-02-03 21:22:14 +08:00
|
|
|
assert.equal(futureDateInputSelector.header().label(), "Select a timeframe");
|
2018-07-26 18:16:32 +08:00
|
|
|
assert.equal(futureDateInputSelector.header().value(), null);
|
2017-11-24 09:48:45 +08:00
|
|
|
});
|
|
|
|
|
2018-07-26 18:16:32 +08:00
|
|
|
QUnit.test("autoclose - specific time", async assert => {
|
2020-07-17 04:06:27 +08:00
|
|
|
updateCurrentUser({ moderator: true });
|
2017-12-22 20:08:12 +08:00
|
|
|
const futureDateInputSelector = selectKit(".future-date-input-selector");
|
|
|
|
|
2018-07-26 18:16:32 +08:00
|
|
|
await visit("/t/internationalization-localization");
|
|
|
|
await click(".toggle-admin-menu");
|
|
|
|
await click(".topic-admin-status-update button");
|
2017-12-22 20:08:12 +08:00
|
|
|
|
2018-07-30 04:51:32 +08:00
|
|
|
await futureDateInputSelector.expand();
|
|
|
|
await futureDateInputSelector.selectRowByValue("next_week");
|
2017-11-24 09:48:45 +08:00
|
|
|
|
2020-02-03 21:22:14 +08:00
|
|
|
assert.ok(
|
|
|
|
futureDateInputSelector
|
|
|
|
.header()
|
|
|
|
.label()
|
|
|
|
.includes("Next week")
|
|
|
|
);
|
2018-07-26 18:16:32 +08:00
|
|
|
assert.equal(futureDateInputSelector.header().value(), "next_week");
|
2017-12-22 20:08:12 +08:00
|
|
|
|
2018-07-26 18:16:32 +08:00
|
|
|
const regex = /will automatically close in/g;
|
|
|
|
const html = find(".future-date-input .topic-status-info")
|
|
|
|
.html()
|
|
|
|
.trim();
|
|
|
|
assert.ok(regex.test(html));
|
2017-11-24 09:48:45 +08:00
|
|
|
});
|
|
|
|
|
2020-03-26 05:40:52 +08:00
|
|
|
QUnit.skip("autoclose", async assert => {
|
2020-07-17 04:06:27 +08:00
|
|
|
updateCurrentUser({ moderator: true });
|
2017-12-22 20:08:12 +08:00
|
|
|
const futureDateInputSelector = selectKit(".future-date-input-selector");
|
|
|
|
|
2018-07-26 18:16:32 +08:00
|
|
|
await visit("/t/internationalization-localization");
|
|
|
|
await click(".toggle-admin-menu");
|
|
|
|
await click(".topic-admin-status-update button");
|
2017-11-24 09:48:45 +08:00
|
|
|
|
2018-07-30 04:51:32 +08:00
|
|
|
await futureDateInputSelector.expand();
|
|
|
|
await futureDateInputSelector.selectRowByValue("next_week");
|
2017-12-22 20:08:12 +08:00
|
|
|
|
2020-02-03 21:22:14 +08:00
|
|
|
assert.ok(
|
|
|
|
futureDateInputSelector
|
|
|
|
.header()
|
|
|
|
.label()
|
|
|
|
.includes("Next week")
|
|
|
|
);
|
2018-07-26 18:16:32 +08:00
|
|
|
assert.equal(futureDateInputSelector.header().value(), "next_week");
|
2017-12-22 20:08:12 +08:00
|
|
|
|
2018-07-26 18:16:32 +08:00
|
|
|
const regex1 = /will automatically close in/g;
|
|
|
|
const html1 = find(".future-date-input .topic-status-info")
|
|
|
|
.html()
|
|
|
|
.trim();
|
|
|
|
assert.ok(regex1.test(html1));
|
2017-11-24 09:48:45 +08:00
|
|
|
|
2018-07-30 04:51:32 +08:00
|
|
|
await futureDateInputSelector.expand();
|
|
|
|
await futureDateInputSelector.selectRowByValue("pick_date_and_time");
|
2017-12-22 20:08:12 +08:00
|
|
|
|
2018-07-26 18:16:32 +08:00
|
|
|
await fillIn(".future-date-input .date-picker", "2099-11-24");
|
2017-11-24 09:48:45 +08:00
|
|
|
|
2020-02-03 21:22:14 +08:00
|
|
|
assert.ok(
|
|
|
|
futureDateInputSelector
|
|
|
|
.header()
|
|
|
|
.label()
|
|
|
|
.includes("Pick date and time")
|
|
|
|
);
|
2018-07-26 18:16:32 +08:00
|
|
|
assert.equal(futureDateInputSelector.header().value(), "pick_date_and_time");
|
2017-12-22 20:08:12 +08:00
|
|
|
|
2018-07-26 18:16:32 +08:00
|
|
|
const regex2 = /will automatically close in/g;
|
|
|
|
const html2 = find(".future-date-input .topic-status-info")
|
|
|
|
.html()
|
|
|
|
.trim();
|
|
|
|
assert.ok(regex2.test(html2));
|
2017-11-24 09:48:45 +08:00
|
|
|
|
2018-07-30 04:51:32 +08:00
|
|
|
await futureDateInputSelector.expand();
|
|
|
|
await futureDateInputSelector.selectRowByValue("set_based_on_last_post");
|
2017-12-22 20:08:12 +08:00
|
|
|
|
2018-07-26 18:16:32 +08:00
|
|
|
await fillIn(".future-date-input input[type=number]", "2");
|
2017-12-22 20:08:12 +08:00
|
|
|
|
2020-02-03 21:22:14 +08:00
|
|
|
assert.ok(
|
|
|
|
futureDateInputSelector
|
|
|
|
.header()
|
|
|
|
.label()
|
|
|
|
.includes("Close based on last post")
|
2018-07-26 18:16:32 +08:00
|
|
|
);
|
|
|
|
assert.equal(
|
|
|
|
futureDateInputSelector.header().value(),
|
|
|
|
"set_based_on_last_post"
|
|
|
|
);
|
2017-12-22 20:08:12 +08:00
|
|
|
|
2018-07-26 18:16:32 +08:00
|
|
|
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));
|
2017-11-24 09:48:45 +08:00
|
|
|
});
|
|
|
|
|
2018-07-26 18:16:32 +08:00
|
|
|
QUnit.test("close temporarily", async assert => {
|
2020-07-17 04:06:27 +08:00
|
|
|
updateCurrentUser({ moderator: true });
|
2017-12-22 20:08:12 +08:00
|
|
|
const timerType = selectKit(".select-kit.timer-type");
|
|
|
|
const futureDateInputSelector = selectKit(".future-date-input-selector");
|
|
|
|
|
2018-07-26 18:16:32 +08:00
|
|
|
await visit("/t/internationalization-localization");
|
|
|
|
await click(".toggle-admin-menu");
|
|
|
|
await click(".topic-admin-status-update button");
|
2017-11-24 09:48:45 +08:00
|
|
|
|
2018-07-30 04:51:32 +08:00
|
|
|
await timerType.expand();
|
|
|
|
await timerType.selectRowByValue("open");
|
2017-11-24 09:48:45 +08:00
|
|
|
|
2020-02-03 21:22:14 +08:00
|
|
|
assert.equal(futureDateInputSelector.header().label(), "Select a timeframe");
|
2018-07-26 18:16:32 +08:00
|
|
|
assert.equal(futureDateInputSelector.header().value(), null);
|
2017-11-24 09:48:45 +08:00
|
|
|
|
2018-07-30 04:51:32 +08:00
|
|
|
await futureDateInputSelector.expand();
|
|
|
|
await futureDateInputSelector.selectRowByValue("next_week");
|
2017-12-22 20:08:12 +08:00
|
|
|
|
2020-02-03 21:22:14 +08:00
|
|
|
assert.ok(
|
|
|
|
futureDateInputSelector
|
|
|
|
.header()
|
|
|
|
.label()
|
|
|
|
.includes("Next week")
|
|
|
|
);
|
2018-07-26 18:16:32 +08:00
|
|
|
assert.equal(futureDateInputSelector.header().value(), "next_week");
|
2017-12-22 20:08:12 +08:00
|
|
|
|
2018-07-26 18:16:32 +08:00
|
|
|
const regex1 = /will automatically open in/g;
|
|
|
|
const html1 = find(".future-date-input .topic-status-info")
|
|
|
|
.html()
|
|
|
|
.trim();
|
|
|
|
assert.ok(regex1.test(html1));
|
2017-11-24 09:48:45 +08:00
|
|
|
|
2018-07-30 04:51:32 +08:00
|
|
|
await futureDateInputSelector.expand();
|
|
|
|
await futureDateInputSelector.selectRowByValue("pick_date_and_time");
|
2017-12-22 20:08:12 +08:00
|
|
|
|
2018-07-26 18:16:32 +08:00
|
|
|
await fillIn(".future-date-input .date-picker", "2099-11-24");
|
2017-11-24 09:48:45 +08:00
|
|
|
|
2020-02-03 21:22:14 +08:00
|
|
|
assert.equal(futureDateInputSelector.header().label(), "Pick date and time");
|
2018-07-26 18:16:32 +08:00
|
|
|
assert.equal(futureDateInputSelector.header().value(), "pick_date_and_time");
|
2017-12-22 20:08:12 +08:00
|
|
|
|
2018-07-26 18:16:32 +08:00
|
|
|
const regex2 = /will automatically open in/g;
|
|
|
|
const html2 = find(".future-date-input .topic-status-info")
|
|
|
|
.html()
|
|
|
|
.trim();
|
|
|
|
assert.ok(regex2.test(html2));
|
2017-11-24 09:48:45 +08:00
|
|
|
});
|
|
|
|
|
2018-07-26 18:16:32 +08:00
|
|
|
QUnit.test("schedule", async assert => {
|
2020-07-17 04:06:27 +08:00
|
|
|
updateCurrentUser({ moderator: true });
|
2017-12-22 20:08:12 +08:00
|
|
|
const timerType = selectKit(".select-kit.timer-type");
|
|
|
|
const categoryChooser = selectKit(".modal-body .category-chooser");
|
|
|
|
const futureDateInputSelector = selectKit(".future-date-input-selector");
|
|
|
|
|
2018-07-26 18:16:32 +08:00
|
|
|
await visit("/t/internationalization-localization");
|
|
|
|
await click(".toggle-admin-menu");
|
|
|
|
await click(".topic-admin-status-update button");
|
2017-11-24 09:48:45 +08:00
|
|
|
|
2018-07-30 04:51:32 +08:00
|
|
|
await timerType.expand();
|
|
|
|
await timerType.selectRowByValue("publish_to_category");
|
2017-11-24 09:48:45 +08:00
|
|
|
|
2020-02-03 21:22:14 +08:00
|
|
|
assert.equal(categoryChooser.header().label(), "uncategorized");
|
2018-07-26 18:16:32 +08:00
|
|
|
assert.equal(categoryChooser.header().value(), null);
|
2017-12-22 20:08:12 +08:00
|
|
|
|
2020-02-03 21:22:14 +08:00
|
|
|
assert.equal(futureDateInputSelector.header().label(), "Select a timeframe");
|
2018-07-26 18:16:32 +08:00
|
|
|
assert.equal(futureDateInputSelector.header().value(), null);
|
2017-11-24 09:48:45 +08:00
|
|
|
|
2018-07-30 04:51:32 +08:00
|
|
|
await categoryChooser.expand();
|
|
|
|
await categoryChooser.selectRowByValue("7");
|
2017-11-24 09:48:45 +08:00
|
|
|
|
2018-07-30 04:51:32 +08:00
|
|
|
await futureDateInputSelector.expand();
|
|
|
|
await futureDateInputSelector.selectRowByValue("next_week");
|
2017-11-24 09:48:45 +08:00
|
|
|
|
2020-02-03 21:22:14 +08:00
|
|
|
assert.ok(
|
|
|
|
futureDateInputSelector
|
|
|
|
.header()
|
|
|
|
.label()
|
|
|
|
.includes("Next week")
|
|
|
|
);
|
2018-07-26 18:16:32 +08:00
|
|
|
assert.equal(futureDateInputSelector.header().value(), "next_week");
|
2017-12-22 20:08:12 +08:00
|
|
|
|
2018-07-26 18:16:32 +08:00
|
|
|
const regex = /will be published to #dev/g;
|
|
|
|
const text = find(".future-date-input .topic-status-info")
|
|
|
|
.text()
|
|
|
|
.trim();
|
|
|
|
assert.ok(regex.test(text));
|
2017-11-24 09:48:45 +08:00
|
|
|
});
|
|
|
|
|
2018-07-26 18:16:32 +08:00
|
|
|
QUnit.test("TL4 can't auto-delete", async assert => {
|
2019-07-25 04:01:08 +08:00
|
|
|
updateCurrentUser({ moderator: false, admin: false, trust_level: 4 });
|
2018-05-17 06:42:48 +08:00
|
|
|
|
2018-07-26 18:16:32 +08:00
|
|
|
await visit("/t/internationalization-localization");
|
|
|
|
await click(".toggle-admin-menu");
|
|
|
|
await click(".topic-admin-status-update button");
|
2018-05-17 06:42:48 +08:00
|
|
|
|
|
|
|
const timerType = selectKit(".select-kit.timer-type");
|
|
|
|
|
2018-07-30 04:51:32 +08:00
|
|
|
await timerType.expand();
|
2018-05-17 06:42:48 +08:00
|
|
|
|
2018-07-26 18:16:32 +08:00
|
|
|
assert.ok(!timerType.rowByValue("delete").exists());
|
2018-05-17 06:42:48 +08:00
|
|
|
});
|
|
|
|
|
2018-07-26 18:16:32 +08:00
|
|
|
QUnit.test("auto delete", async assert => {
|
2020-07-17 04:06:27 +08:00
|
|
|
updateCurrentUser({ moderator: true });
|
2017-12-22 20:08:12 +08:00
|
|
|
const timerType = selectKit(".select-kit.timer-type");
|
|
|
|
const futureDateInputSelector = selectKit(".future-date-input-selector");
|
|
|
|
|
2018-07-26 18:16:32 +08:00
|
|
|
await visit("/t/internationalization-localization");
|
|
|
|
await click(".toggle-admin-menu");
|
|
|
|
await click(".topic-admin-status-update button");
|
2017-11-24 09:48:45 +08:00
|
|
|
|
2018-07-30 04:51:32 +08:00
|
|
|
await timerType.expand();
|
|
|
|
await timerType.selectRowByValue("delete");
|
2017-11-24 09:48:45 +08:00
|
|
|
|
2020-02-03 21:22:14 +08:00
|
|
|
assert.equal(futureDateInputSelector.header().label(), "Select a timeframe");
|
2018-07-26 18:16:32 +08:00
|
|
|
assert.equal(futureDateInputSelector.header().value(), null);
|
2017-11-24 09:48:45 +08:00
|
|
|
|
2018-07-30 04:51:32 +08:00
|
|
|
await futureDateInputSelector.expand();
|
|
|
|
await futureDateInputSelector.selectRowByValue("two_weeks");
|
2017-12-22 20:08:12 +08:00
|
|
|
|
2020-02-03 21:22:14 +08:00
|
|
|
assert.ok(
|
|
|
|
futureDateInputSelector
|
|
|
|
.header()
|
|
|
|
.label()
|
|
|
|
.includes("Two Weeks")
|
|
|
|
);
|
2018-07-26 18:16:32 +08:00
|
|
|
assert.equal(futureDateInputSelector.header().value(), "two_weeks");
|
2017-12-22 20:08:12 +08:00
|
|
|
|
2018-07-26 18:16:32 +08:00
|
|
|
const regex = /will be automatically deleted/g;
|
|
|
|
const html = find(".future-date-input .topic-status-info")
|
|
|
|
.html()
|
|
|
|
.trim();
|
|
|
|
assert.ok(regex.test(html));
|
2017-11-24 09:48:45 +08:00
|
|
|
});
|
2018-07-26 09:48:38 +08:00
|
|
|
|
2019-06-26 23:08:53 +08:00
|
|
|
QUnit.test("Inline delete timer", async assert => {
|
2020-07-17 04:06:27 +08:00
|
|
|
updateCurrentUser({ moderator: true });
|
2019-06-26 23:08:53 +08:00
|
|
|
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);
|
|
|
|
});
|