1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-07-25 08:09:43 +02:00

initial commit

This commit is contained in:
Harvey Kandola 2016-07-07 18:54:16 -07:00
commit 18933c6767
1841 changed files with 810642 additions and 0 deletions

View file

@ -0,0 +1,48 @@
// Copyright 2016 Documize Inc. <legal@documize.com>. 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 <sales@documize.com>.
//
// https://documize.com
import Ember from 'ember';
import { authenticateSession } from 'documize/tests/helpers/ember-simple-auth';
const {
merge
} = Ember;
export default Ember.Test.registerAsyncHelper('authenticateUser', function (app, attrs = {}) {
authenticateSession(app, merge({
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": ""
}]
}
}, attrs));
});

View file

@ -0,0 +1,6 @@
import Ember from 'ember';
export default function destroyApp(application) {
Ember.run(application, 'destroy');
server.shutdown();
}

View file

@ -0,0 +1,32 @@
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);
if (options.beforeEach) {
options.beforeEach.apply(this, arguments);
}
this.register = (fullName, Factory) => {
let instance = this.application.__deprecatedInstance__;
let registry = instance.register ? instance : instance.registry;
return registry.register(fullName, Factory);
};
},
afterEach() {
destroyApp(this.application);
if (options.afterEach) {
options.afterEach.apply(this, arguments);
}
}
});
}

View file

@ -0,0 +1,11 @@
import Resolver from '../../resolver';
import config from '../../config/environment';
const resolver = Resolver.create();
resolver.namespace = {
modulePrefix: config.modulePrefix,
podModulePrefix: config.podModulePrefix
};
export default resolver;

View file

@ -0,0 +1,24 @@
import Ember from 'ember';
import Application from '../../app';
import config from '../../config/environment';
import './stub-audit';
import './user-login';
import './wait-to-appear';
import './wait-to-disappear';
import './stub-user-notification';
import './authenticate-user';
export default function startApp(attrs) {
let application;
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();
});
return application;
}

View file

@ -0,0 +1,52 @@
// Copyright 2016 Documize Inc. <legal@documize.com>. 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 <sales@documize.com>.
//
// https://documize.com
import Ember from 'ember';
// import netUtil from 'documize/utils/net';
const Audit = Ember.Service.extend({
sessionService: Ember.inject.service('session'),
ready: false,
enabled: true,
init() {
this.start();
},
record(id) {
if (!this.get('enabled')) {
return;
}
if (!this.get('ready')) {
this.start();
}
return id;
},
stop() {},
start() {
let session = this.get('sessionService');
if (!this.get('enabled') || !session.authenticated || this.get('ready')) {
return;
}
this.set('ready', true);
},
});
export default Ember.Test.registerAsyncHelper('stubAudit', function (app, test, attrs = {}) {
test.register('service:audit', Audit.extend(attrs));
});

View file

@ -0,0 +1,32 @@
// Copyright 2016 Documize Inc. <legal@documize.com>. 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 <sales@documize.com>.
//
// https://documize.com
import Ember from 'ember';
const userNotification = Ember.Component.extend({
notifications: [],
didInsertElement() {
// this.eventBus.subscribe('notifyUser', this, 'notifyHandler');
},
willDestroyElement() {
// this.eventBus.unsubscribe('notifyUser');
},
showNotification(msg) {
return msg;
}
});
export default Ember.Test.registerAsyncHelper('stubUserNotification', function (app, test, attrs = {}) {
test.register('component:userNotification', userNotification.extend(attrs));
});

View file

@ -0,0 +1,20 @@
// Copyright 2016 Documize Inc. <legal@documize.com>. 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 <sales@documize.com>.
//
// https://documize.com
import Ember from 'ember';
export default Ember.Test.registerAsyncHelper('userLogin', function () {
visit('/auth/login');
fillIn('#authEmail', 'brizdigital@gmail.com');
fillIn('#authPassword', 'zinyando123');
click('button');
});

View file

@ -0,0 +1,32 @@
// Copyright 2016 Documize Inc. <legal@documize.com>. 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 <sales@documize.com>.
//
// https://documize.com
import Ember from 'ember';
function isVisible(selector) {
return $(selector).length > 0;
}
function checkVisibility(selector, interval, resolve, visibility) {
if (isVisible(selector) === visibility) {
resolve($(selector));
} else {
Ember.run.later(null, function () {
checkVisibility(selector, interval, resolve, visibility);
}, interval);
}
}
export default Ember.Test.registerAsyncHelper('waitToAppear', function (app, selector, interval = 200) {
return new Ember.RSVP.Promise(function (resolve) {
checkVisibility(selector, interval, resolve, true);
});
});

View file

@ -0,0 +1,32 @@
// Copyright 2016 Documize Inc. <legal@documize.com>. 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 <sales@documize.com>.
//
// https://documize.com
import Ember from 'ember';
function isVisible(selector) {
return $(selector).length > 0;
}
function checkVisibility(selector, interval, resolve, visibility) {
if (isVisible(selector) === visibility) {
resolve($(selector));
} else {
Ember.run.later(null, function () {
checkVisibility(selector, interval, resolve, visibility);
}, interval);
}
}
export default Ember.Test.registerAsyncHelper('waitToDisappear', function (app, selector, interval = 200) {
return new Ember.RSVP.Promise(function (resolve) {
checkVisibility(selector, interval, resolve, false);
});
});