diff --git a/docs/app/e2e/.jshintrc b/docs/app/e2e/.jshintrc new file mode 100644 index 000000000..6e3ae3068 --- /dev/null +++ b/docs/app/e2e/.jshintrc @@ -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 + } +} \ No newline at end of file diff --git a/docs/app/e2e/api-pages.scenario.js b/docs/app/e2e/api-pages.scenario.js new file mode 100644 index 000000000..76ee7a116 --- /dev/null +++ b/docs/app/e2e/api-pages.scenario.js @@ -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!!!'); + }); + }); +}); \ No newline at end of file diff --git a/docs/app/e2e/docsAppE2E.js b/docs/app/e2e/app.scenario.js similarity index 67% rename from docs/app/e2e/docsAppE2E.js rename to docs/app/e2e/app.scenario.js index d8733f7c0..ef063980d 100644 --- a/docs/app/e2e/docsAppE2E.js +++ b/docs/app/e2e/app.scenario.js @@ -26,21 +26,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/'); @@ -67,6 +52,12 @@ describe('docs.angularjs.org', function () { browser.get('index-debug.html#!error/ng/areq?p0=Missing&p1=not%20a%20function,%20got%20undefined'); expect(element(by.css('.minerr-errmsg')).getText()).toEqual("Argument 'Missing' is not a function, got undefined"); }); + + + 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!'); + }); }); describe("templates", function() { @@ -76,13 +67,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+/); - }); - }); }); diff --git a/docs/protractor-conf.js b/docs/protractor-conf.js new file mode 100644 index 000000000..490b46fc5 --- /dev/null +++ b/docs/protractor-conf.js @@ -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; diff --git a/protractor-conf.js b/protractor-conf.js index d2a204b11..658680b9e 100644 --- a/protractor-conf.js +++ b/protractor-conf.js @@ -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 = { diff --git a/protractor-jenkins-conf.js b/protractor-jenkins-conf.js index 09d6bc114..f0aaa0528 100644 --- a/protractor-jenkins-conf.js +++ b/protractor-jenkins-conf.js @@ -5,7 +5,7 @@ exports.config = { specs: [ 'build/docs/ptore2e/**/*.js', - 'docs/app/e2e/docsAppE2E.js' + 'docs/app/e2e/*.scenario.js' ], capabilities: { diff --git a/scripts/travis/build.sh b/scripts/travis/build.sh index 41739650a..942c34ecd 100755 --- a/scripts/travis/build.sh +++ b/scripts/travis/build.sh @@ -9,7 +9,7 @@ if [ $JOB = "unit" ]; then grunt test:promises-aplus grunt test:unit --browsers SL_Chrome,SL_Safari,SL_Firefox,SL_IE_8,SL_IE_9,SL_IE_10,SL_IE_11 --reporters dots grunt tests:docs --browsers SL_Chrome,SL_Safari,SL_Firefox,SL_IE_8,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