1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-07-21 22:29:41 +02:00

[WIP] Upgrading EmberJS codemods

This commit is contained in:
Harvey Kandola 2018-12-08 15:39:31 +00:00
parent 4b68529090
commit 5cfbf07e55
8 changed files with 376 additions and 425 deletions

View file

@ -1,3 +1,4 @@
import { currentURL, visit } from '@ember/test-helpers';
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved. // Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
// //
// This software (Documize Community Edition) is licensed under // This software (Documize Community Edition) is licensed under
@ -9,16 +10,16 @@
// //
// https://documize.com // https://documize.com
import { test } from 'qunit'; import { module, test } from 'qunit';
import moduleForAcceptance from 'documize/tests/helpers/module-for-acceptance'; 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) { test('visiting / when not authenticated and with { allowAnonymousAccess: false } takes user to login', async function(assert) {
server.create('meta', { allowAnonymousAccess: false }); server.create('meta', { allowAnonymousAccess: false });
visit('/'); await visit('/');
andThen(function () {
assert.equal(currentURL(), '/auth/login'); assert.equal(currentURL(), '/auth/login');
findWithAssert('#authEmail'); findWithAssert('#authEmail');
findWithAssert('#authPassword'); findWithAssert('#authPassword');

View file

@ -1,3 +1,4 @@
import { findAll, currentURL, visit } from '@ember/test-helpers';
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved. // Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
// //
// This software (Documize Community Edition) is licensed under // This software (Documize Community Edition) is licensed under
@ -9,35 +10,31 @@
// //
// https://documize.com // https://documize.com
import { test } from 'qunit'; import { module, test } from 'qunit';
import moduleForAcceptance from 'documize/tests/helpers/module-for-acceptance'; 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) { test('visiting / when not authenticated and with { allowAnonymousAccess: true } takes user to folder view', async function(assert) {
server.create('meta', { allowAnonymousAccess: true }); server.create('meta', { allowAnonymousAccess: true });
visit('/'); await visit('/');
andThen(function () { assert.equal(findAll('.login').length, 1, 'Login button is displayed');
assert.equal(find('.login').length, 1, 'Login button is displayed'); assert.equal(findAll('.documents-list .document').length, 2, '2 document 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'); 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) { test('visiting / when authenticated and with { allowAnonymousAccess: true } takes user to dashboard', async function(assert) {
server.create('meta', { allowAnonymousAccess: true }); server.create('meta', { allowAnonymousAccess: true });
visit('/'); await visit('/');
andThen(function () { assert.equal(findAll('.login').length, 1, 'Login button is displayed');
assert.equal(find('.login').length, 1, 'Login button is displayed');
assert.equal(currentURL(), '/s/VzMuyEw_3WqiafcG/my-project', 'Dashboard displayed without being signed in'); assert.equal(currentURL(), '/s/VzMuyEw_3WqiafcG/my-project', 'Dashboard displayed without being signed in');
});
userLogin(); userLogin();
andThen(function () { assert.equal(findAll('.login').length, 0, 'Login button is not displayed');
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(currentURL(), '/s/VzMuyEw_3WqiafcG/my-project', 'Dashboard is displayed after user is signed in');
}); });
}); });

View file

@ -1,3 +1,4 @@
import { click, fillIn, currentURL, visit } from '@ember/test-helpers';
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved. // Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
// //
// This software (Documize Community Edition) is licensed under // This software (Documize Community Edition) is licensed under
@ -9,50 +10,44 @@
// //
// https://documize.com // https://documize.com
import { test } from 'qunit'; import { module, test } from 'qunit';
import moduleForAcceptance from 'documize/tests/helpers/module-for-acceptance'; import { setupApplicationTest } from 'ember-qunit';
moduleForAcceptance('Acceptance | Authentication'); module('Acceptance | Authentication', function(hooks) {
setupApplicationTest(hooks);
test('visiting /auth/login and logging in', function (assert) { test('visiting /auth/login and logging in', async function(assert) {
server.create('meta', { allowAnonymousAccess: false }); server.create('meta', { allowAnonymousAccess: false });
visit('/auth/login'); await visit('/auth/login');
fillIn('#authEmail', 'brizdigital@gmail.com'); await fillIn('#authEmail', 'brizdigital@gmail.com');
fillIn('#authPassword', 'zinyando123'); await fillIn('#authPassword', 'zinyando123');
click('button'); await click('button');
andThen(function () {
assert.equal(currentURL(), '/s/VzMuyEw_3WqiafcG/my-project', 'Login successful'); assert.equal(currentURL(), '/s/VzMuyEw_3WqiafcG/my-project', 'Login successful');
}); });
});
test('logging out a user', function (assert) { test('logging out a user', async function(assert) {
server.create('meta', { allowAnonymousAccess: false }); server.create('meta', { allowAnonymousAccess: false });
userLogin(); userLogin();
click('.dropdown-menu a:contains(Logout)'); await click('.dropdown-menu a:contains(Logout)');
andThen(function () {
assert.equal(currentURL(), '/auth/login', 'Logging out successful'); assert.equal(currentURL(), '/auth/login', 'Logging out successful');
}); });
});
test('successful sso login authenticates redirects to dashboard', function (assert) { test('successful sso login authenticates redirects to dashboard', async function(assert) {
server.create('meta', { allowAnonymousAccess: false }); server.create('meta', { allowAnonymousAccess: false });
visit('/auth/sso/OmJyaXpkaWdpdGFsQGdtYWlsLmNvbTp6aW55YW5kbzEyMw=='); await visit('/auth/sso/OmJyaXpkaWdpdGFsQGdtYWlsLmNvbTp6aW55YW5kbzEyMw==');
andThen(function () {
assert.equal(currentURL(), '/s/VzMuyEw_3WqiafcG/my-project', 'SSO login successful'); assert.equal(currentURL(), '/s/VzMuyEw_3WqiafcG/my-project', 'SSO login successful');
}); });
});
test('sso login with bad token should redirect to login', function (assert) { test('sso login with bad token should redirect to login', async function(assert) {
server.create('meta', { allowAnonymousAccess: false }); server.create('meta', { allowAnonymousAccess: false });
visit('/auth/sso/randomToken1234567890'); await visit('/auth/sso/randomToken1234567890');
andThen(function () {
assert.equal(currentURL(), '/auth/login', 'SSO login unsuccessful'); assert.equal(currentURL(), '/auth/login', 'SSO login unsuccessful');
}); });
}); });

View file

@ -1,3 +1,4 @@
import { click, fillIn, find, findAll, currentURL, visit } from '@ember/test-helpers';
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved. // Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
// //
// This software (Documize Community Edition) is licensed under // This software (Documize Community Edition) is licensed under
@ -9,189 +10,159 @@
// //
// https://documize.com // https://documize.com
import { test } from 'qunit'; import { module, test } from 'qunit';
import moduleForAcceptance from 'documize/tests/helpers/module-for-acceptance'; 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) { test('Adding a new folder space', async function(assert) {
server.create('meta', { allowAnonymousAccess: false }); server.create('meta', { allowAnonymousAccess: false });
authenticateUser(); authenticateUser();
visit('/s/VzMuyEw_3WqiafcG/my-project'); await visit('/s/VzMuyEw_3WqiafcG/my-project');
andThen(function () { let personalSpaces = findAll('.folders-list div:contains(PERSONAL) .list a').length;
let personalSpaces = find('.folders-list div:contains(PERSONAL) .list a').length;
assert.equal(currentURL(), '/s/VzMuyEw_3WqiafcG/my-project'); assert.equal(currentURL(), '/s/VzMuyEw_3WqiafcG/my-project');
assert.equal(personalSpaces, 1, '1 personal space is listed'); 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 = findAll('.folders-list div:contains(PERSONAL) .list a').length;
let folderCount = find('.folders-list div:contains(PERSONAL) .list a').length;
assert.equal(folderCount, 2, 'New folder has been added'); assert.equal(folderCount, 2, 'New folder has been added');
assert.equal(currentURL(), '/s/V0Vy5Uw_3QeDAMW9/test-folder'); assert.equal(currentURL(), '/s/V0Vy5Uw_3QeDAMW9/test-folder');
}); });
}); test('Adding a document to a space', async function(assert) {
test('Adding a document to a space', function (assert) {
server.create('meta', { allowAnonymousAccess: false }); server.create('meta', { allowAnonymousAccess: false });
authenticateUser(); authenticateUser();
visit('/s/VzMuyEw_3WqiafcG/my-project'); await visit('/s/VzMuyEw_3WqiafcG/my-project');
andThen(function () { let numberOfDocuments = findAll('.documents-list li').length;
let numberOfDocuments = find('.documents-list li').length;
assert.equal(currentURL(), '/s/VzMuyEw_3WqiafcG/my-project'); assert.equal(currentURL(), '/s/VzMuyEw_3WqiafcG/my-project');
assert.equal(numberOfDocuments, 2, '2 documents listed'); assert.equal(numberOfDocuments, 2, '2 documents listed');
});
click('.actions div:contains(Start) .flat-green'); await 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'); assert.equal(currentURL(), '/s/VzMuyEw_3WqiafcG/my-project/d/V4y7jkw_3QvCDSeS/new-document', 'New document displayed');
});
click('a div:contains(My Project) .space-name'); await click('a div:contains(My Project) .space-name');
andThen(function () { let numberOfDocuments = findAll('.documents-list li').length;
let numberOfDocuments = find('.documents-list li').length;
assert.equal(numberOfDocuments, 3, '3 documents listed'); assert.equal(numberOfDocuments, 3, '3 documents listed');
}); });
});
test('visiting space settings page', function (assert) { test('visiting space settings page', async function(assert) {
server.create('meta', { allowAnonymousAccess: false }); server.create('meta', { allowAnonymousAccess: false });
authenticateUser(); authenticateUser();
visit('/s/VzMuyEw_3WqiafcG/my-project'); await visit('/s/VzMuyEw_3WqiafcG/my-project');
click('#folder-settings-button'); await click('#folder-settings-button');
andThen(function () {
checkForCommonAsserts(); checkForCommonAsserts();
assert.equal(find('#folderName').val().trim(), 'My Project', 'Space name displayed in input box'); assert.equal(find('#folderName').value.trim(), 'My Project', 'Space name displayed in input box');
assert.equal(currentURL(), '/s/VzMuyEw_3WqiafcG/my-project/settings'); assert.equal(currentURL(), '/s/VzMuyEw_3WqiafcG/my-project/settings');
}); });
});
test('changing space name', function (assert) { test('changing space name', async function(assert) {
server.create('meta', { allowAnonymousAccess: false }); server.create('meta', { allowAnonymousAccess: false });
authenticateUser(); authenticateUser();
visit('/s/VzMuyEw_3WqiafcG/my-project'); await visit('/s/VzMuyEw_3WqiafcG/my-project');
click('#folder-settings-button'); await click('#folder-settings-button');
fillIn('#folderName', 'Test Space'); await fillIn('#folderName', 'Test Space');
click('.button-blue'); await click('.button-blue');
andThen(function () { let spaceName = find('.info .title').textContent.trim();
let spaceName = find('.info .title').text().trim();
checkForCommonAsserts(); checkForCommonAsserts();
assert.equal(spaceName, 'Test Space', 'Space name has been changed'); assert.equal(spaceName, 'Test Space', 'Space name has been changed');
assert.equal(currentURL(), '/s/VzMuyEw_3WqiafcG/my-project/settings'); assert.equal(currentURL(), '/s/VzMuyEw_3WqiafcG/my-project/settings');
}); });
});
test('sharing a space', function (assert) { test('sharing a space', async function(assert) {
server.create('meta', { allowAnonymousAccess: false }); server.create('meta', { allowAnonymousAccess: false });
authenticateUser(); authenticateUser();
visit('/s/VzMuyEw_3WqiafcG/my-project'); await visit('/s/VzMuyEw_3WqiafcG/my-project');
click('#folder-settings-button'); await click('#folder-settings-button');
click(('.sidebar-menu .options li:contains(Share)')); await click('.sidebar-menu .options li:contains(Share)');
fillIn('#inviteEmail', 'share-test@gmail.com'); await fillIn('#inviteEmail', 'share-test@gmail.com');
click('.button-blue'); await click('.button-blue');
andThen(function () {
checkForCommonAsserts(); checkForCommonAsserts();
assert.equal(currentURL(), '/s/VzMuyEw_3WqiafcG/my-project/settings'); assert.equal(currentURL(), '/s/VzMuyEw_3WqiafcG/my-project/settings');
}); });
});
test('changing space permissions', function (assert) { test('changing space permissions', async function(assert) {
server.create('meta', { allowAnonymousAccess: false }); server.create('meta', { allowAnonymousAccess: false });
authenticateUser(); authenticateUser();
visit('/s/VzMygEw_3WrtFzto/test'); await visit('/s/VzMygEw_3WrtFzto/test');
andThen(function () { let numberOfPublicFolders = findAll('.sidebar-menu .folders-list .section .list:first a').length;
let numberOfPublicFolders = find('.sidebar-menu .folders-list .section .list:first a').length;
assert.equal(numberOfPublicFolders, 1, '1 folder listed as public'); assert.equal(numberOfPublicFolders, 1, '1 folder listed as public');
assert.equal(currentURL(), '/s/VzMygEw_3WrtFzto/test'); assert.equal(currentURL(), '/s/VzMygEw_3WrtFzto/test');
});
click('#folder-settings-button'); await click('#folder-settings-button');
click('.sidebar-menu .options li:contains(Permissions)'); await click('.sidebar-menu .options li:contains(Permissions)');
click('tr:contains(Everyone) #canView-'); await click('tr:contains(Everyone) #canView-');
click('tr:contains(Everyone) #canEdit-'); await click('tr:contains(Everyone) #canEdit-');
click('.button-blue'); await click('.button-blue');
visit('/s/VzMygEw_3WrtFzto/test'); await visit('/s/VzMygEw_3WrtFzto/test');
andThen(function () { let numberOfPublicFolders = findAll('.folders-list div:contains(EVERYONE) .list a').length;
let numberOfPublicFolders = find('.folders-list div:contains(EVERYONE) .list a').length;
assert.equal(numberOfPublicFolders, 2, '2 folder listed as public'); assert.equal(numberOfPublicFolders, 2, '2 folder listed as public');
assert.equal(currentURL(), '/s/VzMygEw_3WrtFzto/test'); assert.equal(currentURL(), '/s/VzMygEw_3WrtFzto/test');
}); });
});
test('deleting a space', function (assert) { test('deleting a space', async function(assert) {
server.create('meta', { allowAnonymousAccess: false }); server.create('meta', { allowAnonymousAccess: false });
authenticateUser(); authenticateUser();
visit('/s/VzMuyEw_3WqiafcG/my-project'); await visit('/s/VzMuyEw_3WqiafcG/my-project');
click('#folder-settings-button'); await click('#folder-settings-button');
click('.sidebar-menu .options li:contains(Delete)'); await click('.sidebar-menu .options li:contains(Delete)');
andThen(function () {
checkForCommonAsserts(); checkForCommonAsserts();
assert.equal(currentURL(), '/s/VzMuyEw_3WqiafcG/my-project/settings'); assert.equal(currentURL(), '/s/VzMuyEw_3WqiafcG/my-project/settings');
}); });
});
test('deleting a document', function (assert) { test('deleting a document', async function(assert) {
server.create('meta', { allowAnonymousAccess: false }); server.create('meta', { allowAnonymousAccess: false });
authenticateUser(); authenticateUser();
visit('/s/VzMuyEw_3WqiafcG/my-project'); await visit('/s/VzMuyEw_3WqiafcG/my-project');
andThen(function () {
let deleteButton = find('#delete-documents-button'); let deleteButton = find('#delete-documents-button');
let numberOfDocuments = find('.documents-list li'); let numberOfDocuments = find('.documents-list li');
assert.equal(numberOfDocuments.length, 2, '2 documents are displayed'); assert.equal(numberOfDocuments.length, 2, '2 documents are displayed');
assert.equal(deleteButton.length, 0, 'Delete button not displayed'); assert.equal(deleteButton.length, 0, 'Delete button not displayed');
});
click('.documents-list li:first .checkbox'); await click('.documents-list li:first .checkbox');
andThen(function () {
let deleteButton = find('#delete-documents-button'); let deleteButton = find('#delete-documents-button');
assert.equal(deleteButton.length, 1, 'Delete button displayed after selecting document'); assert.equal(deleteButton.length, 1, 'Delete button displayed after selecting document');
});
click('.actions div:contains(Delete) .flat-red'); await click('.actions div:contains(Delete) .flat-red');
andThen(function () {
let numberOfDocuments = find('.documents-list li'); let numberOfDocuments = find('.documents-list li');
assert.equal(numberOfDocuments.length, 1, '1 documents is displayed'); assert.equal(numberOfDocuments.length, 1, '1 documents is displayed');
}); });
});
test('clicking a document title displays the document', function (assert) { test('clicking a document title displays the document', async function(assert) {
server.create('meta', { allowAnonymousAccess: false }); server.create('meta', { allowAnonymousAccess: false });
authenticateUser(); authenticateUser();
visit('/s/VzMygEw_3WrtFzto/test'); await visit('/s/VzMygEw_3WrtFzto/test');
click('a .title:contains(README)'); await click('a .title:contains(README)');
andThen(function () {
findWithAssert('#add-section-button'); findWithAssert('#add-section-button');
findWithAssert('#delete-document-button'); findWithAssert('#delete-document-button');
findWithAssert('#print-document-button'); findWithAssert('#print-document-button');
@ -200,11 +171,10 @@ test('clicking a document title displays the document', function (assert) {
findWithAssert('#set-meta-button'); findWithAssert('#set-meta-button');
findWithAssert('.name.space-name'); findWithAssert('.name.space-name');
findWithAssert('.document-sidebar'); findWithAssert('.document-sidebar');
let title = find('.zone-header .title').text().trim(); let title = find('.zone-header .title').textContent.trim();
assert.equal(title, 'README', 'document displayed correctly'); assert.equal(title, 'README', 'document displayed correctly');
assert.equal(currentURL(), '/s/VzMygEw_3WrtFzto/test/d/VzMvJEw_3WqiafcI/readme'); assert.equal(currentURL(), '/s/VzMygEw_3WrtFzto/test/d/VzMvJEw_3WqiafcI/readme');
}); });
});
function checkForCommonAsserts() { function checkForCommonAsserts() {
findWithAssert('.sidebar-menu'); findWithAssert('.sidebar-menu');
@ -213,3 +183,4 @@ function checkForCommonAsserts() {
findWithAssert('.options li:contains(Permissions)'); findWithAssert('.options li:contains(Permissions)');
findWithAssert('.options li:contains(Delete)'); findWithAssert('.options li:contains(Delete)');
} }
});

View file

@ -1,3 +1,4 @@
import { click, fillIn, find, currentURL, visit } from '@ember/test-helpers';
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved. // Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
// //
// This software (Documize Community Edition) is licensed under // This software (Documize Community Edition) is licensed under
@ -9,42 +10,38 @@
// //
// https://documize.com // https://documize.com
import { test } from 'qunit'; import { module, test } from 'qunit';
import moduleForAcceptance from 'documize/tests/helpers/module-for-acceptance'; import { setupApplicationTest } from 'ember-qunit';
moduleForAcceptance('Acceptance | user profile'); module('Acceptance | user profile', function(hooks) {
setupApplicationTest(hooks);
test('visiting /profile', function (assert) { test('visiting /profile', async function(assert) {
authenticateUser(); authenticateUser();
visit('/profile'); await visit('/profile');
andThen(function () {
assert.equal(currentURL(), '/profile'); assert.equal(currentURL(), '/profile');
assert.equal(find('#firstname').val(), 'Lennex', 'Firstaname input displays correct value'); assert.equal(find('#firstname').value, 'Lennex', 'Firstaname input displays correct value');
assert.equal(find('#lastname').val(), 'Zinyando', 'Lastname input displays correct value'); assert.equal(find('#lastname').value, 'Zinyando', 'Lastname input displays correct value');
assert.equal(find('#email').val(), 'brizdigital@gmail.com', 'Email input displays correct value'); assert.equal(find('#email').value, 'brizdigital@gmail.com', 'Email input displays correct value');
});
}); });
test('changing user details and email ', function (assert) { test('changing user details and email ', async function(assert) {
authenticateUser(); authenticateUser();
visit('/profile'); await visit('/profile');
andThen(function () {
assert.equal(currentURL(), '/profile'); assert.equal(currentURL(), '/profile');
assert.equal(find('.content .name').text().trim(), 'Lennex Zinyando', 'Profile name displayed'); assert.equal(find('.content .name').textContent.trim(), 'Lennex Zinyando', 'Profile name displayed');
assert.equal(find('#firstname').val(), 'Lennex', 'Firstaname input displays correct value'); assert.equal(find('#firstname').value, 'Lennex', 'Firstaname input displays correct value');
assert.equal(find('#lastname').val(), 'Zinyando', 'Lastname input displays correct value'); assert.equal(find('#lastname').value, 'Zinyando', 'Lastname input displays correct value');
assert.equal(find('#email').val(), 'brizdigital@gmail.com', 'Email input displays correct value'); assert.equal(find('#email').value, 'brizdigital@gmail.com', 'Email input displays correct value');
});
fillIn('#firstname', 'Test'); await fillIn('#firstname', 'Test');
fillIn('#lastname', 'User'); await fillIn('#lastname', 'User');
fillIn('#email', 'test.user@domain.com'); await fillIn('#email', 'test.user@domain.com');
click('.button-blue'); await click('.button-blue');
andThen(function () {
assert.equal(currentURL(), '/s/VzMuyEw_3WqiafcG/my-project'); assert.equal(currentURL(), '/s/VzMuyEw_3WqiafcG/my-project');
assert.equal(find('.content .name').text().trim(), 'Test User', 'Profile name displayed'); assert.equal(find('.content .name').textContent.trim(), 'Test User', 'Profile name displayed');
}); });
}); });

View file

@ -1,3 +1,4 @@
import { click, fillIn, find, findAll, currentURL, visit } from '@ember/test-helpers';
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved. // Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
// //
// This software (Documize Community Edition) is licensed under // This software (Documize Community Edition) is licensed under
@ -9,99 +10,86 @@
// //
// https://documize.com // https://documize.com
import { test } from 'qunit'; import { module, test } from 'qunit';
import moduleForAcceptance from 'documize/tests/helpers/module-for-acceptance'; import { setupApplicationTest } from 'ember-qunit';
moduleForAcceptance('Acceptance | User Settings'); module('Acceptance | User Settings', function(hooks) {
setupApplicationTest(hooks);
test('visiting /settings/general', function (assert) { test('visiting /settings/general', async function(assert) {
server.create('meta', { allowAnonymousAccess: false }); server.create('meta', { allowAnonymousAccess: false });
authenticateUser(); authenticateUser();
visit('/settings/general'); await visit('/settings/general');
andThen(function () {
assert.equal(currentURL(), '/settings/general'); assert.equal(currentURL(), '/settings/general');
assert.equal(find('#siteTitle').val(), 'EmberSherpa', 'Website title input is filled in correctly'); assert.equal(find('#siteTitle').value, '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('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'); assert.equal(find('#allowAnonymousAccess').is(':checked'), false, 'Allow anonymouus checkbox is unchecked');
}); });
});
test('changing the Website title and description', function (assert) { test('changing the Website title and description', async function(assert) {
server.create('meta', { allowAnonymousAccess: false }); server.create('meta', { allowAnonymousAccess: false });
authenticateUser(); authenticateUser();
visit('/settings/general'); await visit('/settings/general');
andThen(function () { let websiteTitle = find('.content .title').textContent.trim();
let websiteTitle = find('.content .title').text().trim(); let websiteTitleInput = find('#siteTitle').value;
let websiteTitleInput = find('#siteTitle').val();
assert.equal(websiteTitleInput, websiteTitle, 'Website title is set to EmberSherpa'); assert.equal(websiteTitleInput, websiteTitle, 'Website title is set to EmberSherpa');
});
fillIn('#siteTitle', 'Documize Tests'); await fillIn('#siteTitle', 'Documize Tests');
click('.button-blue'); await click('.button-blue');
andThen(function () { let websiteTitle = find('.content .title').textContent.trim();
let websiteTitle = find('.content .title').text().trim(); let websiteTitleInput = find('#siteTitle').value;
let websiteTitleInput = find('#siteTitle').val();
assert.equal(websiteTitleInput, websiteTitle, 'Website title is set to Documize Tests'); assert.equal(websiteTitleInput, websiteTitle, 'Website title is set to Documize Tests');
}); });
});
test('visiting /settings/folders', function (assert) { test('visiting /settings/folders', async function(assert) {
server.create('meta', { allowAnonymousAccess: false }); server.create('meta', { allowAnonymousAccess: false });
authenticateUser(); authenticateUser();
visit('/settings/folders'); await visit('/settings/folders');
andThen(function () {
checkForCommonAsserts(); checkForCommonAsserts();
assert.equal(currentURL(), '/settings/folders'); assert.equal(currentURL(), '/settings/folders');
}); });
});
test('visiting /settings/users', function (assert) { test('visiting /settings/users', async function(assert) {
server.create('meta', { allowAnonymousAccess: false }); server.create('meta', { allowAnonymousAccess: false });
authenticateUser(); authenticateUser();
visit('/settings/users'); await visit('/settings/users');
andThen(function () {
checkForCommonAsserts(); checkForCommonAsserts();
findWithAssert('.user-list'); findWithAssert('.user-list');
let numberOfUsers = find('.user-list tr').length; let numberOfUsers = findAll('.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(numberOfUsers, 3, '2 Users listed');
assert.equal(currentURL(), '/settings/users'); assert.equal(currentURL(), '/settings/users');
}); });
fillIn('#newUserFirstname', 'Test'); test('add a new user', async function(assert) {
fillIn('#newUserLastname', 'User'); server.create('meta', { allowAnonymousAccess: false });
fillIn('#newUserEmail', 'test.user@domain.com'); authenticateUser();
click('.button-blue'); await visit('/settings/users');
andThen(function () { checkForCommonAsserts();
let numberOfUsers = find('.user-list tr').length; 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(numberOfUsers, 4, '3 Users listed');
assert.equal(currentURL(), '/settings/users'); assert.equal(currentURL(), '/settings/users');
}); });
});
function checkForCommonAsserts() { function checkForCommonAsserts() {
findWithAssert('.sidebar-menu'); findWithAssert('.sidebar-menu');
findWithAssert('#user-button'); findWithAssert('#user-button');
findWithAssert('#accounts-button'); findWithAssert('#accounts-button');
findWithAssert('.info .title'); findWithAssert('.info .title');
} }
});

View file

@ -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'; import hbs from 'htmlbars-inline-precompile';
moduleForComponent('is-one-of', 'helper:action-type', { module('helper:action-type', function(hooks) {
integration: true setupRenderingTest(hooks);
});
// Replace this with your real tests. // Replace this with your real tests.
test('it renders', function(assert) { test('it renders', async function(assert) {
this.set('inputValue', '1234'); this.set('inputValue', '1234');
this.render(hbs`{{is-one-of 1 1 2 3}}`); await render(hbs`{{is-one-of 1 1 2 3}}`);
assert.equal(this.$().text().trim(), 'true'); assert.equal(find('*').textContent.trim(), 'true');
});
}); });

View file

@ -1,3 +1,4 @@
import { module, test } from 'qunit';
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved. // Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
// //
// This software (Documize Community Edition) is licensed under // This software (Documize Community Edition) is licensed under
@ -9,15 +10,14 @@
// //
// https://documize.com // https://documize.com
import { moduleFor, test } from 'ember-qunit'; import { setupTest } from 'ember-qunit';
moduleFor('service:local-storage', 'Unit | Service | local storage', { module('Unit | Service | local storage', function(hooks) {
// Specify the other units that are required for this test. setupTest(hooks);
// needs: ['service:foo']
});
// Replace this with your real tests. // Replace this with your real tests.
test('it exists', function (assert) { test('it exists', function (assert) {
let service = this.subject(); let service = this.owner.lookup('service:local-storage');
assert.ok(service); assert.ok(service);
}); });
});