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');
menu.activeCatIdx.should.be.equal(0);
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
spyOn(scroll, 'scrollY').and.returnValue(elTop + 2);
spyOn(scroll, 'scrollY').and.returnValue(nextElTop + 10);
menu.scrollUpdate(true);
menu.activeCatIdx.should.be.equal(1);
scroll.scrollY.and.returnValue(elTop - 2);
scroll.$scrollParent.scrollTop = elTop - 1;
scroll.scrollY.and.returnValue(nextElTop - 2);
scroll.$scrollParent.scrollTop = nextElTop - 1;
menu.scrollUpdate(false);
menu.activeCatIdx.should.be.equal(0);
});

View File

@ -14,7 +14,7 @@
<script>
window.redocError = null;
/* 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) {
window.redocError = err;
});

View File

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

View File

@ -1,7 +1,6 @@
---
swagger: "2.0"
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"
title: "Swagger Petstore"
termsOfService: "http://swagger.io/terms/"
@ -12,56 +11,50 @@
license:
name: "Apache 2.0"
url: "http://www.apache.org/licenses/LICENSE-2.0.html"
description: |-
# Pagination
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
set of data.
```json
{
...
"pagination": {
"next_url": "https://api.instagram.com/v1/tags/puppy/media/recent?access_token=fb2e77d.47a0479900504cb3ab4a1f626d174d2d&max_id=13872296",
"next_max_id": "13872296"
}
}
```
On views where pagination is present, we also support the `count` parameter.
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
defined on each endpoint.
# JSONP
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.
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:
```
https://api.instagram.com/v1/tags/coffee/media/recent?access_token=fb2e77d.47a0479900504cb3ab4a1f626d174d2d&callback=callbackFunction
```
Would respond with:
```js
callbackFunction({
...
});
```
> Example of markdown blockquote
host: "petstore.swagger.io"
basePath: "/v2"
tags:
-
name: "Pagination"
x-traitTag: true
description: |-
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
set of data.
```json
{
...
"pagination": {
"next_url": "https://api.instagram.com/v1/tags/puppy/media/recent?access_token=fb2e77d.47a0479900504cb3ab4a1f626d174d2d&max_id=13872296",
"next_max_id": "13872296"
}
}
```
On views where pagination is present, we also support the `count` parameter.
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
defined on each endpoint.
externalDocs:
description: "Find out more"
url: "http://swagger.io"
-
name: "JSONP"
x-traitTag: true
description: |-
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:
```
https://api.instagram.com/v1/tags/coffee/media/recent?access_token=fb2e77d.47a0479900504cb3ab4a1f626d174d2d&callback=callbackFunction
```
Would respond with:
```js
callbackFunction({
...
});
```
> Example of markdown blockquote
externalDocs:
description: "Find out more"
url: "http://swagger.io"
-
name: "pet"
description: "Everything about your Pets"

View File

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