Skip to content
This repository was archived by the owner on Mar 31, 2025. It is now read-only.

Commit 2bfb666

Browse files
feat(examples/generateProtractorTestsProcessor): allow basePath of test to be specified
Provides support for https://github.com/angular/angular.js/pull/9557/files#r18977324
1 parent 136953d commit 2bfb666

File tree

3 files changed

+31
-4
lines changed

3 files changed

+31
-4
lines changed

examples/processors/protractor-generate.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ var _ = require('lodash');
1010
module.exports = function generateProtractorTestsProcessor(exampleMap) {
1111
return {
1212
deployments: [],
13+
basePath: '',
1314
$validate: {
1415
deployments: { presence: true },
1516
},
@@ -18,6 +19,7 @@ module.exports = function generateProtractorTestsProcessor(exampleMap) {
1819
$process: function(docs) {
1920

2021
var deployments = this.deployments;
22+
var basePath = this.basePath;
2123

2224
exampleMap.forEach(function(example) {
2325
_.forEach(example.files, function(file) {
@@ -26,7 +28,7 @@ module.exports = function generateProtractorTestsProcessor(exampleMap) {
2628
if (file.type === 'protractor') {
2729

2830
_.forEach(deployments, function(deployment) {
29-
docs.push(createProtractorDoc(example, deployment, file));
31+
docs.push(createProtractorDoc(example, deployment, file, basePath));
3032
});
3133
}
3234

@@ -36,14 +38,15 @@ module.exports = function generateProtractorTestsProcessor(exampleMap) {
3638
};
3739
};
3840

39-
function createProtractorDoc(example, deployment, file) {
41+
function createProtractorDoc(example, deployment, file, basePath) {
4042
return {
4143
docType: 'e2e-test',
4244
id: 'protractorTest' + '-' + example.id + '-' + deployment.name,
4345
example: example,
4446
deployment: deployment,
4547
template: 'protractorTests.template.js',
4648
innerTest: file.fileContents,
47-
'ng-app-included': example['ng-app-included']
49+
'ng-app-included': example['ng-app-included'],
50+
basePath: basePath
4851
};
4952
}

examples/processors/protractor-generate.spec.js

+24
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,30 @@ describe("generateExamplesProcessor", function() {
2929
});
3030

3131

32+
it("should add the configured basePath to each doc", function() {
33+
34+
exampleMap.set('x', {
35+
id: 'x',
36+
doc: {},
37+
files: {
38+
'app.scenario.js': { type: 'protractor', name: 'app.scenario.js', contents: '...' }
39+
},
40+
deployments: {}
41+
});
42+
var docs = [];
43+
processor.$process(docs);
44+
expect(docs[0].basePath).toEqual('');
45+
expect(docs[1].basePath).toEqual('');
46+
47+
processor.basePath = 'a/b/';
48+
processor.$process(docs);
49+
50+
expect(docs[2].basePath).toEqual('a/b/');
51+
expect(docs[3].basePath).toEqual('a/b/');
52+
53+
});
54+
55+
3256
it("should add a protractor doc for each example-deployment pair in the example", function() {
3357

3458
docs = [

examples/templates/protractorTests.template.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ describe("{$ doc.description $}", function() {
33
beforeEach(function() {
44
rootEl = browser.rootEl;{% if doc['ng-app-included'] %}
55
browser.rootEl = '[ng-app]';{% endif %}
6-
browser.get("{$ doc.example.deployments[doc.deployment.name].outputPath $}");
6+
browser.get("{$ doc.basePath $}{$ doc.example.deployments[doc.deployment.name].outputPath $}");
77
});
88
{% if doc['ng-app-included'] %}afterEach(function() { browser.rootEl = rootEl; });{% endif %}
99
{$ doc.innerTest $}

0 commit comments

Comments
 (0)