diff --git a/api/export_pr_test.go b/api/export_pr_test.go index ec7b00249..db12ed0bf 100644 --- a/api/export_pr_test.go +++ b/api/export_pr_test.go @@ -197,6 +197,209 @@ func TestIssue_ExportData(t *testing.T) { ] } `), }, + { + name: "issue type", + fields: []string{"issueType"}, + inputJSON: heredoc.Doc(` + { "issueType": { + "id": "IT_1", + "name": "Bug", + "description": "Something is not working", + "color": "d73a4a" + } } + `), + outputJSON: heredoc.Doc(` + { + "issueType": { + "id": "IT_1", + "name": "Bug", + "description": "Something is not working", + "color": "d73a4a" + } + } + `), + }, + { + name: "issue type null", + fields: []string{"issueType"}, + inputJSON: `{}`, + outputJSON: heredoc.Doc(` + { "issueType": null } + `), + }, + { + name: "parent", + fields: []string{"parent"}, + inputJSON: heredoc.Doc(` + { "parent": { + "id": "I_100", + "number": 100, + "title": "Epic: Authentication overhaul", + "url": "https://github.com/OWNER/REPO/issues/100", + "state": "OPEN", + "repository": {"nameWithOwner": "OWNER/REPO"} + } } + `), + outputJSON: heredoc.Doc(` + { + "parent": { + "id": "I_100", + "number": 100, + "title": "Epic: Authentication overhaul", + "url": "https://github.com/OWNER/REPO/issues/100", + "state": "OPEN" + } + } + `), + }, + { + name: "parent null", + fields: []string{"parent"}, + inputJSON: `{}`, + outputJSON: heredoc.Doc(` + { "parent": null } + `), + }, + { + name: "sub-issues", + fields: []string{"subIssues"}, + inputJSON: heredoc.Doc(` + { "subIssues": { + "nodes": [ + { + "id": "I_101", + "number": 101, + "title": "Design auth module", + "url": "https://github.com/OWNER/REPO/issues/101", + "state": "CLOSED", + "repository": {"nameWithOwner": "OWNER/REPO"} + }, + { + "id": "I_102", + "number": 102, + "title": "Token refresh logic", + "url": "https://github.com/OWNER/REPO/issues/102", + "state": "OPEN", + "repository": {"nameWithOwner": "OWNER/REPO"} + } + ], + "totalCount": 2 + } } + `), + outputJSON: heredoc.Doc(` + { + "subIssues": { + "nodes": [ + { + "id": "I_101", + "number": 101, + "title": "Design auth module", + "url": "https://github.com/OWNER/REPO/issues/101", + "state": "CLOSED" + }, + { + "id": "I_102", + "number": 102, + "title": "Token refresh logic", + "url": "https://github.com/OWNER/REPO/issues/102", + "state": "OPEN" + } + ], + "totalCount": 2 + } + } + `), + }, + { + name: "sub-issues summary", + fields: []string{"subIssuesSummary"}, + inputJSON: heredoc.Doc(` + { "subIssuesSummary": { + "total": 4, + "completed": 1, + "percentCompleted": 25.0 + } } + `), + outputJSON: heredoc.Doc(` + { + "subIssuesSummary": { + "total": 4, + "completed": 1, + "percentCompleted": 25 + } + } + `), + }, + { + name: "blocked by", + fields: []string{"blockedBy"}, + inputJSON: heredoc.Doc(` + { "blockedBy": { + "nodes": [ + { + "id": "I_200", + "number": 200, + "title": "API rate limiting", + "url": "https://github.com/OWNER/REPO/issues/200", + "state": "OPEN", + "repository": {"nameWithOwner": "OWNER/REPO"} + } + ], + "totalCount": 1 + } } + `), + outputJSON: heredoc.Doc(` + { + "blockedBy": { + "nodes": [ + { + "id": "I_200", + "number": 200, + "title": "API rate limiting", + "url": "https://github.com/OWNER/REPO/issues/200", + "state": "OPEN" + } + ], + "totalCount": 1 + } + } + `), + }, + { + name: "blocking", + fields: []string{"blocking"}, + inputJSON: heredoc.Doc(` + { "blocking": { + "nodes": [ + { + "id": "I_300", + "number": 300, + "title": "Release v2.0", + "url": "https://github.com/OWNER/REPO/issues/300", + "state": "OPEN", + "repository": {"nameWithOwner": "OWNER/REPO"} + } + ], + "totalCount": 1 + } } + `), + outputJSON: heredoc.Doc(` + { + "blocking": { + "nodes": [ + { + "id": "I_300", + "number": 300, + "title": "Release v2.0", + "url": "https://github.com/OWNER/REPO/issues/300", + "state": "OPEN" + } + ], + "totalCount": 1 + } + } + `), + }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) {