@@ -71,7 +71,6 @@ describe("Fastify RapiDoc", () => {
7171 builder . build ( ) ,
7272 ) ;
7373 RapidocModule . setup ( RAPIDOC_RELATIVE_URL , app , swaggerDocument , {
74- // to showcase that in new implementation u can use custom swagger-ui path. Useful when using e.g. webpack
7574 customRapidocAssetsPath : path . resolve ( `./node_modules/rapidoc/dist` ) ,
7675 } ) ;
7776
@@ -83,6 +82,16 @@ describe("Fastify RapiDoc", () => {
8382 await app . close ( ) ;
8483 } ) ;
8584
85+ it ( "should return the same HTML on every consecutive request" , async ( ) => {
86+ const response1 : Response = await request ( app . getHttpServer ( ) ) . get (
87+ RAPIDOC_RELATIVE_URL ,
88+ ) ;
89+ const response2 : Response = await request ( app . getHttpServer ( ) ) . get (
90+ RAPIDOC_RELATIVE_URL ,
91+ ) ;
92+ expect ( response1 . text ) . toEqual ( response2 . text ) ;
93+ } ) ;
94+
8695 it ( "content type of served json document should be valid" , async ( ) => {
8796 const response = await request ( app . getHttpServer ( ) ) . get (
8897 `${ RAPIDOC_RELATIVE_URL } /openapi.json` ,
@@ -102,6 +111,44 @@ describe("Fastify RapiDoc", () => {
102111 expect ( response . type ) . toEqual ( "application/javascript" ) ;
103112 expect ( response . status ) . toEqual ( 200 ) ;
104113 } ) ;
114+
115+ it ( "should serve favicon" , async ( ) => {
116+ const response = await request ( app . getHttpServer ( ) ) . get (
117+ `${ RAPIDOC_RELATIVE_URL } /favicon.png` ,
118+ ) ;
119+
120+ expect ( response . status ) . toEqual ( 200 ) ;
121+ expect ( response . type ) . toEqual ( "image/png" ) ;
122+ } ) ;
123+ } ) ;
124+
125+ describe ( "served oauth receiver" , ( ) => {
126+ const RAPIDOC_RELATIVE_URL = "/rapidoc" ;
127+
128+ beforeEach ( async ( ) => {
129+ const swaggerDocument = SwaggerModule . createDocument (
130+ app ,
131+ builder . build ( ) ,
132+ ) ;
133+ RapidocModule . setup ( RAPIDOC_RELATIVE_URL , app , swaggerDocument ) ;
134+
135+ await app . init ( ) ;
136+ await app . getHttpAdapter ( ) . getInstance ( ) . ready ( ) ;
137+ } ) ;
138+
139+ afterEach ( async ( ) => {
140+ await app . close ( ) ;
141+ } ) ;
142+
143+ it ( "should serve oauth receiver" , async ( ) => {
144+ const response = await request ( app . getHttpServer ( ) ) . get (
145+ `${ RAPIDOC_RELATIVE_URL } /oauth-receiver.html` ,
146+ ) ;
147+
148+ expect ( response . status ) . toEqual ( 200 ) ;
149+ expect ( response . type ) . toEqual ( "text/html" ) ;
150+ expect ( response . text ) . toContain ( "<oauth-receiver />" ) ;
151+ } ) ;
105152 } ) ;
106153
107154 describe ( "custom documents endpoints" , ( ) => {
@@ -223,6 +270,7 @@ describe("Fastify RapiDoc", () => {
223270 const CUSTOM_SITE_TITLE = "Foo" ;
224271 const CUSTOM_CSS_URL = "/foo.css" ;
225272 const CUSTOM_URL = "/custom" ;
273+ const CUSTOM_LOGO = "/logo.png" ;
226274
227275 beforeEach ( async ( ) => {
228276 const swaggerDocument = SwaggerModule . createDocument (
@@ -237,13 +285,18 @@ describe("Fastify RapiDoc", () => {
237285 customFavIcon : CUSTOM_FAVICON ,
238286 customSiteTitle : CUSTOM_SITE_TITLE ,
239287 customCssUrl : CUSTOM_CSS_URL ,
288+ customLogo : CUSTOM_LOGO ,
240289 patchDocumentOnRequest : ( req , res , document ) => ( {
241290 ...document ,
242291 info : {
243292 ...document . info ,
244293 description : ( req as Record < string , any > ) . query . description ,
245294 } ,
246295 } ) ,
296+ rapidocOptions : {
297+ showHeader : false ,
298+ apiKeyName : "x-api-key" ,
299+ } ,
247300 } ) ;
248301
249302 await app . init ( ) ;
@@ -296,6 +349,15 @@ describe("Fastify RapiDoc", () => {
296349 ) ;
297350 } ) ;
298351
352+ it ( "should include the custom logo" , async ( ) => {
353+ const response : Response = await request ( app . getHttpServer ( ) ) . get (
354+ CUSTOM_URL ,
355+ ) ;
356+ expect ( response . text ) . toContain (
357+ `<img slot="logo" src='${ CUSTOM_LOGO } ' style="height:36px;width:36px;margin-left:5px" />` ,
358+ ) ;
359+ } ) ;
360+
299361 it ( "should patch the OpenAPI document" , async function ( ) {
300362 const response : Response = await request ( app . getHttpServer ( ) ) . get (
301363 `${ CUSTOM_URL } ?description=Custom%20Swagger%20description%20passed%20by%20query%20param` ,
0 commit comments