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

@@ -1,13 +1,12 @@
import { acceptance } from "helpers/qunit-helpers";
acceptance("About");
test("viewing", () => {
QUnit.test("viewing", assert => {
visit("/about");
andThen(() => {
ok($('body.about-page').length, "has body class");
ok(exists('.about.admins .user-info'), 'has admins');
ok(exists('.about.moderators .user-info'), 'has moderators');
ok(exists('.about.stats tr td'), 'has stats');
assert.ok($('body.about-page').length, "has body class");
assert.ok(exists('.about.admins .user-info'), 'has admins');
assert.ok(exists('.about.moderators .user-info'), 'has moderators');
assert.ok(exists('.about.stats tr td'), 'has stats');
});
});
});

View File

@@ -3,7 +3,7 @@ import PreloadStore from 'preload-store';
acceptance("Account Created");
test("account created - message", assert => {
QUnit.test("account created - message", assert => {
PreloadStore.store('accountCreated', {
message: "Hello World",
});
@@ -20,7 +20,7 @@ test("account created - message", assert => {
});
});
test("account created - resend email", assert => {
QUnit.test("account created - resend email", assert => {
PreloadStore.store('accountCreated', {
message: "Hello World",
username: 'eviltrout',
@@ -47,7 +47,7 @@ test("account created - resend email", assert => {
});
test("account created - update email - cancel", assert => {
QUnit.test("account created - update email - cancel", assert => {
PreloadStore.store('accountCreated', {
message: "Hello World",
username: 'eviltrout',
@@ -68,7 +68,7 @@ test("account created - update email - cancel", assert => {
});
});
test("account created - update email - submit", assert => {
QUnit.test("account created - update email - submit", assert => {
PreloadStore.store('accountCreated', {
message: "Hello World",
username: 'eviltrout',
@@ -94,4 +94,4 @@ test("account created - update email - submit", assert => {
assert.equal(email, 'newemail@example.com');
});
});
});

View File

@@ -2,33 +2,33 @@ import { acceptance } from "helpers/qunit-helpers";
acceptance("Admin - Site Texts", { loggedIn: true });
test("search for a key", () => {
QUnit.test("search for a key", assert => {
visit("/admin/customize/site_texts");
fillIn('.site-text-search', 'Test');
andThen(() => {
ok(exists('.site-text'));
ok(exists(".site-text:not(.overridden)"));
ok(exists('.site-text.overridden'));
assert.ok(exists('.site-text'));
assert.ok(exists(".site-text:not(.overridden)"));
assert.ok(exists('.site-text.overridden'));
});
// Only show overridden
click('.extra-options input');
andThen(() => {
ok(!exists(".site-text:not(.overridden)"));
ok(exists('.site-text.overridden'));
assert.ok(!exists(".site-text:not(.overridden)"));
assert.ok(exists('.site-text.overridden'));
});
});
test("edit and revert a site text by key", () => {
QUnit.test("edit and revert a site text by key", assert => {
visit("/admin/customize/site_texts/site.test");
andThen(() => {
equal(find('.title h3').text(), 'site.test');
ok(!exists('.save-messages .saved'));
ok(!exists('.save-messages .saved'));
ok(!exists('.revert-site-text'));
assert.equal(find('.title h3').text(), 'site.test');
assert.ok(!exists('.save-messages .saved'));
assert.ok(!exists('.save-messages .saved'));
assert.ok(!exists('.revert-site-text'));
});
// Change the value
@@ -36,19 +36,19 @@ test("edit and revert a site text by key", () => {
click(".save-changes");
andThen(() => {
ok(exists('.save-messages .saved'));
ok(exists('.revert-site-text'));
assert.ok(exists('.save-messages .saved'));
assert.ok(exists('.revert-site-text'));
});
// Revert the changes
click('.revert-site-text');
andThen(() => {
ok(exists('.bootbox.modal'));
assert.ok(exists('.bootbox.modal'));
});
click('.bootbox.modal .btn-primary');
andThen(() => {
ok(!exists('.save-messages .saved'));
ok(!exists('.revert-site-text'));
assert.ok(!exists('.save-messages .saved'));
assert.ok(!exists('.revert-site-text'));
});
});
});

View File

@@ -2,10 +2,10 @@ import { acceptance } from "helpers/qunit-helpers";
acceptance("Admin - Users List", { loggedIn: true });
test("lists users", () => {
QUnit.test("lists users", assert => {
visit("/admin/users/list/active");
andThen(() => {
ok(exists('.users-list .user'));
ok(!exists('.user:eq(0) .email small'), 'escapes email');
assert.ok(exists('.users-list .user'));
assert.ok(!exists('.user:eq(0) .email small'), 'escapes email');
});
});
});

View File

@@ -2,17 +2,17 @@ import { acceptance } from "helpers/qunit-helpers";
acceptance("Badges");
test("Visit Badge Pages", () => {
QUnit.test("Visit Badge Pages", assert => {
visit("/badges");
andThen(() => {
ok($('body.badges-page').length, "has body class");
ok(exists('.badge-groups .badge-card'), "has a list of badges");
assert.ok($('body.badges-page').length, "has body class");
assert.ok(exists('.badge-groups .badge-card'), "has a list of badges");
});
visit("/badges/9/autobiographer");
andThen(() => {
ok(exists('.badge-card'), "has the badge in the listing");
ok(exists('.user-info'), "has the list of users with that badge");
ok(!exists('.badge-card:eq(0) script'));
assert.ok(exists('.badge-card'), "has the badge in the listing");
assert.ok(exists('.user-info'), "has the list of users with that badge");
assert.ok(!exists('.badge-card:eq(0) script'));
});
});
});

View File

@@ -6,7 +6,7 @@ acceptance("Category Edit", {
settings: { email_in: true }
});
test("Can open the category modal", assert => {
QUnit.test("Can open the category modal", assert => {
visit("/c/bug");
click('.edit-category');
@@ -20,7 +20,7 @@ test("Can open the category modal", assert => {
});
});
test("Change the category color", assert => {
QUnit.test("Change the category color", assert => {
visit("/c/bug");
click('.edit-category');
@@ -32,7 +32,7 @@ test("Change the category color", assert => {
});
});
test("Change the topic template", assert => {
QUnit.test("Change the topic template", assert => {
visit("/c/bug");
click('.edit-category');
@@ -45,7 +45,7 @@ test("Change the topic template", assert => {
});
});
test("Error Saving", assert => {
QUnit.test("Error Saving", assert => {
visit("/c/bug");
click('.edit-category');
@@ -58,19 +58,19 @@ test("Error Saving", assert => {
});
});
test("Subcategory list settings", () => {
QUnit.test("Subcategory list settings", assert => {
visit("/c/bug");
click('.edit-category');
click('.edit-category-settings');
andThen(() => {
ok(!visible(".subcategory-list-style-field"), "subcategory list style isn't visible by default");
assert.ok(!visible(".subcategory-list-style-field"), "subcategory list style isn't visible by default");
});
click(".show-subcategory-list-field input[type=checkbox]");
andThen(() => {
ok(visible(".subcategory-list-style-field"), "subcategory list style is shown if show subcategory list is checked");
assert.ok(visible(".subcategory-list-style-field"), "subcategory list style is shown if show subcategory list is checked");
});
click('.edit-category-general');
@@ -78,7 +78,7 @@ test("Subcategory list settings", () => {
click('.edit-category-settings');
andThen(() => {
ok(!visible(".show-subcategory-list-field"), "show subcategory list isn't visible for child categories");
ok(!visible(".subcategory-list-style-field"), "subcategory list style isn't visible for child categories");
assert.ok(!visible(".show-subcategory-list-field"), "show subcategory list isn't visible for child categories");
assert.ok(!visible(".subcategory-list-style-field"), "subcategory list style isn't visible for child categories");
});
});
});

View File

@@ -2,18 +2,18 @@ import { acceptance } from "helpers/qunit-helpers";
acceptance("Category hashtag", { loggedIn: true });
test("category hashtag is cooked properly", () => {
QUnit.test("category hashtag is cooked properly", assert => {
visit("/t/internationalization-localization/280");
click('#topic-footer-buttons .btn.create');
fillIn('.d-editor-input', "this is a category hashtag #bug");
andThen(() => {
// TODO: Test that the autocomplete shows
equal(find('.d-editor-preview:visible').html().trim(), "<p>this is a category hashtag <a href=\"/c/bugs\" class=\"hashtag\">#<span>bug</span></a></p>");
assert.equal(find('.d-editor-preview:visible').html().trim(), "<p>this is a category hashtag <a href=\"/c/bugs\" class=\"hashtag\">#<span>bug</span></a></p>");
});
click('#reply-control .btn.create');
andThen(() => {
equal(find('.topic-post:last .cooked p').html().trim(), "this is a category hashtag <a href=\"/c/bugs\" class=\"hashtag\">#<span>bug</span></a>");
assert.equal(find('.topic-post:last .cooked p').html().trim(), "this is a category hashtag <a href=\"/c/bugs\" class=\"hashtag\">#<span>bug</span></a>");
});
});
});

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');
});
});
});

View File

@@ -9,58 +9,58 @@ acceptance("Composer topic featured links", {
});
test("onebox with title", () => {
QUnit.test("onebox with title", assert => {
visit("/");
click('#create-topic');
fillIn('#reply-title', "http://www.example.com/has-title.html");
andThen(() => {
ok(find('.d-editor-preview').html().trim().indexOf('onebox') > 0, "it pastes the link into the body and previews it");
ok(exists('.d-editor-textarea-wrapper .popup-tip.good'), 'the body is now good');
equal(find('.title-input input').val(), "An interesting article", "title is from the oneboxed article");
assert.ok(find('.d-editor-preview').html().trim().indexOf('onebox') > 0, "it pastes the link into the body and previews it");
assert.ok(exists('.d-editor-textarea-wrapper .popup-tip.good'), 'the body is now good');
assert.equal(find('.title-input input').val(), "An interesting article", "title is from the oneboxed article");
});
});
test("onebox result doesn't include a title", () => {
QUnit.test("onebox result doesn't include a title", assert => {
visit("/");
click('#create-topic');
fillIn('#reply-title', 'http://www.example.com/no-title.html');
andThen(() => {
ok(find('.d-editor-preview').html().trim().indexOf('onebox') > 0, "it pastes the link into the body and previews it");
ok(exists('.d-editor-textarea-wrapper .popup-tip.good'), 'the body is now good');
equal(find('.title-input input').val(), "http://www.example.com/no-title.html", "title is unchanged");
assert.ok(find('.d-editor-preview').html().trim().indexOf('onebox') > 0, "it pastes the link into the body and previews it");
assert.ok(exists('.d-editor-textarea-wrapper .popup-tip.good'), 'the body is now good');
assert.equal(find('.title-input input').val(), "http://www.example.com/no-title.html", "title is unchanged");
});
});
test("no onebox result", () => {
QUnit.test("no onebox result", assert => {
visit("/");
click('#create-topic');
fillIn('#reply-title', "http://www.example.com/nope-onebox.html");
andThen(() => {
ok(find('.d-editor-preview').html().trim().indexOf('onebox') > 0, "it pastes the link into the body and previews it");
ok(exists('.d-editor-textarea-wrapper .popup-tip.good'), 'link is pasted into body');
equal(find('.title-input input').val(), "http://www.example.com/nope-onebox.html", "title is unchanged");
assert.ok(find('.d-editor-preview').html().trim().indexOf('onebox') > 0, "it pastes the link into the body and previews it");
assert.ok(exists('.d-editor-textarea-wrapper .popup-tip.good'), 'link is pasted into body');
assert.equal(find('.title-input input').val(), "http://www.example.com/nope-onebox.html", "title is unchanged");
});
});
test("ignore internal links", () => {
QUnit.test("ignore internal links", assert => {
visit("/");
click('#create-topic');
const title = "http://" + window.location.hostname + "/internal-page.html";
fillIn('#reply-title', title);
andThen(() => {
equal(find('.d-editor-preview').html().trim().indexOf('onebox'), -1, "onebox preview doesn't show");
equal(find('.d-editor-input').val().length, 0, "link isn't put into the post");
equal(find('.title-input input').val(), title, "title is unchanged");
assert.equal(find('.d-editor-preview').html().trim().indexOf('onebox'), -1, "onebox preview doesn't show");
assert.equal(find('.d-editor-input').val().length, 0, "link isn't put into the post");
assert.equal(find('.title-input input').val(), title, "title is unchanged");
});
});
test("link is longer than max title length", () => {
QUnit.test("link is longer than max title length", assert => {
visit("/");
click('#create-topic');
fillIn('#reply-title', "http://www.example.com/has-title-and-a-url-that-is-more-than-80-characters-because-thats-good-for-seo-i-guess.html");
andThen(() => {
ok(find('.d-editor-preview').html().trim().indexOf('onebox') > 0, "it pastes the link into the body and previews it");
ok(exists('.d-editor-textarea-wrapper .popup-tip.good'), 'the body is now good');
equal(find('.title-input input').val(), "An interesting article", "title is from the oneboxed article");
assert.ok(find('.d-editor-preview').html().trim().indexOf('onebox') > 0, "it pastes the link into the body and previews it");
assert.ok(exists('.d-editor-textarea-wrapper .popup-tip.good'), 'the body is now good');
assert.equal(find('.title-input input').val(), "An interesting article", "title is from the oneboxed article");
});
});
});

View File

@@ -8,14 +8,14 @@ acceptance("Create Account - User Fields", {
}
});
test("create account with user fields", () => {
QUnit.test("create account with user fields", assert => {
visit("/");
click("header .sign-up-button");
andThen(() => {
ok(exists('.create-account'), "it shows the create account modal");
ok(exists('.user-field'), "it has at least one user field");
ok(exists('.modal-footer .btn-primary:disabled'), 'create account is disabled at first');
assert.ok(exists('.create-account'), "it shows the create account modal");
assert.ok(exists('.user-field'), "it has at least one user field");
assert.ok(exists('.modal-footer .btn-primary:disabled'), 'create account is disabled at first');
});
fillIn('#new-account-name', 'Dr. Good Tuna');
@@ -24,24 +24,24 @@ test("create account with user fields", () => {
fillIn('#new-account-username', 'goodtuna');
andThen(() => {
ok(exists('#username-validation.good'), 'the username validation is good');
ok(exists('.modal-footer .btn-primary:disabled'), 'create account is still disabled due to lack of user fields');
assert.ok(exists('#username-validation.good'), 'the username validation is good');
assert.ok(exists('.modal-footer .btn-primary:disabled'), 'create account is still disabled due to lack of user fields');
});
fillIn(".user-field input[type=text]:first", "Barky");
andThen(() => {
ok(exists('.modal-footer .btn-primary:disabled'), 'create account is disabled because field is not checked');
assert.ok(exists('.modal-footer .btn-primary:disabled'), 'create account is disabled because field is not checked');
});
click(".user-field input[type=checkbox]");
andThen(() => {
not(exists('.modal-footer .btn-primary:disabled'), 'create account is enabled because field is not checked');
assert.not(exists('.modal-footer .btn-primary:disabled'), 'create account is enabled because field is not checked');
});
click(".user-field input[type=checkbox]");
andThen(() => {
ok(exists('.modal-footer .btn-primary:disabled'), 'unclicking the checkbox disables the submit');
assert.ok(exists('.modal-footer .btn-primary:disabled'), 'unclicking the checkbox disables the submit');
});
});

View File

@@ -4,14 +4,14 @@ import PreloadStore from 'preload-store';
acceptance("CustomHTML set");
test("has no custom HTML in the top", assert => {
QUnit.test("has no custom HTML in the top", assert => {
visit("/static/faq");
andThen(() => {
assert.ok(!exists('span.custom-html-test'), 'it has no markup');
});
});
test("renders set HTML", assert => {
QUnit.test("renders set HTML", assert => {
setCustomHTML('top', '<span class="custom-html-test">HTML</span>');
visit("/static/faq");
@@ -20,11 +20,11 @@ test("renders set HTML", assert => {
});
});
test("renders preloaded HTML", assert => {
QUnit.test("renders preloaded HTML", assert => {
PreloadStore.store('customHTML', {top: "<span class='cookie'>monster</span>"});
visit("/static/faq");
andThen(() => {
assert.equal(find('span.cookie').text(), 'monster', 'it inserted the markup');
});
});
});

View File

@@ -1,16 +1,16 @@
import { acceptance } from "helpers/qunit-helpers";
acceptance("CustomHTML template", {
setup() {
beforeEach() {
Ember.TEMPLATES['top'] = Ember.HTMLBars.compile(`<span class='top-span'>TOP</span>`);
},
teardown() {
afterEach() {
delete Ember.TEMPLATES['top'];
}
});
test("renders custom template", assert => {
QUnit.test("renders custom template", assert => {
visit("/static/faq");
andThen(() => {
assert.equal(find('span.top-span').text(), 'TOP', 'it inserted the template');

View File

@@ -2,32 +2,32 @@ import { acceptance } from "helpers/qunit-helpers";
acceptance("Emoji", { loggedIn: true });
test("emoji is cooked properly", () => {
QUnit.test("emoji is cooked properly", assert => {
visit("/t/internationalization-localization/280");
click('#topic-footer-buttons .btn.create');
fillIn('.d-editor-input', "this is an emoji :blonde_woman:");
andThen(() => {
equal(find('.d-editor-preview:visible').html().trim(), "<p>this is an emoji <img src=\"/images/emoji/emoji_one/blonde_woman.png?v=5\" title=\":blonde_woman:\" class=\"emoji\" alt=\":blonde_woman:\"></p>");
assert.equal(find('.d-editor-preview:visible').html().trim(), "<p>this is an emoji <img src=\"/images/emoji/emoji_one/blonde_woman.png?v=5\" title=\":blonde_woman:\" class=\"emoji\" alt=\":blonde_woman:\"></p>");
});
click('#reply-control .btn.create');
andThen(() => {
equal(find('.topic-post:last .cooked p').html().trim(), "this is an emoji <img src=\"/images/emoji/emoji_one/blonde_woman.png?v=5\" title=\":blonde_woman:\" class=\"emoji\" alt=\":blonde_woman:\">");
assert.equal(find('.topic-post:last .cooked p').html().trim(), "this is an emoji <img src=\"/images/emoji/emoji_one/blonde_woman.png?v=5\" title=\":blonde_woman:\" class=\"emoji\" alt=\":blonde_woman:\">");
});
});
test("skin toned emoji is cooked properly", () => {
QUnit.test("skin toned emoji is cooked properly", assert => {
visit("/t/internationalization-localization/280");
click('#topic-footer-buttons .btn.create');
fillIn('.d-editor-input', "this is an emoji :blonde_woman:t5:");
andThen(() => {
equal(find('.d-editor-preview:visible').html().trim(), "<p>this is an emoji <img src=\"/images/emoji/emoji_one/blonde_woman/5.png?v=5\" title=\":blonde_woman:t5:\" class=\"emoji\" alt=\":blonde_woman:t5:\"></p>");
assert.equal(find('.d-editor-preview:visible').html().trim(), "<p>this is an emoji <img src=\"/images/emoji/emoji_one/blonde_woman/5.png?v=5\" title=\":blonde_woman:t5:\" class=\"emoji\" alt=\":blonde_woman:t5:\"></p>");
});
click('#reply-control .btn.create');
andThen(() => {
equal(find('.topic-post:last .cooked p').html().trim(), "this is an emoji <img src=\"/images/emoji/emoji_one/blonde_woman/5.png?v=5\" title=\":blonde_woman:t5:\" class=\"emoji\" alt=\":blonde_woman:t5:\">");
assert.equal(find('.topic-post:last .cooked p').html().trim(), "this is an emoji <img src=\"/images/emoji/emoji_one/blonde_woman/5.png?v=5\" title=\":blonde_woman:t5:\" class=\"emoji\" alt=\":blonde_woman:t5:\">");
});
});

View File

@@ -2,39 +2,39 @@ import { acceptance, logIn } from "helpers/qunit-helpers";
acceptance("Editing Group");
test("Editing group", () => {
QUnit.test("Editing group", assert => {
logIn();
Discourse.reset();
visit("/groups/discourse/edit");
andThen(() => {
ok(find('.group-flair-inputs').length === 1, 'it should display avatar flair inputs');
ok(find('.group-edit-bio').length === 1, 'it should display group bio input');
ok(find('.group-edit-full-name').length === 1, 'it should display group full name input');
ok(find('.group-edit-public').length === 1, 'it should display group public input');
ok(find('.group-edit-allow-membership-requests').length === 1, 'it should display group allow_membership_requets input');
ok(find('.group-members-input .item').length === 7, 'it should display group members');
ok(find('.group-members-input-selector').length === 1, 'it should display input to add group members');
ok(find('.group-members-input-selector .add[disabled]').length === 1, 'add members button should be disabled');
assert.ok(find('.group-flair-inputs').length === 1, 'it should display avatar flair inputs');
assert.ok(find('.group-edit-bio').length === 1, 'it should display group bio input');
assert.ok(find('.group-edit-full-name').length === 1, 'it should display group full name input');
assert.ok(find('.group-edit-public').length === 1, 'it should display group public input');
assert.ok(find('.group-edit-allow-membership-requests').length === 1, 'it should display group allow_membership_requets input');
assert.ok(find('.group-members-input .item').length === 7, 'it should display group members');
assert.ok(find('.group-members-input-selector').length === 1, 'it should display input to add group members');
assert.ok(find('.group-members-input-selector .add[disabled]').length === 1, 'add members button should be disabled');
});
andThen(() => {
ok(find('.group-edit-allow-membership-requests[disabled]').length === 1, 'it should disable group allow_membership_request input');
assert.ok(find('.group-edit-allow-membership-requests[disabled]').length === 1, 'it should disable group allow_membership_request input');
});
click('.group-edit-public');
click('.group-edit-allow-membership-requests');
andThen(() => {
ok(find('.group-edit-public[disabled]').length === 1, 'it should disable group public input');
assert.ok(find('.group-edit-public[disabled]').length === 1, 'it should disable group public input');
});
});
test("Editing group as an anonymous user", () => {
QUnit.test("Editing group as an anonymous user", assert => {
visit("/groups/discourse/edit");
andThen(() => {
ok(count('.group-members tr') > 0, "it should redirect to members page for an anonymous user");
assert.ok(count('.group-members tr') > 0, "it should redirect to members page for an anonymous user");
});
});
});

View File

@@ -2,7 +2,7 @@ import { acceptance } from "helpers/qunit-helpers";
acceptance("Group Logs", {
loggedIn: true,
setup() {
beforeEach() {
const response = object => {
return [
200,
@@ -26,15 +26,15 @@ acceptance("Group Logs", {
}
});
test("Browsing group logs", () => {
QUnit.test("Browsing group logs", assert => {
visit("/groups/snorlax/logs");
andThen(() => {
ok(find('tr.group-logs-row').length === 2, 'it should display the right number of logs');
assert.ok(find('tr.group-logs-row').length === 2, 'it should display the right number of logs');
click(find(".group-logs-row button")[0]);
});
andThen(() => {
ok(find('tr.group-logs-row').length === 1, 'it should display the right number of logs');
assert.ok(find('tr.group-logs-row').length === 1, 'it should display the right number of logs');
});
});
});

View File

@@ -2,104 +2,104 @@ import { acceptance, logIn } from "helpers/qunit-helpers";
acceptance("Groups");
test("Browsing Groups", () => {
QUnit.test("Browsing Groups", assert => {
visit("/groups");
andThen(() => {
equal(count('.groups-table-row'), 2, 'it displays visible groups');
equal(find('.group-index-join').length, 1, 'it shows button to join group');
equal(find('.group-index-request').length, 1, 'it shows button to request for group membership');
assert.equal(count('.groups-table-row'), 2, 'it displays visible groups');
assert.equal(find('.group-index-join').length, 1, 'it shows button to join group');
assert.equal(find('.group-index-request').length, 1, 'it shows button to request for group membership');
});
click('.group-index-join');
andThen(() => {
ok(exists('.modal.login-modal'), 'it shows the login modal');
assert.ok(exists('.modal.login-modal'), 'it shows the login modal');
});
click('.login-modal .close');
andThen(() => {
ok(invisible('.modal.login-modal'), 'it closes the login modal');
assert.ok(invisible('.modal.login-modal'), 'it closes the login modal');
});
click('.group-index-request');
andThen(() => {
ok(exists('.modal.login-modal'), 'it shows the login modal');
assert.ok(exists('.modal.login-modal'), 'it shows the login modal');
});
click("a[href='/groups/discourse/members']");
andThen(() => {
equal(find('.group-info-name').text().trim(), 'Awesome Team', "it displays the group page");
assert.equal(find('.group-info-name').text().trim(), 'Awesome Team', "it displays the group page");
});
click('.group-index-join');
andThen(() => {
ok(exists('.modal.login-modal'), 'it shows the login modal');
assert.ok(exists('.modal.login-modal'), 'it shows the login modal');
});
});
test("Viewing Group", () => {
QUnit.test("Viewing Group", assert => {
visit("/groups/discourse");
andThen(() => {
ok(count('.avatar-flair .fa-adjust') === 1, "it displays the group's avatar flair");
ok(count('.group-members tr') > 0, "it lists group members");
assert.ok(count('.avatar-flair .fa-adjust') === 1, "it displays the group's avatar flair");
assert.ok(count('.group-members tr') > 0, "it lists group members");
});
click(".nav-pills li a[title='Activity']");
andThen(() => {
ok(count('.user-stream .item') > 0, "it lists stream items");
assert.ok(count('.user-stream .item') > 0, "it lists stream items");
});
click(".group-activity-nav li a[href='/groups/discourse/activity/topics']");
andThen(() => {
ok(count('.user-stream .item') > 0, "it lists stream items");
assert.ok(count('.user-stream .item') > 0, "it lists stream items");
});
click(".group-activity-nav li a[href='/groups/discourse/activity/mentions']");
andThen(() => {
ok(count('.user-stream .item') > 0, "it lists stream items");
assert.ok(count('.user-stream .item') > 0, "it lists stream items");
});
andThen(() => {
equal(
assert.equal(
find(".group-activity li a[href='/groups/discourse/activity/messages']").length,
0,
'it should not show messages tab if user is not a group user or admin'
);
ok(find(".nav-pills li a[title='Edit Group']").length === 0, 'it should not show messages tab if user is not admin');
ok(find(".nav-pills li a[title='Logs']").length === 0, 'it should not show Logs tab if user is not admin');
ok(count('.user-stream .item') > 0, "it lists stream items");
assert.ok(find(".nav-pills li a[title='Edit Group']").length === 0, 'it should not show messages tab if user is not admin');
assert.ok(find(".nav-pills li a[title='Logs']").length === 0, 'it should not show Logs tab if user is not admin');
assert.ok(count('.user-stream .item') > 0, "it lists stream items");
});
});
test("Admin Viewing Group", () => {
QUnit.test("Admin Viewing Group", assert => {
logIn();
Discourse.reset();
visit("/groups/discourse");
andThen(() => {
ok(find(".nav-pills li a[title='Edit Group']").length === 1, 'it should show edit group tab if user is admin');
ok(find(".nav-pills li a[title='Logs']").length === 1, 'it should show Logs tab if user is admin');
assert.ok(find(".nav-pills li a[title='Edit Group']").length === 1, 'it should show edit group tab if user is admin');
assert.ok(find(".nav-pills li a[title='Logs']").length === 1, 'it should show Logs tab if user is admin');
equal(find('.group-info-name').text(), 'Awesome Team', 'it should display the group name');
assert.equal(find('.group-info-name').text(), 'Awesome Team', 'it should display the group name');
});
click(".nav-pills li a[title='Activity']");
andThen(() => {
equal(
assert.equal(
find(".group-activity li a[href='/groups/discourse/activity/messages']").length,
1,
'it should show messages tab if user is admin'
);
});
});
});

View File

@@ -7,7 +7,7 @@ acceptance("Invite Accept", {
}
});
test("Invite Acceptance Page", () => {
QUnit.test("Invite Acceptance Page", assert => {
PreloadStore.store('invite_info', {
invited_by: {"id":123,"username":"neil","avatar_template":"/user_avatar/localhost/neil/{size}/25_1.png","name":"Neil Lalonde","title":"team"},
email: "invited@asdf.com",
@@ -16,35 +16,35 @@ test("Invite Acceptance Page", () => {
visit("/invites/myvalidinvitetoken");
andThen(() => {
ok(exists("#new-account-username"), "shows the username input");
equal(find("#new-account-username").val(), "invited", "username is prefilled");
ok(exists("#new-account-name"), "shows the name input");
ok(exists("#new-account-password"), "shows the password input");
ok(exists('.invites-show .btn-primary:disabled'), 'submit is disabled because name is not filled');
assert.ok(exists("#new-account-username"), "shows the username input");
assert.equal(find("#new-account-username").val(), "invited", "username is prefilled");
assert.ok(exists("#new-account-name"), "shows the name input");
assert.ok(exists("#new-account-password"), "shows the password input");
assert.ok(exists('.invites-show .btn-primary:disabled'), 'submit is disabled because name is not filled');
});
fillIn("#new-account-name", 'John Doe');
andThen(() => {
not(exists('.invites-show .btn-primary:disabled'), 'submit is enabled');
assert.not(exists('.invites-show .btn-primary:disabled'), 'submit is enabled');
});
fillIn("#new-account-username", 'a');
andThen(() => {
ok(exists(".username-input .bad"), "username is not valid");
ok(exists('.invites-show .btn-primary:disabled'), 'submit is disabled');
assert.ok(exists(".username-input .bad"), "username is not valid");
assert.ok(exists('.invites-show .btn-primary:disabled'), 'submit is disabled');
});
fillIn("#new-account-password", 'aaa');
andThen(() => {
ok(exists(".password-input .bad"), "password is not valid");
ok(exists('.invites-show .btn-primary:disabled'), 'submit is disabled');
assert.ok(exists(".password-input .bad"), "password is not valid");
assert.ok(exists('.invites-show .btn-primary:disabled'), 'submit is disabled');
});
fillIn("#new-account-username", 'validname');
fillIn("#new-account-password", 'secur3ty4Y0uAndMe');
andThen(() => {
ok(exists(".username-input .good"), "username is valid");
ok(exists(".password-input .good"), "password is valid");
not(exists('.invites-show .btn-primary:disabled'), 'submit is enabled');
assert.ok(exists(".username-input .good"), "username is valid");
assert.ok(exists(".password-input .good"), "password is valid");
assert.not(exists('.invites-show .btn-primary:disabled'), 'submit is enabled');
});
});

View File

@@ -8,12 +8,12 @@ acceptance("Accept Invite - User Fields", {
}
});
test("accept invite with user fields", () => {
QUnit.test("accept invite with user fields", assert => {
visit("/invites/myvalidinvitetoken");
andThen(() => {
ok(exists(".invites-show"), "shows the accept invite page");
ok(exists('.user-field'), "it has at least one user field");
ok(exists('.invites-show .btn-primary:disabled'), 'submit is disabled');
assert.ok(exists(".invites-show"), "shows the accept invite page");
assert.ok(exists('.user-field'), "it has at least one user field");
assert.ok(exists('.invites-show .btn-primary:disabled'), 'submit is disabled');
});
fillIn("#new-account-name", 'John Doe');
@@ -21,24 +21,24 @@ test("accept invite with user fields", () => {
fillIn("#new-account-password", 'secur3ty4Y0uAndMe');
andThen(() => {
ok(exists(".username-input .good"), "username is valid");
ok(exists('.invites-show .btn-primary:disabled'), 'submit is still disabled due to lack of user fields');
assert.ok(exists(".username-input .good"), "username is valid");
assert.ok(exists('.invites-show .btn-primary:disabled'), 'submit is still disabled due to lack of user fields');
});
fillIn(".user-field input[type=text]:first", "Barky");
andThen(() => {
ok(exists('.invites-show .btn-primary:disabled'), 'submit is disabled because field is not checked');
assert.ok(exists('.invites-show .btn-primary:disabled'), 'submit is disabled because field is not checked');
});
click(".user-field input[type=checkbox]");
andThen(() => {
not(exists('.invites-show .btn-primary:disabled'), 'submit is enabled because field is checked');
assert.not(exists('.invites-show .btn-primary:disabled'), 'submit is enabled because field is checked');
});
click(".user-field input[type=checkbox]");
andThen(() => {
ok(exists('.invites-show .btn-primary:disabled'), 'unclicking the checkbox disables the submit');
assert.ok(exists('.invites-show .btn-primary:disabled'), 'unclicking the checkbox disables the submit');
});
});

View File

@@ -6,24 +6,24 @@ acceptance("Login Required", {
}
});
test("redirect", () => {
QUnit.test("redirect", assert => {
visit('/latest');
andThen(() => {
equal(currentPath(), "login", "it redirects them to login");
assert.equal(currentPath(), "login", "it redirects them to login");
});
click('#site-logo');
andThen(() => {
equal(currentPath(), "login", "clicking the logo keeps them on login");
assert.equal(currentPath(), "login", "clicking the logo keeps them on login");
});
click('header .login-button');
andThen(() => {
ok(exists('.login-modal'), "they can still access the login modal");
assert.ok(exists('.login-modal'), "they can still access the login modal");
});
click('.modal-header .close');
andThen(() => {
ok(invisible('.login-modal'), "it closes the login modal");
assert.ok(invisible('.login-modal'), "it closes the login modal");
});
});
});

View File

@@ -1,15 +1,15 @@
import { acceptance } from "helpers/qunit-helpers";
acceptance("Topic Discovery - Mobile", { mobileView: true });
test("Visit Discovery Pages", () => {
QUnit.test("Visit Discovery Pages", assert => {
visit("/");
andThen(() => {
ok(exists(".topic-list"), "The list of topics was rendered");
ok(exists('.topic-list .topic-list-item'), "has topics");
assert.ok(exists(".topic-list"), "The list of topics was rendered");
assert.ok(exists('.topic-list .topic-list-item'), "has topics");
});
visit("/categories");
andThen(() => {
ok(exists('.category'), "has a list of categories");
assert.ok(exists('.category'), "has a list of categories");
});
});
});

View File

@@ -2,10 +2,10 @@ import { acceptance } from "helpers/qunit-helpers";
acceptance("Signing In - Mobile", { mobileView: true });
test("sign in", () => {
QUnit.test("sign in", assert => {
visit("/");
click("header .login-button");
andThen(() => {
ok(exists('#login-form'), "it shows the login modal");
assert.ok(exists('#login-form'), "it shows the login modal");
});
});
});

View File

@@ -2,9 +2,9 @@ import { acceptance } from "helpers/qunit-helpers";
acceptance("User Directory - Mobile", { mobileView: true });
test("Visit Page", () => {
QUnit.test("Visit Page", assert => {
visit("/users");
andThen(() => {
ok(exists('.directory .user'), "has a list of users");
assert.ok(exists('.directory .user'), "has a list of users");
});
});
});

View File

@@ -1,30 +1,30 @@
import { acceptance } from "helpers/qunit-helpers";
acceptance("Modal");
test("modal", () => {
QUnit.test("modal", assert => {
visit('/');
andThen(() => {
ok(find('#discourse-modal:visible').length === 0, 'there is no modal at first');
assert.ok(find('#discourse-modal:visible').length === 0, 'there is no modal at first');
});
click('.login-button');
andThen(() => {
ok(find('#discourse-modal:visible').length === 1, 'modal should appear');
assert.ok(find('#discourse-modal:visible').length === 1, 'modal should appear');
});
click('.modal-outer-container');
andThen(() => {
ok(find('#discourse-modal:visible').length === 0, 'modal should disappear when you click outside');
assert.ok(find('#discourse-modal:visible').length === 0, 'modal should disappear when you click outside');
});
click('.login-button');
andThen(() => {
ok(find('#discourse-modal:visible').length === 1, 'modal should reappear');
assert.ok(find('#discourse-modal:visible').length === 1, 'modal should reappear');
});
keyEvent('#main-outlet', 'keydown', 27);
andThen(() => {
ok(find('#discourse-modal:visible').length === 0, 'ESC should close the modal');
assert.ok(find('#discourse-modal:visible').length === 0, 'ESC should close the modal');
});
});
});

View File

@@ -3,7 +3,7 @@ import PreloadStore from 'preload-store';
import { parsePostData } from "helpers/create-pretender";
acceptance("Password Reset", {
setup() {
beforeEach() {
const response = (object) => {
return [
200,
@@ -27,36 +27,35 @@ acceptance("Password Reset", {
}
});
test("Password Reset Page", () => {
QUnit.test("Password Reset Page", assert => {
PreloadStore.store('password_reset', {is_developer: false});
visit("/u/password-reset/myvalidtoken");
andThen(() => {
ok(exists(".password-reset input"), "shows the input");
assert.ok(exists(".password-reset input"), "shows the input");
});
fillIn('.password-reset input', 'perf3ctly5ecur3');
andThen(() => {
ok(exists(".password-reset .tip.good"), "input looks good");
assert.ok(exists(".password-reset .tip.good"), "input looks good");
});
fillIn('.password-reset input', '123');
andThen(() => {
ok(exists(".password-reset .tip.bad"), "input is not valid");
ok(find(".password-reset .tip.bad").html().indexOf(I18n.t('user.password.too_short')) > -1, "password too short");
assert.ok(exists(".password-reset .tip.bad"), "input is not valid");
assert.ok(find(".password-reset .tip.bad").html().indexOf(I18n.t('user.password.too_short')) > -1, "password too short");
});
fillIn('.password-reset input', 'jonesyAlienSlayer');
click('.password-reset form button');
andThen(() => {
ok(exists(".password-reset .tip.bad"), "input is not valid");
ok(find(".password-reset .tip.bad").html().indexOf("is the name of your cat") > -1, "server validation error message shows");
assert.ok(exists(".password-reset .tip.bad"), "input is not valid");
assert.ok(find(".password-reset .tip.bad").html().indexOf("is the name of your cat") > -1, "server validation error message shows");
});
fillIn('.password-reset input', 'perf3ctly5ecur3');
click('.password-reset form button');
andThen(() => {
ok(!exists(".password-reset form"), "form is gone");
assert.ok(!exists(".password-reset form"), "form is gone");
});
});
});

View File

@@ -3,7 +3,7 @@ import { extraConnectorClass } from 'discourse/lib/plugin-connectors';
const PREFIX = "javascripts/single-test/connectors";
acceptance("Plugin Outlet - Connector Class", {
setup() {
beforeEach() {
extraConnectorClass('user-profile-primary/hello', {
actions: {
sayHello() {
@@ -28,13 +28,13 @@ acceptance("Plugin Outlet - Connector Class", {
);
},
teardown() {
afterEach() {
delete Ember.TEMPLATES[`${PREFIX}/user-profile-primary/hello`];
delete Ember.TEMPLATES[`${PREFIX}/user-profile-primary/dont-render`];
}
});
test("Renders a template into the outlet", assert => {
QUnit.test("Renders a template into the outlet", assert => {
visit("/u/eviltrout");
andThen(() => {
assert.ok(find('.user-profile-primary-outlet.hello').length === 1, 'it has class names');
@@ -44,4 +44,4 @@ test("Renders a template into the outlet", assert => {
andThen(() => {
assert.equal(find('.hello-result').text(), 'hello!', 'actions delegate properly');
});
});
});

View File

@@ -5,20 +5,20 @@ const HELLO = 'javascripts/multi-test/connectors/user-profile-primary/hello';
const GOODBYE = 'javascripts/multi-test/connectors/user-profile-primary/goodbye';
acceptance("Plugin Outlet - Multi Template", {
setup() {
beforeEach() {
clearCache();
Ember.TEMPLATES[HELLO] = Ember.HTMLBars.compile(`<span class='hello-span'>Hello</span>`);
Ember.TEMPLATES[GOODBYE] = Ember.HTMLBars.compile(`<span class='bye-span'>Goodbye</span>`);
},
teardown() {
afterEach() {
delete Ember.TEMPLATES[HELLO];
delete Ember.TEMPLATES[GOODBYE];
clearCache();
}
});
test("Renders a template into the outlet", assert => {
QUnit.test("Renders a template into the outlet", assert => {
visit("/u/eviltrout");
andThen(() => {
assert.ok(find('.user-profile-primary-outlet.hello').length === 1, 'it has class names');
@@ -26,4 +26,4 @@ test("Renders a template into the outlet", assert => {
assert.equal(find('.hello-span').text(), 'Hello', 'it renders into the outlet');
assert.equal(find('.bye-span').text(), 'Goodbye', 'it renders into the outlet');
});
});
});

View File

@@ -2,21 +2,21 @@ import { acceptance } from "helpers/qunit-helpers";
const CONNECTOR = 'javascripts/single-test/connectors/user-profile-primary/hello';
acceptance("Plugin Outlet - Single Template", {
setup() {
beforeEach() {
Ember.TEMPLATES[CONNECTOR] = Ember.HTMLBars.compile(
`<span class='hello-username'>{{model.username}}</span>`
);
},
teardown() {
afterEach() {
delete Ember.TEMPLATES[CONNECTOR];
}
});
test("Renders a template into the outlet", assert => {
QUnit.test("Renders a template into the outlet", assert => {
visit("/u/eviltrout");
andThen(() => {
assert.ok(find('.user-profile-primary-outlet.hello').length === 1, 'it has class names');
assert.equal(find('.hello-username').text(), 'eviltrout', 'it renders into the outlet');
});
});
});

View File

@@ -1,20 +1,20 @@
import { acceptance } from "helpers/qunit-helpers";
acceptance("User Preferences", { loggedIn: true });
test("update some fields", () => {
QUnit.test("update some fields", assert => {
visit("/u/eviltrout/preferences");
andThen(() => {
ok($('body.user-preferences-page').length, "has the body class");
equal(currentURL(), '/u/eviltrout/preferences/account', "defaults to account tab");
ok(exists('.user-preferences'), 'it shows the preferences');
assert.ok($('body.user-preferences-page').length, "has the body class");
assert.equal(currentURL(), '/u/eviltrout/preferences/account', "defaults to account tab");
assert.ok(exists('.user-preferences'), 'it shows the preferences');
});
const savePreferences = () => {
click('.save-user');
ok(!exists('.saved-user'), "it hasn't been saved yet");
assert.ok(!exists('.saved-user'), "it hasn't been saved yet");
andThen(() => {
ok(exists('.saved-user'), 'it displays the saved message');
assert.ok(exists('.saved-user'), 'it displays the saved message');
});
};
@@ -37,39 +37,39 @@ test("update some fields", () => {
fillIn('.category-controls .category-selector', 'faq');
savePreferences();
ok(!exists('.preferences-nav .nav-tags a'), "tags tab isn't there when tags are disabled");
assert.ok(!exists('.preferences-nav .nav-tags a'), "tags tab isn't there when tags are disabled");
// Error: Unhandled request in test environment: /themes/assets/10d71596-7e4e-4dc0-b368-faa3b6f1ce6d?_=1493833562388 (GET)
// click(".preferences-nav .nav-interface a");
// click('.control-group.other input[type=checkbox]:first');
// savePreferences();
ok(!exists('.preferences-nav .nav-apps a'), "apps tab isn't there when you have no authorized apps");
assert.ok(!exists('.preferences-nav .nav-apps a'), "apps tab isn't there when you have no authorized apps");
});
test("username", () => {
QUnit.test("username", assert => {
visit("/u/eviltrout/preferences/username");
andThen(() => {
ok(exists("#change_username"), "it has the input element");
assert.ok(exists("#change_username"), "it has the input element");
});
});
test("about me", () => {
QUnit.test("about me", assert => {
visit("/u/eviltrout/preferences/about-me");
andThen(() => {
ok(exists(".raw-bio"), "it has the input element");
assert.ok(exists(".raw-bio"), "it has the input element");
});
});
test("email", () => {
QUnit.test("email", assert => {
visit("/u/eviltrout/preferences/email");
andThen(() => {
ok(exists("#change-email"), "it has the input element");
assert.ok(exists("#change-email"), "it has the input element");
});
fillIn("#change-email", 'invalidemail');
andThen(() => {
equal(find('.tip.bad').text().trim(), I18n.t('user.email.invalid'), 'it should display invalid email tip');
assert.equal(find('.tip.bad').text().trim(), I18n.t('user.email.invalid'), 'it should display invalid email tip');
});
});
});

View File

@@ -2,21 +2,21 @@ import { acceptance } from "helpers/qunit-helpers";
const CONNECTOR = 'javascripts/raw-test/connectors/topic-list-before-status/lala';
acceptance("Raw Plugin Outlet", {
setup() {
beforeEach() {
Discourse.RAW_TEMPLATES[CONNECTOR] = Handlebars.compile(
`<span class='topic-lala'>{{context.topic.id}}</span>`
);
},
teardown() {
afterEach() {
delete Discourse.RAW_TEMPLATES[CONNECTOR];
}
});
test("Renders the raw plugin outlet", assert => {
QUnit.test("Renders the raw plugin outlet", assert => {
visit("/");
andThen(() => {
assert.ok(find('.topic-lala').length > 0, 'it renders the outlet');
assert.equal(find('.topic-lala:eq(0)').text(), '11557', 'it has the topic id');
});
});
});

View File

@@ -1,7 +1,7 @@
import { acceptance, waitFor } from "helpers/qunit-helpers";
acceptance("Search - Full Page", {
settings: {tagging_enabled: true},
setup() {
beforeEach() {
const response = (object) => {
return [
200,
@@ -39,12 +39,12 @@ acceptance("Search - Full Page", {
}
});
test("perform various searches", assert => {
QUnit.test("perform various searches", assert => {
visit("/search");
andThen(() => {
ok($('body.search-page').length, "has body class");
ok(exists('.search-container'), "has container class");
assert.ok($('body.search-page').length, "has body class");
assert.ok(exists('.search-container'), "has container class");
assert.ok(find('input.search').length > 0);
assert.ok(find('.fps-topic').length === 0);
});
@@ -60,7 +60,7 @@ test("perform various searches", assert => {
andThen(() => assert.ok(find('.fps-topic').length === 1, 'has one post'));
});
test("open advanced search", assert => {
QUnit.test("open advanced search", assert => {
visit("/search");
andThen(() => assert.ok(exists('.search .search-advanced'), 'shows advanced search panel'));
@@ -95,7 +95,7 @@ test("open advanced search", assert => {
// });
// });
test("escape search term", (assert) => {
QUnit.test("escape search term", (assert) => {
visit("/search");
fillIn('.search input.full-page-search', '@<script>prompt(1337)</script>gmail.com');
click('.search-advanced-btn');
@@ -105,7 +105,7 @@ test("escape search term", (assert) => {
});
});
test("update username through advanced search ui", assert => {
QUnit.test("update username through advanced search ui", assert => {
visit("/search");
fillIn('.search input.full-page-search', 'none');
click('.search-advanced-btn');
@@ -114,7 +114,7 @@ test("update username through advanced search ui", assert => {
keyEvent('.search-advanced-options .user-selector', 'keydown', 8);
andThen(() => {
waitFor(() => {
waitFor(assert, () => {
assert.ok(visible('.search-advanced-options .autocomplete'), '"autocomplete" popup is visible');
assert.ok(exists('.search-advanced-options .autocomplete ul li a span.username:contains("admin")'), '"autocomplete" popup has an entry for "admin"');
@@ -128,7 +128,7 @@ test("update username through advanced search ui", assert => {
});
});
test("update category through advanced search ui", assert => {
QUnit.test("update category through advanced search ui", assert => {
visit("/search");
fillIn('.search input.full-page-search', 'none');
click('.search-advanced-btn');
@@ -209,7 +209,7 @@ test("update category through advanced search ui", assert => {
// });
// });
test("update in:likes filter through advanced search ui", assert => {
QUnit.test("update in:likes filter through advanced search ui", assert => {
visit("/search");
fillIn('.search input.full-page-search', 'none');
click('.search-advanced-btn');
@@ -221,7 +221,7 @@ test("update in:likes filter through advanced search ui", assert => {
});
});
test("update in:private filter through advanced search ui", assert => {
QUnit.test("update in:private filter through advanced search ui", assert => {
visit("/search");
fillIn('.search input.full-page-search', 'none');
click('.search-advanced-btn');
@@ -233,7 +233,7 @@ test("update in:private filter through advanced search ui", assert => {
});
});
test("update in:seen filter through advanced search ui", assert => {
QUnit.test("update in:seen filter through advanced search ui", assert => {
visit("/search");
fillIn('.search input.full-page-search', 'none');
click('.search-advanced-btn');
@@ -248,7 +248,7 @@ test("update in:seen filter through advanced search ui", assert => {
});
});
test("update in filter through advanced search ui", assert => {
QUnit.test("update in filter through advanced search ui", assert => {
visit("/search");
fillIn('.search input.full-page-search', 'none');
click('.search-advanced-btn');
@@ -261,7 +261,7 @@ test("update in filter through advanced search ui", assert => {
});
});
test("update status through advanced search ui", assert => {
QUnit.test("update status through advanced search ui", assert => {
visit("/search");
fillIn('.search input.full-page-search', 'none');
click('.search-advanced-btn');
@@ -274,7 +274,7 @@ test("update status through advanced search ui", assert => {
});
});
test("update post time through advanced search ui", assert => {
QUnit.test("update post time through advanced search ui", assert => {
visit("/search");
fillIn('.search input.full-page-search', 'none');
click('.search-advanced-btn');
@@ -289,7 +289,7 @@ test("update post time through advanced search ui", assert => {
});
});
test("update min post count through advanced search ui", assert => {
QUnit.test("update min post count through advanced search ui", assert => {
visit("/search");
fillIn('.search input.full-page-search', 'none');
click('.search-advanced-btn');
@@ -301,7 +301,7 @@ test("update min post count through advanced search ui", assert => {
});
});
test("validate advanced search when initially empty", assert => {
QUnit.test("validate advanced search when initially empty", assert => {
visit("/search?expanded=true");
click('.search-advanced-options .in-likes');

View File

@@ -1,7 +1,7 @@
import { acceptance } from "helpers/qunit-helpers";
acceptance("Search");
test("search", (assert) => {
QUnit.test("search", (assert) => {
visit("/");
click('#search-button');
@@ -25,29 +25,29 @@ test("search", (assert) => {
});
});
test("search scope checkbox", () => {
QUnit.test("search scope checkbox", assert => {
visit("/c/bug");
click('#search-button');
andThen(() => {
ok(exists('.search-context input:checked'), 'scope to category checkbox is checked');
assert.ok(exists('.search-context input:checked'), 'scope to category checkbox is checked');
});
click('#search-button');
visit("/t/internationalization-localization/280");
click('#search-button');
andThen(() => {
not(exists('.search-context input:checked'), 'scope to topic checkbox is not checked');
assert.not(exists('.search-context input:checked'), 'scope to topic checkbox is not checked');
});
click('#search-button');
visit("/u/eviltrout");
click('#search-button');
andThen(() => {
ok(exists('.search-context input:checked'), 'scope to user checkbox is checked');
assert.ok(exists('.search-context input:checked'), 'scope to user checkbox is checked');
});
});
test("Search with context", assert => {
QUnit.test("Search with context", assert => {
visit("/t/internationalization-localization/280/1");
click('#search-button');
@@ -72,4 +72,4 @@ test("Search with context", assert => {
andThen(() => {
assert.ok(!$('.search-context input[type=checkbox]').is(":checked"));
});
});
});

View File

@@ -1,11 +1,11 @@
import { acceptance } from "helpers/qunit-helpers";
acceptance("Signing In");
test("sign in", () => {
QUnit.test("sign in", assert => {
visit("/");
click("header .login-button");
andThen(() => {
ok(exists('.login-modal'), "it shows the login modal");
assert.ok(exists('.login-modal'), "it shows the login modal");
});
// Test invalid password first
@@ -13,48 +13,48 @@ test("sign in", () => {
fillIn('#login-account-password', 'incorrect');
click('.modal-footer .btn-primary');
andThen(() => {
ok(exists('#modal-alert:visible'), 'it displays the login error');
not(exists('.modal-footer .btn-primary:disabled'), "enables the login button");
assert.ok(exists('#modal-alert:visible'), 'it displays the login error');
assert.not(exists('.modal-footer .btn-primary:disabled'), "enables the login button");
});
// Use the correct password
fillIn('#login-account-password', 'correct');
click('.modal-footer .btn-primary');
andThen(() => {
ok(exists('.modal-footer .btn-primary:disabled'), "disables the login button");
assert.ok(exists('.modal-footer .btn-primary:disabled'), "disables the login button");
});
});
test("sign in - not activated", () => {
QUnit.test("sign in - not activated", assert => {
visit("/");
andThen(() => {
click("header .login-button");
andThen(() => {
ok(exists('.login-modal'), "it shows the login modal");
assert.ok(exists('.login-modal'), "it shows the login modal");
});
fillIn('#login-account-name', 'eviltrout');
fillIn('#login-account-password', 'not-activated');
click('.modal-footer .btn-primary');
andThen(() => {
equal(find('.modal-body b').text(), '<small>eviltrout@example.com</small>');
ok(!exists('.modal-body small'), 'it escapes the email address');
assert.equal(find('.modal-body b').text(), '<small>eviltrout@example.com</small>');
assert.ok(!exists('.modal-body small'), 'it escapes the email address');
});
click('.modal-footer button.resend');
andThen(() => {
equal(find('.modal-body b').text(), '<small>current@example.com</small>');
ok(!exists('.modal-body small'), 'it escapes the email address');
assert.equal(find('.modal-body b').text(), '<small>current@example.com</small>');
assert.ok(!exists('.modal-body small'), 'it escapes the email address');
});
});
});
test("sign in - not activated - edit email", () => {
QUnit.test("sign in - not activated - edit email", assert => {
visit("/");
andThen(() => {
click("header .login-button");
andThen(() => {
ok(exists('.login-modal'), "it shows the login modal");
assert.ok(exists('.login-modal'), "it shows the login modal");
});
fillIn('#login-account-name', 'eviltrout');
@@ -62,27 +62,27 @@ test("sign in - not activated - edit email", () => {
click('.modal-footer .btn-primary');
click('.modal-footer button.edit-email');
andThen(() => {
equal(find('.activate-new-email').val(), 'current@example.com');
equal(find('.modal-footer .btn-primary:disabled').length, 1, "must change email");
assert.equal(find('.activate-new-email').val(), 'current@example.com');
assert.equal(find('.modal-footer .btn-primary:disabled').length, 1, "must change email");
});
fillIn('.activate-new-email', 'different@example.com');
andThen(() => {
equal(find('.modal-footer .btn-primary:disabled').length, 0);
assert.equal(find('.modal-footer .btn-primary:disabled').length, 0);
});
click(".modal-footer .btn-primary");
andThen(() => {
equal(find('.modal-body b').text(), 'different@example.com');
assert.equal(find('.modal-body b').text(), 'different@example.com');
});
});
});
test("create account", () => {
QUnit.test("create account", assert => {
visit("/");
click("header .sign-up-button");
andThen(() => {
ok(exists('.create-account'), "it shows the create account modal");
ok(exists('.modal-footer .btn-primary:disabled'), 'create account is disabled at first');
assert.ok(exists('.create-account'), "it shows the create account modal");
assert.ok(exists('.modal-footer .btn-primary:disabled'), 'create account is disabled at first');
});
fillIn('#new-account-name', 'Dr. Good Tuna');
@@ -92,18 +92,18 @@ test("create account", () => {
fillIn('#new-account-email', 'good.tuna@test.com');
fillIn('#new-account-username', 'taken');
andThen(() => {
ok(exists('#username-validation.bad'), 'the username validation is bad');
ok(exists('.modal-footer .btn-primary:disabled'), 'create account is still disabled');
assert.ok(exists('#username-validation.bad'), 'the username validation is bad');
assert.ok(exists('.modal-footer .btn-primary:disabled'), 'create account is still disabled');
});
fillIn('#new-account-username', 'goodtuna');
andThen(() => {
ok(exists('#username-validation.good'), 'the username validation is good');
not(exists('.modal-footer .btn-primary:disabled'), 'create account is enabled');
assert.ok(exists('#username-validation.good'), 'the username validation is good');
assert.not(exists('.modal-footer .btn-primary:disabled'), 'create account is enabled');
});
click('.modal-footer .btn-primary');
andThen(() => {
ok(exists('.modal-footer .btn-primary:disabled'), "create account is disabled");
assert.ok(exists('.modal-footer .btn-primary:disabled'), "create account is disabled");
});
});
});

View File

@@ -1,33 +1,33 @@
import { acceptance } from "helpers/qunit-helpers";
acceptance("Static");
test("Static Pages", () => {
QUnit.test("Static Pages", assert => {
visit("/faq");
andThen(() => {
ok($('body.static-faq').length, "has the body class");
ok(exists(".body-page"), "The content is present");
assert.ok($('body.static-faq').length, "has the body class");
assert.ok(exists(".body-page"), "The content is present");
});
visit("/guidelines");
andThen(() => {
ok($('body.static-guidelines').length, "has the body class");
ok(exists(".body-page"), "The content is present");
assert.ok($('body.static-guidelines').length, "has the body class");
assert.ok(exists(".body-page"), "The content is present");
});
visit("/tos");
andThen(() => {
ok($('body.static-tos').length, "has the body class");
ok(exists(".body-page"), "The content is present");
assert.ok($('body.static-tos').length, "has the body class");
assert.ok(exists(".body-page"), "The content is present");
});
visit("/privacy");
andThen(() => {
ok($('body.static-privacy').length, "has the body class");
ok(exists(".body-page"), "The content is present");
assert.ok($('body.static-privacy').length, "has the body class");
assert.ok(exists(".body-page"), "The content is present");
});
visit("/login");
andThen(() => {
equal(currentPath(), "discovery.latest", "it redirects them to latest unless `login_required`");
assert.equal(currentPath(), "discovery.latest", "it redirects them to latest unless `login_required`");
});
});
});

View File

@@ -3,7 +3,7 @@ import { acceptance } from "helpers/qunit-helpers";
acceptance("Tag Hashtag", {
loggedIn: true,
settings: { tagging_enabled: true },
setup() {
beforeEach() {
const response = (object) => {
return [
200,
@@ -26,18 +26,18 @@ acceptance("Tag Hashtag", {
}
});
test("tag is cooked properly", () => {
QUnit.test("tag is cooked properly", assert => {
visit("/t/internationalization-localization/280");
click('#topic-footer-buttons .btn.create');
fillIn('.d-editor-input', "this is a tag hashtag #monkey::tag");
andThen(() => {
// TODO: Test that the autocomplete shows
equal(find('.d-editor-preview:visible').html().trim(), "<p>this is a tag hashtag <a href=\"/tags/monkey\" class=\"hashtag\">#<span>monkey</span></a></p>");
assert.equal(find('.d-editor-preview:visible').html().trim(), "<p>this is a tag hashtag <a href=\"/tags/monkey\" class=\"hashtag\">#<span>monkey</span></a></p>");
});
click('#reply-control .btn.create');
andThen(() => {
equal(find('.topic-post:last .cooked').html().trim(), "<p>this is a tag hashtag <a href=\"/tags/monkey\" class=\"hashtag\">#<span>monkey</span></a></p>");
assert.equal(find('.topic-post:last .cooked').html().trim(), "<p>this is a tag hashtag <a href=\"/tags/monkey\" class=\"hashtag\">#<span>monkey</span></a></p>");
});
});
});

View File

@@ -1,11 +1,11 @@
import { acceptance } from "helpers/qunit-helpers";
acceptance("Tags", { loggedIn: true });
test("list the tags", () => {
QUnit.test("list the tags", assert => {
visit("/tags");
andThen(() => {
ok($('body.tags-page').length, "has the body class");
ok(exists('.tag-eviltrout'), "shows the evil trout tag");
assert.ok($('body.tags-page').length, "has the body class");
assert.ok(exists('.tag-eviltrout'), "shows the evil trout tag");
});
});
});

View File

@@ -1,22 +1,22 @@
import { acceptance } from "helpers/qunit-helpers";
acceptance("Topic - Anonymous");
test("Enter a Topic", () => {
QUnit.test("Enter a Topic", assert => {
visit("/t/internationalization-localization/280/1");
andThen(() => {
ok(exists("#topic"), "The topic was rendered");
ok(exists("#topic .cooked"), "The topic has cooked posts");
assert.ok(exists("#topic"), "The topic was rendered");
assert.ok(exists("#topic .cooked"), "The topic has cooked posts");
});
});
test("Enter without an id", () => {
QUnit.test("Enter without an id", assert => {
visit("/t/internationalization-localization");
andThen(() => {
ok(exists("#topic"), "The topic was rendered");
assert.ok(exists("#topic"), "The topic was rendered");
});
});
test("Enter a 404 topic", assert => {
QUnit.test("Enter a 404 topic", assert => {
visit("/t/not-found/404");
andThen(() => {
assert.ok(!exists("#topic"), "The topic was not rendered");
@@ -24,7 +24,7 @@ test("Enter a 404 topic", assert => {
});
});
test("Enter without access", assert => {
QUnit.test("Enter without access", assert => {
visit("/t/i-dont-have-access/403");
andThen(() => {
assert.ok(!exists("#topic"), "The topic was not rendered");
@@ -32,10 +32,10 @@ test("Enter without access", assert => {
});
});
test("Enter with 500 errors", assert => {
QUnit.test("Enter with 500 errors", assert => {
visit("/t/throws-error/500");
andThen(() => {
assert.ok(!exists("#topic"), "The topic was not rendered");
assert.ok(exists(".topic-error"), "An error message is displayed");
});
});
});

View File

@@ -1,46 +1,46 @@
import { acceptance } from "helpers/qunit-helpers";
acceptance("Topic Discovery");
test("Visit Discovery Pages", () => {
QUnit.test("Visit Discovery Pages", assert => {
visit("/");
andThen(() => {
ok($('body.navigation-topics').length, "has the default navigation");
ok(exists(".topic-list"), "The list of topics was rendered");
ok(exists('.topic-list .topic-list-item'), "has topics");
assert.ok($('body.navigation-topics').length, "has the default navigation");
assert.ok(exists(".topic-list"), "The list of topics was rendered");
assert.ok(exists('.topic-list .topic-list-item'), "has topics");
});
visit("/c/bug");
andThen(() => {
ok(exists(".topic-list"), "The list of topics was rendered");
ok(exists('.topic-list .topic-list-item'), "has topics");
ok(!exists('.category-list'), "doesn't render subcategories");
ok($('body.category-bug').length, "has a custom css class for the category id on the body");
assert.ok(exists(".topic-list"), "The list of topics was rendered");
assert.ok(exists('.topic-list .topic-list-item'), "has topics");
assert.ok(!exists('.category-list'), "doesn't render subcategories");
assert.ok($('body.category-bug').length, "has a custom css class for the category id on the body");
});
visit("/categories");
andThen(() => {
ok($('body.navigation-categories').length, "has the body class");
ok($('body.category-bug').length === 0, "removes the custom category class");
ok(exists('.category'), "has a list of categories");
ok($('body.categories-list').length, "has a custom class to indicate categories");
assert.ok($('body.navigation-categories').length, "has the body class");
assert.ok($('body.category-bug').length === 0, "removes the custom category class");
assert.ok(exists('.category'), "has a list of categories");
assert.ok($('body.categories-list').length, "has a custom class to indicate categories");
});
visit("/top");
andThen(() => {
ok($('body.categories-list').length === 0, "removes the `categories-list` class");
ok(exists('.topic-list .topic-list-item'), "has topics");
assert.ok($('body.categories-list').length === 0, "removes the `categories-list` class");
assert.ok(exists('.topic-list .topic-list-item'), "has topics");
});
visit("/c/feature");
andThen(() => {
ok(exists(".topic-list"), "The list of topics was rendered");
ok(exists(".category-boxes"), "The list of subcategories were rendered with box style");
assert.ok(exists(".topic-list"), "The list of topics was rendered");
assert.ok(exists(".category-boxes"), "The list of subcategories were rendered with box style");
});
visit("/c/dev");
andThen(() => {
ok(exists(".topic-list"), "The list of topics was rendered");
ok(exists(".category-boxes-with-topics"), "The list of subcategories were rendered with box-with-featured-topics style");
ok(exists(".category-boxes-with-topics .featured-topics"), "The featured topics are there too");
assert.ok(exists(".topic-list"), "The list of topics was rendered");
assert.ok(exists(".category-boxes-with-topics"), "The list of subcategories were rendered with box-with-featured-topics style");
assert.ok(exists(".category-boxes-with-topics .featured-topics"), "The featured topics are there too");
});
});
});

View File

@@ -1,7 +1,7 @@
import { acceptance } from "helpers/qunit-helpers";
acceptance("Topic Notifications button", {
loggedIn: true,
setup() {
beforeEach() {
const response = object => {
return [
200,
@@ -16,13 +16,13 @@ acceptance("Topic Notifications button", {
}
});
test("Updating topic notification level", () => {
QUnit.test("Updating topic notification level", assert => {
visit("/t/internationalization-localization/280");
const notificationOptions = "#topic-footer-buttons .notification-options";
andThen(() => {
ok(
assert.ok(
exists(`${notificationOptions} .tracking`),
"it should display the notification options button in the topic's footer"
);
@@ -32,7 +32,7 @@ test("Updating topic notification level", () => {
click(`${notificationOptions} .dropdown-menu .watching`);
andThen(() => {
ok(
assert.ok(
exists(`${notificationOptions} .watching`),
"it should display the right notification level"
);
@@ -44,4 +44,4 @@ test("Updating topic notification level", () => {
// 'it should display the right notification level in topic timeline'
// );
});
});
});

View File

@@ -1,20 +1,20 @@
import { acceptance } from "helpers/qunit-helpers";
acceptance("Topic", { loggedIn: true });
test("Share Popup", () => {
QUnit.test("Share Popup", assert => {
visit("/t/internationalization-localization/280");
andThen(() => {
ok(!exists('#share-link.visible'), 'it is not visible');
assert.ok(!exists('#share-link.visible'), 'it is not visible');
});
click("button[data-share-url]");
andThen(() => {
ok(exists('#share-link.visible'), 'it shows the popup');
assert.ok(exists('#share-link.visible'), 'it shows the popup');
});
click('#share-link .close-share');
andThen(() => {
ok(!exists('#share-link.visible'), 'it closes the popup');
assert.ok(!exists('#share-link.visible'), 'it closes the popup');
});
// TODO tgxworld This fails on Travis but we need to push the security fix out
@@ -30,23 +30,23 @@ test("Share Popup", () => {
// });
});
test("Showing and hiding the edit controls", () => {
QUnit.test("Showing and hiding the edit controls", assert => {
visit("/t/internationalization-localization/280");
click('#topic-title .fa-pencil');
andThen(() => {
ok(exists('#edit-title'), 'it shows the editing controls');
assert.ok(exists('#edit-title'), 'it shows the editing controls');
});
fillIn('#edit-title', 'this is the new title');
click('#topic-title .cancel-edit');
andThen(() => {
ok(!exists('#edit-title'), 'it hides the editing controls');
assert.ok(!exists('#edit-title'), 'it hides the editing controls');
});
});
test("Updating the topic title and category", () => {
QUnit.test("Updating the topic title and category", assert => {
visit("/t/internationalization-localization/280");
click('#topic-title .fa-pencil');
@@ -56,12 +56,12 @@ test("Updating the topic title and category", () => {
click('#topic-title .submit-edit');
andThen(() => {
equal(find('#topic-title .badge-category').text(), 'faq', 'it displays the new category');
equal(find('.fancy-title').text().trim(), 'this is the new title', 'it displays the new title');
assert.equal(find('#topic-title .badge-category').text(), 'faq', 'it displays the new category');
assert.equal(find('.fancy-title').text().trim(), 'this is the new title', 'it displays the new title');
});
});
test("Marking a topic as wiki", () => {
QUnit.test("Marking a topic as wiki", assert => {
server.put('/posts/398/wiki', () => { // eslint-disable-line no-undef
return [
200,
@@ -73,7 +73,7 @@ test("Marking a topic as wiki", () => {
visit("/t/internationalization-localization/280");
andThen(() => {
ok(find('a.wiki').length === 0, 'it does not show the wiki icon');
assert.ok(find('a.wiki').length === 0, 'it does not show the wiki icon');
});
click('.topic-post:eq(0) button.show-more-actions');
@@ -81,39 +81,39 @@ test("Marking a topic as wiki", () => {
click('.btn.wiki');
andThen(() => {
ok(find('a.wiki').length === 1, 'it shows the wiki icon');
assert.ok(find('a.wiki').length === 1, 'it shows the wiki icon');
});
});
test("Reply as new topic", () => {
QUnit.test("Reply as new topic", assert => {
visit("/t/internationalization-localization/280");
click("button.share:eq(0)");
click(".reply-as-new-topic a");
andThen(() => {
ok(exists('.d-editor-input'), 'the composer input is visible');
assert.ok(exists('.d-editor-input'), 'the composer input is visible');
equal(
assert.equal(
find('.d-editor-input').val().trim(),
`Continuing the discussion from [Internationalization / localization](${window.location.origin}/t/internationalization-localization/280):`,
"it fills composer with the ring string"
);
equal(
assert.equal(
find('.category-combobox').select2('data').text, "feature",
"it fills category selector with the right category"
);
});
});
test("Reply as new message", () => {
QUnit.test("Reply as new message", assert => {
visit("/t/pm-for-testing/12");
click("button.share:eq(0)");
click(".reply-as-new-topic a");
andThen(() => {
ok(exists('.d-editor-input'), 'the composer input is visible');
assert.ok(exists('.d-editor-input'), 'the composer input is visible');
equal(
assert.equal(
find('.d-editor-input').val().trim(),
`Continuing the discussion from [PM for testing](${window.location.origin}/t/pm-for-testing/12):`,
"it fills composer with the ring string"
@@ -121,24 +121,24 @@ test("Reply as new message", () => {
const targets = find('.item span', '.composer-fields');
equal(
assert.equal(
$(targets[0]).text(), "someguy",
"it fills up the composer with the right user to start the PM to"
);
equal(
assert.equal(
$(targets[1]).text(), "test",
"it fills up the composer with the right user to start the PM to"
);
equal(
assert.equal(
$(targets[2]).text(), "Group",
"it fills up the composer with the right group to start the PM to"
);
});
});
test("Updating the topic title with emojis", () => {
QUnit.test("Updating the topic title with emojis", assert => {
visit("/t/internationalization-localization/280");
click('#topic-title .fa-pencil');
@@ -147,6 +147,6 @@ test("Updating the topic title with emojis", () => {
click('#topic-title .submit-edit');
andThen(() => {
equal(find('.fancy-title').html().trim(), 'emojis title <img src=\"/images/emoji/emoji_one/bike.png?v=5\" title=\"bike\" alt=\"bike\" class=\"emoji\"> <img src=\"/images/emoji/emoji_one/blonde_woman/6.png?v=5\" title=\"blonde_woman:t6\" alt=\"blonde_woman:t6\" class=\"emoji\">', 'it displays the new title with emojis');
assert.equal(find('.fancy-title').html().trim(), 'emojis title <img src=\"/images/emoji/emoji_one/bike.png?v=5\" title=\"bike\" alt=\"bike\" class=\"emoji\"> <img src=\"/images/emoji/emoji_one/blonde_woman/6.png?v=5\" title=\"blonde_woman:t6\" alt=\"blonde_woman:t6\" class=\"emoji\">', 'it displays the new title with emojis');
});
});
});

View File

@@ -1,10 +1,10 @@
import { acceptance } from "helpers/qunit-helpers";
acceptance("Unknown");
test("Unknown URL", () => {
expect(1);
QUnit.test("Unknown URL", assert => {
assert.expect(1);
visit("/url-that-doesn't-exist");
andThen(() => {
ok(exists(".page-not-found"), "The not found content is present");
assert.ok(exists(".page-not-found"), "The not found content is present");
});
});

View File

@@ -1,54 +1,54 @@
import { acceptance } from "helpers/qunit-helpers";
acceptance("User Anonymous");
export function hasStream() {
function hasStream(assert) {
andThen(() => {
ok(exists('.user-main .about'), 'it has the about section');
ok(count('.user-stream .item') > 0, 'it has stream items');
assert.ok(exists('.user-main .about'), 'it has the about section');
assert.ok(count('.user-stream .item') > 0, 'it has stream items');
});
}
function hasTopicList() {
function hasTopicList(assert) {
andThen(() => {
equal(count('.user-stream .item'), 0, "has no stream displayed");
ok(count('.topic-list tr') > 0, 'it has a topic list');
assert.equal(count('.user-stream .item'), 0, "has no stream displayed");
assert.ok(count('.topic-list tr') > 0, 'it has a topic list');
});
}
test("Root URL", () => {
QUnit.test("Root URL", assert => {
visit("/u/eviltrout");
andThen(() => {
ok($('body.user-summary-page').length, "has the body class");
equal(currentPath(), 'user.summary', "it defaults to summary");
assert.ok($('body.user-summary-page').length, "has the body class");
assert.equal(currentPath(), 'user.summary', "it defaults to summary");
});
});
test("Filters", () => {
QUnit.test("Filters", assert => {
visit("/u/eviltrout/activity");
andThen(() => {
ok($('body.user-activity-page').length, "has the body class");
assert.ok($('body.user-activity-page').length, "has the body class");
});
hasStream();
hasStream(assert);
visit("/u/eviltrout/activity/topics");
hasTopicList();
hasTopicList(assert);
visit("/u/eviltrout/activity/replies");
hasStream();
hasStream(assert);
});
test("Badges", () => {
QUnit.test("Badges", assert => {
visit("/u/eviltrout/badges");
andThen(() => {
ok($('body.user-badges-page').length, "has the body class");
ok(exists(".user-badges-list .badge-card"), "shows a badge");
assert.ok($('body.user-badges-page').length, "has the body class");
assert.ok(exists(".user-badges-list .badge-card"), "shows a badge");
});
});
test("Restricted Routes", () => {
QUnit.test("Restricted Routes", assert => {
visit("/u/eviltrout/preferences");
andThen(() => {
equal(currentURL(), '/u/eviltrout/activity', "it redirects from preferences");
assert.equal(currentURL(), '/u/eviltrout/activity', "it redirects from preferences");
});
});

View File

@@ -1,14 +1,14 @@
import { acceptance } from "helpers/qunit-helpers";
acceptance("User Card");
test("card", () => {
QUnit.test("card", assert => {
visit('/');
ok(invisible('#user-card'), 'user card is invisible by default');
assert.ok(invisible('#user-card'), 'user card is invisible by default');
click('a[data-user-card=eviltrout]:first');
andThen(() => {
ok(visible('#user-card'), 'card should appear');
assert.ok(visible('#user-card'), 'card should appear');
});
});
});

View File

@@ -2,32 +2,32 @@ import { acceptance } from "helpers/qunit-helpers";
acceptance("User", {loggedIn: true});
test("Invites", () => {
QUnit.test("Invites", assert => {
visit("/u/eviltrout/invited/pending");
andThen(() => {
ok($('body.user-invites-page').length, "has the body class");
assert.ok($('body.user-invites-page').length, "has the body class");
});
});
test("Messages", () => {
QUnit.test("Messages", assert => {
visit("/u/eviltrout/messages");
andThen(() => {
ok($('body.user-messages-page').length, "has the body class");
assert.ok($('body.user-messages-page').length, "has the body class");
});
});
test("Notifications", () => {
QUnit.test("Notifications", assert => {
visit("/u/eviltrout/notifications");
andThen(() => {
ok($('body.user-notifications-page').length, "has the body class");
assert.ok($('body.user-notifications-page').length, "has the body class");
});
});
test("Root URL - Viewing Self", () => {
QUnit.test("Root URL - Viewing Self", assert => {
visit("/u/eviltrout");
andThen(() => {
ok($('body.user-activity-page').length, "has the body class");
equal(currentPath(), 'user.userActivity.index', "it defaults to activity");
ok(exists('.container.viewing-self'), "has the viewing-self class");
assert.ok($('body.user-activity-page').length, "has the body class");
assert.equal(currentPath(), 'user.userActivity.index', "it defaults to activity");
assert.ok(exists('.container.viewing-self'), "has the viewing-self class");
});
});
});

View File

@@ -1,17 +1,17 @@
import { acceptance } from "helpers/qunit-helpers";
acceptance("User Directory");
test("Visit Page", function() {
QUnit.test("Visit Page", assert => {
visit("/users");
andThen(() => {
ok($('body.users-page').length, "has the body class");
ok(exists('.directory table tr'), "has a list of users");
assert.ok($('body.users-page').length, "has the body class");
assert.ok(exists('.directory table tr'), "has a list of users");
});
});
test("Visit All Time", function() {
QUnit.test("Visit All Time", assert => {
visit("/users?period=all");
andThen(() => {
ok(exists('.time-read'), "has time read column");
assert.ok(exists('.time-read'), "has time read column");
});
});
});