Fix contacts warning when changing work item type

What does this MR do and why?

This MR fixes an issue where the Change type dialog incorrectly lists Contacts as information that will be lost when promoting an issue to an epic, even when the issue has no associated CRM contacts.

Previously, the dialog relied on contactsAvailable, which indicates group-level CRM contact availability rather than whether the current work item actually has associated contacts.

This MR:

  • Fetches the work item's contacts on demand in the modal with the existing workItemCrmContacts query, using the same variables as the sidebar so Apollo can merge the requests. Contacts is listed as lost information only when the query returns at least one associated contact.
  • Skips the query when the work item has no CRM Contacts widget or when contactsAvailable is false.
  • Leaves the shared BaseWorkItemFeatures GraphQL fragment unchanged, so the shared work item detail queries and mutations don't get more expensive.
  • Uses the WIDGET_TYPE_CRM_CONTACTS constant instead of a hard-coded string.
  • Adds frontend tests for the on-demand query with no contacts and with an associated contact, for both widget-based and feature-based data, and for the case where contactsAvailable is false (no request, no warning).
  • Asserts that Contacts appears in the warning text only when the work item has associated contacts.

As a result, Contacts is listed as lost information only when the issue has at least one associated contact.

References

Closes #639070 (closed)

Related issue: #580580 (closed) (closed)

Screenshots or screen recordings

Change type → Epic (Promote to group) on an issue in a group with CRM contacts. Captured on a local GDK by @vanessaotto.

Issue Before After
No contacts change-type-before-issue-1 change-type-after-issue-1
One contact change-type-before-issue-2 change-type-after-issue-2
  • No contacts: Contacts is no longer listed.
  • One contact: Contacts is still listed.

How to set up and validate locally

  1. Use a GitLab development environment with the frontend dependencies installed.
  2. Create a group with at least one CRM contact.
  3. Create an issue in a project belonging to that group without associating any contacts.
  4. Open More actions → Change type and select Epic (Promote to group).
  5. Verify that Contacts is not listed in the information-loss warning.
  6. Associate one or more CRM contacts with the issue and repeat the steps.
  7. Verify that Contacts appears in the warning.

Frontend test coverage has been added in:

spec/frontend/work_items/components/work_item_change_type_modal_spec.js

Validated locally: the focused Jest specs (CE and EE) pass, and ESLint and Prettier pass. GraphQL ESLint could not be run locally because the Apollo schema was unavailable, so CI covers it.

MR acceptance checklist

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

  • Changes are scoped to the reported issue.
  • Regression test coverage added for empty and single-contact scenarios.
  • Both widget-based and feature-based data paths are covered.
  • The shared BaseWorkItemFeatures fragment is unchanged.
  • git diff --check passes.
  • Focused frontend Jest test passes locally.
  • Focused frontend Jest test passes in CI.
  • GraphQL and frontend CI checks pass.

Closes #639070 (closed)

Edited by Vanessa Otto

Merge request reports

Loading
Loading