github.com/elliott5/community@v0.14.1-0.20160709191136-823126fb026a/app/tests/acceptance/anon-access-enabled-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 | Anon access enabled');
    16  
    17  test('visiting / when not authenticated and with { allowAnonymousAccess: true } takes user to folder view', function (assert) {
    18  	server.create('meta', { allowAnonymousAccess: true });
    19  	server.createList('folder', 2);
    20  	visit('/');
    21  
    22  	andThen(function () {
    23  		assert.equal(find('.login').length, 1, 'Login button is displayed');
    24  		assert.equal(find('.documents-list .document').length, 2, '2 document displayed');
    25  		assert.equal(currentURL(), '/s/VzMuyEw_3WqiafcG/my-project', 'Dashboard and public spaces are displayed without being signed in');
    26  	});
    27  });
    28  
    29  test('visiting / when authenticated and with { allowAnonymousAccess: true } takes user to dashboard', function (assert) {
    30  	server.create('meta', { allowAnonymousAccess: true });
    31  	server.createList('folder', 2);
    32  	visit('/');
    33  
    34  	andThen(function () {
    35  		assert.equal(find('.login').length, 1, 'Login button is displayed');
    36  		assert.equal(currentURL(), '/s/VzMuyEw_3WqiafcG/my-project', 'Dashboard displayed without being signed in');
    37  	});
    38  
    39  	userLogin();
    40  
    41  	andThen(function () {
    42  		assert.equal(find('.login').length, 0, 'Login button is not displayed');
    43  		assert.equal(currentURL(), '/s/VzMuyEw_3WqiafcG/my-project', 'Dashboard is displayed after user is signed in');
    44  	});
    45  });