github.com/jancarloviray/community@v0.41.1-0.20170124221257-33a66c87cf2f/app/tests/acceptance/user-settings-test.js (about) 1 // Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved. 2 // 3 // This software (Documize Community Edition) is licensed under 4 // GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html 5 // 6 // You can operate outside the AGPL restrictions by purchasing 7 // Documize Enterprise Edition and obtaining a commercial license 8 // by contacting <sales@documize.com>. 9 // 10 // https://documize.com 11 12 import { test } from 'qunit'; 13 import moduleForAcceptance from 'documize/tests/helpers/module-for-acceptance'; 14 15 moduleForAcceptance('Acceptance | User Settings'); 16 17 test('visiting /settings/general', function (assert) { 18 server.create('meta', { allowAnonymousAccess: false }); 19 authenticateUser(); 20 visit('/settings/general'); 21 22 andThen(function () { 23 assert.equal(currentURL(), '/settings/general'); 24 assert.equal(find('#siteTitle').val(), 'EmberSherpa', 'Website title input is filled in correctly'); 25 assert.equal(find('textarea').val(), 'This Documize instance contains all our team documentation', 'Message is set correctly'); 26 assert.equal(find('#allowAnonymousAccess').is(':checked'), false, 'Allow anonymouus checkbox is unchecked'); 27 }); 28 }); 29 30 test('changing the Website title and description', function (assert) { 31 server.create('meta', { allowAnonymousAccess: false }); 32 authenticateUser(); 33 visit('/settings/general'); 34 35 andThen(function () { 36 let websiteTitle = find('.content .title').text().trim(); 37 let websiteTitleInput = find('#siteTitle').val(); 38 assert.equal(websiteTitleInput, websiteTitle, 'Website title is set to EmberSherpa'); 39 }); 40 41 fillIn('#siteTitle', 'Documize Tests'); 42 click('.button-blue'); 43 44 andThen(function () { 45 let websiteTitle = find('.content .title').text().trim(); 46 let websiteTitleInput = find('#siteTitle').val(); 47 assert.equal(websiteTitleInput, websiteTitle, 'Website title is set to Documize Tests'); 48 }); 49 }); 50 51 test('visiting /settings/folders', function (assert) { 52 server.create('meta', { allowAnonymousAccess: false }); 53 authenticateUser(); 54 visit('/settings/folders'); 55 56 andThen(function () { 57 checkForCommonAsserts(); 58 assert.equal(currentURL(), '/settings/folders'); 59 }); 60 }); 61 62 test('visiting /settings/users', function (assert) { 63 server.create('meta', { allowAnonymousAccess: false }); 64 authenticateUser(); 65 visit('/settings/users'); 66 67 andThen(function () { 68 checkForCommonAsserts(); 69 findWithAssert('.user-list'); 70 let numberOfUsers = find('.user-list tr').length; 71 assert.equal(numberOfUsers, 3, '2 Users listed'); 72 assert.equal(currentURL(), '/settings/users'); 73 }); 74 }); 75 76 test('add a new user', function (assert) { 77 server.create('meta', { allowAnonymousAccess: false }); 78 authenticateUser(); 79 visit('/settings/users'); 80 81 andThen(function () { 82 checkForCommonAsserts(); 83 findWithAssert('.user-list'); 84 let numberOfUsers = find('.user-list tr').length; 85 assert.equal(numberOfUsers, 3, '2 Users listed'); 86 assert.equal(currentURL(), '/settings/users'); 87 }); 88 89 fillIn('#newUserFirstname', 'Test'); 90 fillIn('#newUserLastname', 'User'); 91 fillIn('#newUserEmail', 'test.user@domain.com'); 92 click('.button-blue'); 93 94 andThen(function () { 95 let numberOfUsers = find('.user-list tr').length; 96 assert.equal(numberOfUsers, 4, '3 Users listed'); 97 assert.equal(currentURL(), '/settings/users'); 98 }); 99 100 }); 101 102 function checkForCommonAsserts() { 103 findWithAssert('.sidebar-menu'); 104 findWithAssert('#user-button'); 105 findWithAssert('#accounts-button'); 106 findWithAssert('.info .title'); 107 }