2018-06-15 11:03:24 -04:00
|
|
|
import { acceptance, replaceCurrentUser } from "helpers/qunit-helpers";
|
2018-07-26 06:16:32 -04: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
|
|
|
|
})
|
|
|
|
);
|
2017-11-23 20:48:45 -05:00
|
|
|
|
2018-07-26 06:16:32 -04:00
|
|
|
server.put("/t/internationalization-localization/280/status", () =>
|
|
|
|
helper.response({
|
|
|
|
success: "OK",
|
|
|
|
topic_status_update: null
|
|
|
|
})
|
|
|
|
);
|
|
|
|
}
|
|
|
|
});
|
2018-07-25 21:48:38 -04:00
|
|
|
|
2018-07-26 06:16:32 -04:00
|
|
|
QUnit.test("default", async assert => {
|
2018-06-15 11:03:24 -04:00
|
|
|
const timerType = selectKit(".select-kit.timer-type");
|
|
|
|
const futureDateInputSelector = selectKit(".future-date-input-selector");
|
2017-12-22 07:08:12 -05:00
|
|
|
|
2018-07-26 06:16:32 -04:00
|
|
|
await visit("/t/internationalization-localization");
|
|
|
|
await click(".toggle-admin-menu");
|
|
|
|
await click(".topic-admin-status-update button");
|
2017-11-23 20:48:45 -05:00
|
|
|
|
2018-07-26 06:16:32 -04:00
|
|
|
assert.equal(futureDateInputSelector.header().title(), "Select a timeframe");
|
|
|
|
assert.equal(futureDateInputSelector.header().value(), null);
|
2017-11-23 20:48:45 -05:00
|
|
|
|
2018-07-26 06:16:32 -04:00
|
|
|
await click("#private-topic-timer");
|
2017-11-23 20:48:45 -05:00
|
|
|
|
2018-07-26 06:16:32 -04:00
|
|
|
assert.equal(timerType.header().title(), "Remind Me");
|
|
|
|
assert.equal(timerType.header().value(), "reminder");
|
2017-12-22 07:08:12 -05:00
|
|
|
|
2018-07-26 06:16:32 -04:00
|
|
|
assert.equal(futureDateInputSelector.header().title(), "Select a timeframe");
|
|
|
|
assert.equal(futureDateInputSelector.header().value(), null);
|
2017-11-23 20:48:45 -05:00
|
|
|
});
|
|
|
|
|
2018-07-26 06:16:32 -04:00
|
|
|
QUnit.test("autoclose - specific time", async assert => {
|
2018-06-15 11:03:24 -04:00
|
|
|
const futureDateInputSelector = selectKit(".future-date-input-selector");
|
2017-12-22 07:08:12 -05:00
|
|
|
|
2018-07-26 06:16:32 -04:00
|
|
|
await visit("/t/internationalization-localization");
|
|
|
|
await click(".toggle-admin-menu");
|
|
|
|
await click(".topic-admin-status-update button");
|
2017-12-22 07:08:12 -05:00
|
|
|
|
2018-07-26 06:16:32 -04:00
|
|
|
await futureDateInputSelector.expandAwait();
|
|
|
|
await futureDateInputSelector.selectRowByValueAwait("next_week");
|
2017-11-23 20:48:45 -05:00
|
|
|
|
2018-07-26 06:16:32 -04:00
|
|
|
assert.equal(futureDateInputSelector.header().title(), "Next week");
|
|
|
|
assert.equal(futureDateInputSelector.header().value(), "next_week");
|
2017-12-22 07:08:12 -05:00
|
|
|
|
2018-07-26 06:16:32 -04: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-23 20:48:45 -05:00
|
|
|
});
|
|
|
|
|
2018-07-26 06:16:32 -04:00
|
|
|
QUnit.test("autoclose", async assert => {
|
2018-06-15 11:03:24 -04:00
|
|
|
const futureDateInputSelector = selectKit(".future-date-input-selector");
|
2017-12-22 07:08:12 -05:00
|
|
|
|
2018-07-26 06:16:32 -04:00
|
|
|
await visit("/t/internationalization-localization");
|
|
|
|
await click(".toggle-admin-menu");
|
|
|
|
await click(".topic-admin-status-update button");
|
2017-11-23 20:48:45 -05:00
|
|
|
|
2018-07-26 06:16:32 -04:00
|
|
|
await futureDateInputSelector.expandAwait();
|
|
|
|
await futureDateInputSelector.selectRowByValueAwait("next_week");
|
2017-12-22 07:08:12 -05:00
|
|
|
|
2018-07-26 06:16:32 -04:00
|
|
|
assert.equal(futureDateInputSelector.header().title(), "Next week");
|
|
|
|
assert.equal(futureDateInputSelector.header().value(), "next_week");
|
2017-12-22 07:08:12 -05:00
|
|
|
|
2018-07-26 06:16:32 -04: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-23 20:48:45 -05:00
|
|
|
|
2018-07-26 06:16:32 -04:00
|
|
|
await futureDateInputSelector.expandAwait();
|
|
|
|
await futureDateInputSelector.selectRowByValueAwait("pick_date_and_time");
|
2017-12-22 07:08:12 -05:00
|
|
|
|
2018-07-26 06:16:32 -04:00
|
|
|
await fillIn(".future-date-input .date-picker", "2099-11-24");
|
2017-11-23 20:48:45 -05:00
|
|
|
|
2018-07-26 06:16:32 -04:00
|
|
|
assert.equal(futureDateInputSelector.header().title(), "Pick date and time");
|
|
|
|
assert.equal(futureDateInputSelector.header().value(), "pick_date_and_time");
|
2017-12-22 07:08:12 -05:00
|
|
|
|
2018-07-26 06:16:32 -04: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-23 20:48:45 -05:00
|
|
|
|
2018-07-26 06:16:32 -04:00
|
|
|
await futureDateInputSelector.expandAwait();
|
|
|
|
await futureDateInputSelector.selectRowByValueAwait("set_based_on_last_post");
|
2017-12-22 07:08:12 -05:00
|
|
|
|
2018-07-26 06:16:32 -04:00
|
|
|
await fillIn(".future-date-input input[type=number]", "2");
|
2017-12-22 07:08:12 -05:00
|
|
|
|
2018-07-26 06:16:32 -04:00
|
|
|
assert.equal(
|
|
|
|
futureDateInputSelector.header().title(),
|
|
|
|
"Close based on last post"
|
|
|
|
);
|
|
|
|
assert.equal(
|
|
|
|
futureDateInputSelector.header().value(),
|
|
|
|
"set_based_on_last_post"
|
|
|
|
);
|
2017-12-22 07:08:12 -05:00
|
|
|
|
2018-07-26 06:16:32 -04: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-23 20:48:45 -05:00
|
|
|
});
|
|
|
|
|
2018-07-26 06:16:32 -04:00
|
|
|
QUnit.test("close temporarily", async assert => {
|
2018-06-15 11:03:24 -04:00
|
|
|
const timerType = selectKit(".select-kit.timer-type");
|
|
|
|
const futureDateInputSelector = selectKit(".future-date-input-selector");
|
2017-12-22 07:08:12 -05:00
|
|
|
|
2018-07-26 06:16:32 -04:00
|
|
|
await visit("/t/internationalization-localization");
|
|
|
|
await click(".toggle-admin-menu");
|
|
|
|
await click(".topic-admin-status-update button");
|
2017-11-23 20:48:45 -05:00
|
|
|
|
2018-07-26 06:16:32 -04:00
|
|
|
await timerType.expandAwait();
|
|
|
|
await timerType.selectRowByValueAwait("open");
|
2017-11-23 20:48:45 -05:00
|
|
|
|
2018-07-26 06:16:32 -04:00
|
|
|
assert.equal(futureDateInputSelector.header().title(), "Select a timeframe");
|
|
|
|
assert.equal(futureDateInputSelector.header().value(), null);
|
2017-11-23 20:48:45 -05:00
|
|
|
|
2018-07-26 06:16:32 -04:00
|
|
|
await futureDateInputSelector.expandAwait();
|
|
|
|
await futureDateInputSelector.selectRowByValueAwait("next_week");
|
2017-12-22 07:08:12 -05:00
|
|
|
|
2018-07-26 06:16:32 -04:00
|
|
|
assert.equal(futureDateInputSelector.header().title(), "Next week");
|
|
|
|
assert.equal(futureDateInputSelector.header().value(), "next_week");
|
2017-12-22 07:08:12 -05:00
|
|
|
|
2018-07-26 06:16:32 -04: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-23 20:48:45 -05:00
|
|
|
|
2018-07-26 06:16:32 -04:00
|
|
|
await futureDateInputSelector.expandAwait();
|
|
|
|
await futureDateInputSelector.selectRowByValueAwait("pick_date_and_time");
|
2017-12-22 07:08:12 -05:00
|
|
|
|
2018-07-26 06:16:32 -04:00
|
|
|
await fillIn(".future-date-input .date-picker", "2099-11-24");
|
2017-11-23 20:48:45 -05:00
|
|
|
|
2018-07-26 06:16:32 -04:00
|
|
|
assert.equal(futureDateInputSelector.header().title(), "Pick date and time");
|
|
|
|
assert.equal(futureDateInputSelector.header().value(), "pick_date_and_time");
|
2017-12-22 07:08:12 -05:00
|
|
|
|
2018-07-26 06:16:32 -04: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-23 20:48:45 -05:00
|
|
|
});
|
|
|
|
|
2018-07-26 06:16:32 -04:00
|
|
|
QUnit.test("schedule", async assert => {
|
2018-06-15 11:03:24 -04:00
|
|
|
const timerType = selectKit(".select-kit.timer-type");
|
|
|
|
const categoryChooser = selectKit(".modal-body .category-chooser");
|
|
|
|
const futureDateInputSelector = selectKit(".future-date-input-selector");
|
2017-12-22 07:08:12 -05:00
|
|
|
|
2018-07-26 06:16:32 -04:00
|
|
|
await visit("/t/internationalization-localization");
|
|
|
|
await click(".toggle-admin-menu");
|
|
|
|
await click(".topic-admin-status-update button");
|
2017-11-23 20:48:45 -05:00
|
|
|
|
2018-07-26 06:16:32 -04:00
|
|
|
await timerType.expandAwait();
|
|
|
|
await timerType.selectRowByValueAwait("publish_to_category");
|
2017-11-23 20:48:45 -05:00
|
|
|
|
2018-07-26 06:16:32 -04:00
|
|
|
assert.equal(categoryChooser.header().title(), "uncategorized");
|
|
|
|
assert.equal(categoryChooser.header().value(), null);
|
2017-12-22 07:08:12 -05:00
|
|
|
|
2018-07-26 06:16:32 -04:00
|
|
|
assert.equal(futureDateInputSelector.header().title(), "Select a timeframe");
|
|
|
|
assert.equal(futureDateInputSelector.header().value(), null);
|
2017-11-23 20:48:45 -05:00
|
|
|
|
2018-07-26 06:16:32 -04:00
|
|
|
await categoryChooser.expandAwait();
|
|
|
|
await categoryChooser.selectRowByValueAwait("7");
|
2017-11-23 20:48:45 -05:00
|
|
|
|
2018-07-26 06:16:32 -04:00
|
|
|
await futureDateInputSelector.expandAwait();
|
|
|
|
await futureDateInputSelector.selectRowByValueAwait("next_week");
|
2017-11-23 20:48:45 -05:00
|
|
|
|
2018-07-26 06:16:32 -04:00
|
|
|
assert.equal(futureDateInputSelector.header().title(), "Next week");
|
|
|
|
assert.equal(futureDateInputSelector.header().value(), "next_week");
|
2017-12-22 07:08:12 -05:00
|
|
|
|
2018-07-26 06:16:32 -04: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-23 20:48:45 -05:00
|
|
|
});
|
|
|
|
|
2018-07-26 06:16:32 -04:00
|
|
|
QUnit.test("TL4 can't auto-delete", async assert => {
|
2018-05-16 18:42:48 -04:00
|
|
|
replaceCurrentUser({ staff: false, trust_level: 4 });
|
|
|
|
|
2018-07-26 06:16:32 -04:00
|
|
|
await visit("/t/internationalization-localization");
|
|
|
|
await click(".toggle-admin-menu");
|
|
|
|
await click(".topic-admin-status-update button");
|
2018-05-16 18:42:48 -04:00
|
|
|
|
2018-06-15 11:03:24 -04:00
|
|
|
const timerType = selectKit(".select-kit.timer-type");
|
2018-05-16 18:42:48 -04:00
|
|
|
|
2018-07-26 06:16:32 -04:00
|
|
|
await timerType.expandAwait();
|
2018-05-16 18:42:48 -04:00
|
|
|
|
2018-07-26 06:16:32 -04:00
|
|
|
assert.ok(!timerType.rowByValue("delete").exists());
|
2018-05-16 18:42:48 -04:00
|
|
|
});
|
|
|
|
|
2018-07-26 06:16:32 -04:00
|
|
|
QUnit.test("auto delete", async assert => {
|
2018-06-15 11:03:24 -04:00
|
|
|
const timerType = selectKit(".select-kit.timer-type");
|
|
|
|
const futureDateInputSelector = selectKit(".future-date-input-selector");
|
2017-12-22 07:08:12 -05:00
|
|
|
|
2018-07-26 06:16:32 -04:00
|
|
|
await visit("/t/internationalization-localization");
|
|
|
|
await click(".toggle-admin-menu");
|
|
|
|
await click(".topic-admin-status-update button");
|
2017-11-23 20:48:45 -05:00
|
|
|
|
2018-07-26 06:16:32 -04:00
|
|
|
await timerType.expandAwait();
|
|
|
|
await timerType.selectRowByValueAwait("delete");
|
2017-11-23 20:48:45 -05:00
|
|
|
|
2018-07-26 06:16:32 -04:00
|
|
|
assert.equal(futureDateInputSelector.header().title(), "Select a timeframe");
|
|
|
|
assert.equal(futureDateInputSelector.header().value(), null);
|
2017-11-23 20:48:45 -05:00
|
|
|
|
2018-07-26 06:16:32 -04:00
|
|
|
await futureDateInputSelector.expandAwait();
|
|
|
|
await futureDateInputSelector.selectRowByValueAwait("two_weeks");
|
2017-12-22 07:08:12 -05:00
|
|
|
|
2018-07-26 06:16:32 -04:00
|
|
|
assert.equal(futureDateInputSelector.header().title(), "Two Weeks");
|
|
|
|
assert.equal(futureDateInputSelector.header().value(), "two_weeks");
|
2017-12-22 07:08:12 -05:00
|
|
|
|
2018-07-26 06:16:32 -04: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-23 20:48:45 -05:00
|
|
|
});
|
2018-07-25 21:48:38 -04:00
|
|
|
|
|
|
|
QUnit.test(
|
|
|
|
"Manually closing before the timer will clear the status text",
|
|
|
|
async assert => {
|
|
|
|
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().selectRowByValue("next_week");
|
|
|
|
await click(".modal-footer button.btn-primary");
|
|
|
|
|
|
|
|
const regex = /will automatically close in/g;
|
|
|
|
const topicStatusInfo = find(".topic-status-info")
|
|
|
|
.html()
|
|
|
|
.trim();
|
|
|
|
assert.ok(regex.test(topicStatusInfo));
|
|
|
|
|
|
|
|
await click(".toggle-admin-menu");
|
|
|
|
await click(".topic-admin-close button");
|
|
|
|
|
|
|
|
const newTopicStatusInfo = find(".topic-status-info")
|
|
|
|
.html()
|
|
|
|
.trim();
|
|
|
|
assert.notOk(regex.test(newTopicStatusInfo));
|
|
|
|
}
|
|
|
|
);
|