Skip to content
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

10413: IRSPractitioner: Restrict Access to DOJ Employees #5171

Merged
merged 19 commits into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions cypress/helpers/authentication/login-as-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,16 @@ export function loginAsAdmissionsClerk(
cy.get('[data-testid="inbox-tab-content"]').should('exist');
}

export function loginAsDojPractitioner(
dojPractitionerUser:
| 'dojPractitioner1'
| 'dojPractitioner2'
| 'dojPractitioner3' = 'dojPractitioner1',
) {
cy.login(dojPractitionerUser);
cy.get('[data-testid="search-for-a-case-card"]').should('exist');
}

export function loginAsPrivatePractitioner(
practitionerUser:
| 'privatePractitioner1'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
export function updateCaseStatus(status: string, judge: string) {
export function updateCaseStatus(status: string, judge?: string) {
cy.get('[data-testid="tab-case-information"]').click();
cy.get('[data-testid="menu-edit-case-context-button"]').click();
cy.get('[data-testid="case-status-select"]').select(status);
cy.get('[data-testid="associated-judge-select"]').select(judge);
if (judge) cy.get('[data-testid="associated-judge-select"]').select(judge);
cy.get('[data-testid="modal-button-confirm"]').click();
cy.get('[data-testid="success-alert"]').should('be.visible');
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import { externalUserSearchesDocketNumber } from '../../../../../../helpers/advancedSearch/external-user-searches-docket-number';
import { goToCase } from '../../../../../../helpers/caseDetail/go-to-case';
import {
loginAsDocketClerk1,
loginAsDojPractitioner,
loginAsPetitioner,
loginAsPrivatePractitioner,
} from '../../../../../../helpers/authentication/login-as-helpers';
import { petitionerCreatesElectronicCaseWithDeceasedSpouse } from '../../../../../../helpers/fileAPetition/petitioner-creates-electronic-case';
import { petitionsClerkServesPetition } from '../../../../../../helpers/documentQC/petitionsclerk-serves-petition';
import { petitionsclerkAddsRespondentToCase } from '../../../../../../helpers/caseDetail/caseInformation/petitionsclerk-adds-respondent-to-case';
import { selectTypeaheadInput } from '../../../../../../helpers/components/typeAhead/select-typeahead-input';
import { updateCaseStatus } from '../../../../../../helpers/caseDetail/caseInformation/update-case-status';

describe('DOJ Practitioners - Represent A Party', () => {
it('should only display the "Represent A Party" button when the case is "On Appeal"', () => {
const BAR_NUMBER = 'WN7777';
const primaryFilerName = 'John';
const secondaryFilerName = 'Sally';

loginAsPetitioner();
petitionerCreatesElectronicCaseWithDeceasedSpouse(
primaryFilerName,
secondaryFilerName,
).then(docketNumber => {
petitionsClerkServesPetition(docketNumber);
petitionsclerkAddsRespondentToCase(docketNumber, BAR_NUMBER);

loginAsPrivatePractitioner();
externalUserSearchesDocketNumber(docketNumber);

cy.get('[data-testid="request-represent-a-party-button"]').click();

selectTypeaheadInput('document-type', 'Entry of Appearance');

cy.get(`[data-testid="filer-${primaryFilerName}, Petitioner"]`).click();
cy.get(`[data-testid="filer-${secondaryFilerName}, Petitioner"]`).click();

cy.get('[data-testid="auto-generation"]').should('exist');
cy.get('[data-testid="request-access-submit-document"]').click();

cy.get('[data-testid="entry-of-appearance-pdf-preview"]').should('exist');
cy.get('[data-testid="submit-represent-a-party-button"]').click();

cy.get('[data-testid="document-download-link-EA"]').should(
'contain.text',
`Entry of Appearance for Petrs. ${primaryFilerName} & ${secondaryFilerName}`,
);

loginAsDojPractitioner();
externalUserSearchesDocketNumber(docketNumber);

cy.get('[data-testid="request-represent-a-party-button"]').should(
'not.exist',
);

loginAsDocketClerk1();
goToCase(docketNumber);
updateCaseStatus('On Appeal');

loginAsDojPractitioner();
externalUserSearchesDocketNumber(docketNumber);

cy.get('[data-testid="request-represent-a-party-button"]').should(
'exist',
);
});
});
});
112 changes: 84 additions & 28 deletions scripts/user/setup-test-users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,42 +90,98 @@ const setupPetitioners = async (
]);
};

const setupPractitionerInformationArray = (
barNumbers: string[],
practiceType: string,
role: string,
emailUsername?: string,
): {
barNumber: string;
emailUsername: string | undefined;
practiceType: string;
role: string;
}[] => {
return barNumbers.map((barNumber: string) => {
return {
barNumber,
emailUsername,
practiceType,
role,
};
});
};

const setupPractitioners = async (
applicationContext: ServerApplicationContext,
) => {
const privatePractitioners = [
{ barNumber: 'PT1234', role: 'privatePractitioner' },
{ barNumber: 'PT5432', role: 'privatePractitioner' },
{ barNumber: 'PT1111', role: 'privatePractitioner' },
{ barNumber: 'PT2222', role: 'privatePractitioner' },
{ barNumber: 'PT3333', role: 'privatePractitioner' },
{ barNumber: 'PT4444', role: 'privatePractitioner' },
{ barNumber: 'PT5555', role: 'privatePractitioner' },
{ barNumber: 'PT6666', role: 'privatePractitioner' },
{ barNumber: 'PT7777', role: 'privatePractitioner' },
{ barNumber: 'PT8888', role: 'privatePractitioner' },
const PRACTICE_TYPES = {
DOJ: 'DOJ',
IRS: 'IRS',
Private: 'Private',
};

const PRACTITIONER_ROLE = {
IRS: 'irsPractitioner',
PRIVATE: 'privatePractitioner',
};

const privatePractitionersBarNumbers = [
'PT1234',
'PT5432',
'PT1111',
'PT2222',
'PT3333',
'PT4444',
'PT5555',
'PT6666',
'PT7777',
'PT8888',
];
const privatePractitioners = setupPractitionerInformationArray(
privatePractitionersBarNumbers,
PRACTICE_TYPES.Private,
PRACTITIONER_ROLE.PRIVATE,
);

const irsPractitionersBarNumbers = [
'RT6789',
'RT0987',
'RT7777',
'RT8888',
'RT9999',
'RT6666',
'RT0000',
'RT1111',
'RT2222',
'RT3333',
];
const irsPractitioners = [
{ barNumber: 'RT6789', role: 'irsPractitioner' },
{ barNumber: 'RT0987', role: 'irsPractitioner' },
{ barNumber: 'RT7777', role: 'irsPractitioner' },
{ barNumber: 'RT8888', role: 'irsPractitioner' },
{ barNumber: 'RT9999', role: 'irsPractitioner' },
{ barNumber: 'RT6666', role: 'irsPractitioner' },
{ barNumber: 'RT0000', role: 'irsPractitioner' },
{ barNumber: 'RT1111', role: 'irsPractitioner' },
{ barNumber: 'RT2222', role: 'irsPractitioner' },
{ barNumber: 'RT3333', role: 'irsPractitioner' },
const irsPractitioners = setupPractitionerInformationArray(
irsPractitionersBarNumbers,
PRACTICE_TYPES.IRS,
PRACTITIONER_ROLE.IRS,
);

const dojBarNumbers = ['DT1111', 'DT2222', 'DT3333'];
const dojPractitioners = setupPractitionerInformationArray(
dojBarNumbers,
PRACTICE_TYPES.DOJ,
PRACTITIONER_ROLE.IRS,
'dojPractitioner',
);

const practitioners = [
privatePractitioners,
irsPractitioners,
dojPractitioners,
];

const practitioners = [privatePractitioners, irsPractitioners];
for (let i = 0; i < practitioners.length; i++) {
const practitionerArray = practitioners[i];
for (let j = 0; j < practitionerArray.length; j++) {
const { barNumber, role } = practitionerArray[j];
const { barNumber, emailUsername, practiceType, role } =
practitionerArray[j];

const practiceType = role === 'privatePractitioner' ? 'Private' : 'IRS';
const email = `${role}${j + 1}@example.com`;
const email = `${emailUsername || role}${j + 1}@example.com`;
const user = {
admissionsDate: '2019-03-01',
admissionsStatus: 'Active',
Expand All @@ -143,9 +199,9 @@ const setupPractitioners = async (
},
email,
firmName: 'Some Firm',
firstName: `${role} ${j + 1}`,
firstName: `${emailUsername || role} ${j + 1}`,
lastName: 'Test',
name: `Test ${role}${j + 1}`,
name: `Test ${emailUsername || role}${j + 1}`,
originalBarState: 'WA',
password: DEFAULT_ACCOUNT_PASS,
practiceType,
Expand Down
12 changes: 11 additions & 1 deletion shared/src/business/entities/EntityConstants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1462,7 +1462,17 @@ export const SCAN_MODE_LABELS = {
FLATBED: 'Flatbed',
};

export const PRACTICE_TYPE_OPTIONS = ['IRS', 'DOJ', 'Private'];
export const PRACTICE_TYPE = {
IRS: 'IRS',
DOJ: 'DOJ',
Private: 'Private',
};

export const PRACTICE_TYPE_OPTIONS = [
PRACTICE_TYPE.IRS,
PRACTICE_TYPE.DOJ,
PRACTICE_TYPE.Private,
];

export const PRACTITIONER_TYPE_OPTIONS = ['Attorney', 'Non-Attorney'];

Expand Down
6 changes: 6 additions & 0 deletions shared/src/business/entities/cases/Case.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ export class Case extends JoiValidationEntity {
public docketNumberWithSuffix?: string;
public canAllowDocumentService?: boolean;
public canAllowPrintableDocketRecord!: boolean;
public canDojPractitionersRepresentParty?: boolean;
public archivedDocketEntries?: RawDocketEntry[];
public docketEntries: any[];
public isSealed?: boolean;
Expand Down Expand Up @@ -397,6 +398,7 @@ export class Case extends JoiValidationEntity {
.meta({ tags: ['Restricted'] }),
canAllowDocumentService: joi.boolean().optional(),
canAllowPrintableDocketRecord: joi.boolean().optional(),
canDojPractitionersRepresentParty: joi.boolean().optional(),
caseCaption: CASE_CAPTION_RULE.messages({ '*': 'Enter a case caption' }),
caseNote: JoiValidationConstants.STRING.max(9000)
.optional()
Expand Down Expand Up @@ -2129,6 +2131,10 @@ export const canAllowPrintableDocketRecord = rawCase => {
return rawCase.status !== CASE_STATUS_TYPES.new;
};

export const canDojPractitionersRepresentPartyForCase = (rawCase: RawCase) => {
return rawCase.status === CASE_STATUS_TYPES.onAppeal;
};

/**
* Determines if the case has been closed
* @param {object} rawCase the case
Expand Down
4 changes: 4 additions & 0 deletions shared/src/business/entities/cases/PublicCase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export class PublicCase extends JoiValidationEntity {
public entityName: string;
public canAllowDocumentService?: string;
public canAllowPrintableDocketRecord?: string;
public canDojPractitionersRepresentParty?: boolean;
public caseCaption: string;
public createdAt?: string;
public leadDocketNumber?: string;
Expand Down Expand Up @@ -50,6 +51,8 @@ export class PublicCase extends JoiValidationEntity {
this.entityName = 'PublicCase';
this.canAllowDocumentService = rawCase.canAllowDocumentService;
this.canAllowPrintableDocketRecord = rawCase.canAllowPrintableDocketRecord;
this.canDojPractitionersRepresentParty =
rawCase.canDojPractitionersRepresentParty;
this.caseCaption = rawCase.caseCaption;
this.createdAt = rawCase.createdAt;
this.docketNumber = rawCase.docketNumber;
Expand Down Expand Up @@ -103,6 +106,7 @@ export class PublicCase extends JoiValidationEntity {
static VALIDATION_RULES = {
canAllowDocumentService: joi.boolean().optional(),
canAllowPrintableDocketRecord: joi.boolean().optional(),
canDojPractitionersRepresentParty: joi.boolean().optional(),
caseCaption: joi
.when('isSealed', {
is: true,
Expand Down
21 changes: 19 additions & 2 deletions shared/src/business/useCases/getCaseInteractor.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {
CASE_STATUS_TYPES,
CASE_TYPES_MAP,
CONTACT_TYPES,
PARTY_TYPES,
Expand Down Expand Up @@ -481,10 +482,26 @@ describe('getCaseInteractor', () => {

describe('decorateForCaseStatus', () => {
it('sets the canAllowDocumentService on the given case record', () => {
expect(MOCK_CASE.canAllowDocumentService).not.toBeDefined();
const TEST_MOCK_CASE: RawCase = {
...MOCK_CASE,
};

expect(TEST_MOCK_CASE.canAllowDocumentService).not.toBeDefined();
expect(
decorateForCaseStatus(MOCK_CASE).canAllowDocumentService,
decorateForCaseStatus(TEST_MOCK_CASE).canAllowDocumentService,
).toBeDefined();
});

it('should set "canDojPractitionersRepresentParty" when the case status is "On Appeal"', () => {
const TEST_MOCK_CASE: RawCase = {
...MOCK_CASE,
status: CASE_STATUS_TYPES.onAppeal,
};

expect(TEST_MOCK_CASE.canDojPractitionersRepresentParty).toBeUndefined();

const DECORATED_CASE = decorateForCaseStatus(TEST_MOCK_CASE);
expect(DECORATED_CASE.canDojPractitionersRepresentParty).toEqual(true);
});
});
});
4 changes: 4 additions & 0 deletions shared/src/business/useCases/getCaseInteractor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {
Case,
canAllowDocumentServiceForCase,
canAllowPrintableDocketRecord,
canDojPractitionersRepresentPartyForCase,
getPetitionerById,
isAssociatedUser,
isUserPartOfGroup,
Expand Down Expand Up @@ -93,6 +94,9 @@ export const decorateForCaseStatus = (caseRecord: RawCase) => {
caseRecord.canAllowPrintableDocketRecord =
canAllowPrintableDocketRecord(caseRecord);

caseRecord.canDojPractitionersRepresentParty =
canDojPractitionersRepresentPartyForCase(caseRecord);

return caseRecord;
};

Expand Down
30 changes: 30 additions & 0 deletions shared/src/test/mockUsers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,36 @@ export const irsPractitionerUser: RawIrsPractitioner = {
userId: 'f7d90c05-f6cd-442c-a168-202db587f16f',
};

export const dojPractitionerUser: RawPractitioner = {
admissionsDate: '',
admissionsStatus: '',
barNumber: 'BN2345',
birthYear: '',
contact: {
address1: '234 Main St',
address2: 'Apartment 4',
address3: 'Under the stairs',
city: 'Chicago',
country: COUNTRY_TYPES.DOMESTIC,
countryType: COUNTRY_TYPES.DOMESTIC,
phone: '+1 (555) 555-5555',
postalCode: '61234',
state: 'IL',
},
email: '[email protected]',
entityName: 'Practitioner',
firstName: '',
lastName: '',
name: 'DOJ Practitioner',
originalBarState: '',
practiceType: 'DOJ',
practitionerType: '',
role: ROLES.irsPractitioner,
section: ROLES.irsPractitioner,
serviceIndicator: SERVICE_INDICATOR_TYPES.SI_PAPER,
userId: 'f7d90c05-f6cd-442c-a168-202db587f16f',
};

export const irsSuperuserUser = {
name: 'IRS Superuser',
role: ROLES.irsSuperuser,
Expand Down
Loading
Loading