diff --git a/protractor.conf.js b/protractor.conf.js index 40168254..8840af64 100644 --- a/protractor.conf.js +++ b/protractor.conf.js @@ -13,6 +13,9 @@ let config = { // load APIs.guru list return loadJson('https://apis-guru.github.io/api-models/api/v1/list.json').then((list) => { global.apisGuruList = list; + return browser.getCapabilities().then(function (cap) { + browser.isIE = cap.caps_.browserName === 'internet explorer'; + }); }); }, //directConnect: true, @@ -20,10 +23,20 @@ let config = { jasmineNodeOpts: { showTiming: true, showColors: true, - defaultTimeoutInterval: 60000, + defaultTimeoutInterval: 120000, print: function() {} }, - multiCapabilities: [{ + multiCapabilities: [ + { browserName: 'chrome' }, + { browserName: 'firefox' } + ] +}; + +if (travis) { + config.sauceUser = process.env.SAUCE_USERNAME; + config.sauceKey = process.env.SAUCE_ACCESS_KEY; + config.sauceSeleniumAddres = 'localhost:4445/wd/hub'; + config.multiCapabilities = [{ browserName: 'chrome', 'tunnel-identifier': process.env.TRAVIS_JOB_NUMBER, build: process.env.TRAVIS_BUILD_NUMBER, @@ -45,14 +58,8 @@ let config = { version: '11.0', 'tunnel-identifier': process.env.TRAVIS_JOB_NUMBER, build: process.env.TRAVIS_BUILD_NUMBER, - name: 'Redoc Firefox Latest/Win build ' + process.env.TRAVIS_BUILD_NUMBER - }] -}; - -if (travis) { - config.sauceUser = process.env.SAUCE_USERNAME; - config.sauceKey = process.env.SAUCE_ACCESS_KEY; - config.sauceSeleniumAddres = 'localhost:4445/wd/hub'; + name: 'Redoc IE11/Win build ' + process.env.TRAVIS_BUILD_NUMBER + }]; } else { config.directConnect = true; } diff --git a/tests/e2e/helpers.js b/tests/e2e/helpers.js index 901557b7..0b570074 100644 --- a/tests/e2e/helpers.js +++ b/tests/e2e/helpers.js @@ -30,12 +30,25 @@ const LogLevel = { const MAX_ERROR_MESSAGE_SYMBOLS = 128; //copied from angular/modules/angular2/src/testing/e2e_util.ts function verifyNoBrowserErrors() { + // IE doesn't support logs method + if (browser.isIE) { + let err = browser.executeScript('return window.redocError'); + expect(err).toBeNull(); + return; + } + // Bug in ChromeDriver: Need to execute at least one command // so that the browser logs can be read out! browser.executeScript('1+1'); browser.manage().logs().get('browser').then(function(browserLog) { let filteredLog = browserLog.filter((logEntry) => { let message = logEntry.message; + + // skip browser-sync errors + if (message.indexOf('browser-sync') > -1) return false; + // skip firefox-specific warning + if (message.indexOf('mutating the [[Prototype]]') > -1) return false; + if (logEntry.level.value >= LogLevel.INFO) { if (message.length > MAX_ERROR_MESSAGE_SYMBOLS) { message = message.substr(0, MAX_ERROR_MESSAGE_SYMBOLS) + '...'; @@ -43,8 +56,6 @@ function verifyNoBrowserErrors() { console.log('>> ' + message); } - // skip browser-sync errors - if (message.indexOf('browser-sync') > -1) return false; return logEntry.level.value > LogLevel.WARNING; }); expect(filteredLog.length).toEqual(0, `Found ${filteredLog.length} browser errors`); @@ -60,8 +71,20 @@ function scrollToEl(selector) { return browser.driver.executeScript(script); } +function fixFFTest(done) { + // firefox issue. the first try to access something from webpage fails + // but the second works fine. So skipping first error + $('body').isPresent().then(()=> { + done(); + }, () => { + //error skipped + done(); + }) +} + module.exports = { loadJson: loadJson, verifyNoBrowserErrors: verifyNoBrowserErrors, - scrollToEl: scrollToEl + scrollToEl: scrollToEl, + fixFFTest: fixFFTest } diff --git a/tests/e2e/index.html b/tests/e2e/index.html index efe1225a..1adf5db4 100644 --- a/tests/e2e/index.html +++ b/tests/e2e/index.html @@ -1,19 +1,23 @@ + ReDoc - + Loading... diff --git a/tests/e2e/redoc.spec.js b/tests/e2e/redoc.spec.js index ed8c4e72..0f88407d 100644 --- a/tests/e2e/redoc.spec.js +++ b/tests/e2e/redoc.spec.js @@ -1,6 +1,7 @@ 'use strict'; const verifyNoBrowserErrors = require('./helpers').verifyNoBrowserErrors; const scrollToEl = require('./helpers').scrollToEl; +const fixFFTest = require('./helpers').fixFFTest; const URL = 'index.html'; @@ -11,12 +12,16 @@ function basicTests(swaggerUrl, title) { specUrl += `?url=${encodeURIComponent(swaggerUrl)}`; } + beforeEach((done) => { + browser.get(specUrl); + fixFFTest(done); + }); + afterEach(() => { verifyNoBrowserErrors(); }); it('should init redoc without errors', () => { - browser.get(specUrl); let $redoc = $('redoc'); expect($redoc.isPresent()).toBe(true); let $methods = $$('method'); @@ -29,8 +34,14 @@ basicTests(null, 'Extended Petstore'); describe('Scroll sync', () => { + let specUrl = URL; + + beforeEach((done) => { + browser.get(specUrl); + fixFFTest(done); + }); + it('should update active menu entries on page scroll', () => { - browser.get(URL); scrollToEl('[tag="store"]').then(function() { expect($('.menu-cat-header.active').getText()).toBe('STORE'); });