Skip to content

Commit

Permalink
feat(e2e): protractor testing of docs now works properly with 'grunt …
Browse files Browse the repository at this point in the history
…dev'
  • Loading branch information
c0bra committed Dec 20, 2013
1 parent a2ff780 commit 08787be
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 31 deletions.
21 changes: 8 additions & 13 deletions Gruntfile.js
Expand Up @@ -143,14 +143,16 @@ module.exports = function(grunt) {
options: {
args: {
seleniumPort: 4444,
specs: ['.tmp/e2e/**/*.spec.js', 'test/e2e/**/*.spec.js']
baseUrl: 'http://localhost:9999',
specs: ['.tmp/doc-scenarios/**/*.spec.js', 'test/e2e/**/*.spec.js']
}
}
}
// docs: {
// options: {
// args: {
// baseUrl: 'http://localhost:9999'
// seleniumPort: 4444,

// }
// }
// }
Expand Down Expand Up @@ -224,7 +226,7 @@ module.exports = function(grunt) {
}
},
protractor: {
files: ['.tmp/e2e/**/*.spec.js', 'test/e2e/**/*.spec.js', '<%= dist %>/docs/**'],
files: ['.tmp/doc-scenarios/**/*.spec.js', 'test/e2e/**/*.spec.js'],
tasks: ['protractor:auto']
},

Expand Down Expand Up @@ -292,12 +294,13 @@ module.exports = function(grunt) {
ngdocs: {
options: {
dest: '<%= dist %>/docs',
testingUrlPrefix: '<%= protractor.auto.options.args.baseUrl %>/docs/#/',
scripts: [
'//ajax.googleapis.com/ajax/libs/angularjs/1.2.4/angular.js',
'http://ajax.googleapis.com/ajax/libs/angularjs/1.2.4/angular-animate.js',
'bower_components/google-code-prettify/src/prettify.js',
'node_modules/marked/lib/marked.js',
'http://<%= site %>/release/<%= pkg.name %>.js'
'<%= protractor.auto.options.args.baseUrl %>/release/<%= pkg.name %>.js'
],
styles: [
'misc/doc/css/prettify.css',
Expand Down Expand Up @@ -401,7 +404,7 @@ module.exports = function(grunt) {
// Testing tasks
// grunt.registerTask('test:ci', ['clean', 'jshint', 'ngtemplates', 'karma:sauce']);
grunt.registerTask('test:ci', ['clean', 'jshint', 'ngtemplates', 'serialsauce']);
grunt.registerTask('test:docs', ['connect:', 'protractor:docs']);
grunt.registerTask('test:docs', ['connect:testserver', 'protractor:docs']);
grunt.registerTask('test:e2e', ['protractor:singlerun']);

// Test
Expand All @@ -417,12 +420,4 @@ module.exports = function(grunt) {
});

grunt.registerTask('release', ['clean', 'build', 'cut-release', 'gh-pages']);

grunt.registerTask('blah', function () {
var ngdoc = require('./node_modules/grunt-ngdocs/src/ngdoc.js');

console.log(ngdoc);
});

grunt.registerTask('butt', ['shell:protractor-start', 'watch:protractor']);
};
1 change: 1 addition & 0 deletions TODO.md
Expand Up @@ -6,6 +6,7 @@
1. Try to reomve `npm install` commands from travis before-script
1. Add grunt task that will use ngdoc to build test specs from docs into .tmp/e2e/doc.spec.js
- It will need to run after ngdocs does. Maybe make a `gendocs` task that runs both serially.
1. Add --browsers option for e2e tests (need it for SauceLabs browsers)

1. [DONE] Add --browsers option for testing on saucelabs with specific browser(s)
1. [DONE] Make karmangular run in `watch` mode and in singlerun too.
Expand Down
46 changes: 33 additions & 13 deletions lib/grunt/plugins.js
Expand Up @@ -5,6 +5,9 @@ var semver = require('semver');
var shell = require('shelljs');
var remote = require('selenium-webdriver/remote');

var ngdoc = require('../../node_modules/grunt-ngdocs/src/ngdoc.js');
var reader = require('../../node_modules/grunt-ngdocs/src/reader.js');

module.exports = function(grunt) {

/*
Expand Down Expand Up @@ -237,24 +240,41 @@ module.exports = function(grunt) {
done();
});

grunt.registerTask('selenium:start', function() {
var done = this.async();
// grunt.registerTask('selenium:start', function() {
// var done = this.async();

// Get the config from the config file
var configFile = path.resolve(process.cwd(), grunt.config('protractor.options.configFile'));
var config = require(configFile);
// // Get the config from the config file
// var configFile = path.resolve(process.cwd(), grunt.config('protractor.options.configFile'));
// var config = require(configFile);

var server = new remote.SeleniumServer(config.seleniumServerJar, {
args: config.seleniumArgs,
port: config.seleniumPort
});
// var server = new remote.SeleniumServer(config.seleniumServerJar, {
// args: config.seleniumArgs,
// port: config.seleniumPort
// });

// // console.log('server', server.start);

// console.log('server', server.start);
// server.start().then(function(url) {
// grunt.log.writeln('Selenium standalone server started at ' + url);

server.start().then(function(url) {
grunt.log.writeln('Selenium standalone server started at ' + url);
// done();
// });
// });

done();
grunt.registerTask('blah', function () {
reader.docs = []
grunt.file.recurse(path.resolve(process.cwd(), 'src'), function (abspath, rootdir, subdir, filename) {
if (!/style\.js$/.test(filename)) { return; }

var contents = fs.readFileSync(abspath, 'utf8');

// var d = new ngdoc.Doc(contents);
// d.parse();
// console.log(d);

reader.process(contents, abspath);
});

console.log(reader.docs[0].convertUrlToAbsolute());
});
};
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -46,7 +46,7 @@
"karma-script-launcher": "~0.1",
"grunt-karma": "~0.6.2",
"marked": "~0.2",
"grunt-ngdocs": "https://github.com/c0bra/grunt-ngdocs/tarball/0.1.7-custom3",
"grunt-ngdocs": "https://github.com/c0bra/grunt-ngdocs/tarball/0.1.7-custom4",
"grunt-conventional-changelog": "~1.0.0",
"grunt-gh-pages": "~0.9.0",
"semver": "~2.2.1",
Expand Down
11 changes: 7 additions & 4 deletions src/js/directives/ui-grid-style.js
Expand Up @@ -17,18 +17,21 @@
var app = angular.module('app', ['ui.grid']);
app.controller('MainCtrl', ['$scope', function ($scope) {
$scope.myStyle = '.blah { color: red }';
$scope.myStyle = '.blah { border: 1px solid }';
}]);
</script>
<div ng-controller="MainCtrl">
<style ui-grid-style>{{ myStyle }}</style>
<span class="blah">I am red.</span>
<span class="blah">I am in a box.</span>
</div>
</doc:source>
<doc:scenario>
it('should do stuff!', function () {
it('should apply the right class to the element', function () {
element(by.css('.blah')).getCssValue('border')
.then(function(c) {
expect(c).toContain('1px solid');
});
});
</doc:scenario>
</doc:example>
Expand Down

0 comments on commit 08787be

Please sign in to comment.