Upgrade QUnit to latest version

This commit is contained in:
Robin Ward
2017-06-14 13:57:58 -04:00
parent 8ae445766f
commit cc525b1a8d
145 changed files with 7569 additions and 6763 deletions

View File

@ -7,44 +7,44 @@ acceptance("Composer", {
}
});
test("Tests the Composer controls", () => {
QUnit.test("Tests the Composer controls", assert => {
visit("/");
andThen(() => {
ok(exists('#create-topic'), 'the create button is visible');
assert.ok(exists('#create-topic'), 'the create button is visible');
});
click('#create-topic');
andThen(() => {
ok(exists('.d-editor-input'), 'the composer input is visible');
ok(exists('.title-input .popup-tip.bad.hide'), 'title errors are hidden by default');
ok(exists('.d-editor-textarea-wrapper .popup-tip.bad.hide'), 'body errors are hidden by default');
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');
});
click('a.toggle-preview');
andThen(() => {
ok(!exists('.d-editor-preview:visible'), "clicking the toggle hides the preview");
assert.ok(!exists('.d-editor-preview:visible'), "clicking the toggle hides the preview");
});
click('a.toggle-preview');
andThen(() => {
ok(exists('.d-editor-preview:visible'), "clicking the toggle shows the preview again");
assert.ok(exists('.d-editor-preview:visible'), "clicking the toggle shows the preview again");
});
click('#reply-control button.create');
andThen(() => {
ok(!exists('.title-input .popup-tip.bad.hide'), 'it shows the empty title error');
ok(!exists('.d-editor-wrapper .popup-tip.bad.hide'), 'it shows the empty body error');
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');
});
fillIn('#reply-title', "this is my new topic title");
andThen(() => {
ok(exists('.title-input .popup-tip.good'), 'the title is now good');
assert.ok(exists('.title-input .popup-tip.good'), 'the title is now good');
});
fillIn('.d-editor-input', "this is the *content* of a post");
andThen(() => {
equal(find('.d-editor-preview').html().trim(), "<p>this is the <em>content</em> of a post</p>", "it previews content");
ok(exists('.d-editor-textarea-wrapper .popup-tip.good'), 'the body is now good');
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');
});
andThen(() => {
@ -64,89 +64,89 @@ test("Tests the Composer controls", () => {
andThen(() => {
const example = I18n.t(`composer.bold_text`);
equal(find('#reply-control .d-editor-input').val().trim(),
assert.equal(find('#reply-control .d-editor-input').val().trim(),
`this is the *content* of a post**${example}**`,
"it supports keyboard shortcuts");
});
click('#reply-control a.cancel');
andThen(() => {
ok(exists('.bootbox.modal'), 'it pops up a confirmation dialog');
assert.ok(exists('.bootbox.modal'), 'it pops up a confirmation dialog');
});
click('.modal-footer a:eq(1)');
andThen(() => {
ok(!exists('.bootbox.modal'), 'the confirmation can be cancelled');
assert.ok(!exists('.bootbox.modal'), 'the confirmation can be cancelled');
});
});
test("Create a topic with server side errors", () => {
QUnit.test("Create a topic with server side errors", assert => {
visit("/");
click('#create-topic');
fillIn('#reply-title', "this title triggers an error");
fillIn('.d-editor-input', "this is the *content* of a post");
click('#reply-control button.create');
andThen(() => {
ok(exists('.bootbox.modal'), 'it pops up an error message');
assert.ok(exists('.bootbox.modal'), 'it pops up an error message');
});
click('.bootbox.modal a.btn-primary');
andThen(() => {
ok(!exists('.bootbox.modal'), 'it dismisses the error');
ok(exists('.d-editor-input'), 'the composer input is visible');
assert.ok(!exists('.bootbox.modal'), 'it dismisses the error');
assert.ok(exists('.d-editor-input'), 'the composer input is visible');
});
});
test("Create a Topic", () => {
QUnit.test("Create a Topic", assert => {
visit("/");
click('#create-topic');
fillIn('#reply-title', "Internationalization Localization");
fillIn('.d-editor-input', "this is the *content* of a new topic post");
click('#reply-control button.create');
andThen(() => {
equal(currentURL(), "/t/internationalization-localization/280", "it transitions to the newly created topic URL");
assert.equal(currentURL(), "/t/internationalization-localization/280", "it transitions to the newly created topic URL");
});
});
test("Create an enqueued Topic", () => {
QUnit.test("Create an enqueued Topic", assert => {
visit("/");
click('#create-topic');
fillIn('#reply-title', "Internationalization Localization");
fillIn('.d-editor-input', "enqueue this content please");
click('#reply-control button.create');
andThen(() => {
ok(visible('#discourse-modal'), 'it pops up a modal');
equal(currentURL(), "/", "it doesn't change routes");
assert.ok(visible('#discourse-modal'), 'it pops up a modal');
assert.equal(currentURL(), "/", "it doesn't change routes");
});
click('.modal-footer button');
andThen(() => {
ok(invisible('#discourse-modal'), 'the modal can be dismissed');
assert.ok(invisible('#discourse-modal'), 'the modal can be dismissed');
});
});
test("Create a Reply", () => {
QUnit.test("Create a Reply", assert => {
visit("/t/internationalization-localization/280");
andThen(() => {
ok(!exists('article[data-post-id=12345]'), 'the post is not in the DOM');
assert.ok(!exists('article[data-post-id=12345]'), 'the post is not in the DOM');
});
click('#topic-footer-buttons .btn.create');
andThen(() => {
ok(exists('.d-editor-input'), 'the composer input is visible');
ok(!exists('#reply-title'), 'there is no title since this is a reply');
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');
});
fillIn('.d-editor-input', 'this is the content of my reply');
click('#reply-control button.create');
andThen(() => {
equal(find('.cooked:last p').text(), 'this is the content of my reply');
assert.equal(find('.cooked:last p').text(), 'this is the content of my reply');
});
});
test("Posting on a different topic", (assert) => {
QUnit.test("Posting on a different topic", (assert) => {
visit("/t/internationalization-localization/280");
click('#topic-footer-buttons .btn.create');
fillIn('.d-editor-input', 'this is the content for a different topic');
@ -167,106 +167,106 @@ test("Posting on a different topic", (assert) => {
});
test("Create an enqueued Reply", () => {
QUnit.test("Create an enqueued Reply", assert => {
visit("/t/internationalization-localization/280");
click('#topic-footer-buttons .btn.create');
andThen(() => {
ok(exists('.d-editor-input'), 'the composer input is visible');
ok(!exists('#reply-title'), 'there is no title since this is a reply');
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');
});
fillIn('.d-editor-input', 'enqueue this content please');
click('#reply-control button.create');
andThen(() => {
ok(find('.cooked:last p').text() !== 'enqueue this content please', "it doesn't insert the post");
assert.ok(find('.cooked:last p').text() !== 'enqueue this content please', "it doesn't insert the post");
});
andThen(() => {
ok(visible('#discourse-modal'), 'it pops up a modal');
assert.ok(visible('#discourse-modal'), 'it pops up a modal');
});
click('.modal-footer button');
andThen(() => {
ok(invisible('#discourse-modal'), 'the modal can be dismissed');
assert.ok(invisible('#discourse-modal'), 'the modal can be dismissed');
});
});
test("Edit the first post", () => {
QUnit.test("Edit the first post", assert => {
visit("/t/internationalization-localization/280");
ok(!exists('.topic-post:eq(0) .post-info.edits'), 'it has no edits icon at first');
assert.ok(!exists('.topic-post:eq(0) .post-info.edits'), 'it has no edits icon at first');
click('.topic-post:eq(0) button.show-more-actions');
click('.topic-post:eq(0) button.edit');
andThen(() => {
equal(find('.d-editor-input').val().indexOf('Any plans to support'), 0, 'it populates the input with the post text');
assert.equal(find('.d-editor-input').val().indexOf('Any plans to support'), 0, 'it populates the input with the post text');
});
fillIn('.d-editor-input', "This is the new text for the post");
fillIn('#reply-title', "This is the new text for the title");
click('#reply-control button.create');
andThen(() => {
ok(!exists('.d-editor-input'), 'it closes the composer');
ok(exists('.topic-post:eq(0) .post-info.edits'), 'it has the edits icon');
ok(find('#topic-title h1').text().indexOf('This is the new text for the title') !== -1, 'it shows the new title');
ok(find('.topic-post:eq(0) .cooked').text().indexOf('This is the new text for the post') !== -1, 'it updates the post');
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');
});
});
test("Composer can switch between edits", () => {
QUnit.test("Composer can switch between edits", assert => {
visit("/t/this-is-a-test-topic/9");
click('.topic-post:eq(0) button.edit');
andThen(() => {
equal(find('.d-editor-input').val().indexOf('This is the first post.'), 0, 'it populates the input with the post text');
assert.equal(find('.d-editor-input').val().indexOf('This is the first post.'), 0, 'it populates the input with the post text');
});
click('.topic-post:eq(1) button.edit');
andThen(() => {
equal(find('.d-editor-input').val().indexOf('This is the second post.'), 0, 'it populates the input with the post text');
assert.equal(find('.d-editor-input').val().indexOf('This is the second post.'), 0, 'it populates the input with the post text');
});
});
test("Composer with dirty edit can toggle to another edit", () => {
QUnit.test("Composer with dirty edit can toggle to another edit", assert => {
visit("/t/this-is-a-test-topic/9");
click('.topic-post:eq(0) button.edit');
fillIn('.d-editor-input', 'This is a dirty reply');
click('.topic-post:eq(1) button.edit');
andThen(() => {
ok(exists('.bootbox.modal'), 'it pops up a confirmation dialog');
assert.ok(exists('.bootbox.modal'), 'it pops up a confirmation dialog');
});
click('.modal-footer a:eq(0)');
andThen(() => {
equal(find('.d-editor-input').val().indexOf('This is the second post.'), 0, 'it populates the input with the post text');
assert.equal(find('.d-editor-input').val().indexOf('This is the second post.'), 0, 'it populates the input with the post text');
});
});
test("Composer can toggle between edit and reply", () => {
QUnit.test("Composer can toggle between edit and reply", assert => {
visit("/t/this-is-a-test-topic/9");
click('.topic-post:eq(0) button.edit');
andThen(() => {
equal(find('.d-editor-input').val().indexOf('This is the first post.'), 0, 'it populates the input with the post text');
assert.equal(find('.d-editor-input').val().indexOf('This is the first post.'), 0, 'it populates the input with the post text');
});
click('.topic-post:eq(0) button.reply');
andThen(() => {
equal(find('.d-editor-input').val(), "", 'it clears the input');
assert.equal(find('.d-editor-input').val(), "", 'it clears the input');
});
click('.topic-post:eq(0) button.edit');
andThen(() => {
equal(find('.d-editor-input').val().indexOf('This is the first post.'), 0, 'it populates the input with the post text');
assert.equal(find('.d-editor-input').val().indexOf('This is the first post.'), 0, 'it populates the input with the post text');
});
});
test("Composer can toggle between reply and createTopic", () => {
QUnit.test("Composer can toggle between reply and createTopic", assert => {
visit("/t/this-is-a-test-topic/9");
click('.topic-post:eq(0) button.reply');
click('button.options');
click('.popup-menu .fa-eye-slash');
andThen(() => {
ok(
assert.ok(
find('.composer-fields .whisper').text().indexOf(I18n.t("composer.whisper")) > 0,
'it sets the post type to whisper'
);
@ -274,12 +274,12 @@ test("Composer can toggle between reply and createTopic", () => {
visit("/");
andThen(() => {
ok(exists('#create-topic'), 'the create topic button is visible');
assert.ok(exists('#create-topic'), 'the create topic button is visible');
});
click('#create-topic');
andThen(() => {
ok(
assert.ok(
find('.composer-fields .whisper').text().indexOf(I18n.t("composer.whisper")) === -1,
"it should reset the state of the composer's model"
);
@ -288,7 +288,7 @@ test("Composer can toggle between reply and createTopic", () => {
click('button.options');
click('.popup-menu .fa-eye-slash');
andThen(() => {
ok(
assert.ok(
find('.composer-fields .whisper').text().indexOf(I18n.t("composer.unlist")) > 0,
'it sets the topic to unlisted'
);
@ -298,29 +298,29 @@ test("Composer can toggle between reply and createTopic", () => {
click('.topic-post:eq(0) button.reply');
andThen(() => {
ok(
assert.ok(
find('.composer-fields .whisper').text().indexOf(I18n.t("composer.unlist")) === -1,
"it should reset the state of the composer's model"
);
});
});
test("Composer with dirty reply can toggle to edit", () => {
QUnit.test("Composer with dirty reply can toggle to edit", assert => {
visit("/t/this-is-a-test-topic/9");
click('.topic-post:eq(0) button.reply');
fillIn('.d-editor-input', 'This is a dirty reply');
click('.topic-post:eq(0) button.edit');
andThen(() => {
ok(exists('.bootbox.modal'), 'it pops up a confirmation dialog');
assert.ok(exists('.bootbox.modal'), 'it pops up a confirmation dialog');
});
click('.modal-footer a:eq(0)');
andThen(() => {
equal(find('.d-editor-input').val().indexOf('This is the first post.'), 0, 'it populates the input with the post text');
assert.equal(find('.d-editor-input').val().indexOf('This is the first post.'), 0, 'it populates the input with the post text');
});
});
test("Composer draft with dirty reply can toggle to edit", () => {
QUnit.test("Composer draft with dirty reply can toggle to edit", assert => {
visit("/t/this-is-a-test-topic/9");
click('.topic-post:eq(0) button.reply');
@ -328,10 +328,10 @@ test("Composer draft with dirty reply can toggle to edit", () => {
click('.toggler');
click('.topic-post:eq(0) button.edit');
andThen(() => {
ok(exists('.bootbox.modal'), 'it pops up a confirmation dialog');
assert.ok(exists('.bootbox.modal'), 'it pops up a confirmation dialog');
});
click('.modal-footer a:eq(0)');
andThen(() => {
equal(find('.d-editor-input').val().indexOf('This is the first post.'), 0, 'it populates the input with the post text');
assert.equal(find('.d-editor-input').val().indexOf('This is the first post.'), 0, 'it populates the input with the post text');
});
});
});