2018-06-15 23:03:24 +08:00
|
|
|
import { acceptance, replaceCurrentUser } from "helpers/qunit-helpers";
|
|
|
|
acceptance("Topic - Edit timer", { loggedIn: true });
|
2017-11-24 09:48:45 +08:00
|
|
|
|
2018-06-15 23:03:24 +08:00
|
|
|
QUnit.test("default", assert => {
|
|
|
|
const timerType = selectKit(".select-kit.timer-type");
|
|
|
|
const futureDateInputSelector = selectKit(".future-date-input-selector");
|
2017-12-22 20:08:12 +08:00
|
|
|
|
2018-06-15 23:03:24 +08:00
|
|
|
visit("/t/internationalization-localization");
|
|
|
|
click(".toggle-admin-menu");
|
|
|
|
click(".topic-admin-status-update button");
|
2017-11-24 09:48:45 +08:00
|
|
|
|
|
|
|
andThen(() => {
|
2018-06-15 23:03:24 +08:00
|
|
|
assert.equal(
|
|
|
|
futureDateInputSelector.header().title(),
|
|
|
|
"Select a timeframe"
|
|
|
|
);
|
2017-12-22 20:08:12 +08:00
|
|
|
assert.equal(futureDateInputSelector.header().value(), null);
|
2017-11-24 09:48:45 +08:00
|
|
|
});
|
|
|
|
|
2018-06-15 23:03:24 +08:00
|
|
|
click("#private-topic-timer");
|
2017-11-24 09:48:45 +08:00
|
|
|
|
|
|
|
andThen(() => {
|
2018-06-15 23:03:24 +08:00
|
|
|
assert.equal(timerType.header().title(), "Remind Me");
|
|
|
|
assert.equal(timerType.header().value(), "reminder");
|
2017-12-22 20:08:12 +08:00
|
|
|
|
2018-06-15 23:03:24 +08:00
|
|
|
assert.equal(
|
|
|
|
futureDateInputSelector.header().title(),
|
|
|
|
"Select a timeframe"
|
|
|
|
);
|
2017-12-22 20:08:12 +08:00
|
|
|
assert.equal(futureDateInputSelector.header().value(), null);
|
2017-11-24 09:48:45 +08:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2018-06-15 23:03:24 +08:00
|
|
|
QUnit.test("autoclose - specific time", assert => {
|
|
|
|
const futureDateInputSelector = selectKit(".future-date-input-selector");
|
2017-12-22 20:08:12 +08:00
|
|
|
|
2018-06-15 23:03:24 +08:00
|
|
|
visit("/t/internationalization-localization");
|
|
|
|
click(".toggle-admin-menu");
|
|
|
|
click(".topic-admin-status-update button");
|
2017-12-22 20:08:12 +08:00
|
|
|
|
2018-06-15 23:03:24 +08:00
|
|
|
futureDateInputSelector.expand().selectRowByValue("next_week");
|
2017-11-24 09:48:45 +08:00
|
|
|
|
|
|
|
andThen(() => {
|
2018-06-15 23:03:24 +08:00
|
|
|
assert.equal(futureDateInputSelector.header().title(), "Next week");
|
|
|
|
assert.equal(futureDateInputSelector.header().value(), "next_week");
|
2017-12-22 20:08:12 +08:00
|
|
|
|
2017-11-24 09:48:45 +08:00
|
|
|
const regex = /will automatically close in/g;
|
2018-06-15 23:03:24 +08:00
|
|
|
const html = find(".future-date-input .topic-status-info")
|
|
|
|
.html()
|
|
|
|
.trim();
|
2017-11-24 09:48:45 +08:00
|
|
|
assert.ok(regex.test(html));
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2018-06-15 23:03:24 +08:00
|
|
|
QUnit.test("autoclose", assert => {
|
|
|
|
const futureDateInputSelector = selectKit(".future-date-input-selector");
|
2017-12-22 20:08:12 +08:00
|
|
|
|
2018-06-15 23:03:24 +08:00
|
|
|
visit("/t/internationalization-localization");
|
|
|
|
click(".toggle-admin-menu");
|
|
|
|
click(".topic-admin-status-update button");
|
2017-11-24 09:48:45 +08:00
|
|
|
|
2018-06-15 23:03:24 +08:00
|
|
|
futureDateInputSelector.expand().selectRowByValue("next_week");
|
2017-12-22 20:08:12 +08:00
|
|
|
|
2017-11-24 09:48:45 +08:00
|
|
|
andThen(() => {
|
2018-06-15 23:03:24 +08:00
|
|
|
assert.equal(futureDateInputSelector.header().title(), "Next week");
|
|
|
|
assert.equal(futureDateInputSelector.header().value(), "next_week");
|
2017-12-22 20:08:12 +08:00
|
|
|
|
2017-11-24 09:48:45 +08:00
|
|
|
const regex = /will automatically close in/g;
|
2018-06-15 23:03:24 +08:00
|
|
|
const html = find(".future-date-input .topic-status-info")
|
|
|
|
.html()
|
|
|
|
.trim();
|
2017-11-24 09:48:45 +08:00
|
|
|
assert.ok(regex.test(html));
|
|
|
|
});
|
|
|
|
|
2018-06-15 23:03:24 +08:00
|
|
|
futureDateInputSelector.expand().selectRowByValue("pick_date_and_time");
|
2017-12-22 20:08:12 +08:00
|
|
|
|
2018-06-15 23:03:24 +08:00
|
|
|
fillIn(".future-date-input .date-picker", "2099-11-24");
|
2017-11-24 09:48:45 +08:00
|
|
|
|
|
|
|
andThen(() => {
|
2018-06-15 23:03:24 +08:00
|
|
|
assert.equal(
|
|
|
|
futureDateInputSelector.header().title(),
|
|
|
|
"Pick date and time"
|
|
|
|
);
|
|
|
|
assert.equal(
|
|
|
|
futureDateInputSelector.header().value(),
|
|
|
|
"pick_date_and_time"
|
|
|
|
);
|
2017-12-22 20:08:12 +08:00
|
|
|
|
2017-11-24 09:48:45 +08:00
|
|
|
const regex = /will automatically close in/g;
|
2018-06-15 23:03:24 +08:00
|
|
|
const html = find(".future-date-input .topic-status-info")
|
|
|
|
.html()
|
|
|
|
.trim();
|
2017-11-24 09:48:45 +08:00
|
|
|
assert.ok(regex.test(html));
|
|
|
|
});
|
|
|
|
|
2018-06-15 23:03:24 +08:00
|
|
|
futureDateInputSelector.expand().selectRowByValue("set_based_on_last_post");
|
2017-12-22 20:08:12 +08:00
|
|
|
|
2018-06-15 23:03:24 +08:00
|
|
|
fillIn(".future-date-input input[type=number]", "2");
|
2017-12-22 20:08:12 +08:00
|
|
|
|
2017-11-24 09:48:45 +08:00
|
|
|
andThen(() => {
|
2018-06-15 23:03:24 +08:00
|
|
|
assert.equal(
|
|
|
|
futureDateInputSelector.header().title(),
|
|
|
|
"Close based on last post"
|
|
|
|
);
|
|
|
|
assert.equal(
|
|
|
|
futureDateInputSelector.header().value(),
|
|
|
|
"set_based_on_last_post"
|
|
|
|
);
|
2017-12-22 20:08:12 +08:00
|
|
|
|
2017-11-24 09:48:45 +08:00
|
|
|
const regex = /This topic will close.*after the last reply/g;
|
2018-06-15 23:03:24 +08:00
|
|
|
const html = find(".future-date-input .topic-status-info")
|
|
|
|
.html()
|
|
|
|
.trim();
|
2017-11-24 09:48:45 +08:00
|
|
|
assert.ok(regex.test(html));
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2018-06-15 23:03:24 +08:00
|
|
|
QUnit.test("close temporarily", assert => {
|
|
|
|
const timerType = selectKit(".select-kit.timer-type");
|
|
|
|
const futureDateInputSelector = selectKit(".future-date-input-selector");
|
2017-12-22 20:08:12 +08:00
|
|
|
|
2018-06-15 23:03:24 +08:00
|
|
|
visit("/t/internationalization-localization");
|
|
|
|
click(".toggle-admin-menu");
|
|
|
|
click(".topic-admin-status-update button");
|
2017-11-24 09:48:45 +08:00
|
|
|
|
2018-06-15 23:03:24 +08:00
|
|
|
timerType.expand().selectRowByValue("open");
|
2017-11-24 09:48:45 +08:00
|
|
|
|
|
|
|
andThen(() => {
|
2018-06-15 23:03:24 +08:00
|
|
|
assert.equal(
|
|
|
|
futureDateInputSelector.header().title(),
|
|
|
|
"Select a timeframe"
|
|
|
|
);
|
2017-12-22 20:08:12 +08:00
|
|
|
assert.equal(futureDateInputSelector.header().value(), null);
|
2017-11-24 09:48:45 +08:00
|
|
|
});
|
|
|
|
|
2018-06-15 23:03:24 +08:00
|
|
|
futureDateInputSelector.expand().selectRowByValue("next_week");
|
2017-12-22 20:08:12 +08:00
|
|
|
|
2017-11-24 09:48:45 +08:00
|
|
|
andThen(() => {
|
2018-06-15 23:03:24 +08:00
|
|
|
assert.equal(futureDateInputSelector.header().title(), "Next week");
|
|
|
|
assert.equal(futureDateInputSelector.header().value(), "next_week");
|
2017-12-22 20:08:12 +08:00
|
|
|
|
2017-11-24 09:48:45 +08:00
|
|
|
const regex = /will automatically open in/g;
|
2018-06-15 23:03:24 +08:00
|
|
|
const html = find(".future-date-input .topic-status-info")
|
|
|
|
.html()
|
|
|
|
.trim();
|
2017-11-24 09:48:45 +08:00
|
|
|
assert.ok(regex.test(html));
|
|
|
|
});
|
|
|
|
|
2018-06-15 23:03:24 +08:00
|
|
|
futureDateInputSelector.expand().selectRowByValue("pick_date_and_time");
|
2017-12-22 20:08:12 +08:00
|
|
|
|
2018-06-15 23:03:24 +08:00
|
|
|
fillIn(".future-date-input .date-picker", "2099-11-24");
|
2017-11-24 09:48:45 +08:00
|
|
|
|
|
|
|
andThen(() => {
|
2018-06-15 23:03:24 +08:00
|
|
|
assert.equal(
|
|
|
|
futureDateInputSelector.header().title(),
|
|
|
|
"Pick date and time"
|
|
|
|
);
|
|
|
|
assert.equal(
|
|
|
|
futureDateInputSelector.header().value(),
|
|
|
|
"pick_date_and_time"
|
|
|
|
);
|
2017-12-22 20:08:12 +08:00
|
|
|
|
2017-11-24 09:48:45 +08:00
|
|
|
const regex = /will automatically open in/g;
|
2018-06-15 23:03:24 +08:00
|
|
|
const html = find(".future-date-input .topic-status-info")
|
|
|
|
.html()
|
|
|
|
.trim();
|
2017-11-24 09:48:45 +08:00
|
|
|
assert.ok(regex.test(html));
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2018-06-15 23:03:24 +08:00
|
|
|
QUnit.test("schedule", assert => {
|
|
|
|
const timerType = selectKit(".select-kit.timer-type");
|
|
|
|
const categoryChooser = selectKit(".modal-body .category-chooser");
|
|
|
|
const futureDateInputSelector = selectKit(".future-date-input-selector");
|
2017-12-22 20:08:12 +08:00
|
|
|
|
2018-06-15 23:03:24 +08:00
|
|
|
visit("/t/internationalization-localization");
|
|
|
|
click(".toggle-admin-menu");
|
|
|
|
click(".topic-admin-status-update button");
|
2017-11-24 09:48:45 +08:00
|
|
|
|
2018-06-15 23:03:24 +08:00
|
|
|
timerType.expand().selectRowByValue("publish_to_category");
|
2017-11-24 09:48:45 +08:00
|
|
|
|
|
|
|
andThen(() => {
|
2018-06-15 23:03:24 +08:00
|
|
|
assert.equal(categoryChooser.header().title(), "uncategorized");
|
2017-12-22 20:08:12 +08:00
|
|
|
assert.equal(categoryChooser.header().value(), null);
|
|
|
|
|
2018-06-15 23:03:24 +08:00
|
|
|
assert.equal(
|
|
|
|
futureDateInputSelector.header().title(),
|
|
|
|
"Select a timeframe"
|
|
|
|
);
|
2017-12-22 20:08:12 +08:00
|
|
|
assert.equal(futureDateInputSelector.header().value(), null);
|
2017-11-24 09:48:45 +08:00
|
|
|
});
|
|
|
|
|
2018-06-15 23:03:24 +08:00
|
|
|
categoryChooser.expand().selectRowByValue("7");
|
2017-11-24 09:48:45 +08:00
|
|
|
|
2018-06-15 23:03:24 +08:00
|
|
|
futureDateInputSelector.expand().selectRowByValue("next_week");
|
2017-11-24 09:48:45 +08:00
|
|
|
|
|
|
|
andThen(() => {
|
2018-06-15 23:03:24 +08:00
|
|
|
assert.equal(futureDateInputSelector.header().title(), "Next week");
|
|
|
|
assert.equal(futureDateInputSelector.header().value(), "next_week");
|
2017-12-22 20:08:12 +08:00
|
|
|
|
2017-11-24 09:48:45 +08:00
|
|
|
const regex = /will be published to #dev/g;
|
2018-06-15 23:03:24 +08:00
|
|
|
const text = find(".future-date-input .topic-status-info")
|
|
|
|
.text()
|
|
|
|
.trim();
|
2017-11-24 09:48:45 +08:00
|
|
|
assert.ok(regex.test(text));
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2018-05-17 06:42:48 +08:00
|
|
|
QUnit.test("TL4 can't auto-delete", assert => {
|
|
|
|
replaceCurrentUser({ staff: false, trust_level: 4 });
|
|
|
|
|
2018-06-15 23:03:24 +08:00
|
|
|
visit("/t/internationalization-localization");
|
|
|
|
click(".toggle-admin-menu");
|
|
|
|
click(".topic-admin-status-update button");
|
2018-05-17 06:42:48 +08:00
|
|
|
|
2018-06-15 23:03:24 +08:00
|
|
|
const timerType = selectKit(".select-kit.timer-type");
|
2018-05-17 06:42:48 +08:00
|
|
|
|
|
|
|
timerType.expand();
|
|
|
|
|
|
|
|
andThen(() => {
|
|
|
|
assert.ok(!timerType.rowByValue("delete").exists());
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2018-06-15 23:03:24 +08:00
|
|
|
QUnit.test("auto delete", assert => {
|
|
|
|
const timerType = selectKit(".select-kit.timer-type");
|
|
|
|
const futureDateInputSelector = selectKit(".future-date-input-selector");
|
2017-12-22 20:08:12 +08:00
|
|
|
|
2018-06-15 23:03:24 +08:00
|
|
|
visit("/t/internationalization-localization");
|
|
|
|
click(".toggle-admin-menu");
|
|
|
|
click(".topic-admin-status-update button");
|
2017-11-24 09:48:45 +08:00
|
|
|
|
2018-06-15 23:03:24 +08:00
|
|
|
timerType.expand().selectRowByValue("delete");
|
2017-11-24 09:48:45 +08:00
|
|
|
|
|
|
|
andThen(() => {
|
2018-06-15 23:03:24 +08:00
|
|
|
assert.equal(
|
|
|
|
futureDateInputSelector.header().title(),
|
|
|
|
"Select a timeframe"
|
|
|
|
);
|
2017-12-22 20:08:12 +08:00
|
|
|
assert.equal(futureDateInputSelector.header().value(), null);
|
2017-11-24 09:48:45 +08:00
|
|
|
});
|
|
|
|
|
2018-06-15 23:03:24 +08:00
|
|
|
futureDateInputSelector.expand().selectRowByValue("two_weeks");
|
2017-12-22 20:08:12 +08:00
|
|
|
|
2017-11-24 09:48:45 +08:00
|
|
|
andThen(() => {
|
2018-06-15 23:03:24 +08:00
|
|
|
assert.equal(futureDateInputSelector.header().title(), "Two Weeks");
|
|
|
|
assert.equal(futureDateInputSelector.header().value(), "two_weeks");
|
2017-12-22 20:08:12 +08:00
|
|
|
|
2017-11-24 09:48:45 +08:00
|
|
|
const regex = /will be automatically deleted/g;
|
2018-06-15 23:03:24 +08:00
|
|
|
const html = find(".future-date-input .topic-status-info")
|
|
|
|
.html()
|
|
|
|
.trim();
|
2017-11-24 09:48:45 +08:00
|
|
|
assert.ok(regex.test(html));
|
|
|
|
});
|
|
|
|
});
|