| 2114 | } |
| 2115 | |
| 2116 | func TestApiActorsSupported(t *testing.T) { |
| 2117 | t.Run("when actors are assignable, query includes assignedActors", func(t *testing.T) { |
| 2118 | ios, _, _, _ := iostreams.Test() |
| 2119 | |
| 2120 | reg := &httpmock.Registry{} |
| 2121 | reg.Register( |
| 2122 | httpmock.GraphQL(`assignedActors`), |
| 2123 | // Simulate a GraphQL error to early exit the test. |
| 2124 | httpmock.StatusStringResponse(500, ""), |
| 2125 | ) |
| 2126 | |
| 2127 | _, cmdTeardown := run.Stub() |
| 2128 | defer cmdTeardown(t) |
| 2129 | |
| 2130 | // Ignore the error because we don't care. |
| 2131 | _ = editRun(&EditOptions{ |
| 2132 | IO: ios, |
| 2133 | HttpClient: func() (*http.Client, error) { |
| 2134 | return &http.Client{Transport: reg}, nil |
| 2135 | }, |
| 2136 | BaseRepo: func() (ghrepo.Interface, error) { |
| 2137 | return ghrepo.New("OWNER", "REPO"), nil |
| 2138 | }, |
| 2139 | Detector: &fd.EnabledDetectorMock{}, |
| 2140 | IssueNumbers: []int{123}, |
| 2141 | Editable: prShared.Editable{ |
| 2142 | Assignees: prShared.EditableAssignees{ |
| 2143 | EditableSlice: prShared.EditableSlice{ |
| 2144 | Add: []string{"monalisa", "octocat"}, |
| 2145 | Edited: true, |
| 2146 | }, |
| 2147 | }, |
| 2148 | }, |
| 2149 | }) |
| 2150 | |
| 2151 | reg.Verify(t) |
| 2152 | }) |
| 2153 | |
| 2154 | t.Run("when actors are not assignable, query includes assignees instead", func(t *testing.T) { |
| 2155 | ios, _, _, _ := iostreams.Test() |
| 2156 | |
| 2157 | reg := &httpmock.Registry{} |
| 2158 | // This test should NOT include assignedActors in the query |
| 2159 | reg.Exclude(t, httpmock.GraphQL(`assignedActors`)) |
| 2160 | // It should include the regular assignees field |
| 2161 | reg.Register( |
| 2162 | httpmock.GraphQL(`assignees`), |
| 2163 | // Simulate a GraphQL error to early exit the test. |
| 2164 | httpmock.StatusStringResponse(500, ""), |
| 2165 | ) |
| 2166 | |
| 2167 | _, cmdTeardown := run.Stub() |
| 2168 | defer cmdTeardown(t) |
| 2169 | |
| 2170 | // Ignore the error because we're not really interested in it. |
| 2171 | _ = editRun(&EditOptions{ |
| 2172 | IO: ios, |
| 2173 | HttpClient: func() (*http.Client, error) { |