test(workitems): split t.Run() sub-tests into individual parent test functions

Summary

Refactors workitems_test.go to replace large table-driven t.Run() blocks with individual top-level TestXxx functions per scenario, as requested in #2273 (closed).

What changed

  • Split TestGetWorkItem (3 sub-tests) → 3 top-level functions:

    • TestGetWorkItem_SuccessfulResponse
    • TestGetWorkItem_EmptyNodesReturnsNotFound
    • TestGetWorkItem_NullProjectReturnsNotFound
  • Split TestListWorkItems (4 sub-tests) → 4 top-level functions:

    • TestListWorkItems_SuccessfulQueryWithAuthorUsername
    • TestListWorkItems_SuccessfulResponseWithSingleWorkItem
    • TestListWorkItems_EmptyResponseIsNotAnError
    • TestListWorkItems_AllOptionsFieldsIncludedInQuery
  • Split TestCreateWorkItem (6 sub-tests, 2 were duplicates) → 5 top-level functions:

    • TestCreateWorkItem_SuccessfulCreationWithTitleOnly
    • TestCreateWorkItem_SuccessfulCreationWithAllOptions
    • TestCreateWorkItem_MutationErrorReturnsError
    • TestCreateWorkItem_GraphQLErrorReturnsError
    • TestCreateWorkItem_NullWorkItemReturnsEmptyResponseError
  • Split TestUpdateWorkItem (5 sub-tests) → 5 top-level functions:

    • TestUpdateWorkItem_SuccessfulUpdateWithTitleOnly
    • TestUpdateWorkItem_SuccessfulUpdateWithAllOptions
    • TestUpdateWorkItem_WorkItemNotFoundDuringIDLookup
    • TestUpdateWorkItem_MutationReturnsNullWorkItem
    • TestUpdateWorkItem_MutationReturnsError
  • Split TestDeleteWorkItem (4 sub-tests) → 4 top-level functions:

    • TestDeleteWorkItem_SuccessfullyDeletesWorkItem
    • TestDeleteWorkItem_WorkItemNotFoundReturnsError
    • TestDeleteWorkItem_NamespaceNotFoundReturnsError
    • TestDeleteWorkItem_MutationReturnsErrors
  • Extracted shared helpers: setupGraphQLHandler (new) and writeResponse (new) reduce boilerplate in each test function while keeping setupWorkItemTypesHandler and assertQueryMatches as-is.

  • Added Gherkin-style comments: Every test function has // GIVEN, // WHEN, and // THEN inline comments per the project's test conventions.

  • All 29 test functions call t.Parallel().

Why

Individual top-level test functions are significantly easier to debug — failures point directly to the failing function. VSCode (and other editors) can discover and run individual tests without needing a prior test run to populate sub-test names.

Closes #2273 (closed)

Merge request reports

Loading