Skip to content

Commit

Permalink
Merge branch 'staging' of github.com:ustaxcourt/ef-cms into 10285-des…
Browse files Browse the repository at this point in the history
…ign-debt
  • Loading branch information
btejha committed Dec 4, 2024
2 parents 15ba7bb + 409cb62 commit bb44c92
Show file tree
Hide file tree
Showing 13 changed files with 261 additions and 558 deletions.
7 changes: 6 additions & 1 deletion cypress/helpers/authentication/login-as-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,12 @@ export function loginAsDocketClerk() {
}

export function loginAsDocketClerk1() {
cy.login('docketclerk1');
login({ email: '[email protected]' });
cy.get('[data-testid="inbox-tab-content"]').should('exist');
}

export function loginAsClerkOfCourt() {
login({ email: '[email protected]' });
cy.get('[data-testid="inbox-tab-content"]').should('exist');
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,26 @@
import { attachFile } from '../../../../../../helpers/file/upload-file';
import { loginAsPetitioner } from '../../../../../../helpers/authentication/login-as-helpers';
import { createAndServePaperFiling } from '../../../../../../helpers/caseDetail/docketRecord/paperFiling/create-and-serve-paper-filing';
import { createAndServePaperPetition } from '../../../../../../helpers/fileAPetition/create-and-serve-paper-petition';
import {
createMessage,
enterSubject,
fillOutMessageField,
selectRecipient,
selectSection,
sendMessage,
} from '../../../../../support/pages/document-qc';
import { goToCase } from '../../../../../../helpers/caseDetail/go-to-case';
import {
loginAsClerkOfCourt,
loginAsDocketClerk1,
loginAsPetitioner,
} from '../../../../../../helpers/authentication/login-as-helpers';
import { petitionerCreatesElectronicCaseWithSpouse } from '../../../../../../helpers/fileAPetition/petitioner-creates-electronic-case';
import { petitionsClerkServesPetition } from '../../../../../../helpers/documentQC/petitionsclerk-serves-petition';
import { selectTypeaheadInput } from '../../../../../../helpers/components/typeAhead/select-typeahead-input';

describe('Judge`s chambers stamps an order', () => {
it('should create an order, serve it, and apply a stamp to it', () => {
it('should create an order, serve it, apply a stamp to it, then redirect to Drafts of case detail', () => {
loginAsPetitioner();
petitionerCreatesElectronicCaseWithSpouse().then(docketNumber => {
petitionsClerkServesPetition(docketNumber);
Expand Down Expand Up @@ -35,7 +50,8 @@ describe('Judge`s chambers stamps an order', () => {
);

// Apply a stamp
cy.login('colvinschambers', `case-detail/${docketNumber}`);
loginAsClerkOfCourt();
goToCase(docketNumber);
cy.get('[data-testid="document-viewer-link-M006"]').last().click();
cy.get('[data-testid="apply-stamp"]').click();
cy.get('[data-testid="status-report-or-stip-decision-due-date"]').click();
Expand Down Expand Up @@ -67,4 +83,44 @@ describe('Judge`s chambers stamps an order', () => {
);
});
});

it('should allow judge to stamp motion from Message View and redirect to MessageDetail', () => {
createAndServePaperPetition().then(({ docketNumber }) => {
loginAsDocketClerk1();
goToCase(docketNumber);
createAndServePaperFiling('Motion to Proceed Remotely', '01/01/2022');
cy.get(
'[data-testid="docket-record-table"] td:contains("Motion to Proceed Remotely")',
)
.parent()
.invoke('attr', 'data-testid')
.then(docketEntryId => {
createMessage();
selectSection('Clerk of the Court');
selectRecipient('Test Clerk of Court');
enterSubject();
fillOutMessageField();
cy.get('[data-testid="select-document"]').select(docketEntryId!);
sendMessage();
loginAsClerkOfCourt();
cy.get(
'.message-subject > .message-document-title > [data-testid="messages-individual-inbox-subject-cell"]',
)
.first()
.click();
cy.get('[data-testid="apply-stamp"]').click();
cy.get('[data-testid="motion-disposition-Granted"]').click();
cy.get('[data-testid="save-signature-button"]').click();
cy.get('[data-testid="success-alert"]').contains(
'Motion to Proceed Remotely stamped successfully.',
);
cy.get('.attachment-viewer-button')
.contains('Motion to Proceed Remotely')
.should('be.visible');
cy.get('.attachment-viewer-button')
.contains('Motion to Proceed Remotely GRANTED')
.should('be.visible');
});
});
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
import { attachFile } from '../../../../../../helpers/file/upload-file';
import { createAndServePaperFiling } from '../../../../../../helpers/caseDetail/docketRecord/paperFiling/create-and-serve-paper-filing';
import { createAndServePaperPetition } from '../../../../../../helpers/fileAPetition/create-and-serve-paper-petition';
import {
createMessage,
enterSubject,
fillOutMessageField,
selectChambers,
selectRecipient,
selectSection,
sendMessage,
} from '../../../../../support/pages/document-qc';
import { goToCase } from '../../../../../../helpers/caseDetail/go-to-case';
import {
loginAsColvin,
loginAsDocketClerk1,
loginAsPetitioner,
} from '../../../../../../helpers/authentication/login-as-helpers';
import { petitionerCreatesElectronicCaseWithSpouse } from '../../../../../../helpers/fileAPetition/petitioner-creates-electronic-case';
import { petitionsClerkServesPetition } from '../../../../../../helpers/documentQC/petitionsclerk-serves-petition';
import { selectTypeaheadInput } from '../../../../../../helpers/components/typeAhead/select-typeahead-input';

describe('Judge`s chambers stamps an order', () => {
it('should create an order, serve it, apply a stamp to it, then redirect to Drafts of case detail', () => {
loginAsPetitioner();
petitionerCreatesElectronicCaseWithSpouse().then(docketNumber => {
petitionsClerkServesPetition(docketNumber);

cy.login('docketclerk1', `case-detail/${docketNumber}`);

// File Motion for Continuance
cy.get('[data-testid="case-detail-menu-button"]').click();
cy.get('[data-testid="menu-button-add-paper-filing"]').click();
cy.get('input#date-received-picker').type('11/01/2023');
selectTypeaheadInput(
'primary-document-type-search',
'Motion for Continuance',
);
cy.get('[data-testid="filed-by-option"]').contains('Petitioner').click();
cy.get('[data-testid="upload-pdf-button"]').click();
attachFile({
filePath: '../../helpers/file/sample.pdf',
selector: 'input#primaryDocumentFile-file',
selectorToAwaitOnSuccess: '[data-testid="remove-pdf"]',
});
cy.get('[data-testid="save-and-serve"]').click();
cy.get('[data-testid="modal-button-confirm"]').click();
cy.get('.usa-alert').should(
'contain',
'Print and mail to complete paper service.',
);

// Apply a stamp
loginAsColvin();
cy.get('.message-document-title > [data-testid="message-header-link"]')
.first()
.click();
goToCase(docketNumber);
cy.get('[data-testid="document-viewer-link-M006"]').last().click();
cy.get('[data-testid="apply-stamp"]').click();
cy.get('[data-testid="status-report-or-stip-decision-due-date"]').click();
cy.get('input#due-date-input-statusReportDueDate-picker').type(
'11/02/2023',
);
cy.get('input#due-date-input-statusReportDueDate-picker').should(
'have.value',
'11/02/2023',
);
cy.get('[data-testid="clear-optional-fields"]').click();
cy.get('[data-testid="status-report-or-stip-decision-due-date"]').click();
cy.get('input#due-date-input-statusReportDueDate-picker').should(
'have.value',
'',
);

// Apply stamp
cy.get('[data-testid="clear-optional-fields"]').click();
cy.get('[data-testid="motion-disposition-Granted"]').click();
cy.get('[data-testid="save-signature-button"]').click();

// Make sure it's there
cy.get('[data-testid="success-alert"]').contains(
'Motion for Continuance stamped successfully.',
);
cy.get('[data-testid="docket-entry-description-1"]').contains(
'Motion for Continuance GRANTED',
);
});
});

it('should allow judge to stamp motion from Message View and redirect to MessageDetail', () => {
createAndServePaperPetition().then(({ docketNumber }) => {
loginAsDocketClerk1();
goToCase(docketNumber);
createAndServePaperFiling('Motion to Proceed Remotely', '01/01/2022');
cy.get(
'[data-testid="docket-record-table"] td:contains("Motion to Proceed Remotely")',
)
.parent()
.invoke('attr', 'data-testid')
.then(docketEntryId => {
createMessage();
selectSection('Chambers');
selectChambers('colvinsChambers');
selectRecipient('Judge Colvin');
enterSubject();
fillOutMessageField();
cy.get('[data-testid="select-document"]').select(docketEntryId!);
sendMessage();
loginAsColvin();
cy.get('tbody')
.contains('td.message-queue-row', docketNumber)
.parents('tbody')
.within(() => {
cy.get(
'div.message-document-title a[data-testid="message-header-link"]',
).click();
});
cy.get('[data-testid="apply-stamp"]').click();
cy.get('[data-testid="motion-disposition-Granted"]').click();
cy.get('[data-testid="save-signature-button"]').click();
cy.get('[data-testid="success-alert"]').contains(
'Motion to Proceed Remotely stamped successfully.',
);
cy.get('.attachment-viewer-button')
.contains('Motion to Proceed Remotely')
.should('be.visible');
cy.get('.attachment-viewer-button')
.contains('Motion to Proceed Remotely GRANTED')
.should('be.visible');
});
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,14 @@ import {
} from '../../../../../shared/src/business/entities/EntityConstants';
import { UnauthorizedError } from '@web-api/errors/errors';
import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext';
import { createMessage as createMessageMock } from '@web-api/persistence/postgres/messages/createMessage';
import { markMessageThreadRepliedTo as markMessageThreadRepliedToMock } from '@web-api/persistence/postgres/messages/markMessageThreadRepliedTo';
import { createMessageAsReply as createMessageAsReplyMock } from '@web-api/persistence/postgres/messages/createMessageAsReply';
import {
mockPetitionerUser,
mockPetitionsClerkUser,
} from '@shared/test/mockAuthUsers';
import { replyToMessageInteractor } from './replyToMessageInteractor';

const createMessage = createMessageMock as jest.Mock;
const markMessageThreadRepliedTo = markMessageThreadRepliedToMock as jest.Mock;
const createMessageAsReply = createMessageAsReplyMock as jest.Mock;

describe('replyToMessageInteractor', () => {
const mockAttachments = [
Expand Down Expand Up @@ -87,23 +85,10 @@ describe('replyToMessageInteractor', () => {
mockPetitionsClerkUser,
);

expect(createMessage).toHaveBeenCalled();
expect((createMessage as jest.Mock).mock.calls[0][0].message).toMatchObject(
{
...messageData,
attachments: mockAttachments,
caseStatus: CASE_STATUS_TYPES.generalDocket,
caseTitle: 'Roslindis Angelino',
docketNumber: '101-20',
from: 'Test Petitionsclerk',
fromSection: PETITIONS_SECTION,
fromUserId: 'b9fcabc8-3c83-4cbf-9f4a-d2ecbdc591e1',
to: 'Test Petitionsclerk2',
},
);
expect(markMessageThreadRepliedTo).toHaveBeenCalled();
expect(createMessage).toHaveBeenCalled();
expect(createMessage.mock.calls[0][0].message).toMatchObject({
expect(createMessageAsReply).toHaveBeenCalled();
expect(
(createMessageAsReply as jest.Mock).mock.calls[0][0].newMessage,
).toMatchObject({
...messageData,
attachments: mockAttachments,
caseStatus: CASE_STATUS_TYPES.generalDocket,
Expand All @@ -114,9 +99,8 @@ describe('replyToMessageInteractor', () => {
fromUserId: 'b9fcabc8-3c83-4cbf-9f4a-d2ecbdc591e1',
to: 'Test Petitionsclerk2',
});
expect(markMessageThreadRepliedTo).toHaveBeenCalled();
expect(markMessageThreadRepliedTo.mock.calls[0][0]).toMatchObject({
parentMessageId: messageData.parentMessageId,
});
expect(createMessageAsReply.mock.calls[0][0].parentMessageId).toEqual(
messageData.parentMessageId,
);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ import { ReplyMessageType } from '@web-api/business/useCases/messages/createMess
import { ServerApplicationContext } from '@web-api/applicationContext';
import { UnauthorizedError } from '@web-api/errors/errors';
import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser';
import { createMessage } from '@web-api/persistence/postgres/messages/createMessage';
import { markMessageThreadRepliedTo } from '@web-api/persistence/postgres/messages/markMessageThreadRepliedTo';
import { createMessageAsReply } from '@web-api/persistence/postgres/messages/createMessageAsReply';

export const replyToMessage = async (
applicationContext: ServerApplicationContext,
Expand All @@ -31,10 +30,6 @@ export const replyToMessage = async (
throw new UnauthorizedError('Unauthorized');
}

await markMessageThreadRepliedTo({
parentMessageId,
});

const { caseCaption, docketNumberWithSuffix, status } =
await applicationContext
.getPersistenceGateway()
Expand Down Expand Up @@ -67,8 +62,9 @@ export const replyToMessage = async (
.validate()
.toRawObject();

await createMessage({
message: validatedRawMessage,
await createMessageAsReply({
newMessage: validatedRawMessage,
parentMessageId,
});

return validatedRawMessage;
Expand Down
41 changes: 41 additions & 0 deletions web-api/src/persistence/postgres/messages/createMessageAsReply.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { Message, RawMessage } from '@shared/business/entities/Message';
import { getDbWriter } from '@web-api/database';
import { getMessageThreadByParentId } from '@web-api/persistence/postgres/messages/getMessageThreadByParentId';
import { toKyselyNewMessage } from './mapper';

export const createMessageAsReply = async ({
newMessage,
parentMessageId,
}: {
parentMessageId: string;
newMessage: RawMessage;
}): Promise<RawMessage> => {
const messages = await getMessageThreadByParentId({
parentMessageId,
});

const createdMessage = await getDbWriter(
async writer =>
await writer.transaction().execute(async trx => {
if (messages?.length) {
await trx
.updateTable('dwMessage')
.set({
isRepliedTo: true,
})
.where('parentMessageId', '=', parentMessageId)
.execute();
}

return await trx
.insertInto('dwMessage')
.values(toKyselyNewMessage(newMessage))
.returningAll()
.executeTakeFirstOrThrow(() => {
throw new Error('could not create a message');
});
}),
);

return new Message(createdMessage);
};
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,5 @@ export const getMessagesByDocketNumber = async ({
.execute(),
);

console.log('*** messages', messages);

return messages.map(message => messageResultEntity(message));
};
4 changes: 4 additions & 0 deletions web-api/src/persistence/postgres/messages/mocks.jest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ jest.mock(
() => mockFactory('markMessageThreadRepliedTo'),
);

jest.mock('@web-api/persistence/postgres/messages/createMessageAsReply', () =>
mockFactory('createMessageAsReply'),
);

jest.mock('@web-api/persistence/postgres/messages/setMessageAsRead', () =>
mockFactory('setMessageAsRead'),
);
Expand Down
Loading

0 comments on commit bb44c92

Please sign in to comment.