Skip to content

CHI-3647: Fix EditCaseOverview component to show working copy#4095

Open
stephenhand wants to merge 5 commits intomasterfrom
CHI-3647-fix_component
Open

CHI-3647: Fix EditCaseOverview component to show working copy#4095
stephenhand wants to merge 5 commits intomasterfrom
CHI-3647-fix_component

Conversation

@stephenhand
Copy link
Copy Markdown
Collaborator

@stephenhand stephenhand commented Mar 25, 2026

Description

  • Removed support for 'refresh' on useCase and updated 'autoload' to only load if the case isn't already loaded into state
  • Added unit test coverage for useCase and useLoadWithRetry hooks

Checklist

  • Corresponding issue has been opened
  • New tests added
  • [n/a] Feature flags added
  • [n/a] Strings are localized
  • Tested for chat contacts
  • Tested for call contacts

Other Related Issues

None

Verification steps

See ticket

AFTER YOU MERGE

  1. Cut a release tag using the Github workflow. Wait for it to complete and notify in the #aselo-deploys Slack channel.
  2. Comment on the ticket with the release tag version AND any additional instructions required to configure an environment to test the changes.
  3. Only then move the ticket into the QA column in JIRA

You are responsible for ensuring the above steps are completed. If you move a ticket into QA without advising what version to test, the QA team will assume the latest tag has the changes. If it does not, the following confusion is on you! :-P


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

…for 'refresh' on useCase and updated 'autoload' to only load if the case isn't already loaded into state
@stephenhand stephenhand requested a review from gpaoloni March 25, 2026 14:54
@stephenhand
Copy link
Copy Markdown
Collaborator Author

@copilot add unit test coverage for useCase and useLoadWithRetry hooks in new files following the existing convention for naming and locating test files

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 25, 2026

@copilot add unit test coverage for useCase and useLoadWithRetry hooks in new files following the existing convention for naming and locating test files

Added unit test coverage in commit fc337cc:

  • src/___tests__/states/hooks/useLoadWithRetry.test.tsx — 11 tests covering initial load conditions, forceRefresh behaviour, retry on 5xx errors, no-retry on 4xx errors, and retry guard conditions (loading in progress, retry disabled)
  • src/___tests__/states/case/hooks/useCase.test.tsx — 9 tests covering autoload dispatch behaviour (case absent, case already loaded, autoload=false, falsy caseId) and return values (connectedCase, loading, error, forceRefresh)

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates case-loading behavior to prevent unnecessary reloads that can overwrite in-progress edits, and ensures the EditCaseOverview UI reflects the case summary working copy. Adds unit tests for the loading/retry hooks supporting this behavior.

Changes:

  • Simplified useCase hook API (removed refresh/referenceId) and adjusted autoload to only fetch when the case is not already in Redux state.
  • Updated case UI components to align with the new useCase signature and ensured EditCaseOverview merges in working-copy values.
  • Added unit test coverage for useLoadWithRetry and useCase.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
plugin-hrm-form/src/states/case/hooks/useCase.ts Changes autoload semantics and public hook signature for case loading.
plugin-hrm-form/src/components/customIntegrations/uscr/DispatchIncidentButton.tsx Updates useCase usage; alters incident-dispatch dispatch behavior.
plugin-hrm-form/src/components/caseMergingBanners/ContactAddedToCaseBanner.tsx Removes deprecated useCase params.
plugin-hrm-form/src/components/case/caseOverview/EditCaseOverview.tsx Ensures working copy is included when computing initial form values.
plugin-hrm-form/src/components/case/Case.tsx Removes forced reload parameters to avoid overwriting cached/working-copy state.
plugin-hrm-form/src/___tests__/states/hooks/useLoadWithRetry.test.tsx Adds tests for initial load, force refresh, and retry/backoff behavior.
plugin-hrm-form/src/___tests__/states/case/hooks/useCase.test.tsx Adds tests for autoload behavior and return values from useCase.
Comments suppressed due to low confidence (1)

plugin-hrm-form/src/states/case/hooks/useCase.ts:47

  • shouldLoad is now autoload && !isAlreadyInState, which means once a case is present in state the returned forceRefresh() can never trigger a reload (because useLoadWithRetry only loads when shouldLoad is true). If forceRefresh is intended to remain part of useCase’s API, consider keeping shouldLoad independent of cache state (e.g. autoload) and instead initialize/derive the internal refresh flag based on isAlreadyInState, or otherwise remove forceRefresh from the returned object to avoid a misleading no-op.
  const safeToLoad = Boolean(caseId);
  const shouldLoad = autoload && !isAlreadyInState;

  const loader = useLoadWithRetry({
    error,
    loadFunction: loadCase,

Comment on lines 27 to 63
@@ -50,7 +40,7 @@ const useCaseLoader = ({
}, [caseId, dispatch]);

const safeToLoad = Boolean(caseId);
const shouldLoad = autoload || refresh;
const shouldLoad = autoload && !isAlreadyInState;

const loader = useLoadWithRetry({
error,
@@ -69,22 +59,11 @@ const useCaseLoader = ({
};

// eslint-disable-next-line import/no-unused-modules
export const useCase = ({
caseId,
referenceId: _referenceId, // Kept for backward compatibility; no longer used with GC-based state management
autoload = true,
refresh = false,
}: {
caseId: Case['id'];
/** @deprecated No longer used; cases are managed via garbage collection */
referenceId?: string;
autoload?: boolean;
refresh?: boolean;
}) => {
export const useCase = ({ caseId, autoload = true }: { caseId: Case['id']; autoload?: boolean }) => {
const connectedCase = useSelector((state: RootState) => selectCaseByCaseId(state, caseId)?.connectedCase);
Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The hook guards if (!caseId) return; and several call sites pass caseId that can be undefined, but the exported useCase/useCaseLoader typings require caseId: Case['id'] (a string). Consider widening the param type to caseId?: Case['id'] (or Case['id'] | undefined) so the public signature matches actual usage and avoids misleading consumers.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot open a new pull request to apply changes based on this feedback

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 26, 2026

@stephenhand I've opened a new pull request, #4097, to work on those changes. Once the pull request is ready, I'll request review from you.

Copilot AI and others added 2 commits March 26, 2026 09:00
…nly shown on success and errors propagate to catch block

Co-authored-by: stephenhand <1694716+stephenhand@users.noreply.github.com>
Agent-Logs-Url: https://github.com/techmatters/flex-plugins/sessions/8ff858da-fa0e-4668-bc0f-ba268cb2ea83
Fix async error handling in DispatchIncidentButton: await newIncidentDispatchAction dispatch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants