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