(t *testing.T)
| 467 | } |
| 468 | |
| 469 | func Test_GetIssue_FieldValues_Enriched(t *testing.T) { |
| 470 | // Verify the enriched field_values are populated via GraphQL when the issue has |
| 471 | // a node ID, and the raw REST issue_field_values stays cleared. |
| 472 | serverTool := IssueRead(translations.NullTranslationHelper) |
| 473 | |
| 474 | mockIssueWithFields := &github.Issue{ |
| 475 | Number: github.Ptr(99), |
| 476 | NodeID: github.Ptr("I_node_99"), |
| 477 | Title: github.Ptr("Issue with field values"), |
| 478 | Body: github.Ptr("body"), |
| 479 | State: github.Ptr("open"), |
| 480 | HTMLURL: github.Ptr("https://github.com/owner/repo/issues/99"), |
| 481 | User: &github.User{ |
| 482 | Login: github.Ptr("testuser"), |
| 483 | }, |
| 484 | IssueFieldValues: []*github.IssueFieldValue{ |
| 485 | { |
| 486 | IssueFieldID: 1001, |
| 487 | NodeID: "FV_node_1", |
| 488 | DataType: "single_select", |
| 489 | Value: "High", |
| 490 | }, |
| 491 | }, |
| 492 | } |
| 493 | |
| 494 | restClient := MockHTTPClientWithHandlers(map[string]http.HandlerFunc{ |
| 495 | GetReposIssuesByOwnerByRepoByIssueNumber: mockResponse(t, http.StatusOK, mockIssueWithFields), |
| 496 | }) |
| 497 | |
| 498 | gqlVars := map[string]any{ |
| 499 | "ids": []any{"I_node_99"}, |
| 500 | } |
| 501 | gqlResponse := githubv4mock.DataResponse(map[string]any{ |
| 502 | "nodes": []map[string]any{ |
| 503 | { |
| 504 | "id": "I_node_99", |
| 505 | "issueFieldValues": map[string]any{ |
| 506 | "nodes": []map[string]any{ |
| 507 | { |
| 508 | "__typename": "IssueFieldSingleSelectValue", |
| 509 | "field": map[string]any{"name": "priority"}, |
| 510 | "value": "P1", |
| 511 | }, |
| 512 | { |
| 513 | "__typename": "IssueFieldNumberValue", |
| 514 | "field": map[string]any{"name": "estimate"}, |
| 515 | "valueNumber": 2.5, |
| 516 | }, |
| 517 | }, |
| 518 | }, |
| 519 | }, |
| 520 | }, |
| 521 | }) |
| 522 | |
| 523 | const nodesQueryString = "query($ids:[ID!]!){nodes(ids: $ids){... on Issue{id,issueFieldValues(first: 25){nodes{__typename,... on IssueFieldDateValue{field{... on IssueFieldDate{name,fullDatabaseId},... on IssueFieldNumber{name,fullDatabaseId},... on IssueFieldSingleSelect{name,fullDatabaseId},... on IssueFieldText{name,fullDatabaseId}},value},... on IssueFieldNumberValue{field{... on IssueFieldDate{name,fullDatabaseId},... on IssueFieldNumber{name,fullDatabaseId},... on IssueFieldSingleSelect{name,fullDatabaseId},... on IssueFieldText{name,fullDatabaseId}},valueNumber: value},... on IssueFieldSingleSelectValue{field{... on IssueFieldDate{name,fullDatabaseId},... on IssueFieldNumber{name,fullDatabaseId},... on IssueFieldSingleSelect{name,fullDatabaseId},... on IssueFieldText{name,fullDatabaseId}},value},... on IssueFieldTextValue{field{... on IssueFieldDate{name,fullDatabaseId},... on IssueFieldNumber{name,fullDatabaseId},... on IssueFieldSingleSelect{name,fullDatabaseId},... on IssueFieldText{name,fullDatabaseId}},value}}}}}}" |
| 524 | matcher := githubv4mock.NewQueryMatcher(nodesQueryString, gqlVars, gqlResponse) |
| 525 | gqlClient := githubv4.NewClient(githubv4mock.NewMockedHTTPClient(matcher)) |
| 526 |
nothing calls this directly
no test coverage detected