Skip to content

Commit 6e0c92d

Browse files
API Console v6.6.6 (#730)
* 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
1 parent f775370 commit 6e0c92d

File tree

6 files changed

+210
-258
lines changed

6 files changed

+210
-258
lines changed

package-lock.json

Lines changed: 167 additions & 213 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "api-console",
33
"description": "The API Console to automatically generate API documentation from RAML and OAS files.",
4-
"version": "6.6.5",
4+
"version": "6.6.6",
55
"license": "CPAL-1.0",
66
"main": "index.js",
77
"module": "index.js",
@@ -62,7 +62,7 @@
6262
"@polymer/iron-test-helpers": "^3.0.0",
6363
"@web/test-runner": "^0.12.5",
6464
"@web/test-runner-playwright": "^0.8.0",
65-
"@web/test-runner-visual-regression": "^0.6.3",
65+
"@web/test-runner-visual-regression": "^0.6.4",
6666
"amf-client-js": "^4.6.0",
6767
"body-parser": "^1.19.0",
6868
"deepmerge": "^4.2.1",
@@ -76,16 +76,16 @@
7676
"lint-staged": "^10.2.2",
7777
"multer": "^1.4.2",
7878
"node-cache": "^5.1.0",
79-
"postcss": "^8.2.4",
79+
"postcss": "^8.4.4",
8080
"rimraf": "^3.0.1",
81-
"rollup": "^2.53.2",
81+
"rollup": "^2.60.2",
8282
"rollup-plugin-cpy": "^2.0.1",
83-
"rollup-plugin-postcss": "^4.0.0",
83+
"rollup-plugin-postcss": "^4.0.2",
8484
"sinon": "^9.2.3",
8585
"tmp": "^0.2.1",
86-
"typescript": "^4.1.3",
86+
"typescript": "^4.5.2",
8787
"typescript-lit-html-plugin": "^0.9.0",
88-
"uglify-js": "^3.12.5",
88+
"uglify-js": "^3.14.3",
8989
"unzipper": "^0.10.10",
9090
"uuid": "^8.3.2"
9191
},

test/api-console-documentation.test.js

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { fixture, assert, html, aTimeout, waitUntil } from '@open-wc/testing';
1+
import { fixture, assert, html, aTimeout, waitUntil, nextFrame } from '@open-wc/testing';
22
import { AmfLoader, ApiDescribe } from './amf-loader.js';
33
import '../api-console.js';
44
import {
@@ -263,6 +263,7 @@ describe('API Console documentation', () => {
263263
});
264264

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

511512
it('should render type documentation', async () => {
513+
await waitUntil(() => Boolean(documentationType(element)));
512514
const item = documentationType(element);
513515
const docShadowRoot = item.shadowRoot;
514516
const description = 'This is number type';
@@ -662,26 +664,30 @@ describe('API Console documentation', () => {
662664
describe(`No overview ${noOverview ? 'enabled' : 'disabled'}`, () => {
663665
beforeEach(async () => {
664666
element.noOverview = noOverview;
665-
await aTimeout(50);
667+
await nextFrame();
666668
await navigationSelectEndpointOverview(element, '/test-query-parameters', noOverview);
667-
await aTimeout(100);
669+
await waitUntil(() => Boolean(documentationEndpoint(element)));
668670
const item = documentationEndpoint(element);
669671
docShadowRoot = item.shadowRoot;
670672
});
671673

672-
it('should render endpoint title', () => {
674+
it('should render endpoint title', async () => {
675+
await waitUntil(() => Boolean(docShadowRoot.querySelector('.title')));
673676
assert.equal(docShadowRoot.querySelector('.title').innerText, 'Query Parameters');
674677
});
675678

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

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

684-
it('should render methods', () => {
689+
it('should render methods', async () => {
690+
await waitUntil(() => Boolean(docShadowRoot.querySelector('.methods')));
685691
const methodsSection = docShadowRoot.querySelector('.methods');
686692
assert.exists(methodsSection);
687693

@@ -759,9 +765,10 @@ describe('API Console documentation', () => {
759765
const toggleButton = parametersSection.querySelector('.toggle-button');
760766
assert.exists(toggleButton);
761767
toggleButton.click();
762-
await aTimeout(0);
768+
await nextFrame();
763769

764770
const collapse = parametersSection.querySelector('anypoint-collapse');
771+
await waitUntil(() => collapse.querySelector('.media-type-selector').innerText === 'Media type: application/json');
765772
assert.equal(collapse.querySelector('.media-type-selector').innerText, 'Media type: application/json');
766773
assert.equal(collapse.querySelector('.any-info').innerText, 'Any instance of data is allowed.');
767774
assert.equal(collapse.querySelector('.any-info-description').innerText, 'The API file specifies body for this request but it does not specify the data model.');

test/api-console-request.test.js

Lines changed: 16 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
requestBodySection, requestCredentialsSection,
99
requestHeadersSection, requestPanel,
1010
requestQueryParamSection, requestSendButton,
11-
requestUrlSection
11+
requestUrlSection,
1212
} from './testHelper.js';
1313

1414
/** @typedef {import('..').ApiConsole} ApiConsole */
@@ -44,9 +44,8 @@ describe('API Console request', () => {
4444
describe('Sections', () => {
4545
beforeEach(async () => {
4646
await navigationSelectEndpointMethod(element, '/test-headers', 'post');
47-
await aTimeout(50);
4847
// @ts-ignore
49-
documentationTryItButton(element).click();
48+
(await documentationTryItButton(element)).click();
5049
await aTimeout(50);
5150
});
5251

@@ -62,9 +61,8 @@ describe('API Console request', () => {
6261
describe('Headers', () => {
6362
beforeEach(async () => {
6463
await navigationSelectEndpointMethod(element, '/test-headers', 'post');
65-
await aTimeout(50);
6664
// @ts-ignore
67-
documentationTryItButton(element).click();
65+
(await documentationTryItButton(element)).click();
6866
await aTimeout(50);
6967
});
7068

@@ -122,9 +120,8 @@ describe('API Console request', () => {
122120
describe('Body', () => {
123121
beforeEach(async () => {
124122
await navigationSelectEndpointMethod(element, '/test-headers', 'post');
125-
await aTimeout(100);
126123
// @ts-ignore
127-
documentationTryItButton(element).click();
124+
(await documentationTryItButton(element)).click();
128125
await aTimeout(50);
129126
});
130127

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

164161
beforeEach(async () => {
165162
await navigationSelectEndpointMethod(element, '/test-custom-scheme', 'get');
166-
await aTimeout(50);
167163
// @ts-ignore
168-
documentationTryItButton(element).click();
164+
(await documentationTryItButton(element)).click();
169165
await aTimeout(50);
170166
credentialsSection = requestCredentialsSection(element);
171167
});
@@ -229,9 +225,8 @@ describe('API Console request', () => {
229225

230226
beforeEach(async () => {
231227
await navigationSelectEndpointMethod(element, '/test-oauth10-scheme', 'get');
232-
await aTimeout(70);
233228
// @ts-ignore
234-
documentationTryItButton(element).click();
229+
(await documentationTryItButton(element)).click();
235230
await aTimeout(70);
236231
credentialsSection = requestCredentialsSection(element);
237232
});
@@ -280,9 +275,8 @@ describe('API Console request', () => {
280275

281276
beforeEach(async () => {
282277
await navigationSelectEndpointMethod(element, '/test-oauth20-scheme', 'get');
283-
await aTimeout(50);
284278
// @ts-ignore
285-
documentationTryItButton(element).click();
279+
(await documentationTryItButton(element)).click();
286280
await aTimeout(50);
287281
credentialsSection = requestCredentialsSection(element);
288282
});
@@ -324,9 +318,8 @@ describe('API Console request', () => {
324318

325319
beforeEach(async () => {
326320
await navigationSelectEndpointMethod(element, '/test-basic-scheme', 'get');
327-
await aTimeout(50);
328321
// @ts-ignore
329-
documentationTryItButton(element).click();
322+
(await documentationTryItButton(element)).click();
330323
await aTimeout(50);
331324
credentialsSection = requestCredentialsSection(element);
332325
});
@@ -387,9 +380,8 @@ describe('API Console request', () => {
387380

388381
beforeEach(async () => {
389382
await navigationSelectEndpointMethod(element, '/test-digest-scheme', 'get');
390-
await aTimeout(100);
391383
// @ts-ignore
392-
documentationTryItButton(element).click();
384+
(await documentationTryItButton(element)).click();
393385
await aTimeout(50);
394386
credentialsSection = requestCredentialsSection(element);
395387
});
@@ -468,9 +460,8 @@ describe('API Console request', () => {
468460

469461
beforeEach(async () => {
470462
await navigationSelectEndpointMethod(element, '/test-pass-through-scheme', 'get');
471-
await aTimeout(100);
472463
// @ts-ignore
473-
documentationTryItButton(element).click();
464+
(await documentationTryItButton(element)).click();
474465
await aTimeout(50);
475466
credentialsSection = requestCredentialsSection(element);
476467
});
@@ -489,7 +480,8 @@ describe('API Console request', () => {
489480
assert.equal(authorizationMethod.getAttribute('type'), 'pass through');
490481
});
491482

492-
it('should render scheme fields', () => {
483+
it('should render scheme fields', async () => {
484+
await waitUntil(() => Boolean(credentialsSection.shadowRoot.querySelector('api-authorization-method')));
493485
const authorizationMethod = credentialsSection.shadowRoot.querySelector('api-authorization-method');
494486
assert.equal(authorizationMethod.shadowRoot.querySelector('.subtitle').innerText.trim(), 'Scheme: passthrough');
495487
assert.exists(authorizationMethod.shadowRoot.querySelector('.hint-icon'));
@@ -539,9 +531,8 @@ describe('API Console request', () => {
539531
describe('Required parameters', () => {
540532
beforeEach(async () => {
541533
await navigationSelectEndpointMethod(element, '/test-query-parameters', 'post');
542-
await aTimeout(50);
543534
// @ts-ignore
544-
documentationTryItButton(element).click();
535+
(await documentationTryItButton(element)).click();
545536
await aTimeout(50);
546537
requestPanel(element).allowHideOptional = true;
547538
await aTimeout(50);
@@ -608,9 +599,8 @@ describe('API Console request', () => {
608599
describe('Optional parameters', () => {
609600
beforeEach(async () => {
610601
await navigationSelectEndpointMethod(element, '/test-query-parameters', 'put');
611-
await aTimeout(50);
612602
// @ts-ignore
613-
documentationTryItButton(element).click();
603+
(await documentationTryItButton(element)).click();
614604
await aTimeout(50);
615605
requestPanel(element).allowHideOptional = true;
616606
await aTimeout(50);
@@ -659,9 +649,8 @@ describe('API Console request', () => {
659649
describe('allowHideOptional disabled', () => {
660650
beforeEach(async () => {
661651
await navigationSelectEndpointMethod(element, '/test-query-parameters', 'put');
662-
await aTimeout(50);
663652
// @ts-ignore
664-
documentationTryItButton(element).click();
653+
(await documentationTryItButton(element)).click();
665654
await aTimeout(50);
666655
});
667656

@@ -674,9 +663,8 @@ describe('API Console request', () => {
674663
describe('No parameters', () => {
675664
beforeEach(async () => {
676665
await navigationSelectEndpointMethod(element, '/test-custom-scheme', 'get');
677-
await aTimeout(50);
678666
// @ts-ignore
679-
documentationTryItButton(element).click();
667+
(await documentationTryItButton(element)).click();
680668
await aTimeout(50);
681669
});
682670

test/api-console.amf.test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ describe('ApiConsole', () => {
104104
await nextFrame();
105105
const apiDocumentation = element.shadowRoot.querySelector('api-documentation');
106106
const apiSummary = apiDocumentation.shadowRoot.querySelector('api-summary');
107+
await waitUntil(() => Boolean(apiSummary.shadowRoot.querySelector('api-url')));
107108
const apiUrl = apiSummary.shadowRoot.querySelector('api-url');
108109
assert.notExists(apiUrl.shadowRoot.querySelector('.method-label'));
109110
assert.notExists(apiUrl.shadowRoot.querySelector('.method-value'));

test/testHelper.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { nextFrame } from '@open-wc/testing';
1+
import { nextFrame, waitUntil } from '@open-wc/testing';
22

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

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

170-
export const documentationTryItButton = (element) => {
170+
export const documentationTryItButton = async (element) => {
171+
await waitUntil(() => Boolean(documentationPanel(element)));
171172
const documentation = documentationPanel(element);
173+
await waitUntil(() => Boolean(documentation.shadowRoot.querySelector('api-method-documentation')));
172174
const methodDocumentation = documentation.shadowRoot.querySelector('api-method-documentation');
173175
return methodDocumentation.shadowRoot.querySelector('.action-button');
174176
};

0 commit comments

Comments
 (0)