From 5cfbf07e5521bfa6fb45662773e045f6c03c8a59 Mon Sep 17 00:00:00 2001 From: Harvey Kandola Date: Sat, 8 Dec 2018 15:39:31 +0000 Subject: [PATCH] [WIP] Upgrading EmberJS codemods --- .../acceptance/anon-access-disabled-test.js | 25 +- .../acceptance/anon-access-enabled-test.js | 53 ++- gui/tests/acceptance/authentication-test.js | 79 ++-- gui/tests/acceptance/documents-space-test.js | 361 ++++++++---------- gui/tests/acceptance/user-profile-test.js | 67 ++-- gui/tests/acceptance/user-settings-test.js | 172 ++++----- .../integration/helpers/is-one-of-test.js | 26 +- gui/tests/unit/services/local-storage-test.js | 18 +- 8 files changed, 376 insertions(+), 425 deletions(-) diff --git a/gui/tests/acceptance/anon-access-disabled-test.js b/gui/tests/acceptance/anon-access-disabled-test.js index 6c88b790..3b2eab6a 100644 --- a/gui/tests/acceptance/anon-access-disabled-test.js +++ b/gui/tests/acceptance/anon-access-disabled-test.js @@ -1,3 +1,4 @@ +import { currentURL, visit } from '@ember/test-helpers'; // Copyright 2016 Documize Inc. . All rights reserved. // // This software (Documize Community Edition) is licensed under @@ -9,19 +10,19 @@ // // https://documize.com -import { test } from 'qunit'; -import moduleForAcceptance from 'documize/tests/helpers/module-for-acceptance'; +import { module, test } from 'qunit'; +import { setupApplicationTest } from 'ember-qunit'; -moduleForAcceptance('Acceptance | Anon access disabled'); +module('Acceptance | Anon access disabled', function(hooks) { + setupApplicationTest(hooks); -test('visiting / when not authenticated and with { allowAnonymousAccess: false } takes user to login', function (assert) { - server.create('meta', { allowAnonymousAccess: false }); - visit('/'); + test('visiting / when not authenticated and with { allowAnonymousAccess: false } takes user to login', async function(assert) { + server.create('meta', { allowAnonymousAccess: false }); + await visit('/'); - andThen(function () { - assert.equal(currentURL(), '/auth/login'); - findWithAssert('#authEmail'); - findWithAssert('#authPassword'); - findWithAssert('button'); - }); + assert.equal(currentURL(), '/auth/login'); + findWithAssert('#authEmail'); + findWithAssert('#authPassword'); + findWithAssert('button'); + }); }); diff --git a/gui/tests/acceptance/anon-access-enabled-test.js b/gui/tests/acceptance/anon-access-enabled-test.js index 5ba3302d..ac54701c 100644 --- a/gui/tests/acceptance/anon-access-enabled-test.js +++ b/gui/tests/acceptance/anon-access-enabled-test.js @@ -1,3 +1,4 @@ +import { findAll, currentURL, visit } from '@ember/test-helpers'; // Copyright 2016 Documize Inc. . All rights reserved. // // This software (Documize Community Edition) is licensed under @@ -9,35 +10,31 @@ // // https://documize.com -import { test } from 'qunit'; -import moduleForAcceptance from 'documize/tests/helpers/module-for-acceptance'; +import { module, test } from 'qunit'; +import { setupApplicationTest } from 'ember-qunit'; -moduleForAcceptance('Acceptance | Anon access enabled'); +module('Acceptance | Anon access enabled', function(hooks) { + setupApplicationTest(hooks); -test('visiting / when not authenticated and with { allowAnonymousAccess: true } takes user to folder view', function (assert) { - server.create('meta', { allowAnonymousAccess: true }); - visit('/'); + test('visiting / when not authenticated and with { allowAnonymousAccess: true } takes user to folder view', async function(assert) { + server.create('meta', { allowAnonymousAccess: true }); + await visit('/'); - andThen(function () { - assert.equal(find('.login').length, 1, 'Login button is displayed'); - assert.equal(find('.documents-list .document').length, 2, '2 document displayed'); - assert.equal(currentURL(), '/s/VzMuyEw_3WqiafcG/my-project', 'Dashboard and public spaces are displayed without being signed in'); - }); -}); - -test('visiting / when authenticated and with { allowAnonymousAccess: true } takes user to dashboard', function (assert) { - server.create('meta', { allowAnonymousAccess: true }); - visit('/'); - - andThen(function () { - assert.equal(find('.login').length, 1, 'Login button is displayed'); - assert.equal(currentURL(), '/s/VzMuyEw_3WqiafcG/my-project', 'Dashboard displayed without being signed in'); - }); - - userLogin(); - - andThen(function () { - assert.equal(find('.login').length, 0, 'Login button is not displayed'); - assert.equal(currentURL(), '/s/VzMuyEw_3WqiafcG/my-project', 'Dashboard is displayed after user is signed in'); - }); + assert.equal(findAll('.login').length, 1, 'Login button is displayed'); + assert.equal(findAll('.documents-list .document').length, 2, '2 document displayed'); + assert.equal(currentURL(), '/s/VzMuyEw_3WqiafcG/my-project', 'Dashboard and public spaces are displayed without being signed in'); + }); + + test('visiting / when authenticated and with { allowAnonymousAccess: true } takes user to dashboard', async function(assert) { + server.create('meta', { allowAnonymousAccess: true }); + await visit('/'); + + assert.equal(findAll('.login').length, 1, 'Login button is displayed'); + assert.equal(currentURL(), '/s/VzMuyEw_3WqiafcG/my-project', 'Dashboard displayed without being signed in'); + + userLogin(); + + assert.equal(findAll('.login').length, 0, 'Login button is not displayed'); + assert.equal(currentURL(), '/s/VzMuyEw_3WqiafcG/my-project', 'Dashboard is displayed after user is signed in'); + }); }); diff --git a/gui/tests/acceptance/authentication-test.js b/gui/tests/acceptance/authentication-test.js index ba300591..ab86c74f 100644 --- a/gui/tests/acceptance/authentication-test.js +++ b/gui/tests/acceptance/authentication-test.js @@ -1,3 +1,4 @@ +import { click, fillIn, currentURL, visit } from '@ember/test-helpers'; // Copyright 2016 Documize Inc. . All rights reserved. // // This software (Documize Community Edition) is licensed under @@ -9,50 +10,44 @@ // // https://documize.com -import { test } from 'qunit'; -import moduleForAcceptance from 'documize/tests/helpers/module-for-acceptance'; +import { module, test } from 'qunit'; +import { setupApplicationTest } from 'ember-qunit'; -moduleForAcceptance('Acceptance | Authentication'); +module('Acceptance | Authentication', function(hooks) { + setupApplicationTest(hooks); -test('visiting /auth/login and logging in', function (assert) { - server.create('meta', { allowAnonymousAccess: false }); - visit('/auth/login'); + test('visiting /auth/login and logging in', async function(assert) { + server.create('meta', { allowAnonymousAccess: false }); + await visit('/auth/login'); - fillIn('#authEmail', 'brizdigital@gmail.com'); - fillIn('#authPassword', 'zinyando123'); - click('button'); + await fillIn('#authEmail', 'brizdigital@gmail.com'); + await fillIn('#authPassword', 'zinyando123'); + await click('button'); - andThen(function () { - assert.equal(currentURL(), '/s/VzMuyEw_3WqiafcG/my-project', 'Login successful'); - }); -}); - -test('logging out a user', function (assert) { - server.create('meta', { allowAnonymousAccess: false }); - userLogin(); - click('.dropdown-menu a:contains(Logout)'); - - andThen(function () { - assert.equal(currentURL(), '/auth/login', 'Logging out successful'); - }); -}); - -test('successful sso login authenticates redirects to dashboard', function (assert) { - server.create('meta', { allowAnonymousAccess: false }); - - visit('/auth/sso/OmJyaXpkaWdpdGFsQGdtYWlsLmNvbTp6aW55YW5kbzEyMw=='); - - andThen(function () { - assert.equal(currentURL(), '/s/VzMuyEw_3WqiafcG/my-project', 'SSO login successful'); - }); -}); - -test('sso login with bad token should redirect to login', function (assert) { - server.create('meta', { allowAnonymousAccess: false }); - - visit('/auth/sso/randomToken1234567890'); - - andThen(function () { - assert.equal(currentURL(), '/auth/login', 'SSO login unsuccessful'); - }); + assert.equal(currentURL(), '/s/VzMuyEw_3WqiafcG/my-project', 'Login successful'); + }); + + test('logging out a user', async function(assert) { + server.create('meta', { allowAnonymousAccess: false }); + userLogin(); + await click('.dropdown-menu a:contains(Logout)'); + + assert.equal(currentURL(), '/auth/login', 'Logging out successful'); + }); + + test('successful sso login authenticates redirects to dashboard', async function(assert) { + server.create('meta', { allowAnonymousAccess: false }); + + await visit('/auth/sso/OmJyaXpkaWdpdGFsQGdtYWlsLmNvbTp6aW55YW5kbzEyMw=='); + + assert.equal(currentURL(), '/s/VzMuyEw_3WqiafcG/my-project', 'SSO login successful'); + }); + + test('sso login with bad token should redirect to login', async function(assert) { + server.create('meta', { allowAnonymousAccess: false }); + + await visit('/auth/sso/randomToken1234567890'); + + assert.equal(currentURL(), '/auth/login', 'SSO login unsuccessful'); + }); }); diff --git a/gui/tests/acceptance/documents-space-test.js b/gui/tests/acceptance/documents-space-test.js index 19a921b3..12eb65d6 100644 --- a/gui/tests/acceptance/documents-space-test.js +++ b/gui/tests/acceptance/documents-space-test.js @@ -1,3 +1,4 @@ +import { click, fillIn, find, findAll, currentURL, visit } from '@ember/test-helpers'; // Copyright 2016 Documize Inc. . All rights reserved. // // This software (Documize Community Edition) is licensed under @@ -9,207 +10,177 @@ // // https://documize.com -import { test } from 'qunit'; -import moduleForAcceptance from 'documize/tests/helpers/module-for-acceptance'; +import { module, test } from 'qunit'; +import { setupApplicationTest } from 'ember-qunit'; -moduleForAcceptance('Acceptance | Documents space'); +module('Acceptance | Documents space', function(hooks) { + setupApplicationTest(hooks); -test('Adding a new folder space', function (assert) { - server.create('meta', { allowAnonymousAccess: false }); - authenticateUser(); - visit('/s/VzMuyEw_3WqiafcG/my-project'); + test('Adding a new folder space', async function(assert) { + server.create('meta', { allowAnonymousAccess: false }); + authenticateUser(); + await visit('/s/VzMuyEw_3WqiafcG/my-project'); - andThen(function () { - let personalSpaces = find('.folders-list div:contains(PERSONAL) .list a').length; - assert.equal(currentURL(), '/s/VzMuyEw_3WqiafcG/my-project'); - assert.equal(personalSpaces, 1, '1 personal space is listed'); - }); + let personalSpaces = findAll('.folders-list div:contains(PERSONAL) .list a').length; + assert.equal(currentURL(), '/s/VzMuyEw_3WqiafcG/my-project'); + assert.equal(personalSpaces, 1, '1 personal space is listed'); - click('#add-folder-button'); + await click('#add-folder-button'); - fillIn('#new-folder-name', 'Test Folder'); + await fillIn('#new-folder-name', 'Test Folder'); - click('.actions div:contains(Add)'); + await click('.actions div:contains(Add)'); - andThen(function () { - let folderCount = find('.folders-list div:contains(PERSONAL) .list a').length; - assert.equal(folderCount, 2, 'New folder has been added'); - assert.equal(currentURL(), '/s/V0Vy5Uw_3QeDAMW9/test-folder'); - }); + let folderCount = findAll('.folders-list div:contains(PERSONAL) .list a').length; + assert.equal(folderCount, 2, 'New folder has been added'); + assert.equal(currentURL(), '/s/V0Vy5Uw_3QeDAMW9/test-folder'); + }); + test('Adding a document to a space', async function(assert) { + server.create('meta', { allowAnonymousAccess: false }); + authenticateUser(); + await visit('/s/VzMuyEw_3WqiafcG/my-project'); + + let numberOfDocuments = findAll('.documents-list li').length; + assert.equal(currentURL(), '/s/VzMuyEw_3WqiafcG/my-project'); + assert.equal(numberOfDocuments, 2, '2 documents listed'); + + await click('.actions div:contains(Start) .flat-green'); + + assert.equal(currentURL(), '/s/VzMuyEw_3WqiafcG/my-project/d/V4y7jkw_3QvCDSeS/new-document', 'New document displayed'); + + await click('a div:contains(My Project) .space-name'); + + let numberOfDocuments = findAll('.documents-list li').length; + assert.equal(numberOfDocuments, 3, '3 documents listed'); + }); + + test('visiting space settings page', async function(assert) { + server.create('meta', { allowAnonymousAccess: false }); + authenticateUser(); + await visit('/s/VzMuyEw_3WqiafcG/my-project'); + + await click('#folder-settings-button'); + + checkForCommonAsserts(); + assert.equal(find('#folderName').value.trim(), 'My Project', 'Space name displayed in input box'); + assert.equal(currentURL(), '/s/VzMuyEw_3WqiafcG/my-project/settings'); + }); + + test('changing space name', async function(assert) { + server.create('meta', { allowAnonymousAccess: false }); + authenticateUser(); + await visit('/s/VzMuyEw_3WqiafcG/my-project'); + + await click('#folder-settings-button'); + + await fillIn('#folderName', 'Test Space'); + await click('.button-blue'); + + let spaceName = find('.info .title').textContent.trim(); + checkForCommonAsserts(); + assert.equal(spaceName, 'Test Space', 'Space name has been changed'); + assert.equal(currentURL(), '/s/VzMuyEw_3WqiafcG/my-project/settings'); + }); + + test('sharing a space', async function(assert) { + server.create('meta', { allowAnonymousAccess: false }); + authenticateUser(); + await visit('/s/VzMuyEw_3WqiafcG/my-project'); + + await click('#folder-settings-button'); + + await click('.sidebar-menu .options li:contains(Share)'); + await fillIn('#inviteEmail', 'share-test@gmail.com'); + await click('.button-blue'); + + checkForCommonAsserts(); + assert.equal(currentURL(), '/s/VzMuyEw_3WqiafcG/my-project/settings'); + }); + + test('changing space permissions', async function(assert) { + server.create('meta', { allowAnonymousAccess: false }); + authenticateUser(); + + await visit('/s/VzMygEw_3WrtFzto/test'); + let numberOfPublicFolders = findAll('.sidebar-menu .folders-list .section .list:first a').length; + assert.equal(numberOfPublicFolders, 1, '1 folder listed as public'); + assert.equal(currentURL(), '/s/VzMygEw_3WrtFzto/test'); + + await click('#folder-settings-button'); + + await click('.sidebar-menu .options li:contains(Permissions)'); + + await click('tr:contains(Everyone) #canView-'); + await click('tr:contains(Everyone) #canEdit-'); + await click('.button-blue'); + + await visit('/s/VzMygEw_3WrtFzto/test'); + + let numberOfPublicFolders = findAll('.folders-list div:contains(EVERYONE) .list a').length; + assert.equal(numberOfPublicFolders, 2, '2 folder listed as public'); + assert.equal(currentURL(), '/s/VzMygEw_3WrtFzto/test'); + }); + + test('deleting a space', async function(assert) { + server.create('meta', { allowAnonymousAccess: false }); + authenticateUser(); + await visit('/s/VzMuyEw_3WqiafcG/my-project'); + + await click('#folder-settings-button'); + + await click('.sidebar-menu .options li:contains(Delete)'); + + checkForCommonAsserts(); + assert.equal(currentURL(), '/s/VzMuyEw_3WqiafcG/my-project/settings'); + }); + + test('deleting a document', async function(assert) { + server.create('meta', { allowAnonymousAccess: false }); + authenticateUser(); + await visit('/s/VzMuyEw_3WqiafcG/my-project'); + + let deleteButton = find('#delete-documents-button'); + let numberOfDocuments = find('.documents-list li'); + assert.equal(numberOfDocuments.length, 2, '2 documents are displayed'); + assert.equal(deleteButton.length, 0, 'Delete button not displayed'); + + await click('.documents-list li:first .checkbox'); + + let deleteButton = find('#delete-documents-button'); + assert.equal(deleteButton.length, 1, 'Delete button displayed after selecting document'); + + await click('.actions div:contains(Delete) .flat-red'); + + let numberOfDocuments = find('.documents-list li'); + assert.equal(numberOfDocuments.length, 1, '1 documents is displayed'); + }); + + test('clicking a document title displays the document', async function(assert) { + server.create('meta', { allowAnonymousAccess: false }); + authenticateUser(); + await visit('/s/VzMygEw_3WrtFzto/test'); + + await click('a .title:contains(README)'); + + findWithAssert('#add-section-button'); + findWithAssert('#delete-document-button'); + findWithAssert('#print-document-button'); + findWithAssert('#save-template-button'); + findWithAssert('#attachment-button'); + findWithAssert('#set-meta-button'); + findWithAssert('.name.space-name'); + findWithAssert('.document-sidebar'); + let title = find('.zone-header .title').textContent.trim(); + assert.equal(title, 'README', 'document displayed correctly'); + assert.equal(currentURL(), '/s/VzMygEw_3WrtFzto/test/d/VzMvJEw_3WqiafcI/readme'); + }); + + function checkForCommonAsserts() { + findWithAssert('.sidebar-menu'); + findWithAssert('.options li:contains(General)'); + findWithAssert('.options li:contains(Share)'); + findWithAssert('.options li:contains(Permissions)'); + findWithAssert('.options li:contains(Delete)'); + } }); - -test('Adding a document to a space', function (assert) { - server.create('meta', { allowAnonymousAccess: false }); - authenticateUser(); - visit('/s/VzMuyEw_3WqiafcG/my-project'); - - andThen(function () { - - let numberOfDocuments = find('.documents-list li').length; - assert.equal(currentURL(), '/s/VzMuyEw_3WqiafcG/my-project'); - assert.equal(numberOfDocuments, 2, '2 documents listed'); - }); - - click('.actions div:contains(Start) .flat-green'); - - andThen(function () { - assert.equal(currentURL(), '/s/VzMuyEw_3WqiafcG/my-project/d/V4y7jkw_3QvCDSeS/new-document', 'New document displayed'); - }); - - click('a div:contains(My Project) .space-name'); - - andThen(function () { - let numberOfDocuments = find('.documents-list li').length; - assert.equal(numberOfDocuments, 3, '3 documents listed'); - }); -}); - -test('visiting space settings page', function (assert) { - server.create('meta', { allowAnonymousAccess: false }); - authenticateUser(); - visit('/s/VzMuyEw_3WqiafcG/my-project'); - - click('#folder-settings-button'); - - andThen(function () { - checkForCommonAsserts(); - assert.equal(find('#folderName').val().trim(), 'My Project', 'Space name displayed in input box'); - assert.equal(currentURL(), '/s/VzMuyEw_3WqiafcG/my-project/settings'); - }); -}); - -test('changing space name', function (assert) { - server.create('meta', { allowAnonymousAccess: false }); - authenticateUser(); - visit('/s/VzMuyEw_3WqiafcG/my-project'); - - click('#folder-settings-button'); - - fillIn('#folderName', 'Test Space'); - click('.button-blue'); - - andThen(function () { - let spaceName = find('.info .title').text().trim(); - checkForCommonAsserts(); - assert.equal(spaceName, 'Test Space', 'Space name has been changed'); - assert.equal(currentURL(), '/s/VzMuyEw_3WqiafcG/my-project/settings'); - }); -}); - -test('sharing a space', function (assert) { - server.create('meta', { allowAnonymousAccess: false }); - authenticateUser(); - visit('/s/VzMuyEw_3WqiafcG/my-project'); - - click('#folder-settings-button'); - - click(('.sidebar-menu .options li:contains(Share)')); - fillIn('#inviteEmail', 'share-test@gmail.com'); - click('.button-blue'); - - andThen(function () { - checkForCommonAsserts(); - assert.equal(currentURL(), '/s/VzMuyEw_3WqiafcG/my-project/settings'); - }); -}); - -test('changing space permissions', function (assert) { - server.create('meta', { allowAnonymousAccess: false }); - authenticateUser(); - - visit('/s/VzMygEw_3WrtFzto/test'); - andThen(function () { - let numberOfPublicFolders = find('.sidebar-menu .folders-list .section .list:first a').length; - assert.equal(numberOfPublicFolders, 1, '1 folder listed as public'); - assert.equal(currentURL(), '/s/VzMygEw_3WrtFzto/test'); - }); - - click('#folder-settings-button'); - - click('.sidebar-menu .options li:contains(Permissions)'); - - click('tr:contains(Everyone) #canView-'); - click('tr:contains(Everyone) #canEdit-'); - click('.button-blue'); - - visit('/s/VzMygEw_3WrtFzto/test'); - - andThen(function () { - let numberOfPublicFolders = find('.folders-list div:contains(EVERYONE) .list a').length; - assert.equal(numberOfPublicFolders, 2, '2 folder listed as public'); - assert.equal(currentURL(), '/s/VzMygEw_3WrtFzto/test'); - }); -}); - -test('deleting a space', function (assert) { - server.create('meta', { allowAnonymousAccess: false }); - authenticateUser(); - visit('/s/VzMuyEw_3WqiafcG/my-project'); - - click('#folder-settings-button'); - - click('.sidebar-menu .options li:contains(Delete)'); - - andThen(function () { - checkForCommonAsserts(); - assert.equal(currentURL(), '/s/VzMuyEw_3WqiafcG/my-project/settings'); - }); -}); - -test('deleting a document', function (assert) { - server.create('meta', { allowAnonymousAccess: false }); - authenticateUser(); - visit('/s/VzMuyEw_3WqiafcG/my-project'); - - andThen(function () { - let deleteButton = find('#delete-documents-button'); - let numberOfDocuments = find('.documents-list li'); - assert.equal(numberOfDocuments.length, 2, '2 documents are displayed'); - assert.equal(deleteButton.length, 0, 'Delete button not displayed'); - }); - - click('.documents-list li:first .checkbox'); - - andThen(function () { - let deleteButton = find('#delete-documents-button'); - assert.equal(deleteButton.length, 1, 'Delete button displayed after selecting document'); - }); - - click('.actions div:contains(Delete) .flat-red'); - - andThen(function () { - let numberOfDocuments = find('.documents-list li'); - assert.equal(numberOfDocuments.length, 1, '1 documents is displayed'); - }); -}); - -test('clicking a document title displays the document', function (assert) { - server.create('meta', { allowAnonymousAccess: false }); - authenticateUser(); - visit('/s/VzMygEw_3WrtFzto/test'); - - click('a .title:contains(README)'); - - andThen(function () { - findWithAssert('#add-section-button'); - findWithAssert('#delete-document-button'); - findWithAssert('#print-document-button'); - findWithAssert('#save-template-button'); - findWithAssert('#attachment-button'); - findWithAssert('#set-meta-button'); - findWithAssert('.name.space-name'); - findWithAssert('.document-sidebar'); - let title = find('.zone-header .title').text().trim(); - assert.equal(title, 'README', 'document displayed correctly'); - assert.equal(currentURL(), '/s/VzMygEw_3WrtFzto/test/d/VzMvJEw_3WqiafcI/readme'); - }); -}); - -function checkForCommonAsserts() { - findWithAssert('.sidebar-menu'); - findWithAssert('.options li:contains(General)'); - findWithAssert('.options li:contains(Share)'); - findWithAssert('.options li:contains(Permissions)'); - findWithAssert('.options li:contains(Delete)'); -} diff --git a/gui/tests/acceptance/user-profile-test.js b/gui/tests/acceptance/user-profile-test.js index 40de4750..dc116cd2 100644 --- a/gui/tests/acceptance/user-profile-test.js +++ b/gui/tests/acceptance/user-profile-test.js @@ -1,3 +1,4 @@ +import { click, fillIn, find, currentURL, visit } from '@ember/test-helpers'; // Copyright 2016 Documize Inc. . All rights reserved. // // This software (Documize Community Edition) is licensed under @@ -9,42 +10,38 @@ // // https://documize.com -import { test } from 'qunit'; -import moduleForAcceptance from 'documize/tests/helpers/module-for-acceptance'; +import { module, test } from 'qunit'; +import { setupApplicationTest } from 'ember-qunit'; -moduleForAcceptance('Acceptance | user profile'); +module('Acceptance | user profile', function(hooks) { + setupApplicationTest(hooks); -test('visiting /profile', function (assert) { - authenticateUser(); - visit('/profile'); + test('visiting /profile', async function(assert) { + authenticateUser(); + await visit('/profile'); - andThen(function () { - assert.equal(currentURL(), '/profile'); - assert.equal(find('#firstname').val(), 'Lennex', 'Firstaname input displays correct value'); - assert.equal(find('#lastname').val(), 'Zinyando', 'Lastname input displays correct value'); - assert.equal(find('#email').val(), 'brizdigital@gmail.com', 'Email input displays correct value'); - }); -}); - -test('changing user details and email ', function (assert) { - authenticateUser(); - visit('/profile'); - - andThen(function () { - assert.equal(currentURL(), '/profile'); - assert.equal(find('.content .name').text().trim(), 'Lennex Zinyando', 'Profile name displayed'); - assert.equal(find('#firstname').val(), 'Lennex', 'Firstaname input displays correct value'); - assert.equal(find('#lastname').val(), 'Zinyando', 'Lastname input displays correct value'); - assert.equal(find('#email').val(), 'brizdigital@gmail.com', 'Email input displays correct value'); - }); - - fillIn('#firstname', 'Test'); - fillIn('#lastname', 'User'); - fillIn('#email', 'test.user@domain.com'); - click('.button-blue'); - - andThen(function () { - assert.equal(currentURL(), '/s/VzMuyEw_3WqiafcG/my-project'); - assert.equal(find('.content .name').text().trim(), 'Test User', 'Profile name displayed'); - }); + assert.equal(currentURL(), '/profile'); + assert.equal(find('#firstname').value, 'Lennex', 'Firstaname input displays correct value'); + assert.equal(find('#lastname').value, 'Zinyando', 'Lastname input displays correct value'); + assert.equal(find('#email').value, 'brizdigital@gmail.com', 'Email input displays correct value'); + }); + + test('changing user details and email ', async function(assert) { + authenticateUser(); + await visit('/profile'); + + assert.equal(currentURL(), '/profile'); + assert.equal(find('.content .name').textContent.trim(), 'Lennex Zinyando', 'Profile name displayed'); + assert.equal(find('#firstname').value, 'Lennex', 'Firstaname input displays correct value'); + assert.equal(find('#lastname').value, 'Zinyando', 'Lastname input displays correct value'); + assert.equal(find('#email').value, 'brizdigital@gmail.com', 'Email input displays correct value'); + + await fillIn('#firstname', 'Test'); + await fillIn('#lastname', 'User'); + await fillIn('#email', 'test.user@domain.com'); + await click('.button-blue'); + + assert.equal(currentURL(), '/s/VzMuyEw_3WqiafcG/my-project'); + assert.equal(find('.content .name').textContent.trim(), 'Test User', 'Profile name displayed'); + }); }); diff --git a/gui/tests/acceptance/user-settings-test.js b/gui/tests/acceptance/user-settings-test.js index 125ee46c..f8751b07 100644 --- a/gui/tests/acceptance/user-settings-test.js +++ b/gui/tests/acceptance/user-settings-test.js @@ -1,3 +1,4 @@ +import { click, fillIn, find, findAll, currentURL, visit } from '@ember/test-helpers'; // Copyright 2016 Documize Inc. . All rights reserved. // // This software (Documize Community Edition) is licensed under @@ -9,99 +10,86 @@ // // https://documize.com -import { test } from 'qunit'; -import moduleForAcceptance from 'documize/tests/helpers/module-for-acceptance'; +import { module, test } from 'qunit'; +import { setupApplicationTest } from 'ember-qunit'; -moduleForAcceptance('Acceptance | User Settings'); +module('Acceptance | User Settings', function(hooks) { + setupApplicationTest(hooks); -test('visiting /settings/general', function (assert) { - server.create('meta', { allowAnonymousAccess: false }); - authenticateUser(); - visit('/settings/general'); + test('visiting /settings/general', async function(assert) { + server.create('meta', { allowAnonymousAccess: false }); + authenticateUser(); + await visit('/settings/general'); - andThen(function () { - assert.equal(currentURL(), '/settings/general'); - assert.equal(find('#siteTitle').val(), 'EmberSherpa', 'Website title input is filled in correctly'); - assert.equal(find('textarea').val(), 'This Documize instance contains all our team documentation', 'Message is set correctly'); - assert.equal(find('#allowAnonymousAccess').is(':checked'), false, 'Allow anonymouus checkbox is unchecked'); - }); + assert.equal(currentURL(), '/settings/general'); + assert.equal(find('#siteTitle').value, 'EmberSherpa', 'Website title input is filled in correctly'); + assert.equal(find('textarea').value, 'This Documize instance contains all our team documentation', 'Message is set correctly'); + assert.equal(find('#allowAnonymousAccess').is(':checked'), false, 'Allow anonymouus checkbox is unchecked'); + }); + + test('changing the Website title and description', async function(assert) { + server.create('meta', { allowAnonymousAccess: false }); + authenticateUser(); + await visit('/settings/general'); + + let websiteTitle = find('.content .title').textContent.trim(); + let websiteTitleInput = find('#siteTitle').value; + assert.equal(websiteTitleInput, websiteTitle, 'Website title is set to EmberSherpa'); + + await fillIn('#siteTitle', 'Documize Tests'); + await click('.button-blue'); + + let websiteTitle = find('.content .title').textContent.trim(); + let websiteTitleInput = find('#siteTitle').value; + assert.equal(websiteTitleInput, websiteTitle, 'Website title is set to Documize Tests'); + }); + + test('visiting /settings/folders', async function(assert) { + server.create('meta', { allowAnonymousAccess: false }); + authenticateUser(); + await visit('/settings/folders'); + + checkForCommonAsserts(); + assert.equal(currentURL(), '/settings/folders'); + }); + + test('visiting /settings/users', async function(assert) { + server.create('meta', { allowAnonymousAccess: false }); + authenticateUser(); + await visit('/settings/users'); + + checkForCommonAsserts(); + findWithAssert('.user-list'); + let numberOfUsers = findAll('.user-list tr').length; + assert.equal(numberOfUsers, 3, '2 Users listed'); + assert.equal(currentURL(), '/settings/users'); + }); + + test('add a new user', async function(assert) { + server.create('meta', { allowAnonymousAccess: false }); + authenticateUser(); + await visit('/settings/users'); + + checkForCommonAsserts(); + findWithAssert('.user-list'); + let numberOfUsers = findAll('.user-list tr').length; + assert.equal(numberOfUsers, 3, '2 Users listed'); + assert.equal(currentURL(), '/settings/users'); + + await fillIn('#newUserFirstname', 'Test'); + await fillIn('#newUserLastname', 'User'); + await fillIn('#newUserEmail', 'test.user@domain.com'); + await click('.button-blue'); + + let numberOfUsers = findAll('.user-list tr').length; + assert.equal(numberOfUsers, 4, '3 Users listed'); + assert.equal(currentURL(), '/settings/users'); + }); + + function checkForCommonAsserts() { + findWithAssert('.sidebar-menu'); + findWithAssert('#user-button'); + findWithAssert('#accounts-button'); + findWithAssert('.info .title'); + } }); - -test('changing the Website title and description', function (assert) { - server.create('meta', { allowAnonymousAccess: false }); - authenticateUser(); - visit('/settings/general'); - - andThen(function () { - let websiteTitle = find('.content .title').text().trim(); - let websiteTitleInput = find('#siteTitle').val(); - assert.equal(websiteTitleInput, websiteTitle, 'Website title is set to EmberSherpa'); - }); - - fillIn('#siteTitle', 'Documize Tests'); - click('.button-blue'); - - andThen(function () { - let websiteTitle = find('.content .title').text().trim(); - let websiteTitleInput = find('#siteTitle').val(); - assert.equal(websiteTitleInput, websiteTitle, 'Website title is set to Documize Tests'); - }); -}); - -test('visiting /settings/folders', function (assert) { - server.create('meta', { allowAnonymousAccess: false }); - authenticateUser(); - visit('/settings/folders'); - - andThen(function () { - checkForCommonAsserts(); - assert.equal(currentURL(), '/settings/folders'); - }); -}); - -test('visiting /settings/users', function (assert) { - server.create('meta', { allowAnonymousAccess: false }); - authenticateUser(); - visit('/settings/users'); - - andThen(function () { - checkForCommonAsserts(); - findWithAssert('.user-list'); - let numberOfUsers = find('.user-list tr').length; - assert.equal(numberOfUsers, 3, '2 Users listed'); - assert.equal(currentURL(), '/settings/users'); - }); -}); - -test('add a new user', function (assert) { - server.create('meta', { allowAnonymousAccess: false }); - authenticateUser(); - visit('/settings/users'); - - andThen(function () { - checkForCommonAsserts(); - findWithAssert('.user-list'); - let numberOfUsers = find('.user-list tr').length; - assert.equal(numberOfUsers, 3, '2 Users listed'); - assert.equal(currentURL(), '/settings/users'); - }); - - fillIn('#newUserFirstname', 'Test'); - fillIn('#newUserLastname', 'User'); - fillIn('#newUserEmail', 'test.user@domain.com'); - click('.button-blue'); - - andThen(function () { - let numberOfUsers = find('.user-list tr').length; - assert.equal(numberOfUsers, 4, '3 Users listed'); - assert.equal(currentURL(), '/settings/users'); - }); - -}); - -function checkForCommonAsserts() { - findWithAssert('.sidebar-menu'); - findWithAssert('#user-button'); - findWithAssert('#accounts-button'); - findWithAssert('.info .title'); -} diff --git a/gui/tests/integration/helpers/is-one-of-test.js b/gui/tests/integration/helpers/is-one-of-test.js index 798431ee..e6b78e47 100644 --- a/gui/tests/integration/helpers/is-one-of-test.js +++ b/gui/tests/integration/helpers/is-one-of-test.js @@ -1,15 +1,17 @@ -import { moduleForComponent, test } from 'ember-qunit'; +import { module, test } from 'qunit'; +import { setupRenderingTest } from 'ember-qunit'; +import { render, find } from '@ember/test-helpers'; import hbs from 'htmlbars-inline-precompile'; -moduleForComponent('is-one-of', 'helper:action-type', { - integration: true -}); - -// Replace this with your real tests. -test('it renders', function(assert) { - this.set('inputValue', '1234'); - - this.render(hbs`{{is-one-of 1 1 2 3}}`); - - assert.equal(this.$().text().trim(), 'true'); +module('helper:action-type', function(hooks) { + setupRenderingTest(hooks); + + // Replace this with your real tests. + test('it renders', async function(assert) { + this.set('inputValue', '1234'); + + await render(hbs`{{is-one-of 1 1 2 3}}`); + + assert.equal(find('*').textContent.trim(), 'true'); + }); }); diff --git a/gui/tests/unit/services/local-storage-test.js b/gui/tests/unit/services/local-storage-test.js index 3b4bf289..c6619514 100644 --- a/gui/tests/unit/services/local-storage-test.js +++ b/gui/tests/unit/services/local-storage-test.js @@ -1,3 +1,4 @@ +import { module, test } from 'qunit'; // Copyright 2016 Documize Inc. . All rights reserved. // // This software (Documize Community Edition) is licensed under @@ -9,15 +10,14 @@ // // https://documize.com -import { moduleFor, test } from 'ember-qunit'; +import { setupTest } from 'ember-qunit'; -moduleFor('service:local-storage', 'Unit | Service | local storage', { - // Specify the other units that are required for this test. - // needs: ['service:foo'] -}); +module('Unit | Service | local storage', function(hooks) { + setupTest(hooks); -// Replace this with your real tests. -test('it exists', function (assert) { - let service = this.subject(); - assert.ok(service); + // Replace this with your real tests. + test('it exists', function (assert) { + let service = this.owner.lookup('service:local-storage'); + assert.ok(service); + }); }); \ No newline at end of file