TESTS: Sign in tests

This commit is contained in:
Robin Ward 2014-07-31 14:17:18 -04:00
parent c5b5db48cf
commit bf16ff275a
6 changed files with 61 additions and 23 deletions

View file

@ -0,0 +1,2 @@
/*jshint maxlen:10000000 */
Discourse.URL_FIXTURES["/session"] = [ { error: "Incorrect username, email or password" } ];

View file

@ -1,11 +1,7 @@
integration("Header as Staff", {
user: { username: 'test',
staff: true,
site_flagged_posts_count: 1 }
});
integration("Header (Anonymous)");
test("header", function() {
expect(20);
expect(14);
visit("/");
andThen(function() {
@ -26,31 +22,14 @@ test("header", function() {
ok(exists(".logo-small"), "it shows the small logo when `showExtraInfo` is enabled");
});
// Notifications
click("#user-notifications");
andThen(function() {
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");
});
// Site Map
click("#site-map");
andThen(function() {
ok(exists('#site-map-dropdown'), "is rendered after user opens it");
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");
ok(exists("#site-map-dropdown .faq-link"), "it shows the faq link");
ok(exists("#site-map-dropdown .category-links"), "has categories correctly bound");
});
// User dropdown
click("#current-user");
andThen(function() {
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");
});
// Search
click("#search-button");
andThen(function() {

View file

@ -0,0 +1,34 @@
integration("Header (Staff)", {
user: { username: 'test',
staff: true,
site_flagged_posts_count: 1 }
});
test("header", function() {
expect(6);
visit("/");
// Notifications
click("#user-notifications");
andThen(function() {
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");
});
// Site Map
click("#site-map");
andThen(function() {
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() {
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");
});
});

View file

@ -0,0 +1,17 @@
integration("Signing In");
test("sign in with incorrect credentials", function() {
visit("/");
click("header .login-button");
andThen(function() {
ok(exists('.login-modal'), "it shows the login modal");
});
fillIn('#login-account-name', 'eviltrout');
fillIn('#login-account-password', 'where da plankton at?');
// The fixture is set to invalid login
click('.modal-footer .btn-primary');
andThen(function() {
// ok(exists('#modal-alert:visible', 'it displays the login error'));
});
});

View file

@ -115,6 +115,9 @@ QUnit.testStart(function(ctx) {
QUnit.testDone(function() {
Ember.run.debounce = origDebounce;
window.sandbox.restore();
// Destroy any modals
$('.modal-backdrop').remove();
});
// Load ES6 tests

View file

@ -2,3 +2,6 @@
*= require desktop
*= require_tree .
*/
.modal-backdrop {
display: none;
}