Fix e2e and unit tests

This commit is contained in:
Roman Hotsiy 2016-10-31 20:15:56 +02:00
parent 4aa212547f
commit 1aa9c4a3f2
No known key found for this signature in database
GPG Key ID: 5CB7B3ACABA57CB0
5 changed files with 60 additions and 62 deletions

View File

@ -78,17 +78,17 @@ describe('Menu service', () => {
scroll.$scrollParent = document.querySelector('#parent'); scroll.$scrollParent = document.querySelector('#parent');
menu.activeCatIdx.should.be.equal(0); menu.activeCatIdx.should.be.equal(0);
menu.activeMethodIdx.should.be.equal(-1); menu.activeMethodIdx.should.be.equal(-1);
let elTop = menu.getCurrentMethodEl().getBoundingClientRect().bottom; let nextElTop = menu.getRelativeCatOrItem(1).getBoundingClientRect().top;
scroll.$scrollParent.scrollTop = elTop + 1; scroll.$scrollParent.scrollTop = nextElTop + 1;
//simulate scroll down //simulate scroll down
spyOn(scroll, 'scrollY').and.returnValue(elTop + 2); spyOn(scroll, 'scrollY').and.returnValue(nextElTop + 10);
menu.scrollUpdate(true); menu.scrollUpdate(true);
menu.activeCatIdx.should.be.equal(1); menu.activeCatIdx.should.be.equal(1);
scroll.scrollY.and.returnValue(elTop - 2); scroll.scrollY.and.returnValue(nextElTop - 2);
scroll.$scrollParent.scrollTop = elTop - 1; scroll.$scrollParent.scrollTop = nextElTop - 1;
menu.scrollUpdate(false); menu.scrollUpdate(false);
menu.activeCatIdx.should.be.equal(0); menu.activeCatIdx.should.be.equal(0);
}); });

View File

@ -14,7 +14,7 @@
<script> <script>
window.redocError = null; window.redocError = null;
/* init redoc */ /* init redoc */
var url = window.location.search.substr(5) || 'http://rebilly.github.io/SwaggerTemplateRepo/swagger.json'; var url = window.location.search.substr(5) || 'http://rebilly.github.io/ReDoc/swagger.yaml';
Redoc.init(decodeURIComponent(url), {disableLazySchemas: true, suppressWarnings: true}).then(function() {}, function(err) { Redoc.init(decodeURIComponent(url), {disableLazySchemas: true, suppressWarnings: true}).then(function() {}, function(err) {
window.redocError = err; window.redocError = err;
}); });

View File

@ -6,6 +6,13 @@ const eachNth = require('./helpers').eachNth;
const URL = 'index.html'; const URL = 'index.html';
function waitForInit() {
var EC = protractor.ExpectedConditions;
var $apiInfo = $('api-info');
var $errorMessage = $('.redoc-error')
browser.wait(EC.or(EC.visibilityOf($apiInfo), EC.visibilityOf($errorMessage)), 60000);
}
function basicTests(swaggerUrl, title) { function basicTests(swaggerUrl, title) {
describe(`Basic suite for ${title}`, () => { describe(`Basic suite for ${title}`, () => {
let specUrl = URL; let specUrl = URL;
@ -15,11 +22,8 @@ function basicTests(swaggerUrl, title) {
beforeEach((done) => { beforeEach((done) => {
browser.get(specUrl); browser.get(specUrl);
waitForInit();
fixFFTest(done); fixFFTest(done);
var EC = protractor.ExpectedConditions;
var $apiInfo = $('api-info');
var $errorMessage = $('.redoc-error')
browser.wait(EC.or(EC.visibilityOf($apiInfo), EC.visibilityOf($errorMessage)), 60000);
}); });
afterEach(() => { afterEach(() => {
@ -46,6 +50,7 @@ describe('Scroll sync', () => {
beforeEach((done) => { beforeEach((done) => {
browser.get(specUrl); browser.get(specUrl);
waitForInit();
fixFFTest(done); fixFFTest(done);
}); });
@ -71,6 +76,7 @@ describe('Language tabs sync', () => {
beforeEach((done) => { beforeEach((done) => {
browser.get(specUrl); browser.get(specUrl);
waitForInit();
fixFFTest(done); fixFFTest(done);
}); });
@ -100,7 +106,6 @@ if (process.env.JOB === 'e2e-guru') {
delete apisGuruList['clarify.io']; // non-string references delete apisGuruList['clarify.io']; // non-string references
//delete apisGuruList['pushpay.com']; // https://github.com/Rebilly/ReDoc/issues/30 //delete apisGuruList['pushpay.com']; // https://github.com/Rebilly/ReDoc/issues/30
delete apisGuruList['bbci.co.uk']; // too big delete apisGuruList['bbci.co.uk']; // too big
delete apisGuruList['bbc.com']; // too big
// run quick version of e2e test on all builds except releases // run quick version of e2e test on all builds except releases
if (process.env.TRAVIS && !process.env.TRAVIS_TAG) { if (process.env.TRAVIS && !process.env.TRAVIS_TAG) {

View File

@ -1,7 +1,6 @@
--- ---
swagger: "2.0" swagger: "2.0"
info: info:
description: "This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters."
version: "1.0.0" version: "1.0.0"
title: "Swagger Petstore" title: "Swagger Petstore"
termsOfService: "http://swagger.io/terms/" termsOfService: "http://swagger.io/terms/"
@ -12,13 +11,8 @@
license: license:
name: "Apache 2.0" name: "Apache 2.0"
url: "http://www.apache.org/licenses/LICENSE-2.0.html" url: "http://www.apache.org/licenses/LICENSE-2.0.html"
host: "petstore.swagger.io"
basePath: "/v2"
tags:
-
name: "Pagination"
x-traitTag: true
description: |- description: |-
# Pagination
Sometimes you just can't get enough. For this reason, we've provided a convenient way to access more data in Sometimes you just can't get enough. For this reason, we've provided a convenient way to access more data in
any request for sequential data. Simply call the url in the next_url parameter and we'll respond with the next any request for sequential data. Simply call the url in the next_url parameter and we'll respond with the next
set of data. set of data.
@ -37,13 +31,12 @@
Simply set this to the number of items you'd like to receive. Note that the default values Simply set this to the number of items you'd like to receive. Note that the default values
should be fine for most applications - but if you decide to increase this number there is a maximum value should be fine for most applications - but if you decide to increase this number there is a maximum value
defined on each endpoint. defined on each endpoint.
externalDocs:
description: "Find out more" # JSONP
url: "http://swagger.io" This is a sample server Petstore server.
- You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on
name: "JSONP" [irc.freenode.net, #swagger](http://swagger.io/irc/).
x-traitTag: true For this sample, you can use the api key `special-key` to test the authorization filters.
description: |-
If you're writing an AJAX application, and you'd like to wrap our response with a callback, If you're writing an AJAX application, and you'd like to wrap our response with a callback,
all you have to do is specify a callback parameter with any API call: all you have to do is specify a callback parameter with any API call:
@ -59,9 +52,9 @@
``` ```
> Example of markdown blockquote > Example of markdown blockquote
externalDocs: host: "petstore.swagger.io"
description: "Find out more" basePath: "/v2"
url: "http://swagger.io" tags:
- -
name: "pet" name: "pet"
description: "Everything about your Pets" description: "Everything about your Pets"

View File

@ -75,9 +75,9 @@ describe('Utils', () => {
describe('byPointer method', () => { describe('byPointer method', () => {
it('should return correct schema part', ()=> { it('should return correct schema part', ()=> {
let part = specMgr.byPointer('/tags/3'); let part = specMgr.byPointer('/tags/0');
part.should.be.deepEqual(specMgr.schema.tags[3]); part.should.be.deepEqual(specMgr.schema.tags[0]);
part.should.be.equal(specMgr.schema.tags[3]); part.should.be.equal(specMgr.schema.tags[0]);
}); });
it('should return null for incorrect pointer', ()=> { it('should return null for incorrect pointer', ()=> {