FIX: editing a post wasn't showing error messages from the server

This commit is contained in:
Régis Hanol
2015-03-19 12:22:56 +01:00
parent b071bd3c7c
commit df3b1f6968
21 changed files with 113 additions and 117 deletions
@@ -1,8 +1,8 @@
integration("About");
test("viewing", function() {
test("viewing", () => {
visit("/about");
andThen(function() {
andThen(() => {
ok(exists('.about.admins .user-small'), 'has admins');
ok(exists('.about.moderators .user-small'), 'has moderators');
ok(exists('.about.stats tr td'), 'has stats');
@@ -1,13 +1,13 @@
integration("Badges");
test("Visit Badge Pages", function() {
test("Visit Badge Pages", () => {
visit("/badges");
andThen(function() {
andThen(() => {
ok(exists('.badges-listing tr'), "has a list of badges");
});
visit("/badges/9/autobiographer");
andThen(function() {
andThen(() => {
ok(exists('.badges-listing tr'), "has the badge in the listing");
ok(exists('.badge-user'), "has the list of users with that badge");
});
@@ -8,11 +8,11 @@ integration("Create Account - User Fields", {
}
});
test("create account with user fields", function() {
test("create account with user fields", () => {
visit("/");
click("header .sign-up-button");
andThen(function() {
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');
@@ -23,24 +23,24 @@ test("create account with user fields", function() {
fillIn('#new-account-email', 'good.tuna@test.com');
fillIn('#new-account-username', 'goodtuna');
andThen(function() {
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');
});
fillIn(".user-field input[type=text]:first", "Barky");
andThen(function() {
andThen(() => {
ok(exists('.modal-footer .btn-primary:disabled'), 'create account is disabled because field is not checked');
});
click(".user-field input[type=checkbox]");
andThen(function() {
andThen(() => {
not(exists('.modal-footer .btn-primary:disabled'), 'create account is enabled because field is not checked');
});
click(".user-field input[type=checkbox]");
andThen(function() {
andThen(() => {
ok(exists('.modal-footer .btn-primary:disabled'), 'unclicking the checkbox disables the submit');
});
@@ -1,8 +1,8 @@
integration("User Directory");
test("Visit Page", function() {
test("Visit Page", () => {
visit("/directory/all");
andThen(function() {
andThen(() => {
ok(exists('.directory table tr'), "has a list of users");
});
});
@@ -1,12 +1,13 @@
integration("Groups");
test("Browsing Groups", function() {
test("Browsing Groups", () => {
visit("/groups/discourse");
andThen(function() {
andThen(() => {
ok(count('.user-stream .item') > 0, "it has stream items");
});
visit("/groups/discourse/members");
andThen(function() {
andThen(() => {
ok(count('.group-members tr') > 0, "it lists group members");
});
});
@@ -1,8 +1,8 @@
integration("Header (Anonymous)");
test("header", function() {
test("header", () => {
visit("/");
andThen(function() {
andThen(() => {
ok(exists("header"), "is rendered");
ok(exists(".logo-big"), "it renders the large logo by default");
not(exists("#notifications-dropdown li"), "no notifications at first");
@@ -12,17 +12,17 @@ test("header", function() {
});
// Logo changing
andThen(function() {
andThen(() => {
controllerFor('header').set("showExtraInfo", true);
});
andThen(function() {
andThen(() => {
ok(exists(".logo-small"), "it shows the small logo when `showExtraInfo` is enabled");
});
// Site Map
click("#site-map");
andThen(function() {
andThen(() => {
ok(exists('#site-map-dropdown'), "is rendered after user opens it");
ok(exists("#site-map-dropdown .faq-link"), "it shows the faq link");
ok(exists("#site-map-dropdown .category-links"), "has categories correctly bound");
@@ -30,14 +30,14 @@ test("header", function() {
// Search
click("#search-button");
andThen(function() {
andThen(() => {
ok(exists("#search-dropdown:visible"), "after clicking a button search box opens");
not(exists("#search-dropdown .heading"), "initially, immediately after opening, search box is empty");
});
// Perform Search
fillIn("#search-term", "hello");
andThen(function() {
andThen(() => {
ok(exists("#search-dropdown .heading"), "when user completes a search, search box shows search results");
equal(find("#search-dropdown .results a:first").attr("href"), "/t/hello-bar-integration-issues/17638", "there is a search result");
});
@@ -4,12 +4,12 @@ integration("Header (Staff)", {
site_flagged_posts_count: 1 }
});
test("header", function() {
test("header", () => {
visit("/");
// Notifications
click("#user-notifications");
andThen(function() {
andThen(() => {
var $items = $("#notifications-dropdown li");
ok(exists($items), "is lazily populated after user opens it");
ok($items.first().hasClass("read"), "correctly binds items' 'read' class");
@@ -17,14 +17,14 @@ test("header", function() {
// Site Map
click("#site-map");
andThen(function() {
andThen(() => {
ok(exists("#site-map-dropdown .admin-link"), "it has the admin link");
ok(exists("#site-map-dropdown .flagged-posts.badge-notification"), "it displays flag notifications");
});
// User dropdown
click("#current-user");
andThen(function() {
andThen(() => {
ok(exists("#user-dropdown:visible"), "is lazily rendered after user opens it");
ok(exists("#user-dropdown .user-dropdown-links"), "has showing / hiding user-dropdown links correctly bound");
});
@@ -4,39 +4,39 @@ integration("Login Required", {
}
});
test("redirect", function() {
test("redirect", () => {
visit('/latest');
andThen(function() {
andThen(() => {
equal(currentPath(), "login", "it redirects them to login");
});
click('#site-logo');
andThen(function() {
andThen(() => {
equal(currentPath(), "login", "clicking the logo keeps them on login");
});
click('header .login-button');
andThen(function() {
andThen(() => {
ok(exists('.login-modal'), "they can still access the login modal");
});
click('.modal-header .close');
andThen(function() {
andThen(() => {
ok(!exists('.login-modal'), "it closes the login modal");
});
click('#search-button');
andThen(function() {
andThen(() => {
ok(exists('.login-modal'), "clicking search opens the login modal");
});
click('.modal-header .close');
andThen(function() {
andThen(() => {
ok(!exists('.login-modal'), "it closes the login modal");
});
click('#site-map');
andThen(function() {
andThen(() => {
ok(exists('.login-modal'), "site map opens the login modal");
});
});
@@ -1,29 +1,29 @@
integration("Modal");
test("modal", function() {
test("modal", () => {
visit('/');
andThen(function() {
andThen(() => {
ok(find('#discourse-modal:visible').length === 0, 'there is no modal at first');
});
click('.login-button');
andThen(function() {
andThen(() => {
ok(find('#discourse-modal:visible').length === 1, 'modal should appear');
});
click('.modal-outer-container');
andThen(function() {
andThen(() => {
ok(find('#discourse-modal:visible').length === 0, 'modal should disappear when you click outside');
});
click('.login-button');
andThen(function() {
andThen(() => {
ok(find('#discourse-modal:visible').length === 1, 'modal should reappear');
});
keyEvent('#main-outlet', 'keyup', 27);
andThen(function() {
andThen(() => {
ok(find('#discourse-modal:visible').length === 0, 'ESC should close the modal');
});
});
@@ -1,9 +1,9 @@
integration("Signing In");
test("sign in", function() {
test("sign in", () => {
visit("/");
click("header .login-button");
andThen(function() {
andThen(() => {
ok(exists('.login-modal'), "it shows the login modal");
});
@@ -11,7 +11,7 @@ test("sign in", function() {
fillIn('#login-account-name', 'eviltrout');
fillIn('#login-account-password', 'incorrect');
click('.modal-footer .btn-primary');
andThen(function() {
andThen(() => {
ok(exists('#modal-alert:visible', 'it displays the login error'));
not(exists('.modal-footer .btn-primary:disabled'), "enables the login button");
});
@@ -19,16 +19,16 @@ test("sign in", function() {
// Use the correct password
fillIn('#login-account-password', 'correct');
click('.modal-footer .btn-primary');
andThen(function() {
andThen(() => {
ok(exists('.modal-footer .btn-primary:disabled'), "disables the login button");
});
});
test("create account", function() {
test("create account", () => {
visit("/");
click("header .sign-up-button");
andThen(function() {
andThen(() => {
ok(exists('.create-account'), "it shows the create account modal");
ok(exists('.modal-footer .btn-primary:disabled'), 'create account is disabled at first');
});
@@ -39,19 +39,19 @@ test("create account", function() {
// Check username
fillIn('#new-account-email', 'good.tuna@test.com');
fillIn('#new-account-username', 'taken');
andThen(function() {
andThen(() => {
ok(exists('#username-validation.bad'), 'the username validation is bad');
ok(exists('.modal-footer .btn-primary:disabled'), 'create account is still disabled');
});
fillIn('#new-account-username', 'goodtuna');
andThen(function() {
andThen(() => {
ok(exists('#username-validation.good'), 'the username validation is good');
not(exists('.modal-footer .btn-primary:disabled'), 'create account is enabled');
});
click('.modal-footer .btn-primary');
andThen(function() {
andThen(() => {
ok(exists('.modal-footer .btn-primary:disabled'), "create account is disabled");
});
@@ -1,28 +1,28 @@
integration("Static");
test("Static Pages", function() {
test("Static Pages", () => {
visit("/faq");
andThen(function() {
andThen(() => {
ok(exists(".body-page"), "The content is present");
});
visit("/guidelines");
andThen(function() {
andThen(() => {
ok(exists(".body-page"), "The content is present");
});
visit("/tos");
andThen(function() {
andThen(() => {
ok(exists(".body-page"), "The content is present");
});
visit("/privacy");
andThen(function() {
andThen(() => {
ok(exists(".body-page"), "The content is present");
});
visit("/login");
andThen(function() {
andThen(() => {
equal(currentPath(), "discovery.latest", "it redirects them to latest unless `login_required`");
});
});
@@ -1,21 +1,21 @@
integration("Topic Discovery");
test("Visit Discovery Pages", function() {
test("Visit Discovery Pages", () => {
visit("/");
andThen(function() {
andThen(() => {
ok(exists(".topic-list"), "The list of topics was rendered");
ok(exists('.topic-list .topic-list-item'), "has topics");
});
visit("/c/bug");
andThen(function() {
andThen(() => {
ok(exists(".topic-list"), "The list of topics was rendered");
ok(exists('.topic-list .topic-list-item'), "has topics");
ok($('body.category-bug').length, "has a custom css class for the category id on the body");
});
visit("/categories");
andThen(function() {
andThen(() => {
ok($('body.category-bug').length === 0, "removes the custom category class");
ok(exists('.category'), "has a list of categories");
@@ -23,7 +23,7 @@ test("Visit Discovery Pages", function() {
});
visit("/top");
andThen(function() {
andThen(() => {
ok($('body.categories-list').length === 0, "removes the `categories-list` class");
ok(exists('.topic-list .topic-list-item'), "has topics");
});
@@ -1,16 +1,16 @@
integration("View Topic");
test("Enter a Topic", function() {
test("Enter a Topic", () => {
visit("/t/internationalization-localization/280");
andThen(function() {
andThen(() => {
ok(exists("#topic"), "The topic was rendered");
ok(exists("#topic .post-cloak"), "The topic has cloaked posts");
});
});
test("Enter without an id", function() {
test("Enter without an id", () => {
visit("/t/internationalization-localization");
andThen(function() {
andThen(() => {
ok(exists("#topic"), "The topic was rendered");
});
});
@@ -1,9 +1,9 @@
integration("Unknown");
test("Unknown URL", function() {
test("Unknown URL", () => {
expect(1);
visit("/url-that-doesn't-exist");
andThen(function() {
andThen(() => {
ok(exists(".page-not-found"), "The not found content is present");
});
});
@@ -1,12 +1,12 @@
integration("User Card");
test("card", function() {
test("card", () => {
visit('/');
ok(invisible('#user-card'), 'user card is invisible by default');
click('a[data-user-card=eviltrout]:first');
andThen(function() {
andThen(() => {
ok(visible('#user-card'), 'card should appear');
});
@@ -1,34 +1,40 @@
integration("User");
function hasStream() {
andThen(function() {
andThen(() => {
ok(exists('.user-main .about'), 'it has the about section');
ok(count('.user-stream .item') > 0, 'it has stream items');
});
}
function hasTopicList() {
andThen(function() {
andThen(() => {
equal(count('.user-stream .item'), 0, "has no stream displayed");
ok(count('.topic-list tr') > 0, 'it has a topic list');
});
}
test("Filters", function() {
test("Filters", () => {
expect(14);
visit("/users/eviltrout");
hasStream();
visit("/users/eviltrout/activity/topics");
hasTopicList();
visit("/users/eviltrout/activity/posts");
hasStream();
visit("/users/eviltrout/activity/replies");
hasStream();
visit("/users/eviltrout/activity/likes-given");
hasStream();
visit("/users/eviltrout/activity/likes-received");
hasStream();
visit("/users/eviltrout/activity/edits");
hasStream();
});