@@ -290,12 +290,15 @@ describe('DigitalExperienceSourceAdapter', () => {
290290 expect ( computeWebAppHashedName ( manifestFile , bundleDir ) ) . to . include ( 'sfdc_cms__webApplicationAsset' ) ;
291291 } ) ;
292292
293- it ( 'should use correct content type for manifest .json' , ( ) => {
293+ it ( 'should use correct content type for json files (only webapp .json is manifest) ' , ( ) => {
294294 const manifestFile = join ( 'path' , 'to' , 'digitalExperiences' , 'web_app' , 'dist2' , 'manifest.json' ) ;
295+ const webappJsonFile = join ( 'path' , 'to' , 'digitalExperiences' , 'web_app' , 'dist2' , 'webapp.json' ) ;
295296 const otherJsonFile = join ( 'path' , 'to' , 'digitalExperiences' , 'web_app' , 'dist2' , 'config.json' ) ;
296297 const bundleDir = join ( 'path' , 'to' , 'digitalExperiences' , 'web_app' , 'dist2' ) ;
297298
298- expect ( computeWebAppHashedName ( manifestFile , bundleDir ) ) . to . include ( 'sfdc_cms__webApplicationManifest' ) ;
299+ // Only webapp.json is treated as manifest, manifest.json is a regular asset
300+ expect ( computeWebAppHashedName ( webappJsonFile , bundleDir ) ) . to . include ( 'sfdc_cms__webApplicationManifest' ) ;
301+ expect ( computeWebAppHashedName ( manifestFile , bundleDir ) ) . to . include ( 'sfdc_cms__webApplicationAsset' ) ;
299302 expect ( computeWebAppHashedName ( otherJsonFile , bundleDir ) ) . to . include ( 'sfdc_cms__webApplicationAsset' ) ;
300303 } ) ;
301304 } ) ;
@@ -307,40 +310,29 @@ describe('DigitalExperienceSourceAdapter', () => {
307310
308311 const webappTree = VirtualTreeContainer . fromFilePaths ( [ WEBAPP_ICON_FILE , WEBAPP_404_FILE ] ) ;
309312
310- assert ( registry . types . digitalexperiencebundle . children ?. types . digitalexperience ) ;
311- const webappChildAdapter = new DigitalExperienceSourceAdapter (
312- registry . types . digitalexperiencebundle . children . types . digitalexperience ,
313+ // Use the bundle type adapter since web_app files are resolved as part of the bundle
314+ const webappBundleAdapter = new DigitalExperienceSourceAdapter (
315+ registry . types . digitalexperiencebundle ,
313316 registryAccess ,
314317 forceIgnore ,
315318 webappTree
316319 ) ;
317320
318- it ( 'should create child component with hashed name for nested file' , ( ) => {
319- const component = webappChildAdapter . getComponent ( WEBAPP_ICON_FILE ) ;
321+ it ( 'should resolve nested file to bundle component' , ( ) => {
322+ // For web_app bundles, getComponent returns the bundle for individual files
323+ // The hashed child names are computed during deploy/retrieve FileResponse generation
324+ const component = webappBundleAdapter . getComponent ( WEBAPP_ICON_FILE ) ;
320325 expect ( component ) . to . not . be . undefined ;
321- expect ( component ?. type . name ) . to . equal ( 'DigitalExperience' ) ;
322-
323- // Verify hashed name format - hash is computed from FULL path 'web_app/dist2/assets/icon.png'
324- const expectedHash = createHash ( 'sha256' ) . update ( 'web_app/dist2/assets/icon.png' , 'utf8' ) . digest ( 'hex' ) . substring ( 0 , 39 ) ;
325- expect ( component ?. fullName ) . to . equal ( `web_app/dist2.sfdc_cms__image/m${ expectedHash } ` ) ;
326-
327- // Verify parent
328- expect ( component ?. parent ?. type . name ) . to . equal ( 'DigitalExperienceBundle' ) ;
329- expect ( component ?. parent ?. fullName ) . to . equal ( 'web_app/dist2' ) ;
326+ expect ( component ?. type . name ) . to . equal ( 'DigitalExperienceBundle' ) ;
327+ expect ( component ?. fullName ) . to . equal ( 'web_app/dist2' ) ;
330328 } ) ;
331329
332- it ( 'should create child component with hashed name for root file' , ( ) => {
333- const component = webappChildAdapter . getComponent ( WEBAPP_404_FILE ) ;
330+ it ( 'should resolve root file to bundle component' , ( ) => {
331+ // For web_app bundles, getComponent returns the bundle for individual files
332+ const component = webappBundleAdapter . getComponent ( WEBAPP_404_FILE ) ;
334333 expect ( component ) . to . not . be . undefined ;
335- expect ( component ?. type . name ) . to . equal ( 'DigitalExperience' ) ;
336-
337- // Verify hashed name format - hash is computed from FULL path 'web_app/dist2/404.html'
338- const expectedHash = createHash ( 'sha256' ) . update ( 'web_app/dist2/404.html' , 'utf8' ) . digest ( 'hex' ) . substring ( 0 , 39 ) ;
339- expect ( component ?. fullName ) . to . equal ( `web_app/dist2.sfdc_cms__webApplicationAsset/m${ expectedHash } ` ) ;
340-
341- // Verify parent
342- expect ( component ?. parent ?. type . name ) . to . equal ( 'DigitalExperienceBundle' ) ;
343- expect ( component ?. parent ?. fullName ) . to . equal ( 'web_app/dist2' ) ;
334+ expect ( component ?. type . name ) . to . equal ( 'DigitalExperienceBundle' ) ;
335+ expect ( component ?. fullName ) . to . equal ( 'web_app/dist2' ) ;
344336 } ) ;
345337 } ) ;
346338} ) ;
0 commit comments