@@ -683,6 +683,24 @@ fn route_buffered_response(
683683 route_result_to_fastly_response ( settings, services, & partner_registry, route_result)
684684}
685685
686+ fn route_with_settings (
687+ settings : & Settings ,
688+ req : Request ,
689+ expect_message : & str ,
690+ ) -> fastly:: Response {
691+ let ( orchestrator, integration_registry) = build_route_stack ( settings) ;
692+ let services = test_runtime_services ( & req) ;
693+
694+ route_buffered_response (
695+ settings,
696+ & orchestrator,
697+ & integration_registry,
698+ & services,
699+ req,
700+ expect_message,
701+ )
702+ }
703+
686704fn valid_banner_ad_unit_body ( ) -> Vec < u8 > {
687705 serde_json:: to_vec ( & json ! ( {
688706 "adUnits" : [
@@ -699,6 +717,94 @@ fn valid_banner_ad_unit_body() -> Vec<u8> {
699717 . expect ( "should serialize valid auction route test body" )
700718}
701719
720+ #[ test]
721+ fn static_tsjs_route_serves_unified_bundle ( ) {
722+ let settings = create_test_settings ( ) ;
723+ let req = Request :: get ( "https://test.com/static/tsjs=tsjs-unified.min.js" ) ;
724+
725+ let mut response = route_with_settings ( & settings, req, "should route static tsjs request" ) ;
726+
727+ assert_eq ! (
728+ response. get_status( ) ,
729+ StatusCode :: OK ,
730+ "should serve the unified static bundle"
731+ ) ;
732+ assert_eq ! (
733+ response. get_header_str( header:: CONTENT_TYPE ) ,
734+ Some ( "application/javascript; charset=utf-8" ) ,
735+ "should serve the unified bundle as JavaScript"
736+ ) ;
737+ assert ! (
738+ response. take_body_str( ) . contains( "requestAds" ) ,
739+ "should serve unified bundle content with the core requestAds API"
740+ ) ;
741+ }
742+
743+ #[ test]
744+ fn static_tsjs_route_returns_not_found_for_unknown_tsjs_bundle ( ) {
745+ let settings = create_test_settings ( ) ;
746+ let req = Request :: get ( "https://test.com/static/tsjs=tsjs-doesnotexist.min.js" ) ;
747+
748+ let response = route_with_settings ( & settings, req, "should route static tsjs request" ) ;
749+
750+ assert_eq ! (
751+ response. get_status( ) ,
752+ StatusCode :: NOT_FOUND ,
753+ "should let the static tsjs branch own unknown bundle paths"
754+ ) ;
755+ }
756+
757+ #[ test]
758+ fn unknown_route_falls_back_to_publisher_proxy_path ( ) {
759+ let settings = create_test_settings ( ) ;
760+ let ( orchestrator, integration_registry) = build_route_stack ( & settings) ;
761+
762+ let req = Request :: get ( "https://test.com/articles/example" ) ;
763+ let http_client = Arc :: new ( RecordingHttpClient :: new ( StatusCode :: BAD_GATEWAY ) ) ;
764+ let services = test_runtime_services_with_http_client (
765+ & req,
766+ Arc :: new ( FixedBackend ) ,
767+ Arc :: clone ( & http_client) as Arc < dyn PlatformHttpClient > ,
768+ ) ;
769+
770+ let response = route_buffered_response (
771+ & settings,
772+ & orchestrator,
773+ & integration_registry,
774+ & services,
775+ req,
776+ "should route publisher fallback" ,
777+ ) ;
778+
779+ assert_eq ! (
780+ response. get_status( ) ,
781+ StatusCode :: BAD_GATEWAY ,
782+ "should return the publisher origin response through fallback routing"
783+ ) ;
784+ let calls = http_client
785+ . calls
786+ . lock ( )
787+ . expect ( "should lock recorded calls" ) ;
788+ assert_eq ! (
789+ calls. len( ) ,
790+ 1 ,
791+ "should send exactly one publisher fallback request"
792+ ) ;
793+ assert_eq ! (
794+ calls[ 0 ] . method,
795+ Method :: GET ,
796+ "should preserve the fallback request method"
797+ ) ;
798+ assert_eq ! (
799+ calls[ 0 ] . backend_name, "https-origin.test-publisher.com" ,
800+ "should dispatch to the publisher origin backend"
801+ ) ;
802+ assert_eq ! (
803+ calls[ 0 ] . uri, "https://origin.test-publisher.com/articles/example" ,
804+ "should send the fallback request to the publisher origin"
805+ ) ;
806+ }
807+
702808#[ test]
703809fn datadome_challenge_short_circuits_before_publisher_origin ( ) {
704810 let settings = create_datadome_auction_test_settings ( "[]" ) ;
0 commit comments