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"}}