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