mirror of
https://github.com/Redocly/redoc.git
synced 2024-11-29 03:53:43 +03:00
e2e tests fixes
This commit is contained in:
parent
19445857f3
commit
139a0ec1b9
|
@ -13,6 +13,9 @@ let config = {
|
||||||
// load APIs.guru list
|
// load APIs.guru list
|
||||||
return loadJson('https://apis-guru.github.io/api-models/api/v1/list.json').then((list) => {
|
return loadJson('https://apis-guru.github.io/api-models/api/v1/list.json').then((list) => {
|
||||||
global.apisGuruList = list;
|
global.apisGuruList = list;
|
||||||
|
return browser.getCapabilities().then(function (cap) {
|
||||||
|
browser.isIE = cap.caps_.browserName === 'internet explorer';
|
||||||
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
//directConnect: true,
|
//directConnect: true,
|
||||||
|
@ -20,10 +23,20 @@ let config = {
|
||||||
jasmineNodeOpts: {
|
jasmineNodeOpts: {
|
||||||
showTiming: true,
|
showTiming: true,
|
||||||
showColors: true,
|
showColors: true,
|
||||||
defaultTimeoutInterval: 60000,
|
defaultTimeoutInterval: 120000,
|
||||||
print: function() {}
|
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',
|
browserName: 'chrome',
|
||||||
'tunnel-identifier': process.env.TRAVIS_JOB_NUMBER,
|
'tunnel-identifier': process.env.TRAVIS_JOB_NUMBER,
|
||||||
build: process.env.TRAVIS_BUILD_NUMBER,
|
build: process.env.TRAVIS_BUILD_NUMBER,
|
||||||
|
@ -45,14 +58,8 @@ let config = {
|
||||||
version: '11.0',
|
version: '11.0',
|
||||||
'tunnel-identifier': process.env.TRAVIS_JOB_NUMBER,
|
'tunnel-identifier': process.env.TRAVIS_JOB_NUMBER,
|
||||||
build: process.env.TRAVIS_BUILD_NUMBER,
|
build: process.env.TRAVIS_BUILD_NUMBER,
|
||||||
name: 'Redoc Firefox Latest/Win build ' + process.env.TRAVIS_BUILD_NUMBER
|
name: 'Redoc IE11/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';
|
|
||||||
} else {
|
} else {
|
||||||
config.directConnect = true;
|
config.directConnect = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,12 +30,25 @@ const LogLevel = {
|
||||||
const MAX_ERROR_MESSAGE_SYMBOLS = 128;
|
const MAX_ERROR_MESSAGE_SYMBOLS = 128;
|
||||||
//copied from angular/modules/angular2/src/testing/e2e_util.ts
|
//copied from angular/modules/angular2/src/testing/e2e_util.ts
|
||||||
function verifyNoBrowserErrors() {
|
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
|
// Bug in ChromeDriver: Need to execute at least one command
|
||||||
// so that the browser logs can be read out!
|
// so that the browser logs can be read out!
|
||||||
browser.executeScript('1+1');
|
browser.executeScript('1+1');
|
||||||
browser.manage().logs().get('browser').then(function(browserLog) {
|
browser.manage().logs().get('browser').then(function(browserLog) {
|
||||||
let filteredLog = browserLog.filter((logEntry) => {
|
let filteredLog = browserLog.filter((logEntry) => {
|
||||||
let message = logEntry.message;
|
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 (logEntry.level.value >= LogLevel.INFO) {
|
||||||
if (message.length > MAX_ERROR_MESSAGE_SYMBOLS) {
|
if (message.length > MAX_ERROR_MESSAGE_SYMBOLS) {
|
||||||
message = message.substr(0, MAX_ERROR_MESSAGE_SYMBOLS) + '...';
|
message = message.substr(0, MAX_ERROR_MESSAGE_SYMBOLS) + '...';
|
||||||
|
@ -43,8 +56,6 @@ function verifyNoBrowserErrors() {
|
||||||
console.log('>> ' + message);
|
console.log('>> ' + message);
|
||||||
}
|
}
|
||||||
|
|
||||||
// skip browser-sync errors
|
|
||||||
if (message.indexOf('browser-sync') > -1) return false;
|
|
||||||
return logEntry.level.value > LogLevel.WARNING;
|
return logEntry.level.value > LogLevel.WARNING;
|
||||||
});
|
});
|
||||||
expect(filteredLog.length).toEqual(0, `Found ${filteredLog.length} browser errors`);
|
expect(filteredLog.length).toEqual(0, `Found ${filteredLog.length} browser errors`);
|
||||||
|
@ -60,8 +71,20 @@ function scrollToEl(selector) {
|
||||||
return browser.driver.executeScript(script);
|
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 = {
|
module.exports = {
|
||||||
loadJson: loadJson,
|
loadJson: loadJson,
|
||||||
verifyNoBrowserErrors: verifyNoBrowserErrors,
|
verifyNoBrowserErrors: verifyNoBrowserErrors,
|
||||||
scrollToEl: scrollToEl
|
scrollToEl: scrollToEl,
|
||||||
|
fixFFTest: fixFFTest
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,19 +1,23 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
<title>ReDoc</title>
|
<title>ReDoc</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<redoc scroll-y-offset="body > nav">
|
<redoc>
|
||||||
Loading...
|
Loading...
|
||||||
</redoc>
|
</redoc>
|
||||||
|
|
||||||
<!-- ReDoc built file with all dependencies included -->
|
<!-- ReDoc built file with all dependencies included -->
|
||||||
<script src="dist/redoc.full.min.js"> </script>
|
<script src="dist/redoc.full.min.js"> </script>
|
||||||
<script>
|
<script>
|
||||||
|
window.redocError = null;
|
||||||
/* init redoc */
|
/* init redoc */
|
||||||
var url = window.location.search.substr(5) || 'swagger.json';
|
var url = window.location.search.substr(5) || 'swagger.json';
|
||||||
Redoc.init(decodeURIComponent(url));
|
Redoc.init(decodeURIComponent(url)).then(function() {}, function(err) {
|
||||||
|
window.redocError = err;
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
const verifyNoBrowserErrors = require('./helpers').verifyNoBrowserErrors;
|
const verifyNoBrowserErrors = require('./helpers').verifyNoBrowserErrors;
|
||||||
const scrollToEl = require('./helpers').scrollToEl;
|
const scrollToEl = require('./helpers').scrollToEl;
|
||||||
|
const fixFFTest = require('./helpers').fixFFTest;
|
||||||
|
|
||||||
const URL = 'index.html';
|
const URL = 'index.html';
|
||||||
|
|
||||||
|
@ -11,12 +12,16 @@ function basicTests(swaggerUrl, title) {
|
||||||
specUrl += `?url=${encodeURIComponent(swaggerUrl)}`;
|
specUrl += `?url=${encodeURIComponent(swaggerUrl)}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
beforeEach((done) => {
|
||||||
|
browser.get(specUrl);
|
||||||
|
fixFFTest(done);
|
||||||
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
verifyNoBrowserErrors();
|
verifyNoBrowserErrors();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should init redoc without errors', () => {
|
it('should init redoc without errors', () => {
|
||||||
browser.get(specUrl);
|
|
||||||
let $redoc = $('redoc');
|
let $redoc = $('redoc');
|
||||||
expect($redoc.isPresent()).toBe(true);
|
expect($redoc.isPresent()).toBe(true);
|
||||||
let $methods = $$('method');
|
let $methods = $$('method');
|
||||||
|
@ -29,8 +34,14 @@ basicTests(null, 'Extended Petstore');
|
||||||
|
|
||||||
|
|
||||||
describe('Scroll sync', () => {
|
describe('Scroll sync', () => {
|
||||||
|
let specUrl = URL;
|
||||||
|
|
||||||
|
beforeEach((done) => {
|
||||||
|
browser.get(specUrl);
|
||||||
|
fixFFTest(done);
|
||||||
|
});
|
||||||
|
|
||||||
it('should update active menu entries on page scroll', () => {
|
it('should update active menu entries on page scroll', () => {
|
||||||
browser.get(URL);
|
|
||||||
scrollToEl('[tag="store"]').then(function() {
|
scrollToEl('[tag="store"]').then(function() {
|
||||||
expect($('.menu-cat-header.active').getText()).toBe('STORE');
|
expect($('.menu-cat-header.active').getText()).toBe('STORE');
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue
Block a user