mirror of
https://github.com/Redocly/redoc.git
synced 2025-08-07 21:54:53 +03:00
Update e2e tests and documentation
This commit is contained in:
parent
27de9e8417
commit
a306068aaa
4
.github/CONTRIBUTING.md
vendored
4
.github/CONTRIBUTING.md
vendored
|
@ -50,11 +50,13 @@ $ npm run unit
|
||||||
|
|
||||||
# run e2e tests
|
# run e2e tests
|
||||||
$ npm run e2e
|
$ npm run e2e
|
||||||
|
# Make sure you have created bundle before running e2e test
|
||||||
|
# E.g. run `npm run bundle` and wait for the finishing process.
|
||||||
|
|
||||||
# open cypress UI to debug e2e test
|
# open cypress UI to debug e2e test
|
||||||
$ npm run cy:open
|
$ npm run cy:open
|
||||||
|
|
||||||
# run the full test suite, include linting / unit / e2e
|
# run the unit tests (includes linting and license checks)
|
||||||
$ npm test
|
$ npm test
|
||||||
|
|
||||||
# prepare bundles
|
# prepare bundles
|
||||||
|
|
|
@ -6,7 +6,7 @@ describe('Menu', () => {
|
||||||
it('should have valid items count', () => {
|
it('should have valid items count', () => {
|
||||||
cy.get('.menu-content')
|
cy.get('.menu-content')
|
||||||
.find('li')
|
.find('li')
|
||||||
.should('have.length', 6 + (2 + 8 + 1 + 4 + 2) + (1 + 8));
|
.should('have.length', 6 + (2 + 8 + 1 + 4 + 2) + (1 + 8) + 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should sync active menu items while scroll', () => {
|
it('should sync active menu items while scroll', () => {
|
||||||
|
|
|
@ -8,9 +8,9 @@ const getInnerHtml = require('./helpers').getInnerHtml;
|
||||||
const URL = 'index.html';
|
const URL = 'index.html';
|
||||||
|
|
||||||
function waitForInit() {
|
function waitForInit() {
|
||||||
var EC = protractor.ExpectedConditions;
|
const EC = protractor.ExpectedConditions;
|
||||||
var $apiInfo = $('api-info');
|
const $apiInfo = $('api-info');
|
||||||
var $errorMessage = $('.redoc-error')
|
const $errorMessage = $('.redoc-error');
|
||||||
browser.wait(EC.or(EC.visibilityOf($apiInfo), EC.visibilityOf($errorMessage)), 60000);
|
browser.wait(EC.or(EC.visibilityOf($apiInfo), EC.visibilityOf($errorMessage)), 60000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ function basicTests(swaggerUrl, title) {
|
||||||
specUrl += `?url=${encodeURIComponent(swaggerUrl)}`;
|
specUrl += `?url=${encodeURIComponent(swaggerUrl)}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
beforeEach((done) => {
|
beforeEach(done => {
|
||||||
browser.get(specUrl);
|
browser.get(specUrl);
|
||||||
waitForInit();
|
waitForInit();
|
||||||
fixFFTest(done);
|
fixFFTest(done);
|
||||||
|
@ -31,11 +31,11 @@ function basicTests(swaggerUrl, title) {
|
||||||
verifyNoBrowserErrors();
|
verifyNoBrowserErrors();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should init redoc without errors', (done) => {
|
it('should init redoc without errors', done => {
|
||||||
let $redoc = $('redoc');
|
const $redoc = $('redoc');
|
||||||
expect($redoc.isPresent()).toBe(true);
|
expect($redoc.isPresent()).toBe(true);
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
let $operations = $$('operation');
|
const $operations = $$('operation');
|
||||||
expect($operations.count()).toBeGreaterThan(0);
|
expect($operations.count()).toBeGreaterThan(0);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
@ -45,11 +45,10 @@ function basicTests(swaggerUrl, title) {
|
||||||
|
|
||||||
basicTests(null, 'Extended Petstore');
|
basicTests(null, 'Extended Petstore');
|
||||||
|
|
||||||
|
|
||||||
describe('Scroll sync', () => {
|
describe('Scroll sync', () => {
|
||||||
let specUrl = URL;
|
const specUrl = URL;
|
||||||
|
|
||||||
beforeEach((done) => {
|
beforeEach(done => {
|
||||||
browser.get(specUrl);
|
browser.get(specUrl);
|
||||||
waitForInit();
|
waitForInit();
|
||||||
fixFFTest(done);
|
fixFFTest(done);
|
||||||
|
@ -57,25 +56,31 @@ describe('Scroll sync', () => {
|
||||||
|
|
||||||
it('should update active menu entries on page scroll forwards', () => {
|
it('should update active menu entries on page scroll forwards', () => {
|
||||||
scrollToEl('[section="tag/store"]').then(() => {
|
scrollToEl('[section="tag/store"]').then(() => {
|
||||||
expect(getInnerHtml('.menu-item.menu-item-depth-1.active > .menu-item-header')).toContain('store');
|
expect(getInnerHtml('.menu-item.menu-item-depth-1.active > .menu-item-header')).toContain(
|
||||||
|
'store',
|
||||||
|
);
|
||||||
expect(getInnerHtml('.selected-tag')).toContain('store');
|
expect(getInnerHtml('.selected-tag')).toContain('store');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should update active menu entries on page scroll backwards', () => {
|
it('should update active menu entries on page scroll backwards', () => {
|
||||||
scrollToEl('[operation-id="getPetById"]').then(() => {
|
scrollToEl('[operation-id="getPetById"]').then(() => {
|
||||||
expect(getInnerHtml('.menu-item.menu-item-depth-1.active .menu-item-header')).toContain('pet');
|
expect(getInnerHtml('.menu-item.menu-item-depth-1.active .menu-item-header')).toContain(
|
||||||
|
'pet',
|
||||||
|
);
|
||||||
expect(getInnerHtml('.selected-tag')).toContain('pet');
|
expect(getInnerHtml('.selected-tag')).toContain('pet');
|
||||||
expect(getInnerHtml('.menu-item.menu-item-depth-2.active .menu-item-header')).toContain('Find pet by ID');
|
expect(getInnerHtml('.menu-item.menu-item-depth-2.active .menu-item-header')).toContain(
|
||||||
|
'Find pet by ID',
|
||||||
|
);
|
||||||
expect(getInnerHtml('.selected-endpoint')).toContain('Find pet by ID');
|
expect(getInnerHtml('.selected-endpoint')).toContain('Find pet by ID');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('Language tabs sync', () => {
|
describe('Language tabs sync', () => {
|
||||||
let specUrl = URL;
|
const specUrl = URL;
|
||||||
|
|
||||||
beforeEach((done) => {
|
beforeEach(done => {
|
||||||
browser.get(specUrl);
|
browser.get(specUrl);
|
||||||
waitForInit();
|
waitForInit();
|
||||||
fixFFTest(done);
|
fixFFTest(done);
|
||||||
|
@ -84,10 +89,10 @@ describe('Language tabs sync', () => {
|
||||||
// skip as it fails for no reason on IE on sauce-labs
|
// skip as it fails for no reason on IE on sauce-labs
|
||||||
// TODO: fixme
|
// TODO: fixme
|
||||||
xit('should sync language tabs', () => {
|
xit('should sync language tabs', () => {
|
||||||
var $item = $$('[operation-id="addPet"] tabs > ul > li').last();
|
const $item = $$('[operation-id="addPet"] tabs > ul > li').last();
|
||||||
// check if correct item
|
// check if correct item
|
||||||
expect($item.getText()).toContain('PHP');
|
expect($item.getText()).toContain('PHP');
|
||||||
var EC = protractor.ExpectedConditions;
|
const EC = protractor.ExpectedConditions;
|
||||||
browser.wait(EC.elementToBeClickable($item), 5000);
|
browser.wait(EC.elementToBeClickable($item), 5000);
|
||||||
$item.click().then(() => {
|
$item.click().then(() => {
|
||||||
expect($('[operation-id="updatePet"] li.active').getText()).toContain('PHP');
|
expect($('[operation-id="updatePet"] li.active').getText()).toContain('PHP');
|
||||||
|
@ -97,7 +102,6 @@ describe('Language tabs sync', () => {
|
||||||
|
|
||||||
if (process.env.JOB === 'e2e-guru') {
|
if (process.env.JOB === 'e2e-guru') {
|
||||||
describe('APIs.guru specs test', () => {
|
describe('APIs.guru specs test', () => {
|
||||||
|
|
||||||
// global.apisGuruList was loaded in onPrepare method of protractor config
|
// global.apisGuruList was loaded in onPrepare method of protractor config
|
||||||
let apisGuruList = global.apisGuruList;
|
let apisGuruList = global.apisGuruList;
|
||||||
|
|
||||||
|
@ -118,11 +122,11 @@ if (process.env.JOB === 'e2e-guru') {
|
||||||
console.log('Running on a short APIs guru list');
|
console.log('Running on a short APIs guru list');
|
||||||
apisGuruList = eachNth(apisGuruList, 20);
|
apisGuruList = eachNth(apisGuruList, 20);
|
||||||
} else {
|
} else {
|
||||||
console.log('Running on full APIs guru list')
|
console.log('Running on full APIs guru list');
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let apiName of Object.keys(apisGuruList)) {
|
for (const apiName of Object.keys(apisGuruList)) {
|
||||||
let apiInfo = apisGuruList[apiName].versions[apisGuruList[apiName].preferred];
|
const apiInfo = apisGuruList[apiName].versions[apisGuruList[apiName].preferred];
|
||||||
let url = apiInfo.swaggerUrl;
|
let url = apiInfo.swaggerUrl;
|
||||||
|
|
||||||
// temporary hack due to this issue: https://github.com/substack/https-browserify/issues/6
|
// temporary hack due to this issue: https://github.com/substack/https-browserify/issues/6
|
||||||
|
|
Loading…
Reference in New Issue
Block a user