Skip to content

Sync epic dates with associated work item

What does this MR do and why?

Related to #440415 (closed)

As part of Workstream 2: Keep epic associations in sync w... (&12213 - closed) we want to sync the legacy epic dates to the work item

Changes summary:

  • When creating an epic with Start date and Due date these are copied to the synced work item using the RolledupDates widget. The epic dates are initially set to Fixed so WorkItems::CreateService will handle creating a new work_item_dates_sources record where the _is_fixed attributes are set to true and the dates saved to the respective _date and _date_fixed fields.
  • When updating an epic to use Inherited dates, the same calculation is performed for the synced work item. If the associated children are also in sync, the calculation will result in matching dates and date sources.
  • Update ParentLink and EpicIssue validations to allow an issue having a parent epic as well as a parent work item if they are synced records. This update was going to be included in the epic_issues sync but we need it here to test the inherited scenario where the epic uses the dates from a child issue's milestone.

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

How to set up and validate locally

  1. In rails console enable the experiment fully
    Feature.enable(:epic_creation_with_synced_work_item)
  2. Visit any group and create an epic Parent epic with dates, setting Start date as Feb 1st and Due date as Feb 29
  3. In rails console find the parent epic's issue_id

Case 1: Fixed dates

  1. Visit http://127.0.0.1:3000/-/graphql-explorer and check the synced work item dates using the following query

    query
    query getDates {
      workItem(id: "gid://gitlab/WorkItem/<issue_id>") {
        widgets {
          ... on WorkItemWidgetRolledupDates {
            startDate
            startDateIsFixed
            startDateFixed
            dueDate
            dueDateIsFixed
            dueDateFixed
            startDateSourcingWorkItem {
              title
            }
            startDateSourcingMilestone {
              title
            }
            dueDateSourcingWorkItem {
              title
            }
            dueDateSourcingMilestone {
              title
            }
          }      
        }
      }
    }
    response
    {
      "data": {
        "workItem": {
          "widgets": [
            {
              "startDate": "2024-02-01",
              "startDateIsFixed": true,
              "startDateFixed": "2024-02-01",
              "dueDate": "2024-02-29",
              "dueDateIsFixed": true,
              "dueDateFixed": "2024-02-29",
              "startDateSourcingWorkItem": null,
              "startDateSourcingMilestone": null,
              "dueDateSourcingWorkItem": null,
              "dueDateSourcingMilestone": null
            }
          ]
        }
      }
    }
  2. Verify that the dates are fixed and set as February

Case 2: Rolled up dates from a child epic

  1. Create another epic Child epic with dates setting Start date as March 1st and Due date as March 31

  2. Add this new epic as a child of Parent epic with dates

  3. Update the parent to use Inherited dates and verify that they change to March 1 to 31.

  4. Execute the same query used in Case 1 and verify the synced work item fields updated correctly. Note that startDateFixed and dueDateFixed should preserve the February dates while startDate and dueDate are updated to the child's date (March).

    response
    {
      "data": {
        "workItem": {
          "widgets": [
            {
              "startDate": "2024-03-01",
              "startDateIsFixed": false,
              "startDateFixed": "2024-02-01",
              "dueDate": "2024-03-31",
              "dueDateIsFixed": false,
              "dueDateFixed": "2024-02-29",
              "startDateSourcingWorkItem": {
                "title": "Child Epic with dates"
              },
              "startDateSourcingMilestone": null,
              "dueDateSourcingWorkItem": {
                "title": "Child Epic with dates"
              },
              "dueDateSourcingMilestone": null
            }
          ]
        }
      }
    }

Case 3: Rolled up dates from a child issue's milestone

  1. Create a new milestone in the same group as the epics, and set its dates to April 1 and April 30

  2. In a project within the same group create a new issue Child issue with milestone and assign the new milestone to it

  3. Visit the synced work item Parent epic with dates and add the issue as a child (this step is necessary because epic_issue syncing hasn't been implemented yet)

  4. Visit the parent epic, remove the previously added child epic and assign the issue as a child

  5. Reload the page and verify the dates have been updated to match the milestone dates (April)

  6. Execute the GraphQL query again and verify that synced work item dates are set to April too

    response
    {
      "data": {
        "workItem": {
          "widgets": [
            {
              "startDate": "2024-04-01",
              "startDateIsFixed": false,
              "startDateFixed": "2024-02-01",
              "dueDate": "2024-04-30",
              "dueDateIsFixed": false,
              "dueDateFixed": "2024-02-29",
              "startDateSourcingWorkItem": null,
              "startDateSourcingMilestone": {
                "title": "April"
              },
              "dueDateSourcingWorkItem": null,
              "dueDateSourcingMilestone": {
                "title": "April"
              }
            }
          ]
        }
      }
    }
Edited by Eugenia Grieff

Merge request reports