2018-04-11 07:31:20 +08:00
|
|
|
import { acceptance, replaceCurrentUser } from "helpers/qunit-helpers";
|
2015-04-02 02:18:46 +08:00
|
|
|
|
2016-07-27 17:50:13 +08:00
|
|
|
acceptance("Composer", {
|
|
|
|
loggedIn: true,
|
|
|
|
settings: {
|
|
|
|
enable_whispers: true
|
|
|
|
}
|
|
|
|
});
|
2015-04-02 02:18:46 +08:00
|
|
|
|
2017-06-15 01:57:58 +08:00
|
|
|
QUnit.test("Tests the Composer controls", assert => {
|
2015-04-02 02:18:46 +08:00
|
|
|
visit("/");
|
|
|
|
andThen(() => {
|
2017-06-15 01:57:58 +08:00
|
|
|
assert.ok(exists('#create-topic'), 'the create button is visible');
|
2015-04-02 02:18:46 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
click('#create-topic');
|
|
|
|
andThen(() => {
|
2017-06-15 01:57:58 +08:00
|
|
|
assert.ok(exists('.d-editor-input'), 'the composer input is visible');
|
|
|
|
assert.ok(exists('.title-input .popup-tip.bad.hide'), 'title errors are hidden by default');
|
|
|
|
assert.ok(exists('.d-editor-textarea-wrapper .popup-tip.bad.hide'), 'body errors are hidden by default');
|
2015-04-02 02:18:46 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
click('a.toggle-preview');
|
|
|
|
andThen(() => {
|
2017-06-15 01:57:58 +08:00
|
|
|
assert.ok(!exists('.d-editor-preview:visible'), "clicking the toggle hides the preview");
|
2015-04-02 02:18:46 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
click('a.toggle-preview');
|
|
|
|
andThen(() => {
|
2017-06-15 01:57:58 +08:00
|
|
|
assert.ok(exists('.d-editor-preview:visible'), "clicking the toggle shows the preview again");
|
2015-04-02 02:18:46 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
click('#reply-control button.create');
|
|
|
|
andThen(() => {
|
2017-06-15 01:57:58 +08:00
|
|
|
assert.ok(!exists('.title-input .popup-tip.bad.hide'), 'it shows the empty title error');
|
|
|
|
assert.ok(!exists('.d-editor-wrapper .popup-tip.bad.hide'), 'it shows the empty body error');
|
2015-04-02 02:18:46 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
fillIn('#reply-title', "this is my new topic title");
|
|
|
|
andThen(() => {
|
2017-06-15 01:57:58 +08:00
|
|
|
assert.ok(exists('.title-input .popup-tip.good'), 'the title is now good');
|
2015-04-02 02:18:46 +08:00
|
|
|
});
|
|
|
|
|
2015-11-04 05:25:37 +08:00
|
|
|
fillIn('.d-editor-input', "this is the *content* of a post");
|
2015-04-02 02:18:46 +08:00
|
|
|
andThen(() => {
|
2017-06-15 01:57:58 +08:00
|
|
|
assert.equal(find('.d-editor-preview').html().trim(), "<p>this is the <em>content</em> of a post</p>", "it previews content");
|
|
|
|
assert.ok(exists('.d-editor-textarea-wrapper .popup-tip.good'), 'the body is now good');
|
2015-04-02 02:18:46 +08:00
|
|
|
});
|
|
|
|
|
2015-11-19 01:35:17 +08:00
|
|
|
andThen(() => {
|
2015-11-19 02:35:18 +08:00
|
|
|
const textarea = find('#reply-control .d-editor-input')[0];
|
|
|
|
textarea.selectionStart = textarea.value.length;
|
|
|
|
textarea.selectionEnd = textarea.value.length;
|
|
|
|
|
2015-11-19 01:35:17 +08:00
|
|
|
// Testing keyboard events is tough!
|
|
|
|
const mac = /Mac|iPod|iPhone|iPad/.test(navigator.platform);
|
|
|
|
const event = document.createEvent('Event');
|
|
|
|
event.initEvent('keydown', true, true);
|
|
|
|
event[mac ? 'metaKey' : 'ctrlKey'] = true;
|
|
|
|
event.keyCode = 66;
|
|
|
|
|
2015-11-19 02:35:18 +08:00
|
|
|
textarea.dispatchEvent(event);
|
2015-11-19 01:35:17 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
andThen(() => {
|
|
|
|
const example = I18n.t(`composer.bold_text`);
|
2017-06-15 01:57:58 +08:00
|
|
|
assert.equal(find('#reply-control .d-editor-input').val().trim(),
|
2015-11-19 01:35:17 +08:00
|
|
|
`this is the *content* of a post**${example}**`,
|
|
|
|
"it supports keyboard shortcuts");
|
|
|
|
});
|
|
|
|
|
2015-04-02 02:18:46 +08:00
|
|
|
click('#reply-control a.cancel');
|
|
|
|
andThen(() => {
|
2017-06-15 01:57:58 +08:00
|
|
|
assert.ok(exists('.bootbox.modal'), 'it pops up a confirmation dialog');
|
2015-04-02 02:18:46 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
click('.modal-footer a:eq(1)');
|
|
|
|
andThen(() => {
|
2017-06-15 01:57:58 +08:00
|
|
|
assert.ok(!exists('.bootbox.modal'), 'the confirmation can be cancelled');
|
2015-04-02 02:18:46 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
2017-06-15 01:57:58 +08:00
|
|
|
QUnit.test("Create a topic with server side errors", assert => {
|
2015-04-02 02:18:46 +08:00
|
|
|
visit("/");
|
|
|
|
click('#create-topic');
|
|
|
|
fillIn('#reply-title', "this title triggers an error");
|
2015-11-04 05:25:37 +08:00
|
|
|
fillIn('.d-editor-input', "this is the *content* of a post");
|
2015-04-02 02:18:46 +08:00
|
|
|
click('#reply-control button.create');
|
|
|
|
andThen(() => {
|
2017-06-15 01:57:58 +08:00
|
|
|
assert.ok(exists('.bootbox.modal'), 'it pops up an error message');
|
2015-04-02 02:18:46 +08:00
|
|
|
});
|
|
|
|
click('.bootbox.modal a.btn-primary');
|
|
|
|
andThen(() => {
|
2017-06-15 01:57:58 +08:00
|
|
|
assert.ok(!exists('.bootbox.modal'), 'it dismisses the error');
|
|
|
|
assert.ok(exists('.d-editor-input'), 'the composer input is visible');
|
2015-04-02 02:18:46 +08:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2017-06-15 01:57:58 +08:00
|
|
|
QUnit.test("Create a Topic", assert => {
|
2015-04-02 02:18:46 +08:00
|
|
|
visit("/");
|
|
|
|
click('#create-topic');
|
|
|
|
fillIn('#reply-title', "Internationalization Localization");
|
2015-11-04 05:25:37 +08:00
|
|
|
fillIn('.d-editor-input', "this is the *content* of a new topic post");
|
2015-04-02 02:18:46 +08:00
|
|
|
click('#reply-control button.create');
|
|
|
|
andThen(() => {
|
2017-06-15 01:57:58 +08:00
|
|
|
assert.equal(currentURL(), "/t/internationalization-localization/280", "it transitions to the newly created topic URL");
|
2015-04-02 02:18:46 +08:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2017-06-15 01:57:58 +08:00
|
|
|
QUnit.test("Create an enqueued Topic", assert => {
|
2015-04-10 06:33:37 +08:00
|
|
|
visit("/");
|
|
|
|
click('#create-topic');
|
|
|
|
fillIn('#reply-title', "Internationalization Localization");
|
2015-11-04 05:25:37 +08:00
|
|
|
fillIn('.d-editor-input', "enqueue this content please");
|
2015-04-10 06:33:37 +08:00
|
|
|
click('#reply-control button.create');
|
|
|
|
andThen(() => {
|
2017-08-31 03:29:51 +08:00
|
|
|
assert.ok(visible('.d-modal'), 'it pops up a modal');
|
2017-06-15 01:57:58 +08:00
|
|
|
assert.equal(currentURL(), "/", "it doesn't change routes");
|
2015-04-10 06:33:37 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
click('.modal-footer button');
|
|
|
|
andThen(() => {
|
2017-08-31 03:29:51 +08:00
|
|
|
assert.ok(invisible('.d-modal'), 'the modal can be dismissed');
|
2015-04-10 06:33:37 +08:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2017-06-15 01:57:58 +08:00
|
|
|
QUnit.test("Create a Reply", assert => {
|
2015-04-02 02:18:46 +08:00
|
|
|
visit("/t/internationalization-localization/280");
|
|
|
|
|
2015-04-10 06:33:37 +08:00
|
|
|
andThen(() => {
|
2017-06-15 01:57:58 +08:00
|
|
|
assert.ok(!exists('article[data-post-id=12345]'), 'the post is not in the DOM');
|
2015-04-10 06:33:37 +08:00
|
|
|
});
|
|
|
|
|
2015-04-02 02:18:46 +08:00
|
|
|
click('#topic-footer-buttons .btn.create');
|
|
|
|
andThen(() => {
|
2017-06-15 01:57:58 +08:00
|
|
|
assert.ok(exists('.d-editor-input'), 'the composer input is visible');
|
|
|
|
assert.ok(!exists('#reply-title'), 'there is no title since this is a reply');
|
2015-04-02 02:18:46 +08:00
|
|
|
});
|
|
|
|
|
2015-11-04 05:25:37 +08:00
|
|
|
fillIn('.d-editor-input', 'this is the content of my reply');
|
2015-04-02 02:18:46 +08:00
|
|
|
click('#reply-control button.create');
|
|
|
|
andThen(() => {
|
2017-06-15 01:57:58 +08:00
|
|
|
assert.equal(find('.cooked:last p').text(), 'this is the content of my reply');
|
2015-04-10 06:33:37 +08:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2017-06-15 01:57:58 +08:00
|
|
|
QUnit.test("Posting on a different topic", (assert) => {
|
2015-05-15 06:18:12 +08:00
|
|
|
visit("/t/internationalization-localization/280");
|
|
|
|
click('#topic-footer-buttons .btn.create');
|
2015-11-04 05:25:37 +08:00
|
|
|
fillIn('.d-editor-input', 'this is the content for a different topic');
|
2015-05-15 06:18:12 +08:00
|
|
|
|
|
|
|
visit("/t/1-3-0beta9-no-rate-limit-popups/28830");
|
|
|
|
andThen(function() {
|
|
|
|
assert.equal(currentURL(), "/t/1-3-0beta9-no-rate-limit-popups/28830");
|
|
|
|
});
|
|
|
|
click('#reply-control button.create');
|
|
|
|
andThen(function() {
|
|
|
|
assert.ok(visible('.reply-where-modal'), 'it pops up a modal');
|
|
|
|
});
|
|
|
|
|
|
|
|
click('.btn-reply-here');
|
|
|
|
andThen(() => {
|
|
|
|
assert.equal(find('.cooked:last p').text(), 'this is the content for a different topic');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2017-06-15 01:57:58 +08:00
|
|
|
QUnit.test("Create an enqueued Reply", assert => {
|
2015-04-10 06:33:37 +08:00
|
|
|
visit("/t/internationalization-localization/280");
|
|
|
|
|
|
|
|
click('#topic-footer-buttons .btn.create');
|
|
|
|
andThen(() => {
|
2017-06-15 01:57:58 +08:00
|
|
|
assert.ok(exists('.d-editor-input'), 'the composer input is visible');
|
|
|
|
assert.ok(!exists('#reply-title'), 'there is no title since this is a reply');
|
2015-04-10 06:33:37 +08:00
|
|
|
});
|
|
|
|
|
2015-11-04 05:25:37 +08:00
|
|
|
fillIn('.d-editor-input', 'enqueue this content please');
|
2015-04-10 06:33:37 +08:00
|
|
|
click('#reply-control button.create');
|
|
|
|
andThen(() => {
|
2017-06-15 01:57:58 +08:00
|
|
|
assert.ok(find('.cooked:last p').text() !== 'enqueue this content please', "it doesn't insert the post");
|
2015-04-10 06:33:37 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
andThen(() => {
|
2017-08-31 03:29:51 +08:00
|
|
|
assert.ok(visible('.d-modal'), 'it pops up a modal');
|
2015-04-10 06:33:37 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
click('.modal-footer button');
|
|
|
|
andThen(() => {
|
2017-08-31 03:29:51 +08:00
|
|
|
assert.ok(invisible('.d-modal'), 'the modal can be dismissed');
|
2015-04-02 02:18:46 +08:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2017-06-15 01:57:58 +08:00
|
|
|
QUnit.test("Edit the first post", assert => {
|
2015-04-02 02:18:46 +08:00
|
|
|
visit("/t/internationalization-localization/280");
|
|
|
|
|
2017-06-15 01:57:58 +08:00
|
|
|
assert.ok(!exists('.topic-post:eq(0) .post-info.edits'), 'it has no edits icon at first');
|
2015-04-10 02:54:17 +08:00
|
|
|
|
2016-01-05 04:18:09 +08:00
|
|
|
click('.topic-post:eq(0) button.show-more-actions');
|
|
|
|
click('.topic-post:eq(0) button.edit');
|
2015-04-02 02:18:46 +08:00
|
|
|
andThen(() => {
|
2017-06-15 01:57:58 +08:00
|
|
|
assert.equal(find('.d-editor-input').val().indexOf('Any plans to support'), 0, 'it populates the input with the post text');
|
2015-04-02 02:18:46 +08:00
|
|
|
});
|
|
|
|
|
2015-11-04 05:25:37 +08:00
|
|
|
fillIn('.d-editor-input', "This is the new text for the post");
|
2015-04-02 02:18:46 +08:00
|
|
|
fillIn('#reply-title', "This is the new text for the title");
|
|
|
|
click('#reply-control button.create');
|
|
|
|
andThen(() => {
|
2017-06-15 01:57:58 +08:00
|
|
|
assert.ok(!exists('.d-editor-input'), 'it closes the composer');
|
|
|
|
assert.ok(exists('.topic-post:eq(0) .post-info.edits'), 'it has the edits icon');
|
|
|
|
assert.ok(find('#topic-title h1').text().indexOf('This is the new text for the title') !== -1, 'it shows the new title');
|
|
|
|
assert.ok(find('.topic-post:eq(0) .cooked').text().indexOf('This is the new text for the post') !== -1, 'it updates the post');
|
2015-04-02 02:18:46 +08:00
|
|
|
});
|
|
|
|
});
|
2015-04-10 06:33:37 +08:00
|
|
|
|
2017-06-15 01:57:58 +08:00
|
|
|
QUnit.test("Composer can switch between edits", assert => {
|
2015-08-14 00:49:13 +08:00
|
|
|
visit("/t/this-is-a-test-topic/9");
|
|
|
|
|
2016-01-05 04:18:09 +08:00
|
|
|
click('.topic-post:eq(0) button.edit');
|
2015-08-14 00:49:13 +08:00
|
|
|
andThen(() => {
|
2017-06-15 01:57:58 +08:00
|
|
|
assert.equal(find('.d-editor-input').val().indexOf('This is the first post.'), 0, 'it populates the input with the post text');
|
2015-08-14 00:49:13 +08:00
|
|
|
});
|
2016-01-05 04:18:09 +08:00
|
|
|
click('.topic-post:eq(1) button.edit');
|
2015-08-14 00:49:13 +08:00
|
|
|
andThen(() => {
|
2017-06-15 01:57:58 +08:00
|
|
|
assert.equal(find('.d-editor-input').val().indexOf('This is the second post.'), 0, 'it populates the input with the post text');
|
2015-08-14 00:49:13 +08:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2017-06-15 01:57:58 +08:00
|
|
|
QUnit.test("Composer with dirty edit can toggle to another edit", assert => {
|
2015-08-24 22:55:56 +08:00
|
|
|
visit("/t/this-is-a-test-topic/9");
|
|
|
|
|
2016-01-05 04:18:09 +08:00
|
|
|
click('.topic-post:eq(0) button.edit');
|
2015-11-04 05:25:37 +08:00
|
|
|
fillIn('.d-editor-input', 'This is a dirty reply');
|
2016-01-05 04:18:09 +08:00
|
|
|
click('.topic-post:eq(1) button.edit');
|
2015-08-24 22:55:56 +08:00
|
|
|
andThen(() => {
|
2017-06-15 01:57:58 +08:00
|
|
|
assert.ok(exists('.bootbox.modal'), 'it pops up a confirmation dialog');
|
2015-08-24 22:55:56 +08:00
|
|
|
});
|
|
|
|
click('.modal-footer a:eq(0)');
|
|
|
|
andThen(() => {
|
2017-06-15 01:57:58 +08:00
|
|
|
assert.equal(find('.d-editor-input').val().indexOf('This is the second post.'), 0, 'it populates the input with the post text');
|
2015-08-24 22:55:56 +08:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2017-06-15 01:57:58 +08:00
|
|
|
QUnit.test("Composer can toggle between edit and reply", assert => {
|
2015-08-14 00:49:13 +08:00
|
|
|
visit("/t/this-is-a-test-topic/9");
|
|
|
|
|
2016-01-05 04:18:09 +08:00
|
|
|
click('.topic-post:eq(0) button.edit');
|
2015-08-14 00:49:13 +08:00
|
|
|
andThen(() => {
|
2017-06-15 01:57:58 +08:00
|
|
|
assert.equal(find('.d-editor-input').val().indexOf('This is the first post.'), 0, 'it populates the input with the post text');
|
2015-08-14 00:49:13 +08:00
|
|
|
});
|
2016-01-05 04:18:09 +08:00
|
|
|
click('.topic-post:eq(0) button.reply');
|
2015-08-14 00:49:13 +08:00
|
|
|
andThen(() => {
|
2017-06-15 01:57:58 +08:00
|
|
|
assert.equal(find('.d-editor-input').val(), "", 'it clears the input');
|
2015-08-14 00:49:13 +08:00
|
|
|
});
|
2016-01-05 04:18:09 +08:00
|
|
|
click('.topic-post:eq(0) button.edit');
|
2015-08-14 00:49:13 +08:00
|
|
|
andThen(() => {
|
2017-06-15 01:57:58 +08:00
|
|
|
assert.equal(find('.d-editor-input').val().indexOf('This is the first post.'), 0, 'it populates the input with the post text');
|
2015-08-14 00:49:13 +08:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2017-06-15 01:57:58 +08:00
|
|
|
QUnit.test("Composer can toggle between reply and createTopic", assert => {
|
2016-07-27 17:50:13 +08:00
|
|
|
visit("/t/this-is-a-test-topic/9");
|
|
|
|
click('.topic-post:eq(0) button.reply');
|
2017-12-22 20:08:12 +08:00
|
|
|
|
|
|
|
selectKit('.toolbar-popup-menu-options').expand().selectRowByValue('toggleWhisper');
|
2017-12-13 17:49:32 +08:00
|
|
|
|
2016-07-27 17:50:13 +08:00
|
|
|
andThen(() => {
|
2017-06-15 01:57:58 +08:00
|
|
|
assert.ok(
|
2016-07-27 17:50:13 +08:00
|
|
|
find('.composer-fields .whisper').text().indexOf(I18n.t("composer.whisper")) > 0,
|
|
|
|
'it sets the post type to whisper'
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
visit("/");
|
|
|
|
andThen(() => {
|
2017-06-15 01:57:58 +08:00
|
|
|
assert.ok(exists('#create-topic'), 'the create topic button is visible');
|
2016-07-27 17:50:13 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
click('#create-topic');
|
|
|
|
andThen(() => {
|
2017-06-15 01:57:58 +08:00
|
|
|
assert.ok(
|
2016-07-27 17:50:13 +08:00
|
|
|
find('.composer-fields .whisper').text().indexOf(I18n.t("composer.whisper")) === -1,
|
|
|
|
"it should reset the state of the composer's model"
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
2017-12-22 20:08:12 +08:00
|
|
|
selectKit('.toolbar-popup-menu-options').expand().selectRowByValue('toggleInvisible');
|
2017-12-13 17:49:32 +08:00
|
|
|
|
2016-07-27 17:50:13 +08:00
|
|
|
andThen(() => {
|
2017-06-15 01:57:58 +08:00
|
|
|
assert.ok(
|
2016-07-27 17:50:13 +08:00
|
|
|
find('.composer-fields .whisper').text().indexOf(I18n.t("composer.unlist")) > 0,
|
|
|
|
'it sets the topic to unlisted'
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
visit("/t/this-is-a-test-topic/9");
|
|
|
|
|
|
|
|
click('.topic-post:eq(0) button.reply');
|
|
|
|
andThen(() => {
|
2017-06-15 01:57:58 +08:00
|
|
|
assert.ok(
|
2016-07-27 17:50:13 +08:00
|
|
|
find('.composer-fields .whisper').text().indexOf(I18n.t("composer.unlist")) === -1,
|
|
|
|
"it should reset the state of the composer's model"
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2017-06-15 01:57:58 +08:00
|
|
|
QUnit.test("Composer with dirty reply can toggle to edit", assert => {
|
2015-08-14 00:49:13 +08:00
|
|
|
visit("/t/this-is-a-test-topic/9");
|
|
|
|
|
2016-01-05 04:18:09 +08:00
|
|
|
click('.topic-post:eq(0) button.reply');
|
2015-11-04 05:25:37 +08:00
|
|
|
fillIn('.d-editor-input', 'This is a dirty reply');
|
2016-01-05 04:18:09 +08:00
|
|
|
click('.topic-post:eq(0) button.edit');
|
2015-08-14 00:49:13 +08:00
|
|
|
andThen(() => {
|
2017-06-15 01:57:58 +08:00
|
|
|
assert.ok(exists('.bootbox.modal'), 'it pops up a confirmation dialog');
|
2015-08-14 00:49:13 +08:00
|
|
|
});
|
|
|
|
click('.modal-footer a:eq(0)');
|
|
|
|
andThen(() => {
|
2017-06-15 01:57:58 +08:00
|
|
|
assert.equal(find('.d-editor-input').val().indexOf('This is the first post.'), 0, 'it populates the input with the post text');
|
2015-08-14 00:49:13 +08:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2017-06-15 01:57:58 +08:00
|
|
|
QUnit.test("Composer draft with dirty reply can toggle to edit", assert => {
|
2015-08-14 00:49:13 +08:00
|
|
|
visit("/t/this-is-a-test-topic/9");
|
|
|
|
|
2016-01-05 04:18:09 +08:00
|
|
|
click('.topic-post:eq(0) button.reply');
|
2015-11-04 05:25:37 +08:00
|
|
|
fillIn('.d-editor-input', 'This is a dirty reply');
|
2015-08-14 00:49:13 +08:00
|
|
|
click('.toggler');
|
2016-01-05 04:18:09 +08:00
|
|
|
click('.topic-post:eq(0) button.edit');
|
2015-08-14 00:49:13 +08:00
|
|
|
andThen(() => {
|
2017-06-15 01:57:58 +08:00
|
|
|
assert.ok(exists('.bootbox.modal'), 'it pops up a confirmation dialog');
|
2015-08-14 00:49:13 +08:00
|
|
|
});
|
|
|
|
click('.modal-footer a:eq(0)');
|
|
|
|
andThen(() => {
|
2017-06-15 01:57:58 +08:00
|
|
|
assert.equal(find('.d-editor-input').val().indexOf('This is the first post.'), 0, 'it populates the input with the post text');
|
2015-08-14 00:49:13 +08:00
|
|
|
});
|
2017-07-27 04:33:17 +08:00
|
|
|
});
|
2018-04-11 07:31:20 +08:00
|
|
|
|
|
|
|
acceptance("Composer and uncategorized is not allowed", {
|
|
|
|
loggedIn: true,
|
|
|
|
settings: {
|
|
|
|
enable_whispers: true,
|
|
|
|
allow_uncategorized_topics: false
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
QUnit.test("Disable body until category is selected", assert => {
|
|
|
|
replaceCurrentUser({ admin: false, staff: false, trust_level: 1 });
|
|
|
|
|
|
|
|
visit("/");
|
|
|
|
click('#create-topic');
|
|
|
|
andThen(() => {
|
|
|
|
assert.ok(exists('.d-editor-input'), 'the composer input is visible');
|
|
|
|
assert.ok(exists('.title-input .popup-tip.bad.hide'), 'title errors are hidden by default');
|
|
|
|
assert.ok(exists('.d-editor-textarea-wrapper .popup-tip.bad.hide'), 'body errors are hidden by default');
|
2018-04-12 23:32:05 +08:00
|
|
|
assert.ok(exists('.d-editor-textarea-wrapper.disabled'), 'textarea is disabled');
|
2018-04-11 07:31:20 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
const categoryChooser = selectKit('.category-chooser');
|
|
|
|
|
|
|
|
categoryChooser.expand().selectRowByValue(2);
|
|
|
|
|
|
|
|
andThen(() => {
|
2018-04-12 23:32:05 +08:00
|
|
|
assert.ok(find('.d-editor-textarea-wrapper.disabled').length === 0, 'textarea is enabled');
|
2018-04-11 07:31:20 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
fillIn('.d-editor-input', 'Now I can type stuff');
|
|
|
|
categoryChooser.expand().selectRowByValue('__none__');
|
|
|
|
|
|
|
|
andThen(() => {
|
2018-04-12 23:32:05 +08:00
|
|
|
assert.ok(find('.d-editor-textarea-wrapper.disabled').length === 0, 'textarea is still enabled');
|
2018-04-11 07:31:20 +08:00
|
|
|
});
|
|
|
|
});
|