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
|
||||
$ 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
|
||||
$ npm run cy:open
|
||||
|
||||
# run the full test suite, include linting / unit / e2e
|
||||
# run the unit tests (includes linting and license checks)
|
||||
$ npm test
|
||||
|
||||
# prepare bundles
|
||||
|
|
|
@ -6,7 +6,7 @@ describe('Menu', () => {
|
|||
it('should have valid items count', () => {
|
||||
cy.get('.menu-content')
|
||||
.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', () => {
|
||||
|
|
|
@ -8,9 +8,9 @@ const getInnerHtml = require('./helpers').getInnerHtml;
|
|||
const URL = 'index.html';
|
||||
|
||||
function waitForInit() {
|
||||
var EC = protractor.ExpectedConditions;
|
||||
var $apiInfo = $('api-info');
|
||||
var $errorMessage = $('.redoc-error')
|
||||
const EC = protractor.ExpectedConditions;
|
||||
const $apiInfo = $('api-info');
|
||||
const $errorMessage = $('.redoc-error');
|
||||
browser.wait(EC.or(EC.visibilityOf($apiInfo), EC.visibilityOf($errorMessage)), 60000);
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,7 @@ function basicTests(swaggerUrl, title) {
|
|||
specUrl += `?url=${encodeURIComponent(swaggerUrl)}`;
|
||||
}
|
||||
|
||||
beforeEach((done) => {
|
||||
beforeEach(done => {
|
||||
browser.get(specUrl);
|
||||
waitForInit();
|
||||
fixFFTest(done);
|
||||
|
@ -31,11 +31,11 @@ function basicTests(swaggerUrl, title) {
|
|||
verifyNoBrowserErrors();
|
||||
});
|
||||
|
||||
it('should init redoc without errors', (done) => {
|
||||
let $redoc = $('redoc');
|
||||
it('should init redoc without errors', done => {
|
||||
const $redoc = $('redoc');
|
||||
expect($redoc.isPresent()).toBe(true);
|
||||
setTimeout(() => {
|
||||
let $operations = $$('operation');
|
||||
const $operations = $$('operation');
|
||||
expect($operations.count()).toBeGreaterThan(0);
|
||||
done();
|
||||
});
|
||||
|
@ -45,11 +45,10 @@ function basicTests(swaggerUrl, title) {
|
|||
|
||||
basicTests(null, 'Extended Petstore');
|
||||
|
||||
|
||||
describe('Scroll sync', () => {
|
||||
let specUrl = URL;
|
||||
const specUrl = URL;
|
||||
|
||||
beforeEach((done) => {
|
||||
beforeEach(done => {
|
||||
browser.get(specUrl);
|
||||
waitForInit();
|
||||
fixFFTest(done);
|
||||
|
@ -57,25 +56,31 @@ describe('Scroll sync', () => {
|
|||
|
||||
it('should update active menu entries on page scroll forwards', () => {
|
||||
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');
|
||||
});
|
||||
});
|
||||
|
||||
it('should update active menu entries on page scroll backwards', () => {
|
||||
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('.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');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Language tabs sync', () => {
|
||||
let specUrl = URL;
|
||||
const specUrl = URL;
|
||||
|
||||
beforeEach((done) => {
|
||||
beforeEach(done => {
|
||||
browser.get(specUrl);
|
||||
waitForInit();
|
||||
fixFFTest(done);
|
||||
|
@ -84,10 +89,10 @@ describe('Language tabs sync', () => {
|
|||
// skip as it fails for no reason on IE on sauce-labs
|
||||
// TODO: fixme
|
||||
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
|
||||
expect($item.getText()).toContain('PHP');
|
||||
var EC = protractor.ExpectedConditions;
|
||||
const EC = protractor.ExpectedConditions;
|
||||
browser.wait(EC.elementToBeClickable($item), 5000);
|
||||
$item.click().then(() => {
|
||||
expect($('[operation-id="updatePet"] li.active').getText()).toContain('PHP');
|
||||
|
@ -96,8 +101,7 @@ describe('Language tabs sync', () => {
|
|||
});
|
||||
|
||||
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
|
||||
let apisGuruList = global.apisGuruList;
|
||||
|
||||
|
@ -118,11 +122,11 @@ if (process.env.JOB === 'e2e-guru') {
|
|||
console.log('Running on a short APIs guru list');
|
||||
apisGuruList = eachNth(apisGuruList, 20);
|
||||
} else {
|
||||
console.log('Running on full APIs guru list')
|
||||
console.log('Running on full APIs guru list');
|
||||
}
|
||||
|
||||
for (let apiName of Object.keys(apisGuruList)) {
|
||||
let apiInfo = apisGuruList[apiName].versions[apisGuruList[apiName].preferred];
|
||||
for (const apiName of Object.keys(apisGuruList)) {
|
||||
const 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
|
||||
|
|
Loading…
Reference in New Issue
Block a user