-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
5430 other petitioners ui #5570
Changes from all commits
9392846
624c35b
b51c035
caa50c0
4d5944b
0914f40
6dd7d1a
c8019b7
e6330da
53273fc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { state } from 'cerebral'; | ||
|
||
/** | ||
* sets state.showingAdditionalPetitioners its negated stored value (default false) | ||
* | ||
* @param {object} providers the providers object | ||
* @param {object} providers.get the cerebral get function | ||
* @param {Function} providers.store the cerebral store function | ||
*/ | ||
export const toggleShowAdditionalPetitionersAction = ({ get, store }) => { | ||
const showingAdditionalPetitioners = | ||
get(state.showingAdditionalPetitioners) || false; | ||
|
||
store.set(state.showingAdditionalPetitioners, !showingAdditionalPetitioners); | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { runAction } from 'cerebral/test'; | ||
import { toggleShowAdditionalPetitionersAction } from './toggleShowAdditionalPetitionersAction'; | ||
|
||
describe('toggleShowAdditionalPetitionersAction', () => { | ||
it('should default to true for the first run', async () => { | ||
const result = await runAction(toggleShowAdditionalPetitionersAction); | ||
|
||
expect(result.state.showingAdditionalPetitioners).toEqual(true); | ||
}); | ||
|
||
it('should be true if the state value is false', async () => { | ||
const result = await runAction(toggleShowAdditionalPetitionersAction, { | ||
state: { | ||
showingAdditionalPetitioners: false, | ||
}, | ||
}); | ||
|
||
expect(result.state.showingAdditionalPetitioners).toEqual(true); | ||
}); | ||
|
||
it('should be false if the state value is true', async () => { | ||
const result = await runAction(toggleShowAdditionalPetitionersAction, { | ||
state: { | ||
showingAdditionalPetitioners: true, | ||
}, | ||
}); | ||
|
||
expect(result.state.showingAdditionalPetitioners).toEqual(false); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -138,4 +138,96 @@ describe('case information helper', () => { | |
}); | ||
expect(result.showSealCaseButton).toBeFalsy(); | ||
}); | ||
|
||
describe('other petitioners', () => { | ||
let baseState; | ||
|
||
beforeEach(() => { | ||
const user = { | ||
role: ROLES.docketClerk, // has SEAL_CASE permission | ||
userId: '789', | ||
}; | ||
|
||
baseState = { | ||
...getBaseState(user), | ||
caseDetail: {}, | ||
form: {}, | ||
}; | ||
}); | ||
|
||
it('shows "Hide" display if showingAdditionalPetitioners is true', () => { | ||
const result = runCompute(caseInformationHelper, { | ||
state: { | ||
...baseState, | ||
showingAdditionalPetitioners: true, | ||
}, | ||
}); | ||
|
||
expect(result.toggleAdditionalPetitionersDisplay).toEqual('Hide'); | ||
}); | ||
|
||
it('shows "View" display if showingAdditionalPetitioners is false', () => { | ||
const result = runCompute(caseInformationHelper, { | ||
state: { | ||
...baseState, | ||
showingAdditionalPetitioners: false, | ||
}, | ||
}); | ||
|
||
expect(result.toggleAdditionalPetitionersDisplay).toEqual('View'); | ||
}); | ||
|
||
it('does not paginate (or show) other petitioners if it is non-existent', () => { | ||
const result = runCompute(caseInformationHelper, { | ||
state: { | ||
...baseState, | ||
}, | ||
}); | ||
|
||
expect(result.formattedOtherPetitioners).toEqual([]); | ||
expect(result.showOtherPetitioners).toEqual(false); | ||
}); | ||
|
||
it('paginates if showingAdditionalPetitioners is false', () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How about if There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's no logic to check the length to paginate or not. It's a "show 4 or show all" kinda thing |
||
const result = runCompute(caseInformationHelper, { | ||
state: { | ||
...baseState, | ||
caseDetail: { | ||
otherPetitioners: [ | ||
{ a: '1' }, | ||
{ a: '1' }, | ||
{ a: '1' }, | ||
{ a: '1' }, | ||
{ a: '1' }, | ||
], | ||
}, | ||
showingAdditionalPetitioners: false, | ||
}, | ||
}); | ||
|
||
expect(result.formattedOtherPetitioners.length).toEqual(4); | ||
expect(result.showOtherPetitioners).toEqual(true); | ||
}); | ||
|
||
it('does not paginate (shows all) if showingAdditionalPetitioners is true', () => { | ||
const result = runCompute(caseInformationHelper, { | ||
state: { | ||
...baseState, | ||
caseDetail: { | ||
otherPetitioners: [ | ||
{ a: '1' }, | ||
{ a: '1' }, | ||
{ a: '1' }, | ||
{ a: '1' }, | ||
{ a: '1' }, | ||
], | ||
}, | ||
showingAdditionalPetitioners: true, | ||
}, | ||
}); | ||
|
||
expect(result.formattedOtherPetitioners.length).toEqual(5); | ||
expect(result.showOtherPetitioners).toEqual(true); | ||
}); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { toggleShowAdditionalPetitionersAction } from '../actions/CaseDetail/toggleShowAdditionalPetitionersAction'; | ||
|
||
export const toggleShowAdditionalPetitionersSequence = [ | ||
toggleShowAdditionalPetitionersAction, | ||
]; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { connect } from '@cerebral/react'; | ||
import { props, state } from 'cerebral'; | ||
import React from 'react'; | ||
|
||
export const AddressDisplay = connect( | ||
{ | ||
constants: state.constants, | ||
contact: props.contact, | ||
nameOverride: props.nameOverride || {}, | ||
}, | ||
function AddressDisplay({ constants, contact, nameOverride }) { | ||
return ( | ||
<> | ||
<p className="margin-top-0 address-name"> | ||
{nameOverride || contact.name}{' '} | ||
{contact.barNumber && `(${contact.barNumber})`} | ||
{contact.inCareOf && ( | ||
<span> | ||
<br /> | ||
c/o {contact.inCareOf} | ||
</span> | ||
)} | ||
</p> | ||
<p> | ||
<span className="address-line">{contact.address1}</span> | ||
Comment on lines
+24
to
+25
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: For both this and the |
||
{contact.address2 && ( | ||
<span className="address-line">{contact.address2}</span> | ||
)} | ||
{contact.address3 && ( | ||
<span className="address-line">{contact.address3}</span> | ||
)} | ||
<span className="address-line"> | ||
{contact.city && `${contact.city}, `} | ||
{contact.state} {contact.postalCode} | ||
</span> | ||
{contact.countryType === constants.COUNTRY_TYPES.INTERNATIONAL && ( | ||
<span className="address-line">{contact.country}</span> | ||
)} | ||
{contact.phone && ( | ||
<span className="address-line margin-top-1">{contact.phone}</span> | ||
)} | ||
</p> | ||
</> | ||
); | ||
}, | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there's a
store.toggle
method for just this purpose -- assuming the tests pass, means fewer lines of code, better coverage by tiny percentages. :D