@@ -27,6 +27,7 @@ import type {
2727import { DEFAULT_SERVER_SETTINGS } from "@t3tools/contracts/settings" ;
2828import { parseChangeRequestUrl } from "@t3tools/shared/changeRequestUrl" ;
2929import type { ServerSettings } from "@t3tools/contracts" ;
30+ import { withHostOverrideSettingsFailure } from "../testUtils/hostOverrideSettingsFailure.ts" ;
3031import * as ServerSettingsService from "../serverSettings.ts" ;
3132import { makeSettingsChanges } from "../testUtils/settingsChanges.ts" ;
3233import { PullRequestOperationError } from "@t3tools/contracts" ;
@@ -800,6 +801,67 @@ it.effect("uses the configured provider's repository selector for a mapped Azure
800801 } ) ,
801802) ;
802803
804+ it . effect (
805+ "uses hostname heuristics and warns for workspace and linked PRs when settings fail" ,
806+ ( ) =>
807+ withHostOverrideSettingsFailure ( ( settingsService , warnings ) =>
808+ Effect . gen ( function * ( ) {
809+ const service = yield * makeService ( {
810+ settingsService,
811+ projects : [
812+ project ( { id : "p1" , title : "web" , workspaceRoot : "/repo" , repository : "team/repo" } ) ,
813+ ] ,
814+ providers : [
815+ fakeProvider ( SourceControlProviderKind . make ( "github" ) , {
816+ getChangeRequest : ( { number } ) =>
817+ Effect . succeed ( { ...hostedChangeRequest ( "PR body" ) , number } ) ,
818+ } ) ,
819+ ] ,
820+ } ) ;
821+ warnings . length = 0 ;
822+ const listed = yield * service . list ( { state : "open" , involvement : "all" } ) ;
823+ assert . isAbove ( listed . providers . length , 0 ) ;
824+ assert . isAbove ( warnings . length , 0 ) ;
825+ warnings . length = 0 ;
826+ const summary = yield * service . summary (
827+ {
828+ projectId : "p1" as ProjectId ,
829+ host : "github.com" ,
830+ repository : "other/repo" ,
831+ number : 42 ,
832+ } ,
833+ { recoverTransientFailure : false } ,
834+ ) ;
835+ assert . strictEqual ( summary . repository , "other/repo" ) ;
836+ assert . isAbove ( warnings . length , 0 ) ;
837+
838+ // No checkout on the requested host exercises the direct-link fallback read.
839+ const linked = yield * makeService ( {
840+ settingsService,
841+ projects : [ project ( { id : "inbox" , title : "Inbox" , workspaceRoot : "/inbox" } ) ] ,
842+ providers : [
843+ fakeProvider ( SourceControlProviderKind . make ( "github" ) , {
844+ getChangeRequest : ( { number } ) =>
845+ Effect . succeed ( { ...hostedChangeRequest ( "PR body" ) , number } ) ,
846+ } ) ,
847+ ] ,
848+ } ) ;
849+ warnings . length = 0 ;
850+ const linkedSummary = yield * linked . summary (
851+ {
852+ projectId : "inbox" as ProjectId ,
853+ host : "github.com" ,
854+ repository : "team/repo" ,
855+ number : 42 ,
856+ } ,
857+ { recoverTransientFailure : false } ,
858+ ) ;
859+ assert . strictEqual ( linkedSummary . repository , "team/repo" ) ;
860+ assert . isAtLeast ( warnings . length , 2 ) ;
861+ } ) ,
862+ ) ,
863+ ) ;
864+
803865function makeService ( input : {
804866 readonly settings ?: ServerSettings ;
805867 readonly settingsService ?: ServerSettingsService . ServerSettingsService [ "Service" ] ;
0 commit comments