github.com/elliott5/community@v0.14.1-0.20160709191136-823126fb026a/app/tests/acceptance/documents-space-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, skip } from 'qunit'; 13 import moduleForAcceptance from 'documize/tests/helpers/module-for-acceptance'; 14 15 moduleForAcceptance('Acceptance | Documents space'); 16 17 skip('Adding a new folder space', function (assert) { 18 server.create('meta', { allowAnonymousAccess: false }); 19 server.createList('folder', 2); 20 server.createList('permission', 4); 21 authenticateUser(); 22 visit('/s/VzMuyEw_3WqiafcG/my-project'); 23 24 andThen(function () { 25 let personalSpaces = find('.section div:contains(PERSONAL)').length; 26 assert.equal(currentURL(), '/s/VzMuyEw_3WqiafcG/my-project'); 27 assert.equal(personalSpaces, 1, '1 personal space is listed'); 28 }); 29 30 click('#add-folder-button'); 31 32 fillIn('#new-folder-name', 'body', 'Test Folder'); 33 34 click('.actions div:contains(Add)', 'body'); 35 36 andThen(function () { 37 assert.equal(currentURL(), '/s/V0Vy5Uw_3QeDAMW9/test-folder'); 38 }); 39 }); 40 41 skip('Adding a document to a space', function (assert) { 42 server.create('meta', { allowAnonymousAccess: false }); 43 server.createList('folder', 2); 44 server.createList('permission', 4); 45 authenticateUser(); 46 visit('/s/VzMuyEw_3WqiafcG/my-project'); 47 48 andThen(function () { 49 50 let numberOfDocuments = find('.documents-list li').length; 51 assert.equal(currentURL(), '/s/VzMuyEw_3WqiafcG/my-project'); 52 assert.equal(numberOfDocuments, 2, '2 documents listed'); 53 }); 54 55 click('#start-document-button'); 56 click('.actions div:contains(Add)', 'body'); 57 58 andThen(function () { 59 let numberOfDocuments = find('.documents-list li').length; 60 assert.equal(numberOfDocuments, 3, '3 documents listed'); 61 assert.equal(currentURL(), '/s/VzMuyEw_3WqiafcG/my-project'); 62 }); 63 }); 64 65 test('visiting space settings page', function (assert) { 66 server.create('meta', { allowAnonymousAccess: false }); 67 server.createList('folder', 2); 68 server.createList('permission', 4); 69 authenticateUser(); 70 visit('/s/VzMuyEw_3WqiafcG/my-project'); 71 72 click('#folder-settings-button'); 73 74 andThen(function () { 75 checkForCommonAsserts(); 76 assert.equal(find('#folderName').val().trim(), 'My Project', 'Space name displayed in input box'); 77 assert.equal(currentURL(), '/s/VzMuyEw_3WqiafcG/my-project/settings'); 78 }); 79 }); 80 81 test('changing space name', function (assert) { 82 server.create('meta', { allowAnonymousAccess: false }); 83 server.createList('folder', 2); 84 server.createList('permission', 4); 85 authenticateUser(); 86 visit('/s/VzMuyEw_3WqiafcG/my-project'); 87 88 click('#folder-settings-button'); 89 90 fillIn('#folderName', 'Test Space'); 91 click('.button-blue'); 92 93 andThen(function () { 94 let spaceName = find('.info .title').text().trim(); 95 checkForCommonAsserts(); 96 assert.equal(spaceName, 'Test Space', 'Space name has been changed'); 97 assert.equal(currentURL(), '/s/VzMuyEw_3WqiafcG/my-project/settings'); 98 }); 99 }); 100 101 test('sharing a space', function (assert) { 102 server.create('meta', { allowAnonymousAccess: false }); 103 server.createList('folder', 2); 104 server.createList('permission', 4); 105 authenticateUser(); 106 visit('/s/VzMuyEw_3WqiafcG/my-project'); 107 108 click('#folder-settings-button'); 109 110 click(('.sidebar-menu .options li:contains(Share)')); 111 fillIn('#inviteEmail', 'share-test@gmail.com'); 112 click('.button-blue'); 113 114 andThen(function () { 115 checkForCommonAsserts(); 116 assert.equal(currentURL(), '/s/VzMuyEw_3WqiafcG/my-project/settings'); 117 }); 118 }); 119 120 // Test will pass after moving to factories 121 test('changing space permissions', function (assert) { 122 server.create('meta', { allowAnonymousAccess: false }); 123 server.createList('folder', 2); 124 server.createList('permission', 4); 125 authenticateUser(); 126 127 visit('/s/VzMygEw_3WrtFzto/test'); 128 andThen(function () { 129 let numberOfPublicFolders = find('.sidebar-menu .folders-list .section .list:first a').length; 130 assert.equal(numberOfPublicFolders, 1, '1 folder listed as public'); 131 assert.equal(currentURL(), '/s/VzMygEw_3WrtFzto/test'); 132 }); 133 134 click('#folder-settings-button'); 135 136 click('.sidebar-menu .options li:contains(Permissions)'); 137 138 click('tr:contains(Everyone) #canView-'); 139 click('tr:contains(Everyone) #canEdit-'); 140 click('.button-blue'); 141 142 visit('/s/VzMygEw_3WrtFzto/test'); 143 144 andThen(function () { 145 let numberOfPublicFolders = find('.folders-list div:contains(EVERYONE) .list a').length; 146 assert.equal(numberOfPublicFolders, 2, '2 folder listed as public'); 147 assert.equal(currentURL(), '/s/VzMygEw_3WrtFzto/test'); 148 }); 149 }); 150 151 test('deleting a space', function (assert) { 152 server.create('meta', { allowAnonymousAccess: false }); 153 server.createList('folder', 2); 154 server.createList('permission', 4); 155 authenticateUser(); 156 visit('/s/VzMuyEw_3WqiafcG/my-project'); 157 158 click('#folder-settings-button'); 159 160 click('.sidebar-menu .options li:contains(Delete)'); 161 162 andThen(function () { 163 checkForCommonAsserts(); 164 assert.equal(currentURL(), '/s/VzMuyEw_3WqiafcG/my-project/settings'); 165 }); 166 }); 167 168 skip('deleting a document', function (assert) { 169 server.create('meta', { allowAnonymousAccess: false }); 170 server.createList('folder', 2); 171 server.createList('permission', 4); 172 authenticateUser(); 173 visit('/s/VzMuyEw_3WqiafcG/my-project'); 174 175 andThen(function () { 176 let deleteButton = find('#delete-documents-button'); 177 let numberOfDocuments = find('.documents-list li'); 178 assert.equal(numberOfDocuments.length, 2, '2 documents are displayed'); 179 assert.equal(deleteButton.length, 0, 'Delete button not displayed'); 180 }); 181 182 click('.documents-list li:first .checkbox'); 183 184 andThen(function () { 185 let deleteButton = find('#delete-documents-button'); 186 assert.equal(deleteButton.length, 1, 'Delete button displayed after selecting document'); 187 }); 188 189 click('#delete-documents-button'); 190 191 waitToAppear('.drop-content'); 192 click('.actions div:contains(Delete)', 'body'); 193 194 andThen(function () { 195 let numberOfDocuments = find('.documents-list li'); 196 assert.equal(numberOfDocuments.length, 1, '1 documents is displayed'); 197 }); 198 }); 199 200 function checkForCommonAsserts() { 201 findWithAssert('.sidebar-menu'); 202 findWithAssert('.options li:contains(General)'); 203 findWithAssert('.options li:contains(Share)'); 204 findWithAssert('.options li:contains(Permissions)'); 205 findWithAssert('.options li:contains(Delete)'); 206 }