From 42a88bb4419b2efe5e0b77dffd65010099b7dd45 Mon Sep 17 00:00:00 2001 From: zinyando Date: Fri, 1 Jul 2016 18:06:31 +0200 Subject: [PATCH] Add and use authenticateUser session helper --- app/tests/helpers/authenticate-user.js | 38 ++++++++++++++++++++++ app/tests/helpers/module-for-acceptance.js | 1 - app/tests/helpers/start-app.js | 1 + 3 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 app/tests/helpers/authenticate-user.js diff --git a/app/tests/helpers/authenticate-user.js b/app/tests/helpers/authenticate-user.js new file mode 100644 index 00000000..6b859266 --- /dev/null +++ b/app/tests/helpers/authenticate-user.js @@ -0,0 +1,38 @@ +import Ember from 'ember'; +import { authenticateSession } from 'documize/tests/helpers/ember-simple-auth'; + +const { + merge +} = Ember; + +export default Ember.Test.registerAsyncHelper('authenticateUser', function(app, attrs = {}) { + authenticateSession(app, merge({ + token: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJkb21haW4iOiIiLCJleHAiOjE0NjQwMjM2NjcsImlzcyI6IkRvY3VtaXplIiwib3JnIjoiVnpNdXlFd18zV3FpYWZjRCIsInN1YiI6IndlYmFwcCIsInVzZXIiOiJWek11eUV3XzNXcWlhZmNFIn0.NXZ6bo8mtvdZF_b9HavbidVUJqhmBA1zr0fSAPvbah0", + user: { + "id": "VzMuyEw_3WqiafcE", + "created": "2016-05-11T15:08:24Z", + "revised": "2016-05-11T15:08:24Z", + "firstname": "Lennex", + "lastname": "Zinyando", + "email": "brizdigital@gmail.com", + "initials": "LZ", + "active": true, + "editor": true, + "admin": true, + "accounts": [{ + "id": "VzMuyEw_3WqiafcF", + "created": "2016-05-11T15:08:24Z", + "revised": "2016-05-11T15:08:24Z", + "admin": true, + "editor": true, + "userId": "VzMuyEw_3WqiafcE", + "orgId": "VzMuyEw_3WqiafcD", + "company": "EmberSherpa", + "title": "EmberSherpa", + "message": "This Documize instance contains all our team documentation", + "domain": "" + }] + } + }, attrs) + ); +}); diff --git a/app/tests/helpers/module-for-acceptance.js b/app/tests/helpers/module-for-acceptance.js index 6d6818e0..f532ceec 100644 --- a/app/tests/helpers/module-for-acceptance.js +++ b/app/tests/helpers/module-for-acceptance.js @@ -7,7 +7,6 @@ export default function(name, options = {}) { beforeEach() { this.application = startApp(); stubAudit(this); - stubSession(this); stubUserNotification(this); if (options.beforeEach) { diff --git a/app/tests/helpers/start-app.js b/app/tests/helpers/start-app.js index 024b70d1..f3ec7b64 100644 --- a/app/tests/helpers/start-app.js +++ b/app/tests/helpers/start-app.js @@ -7,6 +7,7 @@ import './user-login'; import './wait-to-appear'; import './wait-to-disappear'; import './stub-user-notification'; +import './authenticate-user'; export default function startApp(attrs) { let application;