@@ -3,6 +3,7 @@ import MockAdapter from 'axios-mock-adapter';
33import path from 'path' ;
44import fs from 'fs' ;
55import { jest } from '@jest/globals' ;
6+ import { PassThrough } from 'stream' ;
67import Server from '../../index.js' ;
78import ThemeConfig from '../../../lib/theme-config.js' ;
89import { readFromStream } from '../../../lib/utils/asyncUtils.js' ;
@@ -242,7 +243,7 @@ describe('Renderer Plugin', () => {
242243 describe ( 'when the storefront server response is Success and content-type is "image"' , ( ) => {
243244 const browserRequest = {
244245 method : 'get' ,
245- url : '/content /cat_and_dog.jpeg' ,
246+ url : '/images /cat_and_dog.jpeg' ,
246247 } ;
247248 const testImage = fs . readFileSync ( './test/assets/cat_and_dog.jpeg' ) ;
248249 const storefrontResponseHeaders = {
@@ -275,4 +276,21 @@ describe('Renderer Plugin', () => {
275276 expect ( localServerResponse . rawPayload ) . toEqual ( testImage ) ;
276277 } ) ;
277278 } ) ;
279+
280+ describe ( 'WebDav /content requests' , ( ) => {
281+ it ( 'should return plain text response for /content path' , async ( ) => {
282+ const browserRequest = {
283+ method : 'GET' ,
284+ url : '/content/test.txt' ,
285+ } ;
286+ const testString = 'webdav test content' ;
287+ // Simulate a stream response for /content path
288+ const stream = new PassThrough ( ) ;
289+ stream . end ( testString ) ;
290+ axiosMock . onGet ( ) . reply ( 200 , stream , { 'content-type' : 'text/plain' } ) ;
291+ const localServerResponse = await server . inject ( browserRequest ) ;
292+ expect ( localServerResponse . statusCode ) . toEqual ( 200 ) ;
293+ expect ( localServerResponse . payload ) . toEqual ( testString ) ;
294+ } ) ;
295+ } ) ;
278296} ) ;
0 commit comments