Skip to content

Commit

Permalink
API Console v6.6.6 (#730)
Browse files Browse the repository at this point in the history
* feat: upgrade deps

* 6.6.6

* test: added two waitUntil to fix failing tests

* test: added two more waitUntil to fix failing tests

* test: added another waitUntil to fix failing tests

* test: added another waitUntil to fix failing tests

* test: added another waitUntil to fix failing tests

* test: documentationTryItButton is now async and has waitUntil inside

* test: added more waitUntil to fix failing tests

* test: wait until body renders media type
  • Loading branch information
twoplustwoone authored Nov 30, 2021
1 parent f775370 commit 6e0c92d
Show file tree
Hide file tree
Showing 6 changed files with 210 additions and 258 deletions.
380 changes: 167 additions & 213 deletions package-lock.json

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "api-console",
"description": "The API Console to automatically generate API documentation from RAML and OAS files.",
"version": "6.6.5",
"version": "6.6.6",
"license": "CPAL-1.0",
"main": "index.js",
"module": "index.js",
Expand Down Expand Up @@ -62,7 +62,7 @@
"@polymer/iron-test-helpers": "^3.0.0",
"@web/test-runner": "^0.12.5",
"@web/test-runner-playwright": "^0.8.0",
"@web/test-runner-visual-regression": "^0.6.3",
"@web/test-runner-visual-regression": "^0.6.4",
"amf-client-js": "^4.6.0",
"body-parser": "^1.19.0",
"deepmerge": "^4.2.1",
Expand All @@ -76,16 +76,16 @@
"lint-staged": "^10.2.2",
"multer": "^1.4.2",
"node-cache": "^5.1.0",
"postcss": "^8.2.4",
"postcss": "^8.4.4",
"rimraf": "^3.0.1",
"rollup": "^2.53.2",
"rollup": "^2.60.2",
"rollup-plugin-cpy": "^2.0.1",
"rollup-plugin-postcss": "^4.0.0",
"rollup-plugin-postcss": "^4.0.2",
"sinon": "^9.2.3",
"tmp": "^0.2.1",
"typescript": "^4.1.3",
"typescript": "^4.5.2",
"typescript-lit-html-plugin": "^0.9.0",
"uglify-js": "^3.12.5",
"uglify-js": "^3.14.3",
"unzipper": "^0.10.10",
"uuid": "^8.3.2"
},
Expand Down
23 changes: 15 additions & 8 deletions test/api-console-documentation.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { fixture, assert, html, aTimeout, waitUntil } from '@open-wc/testing';
import { fixture, assert, html, aTimeout, waitUntil, nextFrame } from '@open-wc/testing';
import { AmfLoader, ApiDescribe } from './amf-loader.js';
import '../api-console.js';
import {
Expand Down Expand Up @@ -263,6 +263,7 @@ describe('API Console documentation', () => {
});

it('should render security headers content', async () => {
await waitUntil(() => Boolean(documentationSecurity(element)));
const item = documentationSecurity(element);
const securityShadowRoot = item.shadowRoot;
const headersDocument = securityShadowRoot.querySelector('api-headers-document');
Expand Down Expand Up @@ -509,6 +510,7 @@ describe('API Console documentation', () => {
});

it('should render type documentation', async () => {
await waitUntil(() => Boolean(documentationType(element)));
const item = documentationType(element);
const docShadowRoot = item.shadowRoot;
const description = 'This is number type';
Expand Down Expand Up @@ -662,26 +664,30 @@ describe('API Console documentation', () => {
describe(`No overview ${noOverview ? 'enabled' : 'disabled'}`, () => {
beforeEach(async () => {
element.noOverview = noOverview;
await aTimeout(50);
await nextFrame();
await navigationSelectEndpointOverview(element, '/test-query-parameters', noOverview);
await aTimeout(100);
await waitUntil(() => Boolean(documentationEndpoint(element)));
const item = documentationEndpoint(element);
docShadowRoot = item.shadowRoot;
});

it('should render endpoint title', () => {
it('should render endpoint title', async () => {
await waitUntil(() => Boolean(docShadowRoot.querySelector('.title')));
assert.equal(docShadowRoot.querySelector('.title').innerText, 'Query Parameters');
});

it('should render URL', () => {
it('should render URL', async () => {
await waitUntil(() => Boolean(docShadowRoot.querySelector('api-url')));
assert.equal(docShadowRoot.querySelector('api-url').shadowRoot.querySelector('.url-area').innerText.trim(), 'https://example/test-query-parameters');
});

it('should render description', () => {
it('should render description', async () => {
await waitUntil(() => Boolean(docShadowRoot.querySelector('arc-marked')));
assert.equal(docShadowRoot.querySelector('arc-marked').querySelector('.markdown-body').innerText.trim(), 'Query parameters endpoint');
});

it('should render methods', () => {
it('should render methods', async () => {
await waitUntil(() => Boolean(docShadowRoot.querySelector('.methods')));
const methodsSection = docShadowRoot.querySelector('.methods');
assert.exists(methodsSection);

Expand Down Expand Up @@ -759,9 +765,10 @@ describe('API Console documentation', () => {
const toggleButton = parametersSection.querySelector('.toggle-button');
assert.exists(toggleButton);
toggleButton.click();
await aTimeout(0);
await nextFrame();

const collapse = parametersSection.querySelector('anypoint-collapse');
await waitUntil(() => collapse.querySelector('.media-type-selector').innerText === 'Media type: application/json');
assert.equal(collapse.querySelector('.media-type-selector').innerText, 'Media type: application/json');
assert.equal(collapse.querySelector('.any-info').innerText, 'Any instance of data is allowed.');
assert.equal(collapse.querySelector('.any-info-description').innerText, 'The API file specifies body for this request but it does not specify the data model.');
Expand Down
44 changes: 16 additions & 28 deletions test/api-console-request.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
requestBodySection, requestCredentialsSection,
requestHeadersSection, requestPanel,
requestQueryParamSection, requestSendButton,
requestUrlSection
requestUrlSection,
} from './testHelper.js';

/** @typedef {import('..').ApiConsole} ApiConsole */
Expand Down Expand Up @@ -44,9 +44,8 @@ describe('API Console request', () => {
describe('Sections', () => {
beforeEach(async () => {
await navigationSelectEndpointMethod(element, '/test-headers', 'post');
await aTimeout(50);
// @ts-ignore
documentationTryItButton(element).click();
(await documentationTryItButton(element)).click();
await aTimeout(50);
});

Expand All @@ -62,9 +61,8 @@ describe('API Console request', () => {
describe('Headers', () => {
beforeEach(async () => {
await navigationSelectEndpointMethod(element, '/test-headers', 'post');
await aTimeout(50);
// @ts-ignore
documentationTryItButton(element).click();
(await documentationTryItButton(element)).click();
await aTimeout(50);
});

Expand Down Expand Up @@ -122,9 +120,8 @@ describe('API Console request', () => {
describe('Body', () => {
beforeEach(async () => {
await navigationSelectEndpointMethod(element, '/test-headers', 'post');
await aTimeout(100);
// @ts-ignore
documentationTryItButton(element).click();
(await documentationTryItButton(element)).click();
await aTimeout(50);
});

Expand Down Expand Up @@ -163,9 +160,8 @@ describe('API Console request', () => {

beforeEach(async () => {
await navigationSelectEndpointMethod(element, '/test-custom-scheme', 'get');
await aTimeout(50);
// @ts-ignore
documentationTryItButton(element).click();
(await documentationTryItButton(element)).click();
await aTimeout(50);
credentialsSection = requestCredentialsSection(element);
});
Expand Down Expand Up @@ -229,9 +225,8 @@ describe('API Console request', () => {

beforeEach(async () => {
await navigationSelectEndpointMethod(element, '/test-oauth10-scheme', 'get');
await aTimeout(70);
// @ts-ignore
documentationTryItButton(element).click();
(await documentationTryItButton(element)).click();
await aTimeout(70);
credentialsSection = requestCredentialsSection(element);
});
Expand Down Expand Up @@ -280,9 +275,8 @@ describe('API Console request', () => {

beforeEach(async () => {
await navigationSelectEndpointMethod(element, '/test-oauth20-scheme', 'get');
await aTimeout(50);
// @ts-ignore
documentationTryItButton(element).click();
(await documentationTryItButton(element)).click();
await aTimeout(50);
credentialsSection = requestCredentialsSection(element);
});
Expand Down Expand Up @@ -324,9 +318,8 @@ describe('API Console request', () => {

beforeEach(async () => {
await navigationSelectEndpointMethod(element, '/test-basic-scheme', 'get');
await aTimeout(50);
// @ts-ignore
documentationTryItButton(element).click();
(await documentationTryItButton(element)).click();
await aTimeout(50);
credentialsSection = requestCredentialsSection(element);
});
Expand Down Expand Up @@ -387,9 +380,8 @@ describe('API Console request', () => {

beforeEach(async () => {
await navigationSelectEndpointMethod(element, '/test-digest-scheme', 'get');
await aTimeout(100);
// @ts-ignore
documentationTryItButton(element).click();
(await documentationTryItButton(element)).click();
await aTimeout(50);
credentialsSection = requestCredentialsSection(element);
});
Expand Down Expand Up @@ -468,9 +460,8 @@ describe('API Console request', () => {

beforeEach(async () => {
await navigationSelectEndpointMethod(element, '/test-pass-through-scheme', 'get');
await aTimeout(100);
// @ts-ignore
documentationTryItButton(element).click();
(await documentationTryItButton(element)).click();
await aTimeout(50);
credentialsSection = requestCredentialsSection(element);
});
Expand All @@ -489,7 +480,8 @@ describe('API Console request', () => {
assert.equal(authorizationMethod.getAttribute('type'), 'pass through');
});

it('should render scheme fields', () => {
it('should render scheme fields', async () => {
await waitUntil(() => Boolean(credentialsSection.shadowRoot.querySelector('api-authorization-method')));
const authorizationMethod = credentialsSection.shadowRoot.querySelector('api-authorization-method');
assert.equal(authorizationMethod.shadowRoot.querySelector('.subtitle').innerText.trim(), 'Scheme: passthrough');
assert.exists(authorizationMethod.shadowRoot.querySelector('.hint-icon'));
Expand Down Expand Up @@ -539,9 +531,8 @@ describe('API Console request', () => {
describe('Required parameters', () => {
beforeEach(async () => {
await navigationSelectEndpointMethod(element, '/test-query-parameters', 'post');
await aTimeout(50);
// @ts-ignore
documentationTryItButton(element).click();
(await documentationTryItButton(element)).click();
await aTimeout(50);
requestPanel(element).allowHideOptional = true;
await aTimeout(50);
Expand Down Expand Up @@ -608,9 +599,8 @@ describe('API Console request', () => {
describe('Optional parameters', () => {
beforeEach(async () => {
await navigationSelectEndpointMethod(element, '/test-query-parameters', 'put');
await aTimeout(50);
// @ts-ignore
documentationTryItButton(element).click();
(await documentationTryItButton(element)).click();
await aTimeout(50);
requestPanel(element).allowHideOptional = true;
await aTimeout(50);
Expand Down Expand Up @@ -659,9 +649,8 @@ describe('API Console request', () => {
describe('allowHideOptional disabled', () => {
beforeEach(async () => {
await navigationSelectEndpointMethod(element, '/test-query-parameters', 'put');
await aTimeout(50);
// @ts-ignore
documentationTryItButton(element).click();
(await documentationTryItButton(element)).click();
await aTimeout(50);
});

Expand All @@ -674,9 +663,8 @@ describe('API Console request', () => {
describe('No parameters', () => {
beforeEach(async () => {
await navigationSelectEndpointMethod(element, '/test-custom-scheme', 'get');
await aTimeout(50);
// @ts-ignore
documentationTryItButton(element).click();
(await documentationTryItButton(element)).click();
await aTimeout(50);
});

Expand Down
1 change: 1 addition & 0 deletions test/api-console.amf.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ describe('ApiConsole', () => {
await nextFrame();
const apiDocumentation = element.shadowRoot.querySelector('api-documentation');
const apiSummary = apiDocumentation.shadowRoot.querySelector('api-summary');
await waitUntil(() => Boolean(apiSummary.shadowRoot.querySelector('api-url')));
const apiUrl = apiSummary.shadowRoot.querySelector('api-url');
assert.notExists(apiUrl.shadowRoot.querySelector('.method-label'));
assert.notExists(apiUrl.shadowRoot.querySelector('.method-value'));
Expand Down
6 changes: 4 additions & 2 deletions test/testHelper.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { nextFrame } from '@open-wc/testing';
import { nextFrame, waitUntil } from '@open-wc/testing';

/** @typedef {import('@api-components/api-navigation').ApiNavigation} ApiNavigation */

Expand Down Expand Up @@ -167,8 +167,10 @@ export const documentationMethod = (element) => {
return documentation.shadowRoot.querySelector('api-method-documentation');
};

export const documentationTryItButton = (element) => {
export const documentationTryItButton = async (element) => {
await waitUntil(() => Boolean(documentationPanel(element)));
const documentation = documentationPanel(element);
await waitUntil(() => Boolean(documentation.shadowRoot.querySelector('api-method-documentation')));
const methodDocumentation = documentation.shadowRoot.querySelector('api-method-documentation');
return methodDocumentation.shadowRoot.querySelector('.action-button');
};
Expand Down

0 comments on commit 6e0c92d

Please sign in to comment.