@@ -1992,4 +1992,109 @@ func TestGranularSetIssueFields(t *testing.T) {
19921992 // query does not require the feature flag.
19931993 assert .Equal (t , "update_issue_suggestions" , spy .captured .Get (headers .GraphQLFeaturesHeader ))
19941994 })
1995+
1996+ t .Run ("sends rationale and confidence as intent object when feature flag enabled" , func (t * testing.T ) {
1997+ confidence := "high"
1998+ suggestTrue := githubv4 .Boolean (true )
1999+ matchers := []githubv4mock.Matcher {
2000+ githubv4mock .NewQueryMatcher (
2001+ struct {
2002+ Repository struct {
2003+ Issue struct {
2004+ ID githubv4.ID
2005+ } `graphql:"issue(number: $issueNumber)"`
2006+ } `graphql:"repository(owner: $owner, name: $repo)"`
2007+ }{},
2008+ map [string ]any {
2009+ "owner" : githubv4 .String ("owner" ),
2010+ "repo" : githubv4 .String ("repo" ),
2011+ "issueNumber" : githubv4 .Int (5 ),
2012+ },
2013+ githubv4mock .DataResponse (map [string ]any {
2014+ "repository" : map [string ]any {
2015+ "issue" : map [string ]any {"id" : "ISSUE_123" },
2016+ },
2017+ }),
2018+ ),
2019+ githubv4mock .NewMutationMatcher (
2020+ struct {
2021+ SetIssueFieldValue struct {
2022+ Issue struct {
2023+ ID githubv4.ID
2024+ Number githubv4.Int
2025+ URL githubv4.String
2026+ }
2027+ IssueFieldValues []struct {
2028+ TextValue struct {
2029+ Value string
2030+ } `graphql:"... on IssueFieldTextValue"`
2031+ SingleSelectValue struct {
2032+ Name string
2033+ } `graphql:"... on IssueFieldSingleSelectValue"`
2034+ DateValue struct {
2035+ Value string
2036+ } `graphql:"... on IssueFieldDateValue"`
2037+ NumberValue struct {
2038+ Value float64
2039+ } `graphql:"... on IssueFieldNumberValue"`
2040+ }
2041+ } `graphql:"setIssueFieldValue(input: $input)"`
2042+ }{},
2043+ SetIssueFieldValueInput {
2044+ IssueID : githubv4 .ID ("ISSUE_123" ),
2045+ IssueFields : []IssueFieldCreateOrUpdateInput {
2046+ {
2047+ FieldID : githubv4 .ID ("FIELD_1" ),
2048+ TextValue : githubv4 .NewString (githubv4 .String ("hello" )),
2049+ // rationale and confidence are nested under intent,
2050+ // while suggest stays a flat field.
2051+ Intent : & IssueUpdateIntentInput {
2052+ Rationale : githubv4 .NewString (githubv4 .String ("Reflects the reported severity" )),
2053+ Confidence : & confidence ,
2054+ },
2055+ Suggest : & suggestTrue ,
2056+ },
2057+ },
2058+ },
2059+ nil ,
2060+ githubv4mock .DataResponse (map [string ]any {
2061+ "setIssueFieldValue" : map [string ]any {
2062+ "issue" : map [string ]any {
2063+ "id" : "ISSUE_123" ,
2064+ "number" : 5 ,
2065+ "url" : "https://github.com/owner/repo/issues/5" ,
2066+ },
2067+ },
2068+ }),
2069+ ),
2070+ }
2071+
2072+ gqlClient := githubv4 .NewClient (githubv4mock .NewMockedHTTPClient (matchers ... ))
2073+ deps := BaseDeps {
2074+ GQLClient : gqlClient ,
2075+ featureChecker : func (_ context.Context , flag string ) (bool , error ) {
2076+ return flag == FeatureFlagIssueUpdateIntent , nil
2077+ },
2078+ }
2079+ serverTool := GranularSetIssueFields (translations .NullTranslationHelper )
2080+ handler := serverTool .Handler (deps )
2081+
2082+ request := createMCPRequest (map [string ]any {
2083+ "owner" : "owner" ,
2084+ "repo" : "repo" ,
2085+ "issue_number" : float64 (5 ),
2086+ "fields" : []any {
2087+ map [string ]any {
2088+ "field_id" : "FIELD_1" ,
2089+ "text_value" : "hello" ,
2090+ "rationale" : "Reflects the reported severity" ,
2091+ "confidence" : "high" ,
2092+ "is_suggestion" : true ,
2093+ },
2094+ },
2095+ })
2096+ result , err := handler (ContextWithDeps (context .Background (), deps ), & request )
2097+ require .NoError (t , err )
2098+ assert .False (t , result .IsError , getTextResult (t , result ).Text )
2099+ })
19952100}
0 commit comments