1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-08-07 22:45:24 +02:00

Use app meta factory in tests

This commit is contained in:
zinyando 2016-05-31 14:34:42 +02:00
parent f9fc236e27
commit 81ecb75391
7 changed files with 62 additions and 40 deletions

View file

@ -5,23 +5,22 @@ export default function() {
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.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) {
// this.get('/public/meta', function() {
// 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) {
let serverToken = request.queryParams.token;
let token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJkb21haW4iOiIiLCJleHAiOjE0NjQwMjM2NjcsImlzcyI6IkRvY3VtaXplIiwib3JnIjoiVnpNdXlFd18zV3FpYWZjRCIsInN1YiI6IndlYmFwcCIsInVzZXIiOiJWek11eUV3XzNXcWlhZmNFIn0.NXZ6bo8mtvdZF_b9HavbidVUJqhmBA1zr0fSAPvbah0";

View file

@ -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';
// 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({
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"; }
"orgId": "VzMuyEw_3WqiafcD",
"title": "EmberSherpa",
"message": "This Documize instance contains all our team documentation",
"url": "",
"allowAnonymousAccess": false,
"version": "11.2"
});

View file

@ -1,10 +1,11 @@
import { test, skip } from 'qunit';
import { test } from 'qunit';
import moduleForAcceptance from 'documize/tests/helpers/module-for-acceptance';
moduleForAcceptance('Acceptance | Anon access disabled');
test('visiting / when not authenticated and with { allowAnonymousAccess: false } takes user to login', function(assert) {
server.create('meta', { allowAnonymousAccess: false });
visit('/');
andThen(function() {

View file

@ -1,24 +1,32 @@
import { test, skip } from 'qunit';
import { test } from 'qunit';
import moduleForAcceptance from 'documize/tests/helpers/module-for-acceptance';
moduleForAcceptance('Acceptance | Anon access enabled');
skip('visiting / when not authenticated and with { allowAnonymousAccess: true } takes user to folder view', function(assert) {
server.create('app-meta', { allowAnonymousAccess: true });
test('visiting / when not authenticated and with { allowAnonymousAccess: true } takes user to folder view', function(assert) {
server.create('meta', { allowAnonymousAccess: true });
visit('/');
return pauseTest();
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) {
server.create('app-meta', { allowAnonymousAccess: true });
test('visiting / when authenticated and with { allowAnonymousAccess: true } takes user to dashboard', function(assert) {
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();
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');
});
});

View file

@ -4,6 +4,7 @@ import moduleForAcceptance from 'documize/tests/helpers/module-for-acceptance';
moduleForAcceptance('Acceptance | Authentication');
test('visiting /auth/login and logging in', function(assert) {
server.create('meta', { allowAnonymousAccess: false });
visit('/auth/login');
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) {
server.create('meta', { allowAnonymousAccess: false });
userLogin();
visit('/auth/logout'); // logs a user out
return pauseTest();
andThen(function() {
assert.equal(currentURL(), '/');

View file

@ -4,6 +4,7 @@ import moduleForAcceptance from 'documize/tests/helpers/module-for-acceptance';
moduleForAcceptance('Acceptance | documents space');
test('Adding a new folder space', function(assert) {
server.create('meta', { allowAnonymousAccess: false });
userLogin();
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) {
server.create('meta', { allowAnonymousAccess: false });
userLogin();
visit('/s/VzMuyEw_3WqiafcG/my-project');
@ -37,7 +39,6 @@ skip('Adding a document to a space', function(assert) {
click('#start-document-button');
waitToAppear('.drop-content');
click('.drop-content');
return pauseTest();
andThen(function() {
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) {
server.create('meta', { allowAnonymousAccess: false });
userLogin();
visit('/s/VzMuyEw_3WqiafcG/my-project');
@ -58,6 +60,7 @@ test('visiting space settings page', function(assert) {
});
test('changing space name', function(assert) {
server.create('meta', { allowAnonymousAccess: false });
userLogin();
visit('/s/VzMuyEw_3WqiafcG/my-project/settings');
@ -69,11 +72,11 @@ test('changing space name', function(assert) {
checkForCommonAsserts();
assert.equal(spaceName, 'Test Space', 'Space name has been changed');
assert.equal(currentURL(), '/s/VzMuyEw_3WqiafcG/my-project/settings');
// return pauseTest();
});
});
test('sharing a space', function(assert) {
server.create('meta', { allowAnonymousAccess: false });
userLogin();
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('changing space permissions', function(assert) {
server.create('meta', { allowAnonymousAccess: false });
userLogin();
return pauseTest();
andThen(function() {
let numberOfPublicFolders = find('.folders-list div:first .list a').length;
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) {
server.create('meta', { allowAnonymousAccess: false });
userLogin();
visit('/s/VzMuyEw_3WqiafcG/my-project/settings');
@ -127,6 +131,7 @@ test('deleting a space', function(assert) {
});
test('deleting a document', function(assert) {
server.create('meta', { allowAnonymousAccess: false });
userLogin();
visit('/s/VzMuyEw_3WqiafcG/my-project');
@ -148,7 +153,6 @@ test('deleting a document', function(assert) {
waitToAppear('.drop-content');
click('.flat-red');
return pauseTest();
andThen(function() {
let deleteButton = find('#delete-documents-button');

View file

@ -4,6 +4,7 @@ import moduleForAcceptance from 'documize/tests/helpers/module-for-acceptance';
moduleForAcceptance('Acceptance | User Settings');
test('visiting /settings/general', function(assert) {
server.create('meta', { allowAnonymousAccess: false });
userLogin();
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();
visit('/settings/general');
@ -36,6 +38,7 @@ test('changing the Website title and descripttion', function(assert) {
});
test('visiting /settings/folders', function(assert) {
server.create('meta', { allowAnonymousAccess: false });
userLogin();
visit('/settings/folders');
@ -46,6 +49,7 @@ test('visiting /settings/folders', function(assert) {
});
test('visiting /settings/users', function(assert) {
server.create('meta', { allowAnonymousAccess: false });
userLogin();
visit('/settings/users');
@ -59,6 +63,7 @@ test('visiting /settings/users', function(assert) {
});
test('add a new user', function(assert) {
server.create('meta', { allowAnonymousAccess: false });
userLogin();
visit('/settings/users');