mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
TESTS: Use Pretender in test mode for more flexible server responses
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
integration("Header (Anonymous)");
|
||||
|
||||
test("header", function() {
|
||||
expect(14);
|
||||
|
||||
visit("/");
|
||||
andThen(function() {
|
||||
ok(exists("header"), "is rendered");
|
||||
|
||||
@@ -5,8 +5,6 @@ integration("Header (Staff)", {
|
||||
});
|
||||
|
||||
test("header", function() {
|
||||
expect(6);
|
||||
|
||||
visit("/");
|
||||
|
||||
// Notifications
|
||||
@@ -30,5 +28,4 @@ test("header", 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");
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -1,17 +1,61 @@
|
||||
integration("Signing In");
|
||||
|
||||
test("sign in with incorrect credentials", function() {
|
||||
test("sign in", 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
|
||||
// Test invalid password first
|
||||
fillIn('#login-account-name', 'eviltrout');
|
||||
fillIn('#login-account-password', 'incorrect');
|
||||
click('.modal-footer .btn-primary');
|
||||
andThen(function() {
|
||||
// ok(exists('#modal-alert:visible', 'it displays the login error'));
|
||||
ok(exists('#modal-alert:visible', 'it displays the login error'));
|
||||
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(function() {
|
||||
ok(exists('.modal-footer .btn-primary:disabled'), "disables the login button");
|
||||
});
|
||||
});
|
||||
|
||||
test("create account", function() {
|
||||
visit("/");
|
||||
click("header .login-button");
|
||||
click('#new-account-link');
|
||||
|
||||
andThen(function() {
|
||||
ok(exists('.create-account'), "it shows the create account modal");
|
||||
ok(exists('.modal-footer .btn-primary:disabled'), 'create account is disabled at first');
|
||||
});
|
||||
|
||||
fillIn('#new-account-name', 'Dr. Good Tuna');
|
||||
fillIn('#new-account-password', 'cool password bro');
|
||||
|
||||
// Check username
|
||||
fillIn('#new-account-email', 'good.tuna@test.com');
|
||||
fillIn('#new-account-username', 'taken');
|
||||
andThen(function() {
|
||||
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() {
|
||||
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() {
|
||||
not(exists('.modal-body'), 'it hides the body when finished');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user