Verified Commit e9d1c498 authored by Radek Antoniuk's avatar Radek Antoniuk Committed by GitLab
Browse files

fix(workitems): send status widget when creating a work item

Changelog: Improvements
parent ac110524
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -978,6 +978,9 @@ type CreateWorkItemOptions struct {

	// Color of the work item, represented as a hex code or named color. Example: "#fefefe"
	Color *string

	// Global ID of the work item status.
	Status *WorkItemStatusID
}

// CreateWorkItemOptionsLinkedItems represents linked items to be added to a work item.
@@ -1011,6 +1014,7 @@ type workItemCreateInputGQL struct {
	HealthStatusWidget    *workItemWidgetHealthStatusInputGQL      `json:"healthStatusWidget,omitempty"`
	IterationWidget       *workItemWidgetIterationInputGQL         `json:"iterationWidget,omitempty"`
	ColorWidget           *workItemWidgetColorInputGQL             `json:"colorWidget,omitempty"`
	StatusWidget          *workItemWidgetStatusInputGQL            `json:"statusWidget,omitempty"`
}

// workItemWidgetAssigneesInputGQL represents the assignees widget input.
@@ -1204,6 +1208,12 @@ func (opt *CreateWorkItemOptions) wrap(namespacePath string, workItemTypeID Work
		}
	}

	if opt.Status != nil {
		input.StatusWidget = &workItemWidgetStatusInputGQL{
			Status: opt.Status,
		}
	}

	return input
}

+6 −2
Original line number Diff line number Diff line
@@ -760,6 +760,9 @@ func TestCreateWorkItem_SuccessfulCreationWithAllOptions(t *testing.T) {
		"colorWidget": map[string]any{
			"color": "#FF0000",
		},
		"statusWidget": map[string]any{
			"status": "gid://gitlab/WorkItems::Statuses::SystemDefined::Status/2",
		},
	}

	// GIVEN a CreateWorkItem mutation request with all options set
@@ -806,7 +809,7 @@ func TestCreateWorkItem_SuccessfulCreationWithAllOptions(t *testing.T) {
			          },
			          "status": {
			            "status": {
			              "name": "New"
			              "name": "In Progress"
			            }
			          }
			        }
@@ -841,6 +844,7 @@ func TestCreateWorkItem_SuccessfulCreationWithAllOptions(t *testing.T) {
		HealthStatus: Ptr("onTrack"),
		IterationID:  Ptr(int64(567)),
		Color:        Ptr("#FF0000"),
		Status:       Ptr(WorkItemStatusInProgress),
	}

	// WHEN CreateWorkItem is called with all options
@@ -857,7 +861,7 @@ func TestCreateWorkItem_SuccessfulCreationWithAllOptions(t *testing.T) {
		IID:         41,
		Type:        "Issue",
		State:       "OPEN",
		Status:      Ptr("New"),
		Status:      Ptr("In Progress"),
		Title:       "New Issue",
		Description: "This is a detailed description",
		CreatedAt:   Ptr(time.Date(2026, time.February, 6, 10, 0, 0, 0, time.UTC)),