redoc/tests/e2e/redoc.spec.js

84 lines
2.7 KiB
JavaScript
Raw Normal View History

2016-01-15 23:34:28 +03:00
'use strict';
const verifyNoBrowserErrors = require('./helpers').verifyNoBrowserErrors;
const scrollToEl = require('./helpers').scrollToEl;
2016-01-17 14:51:21 +03:00
const fixFFTest = require('./helpers').fixFFTest;
const eachNth = require('./helpers').eachNth;
2016-01-15 23:34:28 +03:00
const URL = 'index.html';
function basicTests(swaggerUrl, title) {
describe(`Basic suite for ${title}`, () => {
let specUrl = URL;
if (swaggerUrl) {
specUrl += `?url=${encodeURIComponent(swaggerUrl)}`;
}
2016-01-17 14:51:21 +03:00
beforeEach((done) => {
browser.get(specUrl);
fixFFTest(done);
});
2016-01-15 23:34:28 +03:00
afterEach(() => {
verifyNoBrowserErrors();
});
2016-01-16 00:22:11 +03:00
it('should init redoc without errors', () => {
2016-01-15 23:34:28 +03:00
let $redoc = $('redoc');
expect($redoc.isPresent()).toBe(true);
let $methods = $$('method');
expect($methods.count()).toBeGreaterThan(0);
});
});
}
2016-01-16 00:22:11 +03:00
basicTests(null, 'Extended Petstore');
2016-01-15 23:34:28 +03:00
describe('Scroll sync', () => {
2016-01-17 14:51:21 +03:00
let specUrl = URL;
2016-01-17 14:51:21 +03:00
beforeEach((done) => {
browser.get(specUrl);
fixFFTest(done);
});
2016-01-15 23:34:28 +03:00
it('should update active menu entries on page scroll', () => {
scrollToEl('[tag="store"]').then(function() {
expect($('.menu-cat-header.active').getInnerHtml()).toContain('store');
expect($('.selected-tag').getInnerHtml()).toContain('store');
2016-01-15 23:34:28 +03:00
});
});
});
describe('APIs.guru specs test', ()=> {
// global.apisGuruList was loaded in onPrepare method of protractor config
let apisGuruList = global.apisGuruList;
2016-01-17 01:35:29 +03:00
// Remove certain APIs that are known to cause problems
delete apisGuruList['motaword.com']; // invalid (see https://github.com/BigstickCarpet/swagger-parser/issues/26)
delete apisGuruList['learnifier.com']; // allof object and no type
delete apisGuruList['googleapis.com:mirror']; // bad urls in images
delete apisGuruList['googleapis.com:discovery']; // non-string references
2016-02-22 17:12:17 +03:00
delete apisGuruList['clarify.io']; // non-string references
2016-03-15 17:14:39 +03:00
delete apisGuruList['pushpay.com']; // https://github.com/Rebilly/ReDoc/issues/30
2016-01-17 01:35:29 +03:00
// run quick version of e2e test on all builds except releases
if (process.env.TRAVIS && !process.env.TRAVIS_TAG) {
console.log('Running on short APIs guru list');
apisGuruList = eachNth(apisGuruList, 10);
} else {
console.log('Running on full APIs guru list')
}
2016-01-15 23:34:28 +03:00
for (let apiName of Object.keys(apisGuruList)) {
let apiInfo = apisGuruList[apiName].versions[apisGuruList[apiName].preferred];
let url = apiInfo.swaggerUrl;
// temporary hack due to this issue: https://github.com/substack/https-browserify/issues/6
url = url.replace('https://', 'http://');
url = url.replace('apis-guru.github.io/', 'apis-guru.github.io:80/');
2016-01-16 00:22:11 +03:00
basicTests(url, `${apiName}:${apiInfo.info.version}\n${url}`);
2016-01-15 23:34:28 +03:00
}
});