mirror of
https://github.com/discourse/discourse.git
synced 2024-11-29 04:03:57 -06:00
FIX: regression preventing to set number of hours before closing
This commit also adds a full test suite for editing topic timer.
This commit is contained in:
parent
82222e8d18
commit
63307c303a
@ -1,6 +1,6 @@
|
||||
<form>
|
||||
<div class="control-group">
|
||||
{{combo-box allowInitialValueMutation=true content=timerTypes value=selection}}
|
||||
{{combo-box class="timer-type" allowInitialValueMutation=true content=timerTypes value=selection}}
|
||||
</div>
|
||||
|
||||
<div>
|
||||
|
@ -114,6 +114,7 @@ export default ComboBoxComponent.extend(DatetimeMixin, {
|
||||
pluginApiIdentifiers: ["future-date-input-selector"],
|
||||
classNames: ["future-date-input-selector"],
|
||||
isCustom: Ember.computed.equal("value", "pick_date_and_time"),
|
||||
isBasedOnLastPost: Ember.computed.equal("value", "set_based_on_last_post"),
|
||||
clearable: true,
|
||||
rowComponent: "future-date-input-selector/future-date-input-selector-row",
|
||||
headerComponent: "future-date-input-selector/future-date-input-selector-header",
|
||||
@ -154,7 +155,7 @@ export default ComboBoxComponent.extend(DatetimeMixin, {
|
||||
},
|
||||
|
||||
mutateValue(value) {
|
||||
if (this.get("isCustom")) {
|
||||
if (this.get("isCustom") || this.get("isBasedOnLastPost")) {
|
||||
this.set("value", value);
|
||||
} else {
|
||||
let input = null;
|
||||
|
153
test/javascripts/acceptance/topic-edit-timer-test.js.es6
Normal file
153
test/javascripts/acceptance/topic-edit-timer-test.js.es6
Normal file
@ -0,0 +1,153 @@
|
||||
import { acceptance } from 'helpers/qunit-helpers';
|
||||
acceptance('Topic - Edit timer', { loggedIn: true });
|
||||
|
||||
QUnit.test('default', assert => {
|
||||
visit('/t/internationalization-localization');
|
||||
click('.toggle-admin-menu');
|
||||
click('.topic-admin-status-update button');
|
||||
|
||||
andThen(() => {
|
||||
assert.equal(selectKit('.select-kit.timer-type').header.name(), 'Auto-Close Topic');
|
||||
assert.equal(selectKit('.future-date-input-selector').header.name(), 'Select a timeframe');
|
||||
});
|
||||
|
||||
click('#private-topic-timer');
|
||||
|
||||
andThen(() => {
|
||||
assert.equal(selectKit('.select-kit.timer-type').header.name(), 'Remind Me');
|
||||
assert.equal(selectKit('.future-date-input-selector').header.name(), 'Select a timeframe');
|
||||
});
|
||||
});
|
||||
|
||||
QUnit.test('autoclose - specific time', assert => {
|
||||
visit('/t/internationalization-localization');
|
||||
click('.toggle-admin-menu');
|
||||
click('.topic-admin-status-update button');
|
||||
expandSelectKit('.future-date-input-selector');
|
||||
selectKitSelectRow('later_today', { selector: '.future-date-input-selector' });
|
||||
|
||||
andThen(() => {
|
||||
assert.equal(selectKit('.future-date-input-selector').header.name(), 'Later today');
|
||||
const regex = /will automatically close in/g;
|
||||
const html = find('.future-date-input .topic-status-info').html().trim();
|
||||
assert.ok(regex.test(html));
|
||||
});
|
||||
});
|
||||
|
||||
QUnit.test('autoclose', assert => {
|
||||
visit('/t/internationalization-localization');
|
||||
click('.toggle-admin-menu');
|
||||
click('.topic-admin-status-update button');
|
||||
expandSelectKit('.future-date-input-selector');
|
||||
|
||||
selectKitSelectRow('later_today', { selector: '.future-date-input-selector' });
|
||||
andThen(() => {
|
||||
assert.equal(selectKit('.future-date-input-selector').header.name(), 'Later today');
|
||||
const regex = /will automatically close in/g;
|
||||
const html = find('.future-date-input .topic-status-info').html().trim();
|
||||
assert.ok(regex.test(html));
|
||||
});
|
||||
|
||||
expandSelectKit('.future-date-input-selector');
|
||||
selectKitSelectRow('pick_date_and_time', { selector: '.future-date-input-selector' });
|
||||
fillIn('.future-date-input .date-picker', '2099-11-24');
|
||||
|
||||
andThen(() => {
|
||||
assert.equal(selectKit('.future-date-input-selector').header.name(), 'Pick date and time');
|
||||
const regex = /will automatically close in/g;
|
||||
const html = find('.future-date-input .topic-status-info').html().trim();
|
||||
assert.ok(regex.test(html));
|
||||
});
|
||||
|
||||
expandSelectKit('.future-date-input-selector');
|
||||
selectKitSelectRow('set_based_on_last_post', { selector: '.future-date-input-selector' });
|
||||
fillIn('.future-date-input input[type=number]', '2');
|
||||
andThen(() => {
|
||||
assert.equal(selectKit('.future-date-input-selector').header.name(), 'Close based on last post');
|
||||
const regex = /This topic will close.*after the last reply/g;
|
||||
const html = find('.future-date-input .topic-status-info').html().trim();
|
||||
assert.ok(regex.test(html));
|
||||
});
|
||||
});
|
||||
|
||||
QUnit.test('close temporarily', assert => {
|
||||
visit('/t/internationalization-localization');
|
||||
click('.toggle-admin-menu');
|
||||
click('.topic-admin-status-update button');
|
||||
|
||||
expandSelectKit('.select-kit.timer-type');
|
||||
selectKitSelectRow('open', { selector: '.select-kit.timer-type' });
|
||||
|
||||
andThen(() => {
|
||||
assert.equal(selectKit('.future-date-input-selector').header.name(), 'Select a timeframe');
|
||||
});
|
||||
|
||||
expandSelectKit('.future-date-input-selector');
|
||||
selectKitSelectRow('tomorrow', { selector: '.future-date-input-selector' });
|
||||
andThen(() => {
|
||||
assert.equal(selectKit('.future-date-input-selector').header.name(), 'Tomorrow');
|
||||
const regex = /will automatically open in/g;
|
||||
const html = find('.future-date-input .topic-status-info').html().trim();
|
||||
assert.ok(regex.test(html));
|
||||
});
|
||||
|
||||
expandSelectKit('.future-date-input-selector');
|
||||
selectKitSelectRow('pick_date_and_time', { selector: '.future-date-input-selector' });
|
||||
fillIn('.future-date-input .date-picker', '2099-11-24');
|
||||
|
||||
andThen(() => {
|
||||
assert.equal(selectKit('.future-date-input-selector').header.name(), 'Pick date and time');
|
||||
const regex = /will automatically open in/g;
|
||||
const html = find('.future-date-input .topic-status-info').html().trim();
|
||||
assert.ok(regex.test(html));
|
||||
});
|
||||
});
|
||||
|
||||
QUnit.test('schedule', assert => {
|
||||
visit('/t/internationalization-localization');
|
||||
click('.toggle-admin-menu');
|
||||
click('.topic-admin-status-update button');
|
||||
|
||||
expandSelectKit('.select-kit.timer-type');
|
||||
selectKitSelectRow('publish_to_category', { selector: '.select-kit.timer-type' });
|
||||
|
||||
andThen(() => {
|
||||
assert.equal(selectKit('.modal-body .category-chooser').header.name(), 'uncategorized');
|
||||
assert.equal(selectKit('.future-date-input-selector').header.name(), 'Select a timeframe');
|
||||
});
|
||||
|
||||
expandSelectKit('.modal-body .category-chooser');
|
||||
selectKitSelectRow('7', { selector: '.modal-body .category-chooser' });
|
||||
|
||||
expandSelectKit('.future-date-input-selector');
|
||||
selectKitSelectRow('next_week', { selector: '.future-date-input-selector' });
|
||||
|
||||
andThen(() => {
|
||||
assert.equal(selectKit('.future-date-input-selector').header.name(), '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('auto delete', assert => {
|
||||
visit('/t/internationalization-localization');
|
||||
click('.toggle-admin-menu');
|
||||
click('.topic-admin-status-update button');
|
||||
|
||||
expandSelectKit('.select-kit.timer-type');
|
||||
selectKitSelectRow('delete', { selector: '.select-kit.timer-type' });
|
||||
|
||||
andThen(() => {
|
||||
assert.equal(selectKit('.future-date-input-selector').header.name(), 'Select a timeframe');
|
||||
});
|
||||
|
||||
expandSelectKit('.future-date-input-selector');
|
||||
selectKitSelectRow('next_month', { selector: '.future-date-input-selector' });
|
||||
andThen(() => {
|
||||
assert.equal(selectKit('.future-date-input-selector').header.name(), 'Next month');
|
||||
const regex = /will be automatically deleted/g;
|
||||
const html = find('.future-date-input .topic-status-info').html().trim();
|
||||
assert.ok(regex.test(html));
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue
Block a user