@@ -363,5 +363,78 @@ describe('WebApplicationsSourceAdapter', () => {
363363 ) ;
364364 expect ( a . getComponent ( APP_PATH ) ) . to . deep . equal ( expected ) ;
365365 } ) ;
366+
367+ it ( 'should validate all rewrites when multiple are present' , ( ) => {
368+ const config = {
369+ outputDir : 'dist' ,
370+ routing : {
371+ trailingSlash : 'auto' ,
372+ fallback : '/index.html' ,
373+ rewrites : [
374+ { route : '/api/*' , rewrite : '/api.html' } ,
375+ { route : '/docs/*' , rewrite : '/docs.html' } ,
376+ { route : '/admin' , rewrite : '/admin.html' } ,
377+ ] ,
378+ } ,
379+ } ;
380+ const distDir : VirtualDirectory = {
381+ dirPath : DIST_PATH ,
382+ children : [
383+ { name : 'index.html' , data : Buffer . from ( '<html>test</html>' ) } ,
384+ { name : 'api.html' , data : Buffer . from ( '<html>api</html>' ) } ,
385+ { name : 'docs.html' , data : Buffer . from ( '<html>docs</html>' ) } ,
386+ { name : 'admin.html' , data : Buffer . from ( '<html>admin</html>' ) } ,
387+ ] ,
388+ } ;
389+ const a = adapterWith ( config , [ distDir ] ) ;
390+ const t = new VirtualTreeContainer ( [
391+ {
392+ dirPath : APP_PATH ,
393+ children : [
394+ `${ APP_NAME } .webapplication-meta.xml` ,
395+ { name : 'webapplication.json' , data : Buffer . from ( JSON . stringify ( config ) ) } ,
396+ ] ,
397+ } ,
398+ distDir ,
399+ ] ) ;
400+ const expected = new SourceComponent (
401+ { name : APP_NAME , type : registry . types . webapplication , content : APP_PATH , xml : META_FILE } ,
402+ t ,
403+ forceIgnore
404+ ) ;
405+ expect ( a . getComponent ( APP_PATH ) ) . to . deep . equal ( expected ) ;
406+ } ) ;
407+
408+ it ( 'should throw when one of multiple rewrites is missing' , ( ) => {
409+ const config = {
410+ outputDir : 'dist' ,
411+ routing : {
412+ trailingSlash : 'never' ,
413+ fallback : '/index.html' ,
414+ rewrites : [
415+ { route : '/api/*' , rewrite : '/api.html' } ,
416+ { route : '/docs/*' , rewrite : '/missing-docs.html' } ,
417+ { route : '/admin' , rewrite : '/admin.html' } ,
418+ ] ,
419+ } ,
420+ } ;
421+ const distDir : VirtualDirectory = {
422+ dirPath : DIST_PATH ,
423+ children : [
424+ { name : 'index.html' , data : Buffer . from ( '<html>test</html>' ) } ,
425+ { name : 'api.html' , data : Buffer . from ( '<html>api</html>' ) } ,
426+ { name : 'admin.html' , data : Buffer . from ( '<html>admin</html>' ) } ,
427+ ] ,
428+ } ;
429+ const a = adapterWith ( config , [ distDir ] ) ;
430+ assert . throws (
431+ ( ) => a . getComponent ( APP_PATH ) ,
432+ SfError ,
433+ messages . getMessage ( 'error_expected_source_files' , [
434+ join ( DIST_PATH , 'missing-docs.html' ) ,
435+ registry . types . webapplication . name ,
436+ ] )
437+ ) ;
438+ } ) ;
366439 } ) ;
367440} ) ;
0 commit comments