Skip to content

Commit

Permalink
Merge pull request #171 from sourcejs/0.5.5-dev
Browse files Browse the repository at this point in the history
0.5.5
  • Loading branch information
robhrt7 committed Aug 16, 2015
2 parents 2b9fabe + 7c2d698 commit 96ceca9
Show file tree
Hide file tree
Showing 14 changed files with 338 additions and 26 deletions.
35 changes: 29 additions & 6 deletions Gruntfile.js
Expand Up @@ -7,6 +7,8 @@ global.pathToApp = pathToApp;
var loadOptions = require('./core/loadOptions');

module.exports = function(grunt) {
var appPort = grunt.option('app-port') || 8080;

// load all grunt tasks matching the `grunt-*` pattern
require('load-grunt-tasks')(grunt);

Expand Down Expand Up @@ -177,11 +179,18 @@ module.exports = function(grunt) {

mochaTest: {
test: {
src: ['test/**/*.js']
src: ['test/specs/**/*.js']
},
noApp: {
src: ['test/specs/lib/**/*.js']
}
},

casperjs: {
options: {
casperjsOptions: ['--app-port='+appPort]
},
files: ['test/casperjs/**/*.js']
}
});

Expand Down Expand Up @@ -286,6 +295,11 @@ module.exports = function(grunt) {
]);

grunt.registerTask('ci-post-run', [
'test',
'test-func'
]);

grunt.registerTask('ci-post-run-win', [
'test'
]);

Expand All @@ -297,14 +311,23 @@ module.exports = function(grunt) {

// Test task. Execute with running app
grunt.registerTask('test', 'Run ALL tests or specified by second param', function () {
// if custom mask set - `grunt test --spec=test/specs/middleware/**/*.js`
var spec = grunt.option('spec');

if (spec) {
// if custom mask set - `grunt test --spec=test/specs/middleware/**/*.js`
grunt.config.set('mochaTest.test.src', [spec]);
grunt.task.run('mochaTest');
} else {
grunt.task.run('mochaTest');
}

grunt.task.run('mochaTest');
});

// Test task. Execute with running app
grunt.registerTask('test-func', 'Run ALL functional tests or specified by second param', function () {
// if custom mask set - `grunt test --spec=test/specs/middleware/**/*.js`
var spec = grunt.option('spec');
if (spec) {
grunt.config.set('casperjs.files', [spec]);
}

grunt.task.run('casperjs');
});
};
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -52,6 +52,7 @@ If you notice some bugs, or need to help finding a better solution in your proce
[Materials for presentations](https://github.com/sourcejs/pres).

## Updates
* 16.08.15 [0.5.5](https://github.com/sourcejs/Source/releases/tag/0.5.5) and [0.5.5-no-jsdom](https://github.com/sourcejs/Source/releases/tag/0.5.5-no-jsdom) patch release with `<markdown>` tag fix and set of functional tests
* 15.08.15 [0.5.4](https://github.com/sourcejs/Source/releases/tag/0.5.4) and [0.5.4-no-jsdom](https://github.com/sourcejs/Source/releases/tag/0.5.4-no-jsdom) with middleware loader, relative paths in navigation support and other improvements
* 28.05.15 [0.5.3](https://github.com/sourcejs/Source/releases/tag/0.5.3) context options support, source-as-npm package, CI integration, watcher stability improvements and other great features
* 28.05.15 [0.5.3-no-jsdom](https://github.com/sourcejs/Source/releases/tag/0.5.3-no-jsdom) special release without JSDom for Windows users
Expand Down
3 changes: 2 additions & 1 deletion app.js
Expand Up @@ -33,6 +33,7 @@ commander
.option('--html', 'Turn on HTML parser on app start (requires installed and enabled parser).')
.option('--test', 'Run app with tests.')
.option('--no-watch', 'Run with disabled watcher.')
.option('--post-grunt [string]', 'Define Grunt command to run after app start', 'ci-post-run')
.parse(process.argv);

global.commander = commander;
Expand Down Expand Up @@ -230,7 +231,7 @@ if (!module.parent) {
if (commander.test) {
var spawn = require('cross-spawn');

spawn('./node_modules/grunt-cli/bin/grunt', ['ci-post-run'], {stdio: 'inherit'})
spawn('./node_modules/grunt-cli/bin/grunt', [commander.postGrunt, '--port='+port], {stdio: 'inherit'})
.on('close', function (code) {
if (code === 0) {
log.info('Test successful');
Expand Down
4 changes: 2 additions & 2 deletions appveyor.yml
Expand Up @@ -16,8 +16,8 @@ before_test: "git clone https://github.com/sourcejs/init.git user"

test_script:
- node --version && npm --version
- ps: "npm run ci-test # PowerShell" # Pass comment to PS for easier debugging
- cmd: "npm run ci-test-nw" # Run without watch because of CI bug
- ps: "npm run ci-test-win # PowerShell" # Pass comment to PS for easier debugging
- cmd: "npm run ci-test-win" # Run without watch because of CI bug

matrix:
fast_finish: true
Expand Down
2 changes: 1 addition & 1 deletion assets/js/modules/codeSource.js
Expand Up @@ -222,7 +222,7 @@ define([
};

if ($('[class*="src-"]:not(.source_visible)')[0]) {
innerNavigation.addMenuItem(RES_TOGGLER_SHOW_CODE, showAllCode, hideAllCode);
innerNavigation.addMenuItem(RES_TOGGLER_SHOW_CODE, showAllCode, hideAllCode, 'source_source-code_action-item');
}

showStaticCode();
Expand Down
2 changes: 1 addition & 1 deletion assets/js/modules/parseFileTree.js
Expand Up @@ -17,7 +17,7 @@ define([
], function ($, module, data, allSpecs) {

function ParseFileTree() {
this.json = $.parseJSON(data.toString());
this.json = JSON.parse(data);
}

ParseFileTree.prototype = module.createInstance();
Expand Down
6 changes: 6 additions & 0 deletions assets/js/modules/search.js
Expand Up @@ -39,12 +39,18 @@ Search.prototype.constructor = Search;
Search.prototype = module.createInstance();

Search.prototype.init = function() {
var _this = this;

this.activated = false;
this.targetField = $('#livesearch');
this.header = $('.source_header');

this.prepareAutoCompleteData();
this.initSearchField();

setTimeout(function() {
_this.targetField.attr('data-initialized', 'true');
}, 1);
};

Search.prototype.prepareAutoCompleteData = function() {
Expand Down
24 changes: 12 additions & 12 deletions docs/base/readme.md
Expand Up @@ -26,9 +26,9 @@ To set-up a new engine instance chose the first option `Init SourceJS in this fo
To install SourceJS as a NPM package, first clone clean `user` configuration folder and then execute `npm install`.

```html
git clone https://github.com/sourcejs/init.git my-sourcejs && cd my-sourcejs
git clone https://github.com/sourcejs/init.git -b npm my-sourcejs && cd my-sourcejs
npm install sourcejs --save
node ./node_modules/sourcejs/app
npm start
```

Starting from 0.6.0 we're planning to change official install path to one with NPM packages. Yeoman generator will be also replaced by [sourcejs-cli](https://github.com/sourcejs/sourcejs-cli) with commands like `run`, `install` (plugin), `init`, `create`.
Expand All @@ -37,40 +37,40 @@ Starting from 0.6.0 we're planning to change official install path to one with N

If you're running Windows and have some issues with [JSDom](https://github.com/tmpvar/jsdom) dependencies compilation, please check this [topic](https://github.com/sourcejs/Source/issues/23).

Alternatively with 0.5.4 we prepared a special build without JSDom, until it's full removal from core at 0.6.0.
Alternatively with 0.5.5 we prepared a special build without JSDom, until it's full removal from core at 0.6.0.

```html
npm install -g yo generator-sourcejs
mkdir sourcejs && cd sourcejs
yo sourcejs --branch 0.5.4-no-jsdom
yo sourcejs --branch 0.5.5-no-jsdom
```

Please note that Clarify feature is not available in `no-jsdom` version. If you had generator installed before, run `npm update -g generator-sourcejs` (v.0.4.2+ required).

And installing same build from NPM:

```html
git clone https://github.com/sourcejs/init.git my-sourcejs && cd my-sourcejs
npm install sourcejs@0.5.4-no-jsdom --save
node .\node_modules\sourcejs\app
git clone https://github.com/sourcejs/init.git -b npm my-sourcejs && cd my-sourcejs
npm install sourcejs@0.5.5-no-jsdom --save
npm start
```

## Commands

### Run

Installation wizard will offer to start SourceJS right after initialization. To run it manually, trigger this command in newly created folder:
Installation wizard will offer to start SourceJS right after initialization. To run it manually, trigger this command in newly created folder with SourceJS app:

```html
node app
npm start
```

To set an alternative server port, pass `-p 8081` option.
To set an alternative server port, pass `-- -p 8081` option.

Other configuration arguments are described in the help section:

```html
node app -h
npm start -- -h
```

### Build
Expand All @@ -88,7 +88,7 @@ It will trigger `npm i` and `grunt default` commands for updating dependencies a
For updating SourceJS to a newer version, just pull the latest changes and trigger build:

```html
git pull && npm install
git pull && npm run build
```

## Creating First Spec
Expand Down
7 changes: 4 additions & 3 deletions package.json
Expand Up @@ -2,7 +2,7 @@
"name": "sourcejs",
"description": "Living Style Guide Engine for Managing and Developing Front-end Components.",
"author": "SourceJS",
"version": "0.5.4",
"version": "0.5.5",
"license": "MIT",
"repository": {
"type": "git",
Expand Down Expand Up @@ -53,16 +53,17 @@
"tinyforever": "0.0.3"
},
"scripts": {
"postinstall": "grunt update && node ./core/postInstall",
"postinstall": "node ./core/postInstall && grunt update",
"build": "npm i",
"start": "node app",
"test": "grunt ci-pre-run && node app.js --test",
"ci-test": "grunt ci-pre-run && node app.js --test --log trace",
"ci-test-nw": "grunt ci-pre-run && node app.js --test --log trace --no-watch"
"ci-test-win": "grunt ci-pre-run && node app.js --post-grunt ci-post-run-win --test --log trace --no-watch"
},
"devDependencies": {
"assert": "~1.1.1",
"cross-spawn": "^0.4.0",
"grunt-casperjs": "^2.1.0",
"grunt-mocha-test": "^0.12.4",
"mocha": "^2.0.1",
"should": "~4.0.4",
Expand Down
47 changes: 47 additions & 0 deletions test/casperjs/common.js
@@ -0,0 +1,47 @@
var appPort = casper.cli.get("app-port") || 8080;
var url = 'http://127.0.0.1:' + appPort;

casper.options.viewportSize = {width: 1024, height: 768};

var urlsToCheck = [
url,
url + '/docs/spec/',
url + '/docs/'
];

var error = {};

casper.on("page.error", function(msg, trace) {
error.msg = msg;

this.echo("Error: " + msg, "ERROR");
this.echo("file: " + trace[0].file, "WARNING");
this.echo("line: " + trace[0].line, "WARNING");
this.echo("function: " + trace[0]["function"], "WARNING");
});

urlsToCheck.forEach(function(item){
casper.test.begin('Check availability and JS errors on ' + item, 2, function(test) {
error = {};

casper.start(item).then(function(response) {

casper.wait(500, function(){
// Slow down a bit, because of strange API bug
});

if (response.status !== 200) {
test.fail("Page load error, expected status 200, got " + response.status);
} else {
test.pass("Status 200 OK");
}
}).then(function() {
if (typeof error.msg === 'string') {
test.fail("JS errors found: "+ error.msg);
} else {
test.pass("No JS errors");
}

}).run(function() { test.done() }).clear();
});
});
33 changes: 33 additions & 0 deletions test/casperjs/globalNav.js
@@ -0,0 +1,33 @@
var appPort = casper.cli.get('app-port') || 8080;
var url = 'http://127.0.0.1:' + appPort + '/docs/';

casper.options.viewportSize = {width: 1024, height: 768};

casper.test.begin('Check navigaton page', 3, function suite(test) {
casper.start(url).then(function() {
var _this = this;
var nav = '.source_catalog_list .source_catalog_list_i';

this.waitForSelector(nav,
function pass() {
test.assertEval(function (nav) {
return document.querySelectorAll(nav).length > 5;
}, 'Should have more than 5 nav items', [nav]);

test.assertEval(function (nav) {
return !!document.querySelector(nav + ' .source_catalog_a[href="/docs/base"]') &&
!!document.querySelector(nav + ' .source_catalog_a[href="/docs/clarify"]') &&
!!document.querySelector(nav + ' .source_catalog_a[href="/docs/starting"]');
}, 'Right nav items in set', [nav]);
},
function fail() {
test.fail(nav);
}
);

}).then(function(){
this.click('.source_catalog_image-tumbler');
test.assertExists('.source_catalog.__show-preview', 'Show preview toggled');

}).run(function() { test.done() }).clear();
});
50 changes: 50 additions & 0 deletions test/casperjs/search.js
@@ -0,0 +1,50 @@
var appPort = casper.cli.get('app-port') || 8080;
var url = 'http://127.0.0.1:' + appPort;

casper.options.viewportSize = {width: 1024, height: 768};

casper.test.begin('Checking search', 3, function suite(test) {
casper.start(url).then(function() {
var _this = this;
var input = '.source_search .source_search_it';
var autoComplete = '.autocomplete-wrapper .autocomplete-suggestion:first-child a';
var searchField = '.source_search_it[data-initialized]';

test.assertExists(input, 'Search input exists');

this.waitForSelector(searchField,
function pass() {
casper.sendKeys(searchField, 'main', {keepFocus: true});

_this.waitForSelector(autoComplete,
function pass() {
this.click(autoComplete);
},
function fail() {
test.fail(autoComplete);
}
);
},
function fail() {
test.fail(searchField);
}
);

}).then(function() {

this.waitFor(
function check() {
return (this.getCurrentUrl() === url+'/docs/base/');
},
function then() { // step to execute when check() is ok
test.assertExists('.source_main > h1', 'Spec header exists');

test.assertEquals(this.getCurrentUrl(), url+'/docs/base/', 'New page URL is right')
},
function timeout() { // step to execute if check has failed
this.echo('Failed to navigate to search result');
}
);

}).run(function() { test.done() }).clear();
});

0 comments on commit 96ceca9

Please sign in to comment.