Skip to content

Commit

Permalink
Merge branch 'staging' of github.com:ustaxcourt/ef-cms into 9970-story
Browse files Browse the repository at this point in the history
  • Loading branch information
Zachary Rogers committed Jul 6, 2023
2 parents e52647a + 0dd85f8 commit ab25f6c
Show file tree
Hide file tree
Showing 31 changed files with 962 additions and 932 deletions.
2 changes: 1 addition & 1 deletion shared/jest-shared.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const config: Config = {
'!src/persistence/sqs/getMessages.ts',
'!src/persistence/messages/*.ts',
'!src/persistence/dynamo/**/*.ts',
'!src/business/utilities/documentGenerators/*.ts',
'!src/business/utilities/documentGenerators/**/*.ts',
],
coverageDirectory: './coverage',
coverageProvider: 'babel',
Expand Down
10 changes: 4 additions & 6 deletions shared/src/business/entities/ReconciliationReportEntry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@ import { DOCKET_ENTRY_VALIDATION_RULES } from './EntityValidationConstants';
import { JoiValidationEntity } from './JoiValidationEntity';
import { pick } from 'lodash';

/**
* constructor
*
* @param {object} rawDocketEntry the raw docket entry data
* @constructor
*/
export class ReconciliationReportEntry extends JoiValidationEntity {
public caseCaption: string;
public docketEntryId: string;
Expand All @@ -23,6 +17,7 @@ export class ReconciliationReportEntry extends JoiValidationEntity {

constructor(rawDocketEntry) {
super('ReconciliationReportEntry');

this.caseCaption = rawDocketEntry.caseCaption;
this.docketEntryId = rawDocketEntry.docketEntryId;
this.docketNumber = rawDocketEntry.docketNumber;
Expand Down Expand Up @@ -56,3 +51,6 @@ export class ReconciliationReportEntry extends JoiValidationEntity {
return {};
}
}

export type RawReconciliationReportEntry =
ExcludeMethods<ReconciliationReportEntry>;
12 changes: 7 additions & 5 deletions shared/src/business/entities/cases/PublicCase.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,14 @@ import { PublicCase } from './PublicCase';
import { applicationContext } from '../../test/createTestApplicationContext';
import { getContactSecondary } from './Case';

const mockContactId = 'b430f7f9-06f3-4a25-915d-5f51adab2f29';
const mockContactIdSecond = '39a359e9-dde3-409e-b40e-77a4959b6f2c';
describe('PublicCase', () => {
const mockContactId = 'b430f7f9-06f3-4a25-915d-5f51adab2f29';
const mockContactIdSecond = '39a359e9-dde3-409e-b40e-77a4959b6f2c';

it('should throw an error when applicationContext is not provided to the constructor', () => {
expect(() => new PublicCase({}, {} as any)).toThrow(TypeError);
});

describe('validation', () => {
it('should validate when all information is provided and case is not sealed', () => {
const entity = new PublicCase(
Expand Down Expand Up @@ -337,7 +342,6 @@ describe('PublicCase', () => {
const entity = new PublicCase(rawCase, { applicationContext });

expect(entity.irsPractitioners).toBeUndefined();
expect(entity.otherFilers).toBeUndefined();
expect(entity.privatePractitioners).toBeUndefined();
expect(entity.leadDocketNumber).toBeUndefined();
});
Expand Down Expand Up @@ -545,7 +549,6 @@ describe('PublicCase', () => {
const entity = new PublicCase(rawCase, { applicationContext });

expect(entity.irsPractitioners).toBeUndefined();
expect(entity.otherFilers).toBeUndefined();
expect(entity.privatePractitioners).toBeUndefined();
});
});
Expand Down Expand Up @@ -586,7 +589,6 @@ describe('PublicCase', () => {
const entity = new PublicCase(rawCase, { applicationContext });

expect(entity.irsPractitioners).toBeDefined();
expect(entity.otherFilers).toBeUndefined();
expect(entity.privatePractitioners).toBeDefined();
expect(entity.leadDocketNumber).toBeDefined();
});
Expand Down
2 changes: 2 additions & 0 deletions shared/src/business/entities/cases/PublicCase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export class PublicCase extends JoiValidationEntity {
public petitioners: any[] | undefined;
public irsPractitioners?: any[];
public privatePractitioners: any;

private _score?: string;

constructor(
Expand All @@ -53,6 +54,7 @@ export class PublicCase extends JoiValidationEntity {
if (!applicationContext) {
throw new TypeError('applicationContext must be defined');
}

this.entityName = 'PublicCase';
this.canAllowDocumentService = rawCase.canAllowDocumentService;
this.canAllowPrintableDocketRecord = rawCase.canAllowPrintableDocketRecord;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,10 @@ function DocketEntryFactory(rawProps) {
};

const exDoc = ExternalDocumentFactory(rawProps);
const docketEntryExternalDocumentSchema = exDoc.getSchema();
const rules = exDoc.getValidationRules();
const docketEntryExternalDocumentSchema = rules.validate
? rules
: joi.object().keys(rules);

schema = schema.concat(docketEntryExternalDocumentSchema).concat(
joi.object({
Expand Down
154 changes: 138 additions & 16 deletions shared/src/business/entities/externalDocument/ExternalDocumentBase.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,138 @@
const { JoiValidationConstants } = require('../JoiValidationConstants');

const externalDocumentDecorator = (obj, rawObj) => {
obj.category = rawObj.category;
obj.documentTitle = rawObj.documentTitle;
obj.documentType = rawObj.documentType;
};

const baseExternalDocumentValidation = {
category: JoiValidationConstants.STRING.required(),
documentTitle: JoiValidationConstants.DOCUMENT_TITLE.optional(),
documentType: JoiValidationConstants.STRING.required(),
};

exports.externalDocumentDecorator = externalDocumentDecorator;
exports.baseExternalDocumentValidation = baseExternalDocumentValidation;
import { JoiValidationConstants } from '../JoiValidationConstants';
import { JoiValidationEntity } from '../JoiValidationEntity';
import { MAX_FILE_SIZE_MB } from '../EntityConstants';

export class ExternalDocumentBase extends JoiValidationEntity {
public category: string;
public documentTitle?: string;
public documentType: string;

constructor(rawProps, scenario: string) {
super(scenario);

this.category = rawProps.category;
this.documentTitle = rawProps.documentTitle;
this.documentType = rawProps.documentType;
}

static VALIDATION_RULES = {
category: JoiValidationConstants.STRING.required(),
documentTitle: JoiValidationConstants.DOCUMENT_TITLE.optional(),
documentType: JoiValidationConstants.STRING.required(),
};

static VALIDATION_ERROR_MESSAGES = {
additionalInfo: [
{
contains: 'must be less than or equal to',
message: 'Limit is 500 characters. Enter 500 or fewer characters.',
},
],
additionalInfo2: [
{
contains: 'must be less than or equal to',
message: 'Limit is 500 characters. Enter 500 or fewer characters.',
},
],
attachments: 'Enter selection for Attachments.',
category: 'Select a Category.',
certificateOfService:
'Indicate whether you are including a Certificate of Service',
certificateOfServiceDate: [
{
contains: 'must be less than or equal to',
message:
'Certificate of Service date cannot be in the future. Enter a valid date.',
},
'Enter date of service',
],
documentTitle:
'Document title must be 3000 characters or fewer. Update this document title and try again.',
documentType: [
{
contains: 'contains an invalid value',
message:
'Proposed Stipulated Decision must be filed separately in each case',
},
'Select a document type',
],
filers: 'Select a filing party',
freeText: [
{ contains: 'is required', message: 'Provide an answer' },
{
contains: 'must be less than or equal to',
message: 'Limit is 1000 characters. Enter 1000 or fewer characters.',
},
],
freeText2: [
{ contains: 'is required', message: 'Provide an answer' },
{
contains: 'must be less than or equal to',
message: 'Limit is 1000 characters. Enter 1000 or fewer characters.',
},
],
hasSecondarySupportingDocuments:
'Enter selection for Secondary Supporting Documents.',
hasSupportingDocuments: 'Enter selection for Supporting Documents.',
objections: 'Enter selection for Objections.',
ordinalValue: 'Select an iteration',
otherIteration: [
{
contains: 'is required',
message: 'Enter an iteration number.',
},
'Maximum iteration value is 999.',
],
partyIrsPractitioner: 'Select a filing party',
previousDocument: 'Select a document',
primaryDocumentFile: 'Upload a document',
primaryDocumentFileSize: [
{
contains: 'must be less than or equal to',
message: `Your Primary Document file size is too big. The maximum file size is ${MAX_FILE_SIZE_MB}MB.`,
},
'Your Primary Document file size is empty.',
],
secondaryDocument: 'Select a document',
secondaryDocumentFile: 'Upload a document',
secondaryDocumentFileSize: [
{
contains: 'must be less than or equal to',
message: `Your Secondary Document file size is too big. The maximum file size is ${MAX_FILE_SIZE_MB}MB.`,
},
'Your Secondary Document file size is empty.',
],
serviceDate: [
{
contains: 'must be less than or equal to',
message: 'Service date cannot be in the future. Enter a valid date.',
},
'Provide a service date',
],
supportingDocument: 'Select a document type',
supportingDocumentFile: 'Upload a document',
supportingDocumentFileSize: [
{
contains: 'must be less than or equal to',
message: `Your Supporting Document file size is too big. The maximum file size is ${MAX_FILE_SIZE_MB}MB.`,
},
'Your Supporting Document file size is empty.',
],
supportingDocumentFreeText: 'Enter name',
trialLocation: 'Select a preferred trial location.',
} as const;

getValidationRules() {
return ExternalDocumentBase.VALIDATION_RULES;
}

getErrorToMessageMap(): any {
return ExternalDocumentBase.VALIDATION_ERROR_MESSAGES;
}

getDocumentTitle() {
return this.documentTitle!;
}
}

export type RawExternalDocumentBase = ExcludeMethods<ExternalDocumentBase>;
Original file line number Diff line number Diff line change
@@ -1,44 +1,22 @@
const {
ExternalDocumentNonStandardA,
} = require('./ExternalDocumentNonStandardA');
const {
ExternalDocumentNonStandardB,
} = require('./ExternalDocumentNonStandardB');
const {
ExternalDocumentNonStandardC,
} = require('./ExternalDocumentNonStandardC');
const {
ExternalDocumentNonStandardD,
} = require('./ExternalDocumentNonStandardD');
const {
ExternalDocumentNonStandardE,
} = require('./ExternalDocumentNonStandardE');
const {
ExternalDocumentNonStandardF,
} = require('./ExternalDocumentNonStandardF');
const {
ExternalDocumentNonStandardG,
} = require('./ExternalDocumentNonStandardG');
const {
ExternalDocumentNonStandardH,
} = require('./ExternalDocumentNonStandardH');
const {
ExternalDocumentNonStandardI,
} = require('./ExternalDocumentNonStandardI');
const {
ExternalDocumentNonStandardJ,
} = require('./ExternalDocumentNonStandardJ');
const { ExternalDocumentStandard } = require('./ExternalDocumentStandard');
import { ExternalDocumentBase } from './ExternalDocumentBase';
import { ExternalDocumentNonStandardA } from './ExternalDocumentNonStandardA';
import { ExternalDocumentNonStandardB } from './ExternalDocumentNonStandardB';
import { ExternalDocumentNonStandardC } from './ExternalDocumentNonStandardC';
import { ExternalDocumentNonStandardD } from './ExternalDocumentNonStandardD';
import { ExternalDocumentNonStandardE } from './ExternalDocumentNonStandardE';
import { ExternalDocumentNonStandardF } from './ExternalDocumentNonStandardF';
import { ExternalDocumentNonStandardG } from './ExternalDocumentNonStandardG';
import { ExternalDocumentNonStandardH } from './ExternalDocumentNonStandardH';
import { ExternalDocumentNonStandardI } from './ExternalDocumentNonStandardI';
import { ExternalDocumentNonStandardJ } from './ExternalDocumentNonStandardJ';
import { ExternalDocumentStandard } from './ExternalDocumentStandard';

/**
* External Document Factory entity
*
* @param {object} documentMetadata the document metadata
* @constructor
*/
function ExternalDocumentFactory(documentMetadata) {
export function ExternalDocumentFactory(
documentMetadata,
): ExternalDocumentBase {
if (documentMetadata && documentMetadata.scenario) {
const scenario = documentMetadata.scenario.toLowerCase().trim();

switch (scenario) {
case 'nonstandard a':
return new ExternalDocumentNonStandardA(documentMetadata);
Expand All @@ -55,19 +33,13 @@ function ExternalDocumentFactory(documentMetadata) {
case 'nonstandard g':
return new ExternalDocumentNonStandardG(documentMetadata);
case 'nonstandard h':
return new ExternalDocumentNonStandardH(
documentMetadata,
ExternalDocumentFactory,
);
return new ExternalDocumentNonStandardH(documentMetadata);
case 'nonstandard i':
return new ExternalDocumentNonStandardI(documentMetadata);
case 'nonstandard j':
return new ExternalDocumentNonStandardJ(documentMetadata);
}
}

// standard - default
return new ExternalDocumentStandard(documentMetadata);
}

module.exports = { ExternalDocumentFactory };
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
const {
calculateISODate,
createISODateString,
} = require('../../utilities/DateHandler');
const {
import {
ExternalDocumentInformationFactory,
VALIDATION_ERROR_MESSAGES,
} = require('./ExternalDocumentInformationFactory');
const { OBJECTIONS_OPTIONS_MAP } = require('../EntityConstants');
} from './ExternalDocumentInformationFactory';
import { OBJECTIONS_OPTIONS_MAP } from '../EntityConstants';
import {
calculateISODate,
createISODateString,
} from '../../utilities/DateHandler';

describe('ExternalDocumentInformationFactory', () => {
let baseDoc;
Expand Down
Loading

0 comments on commit ab25f6c

Please sign in to comment.