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

Commit 9b9a30c

Browse files
test(docs): improve docs e2e tests
1 parent 8be7b5d commit 9b9a30c

File tree

7 files changed

+105
-27
lines changed

7 files changed

+105
-27
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: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,6 @@ describe('docs.angularjs.org', function () {
2626
});
2727

2828

29-
it('should show the functioning input directive example', function () {
30-
browser.get('index-debug.html#!/api/ng/directive/input');
31-
32-
// Ensure that the page is loaded before trying to switch frames.
33-
browser.waitForAngular();
34-
35-
browser.switchTo().frame('example-input-directive');
36-
37-
var nameInput = element(by.model('user.name'));
38-
nameInput.sendKeys('!!!');
39-
40-
var code = element.all(by.css('tt')).first();
41-
expect(code.getText()).toContain('guest!!!');
42-
});
43-
4429

4530
it('should be resilient to trailing slashes', function() {
4631
browser.get('index-debug.html#!/api/ng/function/angular.noop/');
@@ -67,6 +52,12 @@ describe('docs.angularjs.org', function () {
6752
browser.get('index-debug.html#!error/ng/areq?p0=Missing&p1=not%20a%20function,%20got%20undefined');
6853
expect(element(by.css('.minerr-errmsg')).getText()).toEqual("Argument 'Missing' is not a function, got undefined");
6954
});
55+
56+
57+
it("should display an error if the page does not exist", function() {
58+
browser.get('index-debug.html#!/api/does/not/exist');
59+
expect(element(by.css('h1')).getText()).toBe('Oops!');
60+
});
7061
});
7162

7263
describe("templates", function() {
@@ -76,13 +67,4 @@ describe('docs.angularjs.org', function () {
7667
});
7768
});
7869

79-
describe("API pages", function() {
80-
it("should display links to code on GitHub", function() {
81-
browser.get('index-debug.html#!/api/ng/service/$http');
82-
expect(element(by.css('.improve-docs')).getAttribute('href')).toMatch(/https?:\/\/github\.com\/angular\/angular\.js\/edit\/.+\/src\/ng\/http\.js/);
83-
84-
browser.get('index-debug.html#!/api/ng/service/$http');
85-
expect(element(by.css('.view-source')).getAttribute('href')).toMatch(/https?:\/\/github\.com\/angular\/angular\.js\/tree\/.+\/src\/ng\/http\.js#L\d+/);
86-
});
87-
});
8870
});

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_8,SL_IE_9,SL_IE_10,SL_IE_11 --reporters dots
1111
grunt tests:docs --browsers SL_Chrome,SL_Safari,SL_Firefox,SL_IE_8,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)