-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Workflows][Demo] Separate demo mode and testing fixtures (Recidiviz/…
…recidiviz-dashboards#7074) Add testing-specific fixtures to apps/staff/src/WorkflowsStore/__fixtures__/index.ts for use in WorkflowsStore.test.ts, use US_XX and fake names to make it more obvious those fixtures are for internal use only, and remove the empty demo mode staff/facilities that had existed only for testing. This PR is part of an effort to only show data useful for external demos in demo mode, and will be followed by adding some more client fixtures to the most often demoed states. GitOrigin-RevId: 8e7af32a3dae8719017df606c8bad0a1f46f0798
- Loading branch information
1 parent
348ce53
commit fe7e36f
Showing
8 changed files
with
353 additions
and
415 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,59 +17,125 @@ | |
|
||
import { | ||
ClientRecord, | ||
incarcerationStaffFixtures, | ||
IncarcerationStaffRecord, | ||
incarcerationStaffRecordSchema, | ||
makeRecordFixture, | ||
OpportunityType, | ||
outputFixtureArray, | ||
supervisionStaffFixtures, | ||
SupervisionStaffRecord, | ||
supervisionStaffRecordSchema, | ||
} from "~datatypes"; | ||
|
||
import { | ||
CombinedUserRecord, | ||
isUserRecord, | ||
LocationRecord, | ||
UserRecord, | ||
WorkflowsResidentRecord, | ||
} from "../../FirestoreStore"; | ||
import { dateToTimestamp } from "../utils"; | ||
|
||
const userInfoFixtures = outputFixtureArray(supervisionStaffFixtures).filter( | ||
isUserRecord, | ||
// asserting because despite the typeguard, TS can't seem to figure this one out | ||
) as Array<UserRecord>; | ||
// INCARCERATION | ||
|
||
export const mockOfficer: CombinedUserRecord = { | ||
info: { | ||
...userInfoFixtures[0], | ||
const incarcerationStaffTestFixtures: Array<IncarcerationStaffRecord> = [ | ||
makeRecordFixture(incarcerationStaffRecordSchema, { | ||
email: "[email protected]", | ||
id: "INCARCERATION_OFFICER1", | ||
stateCode: "US_XX", | ||
hasCaseload: true, | ||
givenNames: "TestIncarcerationOfficer1", | ||
surname: "", | ||
pseudonymizedId: "p001", | ||
}), | ||
]; | ||
|
||
export const mockIncarcerationOfficers: Array< | ||
IncarcerationStaffRecord["output"] | ||
> = outputFixtureArray(incarcerationStaffTestFixtures); | ||
|
||
export const mockResidents: WorkflowsResidentRecord[] = [ | ||
{ | ||
recordId: "999", | ||
personType: "RESIDENT", | ||
admissionDate: "2023-03-23", | ||
allEligibleOpportunities: ["usMeSCCP"], | ||
custodyLevel: "MINIMUM", | ||
facilityId: "MOUNTAIN VIEW CORRECTIONAL FACILITY", | ||
officerId: "1", | ||
stateCode: "US_ME", | ||
gender: "MALE", | ||
personName: { | ||
givenNames: "Bernie", | ||
surname: "Sanders", | ||
}, | ||
pseudonymizedId: "p999", | ||
releaseDate: "2023-09-22", | ||
unitId: "UNIT E", | ||
personExternalId: "999", | ||
displayId: "d999", | ||
metadata: {}, | ||
}, | ||
}; | ||
]; | ||
|
||
export const mockOfficer2: CombinedUserRecord = { | ||
info: { | ||
...userInfoFixtures[1], | ||
export const mockLocations: LocationRecord[] = [ | ||
{ | ||
id: "FAC1", | ||
stateCode: "US_MO", | ||
idType: "facilityId", | ||
name: "Facility 1", | ||
system: "INCARCERATION", | ||
}, | ||
{ | ||
id: "FAC2", | ||
stateCode: "US_MO", | ||
idType: "facilityId", | ||
name: "Facility 2", | ||
system: "INCARCERATION", | ||
}, | ||
]; | ||
|
||
// SUPERVISION STAFF | ||
|
||
const supervisionStaffTestFixtures = [ | ||
{ | ||
email: "[email protected]", | ||
district: "DISTRICT 1", | ||
id: "XX_OFFICER1", | ||
stateCode: "US_XX", | ||
hasCaseload: true, | ||
givenNames: "TestOfficer", | ||
surname: "AlphabeticallySecond", | ||
supervisorExternalId: null, | ||
pseudonymizedId: "p001", | ||
}, | ||
}; | ||
{ | ||
email: "[email protected]", | ||
district: "DISTRICT 1", | ||
id: "XX_OFFICER2", | ||
stateCode: "US_XX", | ||
givenNames: "TestOfficer", | ||
surname: "AlphabeticallyFirst", | ||
supervisorExternalId: null, | ||
pseudonymizedId: "p002", | ||
}, | ||
].map((r) => makeRecordFixture(supervisionStaffRecordSchema, r)); | ||
|
||
export const mockSupervisor: CombinedUserRecord = { | ||
export const mockSupervisionOfficers: Array<SupervisionStaffRecord["output"]> = | ||
outputFixtureArray(supervisionStaffTestFixtures); | ||
|
||
export const mockOfficer: CombinedUserRecord = { | ||
info: { | ||
...userInfoFixtures[2], | ||
stateCode: "US_XX", | ||
hasCaseload: false, | ||
...(mockSupervisionOfficers[0] as UserRecord), | ||
hasCaseload: true, | ||
}, | ||
}; | ||
|
||
export const mockSupervisor2: CombinedUserRecord = { | ||
export const mockOfficer2: CombinedUserRecord = { | ||
info: { | ||
...userInfoFixtures.filter((user) => user.id === "SUPERVISOR1")[0], | ||
hasCaseload: false, | ||
...(mockSupervisionOfficers[1] as UserRecord), | ||
hasCaseload: true, | ||
}, | ||
}; | ||
|
||
// CLIENTS | ||
|
||
export const ineligibleClient: ClientRecord = { | ||
recordId: "us_xx_100", | ||
personName: { | ||
|
@@ -81,7 +147,7 @@ export const ineligibleClient: ClientRecord = { | |
displayId: "d100", | ||
pseudonymizedId: "p100", | ||
stateCode: "US_XX", | ||
officerId: "OFFICER1", | ||
officerId: "XX_OFFICER1", | ||
supervisionType: "TN PAROLEE", | ||
supervisionLevel: "MEDIUM", | ||
supervisionLevelStart: new Date("2020-12-20"), | ||
|
@@ -140,7 +206,7 @@ export const eligibleClient: ClientRecord = { | |
displayId: "d101", | ||
pseudonymizedId: "p101", | ||
stateCode: "US_XX", | ||
officerId: "OFFICER1", | ||
officerId: "XX_OFFICER1", | ||
supervisionType: "TN PROBATIONER", | ||
supervisionLevel: "MEDIUM", | ||
supervisionLevelStart: new Date("2019-12-20"), | ||
|
@@ -180,7 +246,7 @@ export const lsuEligibleClient: ClientRecord = { | |
displayId: "d102", | ||
pseudonymizedId: "p102", | ||
stateCode: "US_XX", | ||
officerId: "OFFICER1", | ||
officerId: "XX_OFFICER1", | ||
supervisionType: "MISDEMEANOR PROBATIONER", | ||
supervisionLevel: "STANDARD: MINIMUM", | ||
supervisionLevelStart: new Date("2021-07-05"), | ||
|
@@ -220,7 +286,7 @@ export const lsuAlmostEligibleClient: ClientRecord = { | |
displayId: "d103", | ||
pseudonymizedId: "p103", | ||
stateCode: "US_XX", | ||
officerId: "OFFICER1", | ||
officerId: "XX_OFFICER1", | ||
supervisionType: "MISDEMEANOR PROBATIONER", | ||
supervisionLevel: "STANDARD: MINIMUM", | ||
supervisionLevelStart: new Date("2021-07-05"), | ||
|
@@ -256,72 +322,33 @@ export const lsuAlmostEligibleClient: ClientRecord = { | |
], | ||
}; | ||
|
||
export const milestonesClient: ClientRecord = { | ||
...eligibleClient, | ||
recordId: "us_xx_104", | ||
personName: { givenNames: "Mickey", surname: "Mouse" }, | ||
personExternalId: "104", | ||
displayId: "d104", | ||
pseudonymizedId: "p104", | ||
}; | ||
|
||
export const mockClients = [ | ||
ineligibleClient, | ||
eligibleClient, | ||
lsuEligibleClient, | ||
]; | ||
|
||
export const mockResidents: WorkflowsResidentRecord[] = [ | ||
{ | ||
recordId: "999", | ||
personType: "RESIDENT", | ||
admissionDate: "2023-03-23", | ||
allEligibleOpportunities: ["usMeSCCP"], | ||
custodyLevel: "MINIMUM", | ||
facilityId: "MOUNTAIN VIEW CORRECTIONAL FACILITY", | ||
officerId: "1", | ||
stateCode: "US_ME", | ||
gender: "MALE", | ||
personName: { | ||
givenNames: "Bernie", | ||
surname: "Sanders", | ||
}, | ||
pseudonymizedId: "p999", | ||
releaseDate: "2023-09-22", | ||
unitId: "UNIT E", | ||
personExternalId: "999", | ||
displayId: "d999", | ||
metadata: {}, | ||
}, | ||
]; | ||
// SUPERVISORS | ||
|
||
export const mockSupervisionOfficers: Array<SupervisionStaffRecord["output"]> = | ||
outputFixtureArray(supervisionStaffFixtures.slice(0, 2)); | ||
|
||
const mockSelectSupervisionOfficerFixtures: Array<SupervisionStaffRecord> = | ||
supervisionStaffFixtures.filter( | ||
(staff) => staff.output.stateCode === "US_TN", | ||
); | ||
export const mockSupervisionOfficers2: Array<SupervisionStaffRecord["output"]> = | ||
outputFixtureArray(mockSelectSupervisionOfficerFixtures); | ||
export const mockSupervisor: CombinedUserRecord = { | ||
info: { | ||
email: "[email protected]", | ||
id: "XX_SUPERVISOR1", | ||
stateCode: "US_XX", | ||
givenNames: "TestSupervisorWithStaff", | ||
surname: "", | ||
pseudonymizedId: "s001", | ||
recordType: "supervisionStaff", | ||
}, | ||
}; | ||
|
||
export const mockIncarcerationOfficers: Array< | ||
IncarcerationStaffRecord["output"] | ||
> = outputFixtureArray(incarcerationStaffFixtures.slice(0, 2)); | ||
// MILESTONES | ||
|
||
export const mockLocations: LocationRecord[] = [ | ||
{ | ||
id: "FAC1", | ||
stateCode: "US_MO", | ||
idType: "facilityId", | ||
name: "Facility 1", | ||
system: "INCARCERATION", | ||
}, | ||
{ | ||
id: "FAC2", | ||
stateCode: "US_MO", | ||
idType: "facilityId", | ||
name: "Facility 2", | ||
system: "INCARCERATION", | ||
}, | ||
]; | ||
export const milestonesClient: ClientRecord = { | ||
...eligibleClient, | ||
recordId: "us_xx_104", | ||
personName: { givenNames: "Mickey", surname: "Mouse" }, | ||
personExternalId: "104", | ||
displayId: "d104", | ||
pseudonymizedId: "p104", | ||
}; |
Oops, something went wrong.