Skip to content

Commit

Permalink
test(docs): improve docs e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
petebacondarwin committed Sep 12, 2014
1 parent 3d367eb commit 63761fd
Show file tree
Hide file tree
Showing 7 changed files with 100 additions and 28 deletions.
42 changes: 42 additions & 0 deletions docs/app/e2e/.jshintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"extends": "../../../.jshintrc-base",

"globals": {

/* jasmine / karma */
"it": false,
"iit": false,
"describe": false,
"ddescribe": false,
"beforeEach": false,
"afterEach": false,
"expect": false,
"jasmine": false,
"spyOn": false,
"waits": false,
"waitsFor": false,
"runs": false,
"dump": false,

/* e2e */
"browser": false,
"element": false,
"by": false,

/* testabilityPatch / matchers */
"inject": false,
"module": false,
"dealoc": false,
"_jQuery": false,
"_jqLiteMode": false,
"sortedHtml": false,
"childrenTagsOf": false,
"assertHidden": false,
"assertVisible": false,
"provideLog": false,
"spyOnlyCallsWithArgs": false,
"createMockStyleSheet": false,
"browserTrigger": false,
"jqLiteCacheSize": false
}
}
41 changes: 41 additions & 0 deletions docs/app/e2e/api-pages.scenario.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
'use strict';

describe("doc.angularjs.org", function() {

describe("API pages", function() {

it("should display links to code on GitHub", function() {
browser.get('index-debug.html#!/api/ng/service/$http');
expect(element(by.css('.improve-docs')).getAttribute('href')).toMatch(/https?:\/\/github\.com\/angular\/angular\.js\/edit\/.+\/src\/ng\/http\.js/);

browser.get('index-debug.html#!/api/ng/service/$http');
expect(element(by.css('.view-source')).getAttribute('href')).toMatch(/https?:\/\/github\.com\/angular\/angular\.js\/tree\/.+\/src\/ng\/http\.js#L\d+/);
});

it('should change the page content when clicking a link to a service', function () {
browser.get('');

var ngBindLink = element(by.css('.definition-table td a[href="api/ng/directive/ngClick"]'));
ngBindLink.click();

var pageBody = element(by.css('h1'));
expect(pageBody.getText()).toEqual('ngClick');
});


it('should show the functioning input directive example', function () {
browser.get('index-debug.html#!/api/ng/directive/input');

// Ensure that the page is loaded before trying to switch frames.
browser.waitForAngular();

browser.switchTo().frame('example-input-directive');

var nameInput = element(by.model('user.name'));
nameInput.sendKeys('!!!');

var code = element.all(by.css('tt')).first();
expect(code.getText()).toContain('guest!!!');
});
});
});
26 changes: 1 addition & 25 deletions docs/app/e2e/docsAppE2E.js → docs/app/e2e/app.scenario.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,21 +49,6 @@ describe('docs.angularjs.org', function () {
});


it('should show the functioning input directive example', function () {
browser.get('index-debug.html#!/api/ng/directive/input');

// Ensure that the page is loaded before trying to switch frames.
browser.waitForAngular();

browser.switchTo().frame('example-input-directive');

var nameInput = element(by.model('user.name'));
nameInput.sendKeys('!!!');

var code = element.all(by.css('tt')).first();
expect(code.getText()).toContain('guest!!!');
});


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


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

describe("API pages", function() {
it("should display links to code on GitHub", function() {
browser.get('index-debug.html#!/api/ng/service/$http');
expect(element(by.css('.improve-docs')).getAttribute('href')).toMatch(/https?:\/\/github\.com\/angular\/angular\.js\/edit\/.+\/src\/ng\/http\.js/);

browser.get('index-debug.html#!/api/ng/service/$http');
expect(element(by.css('.view-source')).getAttribute('href')).toMatch(/https?:\/\/github\.com\/angular\/angular\.js\/tree\/.+\/src\/ng\/http\.js#L\d+/);
});
});
});
13 changes: 13 additions & 0 deletions docs/protractor-conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
'use strict';

var config = require('../protractor-shared-conf').config;

config.specs = [
'app/e2e/*.scenario.js'
];

config.capabilities = {
browserName: 'chrome',
};

exports.config = config;
2 changes: 1 addition & 1 deletion protractor-conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ var config = require('./protractor-shared-conf').config;

config.specs = [
'build/docs/ptore2e/**/*.js',
'docs/app/e2e/docsAppE2E.js'
'docs/app/e2e/*.scenario.js'
];

config.capabilities = {
Expand Down
2 changes: 1 addition & 1 deletion protractor-jenkins-conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ exports.config = {

specs: [
'build/docs/ptore2e/**/*.js',
'docs/app/e2e/docsAppE2E.js'
'docs/app/e2e/*.scenario.js'
],

capabilities: {
Expand Down
2 changes: 1 addition & 1 deletion scripts/travis/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ if [ $JOB = "unit" ]; then
grunt test:promises-aplus
grunt test:unit --browsers SL_Chrome,SL_Safari,SL_Firefox,SL_IE_9,SL_IE_10,SL_IE_11 --reporters dots
grunt tests:docs --browsers SL_Chrome,SL_Safari,SL_Firefox,SL_IE_9,SL_IE_10,SL_IE_11 --reporters dots
grunt test:travis-protractor --specs "docs/app/e2e/docsAppE2E.js"
grunt test:travis-protractor --specs "docs/app/e2e/*.scenario.js"
elif [ $JOB = "e2e" ]; then
export TARGET_SPECS="build/docs/ptore2e/**/default_test.js"
if [ $TEST_TARGET = "jquery" ]; then
Expand Down

0 comments on commit 63761fd

Please sign in to comment.