Skip to content

Commit

Permalink
10464-bug: do not allow unserved, stricken, or undocketed documents t…
Browse files Browse the repository at this point in the history
…o be selectable in selectDocumentTypeHelper.ts
  • Loading branch information
Mwindo committed Aug 15, 2024
1 parent d6c13e6 commit 4c68083
Show file tree
Hide file tree
Showing 3 changed files with 186 additions and 31 deletions.
189 changes: 167 additions & 22 deletions web-client/src/presenter/computeds/selectDocumentTypeHelper.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ import {
MAX_TITLE_LENGTH,
getOptionsForCategory,
getOrdinalValuesForUploadIteration,
getPreviouslyFiledDocuments,
getValidPreviouslyFiledDocuments,
} from './selectDocumentTypeHelper';
import { MOCK_CASE } from '../../../../shared/src/test/mockCase';
import { MOCK_DOCUMENTS } from '@shared/test/mockDocketEntry';
import { applicationContextForClient as applicationContext } from '@web-client/test/createClientTestApplicationContext';

describe('selectDocumentTypeHelper', () => {
Expand Down Expand Up @@ -48,16 +49,28 @@ describe('selectDocumentTypeHelper', () => {
scenario: 'Nonstandard A',
};

const mockDocuments = MOCK_DOCUMENTS.map(d => {
return {
...d,
isOnDocketRecord: true,
isStricken: false,
servedAt: '2019-08-25T05:00:00.000Z',
};
});

const result = getOptionsForCategory({
applicationContext,
caseDetail: MOCK_CASE,
caseDetail: {
...MOCK_CASE,
docketEntries: mockDocuments,
},
categoryInformation: mockCategoryInformation,
selectedDocketEntryId: mockSelectedDocketEntryId,
});

expect(result).toEqual({
expect(result).toMatchObject({
previousDocumentSelectLabel: 'Which document are you objecting to?',
previouslyFiledDocuments: MOCK_CASE.docketEntries.filter(
previouslyFiledDocuments: mockDocuments.filter(
d => d.eventCode !== INITIAL_DOCUMENT_TYPES.stin.eventCode,
),
showNonstandardForm: true,
Expand Down Expand Up @@ -92,17 +105,29 @@ describe('selectDocumentTypeHelper', () => {
scenario: 'Nonstandard C',
};

const mockDocuments = MOCK_DOCUMENTS.map(d => {
return {
...d,
isOnDocketRecord: true,
isStricken: false,
servedAt: '2019-08-25T05:00:00.000Z',
};
});

const result = getOptionsForCategory({
applicationContext,
caseDetail: MOCK_CASE,
caseDetail: {
...MOCK_CASE,
docketEntries: mockDocuments,
},
categoryInformation: mockCategoryInformation,
selectedDocketEntryId: mockSelectedDocketEntryId,
});

expect(result).toEqual({
expect(result).toMatchObject({
previousDocumentSelectLabel:
'Which document is this affidavit in support of?',
previouslyFiledDocuments: MOCK_CASE.docketEntries.filter(
previouslyFiledDocuments: mockDocuments.filter(
d => d.eventCode !== INITIAL_DOCUMENT_TYPES.stin.eventCode,
),
showNonstandardForm: true,
Expand All @@ -119,17 +144,29 @@ describe('selectDocumentTypeHelper', () => {
scenario: 'Nonstandard D',
};

const mockDocuments = MOCK_DOCUMENTS.map(d => {
return {
...d,
isOnDocketRecord: true,
isStricken: false,
servedAt: '2019-08-25T05:00:00.000Z',
};
});

const result = getOptionsForCategory({
applicationContext,
caseDetail: MOCK_CASE,
caseDetail: {
...MOCK_CASE,
docketEntries: mockDocuments,
},
categoryInformation: mockCategoryInformation,
selectedDocketEntryId: mockSelectedDocketEntryId,
});

expect(result).toEqual({
expect(result).toMatchObject({
previousDocumentSelectLabel:
'Which document is this Certificate of Service for?',
previouslyFiledDocuments: MOCK_CASE.docketEntries.filter(
previouslyFiledDocuments: mockDocuments.filter(
d => d.eventCode !== INITIAL_DOCUMENT_TYPES.stin.eventCode,
),
showDateFields: true,
Expand Down Expand Up @@ -165,17 +202,29 @@ describe('selectDocumentTypeHelper', () => {
scenario: 'Nonstandard F',
};

const mockDocuments = MOCK_DOCUMENTS.map(d => {
return {
...d,
isOnDocketRecord: true,
isStricken: false,
servedAt: '2019-08-25T05:00:00.000Z',
};
});

const result = getOptionsForCategory({
applicationContext,
caseDetail: MOCK_CASE,
caseDetail: {
...MOCK_CASE,
docketEntries: mockDocuments,
},
categoryInformation: mockCategoryInformation,
selectedDocketEntryId: mockSelectedDocketEntryId,
});

expect(result).toEqual({
expect(result).toMatchObject({
ordinalField: 'What iteration is this filing?',
previousDocumentSelectLabel: 'Which document is this a supplement to?',
previouslyFiledDocuments: MOCK_CASE.docketEntries.filter(
previouslyFiledDocuments: mockDocuments.filter(
d => d.eventCode !== INITIAL_DOCUMENT_TYPES.stin.eventCode,
),
showNonstandardForm: true,
Expand Down Expand Up @@ -292,22 +341,28 @@ describe('selectDocumentTypeHelper', () => {
});
});

describe('getPreviouslyFiledDocuments', () => {
describe('getValidPreviouslyFiledDocuments', () => {
it('should return a list of docketEntries with STIN filtered out', () => {
const mockCaseDetail = {
docketEntries: [
{
docketEntryId: '',
documentType: INITIAL_DOCUMENT_TYPES.stin.documentType,
isOnDocketRecord: true,
isStricken: false,
servedAt: '2019-08-25T05:00:00.000Z',
},
{
docketEntryId: '',
documentType: INITIAL_DOCUMENT_TYPES.petition.documentType,
isOnDocketRecord: true,
isStricken: false,
servedAt: '2019-08-25T05:00:00.000Z',
},
],
};

const result = getPreviouslyFiledDocuments(
const result = getValidPreviouslyFiledDocuments(
applicationContext,
mockCaseDetail,
undefined,
Expand All @@ -328,15 +383,21 @@ describe('selectDocumentTypeHelper', () => {
documentType:
INITIAL_DOCUMENT_TYPES.applicationForWaiverOfFilingFee
.documentType,
isOnDocketRecord: true,
isStricken: false,
servedAt: '2019-08-25T05:00:00.000Z',
},
{
docketEntryId: mockSelectedDocketEntryId,
documentType: INITIAL_DOCUMENT_TYPES.petition.documentType,
isOnDocketRecord: true,
isStricken: false,
servedAt: '2019-08-25T05:00:00.000Z',
},
],
};

const result = getPreviouslyFiledDocuments(
const result = getValidPreviouslyFiledDocuments(
applicationContext,
mockCaseDetail,
mockSelectedDocketEntryId,
Expand All @@ -354,18 +415,24 @@ describe('selectDocumentTypeHelper', () => {
docketEntryId: '3913f8a9-891a-4c9c-827e-1a02b403fa63',
documentTitle: 'Exhibit(s)',
documentType: 'Exhibit(s)',
isOnDocketRecord: true,
isStricken: false,
servedAt: '2019-08-25T05:00:00.000Z',
};

const mockCaseDetail = {
docketEntries: [
mockExhibit,
{
docketEntryId: mockSelectedDocketEntryId,
isOnDocketRecord: true,
isStricken: false,
servedAt: '2019-08-25T05:00:00.000Z',
},
],
};

const result = getPreviouslyFiledDocuments(
const result = getValidPreviouslyFiledDocuments(
applicationContext,
mockCaseDetail,
mockSelectedDocketEntryId,
Expand All @@ -377,7 +444,7 @@ describe('selectDocumentTypeHelper', () => {
expect(
applicationContext.getUtilities().getDocumentTitleWithAdditionalInfo
.mock.calls[0][0],
).toEqual({ docketEntry: mockExhibit });
).toMatchObject({ docketEntry: mockExhibit });
expect(result[0].documentTitle).toEqual('Exhibit(s) First');
});

Expand All @@ -394,18 +461,24 @@ describe('selectDocumentTypeHelper', () => {
docketEntryId: '3913f8a9-891a-4c9c-827e-1a02b403fa63',
documentTitle: 'Exhibit(s)',
documentType: 'Exhibit(s)',
isOnDocketRecord: true,
isStricken: false,
servedAt: '2019-08-25T05:00:00.000Z',
};

const mockCaseDetail = {
docketEntries: [
mockExhibit,
{
docketEntryId: mockSelectedDocketEntryId,
isOnDocketRecord: true,
isStricken: false,
servedAt: '2019-08-25T05:00:00.000Z',
},
],
};

const result = getPreviouslyFiledDocuments(
const result = getValidPreviouslyFiledDocuments(
applicationContext,
mockCaseDetail,
mockSelectedDocketEntryId,
Expand All @@ -417,7 +490,7 @@ describe('selectDocumentTypeHelper', () => {
expect(
applicationContext.getUtilities().getDocumentTitleWithAdditionalInfo
.mock.calls[0][0],
).toEqual({ docketEntry: mockExhibit });
).toMatchObject({ docketEntry: mockExhibit });
expect(result[0].documentTitle.length).toBe(MAX_TITLE_LENGTH);
expect(result[0].documentTitle).toEqual(
"MOTION FOR PROTECTIVE ORDER PURSUANT TO RULE 103 REGARDING RESPONDING TO RESP'S INTERROGATORIES & R…",
Expand All @@ -435,18 +508,24 @@ describe('selectDocumentTypeHelper', () => {
docketEntryId: '3913f8a9-891a-4c9c-827e-1a02b403fa63',
documentTitle: 'Exhibit(s)',
documentType: 'Exhibit(s)',
isOnDocketRecord: true,
isStricken: false,
servedAt: '2019-08-25T05:00:00.000Z',
};

const mockCaseDetail = {
docketEntries: [
mockExhibit,
{
docketEntryId: mockSelectedDocketEntryId,
isOnDocketRecord: true,
isStricken: false,
servedAt: '2019-08-25T05:00:00.000Z',
},
],
};

const result = getPreviouslyFiledDocuments(
const result = getValidPreviouslyFiledDocuments(
applicationContext,
mockCaseDetail,
mockSelectedDocketEntryId,
Expand All @@ -458,8 +537,74 @@ describe('selectDocumentTypeHelper', () => {
expect(
applicationContext.getUtilities().getDocumentTitleWithAdditionalInfo
.mock.calls[0][0],
).toEqual({ docketEntry: mockExhibit });
).toMatchObject({ docketEntry: mockExhibit });
expect(result[0].documentTitle).toBeUndefined();
});

it('should not return unserved documents', () => {
const mockCaseDetail = {
docketEntries: [
{
docketEntryId: '',
documentType: INITIAL_DOCUMENT_TYPES.petition.documentType,
isOnDocketRecord: true,
isStricken: false,
servedAt: '',
},
],
};

const result = getValidPreviouslyFiledDocuments(
applicationContext,
mockCaseDetail,
undefined,
);

expect(result.length).toEqual(0);
});

it('should not return stricken documents', () => {
const mockCaseDetail = {
docketEntries: [
{
docketEntryId: '',
documentType: INITIAL_DOCUMENT_TYPES.petition.documentType,
isOnDocketRecord: true,
isStricken: true,
servedAt: '2019-08-25T05:00:00.000Z',
},
],
};

const result = getValidPreviouslyFiledDocuments(
applicationContext,
mockCaseDetail,
undefined,
);

expect(result.length).toEqual(0);
});

it('should not return documents that are not on the docket record', () => {
const mockCaseDetail = {
docketEntries: [
{
docketEntryId: '',
documentType: INITIAL_DOCUMENT_TYPES.petition.documentType,
isOnDocketRecord: false,
isStricken: false,
servedAt: '2019-08-25T05:00:00.000Z',
},
],
};

const result = getValidPreviouslyFiledDocuments(
applicationContext,
mockCaseDetail,
undefined,
);

expect(result.length).toEqual(0);
});
});
});
Loading

0 comments on commit 4c68083

Please sign in to comment.