mirror of
https://github.com/documize/community.git
synced 2025-07-25 08:09:43 +02:00
initial commit
This commit is contained in:
commit
18933c6767
1841 changed files with 810642 additions and 0 deletions
48
app/tests/helpers/authenticate-user.js
Normal file
48
app/tests/helpers/authenticate-user.js
Normal 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));
|
||||
});
|
6
app/tests/helpers/destroy-app.js
Normal file
6
app/tests/helpers/destroy-app.js
Normal file
|
@ -0,0 +1,6 @@
|
|||
import Ember from 'ember';
|
||||
|
||||
export default function destroyApp(application) {
|
||||
Ember.run(application, 'destroy');
|
||||
server.shutdown();
|
||||
}
|
32
app/tests/helpers/module-for-acceptance.js
Normal file
32
app/tests/helpers/module-for-acceptance.js
Normal 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);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
11
app/tests/helpers/resolver.js
Normal file
11
app/tests/helpers/resolver.js
Normal 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;
|
24
app/tests/helpers/start-app.js
Normal file
24
app/tests/helpers/start-app.js
Normal 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;
|
||||
}
|
52
app/tests/helpers/stub-audit.js
Normal file
52
app/tests/helpers/stub-audit.js
Normal 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));
|
||||
});
|
32
app/tests/helpers/stub-user-notification.js
Normal file
32
app/tests/helpers/stub-user-notification.js
Normal 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));
|
||||
});
|
20
app/tests/helpers/user-login.js
Normal file
20
app/tests/helpers/user-login.js
Normal 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');
|
||||
});
|
32
app/tests/helpers/wait-to-appear.js
Normal file
32
app/tests/helpers/wait-to-appear.js
Normal 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);
|
||||
});
|
||||
});
|
32
app/tests/helpers/wait-to-disappear.js
Normal file
32
app/tests/helpers/wait-to-disappear.js
Normal 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);
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue