From bf16ff275ab479f9877cf55524e8ed7040fd3c65 Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Thu, 31 Jul 2014 14:17:18 -0400 Subject: [PATCH] TESTS: Sign in tests --- test/javascripts/fixtures/session_fixtures.js | 2 ++ ...st.js.es6 => header-anonymous-test.js.es6} | 25 ++------------ .../integration/header-test-staff.js.es6 | 34 +++++++++++++++++++ .../integration/sign-in-test.js.es6 | 17 ++++++++++ test/javascripts/test_helper.js | 3 ++ test/stylesheets/test_helper.css | 3 ++ 6 files changed, 61 insertions(+), 23 deletions(-) create mode 100644 test/javascripts/fixtures/session_fixtures.js rename test/javascripts/integration/{header-test.js.es6 => header-anonymous-test.js.es6} (64%) create mode 100644 test/javascripts/integration/header-test-staff.js.es6 create mode 100644 test/javascripts/integration/sign-in-test.js.es6 diff --git a/test/javascripts/fixtures/session_fixtures.js b/test/javascripts/fixtures/session_fixtures.js new file mode 100644 index 00000000000..e7db28f8656 --- /dev/null +++ b/test/javascripts/fixtures/session_fixtures.js @@ -0,0 +1,2 @@ +/*jshint maxlen:10000000 */ +Discourse.URL_FIXTURES["/session"] = [ { error: "Incorrect username, email or password" } ]; diff --git a/test/javascripts/integration/header-test.js.es6 b/test/javascripts/integration/header-anonymous-test.js.es6 similarity index 64% rename from test/javascripts/integration/header-test.js.es6 rename to test/javascripts/integration/header-anonymous-test.js.es6 index 6bf962a072b..a8009c6e576 100644 --- a/test/javascripts/integration/header-test.js.es6 +++ b/test/javascripts/integration/header-anonymous-test.js.es6 @@ -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() { diff --git a/test/javascripts/integration/header-test-staff.js.es6 b/test/javascripts/integration/header-test-staff.js.es6 new file mode 100644 index 00000000000..c9caaef6225 --- /dev/null +++ b/test/javascripts/integration/header-test-staff.js.es6 @@ -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"); + }); + +}); diff --git a/test/javascripts/integration/sign-in-test.js.es6 b/test/javascripts/integration/sign-in-test.js.es6 new file mode 100644 index 00000000000..4e86b2ffcef --- /dev/null +++ b/test/javascripts/integration/sign-in-test.js.es6 @@ -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')); + }); +}); diff --git a/test/javascripts/test_helper.js b/test/javascripts/test_helper.js index 1e6104de933..830d4417a61 100644 --- a/test/javascripts/test_helper.js +++ b/test/javascripts/test_helper.js @@ -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 diff --git a/test/stylesheets/test_helper.css b/test/stylesheets/test_helper.css index ecc7a46d825..c0d5f7f11ec 100644 --- a/test/stylesheets/test_helper.css +++ b/test/stylesheets/test_helper.css @@ -2,3 +2,6 @@ *= require desktop *= require_tree . */ +.modal-backdrop { + display: none; +}