@@ -2,13 +2,16 @@ import { fixture, assert, html, aTimeout, waitUntil, nextFrame } from '@open-wc/
22import { AmfLoader , ApiDescribe } from './amf-loader.js' ;
33import '../api-console.js' ;
44import {
5- documentationDocument , documentationEndpoint , documentationMethod ,
5+ documentationDocument ,
6+ documentationEndpoint ,
7+ documentationMethod ,
68 documentationPanel ,
79 documentationSecurity ,
810 documentationSummary ,
911 documentationType ,
1012 navigationSelectDocumentation ,
11- navigationSelectDocumentationSection , navigationSelectEndpointMethod ,
13+ navigationSelectDocumentationSection ,
14+ navigationSelectEndpointMethod ,
1215 navigationSelectEndpointOverview ,
1316 navigationSelectSecurity ,
1417 navigationSelectSecuritySection ,
@@ -132,6 +135,7 @@ describe('API Console documentation', () => {
132135 } ) ;
133136
134137 it ( 'should render basic summary documentation' , async ( ) => {
138+ await waitUntil ( ( ) => Boolean ( documentationSummary ( element ) ) ) ;
135139 const summaryShadowRoot = documentationSummary ( element ) . shadowRoot ;
136140 await waitUntil ( ( ) => Boolean ( summaryShadowRoot . querySelector ( '.api-title' ) ) ) ;
137141 assert . equal ( summaryShadowRoot . querySelector ( '.api-title' ) . textContent . trim ( ) , 'API title:\n Google Drive' ) ;
@@ -777,4 +781,77 @@ describe('API Console documentation', () => {
777781 } ) ;
778782 } ) ;
779783 } ) ;
784+
785+ [
786+ new ApiDescribe ( 'Regular model' ) ,
787+ new ApiDescribe ( 'Compact model' , true )
788+ ] . forEach ( ( { label, compact } ) => {
789+ describe ( label , ( ) => {
790+ let docShadowRoot ;
791+
792+ before ( async ( ) => {
793+ amf = await AmfLoader . load ( { compact, fileName : 'streetlights' } ) ;
794+ } ) ;
795+
796+ describe ( 'Async APIs' , ( ) => {
797+ describe ( 'Subscribe' , ( ) => {
798+ beforeEach ( async ( ) => {
799+ element = await amfFixture ( amf ) ;
800+ await navigationSelectEndpointMethod ( element , 'smartylighting/streetlights/1/0/event/{streetlightId}/lighting/measured' , 'subscribe' ) ;
801+ await aTimeout ( 100 ) ;
802+ const item = documentationMethod ( element ) ;
803+ docShadowRoot = item . shadowRoot ;
804+ } ) ;
805+
806+ it ( 'should render URL' , async ( ) => {
807+ await waitUntil ( ( ) => Boolean ( docShadowRoot . querySelector ( 'api-url' ) ) ) ;
808+ const apiUrl = docShadowRoot . querySelector ( 'api-url' ) . shadowRoot ;
809+ assert . equal ( apiUrl . querySelector ( '.url-channel-value' ) . innerText . trim ( ) , 'Channel\nsmartylighting/streetlights/1/0/event/{streetlightId}/lighting/measured' ) ;
810+ assert . equal ( apiUrl . querySelector ( '.url-server-value' ) . innerText . trim ( ) , 'Server\nmqtt://api.streetlights.smartylighting.com:{port}' ) ;
811+ } ) ;
812+
813+ it ( 'should render description' , async ( ) => {
814+ await waitUntil ( ( ) => Boolean ( docShadowRoot . querySelector ( 'arc-marked' ) ) ) ;
815+ assert . equal ( docShadowRoot . querySelector ( 'arc-marked' ) . querySelector ( '.markdown-body' ) . innerText . trim ( ) , 'The topic on which measured values may be produced and consumed.' ) ;
816+ } ) ;
817+
818+ it ( 'should render methods' , async ( ) => {
819+ await waitUntil ( ( ) => Boolean ( docShadowRoot . querySelector ( '.request-documentation' ) ) ) ;
820+ const requestDocumentation = docShadowRoot . querySelector ( '.request-documentation' ) ;
821+ assert . exists ( requestDocumentation ) ;
822+ assert . exists ( requestDocumentation . querySelector ( '.security' ) ) ;
823+ assert . exists ( requestDocumentation . querySelector ( 'api-parameters-document' ) ) ;
824+ assert . exists ( requestDocumentation . querySelector ( 'api-headers-document' ) ) ;
825+ assert . exists ( requestDocumentation . querySelector ( 'api-body-document' ) ) ;
826+ } ) ;
827+ } ) ;
828+
829+ describe ( 'Publish' , ( ) => {
830+ beforeEach ( async ( ) => {
831+ await navigationSelectEndpointMethod ( element , 'smartylighting/streetlights/1/0/action/{streetlightId}/turn/on' , 'publish' ) ;
832+ await aTimeout ( 100 ) ;
833+ const item = documentationMethod ( element ) ;
834+ docShadowRoot = item . shadowRoot ;
835+ } ) ;
836+
837+ it ( 'should render URL' , async ( ) => {
838+ await waitUntil ( ( ) => Boolean ( docShadowRoot . querySelector ( 'api-url' ) ) ) ;
839+ const apiUrl = docShadowRoot . querySelector ( 'api-url' ) . shadowRoot ;
840+ assert . equal ( apiUrl . querySelector ( '.url-channel-value' ) . innerText . trim ( ) , 'Channelsmartylighting/streetlights/1/0/action/{streetlightId}/turn/on' ) ;
841+ assert . equal ( apiUrl . querySelector ( '.url-server-value' ) . innerText . trim ( ) , 'Servermqtt://api.streetlights.smartylighting.com:{port}' ) ;
842+ } ) ;
843+
844+ it ( 'should render methods' , async ( ) => {
845+ await waitUntil ( ( ) => Boolean ( docShadowRoot . querySelector ( '.request-documentation' ) ) ) ;
846+ const requestDocumentation = docShadowRoot . querySelector ( '.request-documentation' ) ;
847+ assert . exists ( requestDocumentation ) ;
848+ assert . exists ( requestDocumentation . querySelector ( '.security' ) ) ;
849+ assert . exists ( requestDocumentation . querySelector ( 'api-parameters-document' ) ) ;
850+ assert . exists ( requestDocumentation . querySelector ( 'api-headers-document' ) ) ;
851+ assert . exists ( requestDocumentation . querySelector ( 'api-body-document' ) ) ;
852+ } ) ;
853+ } ) ;
854+ } ) ;
855+ } ) ;
856+ } ) ;
780857} ) ;
0 commit comments