diff --git a/mirage/config.js b/mirage/config.js index 8e114f1e02e6bea6218c1840e93e3cc984154cb1..cefb723fa74e4f0acd2dd32d2a7dcd72e37090fd 100644 --- a/mirage/config.js +++ b/mirage/config.js @@ -103,4 +103,106 @@ export default function() { } }); + this.get('/api/nodes/1/', () => { + return { + "data": [ + { + "type": "folders", + "id":"4", + "attributes": { + "title": "Folder 1", + "created_at": "2021-11-24T20:54:38.833485+01:00", + "updated_at":"2021-11-24T20:54:38.833509+01:00" + }, + "relationships": { + "parent": { + "data":null + } + } + }, + { + "type": "folders", + "id":"5", + "attributes": { + "title": "Folder 2", + "created_at": "2021-11-24T20:54:38.833485+01:00", + "updated_at":"2021-11-24T20:54:38.833509+01:00" + }, + "relationships": { + "parent": { + "data":null + } + } + } + ], + "meta": { + "pagination": { + "page": 1, + "pages": 1, + "count": 2 + } + }, + "links": { + "first": "", + "last": "", + "next": "", + "prev": "" + } + } + }); + + this.get('/api/nodes/2/', () => { + return { + "data": [ + { + "type": "folders", + "id":"4", + "attributes": { + "title": "Folder 1", + "created_at": "2021-11-24T20:54:38.833485+01:00", + "updated_at":"2021-11-24T20:54:38.833509+01:00" + }, + "relationships": { + "parent": { + "data":null + } + } + }, + { + "type": "folders", + "id":"5", + "attributes": { + "title": "Folder 2", + "created_at": "2021-11-24T20:54:38.833485+01:00", + "updated_at":"2021-11-24T20:54:38.833509+01:00" + }, + "relationships": { + "parent": { + "data":null + } + } + } + ], + "meta": { + "pagination": { + "page": 1, + "pages": 1, + "count": 2 + } + }, + "links": { + "first": "", + "last": "", + "next": "", + "prev": "" + } + } + }); + + this.get('/api/preferences/', () => { + return { + "data": [] + } + }); + } diff --git a/tests/acceptance/authenticated-index-test.js b/tests/acceptance/authenticated-index-test.js new file mode 100644 index 0000000000000000000000000000000000000000..6e696120e3648114d97b81d1efb5abed3fe8d8b1 --- /dev/null +++ b/tests/acceptance/authenticated-index-test.js @@ -0,0 +1,31 @@ +import { module, test } from 'qunit'; +import { visit, currentURL } from '@ember/test-helpers'; +import { setupApplicationTest } from 'ember-qunit'; +import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; +import { authenticateSession } from 'ember-simple-auth/test-support'; + + +module('Acceptance | authenticated', function (hooks) { + setupApplicationTest(hooks); + setupMirage(hooks); + + hooks.beforeEach(async function () { + await authenticateSession({ + authToken: '12345', + otherData: 'some-data' + }); + }); + + test('visiting / will redirect user to his home folder', async function (assert) { + /* + * Make sure that authenticated.index routes redirects to user's home folder + */ + await visit('/'); // visit root url + assert.strictEqual(currentURL(), '/nodes/2'); // user is redirected to home folder + }); + + test('visiting /nodes/1/ will land user in his home folder', async function (assert) { + await visit('/nodes/1/'); + assert.strictEqual(currentURL(), '/nodes/1/'); + }); +}); diff --git a/tests/acceptance/roles-test.js b/tests/acceptance/roles-test.js index 8bbbccf84578d128e213b390565111b0b514f987..6a61106c49cc62d2b762de0a8d877878aca407d9 100644 --- a/tests/acceptance/roles-test.js +++ b/tests/acceptance/roles-test.js @@ -20,7 +20,7 @@ module('Acceptance | roles', function (hooks) { test('visiting /roles', async function (assert) { await visit('/roles'); - assert.equal(currentURL(), '/roles'); + assert.strictEqual(currentURL(), '/roles'); assert.dom('.roles-add').hasText('New', 'The user can add new role'); }); }); diff --git a/tests/acceptance/tags-test.js b/tests/acceptance/tags-test.js index 173359a4ab22b3c07075d9c4ed9291fccc1b831b..9606d0b9e0b7a5be116610b77cfd3e5857135ff5 100644 --- a/tests/acceptance/tags-test.js +++ b/tests/acceptance/tags-test.js @@ -20,7 +20,7 @@ module('Acceptance | tags', function (hooks) { test('visiting /tags', async function (assert) { await visit('/tags'); - assert.equal(currentURL(), '/tags'); + assert.strictEqual(currentURL(), '/tags'); assert.dom('.add-tag').hasText('New', 'The user can add new tag'); }); });