mirror of
https://github.com/documize/community.git
synced 2025-08-09 07:25:23 +02:00
Use app meta factory in tests
This commit is contained in:
parent
f9fc236e27
commit
81ecb75391
7 changed files with 62 additions and 40 deletions
|
@ -5,23 +5,22 @@ export default function() {
|
||||||
this.namespace = 'api'; // make this `api`, for example, if your API is namespaced
|
this.namespace = 'api'; // make this `api`, for example, if your API is namespaced
|
||||||
// this.timing = 400; // delay for each request, automatically set to 0 during testing
|
// this.timing = 400; // delay for each request, automatically set to 0 during testing
|
||||||
|
|
||||||
this.get('/public/meta', function() {
|
// this.get('/public/meta', function() {
|
||||||
return {
|
|
||||||
"orgId": "VzMuyEw_3WqiafcD",
|
|
||||||
"title": "EmberSherpa",
|
|
||||||
"message": "This Documize instance contains all our team documentation",
|
|
||||||
"url": "",
|
|
||||||
"allowAnonymousAccess": false,
|
|
||||||
"version": "11.2"
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
// this.get('/public/meta', function(db) {
|
|
||||||
// return {
|
// return {
|
||||||
// meta: db.meta;
|
// "orgId": "VzMuyEw_3WqiafcD",
|
||||||
|
// "title": "EmberSherpa",
|
||||||
|
// "message": "This Documize instance contains all our team documentation",
|
||||||
|
// "url": "",
|
||||||
|
// "allowAnonymousAccess": false,
|
||||||
|
// "version": "11.2"
|
||||||
// };
|
// };
|
||||||
// });
|
// });
|
||||||
|
|
||||||
|
this.get('/public/meta', function(db) {
|
||||||
|
console.log(db.meta[0]);
|
||||||
|
return db.meta[0];
|
||||||
|
});
|
||||||
|
|
||||||
this.get('/public/validate', function(db, request) {
|
this.get('/public/validate', function(db, request) {
|
||||||
let serverToken = request.queryParams.token;
|
let serverToken = request.queryParams.token;
|
||||||
let token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJkb21haW4iOiIiLCJleHAiOjE0NjQwMjM2NjcsImlzcyI6IkRvY3VtaXplIiwib3JnIjoiVnpNdXlFd18zV3FpYWZjRCIsInN1YiI6IndlYmFwcCIsInVzZXIiOiJWek11eUV3XzNXcWlhZmNFIn0.NXZ6bo8mtvdZF_b9HavbidVUJqhmBA1zr0fSAPvbah0";
|
let token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJkb21haW4iOiIiLCJleHAiOjE0NjQwMjM2NjcsImlzcyI6IkRvY3VtaXplIiwib3JnIjoiVnpNdXlFd18zV3FpYWZjRCIsInN1YiI6IndlYmFwcCIsInVzZXIiOiJWek11eUV3XzNXcWlhZmNFIn0.NXZ6bo8mtvdZF_b9HavbidVUJqhmBA1zr0fSAPvbah0";
|
||||||
|
|
|
@ -1,15 +1,19 @@
|
||||||
/*
|
|
||||||
This is an example factory definition.
|
|
||||||
|
|
||||||
Create more files in this directory to define additional factories.
|
|
||||||
*/
|
|
||||||
import Mirage from 'ember-cli-mirage';
|
import Mirage from 'ember-cli-mirage';
|
||||||
|
|
||||||
|
// export default Mirage.Factory.extend({
|
||||||
|
// orgId() { return 'VzMuyEw_3WqiafcD'; },
|
||||||
|
// title() { return 'EmberSherpa'; },
|
||||||
|
// message() { return 'This Documize instance contains all our team documentation'; },
|
||||||
|
// url() { return ''; },
|
||||||
|
// allowAnonymousAccess() { return false; },
|
||||||
|
// version() { return '11.2'; }
|
||||||
|
// });
|
||||||
|
|
||||||
export default Mirage.Factory.extend({
|
export default Mirage.Factory.extend({
|
||||||
orgId() { return "VzMuyEw_3WqiafcD"; },
|
"orgId": "VzMuyEw_3WqiafcD",
|
||||||
title() { return "EmberSherpa"; },
|
"title": "EmberSherpa",
|
||||||
message() { return "This Documize instance contains all our team documentation"; },
|
"message": "This Documize instance contains all our team documentation",
|
||||||
url() { return ""; },
|
"url": "",
|
||||||
allowAnonymousAccess() { return false; },
|
"allowAnonymousAccess": false,
|
||||||
version() { return "11.2"; }
|
"version": "11.2"
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
import { test, skip } from 'qunit';
|
import { test } from 'qunit';
|
||||||
import moduleForAcceptance from 'documize/tests/helpers/module-for-acceptance';
|
import moduleForAcceptance from 'documize/tests/helpers/module-for-acceptance';
|
||||||
|
|
||||||
moduleForAcceptance('Acceptance | Anon access disabled');
|
moduleForAcceptance('Acceptance | Anon access disabled');
|
||||||
|
|
||||||
|
|
||||||
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', function(assert) {
|
||||||
|
server.create('meta', { allowAnonymousAccess: false });
|
||||||
visit('/');
|
visit('/');
|
||||||
|
|
||||||
andThen(function() {
|
andThen(function() {
|
||||||
|
|
|
@ -1,24 +1,32 @@
|
||||||
import { test, skip } from 'qunit';
|
import { test } from 'qunit';
|
||||||
import moduleForAcceptance from 'documize/tests/helpers/module-for-acceptance';
|
import moduleForAcceptance from 'documize/tests/helpers/module-for-acceptance';
|
||||||
|
|
||||||
moduleForAcceptance('Acceptance | Anon access enabled');
|
moduleForAcceptance('Acceptance | Anon access enabled');
|
||||||
|
|
||||||
skip('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', function(assert) {
|
||||||
server.create('app-meta', { allowAnonymousAccess: true });
|
server.create('meta', { allowAnonymousAccess: true });
|
||||||
visit('/');
|
visit('/');
|
||||||
|
|
||||||
return pauseTest();
|
|
||||||
|
|
||||||
andThen(function() {
|
andThen(function() {
|
||||||
assert.equal(currentURL(), '/s/VzMuyEw_3WqiafcG/my-project');
|
assert.equal(find('.login').length, 1, 'Login button is displayed');
|
||||||
|
assert.equal(find('.document-card').length, 2, '2 document displayed');
|
||||||
|
assert.equal(currentURL(), '/s/VzMuyEw_3WqiafcG/my-project', 'Dashboard and public spaces are displayed without being signed in');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
skip('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', function(assert) {
|
||||||
server.create('app-meta', { allowAnonymousAccess: true });
|
server.create('meta', { allowAnonymousAccess: true });
|
||||||
|
visit('/');
|
||||||
|
|
||||||
|
andThen(function() {
|
||||||
|
assert.equal(find('.login').length, 1, 'Login button is displayed');
|
||||||
|
assert.equal(currentURL(), '/s/VzMuyEw_3WqiafcG/my-project', 'Dashboard displayed without being signed in');
|
||||||
|
});
|
||||||
|
|
||||||
userLogin();
|
userLogin();
|
||||||
|
|
||||||
andThen(function() {
|
andThen(function() {
|
||||||
assert.equal(currentURL(), '/s/VzMuyEw_3WqiafcG/my-project');
|
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');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -4,6 +4,7 @@ import moduleForAcceptance from 'documize/tests/helpers/module-for-acceptance';
|
||||||
moduleForAcceptance('Acceptance | Authentication');
|
moduleForAcceptance('Acceptance | Authentication');
|
||||||
|
|
||||||
test('visiting /auth/login and logging in', function(assert) {
|
test('visiting /auth/login and logging in', function(assert) {
|
||||||
|
server.create('meta', { allowAnonymousAccess: false });
|
||||||
visit('/auth/login');
|
visit('/auth/login');
|
||||||
|
|
||||||
fillIn('#authEmail', 'brizdigital@gmail.com');
|
fillIn('#authEmail', 'brizdigital@gmail.com');
|
||||||
|
@ -16,10 +17,10 @@ test('visiting /auth/login and logging in', function(assert) {
|
||||||
});
|
});
|
||||||
|
|
||||||
skip('logging out a user', function(assert) {
|
skip('logging out a user', function(assert) {
|
||||||
|
server.create('meta', { allowAnonymousAccess: false });
|
||||||
userLogin();
|
userLogin();
|
||||||
|
|
||||||
visit('/auth/logout'); // logs a user out
|
visit('/auth/logout'); // logs a user out
|
||||||
return pauseTest();
|
|
||||||
|
|
||||||
andThen(function() {
|
andThen(function() {
|
||||||
assert.equal(currentURL(), '/');
|
assert.equal(currentURL(), '/');
|
||||||
|
|
|
@ -4,6 +4,7 @@ import moduleForAcceptance from 'documize/tests/helpers/module-for-acceptance';
|
||||||
moduleForAcceptance('Acceptance | documents space');
|
moduleForAcceptance('Acceptance | documents space');
|
||||||
|
|
||||||
test('Adding a new folder space', function(assert) {
|
test('Adding a new folder space', function(assert) {
|
||||||
|
server.create('meta', { allowAnonymousAccess: false });
|
||||||
userLogin();
|
userLogin();
|
||||||
visit('/s/VzMuyEw_3WqiafcG/my-project');
|
visit('/s/VzMuyEw_3WqiafcG/my-project');
|
||||||
|
|
||||||
|
@ -24,6 +25,7 @@ test('Adding a new folder space', function(assert) {
|
||||||
});
|
});
|
||||||
|
|
||||||
skip('Adding a document to a space', function(assert) {
|
skip('Adding a document to a space', function(assert) {
|
||||||
|
server.create('meta', { allowAnonymousAccess: false });
|
||||||
userLogin();
|
userLogin();
|
||||||
visit('/s/VzMuyEw_3WqiafcG/my-project');
|
visit('/s/VzMuyEw_3WqiafcG/my-project');
|
||||||
|
|
||||||
|
@ -37,7 +39,6 @@ skip('Adding a document to a space', function(assert) {
|
||||||
click('#start-document-button');
|
click('#start-document-button');
|
||||||
waitToAppear('.drop-content');
|
waitToAppear('.drop-content');
|
||||||
click('.drop-content');
|
click('.drop-content');
|
||||||
return pauseTest();
|
|
||||||
|
|
||||||
andThen(function() {
|
andThen(function() {
|
||||||
assert.equal(currentURL(), 's/V0Vy5Uw_3QeDAMW9/test-folder');
|
assert.equal(currentURL(), 's/V0Vy5Uw_3QeDAMW9/test-folder');
|
||||||
|
@ -45,6 +46,7 @@ skip('Adding a document to a space', function(assert) {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('visiting space settings page', function(assert) {
|
test('visiting space settings page', function(assert) {
|
||||||
|
server.create('meta', { allowAnonymousAccess: false });
|
||||||
userLogin();
|
userLogin();
|
||||||
visit('/s/VzMuyEw_3WqiafcG/my-project');
|
visit('/s/VzMuyEw_3WqiafcG/my-project');
|
||||||
|
|
||||||
|
@ -58,6 +60,7 @@ test('visiting space settings page', function(assert) {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('changing space name', function(assert) {
|
test('changing space name', function(assert) {
|
||||||
|
server.create('meta', { allowAnonymousAccess: false });
|
||||||
userLogin();
|
userLogin();
|
||||||
visit('/s/VzMuyEw_3WqiafcG/my-project/settings');
|
visit('/s/VzMuyEw_3WqiafcG/my-project/settings');
|
||||||
|
|
||||||
|
@ -69,11 +72,11 @@ test('changing space name', function(assert) {
|
||||||
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');
|
||||||
// return pauseTest();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test('sharing a space', function(assert) {
|
test('sharing a space', function(assert) {
|
||||||
|
server.create('meta', { allowAnonymousAccess: false });
|
||||||
userLogin();
|
userLogin();
|
||||||
visit('/s/VzMuyEw_3WqiafcG/my-project/settings');
|
visit('/s/VzMuyEw_3WqiafcG/my-project/settings');
|
||||||
|
|
||||||
|
@ -90,8 +93,8 @@ test('sharing a space', function(assert) {
|
||||||
|
|
||||||
// Test will pass after moving to factories
|
// Test will pass after moving to factories
|
||||||
test('changing space permissions', function(assert) {
|
test('changing space permissions', function(assert) {
|
||||||
|
server.create('meta', { allowAnonymousAccess: false });
|
||||||
userLogin();
|
userLogin();
|
||||||
return pauseTest();
|
|
||||||
andThen(function() {
|
andThen(function() {
|
||||||
let numberOfPublicFolders = find('.folders-list div:first .list a').length;
|
let numberOfPublicFolders = find('.folders-list div:first .list a').length;
|
||||||
assert.equal(numberOfPublicFolders, 1, '1 folder listed as public');
|
assert.equal(numberOfPublicFolders, 1, '1 folder listed as public');
|
||||||
|
@ -115,6 +118,7 @@ test('changing space permissions', function(assert) {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('deleting a space', function(assert) {
|
test('deleting a space', function(assert) {
|
||||||
|
server.create('meta', { allowAnonymousAccess: false });
|
||||||
userLogin();
|
userLogin();
|
||||||
visit('/s/VzMuyEw_3WqiafcG/my-project/settings');
|
visit('/s/VzMuyEw_3WqiafcG/my-project/settings');
|
||||||
|
|
||||||
|
@ -127,6 +131,7 @@ test('deleting a space', function(assert) {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('deleting a document', function(assert) {
|
test('deleting a document', function(assert) {
|
||||||
|
server.create('meta', { allowAnonymousAccess: false });
|
||||||
userLogin();
|
userLogin();
|
||||||
visit('/s/VzMuyEw_3WqiafcG/my-project');
|
visit('/s/VzMuyEw_3WqiafcG/my-project');
|
||||||
|
|
||||||
|
@ -148,7 +153,6 @@ test('deleting a document', function(assert) {
|
||||||
|
|
||||||
waitToAppear('.drop-content');
|
waitToAppear('.drop-content');
|
||||||
click('.flat-red');
|
click('.flat-red');
|
||||||
return pauseTest();
|
|
||||||
|
|
||||||
andThen(function() {
|
andThen(function() {
|
||||||
let deleteButton = find('#delete-documents-button');
|
let deleteButton = find('#delete-documents-button');
|
||||||
|
|
|
@ -4,6 +4,7 @@ import moduleForAcceptance from 'documize/tests/helpers/module-for-acceptance';
|
||||||
moduleForAcceptance('Acceptance | User Settings');
|
moduleForAcceptance('Acceptance | User Settings');
|
||||||
|
|
||||||
test('visiting /settings/general', function(assert) {
|
test('visiting /settings/general', function(assert) {
|
||||||
|
server.create('meta', { allowAnonymousAccess: false });
|
||||||
userLogin();
|
userLogin();
|
||||||
visit('/settings/general');
|
visit('/settings/general');
|
||||||
|
|
||||||
|
@ -15,7 +16,8 @@ test('visiting /settings/general', function(assert) {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test('changing the Website title and descripttion', function(assert) {
|
test('changing the Website title and description', function(assert) {
|
||||||
|
server.create('meta', { allowAnonymousAccess: false });
|
||||||
userLogin();
|
userLogin();
|
||||||
visit('/settings/general');
|
visit('/settings/general');
|
||||||
|
|
||||||
|
@ -36,6 +38,7 @@ test('changing the Website title and descripttion', function(assert) {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('visiting /settings/folders', function(assert) {
|
test('visiting /settings/folders', function(assert) {
|
||||||
|
server.create('meta', { allowAnonymousAccess: false });
|
||||||
userLogin();
|
userLogin();
|
||||||
visit('/settings/folders');
|
visit('/settings/folders');
|
||||||
|
|
||||||
|
@ -46,6 +49,7 @@ test('visiting /settings/folders', function(assert) {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('visiting /settings/users', function(assert) {
|
test('visiting /settings/users', function(assert) {
|
||||||
|
server.create('meta', { allowAnonymousAccess: false });
|
||||||
userLogin();
|
userLogin();
|
||||||
visit('/settings/users');
|
visit('/settings/users');
|
||||||
|
|
||||||
|
@ -59,6 +63,7 @@ test('visiting /settings/users', function(assert) {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('add a new user', function(assert) {
|
test('add a new user', function(assert) {
|
||||||
|
server.create('meta', { allowAnonymousAccess: false });
|
||||||
userLogin();
|
userLogin();
|
||||||
visit('/settings/users');
|
visit('/settings/users');
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue