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