From 663995b60d0cba4368fafcab8b1c8b113c09bcb9 Mon Sep 17 00:00:00 2001 From: zinyando Date: Tue, 12 Jul 2016 14:37:36 +0200 Subject: [PATCH 01/11] Add factories --- app/mirage/factories/document.js | 4 ++++ app/mirage/factories/folder-permission.js | 8 +++++++ app/mirage/factories/organization.js | 13 +++++++++++ app/mirage/factories/permission.js | 12 +++++----- app/mirage/factories/user.js | 27 +++++++++++++++++++++++ 5 files changed, 58 insertions(+), 6 deletions(-) create mode 100644 app/mirage/factories/document.js create mode 100644 app/mirage/factories/folder-permission.js create mode 100644 app/mirage/factories/organization.js create mode 100644 app/mirage/factories/user.js diff --git a/app/mirage/factories/document.js b/app/mirage/factories/document.js new file mode 100644 index 00000000..85018979 --- /dev/null +++ b/app/mirage/factories/document.js @@ -0,0 +1,4 @@ +import { Factory } from 'ember-cli-mirage'; + +export default Factory.extend({ +}); diff --git a/app/mirage/factories/folder-permission.js b/app/mirage/factories/folder-permission.js new file mode 100644 index 00000000..457da316 --- /dev/null +++ b/app/mirage/factories/folder-permission.js @@ -0,0 +1,8 @@ +import { Factory, faker } from 'ember-cli-mirage'; + +export default Factory.extend({ + "folderId": faker.list.cycle("VzMuyEw_3WqiafcG", "VzMygEw_3WrtFzto"), + "userId": faker.list.cycle("VzMuyEw_3WqiafcE", "VzMuyEw_3WqiafcE"), + "canView": true, + "canEdit": true +}); diff --git a/app/mirage/factories/organization.js b/app/mirage/factories/organization.js new file mode 100644 index 00000000..e6885593 --- /dev/null +++ b/app/mirage/factories/organization.js @@ -0,0 +1,13 @@ +import { Factory } from 'ember-cli-mirage'; + +export default Factory.extend({ + "id": "VzMuyEw_3WqiafcD", + "created": "2016-05-11T15:08:24Z", + "revised": "2016-05-23T11:23:20Z", + "title": "EmberSherpa", + "message": "This Documize instance contains all our team documentation", + "url": "", + "domain": "", + "email": "brizdigital@gmail.com", + "allowAnonymousAccess": false +}); diff --git a/app/mirage/factories/permission.js b/app/mirage/factories/permission.js index 96786c0e..cde20ac0 100644 --- a/app/mirage/factories/permission.js +++ b/app/mirage/factories/permission.js @@ -1,19 +1,19 @@ // Copyright 2016 Documize Inc. . All rights reserved. // -// This software (Documize Community Edition) is licensed under +// This software (Documize Community Edition) is licensed under // GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html // // You can operate outside the AGPL restrictions by purchasing // Documize Enterprise Edition and obtaining a commercial license -// by contacting . +// by contacting . // // https://documize.com import Mirage, { faker } from 'ember-cli-mirage'; export default Mirage.Factory.extend({ - "folderId": faker.list.cycle('V0Vy5Uw_3QeDAMW9', 'VzMuyEw_3WqiafcG', 'VzMygEw_3WrtFzto', 'VzMygEw_3WrtFzto'), - "userId": faker.list.cycle('VzMuyEw_3WqiafcE', 'VzMuyEw_3WqiafcE', 'VzMuyEw_3WqiafcE', ''), + "folderId": faker.list.cycle('V0Vy5Uw_3QeDAMW9', 'VzMuyEw_3WqiafcG', 'VzMygEw_3WrtFzto', 'VzMygEw_3WrtFzto', "VzMygEw_3WrtFzto"), + "userId": faker.list.cycle('VzMuyEw_3WqiafcE', 'VzMuyEw_3WqiafcE', 'VzMuyEw_3WqiafcE', '', 0), "canView": true, - "canEdit": faker.list.cycle(true, true, true, false) -}); \ No newline at end of file + "canEdit": faker.list.cycle(true, true, true, false, false) +}); diff --git a/app/mirage/factories/user.js b/app/mirage/factories/user.js new file mode 100644 index 00000000..2809ad84 --- /dev/null +++ b/app/mirage/factories/user.js @@ -0,0 +1,27 @@ +import { Factory, faker } from 'ember-cli-mirage'; + +export default Factory.extend({ + "id": faker.list.cycle("VzMyp0w_3WrtFztq", "VzMuyEw_3WqiafcE"), + "created": faker.list.cycle("2016-05-11T13:24:55Z", "2016-05-11T15:08:24Z"), + "revised": faker.list.cycle("2016-05-11T13:33:47Z", "2016-05-11T15:08:24Z"), + "firstname": faker.list.cycle("Len", "Lennex"), + "lastname": faker.list.cycle("Random", "Zinyando"), + "email": faker.list.cycle("zinyando@gmail.com", "brizdigital@gmail.com"), + "initials": faker.list.cycle("LR", "LZ"), + "active": true, + "editor": true, + "admin": faker.list.cycle(false, true), + "accounts": [{ + "id": faker.list.cycle("VzMyp0w_3WrtFztr", "VzMuyEw_3WqiafcF"), + "created": faker.list.cycle("2016-05-11T13:24:55Z", "2016-05-11T15:08:24Z"), + "revised": faker.list.cycle("2016-05-11T13:24:55Z", "2016-05-11T15:08:24Z"), + "admin": faker.list.cycle(false, true), + "editor": faker.list.cycle(true, true), + "userId": faker.list.cycle("VzMyp0w_3WrtFztq", "VzMuyEw_3WqiafcE"), + "orgId": faker.list.cycle("VzMuyEw_3WqiafcD", "VzMuyEw_3WqiafcD"), + "company": "EmberSherpa", + "title": "EmberSherpa", + "message": "This Documize instance contains all our team documentation", + "domain": "" + }] +}); From a215a05a883ad1a555c5eec51389ad9123576aed Mon Sep 17 00:00:00 2001 From: zinyando Date: Tue, 12 Jul 2016 14:38:33 +0200 Subject: [PATCH 02/11] Refactor mirage config and tests to use new factories --- app/mirage/config.js | 311 +++--------------- .../acceptance/anon-access-enabled-test.js | 9 +- app/tests/acceptance/documents-space-test.js | 7 +- app/tests/acceptance/user-profile-test.js | 8 +- app/tests/acceptance/user-settings-test.js | 10 +- 5 files changed, 69 insertions(+), 276 deletions(-) diff --git a/app/mirage/config.js b/app/mirage/config.js index 40501d1f..84e4646e 100644 --- a/app/mirage/config.js +++ b/app/mirage/config.js @@ -13,48 +13,6 @@ export default function () { return schema.db.meta[0]; }); - this.get('/public/validate', function (schema, request) { - let serverToken = request.queryParams.token; - let token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJkb21haW4iOiIiLCJleHAiOjE0NjQwMjM2NjcsImlzcyI6IkRvY3VtaXplIiwib3JnIjoiVnpNdXlFd18zV3FpYWZjRCIsInN1YiI6IndlYmFwcCIsInVzZXIiOiJWek11eUV3XzNXcWlhZmNFIn0.NXZ6bo8mtvdZF_b9HavbidVUJqhmBA1zr0fSAPvbah0"; - - if (token = serverToken) { - return { - "id": "VzMuyEw_3WqiafcE", - "created": "2016-05-11T15:08:24Z", - "revised": "2016-05-11T15:08:24Z", - "firstname": "Lennex", - "lastname": "Zinyando", - "email": "brizdigital@gmail.com", - "initials": "LZ", - "active": true, - "editor": true, - "admin": true, - "accounts": [{ - "id": "VzMuyEw_3WqiafcF", - "created": "2016-05-11T15:08:24Z", - "revised": "2016-05-11T15:08:24Z", - "admin": true, - "editor": true, - "userId": "VzMuyEw_3WqiafcE", - "orgId": "VzMuyEw_3WqiafcD", - "company": "EmberSherpa", - "title": "EmberSherpa", - "message": "This Documize instance contains all our team documentation", - "domain": "" - }] - }; - } - }); - - this.get('/users/0/permissions', function () { - return [{ - "folderId": "VzMygEw_3WrtFzto", - "userId": "", - "canView": true, - "canEdit": false - }]; - }); - this.get('/templates', function () { return []; }); @@ -90,7 +48,9 @@ export default function () { "tags": "", "template": false }]; - } else if (folder_id = "VzMygEw_3WrtFzto") { + } + + if (folder_id = "VzMygEw_3WrtFzto") { return { "id": "VzMygEw_3WrtFzto", "created": "2016-05-11T13:24:17Z", @@ -100,7 +60,9 @@ export default function () { "userId": "VzMuyEw_3WqiafcE", "folderType": 1 }; - } else if (folder_id = 'V0Vy5Uw_3QeDAMW9') { + } + + if (folder_id = 'V0Vy5Uw_3QeDAMW9') { return null; } }); @@ -110,8 +72,9 @@ export default function () { }); this.post('/folders', function (schema, request) { + debugger; var name = JSON.parse(request.requestBody).name; - let newFolder = { + let folder = { "id": "V0Vy5Uw_3QeDAMW9", "created": "2016-05-25T09:39:49Z", "revised": "2016-05-25T09:39:49Z", @@ -121,43 +84,19 @@ export default function () { "folderType": 2 }; - let folder = schema.db.folders.insert(newFolder); - return folder; + return schema.db.folders.insert(folder); }); this.post('/public/authenticate', (schema, request) => { let authorization = request.requestHeaders.Authorization; let expectedAuthorization = "Basic OmJyaXpkaWdpdGFsQGdtYWlsLmNvbTp6aW55YW5kbzEyMw=="; + let token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJkb21haW4iOiIiLCJleHAiOjE0NjQwMjM2NjcsImlzcyI6IkRvY3VtaXplIiwib3JnIjoiVnpNdXlFd18zV3FpYWZjRCIsInN1YiI6IndlYmFwcCIsInVzZXIiOiJWek11eUV3XzNXcWlhZmNFIn0.NXZ6bo8mtvdZF_b9HavbidVUJqhmBA1zr0fSAPvbah0"; + let user = schema.db.users.where({ id: "VzMuyEw_3WqiafcE" }); if (expectedAuthorization === authorization) { - console.log("SSO login success"); return { - "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJkb21haW4iOiIiLCJleHAiOjE0NjQwMjM2NjcsImlzcyI6IkRvY3VtaXplIiwib3JnIjoiVnpNdXlFd18zV3FpYWZjRCIsInN1YiI6IndlYmFwcCIsInVzZXIiOiJWek11eUV3XzNXcWlhZmNFIn0.NXZ6bo8mtvdZF_b9HavbidVUJqhmBA1zr0fSAPvbah0", - "user": { - "id": "VzMuyEw_3WqiafcE", - "created": "2016-05-11T15:08:24Z", - "revised": "2016-05-11T15:08:24Z", - "firstname": "Lennex", - "lastname": "Zinyando", - "email": "brizdigital@gmail.com", - "initials": "LZ", - "active": true, - "editor": true, - "admin": true, - "accounts": [{ - "id": "VzMuyEw_3WqiafcF", - "created": "2016-05-11T15:08:24Z", - "revised": "2016-05-11T15:08:24Z", - "admin": true, - "editor": true, - "userId": "VzMuyEw_3WqiafcE", - "orgId": "VzMuyEw_3WqiafcD", - "company": "EmberSherpa", - "title": "EmberSherpa", - "message": "This Documize instance contains all our team documentation", - "domain": "" - }] - } + "token": `${token}`, + "user": user[0] }; } @@ -166,78 +105,27 @@ export default function () { } return { - "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJkb21haW4iOiIiLCJleHAiOjE0NjQwMjM2NjcsImlzcyI6IkRvY3VtaXplIiwib3JnIjoiVnpNdXlFd18zV3FpYWZjRCIsInN1YiI6IndlYmFwcCIsInVzZXIiOiJWek11eUV3XzNXcWlhZmNFIn0.NXZ6bo8mtvdZF_b9HavbidVUJqhmBA1zr0fSAPvbah0", - "user": { - "id": "VzMuyEw_3WqiafcE", - "created": "2016-05-11T15:08:24Z", - "revised": "2016-05-11T15:08:24Z", - "firstname": "Lennex", - "lastname": "Zinyando", - "email": "brizdigital@gmail.com", - "initials": "LZ", - "active": true, - "editor": true, - "admin": true, - "accounts": [{ - "id": "VzMuyEw_3WqiafcF", - "created": "2016-05-11T15:08:24Z", - "revised": "2016-05-11T15:08:24Z", - "admin": true, - "editor": true, - "userId": "VzMuyEw_3WqiafcE", - "orgId": "VzMuyEw_3WqiafcD", - "company": "EmberSherpa", - "title": "EmberSherpa", - "message": "This Documize instance contains all our team documentation", - "domain": "" - }] - } + "token": `${token}`, + "user": user[0] }; }); - this.get('/users/VzMuyEw_3WqiafcE/permissions', (schema) => { - return schema.db.permissions; + this.get('/users/:id/permissions', (schema, request) => { + let userId = request.params.id; + return schema.db.permissions.where({ userId: `${userId}` }); }); - this.get('/folders/VzMuyEw_3WqiafcG/permissions', () => { - return [{ - "folderId": "VzMuyEw_3WqiafcG", - "userId": "VzMuyEw_3WqiafcE", - "canView": true, - "canEdit": true - }]; + this.get('/folders/:id/permissions', (schema, request) => { + let id = request.params.id; + return schema.db.folderPermissions.where({ id: `${id}` }); }); - this.put('/folders/VzMygEw_3WrtFzto/permissions', () => { - return [{ - "orgId": "VzMuyEw_3WqiafcD", - "folderId": "VzMygEw_3WrtFzto", - "userId": "", - "canEdit": true, - "canView": true - }, { - "orgId": "VzMuyEw_3WqiafcD", - "folderId": "VzMygEw_3WrtFzto", - "userId": "VzMyp0w_3WrtFztq", - "canEdit": false, - "canView": false - }, { - "orgId": "", - "folderId": "VzMygEw_3WrtFzto", - "userId": "VzMuyEw_3WqiafcE", - "canEdit": true, - "canView": true - }]; - }); + this.put('/folders/:id/permissions', (schema, request) => { + let id = request.params.id; + let attrs = JSON.parse(request.requestBody).Roles; - this.get('/folders/VzMygEw_3WrtFzto/permissions', () => { - return [{ - "folderId": "VzMygEw_3WrtFzto", - "userId": "VzMuyEw_3WqiafcE", - "canView": true, - "canEdit": true - }]; + // return schema.db.folderPermissions.update(`${id}`, { `${attrs[0]}` }); }); this.put('/folders/:id', (schema, request) => { @@ -264,18 +152,8 @@ export default function () { return schema.db.folders.find(id); }); - this.get('/organizations/VzMuyEw_3WqiafcD', () => { - return { - "id": "VzMuyEw_3WqiafcD", - "created": "2016-05-11T15:08:24Z", - "revised": "2016-05-23T11:23:20Z", - "title": "EmberSherpa", - "message": "This Documize instance contains all our team documentation", - "url": "", - "domain": "", - "email": "brizdigital@gmail.com", - "allowAnonymousAccess": false - }; + this.get('/organizations/VzMuyEw_3WqiafcD', (schema) => { + return schema.db.organizations[0]; }); this.put('/organizations/VzMuyEw_3WqiafcD', (schema, request) => { @@ -283,69 +161,15 @@ export default function () { let message = JSON.parse(request.requestBody).title; let allowAnonymousAccess = JSON.parse(request.requestBody).allowAnonymousAccess; - return { - "id": "VzMuyEw_3WqiafcD", - "created": "2016-05-11T15:08:24Z", - "revised": "2016-05-23T11:23:20Z", - "title": `${title}`, - "message": `${message}`, - "url": "", - "domain": "", - "email": "brizdigital@gmail.com", - "allowAnonymousAccess": `${allowAnonymousAccess}` - }; + return schema.db.organizations.update('VzMuyEw_3WqiafcD', { + title: `${title}`, + message: `${message}`, + allowAnonymousAccess: `${allowAnonymousAccess}` + }); }); - this.get('/users', () => { - return [{ - "id": "VzMyp0w_3WrtFztq", - "created": "2016-05-11T13:24:55Z", - "revised": "2016-05-11T13:33:47Z", - "firstname": "Len", - "lastname": "Random", - "email": "zinyando@gmail.com", - "initials": "LR", - "active": true, - "editor": true, - "admin": false, - "accounts": [{ - "id": "VzMyp0w_3WrtFztr", - "created": "2016-05-11T13:24:55Z", - "revised": "2016-05-11T13:24:55Z", - "admin": false, - "editor": true, - "userId": "VzMyp0w_3WrtFztq", - "orgId": "VzMuyEw_3WqiafcD", - "company": "EmberSherpa", - "title": "EmberSherpa", - "message": "This Documize instance contains all our team documentation", - "domain": "" - }] - }, { - "id": "VzMuyEw_3WqiafcE", - "created": "2016-05-11T15:08:24Z", - "revised": "2016-05-11T15:08:24Z", - "firstname": "Lennex", - "lastname": "Zinyando", - "email": "brizdigital@gmail.com", - "initials": "LZ", - "active": true, - "editor": true, - "admin": true, - "accounts": [{ - "id": "VzMuyEw_3WqiafcF", - "created": "2016-05-11T15:08:24Z", - "revised": "2016-05-11T15:08:24Z", - "admin": true, - "editor": true, - "userId": "VzMuyEw_3WqiafcE", - "orgId": "VzMuyEw_3WqiafcD", - "company": "EmberSherpa", - "title": "EmberSherpa", - "message": "This Documize instance contains all our team documentation", - "domain": "" - }] - }]; + this.get('/users', (schema, request) => { + return schema.db.users; }); this.post('/users', (schema, request) => { @@ -353,7 +177,7 @@ export default function () { let lastname = JSON.parse(request.requestBody).lastname; let email = JSON.parse(request.requestBody).email; - return { + let user = { "id": "V0RmtUw_3QeDAMW7", "created": "2016-05-24T14:35:33Z", "revised": "2016-05-24T14:35:33Z", @@ -378,35 +202,14 @@ export default function () { "domain": "" }] }; + + return schema.db.users.insert(user); }); - this.get('/users/VzMuyEw_3WqiafcE', () => { - - return { - "id": "VzMuyEw_3WqiafcE", - "created": "2016-05-11T15:08:24Z", - "revised": "2016-05-11T15:08:24Z", - "firstname": "Lennex", - "lastname": "Zinyando", - "email": "brizdigital@gmail.com", - "initials": "LZ", - "active": true, - "editor": true, - "admin": true, - "accounts": [{ - "id": "VzMuyEw_3WqiafcF", - "created": "2016-05-11T15:08:24Z", - "revised": "2016-05-11T15:08:24Z", - "admin": true, - "editor": true, - "userId": "VzMuyEw_3WqiafcE", - "orgId": "VzMuyEw_3WqiafcD", - "company": "EmberSherpa", - "title": "EmberSherpa", - "message": "This Documize instance contains all our team documentation", - "domain": "" - }] - }; + this.get('/users/:id', (schema, request) => { + let id = request.params.id; + let user = schema.db.users.where({ id: `${id}` }); + return user[0]; }); this.put('/users/VzMuyEw_3WqiafcE', (schema, request) => { @@ -414,35 +217,15 @@ export default function () { let lastname = JSON.parse(request.requestBody).lastname; let email = JSON.parse(request.requestBody).email; - return { - "id": "VzMuyEw_3WqiafcE", - "created": "2016-05-11T15:08:24Z", - "revised": "2016-05-11T15:08:24Z", - "firstname": `${firstname}`, - "lastname": `${lastname}`, - "email": `${email}`, - "initials": "LZ", - "active": true, - "editor": true, - "admin": true, - "accounts": [{ - "id": "VzMuyEw_3WqiafcF", - "created": "2016-05-11T15:08:24Z", - "revised": "2016-05-11T15:08:24Z", - "admin": true, - "editor": true, - "userId": "VzMuyEw_3WqiafcE", - "orgId": "VzMuyEw_3WqiafcD", - "company": "EmberSherpa", - "title": "EmberSherpa", - "message": "This Documize instance contains all our team documentation", - "domain": "" - }] - }; + return schema.db.users.update('VzMuyEw_3WqiafcE', { + firstname: `${firstname}`, + lastname: `${lastname}`, + email: `${email}` + }); }); this.post('/folders/VzMuyEw_3WqiafcG/invitation', () => { return {}; }); -} \ No newline at end of file +} diff --git a/app/tests/acceptance/anon-access-enabled-test.js b/app/tests/acceptance/anon-access-enabled-test.js index 336785f8..c607ba8f 100644 --- a/app/tests/acceptance/anon-access-enabled-test.js +++ b/app/tests/acceptance/anon-access-enabled-test.js @@ -1,11 +1,11 @@ // Copyright 2016 Documize Inc. . All rights reserved. // -// This software (Documize Community Edition) is licensed under +// This software (Documize Community Edition) is licensed under // GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html // // You can operate outside the AGPL restrictions by purchasing // Documize Enterprise Edition and obtaining a commercial license -// by contacting . +// by contacting . // // https://documize.com @@ -29,6 +29,7 @@ test('visiting / when not authenticated and with { allowAnonymousAccess: true } test('visiting / when authenticated and with { allowAnonymousAccess: true } takes user to dashboard', function (assert) { server.create('meta', { allowAnonymousAccess: true }); server.createList('folder', 2); + server.createList('user', 2); visit('/'); andThen(function () { @@ -38,8 +39,10 @@ test('visiting / when authenticated and with { allowAnonymousAccess: true } take userLogin(); + // return pauseTest(); + andThen(function () { 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'); }); -}); \ No newline at end of file +}); diff --git a/app/tests/acceptance/documents-space-test.js b/app/tests/acceptance/documents-space-test.js index 9ab5cf17..7977e6db 100644 --- a/app/tests/acceptance/documents-space-test.js +++ b/app/tests/acceptance/documents-space-test.js @@ -1,11 +1,11 @@ // Copyright 2016 Documize Inc. . All rights reserved. // -// This software (Documize Community Edition) is licensed under +// This software (Documize Community Edition) is licensed under // GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html // // You can operate outside the AGPL restrictions by purchasing // Documize Enterprise Edition and obtaining a commercial license -// by contacting . +// by contacting . // // https://documize.com @@ -66,6 +66,7 @@ test('visiting space settings page', function (assert) { server.create('meta', { allowAnonymousAccess: false }); server.createList('folder', 2); server.createList('permission', 4); + server.createList('folder-permission', 2); authenticateUser(); visit('/s/VzMuyEw_3WqiafcG/my-project'); @@ -203,4 +204,4 @@ function checkForCommonAsserts() { findWithAssert('.options li:contains(Share)'); findWithAssert('.options li:contains(Permissions)'); findWithAssert('.options li:contains(Delete)'); -} \ No newline at end of file +} diff --git a/app/tests/acceptance/user-profile-test.js b/app/tests/acceptance/user-profile-test.js index 449a8601..9e7ad321 100644 --- a/app/tests/acceptance/user-profile-test.js +++ b/app/tests/acceptance/user-profile-test.js @@ -1,11 +1,11 @@ // Copyright 2016 Documize Inc. . All rights reserved. // -// This software (Documize Community Edition) is licensed under +// This software (Documize Community Edition) is licensed under // GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html // // You can operate outside the AGPL restrictions by purchasing // Documize Enterprise Edition and obtaining a commercial license -// by contacting . +// by contacting . // // https://documize.com @@ -16,6 +16,7 @@ moduleForAcceptance('Acceptance | user profile'); test('visiting /profile', function (assert) { server.createList('folder', 2); + server.createList('user', 2); authenticateUser(); visit('/profile'); @@ -29,6 +30,7 @@ test('visiting /profile', function (assert) { test('changing user details and email ', function (assert) { server.createList('folder', 2); + server.createList('user', 2); authenticateUser(); visit('/profile'); @@ -49,4 +51,4 @@ test('changing user details and email ', function (assert) { assert.equal(currentURL(), '/s/VzMuyEw_3WqiafcG/my-project'); assert.equal(find('.content .name').text().trim(), 'Test User', 'Profile name displayed'); }); -}); \ No newline at end of file +}); diff --git a/app/tests/acceptance/user-settings-test.js b/app/tests/acceptance/user-settings-test.js index 1d392de8..4451e698 100644 --- a/app/tests/acceptance/user-settings-test.js +++ b/app/tests/acceptance/user-settings-test.js @@ -1,11 +1,11 @@ // Copyright 2016 Documize Inc. . All rights reserved. // -// This software (Documize Community Edition) is licensed under +// This software (Documize Community Edition) is licensed under // GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html // // You can operate outside the AGPL restrictions by purchasing // Documize Enterprise Edition and obtaining a commercial license -// by contacting . +// by contacting . // // https://documize.com @@ -16,6 +16,7 @@ moduleForAcceptance('Acceptance | User Settings'); test('visiting /settings/general', function (assert) { server.create('meta', { allowAnonymousAccess: false }); + server.createList('organization', 1); authenticateUser(); visit('/settings/general'); @@ -29,6 +30,7 @@ test('visiting /settings/general', function (assert) { test('changing the Website title and description', function (assert) { server.create('meta', { allowAnonymousAccess: false }); + server.createList('organization', 1); authenticateUser(); visit('/settings/general'); @@ -61,6 +63,7 @@ test('visiting /settings/folders', function (assert) { test('visiting /settings/users', function (assert) { server.create('meta', { allowAnonymousAccess: false }); + server.createList('user', 2); authenticateUser(); visit('/settings/users'); @@ -75,6 +78,7 @@ test('visiting /settings/users', function (assert) { test('add a new user', function (assert) { server.create('meta', { allowAnonymousAccess: false }); + server.createList('user', 2); authenticateUser(); visit('/settings/users'); @@ -107,4 +111,4 @@ function checkForCommonAsserts() { findWithAssert('#user-button'); findWithAssert('#accounts-button'); findWithAssert('.info .title'); -} \ No newline at end of file +} From 702eefa7377688886b4e23c12ec2d7b4f8d2ff6a Mon Sep 17 00:00:00 2001 From: zinyando Date: Tue, 12 Jul 2016 15:13:30 +0200 Subject: [PATCH 03/11] Jshint fixes --- app/mirage/config.js | 12 +++++------- app/tests/acceptance/documents-space-test.js | 1 + 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/app/mirage/config.js b/app/mirage/config.js index 84e4646e..2031b102 100644 --- a/app/mirage/config.js +++ b/app/mirage/config.js @@ -72,7 +72,6 @@ export default function () { }); this.post('/folders', function (schema, request) { - debugger; var name = JSON.parse(request.requestBody).name; let folder = { "id": "V0Vy5Uw_3QeDAMW9", @@ -121,11 +120,10 @@ export default function () { return schema.db.folderPermissions.where({ id: `${id}` }); }); - this.put('/folders/:id/permissions', (schema, request) => { - let id = request.params.id; - let attrs = JSON.parse(request.requestBody).Roles; - - // return schema.db.folderPermissions.update(`${id}`, { `${attrs[0]}` }); + this.put('/folders/:id/permissions', () => { + // let id = request.params.id; + // let attrs = JSON.parse(request.requestBody).Roles; + // return schema.db.folderPermissions.update('VzMygEw_3WrtFzto', attrs[0]); }); this.put('/folders/:id', (schema, request) => { @@ -168,7 +166,7 @@ export default function () { }); }); - this.get('/users', (schema, request) => { + this.get('/users', (schema) => { return schema.db.users; }); diff --git a/app/tests/acceptance/documents-space-test.js b/app/tests/acceptance/documents-space-test.js index 7977e6db..0e693fe2 100644 --- a/app/tests/acceptance/documents-space-test.js +++ b/app/tests/acceptance/documents-space-test.js @@ -123,6 +123,7 @@ test('changing space permissions', function (assert) { server.create('meta', { allowAnonymousAccess: false }); server.createList('folder', 2); server.createList('permission', 4); + server.createList('folder-permission', 2); authenticateUser(); visit('/s/VzMygEw_3WrtFzto/test'); From b97d9cd287020ddb2429c04d704b50161afc243b Mon Sep 17 00:00:00 2001 From: zinyando Date: Tue, 12 Jul 2016 15:22:25 +0200 Subject: [PATCH 04/11] Add license info to files --- app/mirage/config.js | 11 ++++++++ app/mirage/factories/contact.js | 31 +++++++++++++++-------- app/mirage/factories/document.js | 14 ++++++++-- app/mirage/factories/folder-permission.js | 11 ++++++++ app/mirage/factories/organization.js | 11 ++++++++ app/mirage/factories/user.js | 11 ++++++++ 6 files changed, 77 insertions(+), 12 deletions(-) diff --git a/app/mirage/config.js b/app/mirage/config.js index 2031b102..834a5301 100644 --- a/app/mirage/config.js +++ b/app/mirage/config.js @@ -1,3 +1,14 @@ +// Copyright 2016 Documize Inc. . All rights reserved. +// +// This software (Documize Community Edition) is licensed under +// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html +// +// You can operate outside the AGPL restrictions by purchasing +// Documize Enterprise Edition and obtaining a commercial license +// by contacting . +// +// https://documize.com + import Mirage from 'ember-cli-mirage'; export default function () { diff --git a/app/mirage/factories/contact.js b/app/mirage/factories/contact.js index 1b3a3eab..ffbcc23b 100644 --- a/app/mirage/factories/contact.js +++ b/app/mirage/factories/contact.js @@ -1,20 +1,31 @@ +// Copyright 2016 Documize Inc. . All rights reserved. +// +// This software (Documize Community Edition) is licensed under +// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html +// +// You can operate outside the AGPL restrictions by purchasing +// Documize Enterprise Edition and obtaining a commercial license +// by contacting . +// +// https://documize.com + /* This is an example factory definition. Create more files in this directory to define additional factories. */ -import Mirage/*, {faker} */ from 'ember-cli-mirage'; +import Mirage /*, {faker} */ from 'ember-cli-mirage'; export default Mirage.Factory.extend({ - // name: 'Pete', // strings - // age: 20, // numbers - // tall: true, // booleans + // name: 'Pete', // strings + // age: 20, // numbers + // tall: true, // booleans - // email: function(i) { // and functions - // return 'person' + i + '@test.com'; - // }, + // email: function(i) { // and functions + // return 'person' + i + '@test.com'; + // }, - // firstName: faker.name.firstName, // using faker - // lastName: faker.name.firstName, - // zipCode: faker.address.zipCode + // firstName: faker.name.firstName, // using faker + // lastName: faker.name.firstName, + // zipCode: faker.address.zipCode }); diff --git a/app/mirage/factories/document.js b/app/mirage/factories/document.js index 85018979..71c8de5f 100644 --- a/app/mirage/factories/document.js +++ b/app/mirage/factories/document.js @@ -1,4 +1,14 @@ +// Copyright 2016 Documize Inc. . All rights reserved. +// +// This software (Documize Community Edition) is licensed under +// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html +// +// You can operate outside the AGPL restrictions by purchasing +// Documize Enterprise Edition and obtaining a commercial license +// by contacting . +// +// https://documize.com + import { Factory } from 'ember-cli-mirage'; -export default Factory.extend({ -}); +export default Factory.extend({}); diff --git a/app/mirage/factories/folder-permission.js b/app/mirage/factories/folder-permission.js index 457da316..e6f26d39 100644 --- a/app/mirage/factories/folder-permission.js +++ b/app/mirage/factories/folder-permission.js @@ -1,3 +1,14 @@ +// Copyright 2016 Documize Inc. . All rights reserved. +// +// This software (Documize Community Edition) is licensed under +// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html +// +// You can operate outside the AGPL restrictions by purchasing +// Documize Enterprise Edition and obtaining a commercial license +// by contacting . +// +// https://documize.com + import { Factory, faker } from 'ember-cli-mirage'; export default Factory.extend({ diff --git a/app/mirage/factories/organization.js b/app/mirage/factories/organization.js index e6885593..bed871f3 100644 --- a/app/mirage/factories/organization.js +++ b/app/mirage/factories/organization.js @@ -1,3 +1,14 @@ +// Copyright 2016 Documize Inc. . All rights reserved. +// +// This software (Documize Community Edition) is licensed under +// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html +// +// You can operate outside the AGPL restrictions by purchasing +// Documize Enterprise Edition and obtaining a commercial license +// by contacting . +// +// https://documize.com + import { Factory } from 'ember-cli-mirage'; export default Factory.extend({ diff --git a/app/mirage/factories/user.js b/app/mirage/factories/user.js index 2809ad84..371eadae 100644 --- a/app/mirage/factories/user.js +++ b/app/mirage/factories/user.js @@ -1,3 +1,14 @@ +// Copyright 2016 Documize Inc. . All rights reserved. +// +// This software (Documize Community Edition) is licensed under +// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html +// +// You can operate outside the AGPL restrictions by purchasing +// Documize Enterprise Edition and obtaining a commercial license +// by contacting . +// +// https://documize.com + import { Factory, faker } from 'ember-cli-mirage'; export default Factory.extend({ From 400f0d26ce120902f4bc957f37e2049a5efe7724 Mon Sep 17 00:00:00 2001 From: zinyando Date: Tue, 19 Jul 2016 15:44:57 +0200 Subject: [PATCH 05/11] Add tether service --- app/app/services/tether.js | 22 ++++++++++++++++++++++ app/tests/unit/services/tether-test.js | 12 ++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 app/app/services/tether.js create mode 100644 app/tests/unit/services/tether-test.js diff --git a/app/app/services/tether.js b/app/app/services/tether.js new file mode 100644 index 00000000..38307d0e --- /dev/null +++ b/app/app/services/tether.js @@ -0,0 +1,22 @@ +import Ember from 'ember'; + +/** + * This is a work around problems that tether introduces into testing. + * TODO: remove this code and refactor in favour of ember-tether + */ +export default Ember.Service.extend({ + createDrop() { + if (Ember.testing) { + return; + } + + return new Drop(...arguments); + }, + createTooltip() { + if (Ember.testing) { + return; + } + + return new Tooltip(...arguments); + } +}); diff --git a/app/tests/unit/services/tether-test.js b/app/tests/unit/services/tether-test.js new file mode 100644 index 00000000..dc2970d5 --- /dev/null +++ b/app/tests/unit/services/tether-test.js @@ -0,0 +1,12 @@ +import { moduleFor, test } from 'ember-qunit'; + +moduleFor('service:tether', 'Unit | Service | tether', { + // Specify the other units that are required for this test. + // needs: ['service:foo'] +}); + +// Replace this with your real tests. +test('it exists', function(assert) { + let service = this.subject(); + assert.ok(service); +}); From a74b14ae76ea24d9a01e0a6c43330a39ac18b4e3 Mon Sep 17 00:00:00 2001 From: zinyando Date: Tue, 19 Jul 2016 15:46:44 +0200 Subject: [PATCH 06/11] Use tether service to determine environment app is running --- app/app/components/dropdown-dialog.js | 52 ++++++++++++++++----------- 1 file changed, 32 insertions(+), 20 deletions(-) diff --git a/app/app/components/dropdown-dialog.js b/app/app/components/dropdown-dialog.js index eab966d6..1974c8a3 100644 --- a/app/app/components/dropdown-dialog.js +++ b/app/app/components/dropdown-dialog.js @@ -32,6 +32,7 @@ export default Ember.Component.extend({ targetOffset: "10px 0", constrainToWindow: true, constrainToScrollParent: true, + tether: Ember.inject.service(), hasSecondButton: Ember.computed('button2', 'color2', function () { return is.not.empty(this.get('button2')) && is.not.empty(this.get('color2')); @@ -43,9 +44,10 @@ export default Ember.Component.extend({ didInsertElement() { this._super(...arguments); + // TODO: refactor to eliminate self let self = this; - let drop = new Drop({ + let drop = this.get('tether').createDrop({ target: document.getElementById(self.get('target')), content: self.$(".dropdown-dialog")[0], classes: 'drop-theme-basic', @@ -65,30 +67,38 @@ export default Ember.Component.extend({ remove: true }); - self.set('drop', drop); + if (drop) { + drop.on('open', function () { + if (is.not.null(self.get("focusOn"))) { + document.getElementById(self.get("focusOn")).focus(); + } - drop.on('open', function () { - if (is.not.null(self.get("focusOn"))) { - document.getElementById(self.get("focusOn")).focus(); - } + if (is.not.null(self.get("selectOn"))) { + document.getElementById(self.get("selectOn")).select(); + } - if (is.not.null(self.get("selectOn"))) { - document.getElementById(self.get("selectOn")).select(); - } + if (is.not.null(self.get("onOpenCallback"))) { + self.attrs.onOpenCallback(drop); + } + }); + self.set('drop', drop); + } - if (is.not.null(self.get("onOpenCallback"))) { - self.attrs.onOpenCallback(drop); - } - }); }, willDestroyElement() { - this.get('drop').destroy(); + let drop = this.get('drop'); + if (drop) { + drop.destroy(); + } }, actions: { onCancel() { - this.get('drop').close(); + let drop = this.get('drop'); + if (drop) { + drop.close(); + } }, onAction() { @@ -98,8 +108,9 @@ export default Ember.Component.extend({ let close = this.attrs.onAction(); - if (close) { - this.get('drop').close(); + let drop = this.get('drop'); + if (close && drop) { + drop.close(); } }, @@ -110,9 +121,10 @@ export default Ember.Component.extend({ let close = this.attrs.onAction2(); - if (close) { - this.get('drop').close(); + let drop = this.get('drop'); + if (close && drop) { + drop.close(); } } } -}); \ No newline at end of file +}); From 68271646eb6ac43a7da89b42ea93a8ba3366cb82 Mon Sep 17 00:00:00 2001 From: zinyando Date: Tue, 19 Jul 2016 15:50:29 +0200 Subject: [PATCH 07/11] Move mirage server create to module-for-acceptance tests file --- app/mirage/config.js | 273 +++++++++++++++++++-- app/tests/.jshintrc | 3 +- app/tests/helpers/module-for-acceptance.js | 51 ++-- app/tests/helpers/start-app.js | 18 +- app/tests/index.html | 21 +- 5 files changed, 296 insertions(+), 70 deletions(-) diff --git a/app/mirage/config.js b/app/mirage/config.js index 834a5301..c7230444 100644 --- a/app/mirage/config.js +++ b/app/mirage/config.js @@ -32,33 +32,7 @@ export default function () { let folder_id = request.queryParams.folder; if (folder_id = "VzMuyEw_3WqiafcG") { - return [{ - "id": "VzMwX0w_3WrtFztd", - "created": "2016-05-11T13:15:11Z", - "revised": "2016-05-11T13:22:16Z", - "orgId": "VzMuyEw_3WqiafcD", - "folderId": "VzMuyEw_3WqiafcG", - "userId": "VzMuyEw_3WqiafcE", - "job": "", - "location": "template-0", - "name": "Empty Document", - "excerpt": "My test document", - "tags": "", - "template": false - }, { - "id": "VzMvJEw_3WqiafcI", - "created": "2016-05-11T13:09:56Z", - "revised": "2016-05-11T13:09:56Z", - "orgId": "VzMuyEw_3WqiafcD", - "folderId": "VzMuyEw_3WqiafcG", - "userId": "VzMuyEw_3WqiafcE", - "job": "0bf9b076-cb74-4e8e-75be-8ee2d24a8171", - "location": "/var/folders/d6/kr81d2fs5bsbm8rz2p092fy80000gn/T/documize/_uploads/0bf9b076-cb74-4e8e-75be-8ee2d24a8171/README.md", - "name": "README", - "excerpt": "To Document/ Instructions. GO. go- bindata- assetsfs. SSL.", - "tags": "", - "template": false - }]; + return schema.db.documents.where({ folderId: folder_id }); } if (folder_id = "VzMygEw_3WrtFzto") { @@ -78,6 +52,228 @@ export default function () { } }); + this.get('/documents/:id', function () { + return { + "id": "VzMzBUw_3WrtFztv", + "created": "2016-05-11T13:26:29Z", + "revised": "2016-05-11T13:26:29Z", + "orgId": "VzMuyEw_3WqiafcD", + "folderId": "VzMygEw_3WrtFzto", + "userId": "VzMuyEw_3WqiafcE", + "job": "3004c449-b053-49a6-4abc-72688136184d", + "location": "/var/folders/d6/kr81d2fs5bsbm8rz2p092fy80000gn/T/documize/_uploads/3004c449-b053-49a6-4abc-72688136184d/README.md", + "name": "README", + "excerpt": "To Document/ Instructions. GO. go- bindata- assetsfs. SSL.", + "tags": "", + "template": false + }; + }); + + this.get('/documents/:id/pages', function () { + return [{ + "id": "VzMzBUw_3WrtFztw", + "created": "2016-05-11T13:26:29Z", + "revised": "2016-05-11T13:26:29Z", + "orgId": "VzMuyEw_3WqiafcD", + "documentId": "VzMzBUw_3WrtFztv", + "userId": "VzMuyEw_3WqiafcE", + "contentType": "wysiwyg", + "level": 1, + "sequence": 1024, + "title": "README", + "body": "", + "revisions": 0 + }, { + "id": "VzMzBUw_3WrtFztx", + "created": "2016-05-11T13:26:29Z", + "revised": "2016-05-11T13:26:29Z", + "orgId": "VzMuyEw_3WqiafcD", + "documentId": "VzMzBUw_3WrtFztv", + "userId": "VzMuyEw_3WqiafcE", + "contentType": "wysiwyg", + "level": 2, + "sequence": 2048, + "title": "To Document / Instructions ", + "body": "\n\n\u003cp\u003eThe build process around go get github.com/elazarl/go-bindata-assetfs\u003c/p\u003e\n\n", + "revisions": 0 + }, { + "id": "VzMzBUw_3WrtFzty", + "created": "2016-05-11T13:26:29Z", + "revised": "2016-05-11T13:26:29Z", + "orgId": "VzMuyEw_3WqiafcD", + "documentId": "VzMzBUw_3WrtFztv", + "userId": "VzMuyEw_3WqiafcE", + "contentType": "wysiwyg", + "level": 3, + "sequence": 3072, + "title": "GO ", + "body": "\n\n\u003cp\u003egobin / go env\u003c/p\u003e\n\n", + "revisions": 0 + }, { + "id": "VzMzBUw_3WrtFztz", + "created": "2016-05-11T13:26:29Z", + "revised": "2016-05-11T13:26:29Z", + "orgId": "VzMuyEw_3WqiafcD", + "documentId": "VzMzBUw_3WrtFztv", + "userId": "VzMuyEw_3WqiafcE", + "contentType": "wysiwyg", + "level": 3, + "sequence": 4096, + "title": "go-bindata-assetsfs ", + "body": "\n\n\u003cp\u003emake sure you do install cmd from inside go-* folder where main.go lives\u003c/p\u003e\n\n", + "revisions": 0 + }, { + "id": "VzMzBUw_3WrtFzt0", + "created": "2016-05-11T13:26:29Z", + "revised": "2016-05-11T13:26:29Z", + "orgId": "VzMuyEw_3WqiafcD", + "documentId": "VzMzBUw_3WrtFztv", + "userId": "VzMuyEw_3WqiafcE", + "contentType": "wysiwyg", + "level": 3, + "sequence": 5120, + "title": "SSL ", + "body": "\n\n\u003cp\u003eselfcert generation and avoiding red lock\u003c/p\u003e\n\n\u003cp\u003e\u003ca href=\"https://www.accuweaver.com/2014/09/19/make-chrome-accept-a-self-signed-certificate-on-osx/\"\u003ehttps://www.accuweaver.com/2014/09/19/make-chrome-accept-a-self-signed-certificate-on-osx/\u003c/a\u003e\u003c/p\u003e\n\n\u003cp\u003echrome://restart\u003c/p\u003e\n\n\u003cp\u003ego run generate_cert.go -host demo1.dev\u003c/p\u003e\n\n\u003cp\u003eport number not required\nbut browser restart is!\u003c/p\u003e\n\n", + "revisions": 0 + }, { + "id": "VzMzBUw_3WrtFzt1", + "created": "2016-05-11T13:26:29Z", + "revised": "2016-05-11T13:26:29Z", + "orgId": "VzMuyEw_3WqiafcD", + "documentId": "VzMzBUw_3WrtFztv", + "userId": "VzMuyEw_3WqiafcE", + "contentType": "wysiwyg", + "level": 3, + "sequence": 6144, + "title": "after clone ", + "body": "\n\n\u003cul\u003e\n\u003cli\u003ecd app\u003c/li\u003e\n\u003cli\u003enpm install\u003c/li\u003e\n\u003cli\u003ebower install\u003c/li\u003e\n\u003cli\u003ecd ..\u003c/li\u003e\n\u003cli\u003e./build.sh\u003c/li\u003e\n\u003c/ul\u003e\n", + "revisions": 0 + }, { + "id": "V1qnNUw_3QRDs13j", + "created": "2016-06-10T11:40:37Z", + "revised": "2016-06-10T11:40:37Z", + "orgId": "VzMuyEw_3WqiafcD", + "documentId": "VzMzBUw_3WrtFztv", + "userId": "VzMuyEw_3WqiafcE", + "contentType": "github", + "level": 2, + "sequence": 12288, + "title": "GitHub Section", + "body": "\n\u003cdiv class=\"section-github-render\"\u003e\n\t\u003cp\u003eThere are 0 commits for branch \u003ca href=\"\"\u003e\u003c/a\u003e of repository \u003ca href=\"\"\u003e.\u003c/a\u003e\u003c/p\u003e\n\t\u003cdiv class=\"github-board\"\u003e\n\t\t\n\t\u003c/div\u003e\n\u003c/div\u003e\n", + "revisions": 0 + }, { + "id": "V1qqJkw_3RXs3w1D", + "created": "2016-06-10T11:53:10Z", + "revised": "2016-06-10T11:53:10Z", + "orgId": "VzMuyEw_3WqiafcD", + "documentId": "VzMzBUw_3WrtFztv", + "userId": "VzMuyEw_3WqiafcE", + "contentType": "github", + "level": 2, + "sequence": 24576, + "title": "GitHub Section", + "body": "\n\u003cdiv class=\"section-github-render\"\u003e\n\t\u003cp\u003eThere are 0 commits for branch \u003ca href=\"\"\u003e\u003c/a\u003e of repository \u003ca href=\"\"\u003e.\u003c/a\u003e\u003c/p\u003e\n\t\u003cdiv class=\"github-board\"\u003e\n\t\t\n\t\u003c/div\u003e\n\u003c/div\u003e\n", + "revisions": 0 + }]; + }); + + this.post('/templates/0/folder/VzMuyEw_3WqiafcG', function (schema, request) { + let type = request.queryParams.type; + if (type === 'saved') { + return schema.db.documents.insert({ + "id": "V4y7jkw_3QvCDSeS", + "created": "2016-07-18T11:20:47Z", + "revised": "2016-07-18T11:20:47Z", + "orgId": "VzMuyEw_3WqiafcD", + "folderId": "VzMuyEw_3WqiafcG", + "userId": "VzMuyEw_3WqiafcE", + "job": "", + "location": "template-0", + "name": "New Document", + "excerpt": "A new document", + "tags": "", + "template": false + }); + } + }); + + this.delete('/documents/:id', function (schema, request) { + let id = request.params.id; + return schema.db.documents.remove(id); + }); + + this.get('/documents/:id/attachments', function () { + return {}; + }); + + this.get('/documents/:id/meta', function () { + return { + "viewers": [{ + "userId": "VzMuyEw_3WqiafcE", + "created": "2016-07-14T13:46:24Z", + "firstname": "Lennex", + "lastname": "Zinyando" + }], + "editors": [{ + "pageId": "V1qqJkw_3RXs3w1D", + "userId": "VzMuyEw_3WqiafcE", + "action": "add-page", + "created": "2016-06-10T11:53:10Z", + "firstname": "Lennex", + "lastname": "Zinyando" + }, { + "pageId": "V1qnNUw_3QRDs13j", + "userId": "VzMuyEw_3WqiafcE", + "action": "add-page", + "created": "2016-06-10T11:40:37Z", + "firstname": "Lennex", + "lastname": "Zinyando" + }, { + "pageId": "VzMzBUw_3WrtFztw", + "userId": "VzMuyEw_3WqiafcE", + "action": "add-page", + "created": "2016-05-11T13:26:29Z", + "firstname": "Lennex", + "lastname": "Zinyando" + }, { + "pageId": "VzMzBUw_3WrtFztx", + "userId": "VzMuyEw_3WqiafcE", + "action": "add-page", + "created": "2016-05-11T13:26:29Z", + "firstname": "Lennex", + "lastname": "Zinyando" + }, { + "pageId": "VzMzBUw_3WrtFzty", + "userId": "VzMuyEw_3WqiafcE", + "action": "add-page", + "created": "2016-05-11T13:26:29Z", + "firstname": "Lennex", + "lastname": "Zinyando" + }, { + "pageId": "VzMzBUw_3WrtFztz", + "userId": "VzMuyEw_3WqiafcE", + "action": "add-page", + "created": "2016-05-11T13:26:29Z", + "firstname": "Lennex", + "lastname": "Zinyando" + }, { + "pageId": "VzMzBUw_3WrtFzt0", + "userId": "VzMuyEw_3WqiafcE", + "action": "add-page", + "created": "2016-05-11T13:26:29Z", + "firstname": "Lennex", + "lastname": "Zinyando" + }, { + "pageId": "VzMzBUw_3WrtFzt1", + "userId": "VzMuyEw_3WqiafcE", + "action": "add-page", + "created": "2016-05-11T13:26:29Z", + "firstname": "Lennex", + "lastname": "Zinyando" + }] + }; + }); + this.get('/folders', function (schema) { return schema.db.folders; }); @@ -137,6 +333,29 @@ export default function () { // return schema.db.folderPermissions.update('VzMygEw_3WrtFzto', attrs[0]); }); + this.get('/users/folder/:id', () => { + return [{ + "id": "VzMuyEw_3WqiafcE", + "created": "2016-05-11T15:08:24Z", + "revised": "2016-07-04T10:24:41Z", + "firstname": "Lennex", + "lastname": "Zinyando", + "email": "brizdigital@gmail.com", + "initials": "LZ", + "active": true, + "editor": false, + "admin": false, + "accounts": null + }]; + }); + + this.get('/sections/refresh', (schema, request) => { + let documentID = request.queryParams.documentID; + if (documentID) { + return {}; + } + }); + this.put('/folders/:id', (schema, request) => { let id = request.params.id; let attrs = JSON.parse(request.requestBody); diff --git a/app/tests/.jshintrc b/app/tests/.jshintrc index 6be92267..91b2d0f4 100644 --- a/app/tests/.jshintrc +++ b/app/tests/.jshintrc @@ -32,7 +32,8 @@ "waitToAppear", "stubUserNotification", "is", - "authenticateUser" + "authenticateUser", + "localStorage" ], "node": false, "browser": false, diff --git a/app/tests/helpers/module-for-acceptance.js b/app/tests/helpers/module-for-acceptance.js index f532ceec..2bd73095 100644 --- a/app/tests/helpers/module-for-acceptance.js +++ b/app/tests/helpers/module-for-acceptance.js @@ -2,31 +2,38 @@ import { module } from 'qunit'; import startApp from '../helpers/start-app'; import destroyApp from '../helpers/destroy-app'; -export default function(name, options = {}) { - module(name, { - beforeEach() { - this.application = startApp(); - stubAudit(this); - stubUserNotification(this); +export default function (name, options = {}) { + module(name, { + beforeEach() { + this.application = startApp(); + localStorage.setItem('folder', 'VzMuyEw_3WqiafcG'); + stubAudit(this); + stubUserNotification(this); + server.createList('folder', 2); + server.createList('user', 2); + server.createList('document', 2); + server.createList('permission', 4); + server.createList('folder-permission', 2); + server.createList('organization', 1); - if (options.beforeEach) { - options.beforeEach.apply(this, arguments); - } + if (options.beforeEach) { + options.beforeEach.apply(this, arguments); + } - this.register = (fullName, Factory) => { - let instance = this.application.__deprecatedInstance__; - let registry = instance.register ? instance : instance.registry; + this.register = (fullName, Factory) => { + let instance = this.application.__deprecatedInstance__; + let registry = instance.register ? instance : instance.registry; - return registry.register(fullName, Factory); - }; - }, + return registry.register(fullName, Factory); + }; + }, - afterEach() { - destroyApp(this.application); + afterEach() { + destroyApp(this.application); - if (options.afterEach) { - options.afterEach.apply(this, arguments); - } - } - }); + if (options.afterEach) { + options.afterEach.apply(this, arguments); + } + } + }); } diff --git a/app/tests/helpers/start-app.js b/app/tests/helpers/start-app.js index 1d1582e3..928212f4 100644 --- a/app/tests/helpers/start-app.js +++ b/app/tests/helpers/start-app.js @@ -9,16 +9,16 @@ import './stub-user-notification'; import './authenticate-user'; export default function startApp(attrs) { - let application; + let application; - let attributes = Ember.merge({}, config.APP); - attributes = Ember.merge(attributes, attrs); // use defaults, but you can override; + let attributes = Ember.merge({}, config.APP); + attributes = Ember.merge(attributes, attrs); // use defaults, but you can override; - Ember.run(() => { - application = Application.create(attributes); - application.setupForTesting(); - application.injectTestHelpers(); - }); + Ember.run(() => { + application = Application.create(attributes); + application.setupForTesting(); + application.injectTestHelpers(); + }); - return application; + return application; } diff --git a/app/tests/index.html b/app/tests/index.html index 514047e7..cb51b93b 100644 --- a/app/tests/index.html +++ b/app/tests/index.html @@ -10,17 +10,16 @@ - - + {{content-for "head"}} {{content-for "test-head"}} From c3c7a8450c6e7f45d92a543be469c0dd182bedd1 Mon Sep 17 00:00:00 2001 From: zinyando Date: Tue, 19 Jul 2016 15:51:35 +0200 Subject: [PATCH 08/11] Add more tests and cleanup old ones --- app/mirage/factories/document.js | 31 +++++++- .../acceptance/anon-access-disabled-test.js | 7 +- .../acceptance/anon-access-enabled-test.js | 5 -- app/tests/acceptance/authentication-test.js | 10 +-- app/tests/acceptance/documents-space-test.js | 73 ++++++++++--------- app/tests/acceptance/user-profile-test.js | 4 - app/tests/acceptance/user-settings-test.js | 7 -- 7 files changed, 75 insertions(+), 62 deletions(-) diff --git a/app/mirage/factories/document.js b/app/mirage/factories/document.js index 71c8de5f..5d528d89 100644 --- a/app/mirage/factories/document.js +++ b/app/mirage/factories/document.js @@ -9,6 +9,33 @@ // // https://documize.com -import { Factory } from 'ember-cli-mirage'; +import { Factory, faker } from 'ember-cli-mirage'; -export default Factory.extend({}); +export default Factory.extend({ + "id": faker.list.cycle("VzMwX0w_3WrtFztd", "VzMvJEw_3WqiafcI", "VzMzBUw_3WrtFztv"), + "created": "2016-05-11T13:15:11Z", + "revised": "2016-05-11T13:22:16Z", + "orgId": "VzMuyEw_3WqiafcD", + "folderId": "VzMuyEw_3WqiafcG", + "userId": "VzMuyEw_3WqiafcE", + "job": faker.list.cycle("", "0bf9b076-cb74-4e8e-75be-8ee2d24a8171", "3004c449-b053-49a6-4abc-72688136184d"), + "location": faker.list.cycle("template-0", "/var/folders/README.md", "/var/folders/d6/3004c449-b053-49a6-4abc-72688136184d/README.md"), + "name": faker.list.cycle("Empty Document", "README", "README"), + "excerpt": faker.list.cycle("My test document", "To Document/ Instructions. GO. go- bindata- assetsfs. SSL.", "To Document/ Instructions. GO. go- bindata- assetsfs. SSL."), + "tags": "", + "template": false +}); +// return { +// "id": "VzMzBUw_3WrtFztv", +// "created": "2016-05-11T13:26:29Z", +// "revised": "2016-05-11T13:26:29Z", +// "orgId": "VzMuyEw_3WqiafcD", +// "folderId": "VzMygEw_3WrtFzto", +// "userId": "VzMuyEw_3WqiafcE", +// "job": "3004c449-b053-49a6-4abc-72688136184d", +// "location": "/var/folders/d6/kr81d2fs5bsbm8rz2p092fy80000gn/T/documize/_uploads/3004c449-b053-49a6-4abc-72688136184d/README.md", +// "name": "README", +// "excerpt": "To Document/ Instructions. GO. go- bindata- assetsfs. SSL.", +// "tags": "", +// "template": false +// }; diff --git a/app/tests/acceptance/anon-access-disabled-test.js b/app/tests/acceptance/anon-access-disabled-test.js index fb173211..6c88b790 100644 --- a/app/tests/acceptance/anon-access-disabled-test.js +++ b/app/tests/acceptance/anon-access-disabled-test.js @@ -1,11 +1,11 @@ // Copyright 2016 Documize Inc. . All rights reserved. // -// This software (Documize Community Edition) is licensed under +// This software (Documize Community Edition) is licensed under // GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html // // You can operate outside the AGPL restrictions by purchasing // Documize Enterprise Edition and obtaining a commercial license -// by contacting . +// by contacting . // // https://documize.com @@ -16,7 +16,6 @@ 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 }); - server.createList('folder', 2); visit('/'); andThen(function () { @@ -25,4 +24,4 @@ test('visiting / when not authenticated and with { allowAnonymousAccess: false } findWithAssert('#authPassword'); findWithAssert('button'); }); -}); \ No newline at end of file +}); diff --git a/app/tests/acceptance/anon-access-enabled-test.js b/app/tests/acceptance/anon-access-enabled-test.js index c607ba8f..5ba3302d 100644 --- a/app/tests/acceptance/anon-access-enabled-test.js +++ b/app/tests/acceptance/anon-access-enabled-test.js @@ -16,7 +16,6 @@ moduleForAcceptance('Acceptance | Anon access enabled'); test('visiting / when not authenticated and with { allowAnonymousAccess: true } takes user to folder view', function (assert) { server.create('meta', { allowAnonymousAccess: true }); - server.createList('folder', 2); visit('/'); andThen(function () { @@ -28,8 +27,6 @@ test('visiting / when not authenticated and with { allowAnonymousAccess: true } test('visiting / when authenticated and with { allowAnonymousAccess: true } takes user to dashboard', function (assert) { server.create('meta', { allowAnonymousAccess: true }); - server.createList('folder', 2); - server.createList('user', 2); visit('/'); andThen(function () { @@ -39,8 +36,6 @@ test('visiting / when authenticated and with { allowAnonymousAccess: true } take userLogin(); - // return pauseTest(); - andThen(function () { 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'); diff --git a/app/tests/acceptance/authentication-test.js b/app/tests/acceptance/authentication-test.js index 9884a508..1fc2f369 100644 --- a/app/tests/acceptance/authentication-test.js +++ b/app/tests/acceptance/authentication-test.js @@ -1,11 +1,11 @@ // Copyright 2016 Documize Inc. . All rights reserved. // -// This software (Documize Community Edition) is licensed under +// This software (Documize Community Edition) is licensed under // GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html // // You can operate outside the AGPL restrictions by purchasing // Documize Enterprise Edition and obtaining a commercial license -// by contacting . +// by contacting . // // https://documize.com @@ -16,7 +16,6 @@ moduleForAcceptance('Acceptance | Authentication'); test('visiting /auth/login and logging in', function (assert) { server.create('meta', { allowAnonymousAccess: false }); - server.createList('folder', 2); visit('/auth/login'); fillIn('#authEmail', 'brizdigital@gmail.com'); @@ -30,7 +29,6 @@ test('visiting /auth/login and logging in', function (assert) { test('logging out a user', function (assert) { server.create('meta', { allowAnonymousAccess: false }); - server.createList('folder', 2); userLogin(); visit('/auth/logout'); @@ -42,7 +40,6 @@ test('logging out a user', function (assert) { test('successful sso login authenticates redirects to dashboard', function (assert) { server.create('meta', { allowAnonymousAccess: false }); - server.createList('folder', 2); visit('/auth/sso/OmJyaXpkaWdpdGFsQGdtYWlsLmNvbTp6aW55YW5kbzEyMw=='); @@ -53,11 +50,10 @@ test('successful sso login authenticates redirects to dashboard', function (asse test('sso login with bad token should redirect to login', function (assert) { server.create('meta', { allowAnonymousAccess: false }); - server.createList('folder', 2); visit('/auth/sso/randomToken1234567890'); andThen(function () { assert.equal(currentURL(), '/auth/login', 'SSO login unsuccessful'); }); -}); \ No newline at end of file +}); diff --git a/app/tests/acceptance/documents-space-test.js b/app/tests/acceptance/documents-space-test.js index 0e693fe2..19a921b3 100644 --- a/app/tests/acceptance/documents-space-test.js +++ b/app/tests/acceptance/documents-space-test.js @@ -9,39 +9,38 @@ // // https://documize.com -import { test, skip } from 'qunit'; +import { test } from 'qunit'; import moduleForAcceptance from 'documize/tests/helpers/module-for-acceptance'; moduleForAcceptance('Acceptance | Documents space'); -skip('Adding a new folder space', function (assert) { +test('Adding a new folder space', function (assert) { server.create('meta', { allowAnonymousAccess: false }); - server.createList('folder', 2); - server.createList('permission', 4); authenticateUser(); visit('/s/VzMuyEw_3WqiafcG/my-project'); andThen(function () { - let personalSpaces = find('.section div:contains(PERSONAL)').length; + let personalSpaces = find('.folders-list div:contains(PERSONAL) .list a').length; assert.equal(currentURL(), '/s/VzMuyEw_3WqiafcG/my-project'); assert.equal(personalSpaces, 1, '1 personal space is listed'); }); click('#add-folder-button'); - fillIn('#new-folder-name', 'body', 'Test Folder'); + fillIn('#new-folder-name', 'Test Folder'); - click('.actions div:contains(Add)', 'body'); + click('.actions div:contains(Add)'); andThen(function () { + let folderCount = find('.folders-list div:contains(PERSONAL) .list a').length; + assert.equal(folderCount, 2, 'New folder has been added'); assert.equal(currentURL(), '/s/V0Vy5Uw_3QeDAMW9/test-folder'); }); + }); -skip('Adding a document to a space', function (assert) { +test('Adding a document to a space', function (assert) { server.create('meta', { allowAnonymousAccess: false }); - server.createList('folder', 2); - server.createList('permission', 4); authenticateUser(); visit('/s/VzMuyEw_3WqiafcG/my-project'); @@ -52,21 +51,22 @@ skip('Adding a document to a space', function (assert) { assert.equal(numberOfDocuments, 2, '2 documents listed'); }); - click('#start-document-button'); - click('.actions div:contains(Add)', 'body'); + 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'); + }); + + click('a div:contains(My Project) .space-name'); andThen(function () { let numberOfDocuments = find('.documents-list li').length; assert.equal(numberOfDocuments, 3, '3 documents listed'); - assert.equal(currentURL(), '/s/VzMuyEw_3WqiafcG/my-project'); }); }); test('visiting space settings page', function (assert) { server.create('meta', { allowAnonymousAccess: false }); - server.createList('folder', 2); - server.createList('permission', 4); - server.createList('folder-permission', 2); authenticateUser(); visit('/s/VzMuyEw_3WqiafcG/my-project'); @@ -81,8 +81,6 @@ test('visiting space settings page', function (assert) { test('changing space name', function (assert) { server.create('meta', { allowAnonymousAccess: false }); - server.createList('folder', 2); - server.createList('permission', 4); authenticateUser(); visit('/s/VzMuyEw_3WqiafcG/my-project'); @@ -101,8 +99,6 @@ test('changing space name', function (assert) { test('sharing a space', function (assert) { server.create('meta', { allowAnonymousAccess: false }); - server.createList('folder', 2); - server.createList('permission', 4); authenticateUser(); visit('/s/VzMuyEw_3WqiafcG/my-project'); @@ -118,12 +114,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 }); - server.createList('folder', 2); - server.createList('permission', 4); - server.createList('folder-permission', 2); authenticateUser(); visit('/s/VzMygEw_3WrtFzto/test'); @@ -152,8 +144,6 @@ test('changing space permissions', function (assert) { test('deleting a space', function (assert) { server.create('meta', { allowAnonymousAccess: false }); - server.createList('folder', 2); - server.createList('permission', 4); authenticateUser(); visit('/s/VzMuyEw_3WqiafcG/my-project'); @@ -167,10 +157,8 @@ test('deleting a space', function (assert) { }); }); -skip('deleting a document', function (assert) { +test('deleting a document', function (assert) { server.create('meta', { allowAnonymousAccess: false }); - server.createList('folder', 2); - server.createList('permission', 4); authenticateUser(); visit('/s/VzMuyEw_3WqiafcG/my-project'); @@ -188,10 +176,7 @@ skip('deleting a document', function (assert) { assert.equal(deleteButton.length, 1, 'Delete button displayed after selecting document'); }); - click('#delete-documents-button'); - - waitToAppear('.drop-content'); - click('.actions div:contains(Delete)', 'body'); + click('.actions div:contains(Delete) .flat-red'); andThen(function () { let numberOfDocuments = find('.documents-list li'); @@ -199,6 +184,28 @@ skip('deleting a document', function (assert) { }); }); +test('clicking a document title displays the document', function (assert) { + server.create('meta', { allowAnonymousAccess: false }); + authenticateUser(); + visit('/s/VzMygEw_3WrtFzto/test'); + + click('a .title:contains(README)'); + + andThen(function () { + findWithAssert('#add-section-button'); + findWithAssert('#delete-document-button'); + findWithAssert('#print-document-button'); + findWithAssert('#save-template-button'); + findWithAssert('#attachment-button'); + findWithAssert('#set-meta-button'); + findWithAssert('.name.space-name'); + findWithAssert('.document-sidebar'); + let title = find('.zone-header .title').text().trim(); + assert.equal(title, 'README', 'document displayed correctly'); + assert.equal(currentURL(), '/s/VzMygEw_3WrtFzto/test/d/VzMvJEw_3WqiafcI/readme'); + }); +}); + function checkForCommonAsserts() { findWithAssert('.sidebar-menu'); findWithAssert('.options li:contains(General)'); diff --git a/app/tests/acceptance/user-profile-test.js b/app/tests/acceptance/user-profile-test.js index 9e7ad321..40de4750 100644 --- a/app/tests/acceptance/user-profile-test.js +++ b/app/tests/acceptance/user-profile-test.js @@ -15,8 +15,6 @@ import moduleForAcceptance from 'documize/tests/helpers/module-for-acceptance'; moduleForAcceptance('Acceptance | user profile'); test('visiting /profile', function (assert) { - server.createList('folder', 2); - server.createList('user', 2); authenticateUser(); visit('/profile'); @@ -29,8 +27,6 @@ test('visiting /profile', function (assert) { }); test('changing user details and email ', function (assert) { - server.createList('folder', 2); - server.createList('user', 2); authenticateUser(); visit('/profile'); diff --git a/app/tests/acceptance/user-settings-test.js b/app/tests/acceptance/user-settings-test.js index 4451e698..125ee46c 100644 --- a/app/tests/acceptance/user-settings-test.js +++ b/app/tests/acceptance/user-settings-test.js @@ -16,7 +16,6 @@ moduleForAcceptance('Acceptance | User Settings'); test('visiting /settings/general', function (assert) { server.create('meta', { allowAnonymousAccess: false }); - server.createList('organization', 1); authenticateUser(); visit('/settings/general'); @@ -30,7 +29,6 @@ test('visiting /settings/general', function (assert) { test('changing the Website title and description', function (assert) { server.create('meta', { allowAnonymousAccess: false }); - server.createList('organization', 1); authenticateUser(); visit('/settings/general'); @@ -63,7 +61,6 @@ test('visiting /settings/folders', function (assert) { test('visiting /settings/users', function (assert) { server.create('meta', { allowAnonymousAccess: false }); - server.createList('user', 2); authenticateUser(); visit('/settings/users'); @@ -78,7 +75,6 @@ test('visiting /settings/users', function (assert) { test('add a new user', function (assert) { server.create('meta', { allowAnonymousAccess: false }); - server.createList('user', 2); authenticateUser(); visit('/settings/users'); @@ -95,9 +91,6 @@ test('add a new user', function (assert) { fillIn('#newUserEmail', 'test.user@domain.com'); click('.button-blue'); - // waitToAppear('.user-notification:contains(Added)'); - // waitToDisappear('.user-notification:contains(Added)'); - andThen(function () { let numberOfUsers = find('.user-list tr').length; assert.equal(numberOfUsers, 4, '3 Users listed'); From 41735837b9ae2d82f5f4aed072a4b72d01bbde8f Mon Sep 17 00:00:00 2001 From: zinyando Date: Tue, 19 Jul 2016 16:02:28 +0200 Subject: [PATCH 09/11] Add license information --- app/app/services/tether.js | 11 +++++++++++ app/tests/unit/services/tether-test.js | 12 ------------ 2 files changed, 11 insertions(+), 12 deletions(-) delete mode 100644 app/tests/unit/services/tether-test.js diff --git a/app/app/services/tether.js b/app/app/services/tether.js index 38307d0e..e17c7e85 100644 --- a/app/app/services/tether.js +++ b/app/app/services/tether.js @@ -1,3 +1,14 @@ +// Copyright 2016 Documize Inc. . All rights reserved. +// +// This software (Documize Community Edition) is licensed under +// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html +// +// You can operate outside the AGPL restrictions by purchasing +// Documize Enterprise Edition and obtaining a commercial license +// by contacting . +// +// https://documize.com + import Ember from 'ember'; /** diff --git a/app/tests/unit/services/tether-test.js b/app/tests/unit/services/tether-test.js deleted file mode 100644 index dc2970d5..00000000 --- a/app/tests/unit/services/tether-test.js +++ /dev/null @@ -1,12 +0,0 @@ -import { moduleFor, test } from 'ember-qunit'; - -moduleFor('service:tether', 'Unit | Service | tether', { - // Specify the other units that are required for this test. - // needs: ['service:foo'] -}); - -// Replace this with your real tests. -test('it exists', function(assert) { - let service = this.subject(); - assert.ok(service); -}); From fe1e457d9691cd9a271e045a802cdfce32b498a7 Mon Sep 17 00:00:00 2001 From: zinyando Date: Tue, 19 Jul 2016 18:13:03 +0200 Subject: [PATCH 10/11] Fix auth test to use logout button and tweaks to mirage config --- app/mirage/config.js | 30 +++------------------ app/mirage/factories/document.js | 14 ---------- app/tests/acceptance/authentication-test.js | 3 +-- 3 files changed, 4 insertions(+), 43 deletions(-) diff --git a/app/mirage/config.js b/app/mirage/config.js index c7230444..08dbdec9 100644 --- a/app/mirage/config.js +++ b/app/mirage/config.js @@ -35,38 +35,14 @@ export default function () { return schema.db.documents.where({ folderId: folder_id }); } - if (folder_id = "VzMygEw_3WrtFzto") { - return { - "id": "VzMygEw_3WrtFzto", - "created": "2016-05-11T13:24:17Z", - "revised": "2016-05-11T13:25:51Z", - "name": "Test", - "orgId": "VzMuyEw_3WqiafcD", - "userId": "VzMuyEw_3WqiafcE", - "folderType": 1 - }; - } - if (folder_id = 'V0Vy5Uw_3QeDAMW9') { return null; } }); - this.get('/documents/:id', function () { - return { - "id": "VzMzBUw_3WrtFztv", - "created": "2016-05-11T13:26:29Z", - "revised": "2016-05-11T13:26:29Z", - "orgId": "VzMuyEw_3WqiafcD", - "folderId": "VzMygEw_3WrtFzto", - "userId": "VzMuyEw_3WqiafcE", - "job": "3004c449-b053-49a6-4abc-72688136184d", - "location": "/var/folders/d6/kr81d2fs5bsbm8rz2p092fy80000gn/T/documize/_uploads/3004c449-b053-49a6-4abc-72688136184d/README.md", - "name": "README", - "excerpt": "To Document/ Instructions. GO. go- bindata- assetsfs. SSL.", - "tags": "", - "template": false - }; + this.get('/documents/:id', function (schema, request) { + let id = request.params.id; + return schema.db.documents.where({ id: `${id}` })[0]; }); this.get('/documents/:id/pages', function () { diff --git a/app/mirage/factories/document.js b/app/mirage/factories/document.js index 5d528d89..d9e9efe5 100644 --- a/app/mirage/factories/document.js +++ b/app/mirage/factories/document.js @@ -25,17 +25,3 @@ export default Factory.extend({ "tags": "", "template": false }); -// return { -// "id": "VzMzBUw_3WrtFztv", -// "created": "2016-05-11T13:26:29Z", -// "revised": "2016-05-11T13:26:29Z", -// "orgId": "VzMuyEw_3WqiafcD", -// "folderId": "VzMygEw_3WrtFzto", -// "userId": "VzMuyEw_3WqiafcE", -// "job": "3004c449-b053-49a6-4abc-72688136184d", -// "location": "/var/folders/d6/kr81d2fs5bsbm8rz2p092fy80000gn/T/documize/_uploads/3004c449-b053-49a6-4abc-72688136184d/README.md", -// "name": "README", -// "excerpt": "To Document/ Instructions. GO. go- bindata- assetsfs. SSL.", -// "tags": "", -// "template": false -// }; diff --git a/app/tests/acceptance/authentication-test.js b/app/tests/acceptance/authentication-test.js index 1fc2f369..ba300591 100644 --- a/app/tests/acceptance/authentication-test.js +++ b/app/tests/acceptance/authentication-test.js @@ -30,8 +30,7 @@ test('visiting /auth/login and logging in', function (assert) { test('logging out a user', function (assert) { server.create('meta', { allowAnonymousAccess: false }); userLogin(); - - visit('/auth/logout'); + click('.dropdown-menu a:contains(Logout)'); andThen(function () { assert.equal(currentURL(), '/auth/login', 'Logging out successful'); From 4a5efd26978f833ad1ad47346c44ff39bc48b09d Mon Sep 17 00:00:00 2001 From: zinyando Date: Tue, 19 Jul 2016 18:14:53 +0200 Subject: [PATCH 11/11] Use tether service in dropdown menu --- app/app/components/dropdown-menu.js | 70 +++++++++++++++-------------- 1 file changed, 37 insertions(+), 33 deletions(-) diff --git a/app/app/components/dropdown-menu.js b/app/app/components/dropdown-menu.js index 38fb9f9d..6f82ca24 100644 --- a/app/app/components/dropdown-menu.js +++ b/app/app/components/dropdown-menu.js @@ -1,11 +1,11 @@ // Copyright 2016 Documize Inc. . All rights reserved. // -// This software (Documize Community Edition) is licensed under +// This software (Documize Community Edition) is licensed under // GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html // // You can operate outside the AGPL restrictions by purchasing // Documize Enterprise Edition and obtaining a commercial license -// by contacting . +// by contacting . // // https://documize.com @@ -13,40 +13,44 @@ import Ember from 'ember'; import stringUtil from '../utils/string'; export default Ember.Component.extend({ - target: null, - open: "click", - position: 'bottom right', - contentId: "", - drop: null, + target: null, + open: "click", + position: 'bottom right', + contentId: "", + drop: null, + tether: Ember.inject.service(), - didReceiveAttrs() { - this.set("contentId", 'dropdown-menu-' + stringUtil.makeId(10)); + didReceiveAttrs() { + this.set("contentId", 'dropdown-menu-' + stringUtil.makeId(10)); - // if (this.session.get('isMobile')) { - // this.set('open', "click"); - // } - }, + // if (this.session.get('isMobile')) { + // this.set('open', "click"); + // } + }, - didInsertElement() { - this._super(...arguments); - let self = this; + didInsertElement() { + this._super(...arguments); + let self = this; - let drop = new Drop({ - target: document.getElementById(self.get('target')), - content: self.$(".dropdown-menu")[0], - classes: 'drop-theme-menu', - position: self.get('position'), - openOn: self.get('open'), - tetherOptions: { - offset: "5px 0", - targetOffset: "10px 0" - } - }); + let drop = this.get('tether').createDrop({ + target: document.getElementById(self.get('target')), + content: self.$(".dropdown-menu")[0], + classes: 'drop-theme-menu', + position: self.get('position'), + openOn: self.get('open'), + tetherOptions: { + offset: "5px 0", + targetOffset: "10px 0" + } + }); - self.set('drop', drop); - }, + self.set('drop', drop); + }, - willDestroyElement() { - this.get('drop').destroy(); - } -}); \ No newline at end of file + willDestroyElement() { + let drop = this.get('drop'); + if (drop) { + drop.destroy(); + } + } +});