Skip to content

Commit

Permalink
Merge branch 'staging' into 10429-design-debt
Browse files Browse the repository at this point in the history
  • Loading branch information
Mwindo authored Aug 15, 2024
2 parents 7acbc6b + d6c13e6 commit f484199
Show file tree
Hide file tree
Showing 106 changed files with 7,088 additions and 2,436 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export function externalUserSearchesDocketNumber(docketNumber: string) {
cy.get('[data-testid="docket-search-field"]').should('exist');
cy.get('[data-testid="docket-search-field"]').type(docketNumber);
cy.get('[data-testid="search-by-docket-number"]').click();
}
46 changes: 46 additions & 0 deletions cypress/local-only/support/statusReportOrder.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import {
FORMATS,
formatNow,
} from '../../../shared/src/business/utilities/DateHandler';

export const docketNumber = '107-19';
export const leadCaseDocketNumber = '102-67';
export const statusReportDocketEntryId = '178af2d2-fab1-445a-a729-d3da63517a0a';
export const messages = {
statusReport: {
messageId: '73d4365b-8b3a-4b01-9ca3-7087f7a6d4b5',
name: 'Status Report',
},
testStatusReportOrderSigned: {
messageId: '32484c7f-4606-49fc-89f1-27ba1d5596be',
name: 'Test Status Report Order (Signed)',
},
testStatusReportOrderUnsigned: {
messageId: '34483b5b-29de-4ad4-8caa-59f71ad6d906',
name: 'Test Status Report Order (Unsigned)',
},
};
export const expectedPdfLines = [
'On June 28, 2024, a status report was filed (Index no. 5). For cause, it is',
`ORDERED that the parties shall file a further status report by ${formatNow(FORMATS.MONTH_DAY_YEAR)}. It is further`,
'ORDERED that this case is stricken from the trial session. It is further',
'ORDERED that jurisdiction is retained by the undersigned. It is further',
'ORDERED that Here is my additional order text.',
];
export const selectAllOptionsInForm = () => {
cy.get('#order-type-status-report').check({ force: true });
cy.get('#status-report-due-date-picker').type(formatNow(FORMATS.MMDDYYYY));
cy.get('#stricken-from-trial-sessions').check({ force: true });
cy.get('#jurisdiction-retained').check({ force: true });
cy.get('#additional-order-text').type('Here is my additional order text.');
};

export const getLastDraftOrderElementFromDrafts = () => {
return cy.get('button:contains(Order)').last();
};

export const getLastDraftOrderElementIndexFromDrafts = () => {
return getLastDraftOrderElementFromDrafts().then(lastOrderButton => {
return lastOrderButton.index();
});
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { checkA11y } from '../../../support/generalCommands/checkA11y';
import { loginAsColvin } from '../../../../helpers/authentication/login-as-helpers';

describe('Status Report Order - Judge Accessibility', () => {
beforeEach(() => {
Cypress.session.clearCurrentSessionData();
});

it('should be free of a11y issues', () => {
loginAsColvin();
cy.visit(
'/case-detail/102-67/documents/7be2dea1-4428-4917-a66d-0d474e57ee02/status-report-order-create?statusReportFilingDate=2024-06-28&statusReportIndex=1',
);
cy.get('[data-testid="save-draft-button"]').should('exist');

checkA11y();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import {
docketNumber,
messages,
statusReportDocketEntryId,
} from '../../../support/statusReportOrder';
import { loginAsDocketClerk } from '../../../../helpers/authentication/login-as-helpers';

describe('check permissions for status report order', () => {
beforeEach(() => {
loginAsDocketClerk();
});

it('docket clerk should not be able to create status report order', () => {
cy.visit(`/case-detail/${docketNumber}`);
cy.get('#tab-document-view').click();
cy.get(`[data-entry-id="${statusReportDocketEntryId}"]`).click();

cy.get('[data-testid="order-button"]').should('not.exist');
});

it('docket clerk should not be able to edit a status report order in the status report order form', () => {
cy.visit(`/case-detail/${docketNumber}`);
cy.get('#tab-drafts').click();
cy.contains('button', messages.testStatusReportOrderUnsigned.name).click();

cy.get('#draft-edit-button-not-signed').should('not.exist');
});

it('docket clerk should not be able to view status report order route', () => {
[
`/case-detail/${docketNumber}/documents/${statusReportDocketEntryId}/status-report-order-create?statusReportFilingDate=2024-06-28&statusReportIndex=5`,
`/case-detail/${docketNumber}/documents/${statusReportDocketEntryId}/status-report-order-edit`,
`/messages/${docketNumber}/message-detail/${messages.statusReport.messageId}/${statusReportDocketEntryId}/status-report-order-create?statusReportFilingDate=2024-06-28&statusReportIndex=5`,
`/messages/${docketNumber}/message-detail/${messages.statusReport.messageId}/${statusReportDocketEntryId}/status-report-order-create`,
].forEach((route: string) => {
cy.visit(route);
cy.contains('Error 404').should('exist');
});
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,207 @@
import {
FORMATS,
formatNow,
} from '../../../../../shared/src/business/utilities/DateHandler';
import {
docketNumber,
expectedPdfLines,
getLastDraftOrderElementFromDrafts,
getLastDraftOrderElementIndexFromDrafts,
messages,
selectAllOptionsInForm,
statusReportDocketEntryId,
} from '../../../support/statusReportOrder';
import { loginAsColvin } from '../../../../helpers/authentication/login-as-helpers';

describe('edit status report order', () => {
beforeEach(() => {
loginAsColvin();
cy.visit(`/case-detail/${docketNumber}`);
});

describe('editing a status report order from drafts document view', () => {
it('should load existing unsigned order', () => {
cy.visit(`/case-detail/${docketNumber}`);
cy.get('#tab-drafts').click();
cy.contains(
'button',
messages.testStatusReportOrderUnsigned.name,
).click();
cy.get('[data-testid="draft-edit-button-not-signed"]').click();

cy.get('[data-testid="status-report-order-pdf-preview"]').should(
'not.be.empty',
);

cy.get('#order-type-status-report').should('be.checked');
// expect either the seeded data's date or else the updated date we set in these tests
cy.get('#status-report-due-date-picker').should($el => {
expect($el.val()).to.satisfy(
(t: string | string[]) =>
t.includes('07/11/2024') ||
t.includes(`${formatNow(FORMATS.MMDDYYYY)}`),
);
});
cy.get('#stricken-from-trial-sessions').should('be.checked');
cy.get('#jurisdiction-retained').should('be.checked');
cy.get('#additional-order-text').should('contain', 'Test');
});

it('should load existing signed order', () => {
cy.get('#tab-drafts').click();
cy.contains('button', messages.testStatusReportOrderSigned.name).click();
cy.get('[data-testid="edit-order-button"]').click();
cy.get('[data-testid="modal-button-confirm"]').click();

cy.get('[data-testid="status-report-order-pdf-preview"]').should(
'not.be.empty',
);

cy.get('#order-type-status-report').should('be.checked');
cy.get('#status-report-due-date-picker').invoke('val').should('exist');
cy.get('#stricken-from-trial-sessions').should('be.checked');
cy.get('#jurisdiction-retained').should('be.checked');
cy.get('#additional-order-text').should('contain', 'Test');

cy.get('#status-report-due-date-picker').clear();
cy.get('#status-report-due-date-picker').type(
formatNow(FORMATS.MMDDYYYY),
);
cy.get('[data-testid="save-draft-button"]').click();
cy.get('[data-testid="sign-pdf-canvas"]').click();
cy.get('[data-testid="save-signature-button"]').click();
});

it('should be able to save edited status report order without duplicates', () => {
cy.get('#tab-document-view').click();
cy.get(`[data-entry-id="${statusReportDocketEntryId}"]`).click();
cy.get('[data-testid="status-report-order-button"]').click();
selectAllOptionsInForm();
cy.get('[data-testid="save-draft-button"]').click();
cy.contains('Apply Signature').should('exist');
cy.get('[data-testid="skip-signature-button"]').click();

cy.get('#tab-drafts').click();

getLastDraftOrderElementFromDrafts().click();
// We'll get the order index and check it later to ensure that we have edited our existing order rather than created a new order
const lastOrderIndex = getLastDraftOrderElementIndexFromDrafts();

cy.get('[data-testid="draft-edit-button-not-signed"]').click();
cy.get('#stricken-from-trial-sessions').uncheck({ force: true });

cy.intercept('POST', '**/api/court-issued-order').as('courtIssuedOrder');
cy.get('[data-testid="save-draft-button"]').click();

cy.wait('@courtIssuedOrder').then(({ request: req }) => {
expectedPdfLines.forEach((pdfLine, i) => {
if (i === 2 || i === 3) {
expect(req.body.contentHtml).to.not.include(pdfLine);
} else {
expect(req.body.contentHtml).to.include(pdfLine);
}
});
});
cy.contains('Apply Signature').should('exist');

cy.get('[data-testid="skip-signature-button"]').click();
cy.get('#tab-drafts').click();

expect(lastOrderIndex == getLastDraftOrderElementIndexFromDrafts());
});
});

describe('editing a status report order from message view', () => {
it('should load existing unsigned order', () => {
cy.get('#tab-case-messages').click();
cy.contains('a', messages.testStatusReportOrderUnsigned.name).click();
cy.get('[data-testid="edit-unsigned-document-button"]').click();

cy.get('[data-testid="status-report-order-pdf-preview"]').should(
'not.be.empty',
);

cy.get('#order-type-status-report').should('be.checked');
// expect either the seeded data's date or else the updated date we set in these tests
cy.get('#status-report-due-date-picker').should($el => {
expect($el.val()).to.satisfy(
(t: string | string[]) =>
t.includes('07/11/2024') ||
t.includes(`${formatNow(FORMATS.MMDDYYYY)}`),
);
});
cy.get('#stricken-from-trial-sessions').should('be.checked');
cy.get('#jurisdiction-retained').should('be.checked');
cy.get('#additional-order-text').should('contain', 'Test');
});

it('should load existing signed order', () => {
cy.get('#tab-case-messages').click();
cy.contains('a', messages.testStatusReportOrderSigned.name).click();
cy.get('[data-testid="edit-signed-document-button"]').click();
cy.get('[data-testid="modal-button-confirm"]').click();

cy.get('[data-testid="status-report-order-pdf-preview"]').should(
'not.be.empty',
);

cy.get('#order-type-status-report').should('be.checked');
cy.get('#status-report-due-date-picker').invoke('val').should('exist');
cy.get('#stricken-from-trial-sessions').should('be.checked');
cy.get('#jurisdiction-retained').should('be.checked');
cy.get('#additional-order-text').should('contain', 'Test');

cy.get('#status-report-due-date-picker').clear();
cy.get('#status-report-due-date-picker').type(
formatNow(FORMATS.MMDDYYYY),
);
cy.get('[data-testid="save-draft-button"]').click();
cy.get('[data-testid="sign-pdf-canvas"]').click();
cy.get('[data-testid="save-signature-button"]').click();
});

it('should redirect to messages tab upon saving signed status report order', () => {
cy.get('#tab-case-messages').click();
cy.contains('a', messages.testStatusReportOrderSigned.name).click();
cy.get('[data-testid="edit-signed-document-button"]').click();
cy.get('[data-testid="modal-button-confirm"]').click();
cy.get('#status-report-due-date-picker').clear();
cy.get('#status-report-due-date-picker').type(
formatNow(FORMATS.MMDDYYYY),
);

cy.get('[data-testid="save-draft-button"]').click();

cy.contains('Apply Signature').should('exist');

cy.get('[data-testid="sign-pdf-canvas"]').click();
cy.get('[data-testid="save-signature-button"]').click();

cy.url().should('contain', `messages/${docketNumber}/message-detail`);
cy.contains(
'.attachment-viewer-button',
messages.testStatusReportOrderSigned.name,
).should('exist');
});

it('should redirect to messages tab upon saving unsigned status report order', () => {
cy.get('#tab-case-messages').click();
cy.contains('a', messages.testStatusReportOrderUnsigned.name).click();
cy.get('[data-testid="edit-unsigned-document-button"]').click();

// Update date to pass validation on save
cy.get('#status-report-due-date-picker').clear();
cy.get('#status-report-due-date-picker').type(
formatNow(FORMATS.MMDDYYYY),
);

cy.get('[data-testid="save-draft-button"]').click();

cy.contains('Apply Signature').should('exist');

cy.get('[data-testid="skip-signature-button"]').click();

cy.url().should('contain', `messages/${docketNumber}/message-detail`);
});
});
});
Loading

0 comments on commit f484199

Please sign in to comment.