github.com/jancarloviray/community@v0.41.1-0.20170124221257-33a66c87cf2f/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  	visit('/');
    20  
    21  	andThen(function () {
    22  		assert.equal(find('.login').length, 1, 'Login button is displayed');
    23  		assert.equal(find('.documents-list .document').length, 2, '2 document displayed');
    24  		assert.equal(currentURL(), '/s/VzMuyEw_3WqiafcG/my-project', 'Dashboard and public spaces are displayed without being signed in');
    25  	});
    26  });
    27  
    28  test('visiting / when authenticated and with { allowAnonymousAccess: true } takes user to dashboard', function (assert) {
    29  	server.create('meta', { allowAnonymousAccess: true });
    30  	visit('/');
    31  
    32  	andThen(function () {
    33  		assert.equal(find('.login').length, 1, 'Login button is displayed');
    34  		assert.equal(currentURL(), '/s/VzMuyEw_3WqiafcG/my-project', 'Dashboard displayed without being signed in');
    35  	});
    36  
    37  	userLogin();
    38  
    39  	andThen(function () {
    40  		assert.equal(find('.login').length, 0, 'Login button is not displayed');
    41  		assert.equal(currentURL(), '/s/VzMuyEw_3WqiafcG/my-project', 'Dashboard is displayed after user is signed in');
    42  	});
    43  });