Skip to content

Commit

Permalink
10489: set default judge when eventCode is OJR;
Browse files Browse the repository at this point in the history
  • Loading branch information
nechama-krigsman committed Nov 26, 2024
1 parent 47ed280 commit f766dcb
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ describe('setCourtIssuedDocumentInitialDataAction', () => {
const docketEntryIds = [
'ddfd978d-6be6-4877-b004-2b5735a41fee',
'11597d22-0874-4c5e-ac98-a843d1472baf',
'22597d22-0874-4c5e-ac98-a843d1472baf',
];

beforeAll(() => {
Expand All @@ -22,6 +23,11 @@ describe('setCourtIssuedDocumentInitialDataAction', () => {
eventCode: 'O',
freeText: 'something',
});
MOCK_CASE.docketEntries.push({
docketEntryId: docketEntryIds[2],
eventCode: 'OJR',
signedByUserId: '4497d22-0874-4c5e-ac98-a843d1472baf',
});
});

it('should set correct values on state.form for the docketEntryId passed in via props', async () => {
Expand Down Expand Up @@ -108,4 +114,42 @@ describe('setCourtIssuedDocumentInitialDataAction', () => {

expect(result.state.form).toEqual({});
});

it('should set the judge name when eventcode is OJR and docketEntry was signed by the judge', async () => {
const result = await runAction(setCourtIssuedDocumentInitialDataAction, {
modules: {
presenter,
},
props: {
docketEntryId: '22597d22-0874-4c5e-ac98-a843d1472baf',
},
state: {
caseDetail: MOCK_CASE,
form: {},
judges: [
{ name: 'Colvin', userId: '4497d22-0874-4c5e-ac98-a843d1472baf' },
],
},
});
expect(result.state.form.judge).toEqual('Colvin');
});

it('should not set the judge name when eventcode is OJR and docketEntry was signed by a non judge user', async () => {
const result = await runAction(setCourtIssuedDocumentInitialDataAction, {
modules: {
presenter,
},
props: {
docketEntryId: '22597d22-0874-4c5e-ac98-a843d1472baf',
},
state: {
caseDetail: MOCK_CASE,
form: {},
judges: [
{ name: 'Cohen', userId: '3297d22-0874-4c5e-ac98-a843d1472baf' },
],
},
});
expect(result.state.form.judge).toEqual(undefined);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ export const setCourtIssuedDocumentInitialDataAction = ({
}: ActionProps) => {
const { docketEntries } = get(state.caseDetail);

const judges = get(state.judges);

const docketEntry = docketEntries.find(
item => item.docketEntryId === props.docketEntryId,
);
Expand All @@ -34,6 +36,15 @@ export const setCourtIssuedDocumentInitialDataAction = ({
store.set(state.form.attachments, false);
}

if (docketEntry.eventCode === 'OJR') {
const signingJudge = judges.find(judge => {
return judge.userId === docketEntry.signedByUserId;
});
if (signingJudge) {
store.set(state.form.judge, signingJudge.name);
}
}

if (docketEntry.freeText) {
store.set(state.form.freeText, docketEntry.freeText);
}
Expand Down

0 comments on commit f766dcb

Please sign in to comment.