Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 63761fd

Browse files
test(docs): improve docs e2e tests
1 parent 3d367eb commit 63761fd

File tree

7 files changed

+100
-28
lines changed

7 files changed

+100
-28
lines changed

docs/app/e2e/.jshintrc

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
"extends": "../../../.jshintrc-base",
3+
4+
"globals": {
5+
6+
/* jasmine / karma */
7+
"it": false,
8+
"iit": false,
9+
"describe": false,
10+
"ddescribe": false,
11+
"beforeEach": false,
12+
"afterEach": false,
13+
"expect": false,
14+
"jasmine": false,
15+
"spyOn": false,
16+
"waits": false,
17+
"waitsFor": false,
18+
"runs": false,
19+
"dump": false,
20+
21+
/* e2e */
22+
"browser": false,
23+
"element": false,
24+
"by": false,
25+
26+
/* testabilityPatch / matchers */
27+
"inject": false,
28+
"module": false,
29+
"dealoc": false,
30+
"_jQuery": false,
31+
"_jqLiteMode": false,
32+
"sortedHtml": false,
33+
"childrenTagsOf": false,
34+
"assertHidden": false,
35+
"assertVisible": false,
36+
"provideLog": false,
37+
"spyOnlyCallsWithArgs": false,
38+
"createMockStyleSheet": false,
39+
"browserTrigger": false,
40+
"jqLiteCacheSize": false
41+
}
42+
}

docs/app/e2e/api-pages.scenario.js

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
'use strict';
2+
3+
describe("doc.angularjs.org", function() {
4+
5+
describe("API pages", function() {
6+
7+
it("should display links to code on GitHub", function() {
8+
browser.get('index-debug.html#!/api/ng/service/$http');
9+
expect(element(by.css('.improve-docs')).getAttribute('href')).toMatch(/https?:\/\/github\.com\/angular\/angular\.js\/edit\/.+\/src\/ng\/http\.js/);
10+
11+
browser.get('index-debug.html#!/api/ng/service/$http');
12+
expect(element(by.css('.view-source')).getAttribute('href')).toMatch(/https?:\/\/github\.com\/angular\/angular\.js\/tree\/.+\/src\/ng\/http\.js#L\d+/);
13+
});
14+
15+
it('should change the page content when clicking a link to a service', function () {
16+
browser.get('');
17+
18+
var ngBindLink = element(by.css('.definition-table td a[href="api/ng/directive/ngClick"]'));
19+
ngBindLink.click();
20+
21+
var pageBody = element(by.css('h1'));
22+
expect(pageBody.getText()).toEqual('ngClick');
23+
});
24+
25+
26+
it('should show the functioning input directive example', function () {
27+
browser.get('index-debug.html#!/api/ng/directive/input');
28+
29+
// Ensure that the page is loaded before trying to switch frames.
30+
browser.waitForAngular();
31+
32+
browser.switchTo().frame('example-input-directive');
33+
34+
var nameInput = element(by.model('user.name'));
35+
nameInput.sendKeys('!!!');
36+
37+
var code = element.all(by.css('tt')).first();
38+
expect(code.getText()).toContain('guest!!!');
39+
});
40+
});
41+
});

docs/app/e2e/docsAppE2E.js renamed to docs/app/e2e/app.scenario.js

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -49,21 +49,6 @@ describe('docs.angularjs.org', function () {
4949
});
5050

5151

52-
it('should show the functioning input directive example', function () {
53-
browser.get('index-debug.html#!/api/ng/directive/input');
54-
55-
// Ensure that the page is loaded before trying to switch frames.
56-
browser.waitForAngular();
57-
58-
browser.switchTo().frame('example-input-directive');
59-
60-
var nameInput = element(by.model('user.name'));
61-
nameInput.sendKeys('!!!');
62-
63-
var code = element.all(by.css('tt')).first();
64-
expect(code.getText()).toContain('guest!!!');
65-
});
66-
6752

6853
it('should be resilient to trailing slashes', function() {
6954
browser.get('index-debug.html#!/api/ng/function/angular.noop/');
@@ -92,7 +77,7 @@ describe('docs.angularjs.org', function () {
9277
});
9378

9479

95-
it("should display links to code on GitHub", function() {
80+
it("should display an error if the page does not exist", function() {
9681
browser.get('index-debug.html#!/api/does/not/exist');
9782
expect(element(by.css('h1')).getText()).toBe('Oops!');
9883
});
@@ -105,13 +90,4 @@ describe('docs.angularjs.org', function () {
10590
});
10691
});
10792

108-
describe("API pages", function() {
109-
it("should display links to code on GitHub", function() {
110-
browser.get('index-debug.html#!/api/ng/service/$http');
111-
expect(element(by.css('.improve-docs')).getAttribute('href')).toMatch(/https?:\/\/github\.com\/angular\/angular\.js\/edit\/.+\/src\/ng\/http\.js/);
112-
113-
browser.get('index-debug.html#!/api/ng/service/$http');
114-
expect(element(by.css('.view-source')).getAttribute('href')).toMatch(/https?:\/\/github\.com\/angular\/angular\.js\/tree\/.+\/src\/ng\/http\.js#L\d+/);
115-
});
116-
});
11793
});

docs/protractor-conf.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
'use strict';
2+
3+
var config = require('../protractor-shared-conf').config;
4+
5+
config.specs = [
6+
'app/e2e/*.scenario.js'
7+
];
8+
9+
config.capabilities = {
10+
browserName: 'chrome',
11+
};
12+
13+
exports.config = config;

protractor-conf.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ var config = require('./protractor-shared-conf').config;
44

55
config.specs = [
66
'build/docs/ptore2e/**/*.js',
7-
'docs/app/e2e/docsAppE2E.js'
7+
'docs/app/e2e/*.scenario.js'
88
];
99

1010
config.capabilities = {

protractor-jenkins-conf.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ exports.config = {
55

66
specs: [
77
'build/docs/ptore2e/**/*.js',
8-
'docs/app/e2e/docsAppE2E.js'
8+
'docs/app/e2e/*.scenario.js'
99
],
1010

1111
capabilities: {

scripts/travis/build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ if [ $JOB = "unit" ]; then
99
grunt test:promises-aplus
1010
grunt test:unit --browsers SL_Chrome,SL_Safari,SL_Firefox,SL_IE_9,SL_IE_10,SL_IE_11 --reporters dots
1111
grunt tests:docs --browsers SL_Chrome,SL_Safari,SL_Firefox,SL_IE_9,SL_IE_10,SL_IE_11 --reporters dots
12-
grunt test:travis-protractor --specs "docs/app/e2e/docsAppE2E.js"
12+
grunt test:travis-protractor --specs "docs/app/e2e/*.scenario.js"
1313
elif [ $JOB = "e2e" ]; then
1414
export TARGET_SPECS="build/docs/ptore2e/**/default_test.js"
1515
if [ $TEST_TARGET = "jquery" ]; then

0 commit comments

Comments
 (0)