mirror of
https://github.com/darkwire/darkwire.io.git
synced 2025-07-18 18:54:52 +00:00
Merge branch 'develop' into feature/fileTransfer
* develop: Add Travis yml file Add zombie.js tests
This commit is contained in:
commit
e1d095da84
@ -4,4 +4,4 @@ node_js:
|
|||||||
before_script:
|
before_script:
|
||||||
- gulp bundle
|
- gulp bundle
|
||||||
- sleep 5
|
- sleep 5
|
||||||
script: npm test
|
script: gulp test
|
@ -4,6 +4,7 @@ import WindowHandler from './window';
|
|||||||
import CryptoUtil from './crypto';
|
import CryptoUtil from './crypto';
|
||||||
import Chat from './chat';
|
import Chat from './chat';
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
|
import sanitizeHtml from 'sanitize-html';
|
||||||
|
|
||||||
let fs = window.RequestFileSystem || window.webkitRequestFileSystem;
|
let fs = window.RequestFileSystem || window.webkitRequestFileSystem;
|
||||||
|
|
||||||
@ -60,9 +61,15 @@ $(function() {
|
|||||||
|
|
||||||
// Prevents input from having injected markup
|
// Prevents input from having injected markup
|
||||||
function cleanInput(input) {
|
function cleanInput(input) {
|
||||||
let message = $('<div/>').html(input).text();
|
let message = sanitizeHtml(_.escape(input), {
|
||||||
|
allowedTags: ['b', 'i', 'em', 'strong', 'a'],
|
||||||
|
allowedAttributes: {
|
||||||
|
'a': ['href']
|
||||||
|
}
|
||||||
|
});
|
||||||
|
// let message = $('<div/>').html(input).text();
|
||||||
message = Autolinker.link(message);
|
message = Autolinker.link(message);
|
||||||
return message;
|
return _.escape(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Keyboard events
|
// Keyboard events
|
||||||
@ -200,10 +207,10 @@ $(function() {
|
|||||||
function handleMessageSending() {
|
function handleMessageSending() {
|
||||||
let message = chat.inputMessage;
|
let message = chat.inputMessage;
|
||||||
let cleanedMessage = cleanInput(message.val());
|
let cleanedMessage = cleanInput(message.val());
|
||||||
let isCommand = chat.parseCommand(cleanedMessage);
|
let slashCommand = chat.parseCommand(cleanedMessage);
|
||||||
|
|
||||||
if (isCommand) {
|
if (slashCommand) {
|
||||||
return chat.executeCommand(isCommand, this);
|
return chat.executeCommand(slashCommand, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prevent markup from being injected into the message
|
// Prevent markup from being injected into the message
|
||||||
|
22
test/app.js
22
test/app.js
@ -1,18 +1,15 @@
|
|||||||
import appPkg from '../package.json';
|
|
||||||
import helpers from './helpers';
|
import helpers from './helpers';
|
||||||
import app from '../index';
|
import app from '../index';
|
||||||
import mochaJSCS from 'mocha-jscs';
|
import mochaJSCS from 'mocha-jscs';
|
||||||
import mochaJSHint from 'mocha-jshint';
|
import mochaJSHint from 'mocha-jshint';
|
||||||
import Browser from 'zombie';
|
|
||||||
|
|
||||||
const APPVER = 'v' + appPkg.version;
|
|
||||||
|
|
||||||
|
const Browser = require('zombie');
|
||||||
Browser.localhost('localhost', 3000);
|
Browser.localhost('localhost', 3000);
|
||||||
|
|
||||||
mochaJSCS();
|
mochaJSCS();
|
||||||
mochaJSHint();
|
mochaJSHint();
|
||||||
|
|
||||||
describe('Darkwire', () => {
|
describe('Visiting /', () => {
|
||||||
|
|
||||||
const browser = new Browser();
|
const browser = new Browser();
|
||||||
|
|
||||||
@ -25,25 +22,19 @@ describe('Darkwire', () => {
|
|||||||
browser.visit('/', done);
|
browser.visit('/', done);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('Navigate to /', () => {
|
|
||||||
it('should be running released version', () => {
|
|
||||||
browser.assert.text('#appVersion', APPVER);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should be successful', () => {
|
it('should be successful', () => {
|
||||||
browser.assert.success();
|
browser.assert.success();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should show welcome modal', () => {
|
it('should show welcome modal', () => {
|
||||||
browser.assert.evaluate('$("#first-modal:visible").length', 1);
|
browser.assert.evaluate('$("#first-modal:visible").length', 1);
|
||||||
browser.assert.text('#first-modal h4.modal-title', 'Welcome to darkwire.io ' + APPVER);
|
browser.assert.text('#first-modal h4.modal-title', 'Welcome to darkwire.io');
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('closing the initial modal', () => {
|
describe('closing the initial modal', () => {
|
||||||
|
|
||||||
before((done) => {
|
before((done) => {
|
||||||
return browser.pressButton('#first-modal .modal-footer button', done);
|
browser.pressButton('#first-modal .modal-footer button', done);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should close the modal and show the main chat page', () => {
|
it('should close the modal and show the main chat page', () => {
|
||||||
@ -75,8 +66,9 @@ describe('Darkwire', () => {
|
|||||||
browser.click('span#send-message-btn', done);
|
browser.click('span#send-message-btn', done);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should send message', (done) => {
|
it('should send message', () => {
|
||||||
helpers.zombie.waitFor(browser, '$(".messageBody").text() === "Hello world"', done);
|
browser.tabs.current = 0;
|
||||||
|
browser.assert.text('body', /Hello world/);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -44,16 +44,6 @@ var helpers = {
|
|||||||
return [1,2,3,4];
|
return [1,2,3,4];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
},
|
|
||||||
zombie: {
|
|
||||||
waitFor: (browser, str, cb) => {
|
|
||||||
let int = setInterval(() => {
|
|
||||||
if (browser.evaluate(str)) {
|
|
||||||
clearInterval(int);
|
|
||||||
cb();
|
|
||||||
}
|
|
||||||
}, 50);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user