Skip to content

Commit

Permalink
Merge branch '10049-display-wip-cav-submitted-cases' of https://githu…
Browse files Browse the repository at this point in the history
…b.com/flexion/ef-cms into 10049-display-wip-cav-submitted-cases
  • Loading branch information
Absolutestunna committed Sep 14, 2023
2 parents 0be92d4 + 183d15e commit 1eef980
Show file tree
Hide file tree
Showing 71 changed files with 1,267 additions and 615 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { navigateTo as navigateToDashboard } from '../support/pages/dashboard';

describe('Private practitioner mobile', () => {
beforeEach(() => {
cy.viewport('iphone-6');
});

it('should have access to case, order, and opinion advanced searches (and NOT practitioner advanced search)', () => {
navigateToDashboard('privatePractitioner');

cy.get('[data-test="advanced-search-link"]').click();

cy.get('[data-test="advanced-search-type-mobile-selector"]')
.children()
.then(options => {
const actualAdvancedSearchOptions: string[] = [...options].map(
o => o.innerText,
);

const expectedAdvancedSearchOptions = ['Case', 'Order', 'Opinion'];
expect(actualAdvancedSearchOptions).to.deep.eq(
expectedAdvancedSearchOptions,
);
});
});
});
6 changes: 6 additions & 0 deletions cypress/cypress-integration/support/pages/document-qc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ export const uploadCourtIssuedDocumentAndEditViaDocumentQC = attempt => {
const freeText = `court document ${attempt}`;
cy.get('#upload-description').clear().type(freeText);
cy.get('input#primary-document-file').attachFile('../fixtures/w3-dummy.pdf');

// Fix flaky test
// https://github.com/flexion/ef-cms/issues/10144
// eslint-disable-next-line cypress/no-unnecessary-waiting
cy.wait(0);

cy.get('#save-uploaded-pdf-button').click();
cy.get('#add-court-issued-docket-entry-button').click();
cy.get('#document-type .select-react-element__input-container input')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,10 @@ describe('Docket Clerk', () => {

// in its own step for retry purposes - sometimes the click fails
it('should click the save uploaded PDF button', () => {
// Fix flaky test
// https://github.com/flexion/ef-cms/issues/10144
// eslint-disable-next-line cypress/no-unnecessary-waiting
cy.wait(0);
clickSaveUploadedPdfButton();
});

Expand Down
7 changes: 7 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@
"@types/aws-lambda": "^8.10.119",
"@types/jest": "^29.5.4",
"@types/lodash": "^4.14.197",
"@types/luxon": "^3.3.0",
"@types/node": "^20.5.7",
"@types/promise-retry": "^1.1.3",
"@types/react": "^18.2.21",
Expand Down
13 changes: 13 additions & 0 deletions scripts/dynamo/setup-use-change-of-address-lambda-flag.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash -e

# Sets the redaction acknowledgement enabled feature flag to "false" in the dynamo deploy table

# Usage
# ENV=dev ./setup-redaction-acknowledgement-enabled-flag.sh

./check-env-variables.sh \
"ENV" \
"AWS_SECRET_ACCESS_KEY" \
"AWS_ACCESS_KEY_ID"

aws dynamodb put-item --region us-east-1 --table-name "efcms-deploy-${ENV}" --item '{"pk":{"S":"use-change-of-address-lambda"},"sk":{"S":"use-change-of-address-lambda"},"current":{"BOOL":true}}'
5 changes: 5 additions & 0 deletions shared/src/business/entities/EntityConstants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,11 @@ export const ALLOWLIST_FEATURE_FLAGS = {
disabledMessage: 'Currently using legacy trial status types.',
key: 'updated-trial-status-types',
},
USE_CHANGE_OF_ADDRESS_LAMBDA: {
disabledMessage:
'A flag to know when to use the change of address lambda for processing.',
key: 'use-change-of-address-lambda',
},
USE_EXTERNAL_PDF_GENERATION: {
disabledMessage:
'A flag to tell the code to directly generation pdfs or to do in an external lambda.',
Expand Down
4 changes: 2 additions & 2 deletions shared/src/business/entities/Practitioner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ import { User } from './User';
import joi from 'joi';

export class Practitioner extends User {
public additionalPhone: string;
public additionalPhone?: string;
public admissionsDate: string;
public admissionsStatus: string;
public barNumber: string;
public birthYear: string;
public confirmEmail: string;
public confirmEmail?: string;
public employer: string;
public firmName: string;
public firstName: string;
Expand Down
4 changes: 4 additions & 0 deletions shared/src/business/test/createTestApplicationContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ import {
} from '../../../src/business/utilities/getFormattedJudgeName';
import { formatPhoneNumber } from '../../../src/business/utilities/formatPhoneNumber';
import { generateAndServeDocketEntry } from '../useCaseHelper/service/createChangeItems';
import { generateChangeOfAddressHelper } from '@shared/business/useCaseHelper/generateChangeOfAddressHelper';
import { generateNoticesForCaseTrialSessionCalendarInteractor } from '../useCases/trialSessions/generateNoticesForCaseTrialSessionCalendarInteractor';
import {
getAddressPhoneDiff,
Expand Down Expand Up @@ -378,6 +379,9 @@ export const createTestApplicationContext = ({ user } = {}) => {
generateAndServeDocketEntry: jest
.fn()
.mockImplementation(generateAndServeDocketEntry),
generateChangeOfAddressHelper: jest
.fn()
.mockImplementation(generateChangeOfAddressHelper),
getJudgeInSectionHelper: jest.fn(),
getUserIdForNote: jest.fn().mockImplementation(getUserIdForNote),
removeCounselFromRemovedPetitioner: jest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ export const removeCoversheet = async (
})
.promise());
} catch (err) {
err.message = `${err.message} docket entry id is ${docketEntryId}`;
throw err;
const error = err as Error;
error.message = `${error.message} docket entry id is ${docketEntryId}`;
throw error;
}

const { PDFDocument } = await applicationContext.getPdfLib();
Expand Down
196 changes: 196 additions & 0 deletions shared/src/business/useCaseHelper/generateChangeOfAddressHelper.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,196 @@
import { Case } from '@shared/business/entities/cases/Case';
import { Practitioner } from '../entities/Practitioner';
import {
ROLES,
SERVICE_INDICATOR_TYPES,
} from '@shared/business/entities/EntityConstants';
import { TUserContact } from '@shared/business/useCases/users/generateChangeOfAddress';
import { aggregatePartiesForService } from '@shared/business/utilities/aggregatePartiesForService';
import { clone } from 'lodash';
import { generateAndServeDocketEntry } from '@shared/business/useCaseHelper/service/createChangeItems';

/**
* generateChangeOfAddressHelper
*
* @param {object} applicationContext the application context
* @param {string} providers.deadlineDate the date of the deadline to generated
* @param {string} providers.description the description of the deadline
* @param {Case} providers.subjectCaseEntity the subjectCaseEntity
*/
export const generateChangeOfAddressHelper = async ({
applicationContext,
bypassDocketEntry,
contactInfo,
docketNumber,
firmName,
jobId,
requestUserId,
updatedEmail,
updatedName,
user,
websocketMessagePrefix,
}: {
applicationContext: IApplicationContext;
docketNumber: string;
bypassDocketEntry: boolean;
contactInfo: TUserContact;
firmName: string;
updatedEmail?: string;
updatedName?: string;
jobId: string;
user: RawPractitioner;
requestUserId?: string;
websocketMessagePrefix: string;
}) => {
try {
const newData = contactInfo;

const userCase = await applicationContext
.getPersistenceGateway()
.getCaseByDocketNumber({
applicationContext,
docketNumber,
});
let caseEntity = new Case(userCase, { applicationContext });

const practitionerName = updatedName || user.name;
const practitionerObject = caseEntity.privatePractitioners
.concat(caseEntity.irsPractitioners)
.find(practitioner => practitioner.userId === user.userId);

if (!practitionerObject) {
throw new Error(
`Could not find user|${user.userId} barNumber: ${user.barNumber} on ${docketNumber}`,
);
}

const oldData = clone(practitionerObject.contact);

// This updates the case by reference!
practitionerObject.contact = contactInfo;
practitionerObject.firmName = firmName;
practitionerObject.name = practitionerName;

if (!oldData.email && updatedEmail) {
practitionerObject.serviceIndicator =
SERVICE_INDICATOR_TYPES.SI_ELECTRONIC;
practitionerObject.email = updatedEmail;
}

if (!bypassDocketEntry && caseEntity.shouldGenerateNoticesForCase()) {
await prepareToGenerateAndServeDocketEntry({
applicationContext,
caseEntity,
newData,
oldData,
practitionerName,
user,
});
}

await applicationContext.getUseCaseHelpers().updateCaseAndAssociations({
applicationContext,
caseToUpdate: caseEntity,
});
} catch (error) {
applicationContext.logger.error(error);
}

await applicationContext.getNotificationGateway().sendNotificationToUser({
applicationContext,
message: {
action: `${websocketMessagePrefix}_contact_update_progress`,
},
userId: requestUserId || user.userId,
});

const updatedJob = await applicationContext
.getPersistenceGateway()
.setChangeOfAddressCaseAsDone({ applicationContext, docketNumber, jobId });

const isDoneProcessing = updatedJob.remaining === 0;

if (isDoneProcessing) {
applicationContext.logger.info(
`"change-of-address-job|${jobId}" job finished`,
);

if (websocketMessagePrefix === 'user') {
const userEntity = new Practitioner({
...user,
isUpdatingInformation: false,
});

await applicationContext.getPersistenceGateway().updateUser({
applicationContext,
user: userEntity.validate().toRawObject(),
});
}

await applicationContext.getNotificationGateway().sendNotificationToUser({
applicationContext,
message: {
action: `${websocketMessagePrefix}_contact_full_update_complete`,
},
userId: requestUserId || user.userId,
});
}
};

/**
* This function prepares data to be passed to generateAndServeDocketEntry
*
* @param {object} providers the providers object
* @param {object} providers.applicationContext the application context
* @param {object} providers.caseEntity the instantiated Case class
* @param {object} providers.newData the new practitioner contact information
* @param {object} providers.oldData the old practitioner contact information (for comparison)
* @param {object} providers.practitionerName the name of the practitioner
* @param {object} providers.user the user object that includes userId, barNumber etc.
* @returns {Promise<*>} resolves upon completion of docket entry service
*/
const prepareToGenerateAndServeDocketEntry = async ({
applicationContext,
caseEntity,
newData,
oldData,
practitionerName,
user,
}) => {
const documentType = applicationContext
.getUtilities()
.getDocumentTypeForAddressChange({
newData,
oldData,
});

if (!documentType) return;

const servedParties = aggregatePartiesForService(caseEntity);

const docketMeta = {} as any;
if (user.role === ROLES.privatePractitioner) {
docketMeta.privatePractitioners = [
{
name: practitionerName,
},
];
} else if (user.role === ROLES.irsPractitioner) {
docketMeta.partyIrsPractitioner = true;
}

newData.name = practitionerName;
const { changeOfAddressDocketEntry } = await generateAndServeDocketEntry({
applicationContext,
barNumber: user.barNumber,
caseEntity,
docketMeta,
documentType,
newData,
oldData,
servedParties,
user,
});

caseEntity.updateDocketEntry(changeOfAddressDocketEntry);
};
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ export const generatePdfFromHtmlHelper = async (
}: {
contentHtml: string;
displayHeaderFooter: boolean;
docketNumber: string;
footerHtml: string;
headerHtml: string;
overwriteFooter: string;
docketNumber?: string;
footerHtml?: string;
headerHtml?: string;
overwriteFooter?: string;
},
) => {
let browser: Browser | undefined;
Expand Down
1 change: 1 addition & 0 deletions shared/src/business/useCases/addCoverToPdf.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Case } from '../entities/cases/Case';
import { DocketEntry } from '../entities/DocketEntry';
import { generateCoverSheetData } from './generateCoverSheetData';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ describe('checkForReadyForTrialCasesInteractor', () => {
).not.toHaveBeenCalled();
});

it("should update cases to 'ready for trial' that meet requirements", async () => {
it("should update cases to 'ready for trial' that meet requirements, removing duplicate cases before updating", async () => {
/**
* Requirements:
* 1. Case has status 'General Docket - Not at Issue'
Expand All @@ -123,6 +123,8 @@ describe('checkForReadyForTrialCasesInteractor', () => {
applicationContext
.getPersistenceGateway()
.getReadyForTrialCases.mockReturnValue([
{ docketNumber: '101-20' },
{ docketNumber: '101-20' },
{ docketNumber: '101-20' },
{ docketNumber: '320-21' },
]);
Expand Down
Loading

0 comments on commit 1eef980

Please sign in to comment.