From 5a4dc1534fc81aa4ed0866e7e61e5f1898684b8e Mon Sep 17 00:00:00 2001 From: zinyando Date: Thu, 19 May 2016 17:32:58 +0200 Subject: [PATCH] Initial auth tests and tests for allowAnonymousAccess --- app/tests/acceptance/authentication-test.js | 26 ++++++++++++++ app/tests/acceptance/index-test.js | 38 +++++++++++++-------- 2 files changed, 49 insertions(+), 15 deletions(-) create mode 100644 app/tests/acceptance/authentication-test.js diff --git a/app/tests/acceptance/authentication-test.js b/app/tests/acceptance/authentication-test.js new file mode 100644 index 00000000..0f778fba --- /dev/null +++ b/app/tests/acceptance/authentication-test.js @@ -0,0 +1,26 @@ +import { test } from 'qunit'; +import moduleForAcceptance from 'documize/tests/helpers/module-for-acceptance'; + +moduleForAcceptance('Acceptance | authentication'); + +test('visiting /auth/login and logging in', function(assert) { + visit('/auth/login'); + + fillIn('#authEmail', 'brizdigital@gmail.com'); + fillIn('#authPassword', 'zinyando123'); + click('button'); + + andThen(function() { + assert.equal(currentURL(), '/s/VzMuyEw_3WqiafcG/my-project'); + }); +}); + +test('logging out a user', function(assert) { + userLogin(); + + visit('/auth/logout'); // logs a user out + + andThen(function() { + assert.equal(currentURL(), '/'); + }); +}); diff --git a/app/tests/acceptance/index-test.js b/app/tests/acceptance/index-test.js index 9a587756..1a7565fa 100644 --- a/app/tests/acceptance/index-test.js +++ b/app/tests/acceptance/index-test.js @@ -1,21 +1,29 @@ -import { test } from 'qunit'; +import { test, skip } from 'qunit'; import moduleForAcceptance from 'documize/tests/helpers/module-for-acceptance'; +// import stubSession from '../helpers/stub-session'; moduleForAcceptance('Acceptance | /'); -// TODO: when accessing / with /api/public/meta -> { allowAnonymousAccess: false } then take user to login -// TODO: when accessing / with /api/public/meta -> { allowAnonymousAccess: true } then take user to folers.index -// TODO: when accessing / with /api/public/meta -> { allowAnonymousAccess: true } and user is authenticated -> show authenticated user information +skip('visiting / when not authenticated and with { allowAnonymousAccess: false } takes user to login', function(assert) { + visit('/'); -test('visiting /', function(assert) { - visit('/'); - - return pauseTest(); - - // setup mirage for /api/public/meta -> { allowAnonymousAccess: false} - - - andThen(function() { - assert.equal(currentURL(), '/auth/login'); - }); + andThen(function() { + assert.equal(currentURL(), '/auth/login'); + }); +}); + +skip('visiting / when not authenticated and with { allowAnonymousAccess: true } takes user to folder view', function(assert) { + visit('/'); + + andThen(function() { + assert.equal(currentURL(), '/s/VzMuyEw_3WqiafcG/my-project'); + }); +}); + +skip('visiting / when authenticated and with { allowAnonymousAccess: true } takes user to dashboard', function(assert) { + userLogin(); + + andThen(function() { + assert.equal(currentURL(), '/s/VzMuyEw_3WqiafcG/my-project'); + }); });