From 50d4f02388c429eef2a47c06d7cb5f342d43b7d6 Mon Sep 17 00:00:00 2001 From: Fabian Becker Date: Wed, 15 Jul 2015 11:33:53 +0200 Subject: [PATCH] Fix signin test (run setup properly) fixes #5536 --- core/test/functional/base.js | 18 +++++++++--------- core/test/functional/client/signin_test.js | 1 - core/test/functional/setup/setup_test.js | 4 ++-- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/core/test/functional/base.js b/core/test/functional/base.js index bfb77efb5b..5129912e69 100644 --- a/core/test/functional/base.js +++ b/core/test/functional/base.js @@ -347,23 +347,23 @@ CasperTest = (function () { }); // Wrapper around `casper.test.begin` - function begin(testName, expect, suite, doNotAutoLogin) { + function begin(testName, expect, suite, doNotAutoLogin, doNotRunSetup) { _beforeDoneHandler = _noop; var runTest = function (test) { test.filename = testName.toLowerCase().replace(/ /g, '-').concat('.png'); casper.start('about:blank').viewport(1280, 1024); + // Only call register once for the lifetime of CasperTest + if (!_isUserRegistered && !doNotRunSetup) { + CasperTest.Routines.signout.run(); + CasperTest.Routines.setup.run(); + CasperTest.Routines.signout.run(); + + _isUserRegistered = true; + } if (!doNotAutoLogin) { - // Only call register once for the lifetime of CasperTest - if (!_isUserRegistered) { - CasperTest.Routines.signout.run(); - CasperTest.Routines.setup.run(); - - _isUserRegistered = true; - } - /* Ensure we're logged out at the start of every test or we may get unexpected failures. */ CasperTest.Routines.signout.run(); diff --git a/core/test/functional/client/signin_test.js b/core/test/functional/client/signin_test.js index 0883b9c57e..a5154cd5f9 100644 --- a/core/test/functional/client/signin_test.js +++ b/core/test/functional/client/signin_test.js @@ -22,7 +22,6 @@ CasperTest.begin('Ghost admin will load login page', 4, function suite(test) { }, true); // Note, this test applies to a global redirect, which sends us to the standard admin. -// Once Ember becomes the standard admin, this test should still pass. CasperTest.begin('Redirects login to signin', 2, function suite(test) { CasperTest.Routines.signout.run(test); casper.start(url + 'ghost/login/', function testRedirect(response) { diff --git a/core/test/functional/setup/setup_test.js b/core/test/functional/setup/setup_test.js index ada7609ba7..20366b1314 100644 --- a/core/test/functional/setup/setup_test.js +++ b/core/test/functional/setup/setup_test.js @@ -64,7 +64,7 @@ CasperTest.begin('Ghost setup fails properly', 10, function suite(test) { }, function onTimeout() { test.assert(false, 'No error notification after invite.'); }); -}, true); +}, true, true); CasperTest.begin('Authenticated user is redirected', 6, function suite(test) { casper.thenOpenAndWaitForPageLoad('signin', function testTitleAndUrl() { @@ -91,4 +91,4 @@ CasperTest.begin('Authenticated user is redirected', 6, function suite(test) { }, function onTimeOut() { test.fail('Failed to redirect'); }); -}, true); +}, true, true);