Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

React / Redux + better test coverage #145

Merged
merged 87 commits into from
Jan 8, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
97863a0
setup for react and babel6
lemieux Nov 6, 2015
9eb5fc1
setup redux store, added header and notification components
lemieux Nov 8, 2015
1b8a5d8
added conversation components and rendering logic
lemieux Nov 8, 2015
b60674d
added login and get/send conversation
lemieux Nov 8, 2015
a528be4
added settings view, fix core server url setup, started to add faye s…
lemieux Nov 9, 2015
54a89be
added faye
lemieux Nov 17, 2015
5ecb5a8
block send message if input is empty
lemieux Nov 17, 2015
16157f9
use new smooch-core auth format
lemieux Nov 17, 2015
76b0766
base for webpack build setup
lemieux Nov 23, 2015
20781d9
mv webpack stuff to its folder, changed build folder to dist
lemieux Nov 23, 2015
b68c931
added grunt task for webpack
lemieux Nov 23, 2015
ea0ad45
updated dev server public path handling
lemieux Nov 23, 2015
c5a69c4
track api
lemieux Dec 15, 2015
446a4df
Merge branch 'integration' into f/reactify
lemieux Dec 15, 2015
d5ec0e1
merge fix
lemieux Dec 15, 2015
e91de6c
merged webpack in
lemieux Dec 15, 2015
e856d69
fix merge leftovers
lemieux Dec 15, 2015
6b59cbe
fixed open/close animation, fixed scroll to bottom
lemieux Dec 15, 2015
392ea9d
clean up, added get conversation after track
lemieux Dec 15, 2015
72fbe9b
set up tests with karma
lemieux Dec 16, 2015
7f59b0b
added test for header component
lemieux Dec 16, 2015
a39cf2d
added click simulation test on header
lemieux Dec 16, 2015
0abf919
removed useless tasks and packages
lemieux Dec 16, 2015
0cd21e3
full test suite for header component
lemieux Dec 16, 2015
0dd8af0
added options variant of autolink test
lemieux Dec 16, 2015
2b993b4
added tests for chat input component
lemieux Dec 16, 2015
2cedf16
added test suite for message component
lemieux Dec 17, 2015
f794183
finished test suite for message component
lemieux Dec 17, 2015
8887a00
split message from conversation component files, added test suite for…
lemieux Dec 17, 2015
919cefa
added full test suite for widget component
lemieux Dec 18, 2015
92a435f
replace relative path with module paths
lemieux Dec 18, 2015
ea3414c
added test suite for auth reducer
lemieux Dec 18, 2015
572048d
added test suite for user reducer
lemieux Dec 18, 2015
d2ed95f
added test suite for storage
lemieux Dec 18, 2015
f0261b7
added test suite for storage, start test suite for smooch
lemieux Dec 18, 2015
a618da1
added most of test cases for smooch js api
lemieux Dec 21, 2015
0d2b97c
removed rewire
lemieux Dec 21, 2015
bd375d4
added a reset action to reset store state
lemieux Dec 21, 2015
14b72a0
added test cases for update user
lemieux Dec 21, 2015
ab28c2d
move some logic in the services and adapted tests to it
lemieux Dec 23, 2015
138279e
added test for auth service
lemieux Dec 23, 2015
c67961a
added redux devtools
lemieux Dec 27, 2015
6729627
added notification component
lemieux Dec 27, 2015
736e0be
added test for notification component
lemieux Dec 29, 2015
9eebd79
added test for onClick handler
lemieux Dec 30, 2015
a1fa023
added test suite for settings component
lemieux Dec 31, 2015
dec0767
format jsx code
lemieux Jan 2, 2016
8a907e6
added user service test suite
lemieux Jan 2, 2016
5b442e9
added conversation service test suite and remove useless stuff
lemieux Jan 4, 2016
280fe0b
removed old templates, added placeholder for sendMessage tests
lemieux Jan 4, 2016
2d07fca
better handling for read only email
lemieux Jan 4, 2016
f4d326b
added todo for isDirty flag
lemieux Jan 4, 2016
42f3142
remove legacy js code
lemieux Jan 4, 2016
9e6272f
Merge branch 'integration' into f/reactify
lemieux Jan 4, 2016
4603fe7
PR comments, fixed local storage tests on Chrome
lemieux Jan 4, 2016
50e9ce6
some formatting, added first message middleware
lemieux Jan 5, 2016
1d9a6dd
added tests for first message middleware
lemieux Jan 5, 2016
6a44d75
remove underscore dependency and added pick utils
lemieux Jan 5, 2016
3640c5d
removed node-lessify
lemieux Jan 5, 2016
0dc83b5
added throttling for update user
lemieux Jan 5, 2016
658df7b
added isDirty check before saving
lemieux Jan 5, 2016
fb48392
added support for unread count
lemieux Jan 5, 2016
5ad248e
added observable utils
lemieux Jan 6, 2016
d98c0c7
added custom text handling
lemieux Jan 6, 2016
c77298b
added events for new messages
lemieux Jan 6, 2016
2d32f2e
support for sliding in and out settings
lemieux Jan 7, 2016
d1a38f2
remove transition from notification component
lemieux Jan 7, 2016
4bac8bf
fixed tests after moving dom around in notification and settings
lemieux Jan 7, 2016
ca152ec
added test for trackEvent
lemieux Jan 7, 2016
0d37cab
test for isdirty
lemieux Jan 7, 2016
8c68e7b
added test for send message
lemieux Jan 7, 2016
f193a93
reset last triggered message ts on destroy
lemieux Jan 7, 2016
f1b0c30
added underscore back in the dev deps
lemieux Jan 7, 2016
6840020
Lint Lemieux's code :)
alavers Jan 7, 2016
f7721e3
Merge pull request #1 from smooch/f/reactify-linted
lemieux Jan 7, 2016
2f32d07
use strict
lemieux Jan 7, 2016
f72faa7
Lint the jsx files
alavers Jan 7, 2016
70a0c7f
Merge pull request #2 from smooch/f/reactify-linted
lemieux Jan 7, 2016
94f91b0
added support for default config
lemieux Jan 7, 2016
ce74a35
Merge branch 'f/reactify' of github.com:lemieux/supportkit-js into f/…
lemieux Jan 7, 2016
485bb6f
added support for service url
lemieux Jan 7, 2016
c8bf47e
moved first user message handling to service
lemieux Jan 8, 2016
064f13f
use lodash.pick instead of our own
lemieux Jan 8, 2016
e4d95e6
put back applyMiddleware in dev
lemieux Jan 8, 2016
9b39f7c
fix notification class name
lemieux Jan 8, 2016
3d21580
get rid of defaultProps
lemieux Jan 8, 2016
bfbfb3f
fixed logo anchoring
lemieux Jan 8, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
{
"presets": [
"stage-2",
"es2015",
"react"
],
"plugins": [
"transform-runtime"
]
}
36 changes: 29 additions & 7 deletions .esformatter
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"AssignmentExpression": 1,
"BinaryExpression": 1,
"ConditionalExpression": 1,
"CallExpression": 0,
"CallExpression": 1,
"CatchClause": 1,
"ConditionalExpression": 1,
"DoWhileStatement": 1,
Expand All @@ -17,15 +17,14 @@
"MemberExpression": 1,
"MultipleVariableDeclaration": 1,
"ObjectExpression": 1,
"ReturnStatement": 0,
"ReturnStatement": 1,
"SwitchCase": 1,
"SwitchStatement": 1,
"TopLevelFunctionBlock": 1,
"TryStatement": 1,
"WhileStatement": 1
},


"lineBreak": {
"value": "\n",

Expand Down Expand Up @@ -303,11 +302,34 @@
"plugins": [
"esformatter-quotes",
"esformatter-braces",
"esformatter-var-each",
"esformatter-dot-notation"
"esformatter-dot-notation",
"esformatter-jsx"
],
"quotes": {
"type": "single",
"avoidEscape": false
}
}
},
"jsx": {
// keep the node attributes on the same line as the open tag. Default is true.
// Setting this to false will put each one of the attributes on a single line
"attrsOnSameLineAsTag": false,
// how many attributes should the node have before having to put each
// attribute in a new line. Default 1
"maxAttrsOnTag": 3,
// if the attributes are going to be put each one on its own line, then keep the first
// on the same line as the open tag
"firstAttributeOnSameLine": true,
// default to one space. Make it empty if you don't like spaces between JSXExpressionContainers
"spaceInJSXExpressionContainers": " ",
// align the attributes with the first attribute (if the first attribute was kept on the same line as on the open tag)
"alignWithFirstAttribute": true,
"htmlOptions": { // same as the ones passed to js-beautifier.html
"brace_style": "collapse",
"indent_char": " ",
"indent_size": 4,
"max_preserve_newlines": 2,
"preserve_newlines": true
//wrap_line_length: 250
}
}
}
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
38 changes: 38 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"parser": "babel-eslint",
"rules": {
"indent": [
2,
4,
{"SwitchCase": 1}
],
"quotes": [
2,
"single"
],
"linebreak-style": [
2,
"unix"
],
"semi": [
2,
"always"
],
"no-unused-vars": 0
},
"env": {
"es6": true,
"node": true,
"commonjs": true,
"browser": true,
"mocha": true
},
"globals": {
"expect": true,
"VERSION": true
},
"ecmaFeatures": {
"jsx": true
},
"extends": "eslint:recommended"
}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
node_modules
bower_components
*.log
build
tmp
dist/
grunt-aws.json
grunt-maxcdn.json
*.sublime-workspace
junit
config/*
!config/build
!config/default
!config/default/*.json
example/*
!example/template
!example/template/*.html
npm-debug*
3 changes: 2 additions & 1 deletion .jshintrc
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@
"alert",
"module",
"Promise",
"global"
"global",
"VERSION"
],
"maxparams" : 30,
"maxdepth" : 5,
Expand Down
76 changes: 16 additions & 60 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

/* global process:false */

var _ = require('underscore');

module.exports = function(grunt) {
require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
grunt.registerTask('awsconfig', function() {
Expand Down Expand Up @@ -46,19 +44,6 @@ module.exports = function(grunt) {
license: grunt.file.read('LICENSE'),
globalVersion: '<%= pkg.version %>',
clean: ['dist/*'],
karma: {
unit: {
configFile: 'karma.conf.js',
singleRun: false,
browsers: ['PhantomJS', 'Chrome'],
reporters: ['progress']
},
ci: {
configFile: 'karma.conf.js',
singleRun: true,
browsers: ['PhantomJS']
}
},

s3: {
options: {
Expand All @@ -76,14 +61,6 @@ module.exports = function(grunt) {
src: 'dist/smooch.js.map',
dest: 'smooch.js.map'
}]
},
images: {
upload: [
{
src: 'src/images/**',
dest: 'images/'
}
]
}
},

Expand All @@ -95,21 +72,20 @@ module.exports = function(grunt) {
},

maxcdn: {
purgeCache: {
options: {
companyAlias: '<%= maxcdn.options.companyAlias %>',
consumerKey: '<%= maxcdn.options.consumerKey %>',
consumerSecret: '<%= maxcdn.options.consumerSecret %>',
zone_id: '<%= maxcdn.options.zoneId %>',
method: 'delete'
},
files: [
{ dest: '/smooch.min.js' },
{ dest: '/smooch.js.map' },
{ dest: '/images/logo_webwidget.png' },
{ dest: '/images/logo_webwidget_2x.png' }
],
},
purgeCache: {
options: {
companyAlias: '<%= maxcdn.options.companyAlias %>',
consumerKey: '<%= maxcdn.options.consumerKey %>',
consumerSecret: '<%= maxcdn.options.consumerSecret %>',
zone_id: '<%= maxcdn.options.zoneId %>',
method: 'delete'
},
files: [
{
dest: '/smooch.min.js'
}
]
}
},

release: {
Expand Down Expand Up @@ -254,39 +230,19 @@ module.exports = function(grunt) {
grunt.task.run('branchCheck', 'publish:prepare', 'publish:release', 'publish:cleanup');
});

grunt.registerTask('loadConfig', 'Loads config from config folder (uses default if none present', function() {
var defaultConfig = grunt.file.readJSON('config/default/config.json');
var config = {};

try {
config = grunt.file.readJSON('config/config.json');
}
catch (err) {
grunt.log.warn('You might want to create a config with your app token at config/config.json');
}

var merged = _.extend(defaultConfig, config);
grunt.config.set('config', merged);
});

grunt.registerTask('setMinMode', function() {
grunt.config.set('config.WIDGET_CODE', 'smooch.min.js');
});
grunt.registerTask('build', ['clean', 'exec:build']);
grunt.registerTask('dev', ['concurrent:dev']);


grunt.registerTask('build', ['clean', 'exec:build']);
grunt.registerTask('dev', ['concurrent:dev']);

grunt.registerTask('deploy', ['build', 'awsconfig', 'maxcdnconfig', 's3:js', 'maxcdn']);
grunt.registerTask('test', ['karma:unit']);
grunt.registerTask('test:ci', ['karma:ci']);
grunt.registerTask('default', ['dev']);

grunt.registerTask('publish:prepare', ['versionBump', 'exec:commitFiles', 'exec:createRelease', 'build', 'exec:addDist']);
grunt.registerTask('publish:release', ['release']);
grunt.registerTask('publish:cleanup', ['exec:cleanRelease', 'exec:push']);

grunt.registerTask('branchCheck', 'Checks that you are publishing from Master branch with no working changes', ['gitinfo', 'checkBranchStatus']);

grunt.registerTask('cdnify', ['awsconfig', 's3:images']);
};
2 changes: 1 addition & 1 deletion circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ dependencies:
- npm install -g npm@3
test:
override:
- grunt test:ci
- npm run test:ci
post:
- grunt build

Expand Down
3 changes: 1 addition & 2 deletions config/default/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,5 @@
"USER_ID": "",
"GIVEN_NAME": "DEFAULT_NAME",
"SURNAME": "DEFAULT_SURNAME",
"EMAIL": "[email protected]",
"WIDGET_CODE": "smooch.js"
"EMAIL": "[email protected]"
}
12 changes: 7 additions & 5 deletions karma.conf.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// Karma configuration
// Generated on Fri Nov 07 2014 08:13:06 GMT-0500 (EST)

module.exports = function(config) {
var testReportsPath = process.env.CIRCLE_TEST_REPORTS || '.';
var _ = require('underscore');
Expand All @@ -22,7 +19,10 @@ module.exports = function(config) {
frameworks: ['mocha', 'sinon-chai', 'phantomjs-shim'],

// list of files / patterns to load in the browser
files: ['test/specs/**/*.spec.js'],
files: [
'test/specs/**/*.spec.js',
'test/specs/**/*.spec.jsx'
],


// list of files to exclude
Expand All @@ -32,7 +32,8 @@ module.exports = function(config) {
// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
'test/specs/**/*.spec.js': ['webpack', 'sourcemap']
'test/specs/**/*.spec.js': ['webpack', 'sourcemap'],
'test/specs/**/*.spec.jsx': ['webpack', 'sourcemap']
},


Expand Down Expand Up @@ -81,5 +82,6 @@ module.exports = function(config) {
// i. e.
noInfo: true
},
specReporter: {}
});
};
29 changes: 18 additions & 11 deletions lib/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,16 @@ module.exports = function(options) {
'http://localhost:2992/_assets/' :
'/_assets/';

var config = require('../config/default/config.json');

try {
Object.assign(config, require('../config/config.json'));
}
catch (e) {}

var renderer = new Renderer({
scriptUrl: publicPath + 'smooch.js',
data: require('../config/config.json')
data: config
});

var app = express();
Expand All @@ -30,22 +37,22 @@ module.exports = function(options) {
// application
app.get('/*', function(req, res) {
renderer.render(
req.path, {}, function(err, html) {
if (err) {
res.statusCode = 500;
res.contentType = 'text; charset=utf8';
res.end(err.message);
return;
req.path, {}, function(err, html) {
if (err) {
res.statusCode = 500;
res.contentType = 'text; charset=utf8';
res.end(err.message);
return;
}
res.contentType = 'text/html; charset=utf8';
res.end(html);
}
res.contentType = 'text/html; charset=utf8';
res.end(html);
}
);
});


var port = process.env.PORT || options.defaultPort || 8080;
app.listen(port, function() {
console.log('Server listening on port ' + port);
console.log('Server listening on port ' + port); //eslint-disable-line no-console
});
};
Loading