@@ -10,6 +10,7 @@ import (
1010
1111 "github.com/cli/cli/v2/api"
1212 fd "github.com/cli/cli/v2/internal/featuredetection"
13+ "github.com/cli/cli/v2/internal/gh"
1314 "github.com/cli/cli/v2/internal/ghrepo"
1415 shared "github.com/cli/cli/v2/pkg/cmd/pr/shared"
1516 "github.com/cli/cli/v2/pkg/cmdutil"
@@ -894,6 +895,67 @@ func Test_editRun(t *testing.T) {
894895 },
895896 stdout : "https://github.com/OWNER/REPO/pull/123\n " ,
896897 },
898+ {
899+ name : "non-interactive projects v1 unsupported doesn't fetch v1 metadata" ,
900+ input : & EditOptions {
901+ Detector : & fd.DisabledDetectorMock {},
902+ SelectorArg : "123" ,
903+ Finder : shared .NewMockFinder ("123" , & api.PullRequest {
904+ URL : "https://github.com/OWNER/REPO/pull/123" ,
905+ }, ghrepo .New ("OWNER" , "REPO" )),
906+ Interactive : false ,
907+ Editable : shared.Editable {
908+ Projects : shared.EditableProjects {
909+ EditableSlice : shared.EditableSlice {
910+ Add : []string {"CleanupV2" },
911+ Remove : []string {"RoadmapV2" },
912+ Edited : true ,
913+ },
914+ },
915+ },
916+ Fetcher : testFetcher {},
917+ },
918+ httpStubs : func (t * testing.T , reg * httpmock.Registry ) {
919+ // Ensure v1 project queries are NOT made.
920+ reg .Exclude (t , httpmock .GraphQL (`query RepositoryProjectList\b` ))
921+ reg .Exclude (t , httpmock .GraphQL (`query OrganizationProjectList\b` ))
922+ // Provide only v2 project metadata queries.
923+ reg .Register (
924+ httpmock .GraphQL (`query RepositoryProjectV2List\b` ),
925+ httpmock .StringResponse (`
926+ { "data": { "repository": { "projectsV2": {
927+ "nodes": [
928+ { "title": "CleanupV2", "id": "CLEANUPV2ID" },
929+ { "title": "RoadmapV2", "id": "ROADMAPV2ID" }
930+ ],
931+ "pageInfo": { "hasNextPage": false }
932+ } } } }
933+ ` ))
934+ reg .Register (
935+ httpmock .GraphQL (`query OrganizationProjectV2List\b` ),
936+ httpmock .StringResponse (`
937+ { "data": { "organization": { "projectsV2": {
938+ "nodes": [
939+ { "title": "TriageV2", "id": "TRIAGEV2ID" }
940+ ],
941+ "pageInfo": { "hasNextPage": false }
942+ } } } }
943+ ` ))
944+ reg .Register (
945+ httpmock .GraphQL (`query UserProjectV2List\b` ),
946+ httpmock .StringResponse (`
947+ { "data": { "viewer": { "projectsV2": {
948+ "nodes": [
949+ { "title": "MonalisaV2", "id": "MONALISAV2ID" }
950+ ],
951+ "pageInfo": { "hasNextPage": false }
952+ } } } }
953+ ` ))
954+ mockProjectV2ItemUpdate (reg )
955+ mockPullRequestUpdate (reg )
956+ },
957+ stdout : "https://github.com/OWNER/REPO/pull/123\n " ,
958+ },
897959 }
898960 for _ , tt := range tests {
899961 t .Run (tt .name , func (t * testing.T ) {
@@ -1102,8 +1164,8 @@ func mockProjectV2ItemUpdate(reg *httpmock.Registry) {
11021164
11031165type testFetcher struct {}
11041166
1105- func (f testFetcher ) EditableOptionsFetch (client * api.Client , repo ghrepo.Interface , opts * shared.Editable ) error {
1106- return shared .FetchOptions (client , repo , opts )
1167+ func (f testFetcher ) EditableOptionsFetch (client * api.Client , repo ghrepo.Interface , opts * shared.Editable , projectsV1Support gh. ProjectsV1Support ) error {
1168+ return shared .FetchOptions (client , repo , opts , projectsV1Support )
11071169}
11081170
11091171type testSurveyor struct {
0 commit comments