-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'staging' into type-notifications-to-user
- Loading branch information
Showing
23 changed files
with
844 additions
and
720 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
134 changes: 134 additions & 0 deletions
134
...-only/tests/integration/caseDetail/docketRecord/courtIssuedFiling/judge-stamp-order.cy.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }); | ||
}; |
Oops, something went wrong.