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 +}); 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(); + } + } +}); diff --git a/app/app/services/tether.js b/app/app/services/tether.js new file mode 100644 index 00000000..e17c7e85 --- /dev/null +++ b/app/app/services/tether.js @@ -0,0 +1,33 @@ +// 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'; + +/** + * 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/mirage/config.js b/app/mirage/config.js index 40501d1f..08dbdec9 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 () { @@ -13,48 +24,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 []; }); @@ -63,55 +32,231 @@ 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", + return schema.db.documents.where({ folderId: folder_id }); + } + + if (folder_id = 'V0Vy5Uw_3QeDAMW9') { + return null; + } + }); + + 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 () { + 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": "Empty Document", - "excerpt": "My test document", + "name": "New Document", + "excerpt": "A new 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 - }]; - } else 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 - }; - } else if (folder_id = 'V0Vy5Uw_3QeDAMW9') { - return null; + }); } }); + 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; }); this.post('/folders', function (schema, request) { 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 +266,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 +287,49 @@ 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', () => { + this.get('/folders/:id/permissions', (schema, request) => { + let id = request.params.id; + return schema.db.folderPermissions.where({ id: `${id}` }); + }); + + 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.get('/users/folder/:id', () => { return [{ - "folderId": "VzMuyEw_3WqiafcG", - "userId": "VzMuyEw_3WqiafcE", - "canView": true, - "canEdit": true + "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.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.get('/folders/VzMygEw_3WrtFzto/permissions', () => { - return [{ - "folderId": "VzMygEw_3WrtFzto", - "userId": "VzMuyEw_3WqiafcE", - "canView": true, - "canEdit": true - }]; + this.get('/sections/refresh', (schema, request) => { + let documentID = request.queryParams.documentID; + if (documentID) { + return {}; + } }); this.put('/folders/:id', (schema, request) => { @@ -264,18 +356,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 +365,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) => { + return schema.db.users; }); this.post('/users', (schema, request) => { @@ -353,7 +381,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 +406,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 +421,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/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 new file mode 100644 index 00000000..d9e9efe5 --- /dev/null +++ b/app/mirage/factories/document.js @@ -0,0 +1,27 @@ +// 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({ + "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 +}); diff --git a/app/mirage/factories/folder-permission.js b/app/mirage/factories/folder-permission.js new file mode 100644 index 00000000..e6f26d39 --- /dev/null +++ b/app/mirage/factories/folder-permission.js @@ -0,0 +1,19 @@ +// 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({ + "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..bed871f3 --- /dev/null +++ b/app/mirage/factories/organization.js @@ -0,0 +1,24 @@ +// 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({ + "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..371eadae --- /dev/null +++ b/app/mirage/factories/user.js @@ -0,0 +1,38 @@ +// 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({ + "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": "" + }] +}); 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/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 336785f8..5ba3302d 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 @@ -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,7 +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); visit('/'); andThen(function () { @@ -42,4 +40,4 @@ test('visiting / when authenticated and with { allowAnonymousAccess: true } take 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/authentication-test.js b/app/tests/acceptance/authentication-test.js index 9884a508..ba300591 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,10 +29,8 @@ 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'); + click('.dropdown-menu a:contains(Logout)'); andThen(function () { assert.equal(currentURL(), '/auth/login', 'Logging out successful'); @@ -42,7 +39,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 +49,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 9ab5cf17..19a921b3 100644 --- a/app/tests/acceptance/documents-space-test.js +++ b/app/tests/acceptance/documents-space-test.js @@ -1,47 +1,46 @@ // 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 { 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,20 +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); authenticateUser(); visit('/s/VzMuyEw_3WqiafcG/my-project'); @@ -80,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'); @@ -100,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'); @@ -117,11 +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); authenticateUser(); visit('/s/VzMygEw_3WrtFzto/test'); @@ -150,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'); @@ -165,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'); @@ -186,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'); @@ -197,10 +184,32 @@ 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)'); 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..40de4750 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 @@ -15,7 +15,6 @@ import moduleForAcceptance from 'documize/tests/helpers/module-for-acceptance'; moduleForAcceptance('Acceptance | user profile'); test('visiting /profile', function (assert) { - server.createList('folder', 2); authenticateUser(); visit('/profile'); @@ -28,7 +27,6 @@ test('visiting /profile', function (assert) { }); test('changing user details and email ', function (assert) { - server.createList('folder', 2); authenticateUser(); visit('/profile'); @@ -49,4 +47,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..125ee46c 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 @@ -91,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'); @@ -107,4 +104,4 @@ function checkForCommonAsserts() { findWithAssert('#user-button'); findWithAssert('#accounts-button'); findWithAssert('.info .title'); -} \ No newline at end of file +} 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"}}