Skip to content

Commit

Permalink
Merge branch 'staging' into type-notifications-to-user
Browse files Browse the repository at this point in the history
  • Loading branch information
cruzjone-flexion authored Dec 4, 2024
2 parents 618c592 + 0b880c7 commit bba9d43
Show file tree
Hide file tree
Showing 23 changed files with 844 additions and 720 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: 'docketclerk1@example.com' });
cy.get('[data-testid="inbox-tab-content"]').should('exist');
}

export function loginAsClerkOfCourt() {
login({ email: 'clerkofcourt@example.com' });
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');
});
});
});
});
91 changes: 91 additions & 0 deletions scripts/helpers/generate-csv.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
import { generateCsv } from './generate-csv';
import fs from 'fs';

const exists = jest.spyOn(fs, 'existsSync').mockImplementation(jest.fn());
const unlink = jest.spyOn(fs, 'unlinkSync').mockImplementation(jest.fn());
const append = jest.spyOn(fs, 'appendFileSync').mockImplementation(jest.fn());

const MOCK_COLUMNS = [
{ header: 'Droid name', key: 'name' },
{ header: 'Droid type', key: 'type' },
{ header: 'Alliance', key: 'alliance' },
];
const MOCK_ROWS = [
{
alliance: 'Rebellion',
name: 'C-3PO',
restrained: true,
type: 'Protocol',
},
{
alliance: 'Rebellion',
name: 'R2-D2',
restrained: false,
type: 'Astromech',
},
{
alliance: 'Rebellion',
name: 'C1-10P',
restrained: false,
type: 'Astromech',
},
{
alliance: 'Empire',
name: 'IG-88',
restrained: false,
type: 'Assassin',
},
{
name: 'MSE-6',
restrained: true,
type: 'Mouse',
},
];
const MOCK_FILENAME = `${process.env.HOME}/tmp/jest.csv`;
const MOCK_CONTENTS =
'"Droid name","Droid type","Alliance"' +
'\n"C-3PO","Protocol","Rebellion"' +
'\n"R2-D2","Astromech","Rebellion"' +
'\n"C1-10P","Astromech","Rebellion"' +
'\n"IG-88","Assassin","Empire"' +
'\n"MSE-6","Mouse",""';

describe('generateCsv', () => {
beforeEach(() => {
exists.mockReturnValue(true);
});

it('deletes the specified output file if it already exists', () => {
generateCsv({
columns: MOCK_COLUMNS,
filename: MOCK_FILENAME,
rows: MOCK_ROWS,
});

expect(unlink).toHaveBeenCalled();
expect(append).toHaveBeenCalled();
});

it('does not attempt to delete the specified output file if it does not already exist', () => {
exists.mockReturnValueOnce(false);

generateCsv({
columns: MOCK_COLUMNS,
filename: MOCK_FILENAME,
rows: MOCK_ROWS,
});

expect(unlink).not.toHaveBeenCalled();
expect(append).toHaveBeenCalled();
});

it('compiles an array of objects into a CSV with the given columns', () => {
generateCsv({
columns: MOCK_COLUMNS,
filename: MOCK_FILENAME,
rows: MOCK_ROWS,
});

expect(append).toHaveBeenCalledWith(MOCK_FILENAME, MOCK_CONTENTS);
});
});
48 changes: 48 additions & 0 deletions scripts/helpers/generate-csv.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { appendFileSync, existsSync, unlinkSync } from 'fs';

const compileOutput = ({
columns,
rows,
}: {
columns: { header: string; key: string }[];
rows: { [k: string]: any }[];
}): string => {
const headers = columns.map(c => c.header);
const keys = columns.map(c => c.key);
let output = `"${headers.join('","')}"`;
for (const row of rows) {
const values: string[] = [];
for (const key of keys) {
const value = row[key] || '';
values.push(`${value}`);
}
output += `\n"${values.join('","')}"`;
}
return output;
};

const writeFile = ({
contents,
filename,
}: {
contents: string;
filename: string;
}): void => {
if (existsSync(filename)) {
unlinkSync(filename);
}
appendFileSync(filename, contents);
};

export const generateCsv = ({
columns,
filename,
rows,
}: {
columns: { header: string; key: string }[];
filename: string;
rows: { [k: string]: any }[];
}): void => {
const contents = compileOutput({ columns, rows });
writeFile({ contents, filename });
};
Loading

0 comments on commit bba9d43

Please sign in to comment.