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
andDue date
these are copied to the synced work item using theRolledupDates
widget. The epic dates are initially set to Fixed soWorkItems::CreateService
will handle creating a newwork_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
andEpicIssue
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 theepic_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
- In rails console enable the experiment fully
Feature.enable(:epic_creation_with_synced_work_item)
- Visit any group and create an epic
Parent epic with dates
, setting Start date as Feb 1st and Due date as Feb 29 - In rails console find the parent epic's
issue_id
Case 1: Fixed dates
-
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 } ] } } }
-
Verify that the dates are fixed and set as February
Case 2: Rolled up dates from a child epic
-
Create another epic
Child epic with dates
setting Start date as March 1st and Due date as March 31 -
Add this new epic as a child of
Parent epic with dates
-
Update the parent to use Inherited dates and verify that they change to March 1 to 31.
-
Execute the same query used in
Case 1
and verify the synced work item fields updated correctly. Note thatstartDateFixed
anddueDateFixed
should preserve the February dates whilestartDate
anddueDate
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
-
Create a new milestone in the same group as the epics, and set its dates to April 1 and April 30
-
In a project within the same group create a new issue
Child issue with milestone
and assign the new milestone to it -
Visit the synced work item
Parent epic with dates
and add the issue as a child (this step is necessary becauseepic_issue
syncing hasn't been implemented yet) -
Visit the parent epic, remove the previously added child epic and assign the issue as a child
-
Reload the page and verify the dates have been updated to match the milestone dates (April)
-
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" } } ] } } }