diff --git a/e2e/clients_path/clients.spec.js b/e2e/clients_path/clients.spec.js new file mode 100644 index 000000000..a01aff850 --- /dev/null +++ b/e2e/clients_path/clients.spec.js @@ -0,0 +1,12 @@ +import createNightmare from '../nightmare'; +const nightmare = createNightmare(); + +describe('Clients path', () => { + it('should create a new client', done => { + // nightmare user to go any further. + nightmare.login('Nightmare', 'NightmarePassword') + .then(() => { + done(); + }); + }); +}); diff --git a/e2e/e2e.js b/e2e/e2e.js new file mode 100644 index 000000000..b837633d8 --- /dev/null +++ b/e2e/e2e.js @@ -0,0 +1,39 @@ +require('babel-core/register')({presets: ['es2015']}); + +process.on('warning', warning => { + console.log(warning.name); + console.log(warning.message); + console.log(warning.stack); +}); + +var verbose = false; + +if (process.argv[2] === '--v') { + verbose = true; +} + +var Jasmine = require('jasmine'); +var jasmine = new Jasmine(); +var SpecReporter = require('jasmine-spec-reporter').SpecReporter; + +jasmine.loadConfig({ + spec_files: [ + './helpers.js', + './**/*[sS]pec.js' + ], + helpers: [ + // to implement + // '/api/utils/jasmineHelpers.js' + ] +}); + +jasmine.addReporter(new SpecReporter({ + spec: { + // displayStacktrace: 'summary', + displaySuccessful: verbose, + displayFailedSpec: true, + displaySpecDuration: true + } +})); + +jasmine.execute(); diff --git a/e2e/helpers.js b/e2e/helpers.js new file mode 100644 index 000000000..49f46eaaa --- /dev/null +++ b/e2e/helpers.js @@ -0,0 +1,10 @@ +import Nightmare from 'nightmare'; + +Nightmare.action('login', function(name, password, done) { + this.goto('http://localhost:5000/auth/?apiKey=salix') + .wait('body > vn-login > div > div > div > form > vn-textfield:nth-child(1) > div > input') + .type('body > vn-login > div > div > div > form > vn-textfield:nth-child(1) > div > input', name) + .type('body > vn-login > div > div > div > form > vn-textfield:nth-child(2) > div > input', password) + .click('input[type="submit"]') + .then(done); +}); diff --git a/e2e/nightmare.js b/e2e/nightmare.js new file mode 100644 index 000000000..850242774 --- /dev/null +++ b/e2e/nightmare.js @@ -0,0 +1,22 @@ +/* eslint no-console: 0 */ +import Nightmare from 'nightmare'; +import './helpers'; + +export default function createNightmare(width = 1100, height = 600) { + const nightmare = new Nightmare({show: true, typeInterval: 10}).viewport(width, height); + + nightmare.on('page', function(type, message, error) { + fail(error); + }); + + nightmare.on('console', function(type, message) { + if (type === 'error') { + fail(message); + } + if (type === 'log') { + console.log(message); + } + }); + + return nightmare; +} diff --git a/package.json b/package.json index 75847067b..d8f1cb303 100644 --- a/package.json +++ b/package.json @@ -52,6 +52,7 @@ "karma-sourcemap-loader": "^0.3.7", "karma-webpack": "^2.0.4", "merge-stream": "^1.0.1", + "nightmare": "^2.10.0", "node-sass": "^3.11.0", "nodemon": "^1.12.0", "pre-commit": "^1.1.3", diff --git a/services/auth/server/datasources.test.json b/services/auth/server/datasources.test.json new file mode 100644 index 000000000..d8443f0c5 --- /dev/null +++ b/services/auth/server/datasources.test.json @@ -0,0 +1,20 @@ +{ + "db": + { + "name": "db", + "connector": "memory", + "file": "db.json" + }, + "auth": { + "name": "mysql", + "connector": "mysql", + "database": "salix", + "debug": false, + "host": "localhost", + "port": 3306, + "username": "root", + "password": "", + "connectTimeout": 20000, + "acquireTimeout": 20000 + } + } \ No newline at end of file diff --git a/services/client/common/methods/client/specs/activate.spec.js b/services/client/common/methods/client/specs/activate.spec.js deleted file mode 100644 index 2988ac410..000000000 --- a/services/client/common/methods/client/specs/activate.spec.js +++ /dev/null @@ -1,5 +0,0 @@ -describe('description', () => { - it('should ...', () => { - expect(true).toBe(true); - }); -}); \ No newline at end of file diff --git a/services/client/common/methods/client/specs/create.spec.js b/services/client/common/methods/client/specs/create.spec.js new file mode 100644 index 000000000..bed7e9796 --- /dev/null +++ b/services/client/common/methods/client/specs/create.spec.js @@ -0,0 +1,28 @@ +var app = require('../../../../server/server'); +var Client = app.models.Client; +describe('Client Create()', () => { + + beforeEach(() => { + //wipe db + //insert firxtures + }); + + let data = { + name: 'John', + userName: 'John', + email: 'John@wayne.com', + fi: 'The Man', + socialName: 'Wayne industries' + } + + it('should createa new account', (done) => { + Client.createUserProfile(data, (error) => { + //connect to db and query for the new account OR use accounts model to check it like this + app.models.Account.findOne({where: {name: 'John'}}) + .then((account) => { + console.log(account); + done(); + }); + }); + }); +}); \ No newline at end of file diff --git a/services/utils/jasmineHelpers.js b/services/utils/jasmineHelpers.js new file mode 100644 index 000000000..11a808d1d --- /dev/null +++ b/services/utils/jasmineHelpers.js @@ -0,0 +1,8 @@ +export function catchErrors(done) { + return error => { + if (error instanceof Error) { + return done.fail(error.stack); + } + return done.fail(JSON.stringify(error)); + }; +} diff --git a/services_tests.js b/services_tests.js index 93ad6295c..5047ab208 100644 --- a/services_tests.js +++ b/services_tests.js @@ -1,10 +1,10 @@ require('babel-core/register')({presets: ['es2015']}); -// process.on('warning', warning => { -// console.log(warning.name); -// console.log(warning.message); -// console.log(warning.stack); -// }); +process.on('warning', warning => { + console.log(warning.name); + console.log(warning.message); + console.log(warning.stack); +}); var verbose = false;