Skip to content

Commit 08787be

Browse files
committed
feat(e2e): protractor testing of docs now works properly with 'grunt dev'
1 parent a2ff780 commit 08787be

File tree

5 files changed

+50
-31
lines changed

5 files changed

+50
-31
lines changed

Gruntfile.js

+8-13
Original file line numberDiff line numberDiff line change
@@ -143,14 +143,16 @@ module.exports = function(grunt) {
143143
options: {
144144
args: {
145145
seleniumPort: 4444,
146-
specs: ['.tmp/e2e/**/*.spec.js', 'test/e2e/**/*.spec.js']
146+
baseUrl: 'http://localhost:9999',
147+
specs: ['.tmp/doc-scenarios/**/*.spec.js', 'test/e2e/**/*.spec.js']
147148
}
148149
}
149150
}
150151
// docs: {
151152
// options: {
152153
// args: {
153-
// baseUrl: 'http://localhost:9999'
154+
// seleniumPort: 4444,
155+
154156
// }
155157
// }
156158
// }
@@ -224,7 +226,7 @@ module.exports = function(grunt) {
224226
}
225227
},
226228
protractor: {
227-
files: ['.tmp/e2e/**/*.spec.js', 'test/e2e/**/*.spec.js', '<%= dist %>/docs/**'],
229+
files: ['.tmp/doc-scenarios/**/*.spec.js', 'test/e2e/**/*.spec.js'],
228230
tasks: ['protractor:auto']
229231
},
230232

@@ -292,12 +294,13 @@ module.exports = function(grunt) {
292294
ngdocs: {
293295
options: {
294296
dest: '<%= dist %>/docs',
297+
testingUrlPrefix: '<%= protractor.auto.options.args.baseUrl %>/docs/#/',
295298
scripts: [
296299
'//ajax.googleapis.com/ajax/libs/angularjs/1.2.4/angular.js',
297300
'http://ajax.googleapis.com/ajax/libs/angularjs/1.2.4/angular-animate.js',
298301
'bower_components/google-code-prettify/src/prettify.js',
299302
'node_modules/marked/lib/marked.js',
300-
'http://<%= site %>/release/<%= pkg.name %>.js'
303+
'<%= protractor.auto.options.args.baseUrl %>/release/<%= pkg.name %>.js'
301304
],
302305
styles: [
303306
'misc/doc/css/prettify.css',
@@ -401,7 +404,7 @@ module.exports = function(grunt) {
401404
// Testing tasks
402405
// grunt.registerTask('test:ci', ['clean', 'jshint', 'ngtemplates', 'karma:sauce']);
403406
grunt.registerTask('test:ci', ['clean', 'jshint', 'ngtemplates', 'serialsauce']);
404-
grunt.registerTask('test:docs', ['connect:', 'protractor:docs']);
407+
grunt.registerTask('test:docs', ['connect:testserver', 'protractor:docs']);
405408
grunt.registerTask('test:e2e', ['protractor:singlerun']);
406409

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

419422
grunt.registerTask('release', ['clean', 'build', 'cut-release', 'gh-pages']);
420-
421-
grunt.registerTask('blah', function () {
422-
var ngdoc = require('./node_modules/grunt-ngdocs/src/ngdoc.js');
423-
424-
console.log(ngdoc);
425-
});
426-
427-
grunt.registerTask('butt', ['shell:protractor-start', 'watch:protractor']);
428423
};

TODO.md

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
1. Try to reomve `npm install` commands from travis before-script
77
1. Add grunt task that will use ngdoc to build test specs from docs into .tmp/e2e/doc.spec.js
88
- It will need to run after ngdocs does. Maybe make a `gendocs` task that runs both serially.
9+
1. Add --browsers option for e2e tests (need it for SauceLabs browsers)
910

1011
1. [DONE] Add --browsers option for testing on saucelabs with specific browser(s)
1112
1. [DONE] Make karmangular run in `watch` mode and in singlerun too.

lib/grunt/plugins.js

+33-13
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ var semver = require('semver');
55
var shell = require('shelljs');
66
var remote = require('selenium-webdriver/remote');
77

8+
var ngdoc = require('../../node_modules/grunt-ngdocs/src/ngdoc.js');
9+
var reader = require('../../node_modules/grunt-ngdocs/src/reader.js');
10+
811
module.exports = function(grunt) {
912

1013
/*
@@ -237,24 +240,41 @@ module.exports = function(grunt) {
237240
done();
238241
});
239242

240-
grunt.registerTask('selenium:start', function() {
241-
var done = this.async();
243+
// grunt.registerTask('selenium:start', function() {
244+
// var done = this.async();
242245

243-
// Get the config from the config file
244-
var configFile = path.resolve(process.cwd(), grunt.config('protractor.options.configFile'));
245-
var config = require(configFile);
246+
// // Get the config from the config file
247+
// var configFile = path.resolve(process.cwd(), grunt.config('protractor.options.configFile'));
248+
// var config = require(configFile);
246249

247-
var server = new remote.SeleniumServer(config.seleniumServerJar, {
248-
args: config.seleniumArgs,
249-
port: config.seleniumPort
250-
});
250+
// var server = new remote.SeleniumServer(config.seleniumServerJar, {
251+
// args: config.seleniumArgs,
252+
// port: config.seleniumPort
253+
// });
254+
255+
// // console.log('server', server.start);
251256

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

254-
server.start().then(function(url) {
255-
grunt.log.writeln('Selenium standalone server started at ' + url);
260+
// done();
261+
// });
262+
// });
256263

257-
done();
264+
grunt.registerTask('blah', function () {
265+
reader.docs = []
266+
grunt.file.recurse(path.resolve(process.cwd(), 'src'), function (abspath, rootdir, subdir, filename) {
267+
if (!/style\.js$/.test(filename)) { return; }
268+
269+
var contents = fs.readFileSync(abspath, 'utf8');
270+
271+
// var d = new ngdoc.Doc(contents);
272+
// d.parse();
273+
// console.log(d);
274+
275+
reader.process(contents, abspath);
258276
});
277+
278+
console.log(reader.docs[0].convertUrlToAbsolute());
259279
});
260280
};

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
"karma-script-launcher": "~0.1",
4747
"grunt-karma": "~0.6.2",
4848
"marked": "~0.2",
49-
"grunt-ngdocs": "https://github.com/c0bra/grunt-ngdocs/tarball/0.1.7-custom3",
49+
"grunt-ngdocs": "https://github.com/c0bra/grunt-ngdocs/tarball/0.1.7-custom4",
5050
"grunt-conventional-changelog": "~1.0.0",
5151
"grunt-gh-pages": "~0.9.0",
5252
"semver": "~2.2.1",

src/js/directives/ui-grid-style.js

+7-4
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,21 @@
1717
var app = angular.module('app', ['ui.grid']);
1818
1919
app.controller('MainCtrl', ['$scope', function ($scope) {
20-
$scope.myStyle = '.blah { color: red }';
20+
$scope.myStyle = '.blah { border: 1px solid }';
2121
}]);
2222
</script>
2323
2424
<div ng-controller="MainCtrl">
2525
<style ui-grid-style>{{ myStyle }}</style>
26-
<span class="blah">I am red.</span>
26+
<span class="blah">I am in a box.</span>
2727
</div>
2828
</doc:source>
2929
<doc:scenario>
30-
it('should do stuff!', function () {
31-
30+
it('should apply the right class to the element', function () {
31+
element(by.css('.blah')).getCssValue('border')
32+
.then(function(c) {
33+
expect(c).toContain('1px solid');
34+
});
3235
});
3336
</doc:scenario>
3437
</doc:example>

0 commit comments

Comments
 (0)