@@ -116,6 +116,65 @@ function hostedChangeRequest(body: string, additions = 1) {
116116 } ;
117117}
118118
119+ it . effect ( "reads maintainer edits and changes them through the update command" , ( ) =>
120+ Effect . gen ( function * ( ) {
121+ let enabled = true ;
122+ const provider = fakePullRequestProvider ( SourceControlProviderKind . make ( "github" ) , {
123+ getChangeRequest : ( ) =>
124+ Effect . succeed ( { ...hostedChangeRequest ( "Body" ) , maintainerCanModify : enabled } ) ,
125+ updateChangeRequest : ( input ) =>
126+ Effect . sync ( ( ) => {
127+ assert . strictEqual ( input . title , undefined ) ;
128+ assert . strictEqual ( input . body , undefined ) ;
129+ enabled = input . maintainerCanModify ! ;
130+ } ) ,
131+ } ) ;
132+ const service = yield * makeService ( {
133+ projects : [ project ( { id : "p1" , title : "web" , workspaceRoot : "/w" , repository : "acme/web" } ) ] ,
134+ providers : [
135+ {
136+ ...provider ,
137+ capabilities : {
138+ ...provider . capabilities ,
139+ edit : { changeRequest : true , comment : true , maintainerEdits : true } ,
140+ } ,
141+ } ,
142+ ] ,
143+ } ) ;
144+ const ref = { projectId : "p1" as ProjectId , repository : "acme/web" , number : 1 } ;
145+ assert . strictEqual ( ( yield * service . detail ( ref ) ) . maintainerCanModify , true ) ;
146+ yield * service . update ( { ...ref , maintainerCanModify : false } ) ;
147+ assert . strictEqual ( ( yield * service . detail ( ref ) ) . maintainerCanModify , false ) ;
148+ } ) ,
149+ ) ;
150+
151+ it . effect ( "refuses maintainer edits on a host without the capability" , ( ) =>
152+ Effect . gen ( function * ( ) {
153+ let writes = 0 ;
154+ const service = yield * makeService ( {
155+ projects : [ project ( { id : "p1" , title : "web" , workspaceRoot : "/w" , repository : "acme/web" } ) ] ,
156+ providers : [
157+ fakePullRequestProvider ( SourceControlProviderKind . make ( "github" ) , {
158+ updateChangeRequest : ( ) =>
159+ Effect . sync ( ( ) => {
160+ writes += 1 ;
161+ } ) ,
162+ } ) ,
163+ ] ,
164+ } ) ;
165+ const result = yield * service
166+ . update ( {
167+ projectId : "p1" as ProjectId ,
168+ repository : "acme/web" ,
169+ number : 1 ,
170+ maintainerCanModify : false ,
171+ } )
172+ . pipe ( Effect . flip ) ;
173+ assert . strictEqual ( result . _tag , "PullRequestOperationError" ) ;
174+ assert . strictEqual ( writes , 0 ) ;
175+ } ) ,
176+ ) ;
177+
119178it . effect ( "does not wait for an in-flight detail read to display a preview" , ( ) =>
120179 Effect . gen ( function * ( ) {
121180 const detailStarted = yield * Deferred . make < void > ( ) ;
0 commit comments