CHI-3647: Fix EditCaseOverview component to show working copy#4095
CHI-3647: Fix EditCaseOverview component to show working copy#4095stephenhand wants to merge 5 commits intomasterfrom
Conversation
…for 'refresh' on useCase and updated 'autoload' to only load if the case isn't already loaded into state
|
@copilot add unit test coverage for useCase and useLoadWithRetry hooks in new files following the existing convention for naming and locating test files |
Co-authored-by: stephenhand <1694716+stephenhand@users.noreply.github.com> Agent-Logs-Url: https://github.com/techmatters/flex-plugins/sessions/c9200530-3a3e-47ec-9d56-142f75e25878
Added unit test coverage in commit
|
There was a problem hiding this comment.
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
useCasehook API (removedrefresh/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
useCasesignature and ensuredEditCaseOverviewmerges in working-copy values. - Added unit test coverage for
useLoadWithRetryanduseCase.
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
shouldLoadis nowautoload && !isAlreadyInState, which means once a case is present in state the returnedforceRefresh()can never trigger a reload (becauseuseLoadWithRetryonly loads whenshouldLoadis true). IfforceRefreshis intended to remain part ofuseCase’s API, consider keepingshouldLoadindependent of cache state (e.g.autoload) and instead initialize/derive the internal refresh flag based onisAlreadyInState, or otherwise removeforceRefreshfrom the returned object to avoid a misleading no-op.
const safeToLoad = Boolean(caseId);
const shouldLoad = autoload && !isAlreadyInState;
const loader = useLoadWithRetry({
error,
loadFunction: loadCase,
| @@ -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); | |||
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
@copilot open a new pull request to apply changes based on this feedback
plugin-hrm-form/src/components/customIntegrations/uscr/DispatchIncidentButton.tsx
Show resolved
Hide resolved
|
@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. |
…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
Description
useCaseanduseLoadWithRetryhooksChecklist
Other Related Issues
None
Verification steps
See ticket
AFTER YOU MERGE
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.