diff --git a/.circleci/config.yml b/.circleci/config.yml index 9678a0f6fd5..b923d9ec4d7 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -398,6 +398,9 @@ jobs: - run: name: 'Deploy - Web API - Serverless - Practitioners - us-east-1' command: docker run -e "AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}" -e "AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}" -e "EFCMS_DOMAIN=${EFCMS_DOMAIN}" -e "CIRCLE_HONEYBADGER_API_KEY=${CIRCLE_HONEYBADGER_API_KEY}" -e "IRS_SUPERUSER_EMAIL=${IRS_SUPERUSER_EMAIL}" -v $(pwd)/.cache:/home/app/.cache --rm efcms /bin/sh -c "./web-api/run-serverless-practitioners.sh ${ENV} us-east-1" + - run: + name: 'Deploy - Web API - Serverless - Messages - us-east-1' + command: docker run -e "AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}" -e "AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}" -e "EFCMS_DOMAIN=${EFCMS_DOMAIN}" -e "CIRCLE_HONEYBADGER_API_KEY=${CIRCLE_HONEYBADGER_API_KEY}" -e "IRS_SUPERUSER_EMAIL=${IRS_SUPERUSER_EMAIL}" -v $(pwd)/.cache:/home/app/.cache --rm efcms /bin/sh -c "./web-api/run-serverless-messages.sh ${ENV} us-east-1" - run: name: 'Deploy - Web API - Serverless - Notifications - us-east-1' command: docker run -e "AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}" -e "AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}" -e "EFCMS_DOMAIN=${EFCMS_DOMAIN}" -e "CIRCLE_HONEYBADGER_API_KEY=${CIRCLE_HONEYBADGER_API_KEY}" -e "IRS_SUPERUSER_EMAIL=${IRS_SUPERUSER_EMAIL}" -v $(pwd)/.cache:/home/app/.cache --rm efcms /bin/sh -c "./web-api/run-serverless-notifications.sh ${ENV} us-east-1" @@ -476,6 +479,9 @@ jobs: - run: name: 'Deploy - Web API - Serverless - Practitioners - us-west-1' command: docker run -e "AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}" -e "AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}" -e "EFCMS_DOMAIN=${EFCMS_DOMAIN}" -e "CIRCLE_HONEYBADGER_API_KEY=${CIRCLE_HONEYBADGER_API_KEY}" -e "IRS_SUPERUSER_EMAIL=${IRS_SUPERUSER_EMAIL}" -v $(pwd)/.cache:/home/app/.cache --rm efcms /bin/sh -c "./web-api/run-serverless-practitioners.sh ${ENV} us-west-1" + - run: + name: 'Deploy - Web API - Serverless - Messages - us-west-1' + command: docker run -e "AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}" -e "AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}" -e "EFCMS_DOMAIN=${EFCMS_DOMAIN}" -e "CIRCLE_HONEYBADGER_API_KEY=${CIRCLE_HONEYBADGER_API_KEY}" -e "IRS_SUPERUSER_EMAIL=${IRS_SUPERUSER_EMAIL}" -v $(pwd)/.cache:/home/app/.cache --rm efcms /bin/sh -c "./web-api/run-serverless-messages.sh ${ENV} us-west-1" - run: name: 'Deploy - Web API - Serverless - Notifications - us-west-1' command: docker run -e "AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}" -e "AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}" -e "EFCMS_DOMAIN=${EFCMS_DOMAIN}" -e "CIRCLE_HONEYBADGER_API_KEY=${CIRCLE_HONEYBADGER_API_KEY}" -e "IRS_SUPERUSER_EMAIL=${IRS_SUPERUSER_EMAIL}" -v $(pwd)/.cache:/home/app/.cache --rm efcms /bin/sh -c "./web-api/run-serverless-notifications.sh ${ENV} us-west-1" @@ -502,10 +508,10 @@ jobs: # command: docker run -e "AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}" -e "AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}" -e "EFCMS_DOMAIN=${EFCMS_DOMAIN}" --rm efcms /bin/sh -c "cd web-api && ./switch-environment-color.sh ${ENV}" - run: name: 'Deploy - Web Client - S3' - command: docker run -e "DYNAMSOFT_URL_OVERRIDE=${DYNAMSOFT_URL_OVERRIDE}" -e "ENV=${ENV}" -e "AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}" -e "AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}" -e "EFCMS_DOMAIN=${EFCMS_DOMAIN}" -e "COGNITO_SUFFIX=${COGNITO_SUFFIX}" -e "CIRCLE_SHA1=${CIRCLE_SHA1}" -e "CIRCLE_HONEYBADGER_API_KEY=${CIRCLE_HONEYBADGER_API_KEY}" --rm efcms /bin/sh -c "./web-client/build-dist.sh $ENV && aws s3 sync dist s3://ui-${ENV}.${EFCMS_DOMAIN} --delete && aws s3 sync dist s3://failover-ui-${ENV}.${EFCMS_DOMAIN} --delete" + command: docker run -e "DYNAMSOFT_URL_OVERRIDE=${DYNAMSOFT_URL_OVERRIDE}" -e "ENV=${ENV}" -e "AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}" -e "AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}" -e "EFCMS_DOMAIN=${EFCMS_DOMAIN}" -e "COGNITO_SUFFIX=${COGNITO_SUFFIX}" -e "CIRCLE_SHA1=${CIRCLE_SHA1}" -e "CIRCLE_HONEYBADGER_API_KEY=${CIRCLE_HONEYBADGER_API_KEY}" --rm efcms /bin/sh -c "./web-client/build-dist.sh $ENV && aws s3 sync dist s3://ui-${ENV}.${EFCMS_DOMAIN} --delete && aws s3 cp s3://ui-${ENV}.${EFCMS_DOMAIN}/index.html s3://ui-${ENV}.${EFCMS_DOMAIN}/index.html --metadata-directive REPLACE --cache-control max-age=0 && aws s3 sync dist s3://failover-ui-${ENV}.${EFCMS_DOMAIN} --delete --cache-control no-cache && aws s3 cp s3://failover-ui-${ENV}.${EFCMS_DOMAIN}/index.html s3://failover-ui-${ENV}.${EFCMS_DOMAIN}/index.html --metadata-directive REPLACE --cache-control max-age=0" - run: name: 'Deploy - Public Web Client - S3' - command: docker run -e "ENV=${ENV}" -e "AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}" -e "AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}" -e "EFCMS_DOMAIN=${EFCMS_DOMAIN}" -e "COGNITO_SUFFIX=${COGNITO_SUFFIX}" -e "CIRCLE_SHA1=${CIRCLE_SHA1}" --rm efcms /bin/sh -c "./web-client/build-dist-public.sh $ENV && aws s3 sync dist-public s3://ui-public-${ENV}.${EFCMS_DOMAIN} --delete && aws s3 sync dist-public s3://failover-ui-public-${ENV}.${EFCMS_DOMAIN} --delete" + command: docker run -e "ENV=${ENV}" -e "AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}" -e "AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}" -e "EFCMS_DOMAIN=${EFCMS_DOMAIN}" -e "COGNITO_SUFFIX=${COGNITO_SUFFIX}" -e "CIRCLE_SHA1=${CIRCLE_SHA1}" --rm efcms /bin/sh -c "./web-client/build-dist-public.sh $ENV && aws s3 sync dist-public s3://ui-public-${ENV}.${EFCMS_DOMAIN} --delete && aws s3 cp s3://ui-public-${ENV}.${EFCMS_DOMAIN}/index.html s3://ui-public-${ENV}.${EFCMS_DOMAIN}/index.html --metadata-directive REPLACE --cache-control max-age=0 && aws s3 sync dist-public s3://failover-ui-public-${ENV}.${EFCMS_DOMAIN} --delete --cache-control no-cache && aws s3 cp s3://failover-ui-public-${ENV}.${EFCMS_DOMAIN}/index.html s3://failover-ui-public-${ENV}.${EFCMS_DOMAIN}/index.html --metadata-directive REPLACE --cache-control max-age=0" post-deploy: machine: @@ -533,22 +539,22 @@ jobs: - run: name: 'Deploy - Web API - Cognito Create Users' command: | - if [ "${CIRCLE_BRANCH}" == "staging" ] || [ "${CIRCLE_BRANCH}" == "irs" ]; then + if [ "${CIRCLE_BRANCH}" == "develop" ] || [ "${CIRCLE_BRANCH}" == "staging" ] || [ "${CIRCLE_BRANCH}" == "irs" ] || [ "${CIRCLE_BRANCH}" == "experimental1" ] || [ "${CIRCLE_BRANCH}" == "experimental2" ] ; then docker run -e "AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}" -e "AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}" -e "USTC_ADMIN_PASS=${USTC_ADMIN_PASS}" --rm efcms /bin/sh -c "cd web-api && ./setup-cognito-users.sh ${ENV}" else echo "skipping…" fi - run: name: 'Deploy - Web API - Cognito Create Court Users' - command: | - if [ "${CIRCLE_BRANCH}" == "staging" ] || [ "${CIRCLE_BRANCH}" == "test" ]; then + command: | + if [ "${CIRCLE_BRANCH}" == "develop" ] || [ "${CIRCLE_BRANCH}" == "staging" ] || [ "${CIRCLE_BRANCH}" == "test" ] || [ "${CIRCLE_BRANCH}" == "experimental1" ] || [ "${CIRCLE_BRANCH}" == "experimental2" ]; then docker run -e "AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}" -e "AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}" -e "USTC_ADMIN_PASS=${USTC_ADMIN_PASS}" --rm efcms /bin/sh -c "cd web-api && ./setup-court-users.sh ${ENV}" else echo "skipping…" fi - run: name: 'Deploy - Web API - Cognito Create IRS User' - command: | + command: | if [ "${CIRCLE_BRANCH}" == "irs" ]; then docker run -e "AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}" -e "AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}" -e "USTC_ADMIN_PASS=${USTC_ADMIN_PASS}" --rm efcms /bin/sh -c "cd web-api && ./setup-irs-user.sh ${ENV}" else diff --git a/.eslintrc.js b/.eslintrc.js index df4ae40c5d3..feed186b1b6 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -33,6 +33,15 @@ module.exports = { 'promise/catch-or-return': 'off', }, }, + { + files: [ + 'web-client/integration-tests/**/*.js', + 'web-client/integration-tests-public/**/*.js', + ], + rules: { + 'jest/expect-expect': 'off', + }, + }, ], parser: 'babel-eslint', parserOptions: { @@ -218,6 +227,7 @@ module.exports = { 'dynamsoft', 'efcms', 'elasticsearch', + 'enum', 'eslint', 'falsy', 'fieldset', @@ -324,6 +334,7 @@ module.exports = { 'textarea', 'thorton', 'thortons', + 'todays', 'touchmove', 'transferee', 'truthy', diff --git a/Dockerfile b/Dockerfile index 323d71bcc87..45a75989b3c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,4 @@ -FROM cypress/base:12.16.0 - -RUN echo "recache again" +FROM cypress/base:12.16.2 WORKDIR /home/app @@ -46,6 +44,7 @@ ENV JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64 COPY package.json /home/app/package.json COPY package-lock.json /home/app/package-lock.json RUN npm set progress=false && \ + npm config set puppeteer_skip_chromium_download true && \ npm i COPY . /home/app diff --git a/README.md b/README.md index 77417646dcc..f04101fd461 100644 --- a/README.md +++ b/README.md @@ -50,11 +50,6 @@ For documentation about the CI/CD setup, API, style guide, UX, code review, etc. -## Dependency diagrams - -- Client -- Server - ## Backlog The backlog is stored [in GitHub Issues in Flexion’s repository](https://github.com/flexion/ef-cms/issues), _not_ on this repository. Although they can be viewed like any other GitHub issues, they are managed on a scrum board that requires the [ZenHub browser plugin](https://www.zenhub.com/) to see. diff --git a/cypress/integration/assign-a-work-item-to-self.spec.js b/cypress/integration/assign-a-work-item-to-self.spec.js index 3db9f7ec5c5..669a10e75cd 100644 --- a/cypress/integration/assign-a-work-item-to-self.spec.js +++ b/cypress/integration/assign-a-work-item-to-self.spec.js @@ -7,10 +7,6 @@ const { } = require('../support/pages/dashboard'); describe('Assign a work item ', () => { - before(() => { - cy.task('seed'); - }); - it('views the section inbox', () => { navigateToDashboard('petitionsclerk'); viewDocumentQCSectionInbox(); diff --git a/cypress/integration/create-a-work-item.spec.js b/cypress/integration/create-a-work-item.spec.js index 08d9006a80a..26908e4e702 100644 --- a/cypress/integration/create-a-work-item.spec.js +++ b/cypress/integration/create-a-work-item.spec.js @@ -22,7 +22,6 @@ const { describe('Create a work item ', () => { before(() => { - cy.task('seed'); navigateToDocumentDetail( 'petitionsclerk', '104-19', diff --git a/cypress/integration/edit-case-caption-via-case-detail-header.spec.js b/cypress/integration/edit-case-caption-via-case-detail-header.spec.js index 61a5973159a..fd364b3962e 100644 --- a/cypress/integration/edit-case-caption-via-case-detail-header.spec.js +++ b/cypress/integration/edit-case-caption-via-case-detail-header.spec.js @@ -9,7 +9,6 @@ const { describe('Edit a case caption from case detail header', function () { before(() => { - cy.task('seed'); navigateToCaseDetail('docketclerk', '101-19'); getActionMenuButton().click(); getEditCaseCaptionButton().click(); diff --git a/cypress/integration/edit-case-caption-via-petition-qc.spec.js b/cypress/integration/edit-case-caption-via-petition-qc.spec.js index 404c4fca60e..32b7a511c70 100644 --- a/cypress/integration/edit-case-caption-via-petition-qc.spec.js +++ b/cypress/integration/edit-case-caption-via-petition-qc.spec.js @@ -10,7 +10,6 @@ const { describe('change the case caption via the petition qc page', () => { before(() => { - cy.task('seed'); navigateToPetitionQc( 'petitionsclerk', '101-19', diff --git a/cypress/integration/file-a-petition.spec.js b/cypress/integration/file-a-petition.spec.js index ea9a177358c..9fdb34a961f 100644 --- a/cypress/integration/file-a-petition.spec.js +++ b/cypress/integration/file-a-petition.spec.js @@ -3,7 +3,6 @@ let createdDocketNumber; describe('File a petition', function () { before(() => { - cy.task('seed'); cy.login('petitioner'); }); @@ -189,15 +188,20 @@ describe('creation form', () => { }); it('submits forms and redirects to the file petition success page', () => { + cy.get('button#submit-case').scrollIntoView().click(); + cy.server(); cy.route('POST', '**/cases').as('postCase'); - cy.get('button#submit-case').scrollIntoView().click(); cy.wait('@postCase'); cy.get('@postCase').should(xhr => { // eslint-disable-next-line jest/valid-expect expect(xhr.responseBody).to.have.property('docketNumber'); createdDocketNumber = xhr.responseBody.docketNumber; }); + + // wait for elasticsearch to refresh + cy.wait(1000); + cy.url().should('include', 'file-a-petition/success'); cy.get('a#button-back-to-dashboard').click(); }); diff --git a/cypress/integration/file-an-answer.spec.js b/cypress/integration/file-an-answer.spec.js index 6e5680eebc0..d1e88b75a6a 100644 --- a/cypress/integration/file-an-answer.spec.js +++ b/cypress/integration/file-an-answer.spec.js @@ -4,7 +4,6 @@ const { describe('Filing an Answer', function () { before(() => { - cy.task('seed'); cy.login('irsPractitioner', '/case-detail/102-19'); }); @@ -43,6 +42,9 @@ describe('Filing an Answer', function () { }); it('reflects changes to 102-19 by showing it in irsPractitioner case list', () => { + // wait for elasticsearch to refresh + cy.wait(1000); + navigateToDashboard('irsPractitioner'); cy.get('table#case-list').find('a').should('contain', '102-19'); }); diff --git a/cypress/integration/petitions-clerk-creates-a-case.spec.js b/cypress/integration/petitions-clerk-creates-a-case.spec.js index 7e2e8f43b39..f4fb8bb1bb1 100644 --- a/cypress/integration/petitions-clerk-creates-a-case.spec.js +++ b/cypress/integration/petitions-clerk-creates-a-case.spec.js @@ -9,8 +9,6 @@ const { describe('Create case and submit to IRS', function () { before(() => { - cy.task('seed'); - navigateToDocumentQC('petitionsclerk'); getCreateACaseButton().click(); @@ -29,4 +27,9 @@ describe('Create case and submit to IRS', function () { expect(xhr.responseBody).to.have.property('docketNumber'); }); }); + + it('should display a confirmation modal when the user clicks cancel on the review page', () => { + cy.get('button#cancel-create-case').scrollIntoView().click(); + cy.get('div.modal-header').should('exist'); + }); }); diff --git a/cypress/integration/public/advanced-search.spec.js b/cypress/integration/public/advanced-search.spec.js index 2ce7e5578d2..13729024487 100644 --- a/cypress/integration/public/advanced-search.spec.js +++ b/cypress/integration/public/advanced-search.spec.js @@ -13,10 +13,6 @@ const { } = require('../../support/pages/public/advanced-search'); describe('Advanced search', () => { - before(() => { - cy.task('seed'); - }); - describe('case - by name', () => { it('should route to case detail when a match is found and the user clicks on the docket record link in the table', () => { navigateToDashboard(); diff --git a/cypress/integration/start-a-case-practitioner.spec.js b/cypress/integration/start-a-case-practitioner.spec.js index 05118b94d93..418ee965b87 100644 --- a/cypress/integration/start-a-case-practitioner.spec.js +++ b/cypress/integration/start-a-case-practitioner.spec.js @@ -7,10 +7,6 @@ const { const { fillInAndSubmitForm } = require('../support/pages/start-a-case'); describe('Start a case as a practitioner ', () => { - before(() => { - cy.task('seed'); - }); - it('go to the practitioner dashboard and expect that a case list table is displayed with 3 cases', () => { navigateToDashboard('privatePractitioner'); getCaseList().should('have.length', 3); diff --git a/cypress/support/pages/start-a-case.js b/cypress/support/pages/start-a-case.js index f5ac8068bc0..1e75e5aa023 100644 --- a/cypress/support/pages/start-a-case.js +++ b/cypress/support/pages/start-a-case.js @@ -37,6 +37,9 @@ exports.fillInAndSubmitForm = () => { // step 5 cy.get('button#submit-case').scrollIntoView().click(); + // wait for elasticsearch to refresh + cy.wait(3000); + // success page cy.url().should('include', 'file-a-petition/success'); cy.get('a#button-back-to-dashboard').click(); diff --git a/docs/TROUBLESHOOTING.md b/docs/TROUBLESHOOTING.md index 3e787a5fed1..ed47c6915e2 100644 --- a/docs/TROUBLESHOOTING.md +++ b/docs/TROUBLESHOOTING.md @@ -116,3 +116,12 @@ To revert your `serverless-prune-plugin`, just change `before` back to `after` o This error often occurs when we are indexing too many dynamic keys or nested objects with Elasticsearch and reach our total field limit. The script will output data related to the mapping for the environment and can help pinpoint areas to look into further. To filter data from indexing, add fields or keys to the filtering functions in `processStreamRecordsInteractor.js`. + + +### NotFoundException when calling the GetDomainName + +This error occurs when code changes do not cause the checksums of the files to change. In order to redeploy, the file must have a different checksum than what is recorded in the database. + +#### Solution + +Delete checksums from the environment dynamo table that is failing. For example, if the dev deploy is failing, navigate to the efcms-deploy-dev table in AWS and delete all the check-sum-** items. \ No newline at end of file diff --git a/docs/entities/Case.md b/docs/entities/Case.md index a958b283f03..9d83f7e37ef 100644 --- a/docs/entities/Case.md +++ b/docs/entities/Case.md @@ -259,7 +259,7 @@ - name: "pattern" args: - regex: "/^(\\d{3,5}-\\d{2})$/" + regex: "/^([1-9]\\d{2,4}-\\d{2})$/" docketNumberSuffix: type: "string" flags: diff --git a/docs/entities/CaseMessage.md b/docs/entities/CaseMessage.md new file mode 100644 index 00000000000..defe0a48486 --- /dev/null +++ b/docs/entities/CaseMessage.md @@ -0,0 +1,225 @@ +# CaseMessage + ``` +--- + type: "object" + keys: + caseId: + type: "string" + flags: + presence: "required" + description: "ID of the case the message is attached to." + rules: + - + name: "guid" + args: + options: + version: + - "uuidv4" + caseStatus: + type: "string" + flags: + presence: "optional" + description: "The status of the associated case." + createdAt: + type: "date" + flags: + format: + - "YYYY-MM-DDTHH:mm:ss.SSSZ" + - "YYYY-MM-DD" + presence: "required" + description: "When the message was created." + docketNumber: + type: "string" + flags: + presence: "required" + rules: + - + name: "pattern" + args: + regex: "/^([1-9]\\d{2,4}-\\d{2})$/" + docketNumberWithSuffix: + type: "string" + flags: + presence: "optional" + description: "The docket number and suffix for the associated case." + allow: + - null + entityName: + type: "string" + flags: + only: true + presence: "required" + allow: + - "CaseMessage" + from: + type: "string" + flags: + presence: "required" + description: "The name of the user who sent the message." + rules: + - + name: "max" + args: + limit: 100 + fromSection: + type: "string" + flags: + only: true + presence: "required" + description: "The section of the user who sent the message." + allow: + - "adc" + - "admissions" + - "chambers" + - "clerkofcourt" + - "docket" + - "petitions" + - "trialClerks" + - "armensChambers" + - "ashfordsChambers" + - "buchsChambers" + - "carluzzosChambers" + - "cohensChambers" + - "colvinsChambers" + - "copelandsChambers" + - "foleysChambers" + - "galesChambers" + - "gerbersChambers" + - "goekesChambers" + - "gustafsonsChambers" + - "guysChambers" + - "halpernsChambers" + - "holmesChambers" + - "jacobsChambers" + - "jonesChambers" + - "kerrigansChambers" + - "laubersChambers" + - "leydensChambers" + - "marvelsChambers" + - "morrisonsChambers" + - "negasChambers" + - "panuthosChambers" + - "parisChambers" + - "pughsChambers" + - "ruwesChambers" + - "thorntonsChambers" + - "urdasChambers" + - "vasquezsChambers" + - "wellsChambers" + fromUserId: + type: "string" + flags: + presence: "required" + description: "The ID of the user who sent the message." + rules: + - + name: "guid" + args: + options: + version: + - "uuidv4" + message: + type: "string" + flags: + presence: "required" + description: "The message text." + rules: + - + name: "max" + args: + limit: 500 + messageId: + type: "string" + flags: + presence: "required" + description: "A unique ID generated by the system to represent the message." + rules: + - + name: "guid" + args: + options: + version: + - "uuidv4" + subject: + type: "string" + flags: + presence: "required" + description: "The subject line of the message." + rules: + - + name: "max" + args: + limit: 250 + to: + type: "string" + flags: + presence: "required" + description: "The name of the user who is the recipient of the message." + rules: + - + name: "max" + args: + limit: 100 + allow: + - null + toSection: + type: "string" + flags: + only: true + presence: "required" + description: "The section of the user who is the recipient of the message." + allow: + - "adc" + - "admissions" + - "chambers" + - "clerkofcourt" + - "docket" + - "petitions" + - "trialClerks" + - "armensChambers" + - "ashfordsChambers" + - "buchsChambers" + - "carluzzosChambers" + - "cohensChambers" + - "colvinsChambers" + - "copelandsChambers" + - "foleysChambers" + - "galesChambers" + - "gerbersChambers" + - "goekesChambers" + - "gustafsonsChambers" + - "guysChambers" + - "halpernsChambers" + - "holmesChambers" + - "jacobsChambers" + - "jonesChambers" + - "kerrigansChambers" + - "laubersChambers" + - "leydensChambers" + - "marvelsChambers" + - "morrisonsChambers" + - "negasChambers" + - "panuthosChambers" + - "parisChambers" + - "pughsChambers" + - "ruwesChambers" + - "thorntonsChambers" + - "urdasChambers" + - "vasquezsChambers" + - "wellsChambers" + toUserId: + type: "string" + flags: + presence: "required" + description: "The ID of the user who is the recipient of the message." + rules: + - + name: "guid" + args: + options: + version: + - "uuidv4" + allow: + - null + + ``` diff --git a/docs/entities/Document.md b/docs/entities/Document.md index ff8282d4e04..56c3a12a286 100644 --- a/docs/entities/Document.md +++ b/docs/entities/Document.md @@ -86,7 +86,7 @@ - name: "pattern" args: - regex: "/^(\\d{3,5}-\\d{2})$/" + regex: "/^([1-9]\\d{2,4}-\\d{2})$/" docketNumbers: type: "string" flags: @@ -435,8 +435,8 @@ - "OAW - Order that the letter \"W\" is added to the Docket number" - "OAX - Order that the letter \"X\" is added to the Docket number" - "OCA - Order that caption of case is amended" - - "OD - Order of Dismissal Entered," - - "ODD - Order of Dismissal and Decision Entered," + - "OD - Order of Dismissal Entered" + - "ODD - Order of Dismissal and Decision Entered" - "ODL - Order that the letter \"L\" is deleted from the Docket number" - "ODP - Order that the letter \"P\" is deleted from the Docket number" - "ODR - Order that the letter \"R\" is deleted from the Docket number" diff --git a/docs/entities/ForwardMessage.md b/docs/entities/ForwardMessage.md index 87c7b6c0d94..e92aa17e980 100644 --- a/docs/entities/ForwardMessage.md +++ b/docs/entities/ForwardMessage.md @@ -52,6 +52,7 @@ - "halpernsChambers" - "holmesChambers" - "jacobsChambers" + - "jonesChambers" - "kerrigansChambers" - "laubersChambers" - "leydensChambers" diff --git a/docs/entities/InitialWorkItemMessage.md b/docs/entities/InitialWorkItemMessage.md new file mode 100644 index 00000000000..31deb7a24cb --- /dev/null +++ b/docs/entities/InitialWorkItemMessage.md @@ -0,0 +1,71 @@ +# InitialWorkItemMessage + ``` +--- + type: "object" + keys: + assigneeId: + type: "string" + flags: + presence: "required" + rules: + - + name: "guid" + args: + options: + version: + - "uuidv4" + message: + type: "string" + flags: + presence: "required" + rules: + - + name: "max" + args: + limit: 500 + section: + type: "string" + flags: + only: true + presence: "required" + allow: + - "adc" + - "admissions" + - "chambers" + - "clerkofcourt" + - "docket" + - "petitions" + - "trialClerks" + - "armensChambers" + - "ashfordsChambers" + - "buchsChambers" + - "carluzzosChambers" + - "cohensChambers" + - "colvinsChambers" + - "copelandsChambers" + - "foleysChambers" + - "galesChambers" + - "gerbersChambers" + - "goekesChambers" + - "gustafsonsChambers" + - "guysChambers" + - "halpernsChambers" + - "holmesChambers" + - "jacobsChambers" + - "jonesChambers" + - "kerrigansChambers" + - "laubersChambers" + - "leydensChambers" + - "marvelsChambers" + - "morrisonsChambers" + - "negasChambers" + - "panuthosChambers" + - "parisChambers" + - "pughsChambers" + - "ruwesChambers" + - "thorntonsChambers" + - "urdasChambers" + - "vasquezsChambers" + - "wellsChambers" + + ``` diff --git a/docs/entities/IrsPractitioner.md b/docs/entities/IrsPractitioner.md new file mode 100644 index 00000000000..ec6cf19287c --- /dev/null +++ b/docs/entities/IrsPractitioner.md @@ -0,0 +1,288 @@ +# IrsPractitioner + ``` +--- + type: "object" + keys: + barNumber: + type: "string" + flags: + presence: "optional" + allow: + - null + contact: + type: "object" + flags: + presence: "optional" + keys: + address1: + type: "string" + flags: + presence: "required" + rules: + - + name: "max" + args: + limit: 100 + address2: + type: "string" + flags: + presence: "optional" + rules: + - + name: "max" + args: + limit: 100 + allow: + - null + address3: + type: "string" + flags: + presence: "optional" + rules: + - + name: "max" + args: + limit: 100 + allow: + - null + city: + type: "string" + flags: + presence: "required" + rules: + - + name: "max" + args: + limit: 100 + countryType: + type: "string" + flags: + only: true + presence: "required" + allow: + - "domestic" + - "international" + country: + type: "any" + whens: + - + ref: + path: + - "countryType" + is: + type: "any" + flags: + only: true + presence: "required" + allow: + - + override: true + - "international" + then: + type: "string" + flags: + presence: "required" + otherwise: + type: "string" + flags: + presence: "optional" + allow: + - null + phone: + type: "string" + flags: + presence: "required" + rules: + - + name: "max" + args: + limit: 100 + postalCode: + type: "any" + whens: + - + ref: + path: + - "countryType" + is: + type: "any" + flags: + only: true + presence: "required" + allow: + - + override: true + - "international" + then: + type: "string" + flags: + presence: "required" + rules: + - + name: "max" + args: + limit: 100 + otherwise: + type: "string" + flags: + presence: "required" + rules: + - + name: "pattern" + args: + regex: "/^(\\d{5}|\\d{5}-\\d{4})$/" + state: + type: "any" + whens: + - + ref: + path: + - "countryType" + is: + type: "any" + flags: + only: true + presence: "required" + allow: + - + override: true + - "international" + then: + type: "string" + flags: + presence: "optional" + allow: + - null + otherwise: + type: "string" + flags: + presence: "required" + rules: + - + name: "max" + args: + limit: 100 + email: + type: "string" + flags: + presence: "optional" + rules: + - + name: "max" + args: + limit: 100 + entityName: + type: "string" + flags: + only: true + presence: "required" + allow: + - "IrsPractitioner" + section: + type: "string" + flags: + presence: "optional" + token: + type: "string" + flags: + presence: "optional" + userId: + type: "string" + flags: + presence: "required" + rules: + - + name: "guid" + args: + options: + version: + - "uuidv4" + name: + type: "string" + flags: + presence: "optional" + rules: + - + name: "max" + args: + limit: 100 + role: + type: "string" + flags: + only: true + presence: "required" + allow: + - "irsPractitioner" + judgeFullName: + type: "any" + whens: + - + ref: + path: + - "role" + is: + type: "any" + flags: + only: true + presence: "required" + allow: + - + override: true + - "judge" + then: + type: "string" + flags: + presence: "optional" + rules: + - + name: "max" + args: + limit: 100 + otherwise: + type: "any" + flags: + presence: "optional" + allow: + - null + judgeTitle: + type: "any" + whens: + - + ref: + path: + - "role" + is: + type: "any" + flags: + only: true + presence: "required" + allow: + - + override: true + - "judge" + then: + type: "string" + flags: + presence: "optional" + rules: + - + name: "max" + args: + limit: 100 + otherwise: + type: "any" + flags: + presence: "optional" + allow: + - null + serviceIndicator: + type: "string" + flags: + only: true + presence: "required" + allow: + - "Electronic" + - "None" + - "Paper" + + ``` diff --git a/docs/entities/Message.md b/docs/entities/Message.md new file mode 100644 index 00000000000..e5e169b6d02 --- /dev/null +++ b/docs/entities/Message.md @@ -0,0 +1,85 @@ +# Message + ``` +--- + type: "object" + keys: + createdAt: + type: "date" + flags: + format: + - "YYYY-MM-DDTHH:mm:ss.SSSZ" + - "YYYY-MM-DD" + presence: "optional" + entityName: + type: "string" + flags: + only: true + presence: "required" + allow: + - "Message" + from: + type: "string" + flags: + presence: "required" + rules: + - + name: "max" + args: + limit: 100 + fromUserId: + type: "string" + flags: + presence: "required" + rules: + - + name: "guid" + args: + options: + version: + - "uuidv4" + message: + type: "string" + flags: + presence: "required" + rules: + - + name: "max" + args: + limit: 500 + messageId: + type: "string" + flags: + presence: "required" + rules: + - + name: "guid" + args: + options: + version: + - "uuidv4" + to: + type: "string" + flags: + presence: "optional" + rules: + - + name: "max" + args: + limit: 100 + allow: + - null + toUserId: + type: "string" + flags: + presence: "optional" + rules: + - + name: "guid" + args: + options: + version: + - "uuidv4" + allow: + - null + + ``` diff --git a/docs/entities/NewCaseMessage.md b/docs/entities/NewCaseMessage.md new file mode 100644 index 00000000000..c50fef4ea11 --- /dev/null +++ b/docs/entities/NewCaseMessage.md @@ -0,0 +1,93 @@ +# NewCaseMessage + ``` +--- + type: "object" + keys: + entityName: + type: "string" + flags: + only: true + presence: "required" + allow: + - "NewCaseMessage" + message: + type: "string" + flags: + presence: "required" + description: "The message text." + rules: + - + name: "max" + args: + limit: 500 + subject: + type: "string" + flags: + presence: "required" + description: "The subject line of the message." + rules: + - + name: "max" + args: + limit: 250 + toSection: + type: "string" + flags: + only: true + presence: "required" + description: "The section of the user who is the recipient of the message." + allow: + - "adc" + - "admissions" + - "chambers" + - "clerkofcourt" + - "docket" + - "petitions" + - "trialClerks" + - "armensChambers" + - "ashfordsChambers" + - "buchsChambers" + - "carluzzosChambers" + - "cohensChambers" + - "colvinsChambers" + - "copelandsChambers" + - "foleysChambers" + - "galesChambers" + - "gerbersChambers" + - "goekesChambers" + - "gustafsonsChambers" + - "guysChambers" + - "halpernsChambers" + - "holmesChambers" + - "jacobsChambers" + - "jonesChambers" + - "kerrigansChambers" + - "laubersChambers" + - "leydensChambers" + - "marvelsChambers" + - "morrisonsChambers" + - "negasChambers" + - "panuthosChambers" + - "parisChambers" + - "pughsChambers" + - "ruwesChambers" + - "thorntonsChambers" + - "urdasChambers" + - "vasquezsChambers" + - "wellsChambers" + toUserId: + type: "string" + flags: + presence: "required" + description: "The ID of the user who is the recipient of the message." + rules: + - + name: "guid" + args: + options: + version: + - "uuidv4" + allow: + - null + + ``` diff --git a/docs/entities/NewPractitioner.md b/docs/entities/NewPractitioner.md new file mode 100644 index 00000000000..c11a5684f2f --- /dev/null +++ b/docs/entities/NewPractitioner.md @@ -0,0 +1,398 @@ +# NewPractitioner + ``` +--- + type: "object" + keys: + barNumber: + type: "string" + flags: + presence: "optional" + allow: + - null + contact: + type: "object" + flags: + presence: "optional" + keys: + address1: + type: "string" + flags: + presence: "required" + rules: + - + name: "max" + args: + limit: 100 + address2: + type: "string" + flags: + presence: "optional" + rules: + - + name: "max" + args: + limit: 100 + allow: + - null + address3: + type: "string" + flags: + presence: "optional" + rules: + - + name: "max" + args: + limit: 100 + allow: + - null + city: + type: "string" + flags: + presence: "required" + rules: + - + name: "max" + args: + limit: 100 + countryType: + type: "string" + flags: + only: true + presence: "required" + allow: + - "domestic" + - "international" + country: + type: "any" + whens: + - + ref: + path: + - "countryType" + is: + type: "any" + flags: + only: true + presence: "required" + allow: + - + override: true + - "international" + then: + type: "string" + flags: + presence: "required" + otherwise: + type: "string" + flags: + presence: "optional" + allow: + - null + phone: + type: "string" + flags: + presence: "required" + rules: + - + name: "max" + args: + limit: 100 + postalCode: + type: "any" + whens: + - + ref: + path: + - "countryType" + is: + type: "any" + flags: + only: true + presence: "required" + allow: + - + override: true + - "international" + then: + type: "string" + flags: + presence: "required" + rules: + - + name: "max" + args: + limit: 100 + otherwise: + type: "string" + flags: + presence: "required" + rules: + - + name: "pattern" + args: + regex: "/^(\\d{5}|\\d{5}-\\d{4})$/" + state: + type: "any" + whens: + - + ref: + path: + - "countryType" + is: + type: "any" + flags: + only: true + presence: "required" + allow: + - + override: true + - "international" + then: + type: "string" + flags: + presence: "optional" + allow: + - null + otherwise: + type: "string" + flags: + presence: "required" + rules: + - + name: "max" + args: + limit: 100 + email: + type: "string" + flags: + presence: "required" + entityName: + type: "string" + flags: + only: true + presence: "required" + allow: + - "Practitioner" + section: + type: "string" + flags: + presence: "optional" + token: + type: "string" + flags: + presence: "optional" + userId: + type: "string" + flags: + presence: "optional" + allow: + - null + name: + type: "string" + flags: + presence: "optional" + rules: + - + name: "max" + args: + limit: 100 + role: + type: "string" + flags: + presence: "optional" + allow: + - null + judgeFullName: + type: "any" + whens: + - + ref: + path: + - "role" + is: + type: "any" + flags: + only: true + presence: "required" + allow: + - + override: true + - "judge" + then: + type: "string" + flags: + presence: "optional" + rules: + - + name: "max" + args: + limit: 100 + otherwise: + type: "any" + flags: + presence: "optional" + allow: + - null + judgeTitle: + type: "any" + whens: + - + ref: + path: + - "role" + is: + type: "any" + flags: + only: true + presence: "required" + allow: + - + override: true + - "judge" + then: + type: "string" + flags: + presence: "optional" + rules: + - + name: "max" + args: + limit: 100 + otherwise: + type: "any" + flags: + presence: "optional" + allow: + - null + additionalPhone: + type: "string" + flags: + presence: "optional" + description: "An alternate phone number for the practitioner." + rules: + - + name: "max" + args: + limit: 100 + allow: + - null + admissionsDate: + type: "date" + flags: + format: + - "YYYY-MM-DDTHH:mm:ss.SSSZ" + - "YYYY-MM-DD" + presence: "required" + description: "The date the practitioner was admitted to the Tax Court bar." + rules: + - + name: "max" + args: + date: "now" + admissionsStatus: + type: "string" + flags: + presence: "required" + alternateEmail: + type: "string" + flags: + presence: "optional" + description: "An alternate email address for the practitioner." + rules: + - + name: "max" + args: + limit: 100 + allow: + - null + birthYear: + type: "number" + flags: + presence: "required" + description: "The year the practitioner was born." + rules: + - + name: "integer" + - + name: "min" + args: + limit: 1900 + - + name: "max" + args: + limit: 2020 + employer: + type: "string" + flags: + only: true + presence: "required" + description: "The employer designation for the practitioner." + allow: + - "IRS" + - "DOJ" + - "Private" + firmName: + type: "string" + flags: + presence: "optional" + description: "The firm name for the practitioner." + rules: + - + name: "max" + args: + limit: 100 + allow: + - null + firstName: + type: "string" + flags: + presence: "required" + lastName: + type: "string" + flags: + presence: "required" + middleName: + type: "string" + flags: + presence: "optional" + description: "The optional middle name of the practitioner." + rules: + - + name: "max" + args: + limit: 100 + allow: + - null + originalBarState: + type: "string" + flags: + presence: "required" + description: "The state in which the practitioner passed their bar examination." + rules: + - + name: "max" + args: + limit: 100 + practitionerType: + type: "string" + flags: + only: true + presence: "required" + description: "The type of practitioner - either Attorney or Non-Attorney." + allow: + - "Attorney" + - "Non-Attorney" + suffix: + type: "string" + flags: + presence: "optional" + description: "The name suffix of the practitioner." + rules: + - + name: "max" + args: + limit: 100 + allow: + - "" + + ``` diff --git a/docs/entities/Note.md b/docs/entities/Note.md new file mode 100644 index 00000000000..0aa5fa058b2 --- /dev/null +++ b/docs/entities/Note.md @@ -0,0 +1,11 @@ +# Note + ``` +--- + type: "object" + keys: + notes: + type: "string" + flags: + presence: "required" + + ``` diff --git a/docs/entities/Order.md b/docs/entities/Order.md new file mode 100644 index 00000000000..a4e5f62d935 --- /dev/null +++ b/docs/entities/Order.md @@ -0,0 +1,33 @@ +# Order + ``` +--- + type: "object" + keys: + documentTitle: + type: "string" + flags: + presence: "required" + rules: + - + name: "max" + args: + limit: 100 + documentType: + type: "string" + flags: + presence: "required" + eventCode: + type: "string" + flags: + presence: "optional" + orderBody: + type: "string" + flags: + presence: "required" + rules: + - + name: "max" + args: + limit: 500 + + ``` diff --git a/docs/entities/OrderWithoutBody.md b/docs/entities/OrderWithoutBody.md new file mode 100644 index 00000000000..603ebcb8622 --- /dev/null +++ b/docs/entities/OrderWithoutBody.md @@ -0,0 +1,19 @@ +# OrderWithoutBody + ``` +--- + type: "object" + keys: + documentTitle: + type: "string" + flags: + presence: "required" + documentType: + type: "string" + flags: + presence: "required" + eventCode: + type: "string" + flags: + presence: "required" + + ``` diff --git a/docs/entities/Practitioner.md b/docs/entities/Practitioner.md index 3356053c047..f777ee6bf1b 100644 --- a/docs/entities/Practitioner.md +++ b/docs/entities/Practitioner.md @@ -182,6 +182,25 @@ presence: "required" allow: - "Practitioner" + section: + type: "string" + flags: + presence: "optional" + token: + type: "string" + flags: + presence: "optional" + userId: + type: "string" + flags: + presence: "required" + rules: + - + name: "guid" + args: + options: + version: + - "uuidv4" name: type: "string" flags: @@ -281,76 +300,6 @@ presence: "optional" allow: - null - section: - type: "string" - flags: - only: true - presence: "optional" - allow: - - "adc" - - "admissions" - - "chambers" - - "clerkofcourt" - - "docket" - - "petitions" - - "trialClerks" - - "armensChambers" - - "ashfordsChambers" - - "buchsChambers" - - "carluzzosChambers" - - "cohensChambers" - - "colvinsChambers" - - "copelandsChambers" - - "foleysChambers" - - "galesChambers" - - "gerbersChambers" - - "goekesChambers" - - "gustafsonsChambers" - - "guysChambers" - - "halpernsChambers" - - "holmesChambers" - - "jacobsChambers" - - "kerrigansChambers" - - "laubersChambers" - - "leydensChambers" - - "marvelsChambers" - - "morrisonsChambers" - - "negasChambers" - - "panuthosChambers" - - "parisChambers" - - "pughsChambers" - - "ruwesChambers" - - "thorntonsChambers" - - "urdasChambers" - - "vasquezsChambers" - - "wellsChambers" - - "admin" - - "admissionsclerk" - - "docketclerk" - - "floater" - - "inactivePractitioner" - - "irsPractitioner" - - "irsSuperuser" - - "judge" - - "petitioner" - - "petitionsclerk" - - "privatePractitioner" - - "trialclerk" - token: - type: "string" - flags: - presence: "optional" - userId: - type: "string" - flags: - presence: "required" - rules: - - - name: "guid" - args: - options: - version: - - "uuidv4" additionalPhone: type: "string" flags: diff --git a/docs/entities/PrivatePractitioner.md b/docs/entities/PrivatePractitioner.md index 5abad018375..4a7fa446fbc 100644 --- a/docs/entities/PrivatePractitioner.md +++ b/docs/entities/PrivatePractitioner.md @@ -178,6 +178,25 @@ presence: "required" allow: - "PrivatePractitioner" + section: + type: "string" + flags: + presence: "optional" + token: + type: "string" + flags: + presence: "optional" + userId: + type: "string" + flags: + presence: "required" + rules: + - + name: "guid" + args: + options: + version: + - "uuidv4" name: type: "string" flags: @@ -256,76 +275,6 @@ presence: "optional" allow: - null - section: - type: "string" - flags: - only: true - presence: "optional" - allow: - - "adc" - - "admissions" - - "chambers" - - "clerkofcourt" - - "docket" - - "petitions" - - "trialClerks" - - "armensChambers" - - "ashfordsChambers" - - "buchsChambers" - - "carluzzosChambers" - - "cohensChambers" - - "colvinsChambers" - - "copelandsChambers" - - "foleysChambers" - - "galesChambers" - - "gerbersChambers" - - "goekesChambers" - - "gustafsonsChambers" - - "guysChambers" - - "halpernsChambers" - - "holmesChambers" - - "jacobsChambers" - - "kerrigansChambers" - - "laubersChambers" - - "leydensChambers" - - "marvelsChambers" - - "morrisonsChambers" - - "negasChambers" - - "panuthosChambers" - - "parisChambers" - - "pughsChambers" - - "ruwesChambers" - - "thorntonsChambers" - - "urdasChambers" - - "vasquezsChambers" - - "wellsChambers" - - "admin" - - "admissionsclerk" - - "docketclerk" - - "floater" - - "inactivePractitioner" - - "irsPractitioner" - - "irsSuperuser" - - "judge" - - "petitioner" - - "petitionsclerk" - - "privatePractitioner" - - "trialclerk" - token: - type: "string" - flags: - presence: "optional" - userId: - type: "string" - flags: - presence: "required" - rules: - - - name: "guid" - args: - options: - version: - - "uuidv4" representingPrimary: type: "boolean" flags: diff --git a/docs/entities/Scan.md b/docs/entities/Scan.md new file mode 100644 index 00000000000..93c44d0c231 --- /dev/null +++ b/docs/entities/Scan.md @@ -0,0 +1,34 @@ +# Scan + ``` +--- + type: "object" + keys: + batches: + type: "array" + flags: + presence: "required" + rules: + - + name: "min" + args: + limit: 1 + createdAt: + type: "date" + flags: + format: + - "YYYY-MM-DDTHH:mm:ss.SSSZ" + - "YYYY-MM-DD" + presence: "required" + scanId: + type: "string" + flags: + presence: "required" + rules: + - + name: "guid" + args: + options: + version: + - "uuidv4" + + ``` diff --git a/docs/entities/User.md b/docs/entities/User.md index 276747a838a..ae9319383af 100644 --- a/docs/entities/User.md +++ b/docs/entities/User.md @@ -178,6 +178,25 @@ presence: "required" allow: - "User" + section: + type: "string" + flags: + presence: "optional" + token: + type: "string" + flags: + presence: "optional" + userId: + type: "string" + flags: + presence: "required" + rules: + - + name: "guid" + args: + options: + version: + - "uuidv4" name: type: "string" flags: @@ -270,75 +289,5 @@ presence: "optional" allow: - null - section: - type: "string" - flags: - only: true - presence: "optional" - allow: - - "adc" - - "admissions" - - "chambers" - - "clerkofcourt" - - "docket" - - "petitions" - - "trialClerks" - - "armensChambers" - - "ashfordsChambers" - - "buchsChambers" - - "carluzzosChambers" - - "cohensChambers" - - "colvinsChambers" - - "copelandsChambers" - - "foleysChambers" - - "galesChambers" - - "gerbersChambers" - - "goekesChambers" - - "gustafsonsChambers" - - "guysChambers" - - "halpernsChambers" - - "holmesChambers" - - "jacobsChambers" - - "kerrigansChambers" - - "laubersChambers" - - "leydensChambers" - - "marvelsChambers" - - "morrisonsChambers" - - "negasChambers" - - "panuthosChambers" - - "parisChambers" - - "pughsChambers" - - "ruwesChambers" - - "thorntonsChambers" - - "urdasChambers" - - "vasquezsChambers" - - "wellsChambers" - - "admin" - - "admissionsclerk" - - "docketclerk" - - "floater" - - "inactivePractitioner" - - "irsPractitioner" - - "irsSuperuser" - - "judge" - - "petitioner" - - "petitionsclerk" - - "privatePractitioner" - - "trialclerk" - token: - type: "string" - flags: - presence: "optional" - userId: - type: "string" - flags: - presence: "required" - rules: - - - name: "guid" - args: - options: - version: - - "uuidv4" ``` diff --git a/docs/entities/UserCase.md b/docs/entities/UserCase.md new file mode 100644 index 00000000000..e1e0dbe9990 --- /dev/null +++ b/docs/entities/UserCase.md @@ -0,0 +1,79 @@ +# UserCase + ``` +--- + type: "object" + keys: + caseCaption: + type: "string" + flags: + presence: "required" + description: "The name of the party bringing the case, e.g. \"Carol Williams, Petitioner,\" \"Mark Taylor, Incompetent, Debra Thomas, Next Friend, Petitioner,\" or \"Estate of Test Taxpayer, Deceased, Petitioner.\" This is the first half of the case title." + rules: + - + name: "max" + args: + limit: 500 + caseId: + type: "string" + flags: + presence: "required" + description: "Unique case ID only used by the system." + rules: + - + name: "guid" + args: + options: + version: + - "uuidv4" + docketNumber: + type: "string" + flags: + presence: "required" + description: "Unique case ID in XXXXX-YY format." + rules: + - + name: "pattern" + args: + regex: "/^([1-9]\\d{2,4}-\\d{2})$/" + docketNumberWithSuffix: + type: "string" + flags: + presence: "optional" + description: "Auto-generated from docket number and the suffix." + leadCaseId: + type: "string" + flags: + presence: "optional" + description: "If this case is consolidated, this is the ID of the lead case. It is the lowest docket number in the consolidated group." + rules: + - + name: "guid" + args: + options: + version: + - "uuidv4" + status: + type: "string" + flags: + only: true + presence: "optional" + description: "Status of the case." + allow: + - "Assigned - Case" + - "Assigned - Motion" + - "Calendared" + - "CAV" + - "Closed" + - "General Docket - Not at Issue" + - "General Docket - At Issue (Ready for Trial)" + - "Jurisdiction Retained" + - "New" + - "On Appeal" + - "Rule 155" + - "Submitted" + metas: + - + tags: + - "Restricted" + + ``` diff --git a/docs/entities/UserCaseNote.md b/docs/entities/UserCaseNote.md new file mode 100644 index 00000000000..e23c719cdb7 --- /dev/null +++ b/docs/entities/UserCaseNote.md @@ -0,0 +1,40 @@ +# UserCaseNote + ``` +--- + type: "object" + keys: + caseId: + type: "string" + flags: + presence: "required" + rules: + - + name: "guid" + args: + options: + version: + - "uuidv4" + entityName: + type: "string" + flags: + only: true + presence: "required" + allow: + - "UserCaseNote" + notes: + type: "string" + flags: + presence: "required" + userId: + type: "string" + flags: + presence: "required" + rules: + - + name: "guid" + args: + options: + version: + - "uuidv4" + + ``` diff --git a/docs/entities/WorkItem.md b/docs/entities/WorkItem.md index 1f4ca41b8b5..c607e5e0342 100644 --- a/docs/entities/WorkItem.md +++ b/docs/entities/WorkItem.md @@ -20,12 +20,22 @@ type: "string" flags: presence: "optional" + rules: + - + name: "max" + args: + limit: 100 allow: - null associatedJudge: type: "string" flags: presence: "required" + rules: + - + name: "max" + args: + limit: 100 caseId: type: "string" flags: @@ -44,11 +54,30 @@ caseStatus: type: "string" flags: + only: true presence: "optional" + allow: + - "Assigned - Case" + - "Assigned - Motion" + - "Calendared" + - "CAV" + - "Closed" + - "General Docket - Not at Issue" + - "General Docket - At Issue (Ready for Trial)" + - "Jurisdiction Retained" + - "New" + - "On Appeal" + - "Rule 155" + - "Submitted" caseTitle: type: "string" flags: presence: "optional" + rules: + - + name: "max" + args: + limit: 500 completedAt: type: "date" flags: @@ -60,6 +89,11 @@ type: "string" flags: presence: "optional" + rules: + - + name: "max" + args: + limit: 100 allow: - null completedByUserId: @@ -79,6 +113,11 @@ type: "string" flags: presence: "optional" + rules: + - + name: "max" + args: + limit: 100 allow: - null createdAt: @@ -92,11 +131,24 @@ type: "string" flags: presence: "required" + rules: + - + name: "pattern" + args: + regex: "/^([1-9]\\d{2,4}-\\d{2})$/" docketNumberSuffix: type: "string" flags: + only: true presence: "optional" allow: + - "W" + - "P" + - "X" + - "R" + - "SL" + - "L" + - "S" - null document: type: "object" @@ -143,15 +195,125 @@ section: type: "string" flags: + only: true presence: "required" + allow: + - "adc" + - "admissions" + - "chambers" + - "clerkofcourt" + - "docket" + - "petitions" + - "trialClerks" + - "armensChambers" + - "ashfordsChambers" + - "buchsChambers" + - "carluzzosChambers" + - "cohensChambers" + - "colvinsChambers" + - "copelandsChambers" + - "foleysChambers" + - "galesChambers" + - "gerbersChambers" + - "goekesChambers" + - "gustafsonsChambers" + - "guysChambers" + - "halpernsChambers" + - "holmesChambers" + - "jacobsChambers" + - "jonesChambers" + - "kerrigansChambers" + - "laubersChambers" + - "leydensChambers" + - "marvelsChambers" + - "morrisonsChambers" + - "negasChambers" + - "panuthosChambers" + - "parisChambers" + - "pughsChambers" + - "ruwesChambers" + - "thorntonsChambers" + - "urdasChambers" + - "vasquezsChambers" + - "wellsChambers" + - "admin" + - "admissionsclerk" + - "docketclerk" + - "floater" + - "inactivePractitioner" + - "irsPractitioner" + - "irsSuperuser" + - "judge" + - "petitioner" + - "petitionsclerk" + - "privatePractitioner" + - "trialclerk" + - "irsSystem" sentBy: type: "string" flags: presence: "required" + rules: + - + name: "max" + args: + limit: 100 sentBySection: type: "string" flags: + only: true presence: "optional" + allow: + - "adc" + - "admissions" + - "chambers" + - "clerkofcourt" + - "docket" + - "petitions" + - "trialClerks" + - "armensChambers" + - "ashfordsChambers" + - "buchsChambers" + - "carluzzosChambers" + - "cohensChambers" + - "colvinsChambers" + - "copelandsChambers" + - "foleysChambers" + - "galesChambers" + - "gerbersChambers" + - "goekesChambers" + - "gustafsonsChambers" + - "guysChambers" + - "halpernsChambers" + - "holmesChambers" + - "jacobsChambers" + - "jonesChambers" + - "kerrigansChambers" + - "laubersChambers" + - "leydensChambers" + - "marvelsChambers" + - "morrisonsChambers" + - "negasChambers" + - "panuthosChambers" + - "parisChambers" + - "pughsChambers" + - "ruwesChambers" + - "thorntonsChambers" + - "urdasChambers" + - "vasquezsChambers" + - "wellsChambers" + - "admin" + - "admissionsclerk" + - "docketclerk" + - "floater" + - "inactivePractitioner" + - "irsPractitioner" + - "irsSuperuser" + - "judge" + - "petitioner" + - "petitionsclerk" + - "privatePractitioner" + - "trialclerk" sentByUserId: type: "string" flags: diff --git a/package-lock.json b/package-lock.json index d9b1f530310..440c3fa73d2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -113,35 +113,6 @@ "source-map": "^0.5.0" }, "dependencies": { - "@babel/generator": { - "version": "7.10.2", - "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.10.2.tgz", - "integrity": "sha512-AxfBNHNu99DTMvlUPlt1h2+Hn7knPpH5ayJ8OqDWSeLld+Fi2AYBTC/IejWDM9Edcii4UzZRCsbUt0WlSDsDsA==", - "dev": true, - "requires": { - "@babel/types": "^7.10.2", - "jsesc": "^2.5.1", - "lodash": "^4.17.13", - "source-map": "^0.5.0" - } - }, - "@babel/parser": { - "version": "7.10.2", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.10.2.tgz", - "integrity": "sha512-PApSXlNMJyB4JiGVhCOlzKIif+TKFTvu0aQAhnTvfP/z3vVSN6ZypH5bfUNwFXXjRQtUEBNFd2PtmCmG2Py3qQ==", - "dev": true - }, - "@babel/types": { - "version": "7.10.2", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.10.2.tgz", - "integrity": "sha512-AD3AwWBSz0AWF0AkCN9VPiWrvldXq+/e3cHa4J89vo4ymjz1XwrBFFVZmkJTsQIPNk+ZVomPSXUJqq8yyjZsng==", - "dev": true, - "requires": { - "@babel/helper-validator-identifier": "^7.10.1", - "lodash": "^4.17.13", - "to-fast-properties": "^2.0.0" - } - }, "debug": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", @@ -160,12 +131,12 @@ } }, "@babel/generator": { - "version": "7.10.1", - "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.10.1.tgz", - "integrity": "sha512-AT0YPLQw9DI21tliuJIdplVfLHya6mcGa8ctkv7n4Qv+hYacJrKmNWIteAK1P9iyLikFIAkwqJ7HAOqIDLFfgA==", + "version": "7.10.2", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.10.2.tgz", + "integrity": "sha512-AxfBNHNu99DTMvlUPlt1h2+Hn7knPpH5ayJ8OqDWSeLld+Fi2AYBTC/IejWDM9Edcii4UzZRCsbUt0WlSDsDsA==", "dev": true, "requires": { - "@babel/types": "^7.10.1", + "@babel/types": "^7.10.2", "jsesc": "^2.5.1", "lodash": "^4.17.13", "source-map": "^0.5.0" @@ -441,9 +412,9 @@ } }, "@babel/parser": { - "version": "7.10.1", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.10.1.tgz", - "integrity": "sha512-AUTksaz3FqugBkbTZ1i+lDLG5qy8hIzCaAxEtttU6C0BtZZU9pkNZtWSVAht4EW9kl46YBiyTGMp9xTTGqViNg==", + "version": "7.10.2", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.10.2.tgz", + "integrity": "sha512-PApSXlNMJyB4JiGVhCOlzKIif+TKFTvu0aQAhnTvfP/z3vVSN6ZypH5bfUNwFXXjRQtUEBNFd2PtmCmG2Py3qQ==", "dev": true }, "@babel/plugin-proposal-async-generator-functions": { @@ -603,6 +574,15 @@ "@babel/helper-plugin-utils": "^7.10.1" } }, + "@babel/plugin-syntax-import-meta": { + "version": "7.10.1", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-import-meta/-/plugin-syntax-import-meta-7.10.1.tgz", + "integrity": "sha512-ypC4jwfIVF72og0dgvEcFRdOM2V9Qm1tu7RGmdZOlhsccyK0wisXmMObGuWEOd5jQ+K9wcIgSNftCpk2vkjUfQ==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.10.1" + } + }, "@babel/plugin-syntax-json-strings": { "version": "7.8.3", "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-json-strings/-/plugin-syntax-json-strings-7.8.3.tgz", @@ -1141,19 +1121,6 @@ "invariant": "^2.2.2", "levenary": "^1.1.1", "semver": "^5.5.0" - }, - "dependencies": { - "@babel/types": { - "version": "7.10.2", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.10.2.tgz", - "integrity": "sha512-AD3AwWBSz0AWF0AkCN9VPiWrvldXq+/e3cHa4J89vo4ymjz1XwrBFFVZmkJTsQIPNk+ZVomPSXUJqq8yyjZsng==", - "dev": true, - "requires": { - "@babel/helper-validator-identifier": "^7.10.1", - "lodash": "^4.17.13", - "to-fast-properties": "^2.0.0" - } - } } }, "@babel/preset-modules": { @@ -1198,18 +1165,18 @@ } }, "@babel/runtime": { - "version": "7.10.1", - "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.10.1.tgz", - "integrity": "sha512-nQbbCbQc9u/rpg1XCxoMYQTbSMVZjCDxErQ1ClCn9Pvcmv1lGads19ep0a2VsEiIJeHqjZley6EQGEC3Yo1xMA==", + "version": "7.10.2", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.10.2.tgz", + "integrity": "sha512-6sF3uQw2ivImfVIl62RZ7MXhO2tap69WeWK57vAaimT6AZbE4FbqjdEJIN1UqoD6wI6B+1n9UiagafH1sxjOtg==", "dev": true, "requires": { "regenerator-runtime": "^0.13.4" } }, "@babel/runtime-corejs3": { - "version": "7.10.1", - "resolved": "https://registry.npmjs.org/@babel/runtime-corejs3/-/runtime-corejs3-7.10.1.tgz", - "integrity": "sha512-/NLH0a34E/moPbqB1C/72I2gvMOmOly2JQARcRE1+PWCdHwMQ3la4sz7WnlK/EVHiBjQruH2WqE8YufL632Y8w==", + "version": "7.10.2", + "resolved": "https://registry.npmjs.org/@babel/runtime-corejs3/-/runtime-corejs3-7.10.2.tgz", + "integrity": "sha512-+a2M/u7r15o3dV1NEizr9bRi+KUVnrs/qYxF0Z06DAPx/4VCWaz1WA7EcbE+uqGgt39lp5akWGmHsTseIkHkHg==", "dev": true, "requires": { "core-js-pure": "^3.0.0", @@ -1262,9 +1229,9 @@ } }, "@babel/types": { - "version": "7.10.1", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.10.1.tgz", - "integrity": "sha512-L2yqUOpf3tzlW9GVuipgLEcZxnO+96SzR6fjXMuxxNkIgFJ5+07mHCZ+HkHqaeZu8+3LKnNJJ1bKbjBETQAsrA==", + "version": "7.10.2", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.10.2.tgz", + "integrity": "sha512-AD3AwWBSz0AWF0AkCN9VPiWrvldXq+/e3cHa4J89vo4ymjz1XwrBFFVZmkJTsQIPNk+ZVomPSXUJqq8yyjZsng==", "dev": true, "requires": { "@babel/helper-validator-identifier": "^7.10.1", @@ -1294,14 +1261,11 @@ "dev": true, "requires": { "exec-sh": "^0.3.2", - "minimist": "^1.2.0" + "minimist": "^1.2.5" }, "dependencies": { "minimist": { - "version": "1.2.5", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", - "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==", - "dev": true + "version": "^1.2.5" } } }, @@ -1550,9 +1514,9 @@ } }, "@fortawesome/react-fontawesome": { - "version": "0.1.9", - "resolved": "https://registry.npmjs.org/@fortawesome/react-fontawesome/-/react-fontawesome-0.1.9.tgz", - "integrity": "sha512-49V3WNysLZU5fZ3sqSuys4nGRytsrxJktbv3vuaXkEoxv22C6T7TEG0TW6+nqVjMnkfCQd5xOnmJoZHMF78tOw==", + "version": "0.1.10", + "resolved": "https://registry.npmjs.org/@fortawesome/react-fontawesome/-/react-fontawesome-0.1.10.tgz", + "integrity": "sha512-UGdpJiLBIqR/8xcLrCarf2pChqQFKjDTD02C7ZS/odpOVVl2YuHYRCLEOQ0GpfOk6jtYhmouSFOFoC8qNCe5cg==", "dev": true, "requires": { "prop-types": "^15.7.2" @@ -2449,9 +2413,9 @@ } }, "chalk": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.0.0.tgz", - "integrity": "sha512-N9oWFcegS0sFr9oh1oz2d7Npos6vNoWW9HvtCg5N1KRFpUhaAhvTv5Y58g880fZaEYSNm3qDz8SU1UrGvp+n7A==", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz", + "integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==", "dev": true, "requires": { "ansi-styles": "^4.1.0", @@ -2566,9 +2530,9 @@ } }, "chalk": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.0.0.tgz", - "integrity": "sha512-N9oWFcegS0sFr9oh1oz2d7Npos6vNoWW9HvtCg5N1KRFpUhaAhvTv5Y58g880fZaEYSNm3qDz8SU1UrGvp+n7A==", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz", + "integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==", "dev": true, "requires": { "ansi-styles": "^4.1.0", @@ -2750,9 +2714,9 @@ } }, "chalk": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.0.0.tgz", - "integrity": "sha512-N9oWFcegS0sFr9oh1oz2d7Npos6vNoWW9HvtCg5N1KRFpUhaAhvTv5Y58g880fZaEYSNm3qDz8SU1UrGvp+n7A==", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz", + "integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==", "dev": true, "requires": { "ansi-styles": "^4.1.0", @@ -2890,9 +2854,9 @@ } }, "chalk": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.0.0.tgz", - "integrity": "sha512-N9oWFcegS0sFr9oh1oz2d7Npos6vNoWW9HvtCg5N1KRFpUhaAhvTv5Y58g880fZaEYSNm3qDz8SU1UrGvp+n7A==", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz", + "integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==", "dev": true, "requires": { "ansi-styles": "^4.1.0", @@ -3000,9 +2964,9 @@ } }, "chalk": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.0.0.tgz", - "integrity": "sha512-N9oWFcegS0sFr9oh1oz2d7Npos6vNoWW9HvtCg5N1KRFpUhaAhvTv5Y58g880fZaEYSNm3qDz8SU1UrGvp+n7A==", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz", + "integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==", "dev": true, "requires": { "ansi-styles": "^4.1.0", @@ -3047,6 +3011,55 @@ "integrity": "sha512-qS/a24RA5FEoiJS9wiv6Pwg2c/kiUo3IVUQcfeM9JvsR6pM8Yx+yl/6xWYLckZCT5jpLNhslgjiA8p/XcGyMRQ==", "dev": true }, + "@koa/router": { + "version": "9.0.1", + "resolved": "https://registry.npmjs.org/@koa/router/-/router-9.0.1.tgz", + "integrity": "sha512-OI+OU49CJV4px0WkIMmayBeqVXB/JS1ZMq7UoGlTZt6Y7ijK7kdeQ18+SEHHJPytmtI1y6Hf8XLrpxva3mhv5Q==", + "dev": true, + "requires": { + "debug": "^4.1.1", + "http-errors": "^1.7.3", + "koa-compose": "^4.1.0", + "methods": "^1.1.2", + "path-to-regexp": "^6.1.0" + }, + "dependencies": { + "debug": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", + "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", + "dev": true, + "requires": { + "ms": "^2.1.1" + } + }, + "http-errors": { + "version": "1.7.3", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.7.3.tgz", + "integrity": "sha512-ZTTX0MWrsQ2ZAhA1cejAwDLycFsd7I7nVtnkT3Ol0aqodaKW+0CTZDQ1uBv5whptCnc8e8HeRRJxRs0kmm/Qfw==", + "dev": true, + "requires": { + "depd": "~1.1.2", + "inherits": "2.0.4", + "setprototypeof": "1.1.1", + "statuses": ">= 1.5.0 < 2", + "toidentifier": "1.0.0" + } + }, + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + }, + "path-to-regexp": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-6.1.0.tgz", + "integrity": "sha512-h9DqehX3zZZDCEm+xbfU0ZmwCGFCAAraPJWMXJ4+v32NjZJilVg3k1TcKsRgIb8IQ/izZSaydDc1OhJCZvs2Dw==", + "dev": true + } + } + }, "@mrmlnc/readdir-enhanced": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/@mrmlnc/readdir-enhanced/-/readdir-enhanced-2.2.1.tgz", @@ -3316,19 +3329,20 @@ } }, "@serverless/cli": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/@serverless/cli/-/cli-1.4.0.tgz", - "integrity": "sha512-YqlCiYmRFeGksw6XJaXbigIDlktc7OfRuVpyPB7IZgkCJ9mUlBmvyWdwqJEQdkUz0xPTGsd4Jd/XSrwyiw1Brg==", + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/@serverless/cli/-/cli-1.5.0.tgz", + "integrity": "sha512-hGYbsI/Gf9RFTTZS4yXvufDAv/lk6ae8PGBbjZySEtlx/zqA31PgNaWBqWjCo3+KMfpcq8abDaxiJbsu4OfWew==", "dev": true, "requires": { - "@serverless/core": "^1.0.0", - "@serverless/template": "^1.1.0", - "ansi-escapes": "^4.2.0", + "@serverless/core": "^1.1.2", + "@serverless/template": "^1.1.3", + "@serverless/utils": "^1.1.0", + "ansi-escapes": "^4.3.1", "chalk": "^2.4.2", - "chokidar": "^3.0.2", - "dotenv": "^8.0.0", - "figures": "^3.0.0", - "minimist": "^1.2.0", + "chokidar": "^3.4.0", + "dotenv": "^8.2.0", + "figures": "^3.2.0", + "minimist": "^1.2.5", "prettyoutput": "^1.2.0", "strip-ansi": "^5.2.0" }, @@ -3445,10 +3459,7 @@ "dev": true }, "minimist": { - "version": "1.2.5", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", - "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==", - "dev": true + "version": "^1.2.5" }, "readdirp": { "version": "3.4.0", @@ -3536,14 +3547,14 @@ } }, "@serverless/enterprise-plugin": { - "version": "3.6.12", - "resolved": "https://registry.npmjs.org/@serverless/enterprise-plugin/-/enterprise-plugin-3.6.12.tgz", - "integrity": "sha512-AKfVXBQefJV0RIg3YpDlF9Vep3aMzjpD6lP+lgSVKUVUMEaZnp4x9Y40wc+O7pwAmowM033sFxoIkADEofv1Sg==", + "version": "3.6.13", + "resolved": "https://registry.npmjs.org/@serverless/enterprise-plugin/-/enterprise-plugin-3.6.13.tgz", + "integrity": "sha512-L7DOqo7LviAbYIySV5n+sURwyI5rf6IfVKRzFF3CK/EtbHUBJn7gEdHNo86Xmsm4I251ZggGSsorQvSIzT2VUQ==", "dev": true, "requires": { "@serverless/event-mocks": "^1.1.1", - "@serverless/platform-client": "^0.25.7", - "@serverless/platform-sdk": "^2.3.0", + "@serverless/platform-client": "^0.25.14", + "@serverless/platform-sdk": "^2.3.1", "chalk": "^2.4.2", "child-process-ext": "^2.1.1", "chokidar": "^3.4.0", @@ -3554,12 +3565,12 @@ "fs-extra": "^8.1.0", "iso8601-duration": "^1.2.0", "isomorphic-fetch": "^2.2.1", - "js-yaml": "^3.13.1", + "js-yaml": "^3.14.0", "jsonata": "^1.8.3", "jszip": "^3.4.0", "lodash": "^4.17.15", "memoizee": "^0.4.14", - "moment": "^2.25.3", + "moment": "^2.26.0", "node-dir": "^0.1.17", "node-fetch": "^2.6.0", "regenerator-runtime": "^0.13.5", @@ -3567,7 +3578,7 @@ "simple-git": "^1.132.0", "source-map-support": "^0.5.19", "update-notifier": "^2.5.0", - "uuid": "^8.0.0", + "uuid": "^3.4.0", "yamljs": "^0.3.0" }, "dependencies": { @@ -3681,6 +3692,22 @@ "requires": { "is-number": "^7.0.0" } + }, + "uuid": { + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", + "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==", + "dev": true + }, + "yamljs": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/yamljs/-/yamljs-0.3.0.tgz", + "integrity": "sha512-C/FsVVhht4iPQYXOInoxUM/1ELSf9EsgKH34FofQOp6hwCPrW4vG4w5++TED3xRUo8gD7l0P1J1dLlDYzODsTQ==", + "dev": true, + "requires": { + "argparse": "^1.0.7", + "glob": "^7.0.5" + } } } }, @@ -3847,44 +3874,28 @@ } }, "@serverless/platform-client-china": { - "version": "1.0.14", - "resolved": "https://registry.npmjs.org/@serverless/platform-client-china/-/platform-client-china-1.0.14.tgz", - "integrity": "sha512-cuNkZA551XiaU2fD9ZVjcnqN5L3HvRpLf8JAGNJJ3fe8iBHDLjs+kVCRI/LOF7lUAIcElOvcFeqmsg8GFbbI9g==", + "version": "1.0.18", + "resolved": "https://registry.npmjs.org/@serverless/platform-client-china/-/platform-client-china-1.0.18.tgz", + "integrity": "sha512-M6bucQXgnHF6M+4D4Wt8KCz1bUxpMtG8CPS/WiOhzwwTdG79aYwNIOIC1xo0wtDmrlTwh8ECD8WclAWSHmfaqg==", "dev": true, "requires": { - "@serverless/utils-china": "^0.1.12", + "@serverless/utils-china": "^0.1.13", "archiver": "^4.0.1", "dotenv": "^8.2.0", + "fs-extra": "^8.1.0", "https-proxy-agent": "^5.0.0", "isomorphic-ws": "^4.0.1", - "js-yaml": "^3.13.1", + "js-yaml": "^3.14.0", "jwt-decode": "^2.2.0", "minimatch": "^3.0.4", + "pify": "^5.0.0", "querystring": "^0.2.0", + "stream.pipeline-shim": "^1.1.0", "traverse": "^0.6.6", "urlencode": "^1.1.0", - "ws": "^7.2.1" + "ws": "^7.3.0" }, "dependencies": { - "@serverless/utils-china": { - "version": "0.1.12", - "resolved": "https://registry.npmjs.org/@serverless/utils-china/-/utils-china-0.1.12.tgz", - "integrity": "sha512-H6F6nZ8nAuewQEte6jHai6azi6Ox2+18V6wodgBE+ZIHuQp8ABl3pVgoxqvJhEJ+t/jyDdr2Z0QaHAOaSd3eIw==", - "dev": true, - "requires": { - "@tencent-sdk/capi": "^0.2.15-alpha.0", - "dijkstrajs": "^1.0.1", - "dot-qs": "0.2.0", - "duplexify": "^4.1.1", - "end-of-stream": "^1.4.4", - "https-proxy-agent": "^5.0.0", - "object-assign": "^4.1.1", - "protobufjs": "^6.9.0", - "socket.io-client": "^2.3.0", - "socket.io-stream": "^0.9.1", - "winston": "^3.2.1" - } - }, "agent-base": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.0.tgz", @@ -3969,6 +3980,12 @@ "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", "dev": true }, + "pify": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/pify/-/pify-5.0.0.tgz", + "integrity": "sha512-eW/gHNMlxdSP6dmG6uJip6FXN0EQBwm2clYYd8Wul42Cwu/DK8HEftzsapcNdYe2MfLiIwZqsDk2RDEsTE79hA==", + "dev": true + }, "readable-stream": { "version": "3.6.0", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", @@ -3980,23 +3997,6 @@ "util-deprecate": "^1.0.1" } }, - "winston": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/winston/-/winston-3.2.1.tgz", - "integrity": "sha512-zU6vgnS9dAWCEKg/QYigd6cgMVVNwyTzKs81XZtTFuRwJOcDdBg7AU0mXVyNbs7O5RH2zdv+BdNZUlx7mXPuOw==", - "dev": true, - "requires": { - "async": "^2.6.1", - "diagnostics": "^1.1.1", - "is-stream": "^1.1.0", - "logform": "^2.1.1", - "one-time": "0.0.4", - "readable-stream": "^3.1.1", - "stack-trace": "0.0.x", - "triple-beam": "^1.3.0", - "winston-transport": "^4.3.0" - } - }, "ws": { "version": "7.3.0", "resolved": "https://registry.npmjs.org/ws/-/ws-7.3.0.tgz", @@ -4112,6 +4112,128 @@ "traverse": "^0.6.6" } }, + "@serverless/utils": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@serverless/utils/-/utils-1.1.0.tgz", + "integrity": "sha512-MZBLphb8Dz9/mGclFQ53INznSFHZAwS2z4H8RZb6UPCqcRhW0SRrdLwLmn9JIqLWH4Zn95LbNsAjmzJ4Dl3CPQ==", + "dev": true, + "requires": { + "chalk": "^2.0.1", + "lodash": "^4.17.15", + "rc": "^1.2.8", + "type": "^2.0.0", + "uuid": "^3.4.0", + "write-file-atomic": "^2.4.3" + }, + "dependencies": { + "type": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/type/-/type-2.0.0.tgz", + "integrity": "sha512-KBt58xCHry4Cejnc2ISQAF7QY+ORngsWfxezO68+12hKV6lQY8P/psIkcbjeHWn7MqcgciWJyCCevFMJdIXpow==", + "dev": true + }, + "uuid": { + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", + "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==", + "dev": true + }, + "write-file-atomic": { + "version": "2.4.3", + "resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-2.4.3.tgz", + "integrity": "sha512-GaETH5wwsX+GcnzhPgKcKjJ6M2Cq3/iZp1WyY/X1CSqrW+jVNM9Y7D8EC2sM4ZG/V8wZlSniJnCKWPmBYAucRQ==", + "dev": true, + "requires": { + "graceful-fs": "^4.1.11", + "imurmurhash": "^0.1.4", + "signal-exit": "^3.0.2" + } + } + } + }, + "@serverless/utils-china": { + "version": "0.1.14", + "resolved": "https://registry.npmjs.org/@serverless/utils-china/-/utils-china-0.1.14.tgz", + "integrity": "sha512-M1/bvs/ZhqPfj1yqdsyxu4yIWtCXHd+a5Av/ZXef1deTn1zJHO+ZJdOtvFzWHb0Sr7sX4p2ZHD/vGj0Rve/Pzg==", + "dev": true, + "requires": { + "@tencent-sdk/capi": "0.2.15-alpha.0", + "dijkstrajs": "^1.0.1", + "dot-qs": "0.2.0", + "duplexify": "^4.1.1", + "end-of-stream": "^1.4.4", + "https-proxy-agent": "^5.0.0", + "object-assign": "^4.1.1", + "protobufjs": "^6.9.0", + "socket.io-client": "^2.3.0", + "socket.io-stream": "^0.9.1", + "winston": "^3.2.1" + }, + "dependencies": { + "agent-base": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.0.tgz", + "integrity": "sha512-j1Q7cSCqN+AwrmDd+pzgqc0/NpC655x2bUf5ZjRIO77DcNBFmh+OgRNzF6OKdCC9RSCb19fGd99+bhXFdkRNqw==", + "dev": true, + "requires": { + "debug": "4" + } + }, + "debug": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", + "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", + "dev": true, + "requires": { + "ms": "^2.1.1" + } + }, + "https-proxy-agent": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.0.tgz", + "integrity": "sha512-EkYm5BcKUGiduxzSt3Eppko+PiNWNEpa4ySk9vTC6wDsQJW9rHSa+UhGNJoRYp7bz6Ht1eaRIa6QaJqO5rCFbA==", + "dev": true, + "requires": { + "agent-base": "6", + "debug": "4" + } + }, + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + }, + "readable-stream": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", + "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", + "dev": true, + "requires": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + } + }, + "winston": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/winston/-/winston-3.2.1.tgz", + "integrity": "sha512-zU6vgnS9dAWCEKg/QYigd6cgMVVNwyTzKs81XZtTFuRwJOcDdBg7AU0mXVyNbs7O5RH2zdv+BdNZUlx7mXPuOw==", + "dev": true, + "requires": { + "async": "^2.6.1", + "diagnostics": "^1.1.1", + "is-stream": "^1.1.0", + "logform": "^2.1.1", + "one-time": "0.0.4", + "readable-stream": "^3.1.1", + "stack-trace": "0.0.x", + "triple-beam": "^1.3.0", + "winston-transport": "^4.3.0" + } + } + } + }, "@sindresorhus/is": { "version": "0.7.0", "resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-0.7.0.tgz", @@ -4192,19 +4314,69 @@ } }, "@tencent-sdk/capi": { - "version": "0.2.17", - "resolved": "https://registry.npmjs.org/@tencent-sdk/capi/-/capi-0.2.17.tgz", - "integrity": "sha512-DIenMFJXrd4yb35BbW/7LiikCQotbm9HEBG9S4HKV47tcKt6e4nZrNPO3R2hHgQ2jdo0xfqmlUlCP0O4Q3b9pw==", + "version": "0.2.15-alpha.0", + "resolved": "https://registry.npmjs.org/@tencent-sdk/capi/-/capi-0.2.15-alpha.0.tgz", + "integrity": "sha512-1P3tlXJgQaQIqphh1jVeyXDOajFUFIU4J7MoU3Pwxdx58dOwS59/suTq4El0Fe12pc3Gmhw+eDeQc35GaHYViw==", "dev": true, "requires": { - "@types/chalk": "^2.2.0", - "@types/object-assign": "^4.0.30", - "@types/request": "^2.48.3", - "@types/request-promise-native": "^1.0.17", + "chalk": "^3.0.0", + "moment": "^2.24.0", "object-assign": "^4.1.1", "querystring": "^0.2.0", "request": "^2.88.0", "request-promise-native": "^1.0.8" + }, + "dependencies": { + "ansi-styles": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.2.1.tgz", + "integrity": "sha512-9VGjrMsG1vePxcSweQsN20KY/c4zN0h9fLjqAbwbPfahM3t+NL+M9HC8xeXG2I8pX5NoamTGNuomEUFI7fcUjA==", + "dev": true, + "requires": { + "@types/color-name": "^1.1.1", + "color-convert": "^2.0.1" + } + }, + "chalk": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-3.0.0.tgz", + "integrity": "sha512-4D3B6Wf41KOYRFdszmDqMCGq5VV/uMAB273JILmO+3jAlh8X4qDtdtgCR3fxtbLEMzSx22QdhnDcJvu2u1fVwg==", + "dev": true, + "requires": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + } + }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true + }, + "supports-color": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.1.0.tgz", + "integrity": "sha512-oRSIpR8pxT1Wr2FquTNnGet79b3BWljqOuoW/h4oBhxJ/HUbX5nX6JSruTkvXDCFMwDPvsaTTbvMLKZWSy0R5g==", + "dev": true, + "requires": { + "has-flag": "^4.0.0" + } + } } }, "@types/babel-types": { @@ -4214,9 +4386,9 @@ "dev": true }, "@types/babel__core": { - "version": "7.1.7", - "resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.1.7.tgz", - "integrity": "sha512-RL62NqSFPCDK2FM1pSDH0scHpJvsXtZNiYlMB73DgPBaG1E38ZYVL+ei5EkWRbr+KC4YNiAUNBnRj+bgwpgjMw==", + "version": "7.1.8", + "resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.1.8.tgz", + "integrity": "sha512-KXBiQG2OXvaPWFPDS1rD8yV9vO0OuWIqAEqLsbfX0oU2REN5KuoMnZ1gClWcBhO5I3n6oTVAmrMufOvRqdmFTQ==", "dev": true, "requires": { "@babel/parser": "^7.1.0", @@ -4246,9 +4418,9 @@ } }, "@types/babel__traverse": { - "version": "7.0.11", - "resolved": "https://registry.npmjs.org/@types/babel__traverse/-/babel__traverse-7.0.11.tgz", - "integrity": "sha512-ddHK5icION5U6q11+tV2f9Mo6CZVuT8GJKld2q9LqHSZbvLbH34Kcu2yFGckZut453+eQU6btIA3RihmnRgI+Q==", + "version": "7.0.12", + "resolved": "https://registry.npmjs.org/@types/babel__traverse/-/babel__traverse-7.0.12.tgz", + "integrity": "sha512-t4CoEokHTfcyfb4hUaF9oOHu9RmmNWnm1CP0YmMqOOfClKascOmvlEM736vlqeScuGvBDsHkf8R2INd4DWreQA==", "dev": true, "requires": { "@babel/types": "^7.3.0" @@ -4273,21 +4445,6 @@ "@types/node": "*" } }, - "@types/caseless": { - "version": "0.12.2", - "resolved": "https://registry.npmjs.org/@types/caseless/-/caseless-0.12.2.tgz", - "integrity": "sha512-6ckxMjBBD8URvjB6J3NcnuAn5Pkl7t3TizAg+xdlzzQGSPSmBcXf8KoIH0ua/i+tio+ZRUHEXp0HEmvaR4kt0w==", - "dev": true - }, - "@types/chalk": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/@types/chalk/-/chalk-2.2.0.tgz", - "integrity": "sha512-1zzPV9FDe1I/WHhRkf9SNgqtRJWZqrBWgu7JGveuHmmyR9CnAPCie2N/x+iHrgnpYBIcCJWHBoMRv2TRWktsvw==", - "dev": true, - "requires": { - "chalk": "*" - } - }, "@types/color-name": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/@types/color-name/-/color-name-1.1.1.tgz", @@ -4312,12 +4469,6 @@ "@types/node": "*" } }, - "@types/events": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/@types/events/-/events-3.0.0.tgz", - "integrity": "sha512-EaObqwIvayI5a8dCzhFrjKzVwKLxjoG9T6Ppd5CEo07LRKfQ8Yokw54r5+Wq7FaBQ+yXRvQAYPrHwya1/UFt9g==", - "dev": true - }, "@types/express": { "version": "4.17.6", "resolved": "https://registry.npmjs.org/@types/express/-/express-4.17.6.tgz", @@ -4342,12 +4493,11 @@ } }, "@types/glob": { - "version": "7.1.1", - "resolved": "https://registry.npmjs.org/@types/glob/-/glob-7.1.1.tgz", - "integrity": "sha512-1Bh06cbWJUHMC97acuD6UMG29nMt0Aqz1vF3guLfG+kHHJhy3AyohZFFxYk2f7Q1SQIrNwvncxAE0N/9s70F2w==", + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/@types/glob/-/glob-7.1.2.tgz", + "integrity": "sha512-VgNIkxK+j7Nz5P7jvUZlRvhuPSmsEfS03b0alKcq5V/STUKAa3Plemsn5mrQUO7am6OErJ4rhGEGJbACclrtRA==", "dev": true, "requires": { - "@types/events": "*", "@types/minimatch": "*", "@types/node": "*" } @@ -4371,9 +4521,9 @@ } }, "@types/istanbul-lib-coverage": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.2.tgz", - "integrity": "sha512-rsZg7eL+Xcxsxk2XlBt9KcG8nOp9iYdKCOikY9x2RFJCyOdNj4MKPQty0e8oZr29vVAzKXr1BmR+kZauti3o1w==", + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.3.tgz", + "integrity": "sha512-sz7iLqvVUg1gIedBOvlkxPlc8/uVzyS5OwGz1cKjXzkl3FpL3al0crU8YGU1WoHkxn0Wxbw5tyi6hvzJKNzFsw==", "dev": true }, "@types/istanbul-lib-report": { @@ -4396,15 +4546,21 @@ } }, "@types/json-schema": { - "version": "7.0.4", - "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.4.tgz", - "integrity": "sha512-8+KAKzEvSUdeo+kmqnKrqgeE+LcA0tjYWFY7RPProVYwnqDjukzO+3b6dLD56rYX5TdWejnEOLJYOIeh4CXKuA==", + "version": "7.0.5", + "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.5.tgz", + "integrity": "sha512-7+2BITlgjgDhH0vvwZU/HZJVyk+2XUlvxXe8dFMedNX/aMkaOq++rMAFXc0tM7ij15QaWlbdQASBR9dihi+bDQ==", + "dev": true + }, + "@types/json5": { + "version": "0.0.29", + "resolved": "https://registry.npmjs.org/@types/json5/-/json5-0.0.29.tgz", + "integrity": "sha1-7ihweulOEdK4J7y+UnC86n8+ce4=", "dev": true }, "@types/lodash": { - "version": "4.14.153", - "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.153.tgz", - "integrity": "sha512-lYniGRiRfZf2gGAR9cfRC3Pi5+Q1ziJCKqPmjZocigrSJUVPWf7st1BtSJ8JOeK0FLXVndQ1IjUjTco9CXGo/Q==", + "version": "4.14.155", + "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.155.tgz", + "integrity": "sha512-vEcX7S7aPhsBCivxMwAANQburHBtfN9RdyXFk84IJmu2Z4Hkg1tOFgaslRiEqqvoLtbCBi6ika1EMspE+NZ9Lg==", "dev": true }, "@types/long": { @@ -4441,9 +4597,9 @@ } }, "@types/node": { - "version": "14.0.5", - "resolved": "https://registry.npmjs.org/@types/node/-/node-14.0.5.tgz", - "integrity": "sha512-90hiq6/VqtQgX8Sp0EzeIsv3r+ellbGj4URKj5j30tLlZvRUpnAe9YbYnjl3pJM93GyXU0tghHhvXHq+5rnCKA==", + "version": "14.0.13", + "resolved": "https://registry.npmjs.org/@types/node/-/node-14.0.13.tgz", + "integrity": "sha512-rouEWBImiRaSJsVA+ITTFM6ZxibuAlTuNOCyxVbwreu6k6+ujs7DfnU9o+PShFhET78pMBl3eH+AGSI5eOTkPA==", "dev": true }, "@types/normalize-package-data": { @@ -4452,12 +4608,6 @@ "integrity": "sha512-f5j5b/Gf71L+dbqxIpQ4Z2WlmI/mPJ0fOkGGmFgtb6sAu97EPczzbS3/tJKxmcYDj55OX6ssqwDAWOHIYDRDGA==", "dev": true }, - "@types/object-assign": { - "version": "4.0.30", - "resolved": "https://registry.npmjs.org/@types/object-assign/-/object-assign-4.0.30.tgz", - "integrity": "sha1-iUk3HVqZ9Dge4PHfCpt6GH4H5lI=", - "dev": true - }, "@types/parse-json": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/@types/parse-json/-/parse-json-4.0.0.tgz", @@ -4513,40 +4663,6 @@ "integrity": "sha512-ewFXqrQHlFsgc09MK5jP5iR7vumV/BYayNC6PgJO2LPe8vrnNFyjQjSppfEngITi0qvfKtzFvgKymGheFM9UOA==", "dev": true }, - "@types/request": { - "version": "2.48.5", - "resolved": "https://registry.npmjs.org/@types/request/-/request-2.48.5.tgz", - "integrity": "sha512-/LO7xRVnL3DxJ1WkPGDQrp4VTV1reX9RkC85mJ+Qzykj2Bdw+mG15aAfDahc76HtknjzE16SX/Yddn6MxVbmGQ==", - "dev": true, - "requires": { - "@types/caseless": "*", - "@types/node": "*", - "@types/tough-cookie": "*", - "form-data": "^2.5.0" - }, - "dependencies": { - "form-data": { - "version": "2.5.1", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.5.1.tgz", - "integrity": "sha512-m21N3WOmEEURgk6B9GLOE4RuWOFf28Lhh9qGYeNlGq4VDXUlJy2th2slBNU8Gp8EzloYZOibZJ7t5ecIrFSjVA==", - "dev": true, - "requires": { - "asynckit": "^0.4.0", - "combined-stream": "^1.0.6", - "mime-types": "^2.1.12" - } - } - } - }, - "@types/request-promise-native": { - "version": "1.0.17", - "resolved": "https://registry.npmjs.org/@types/request-promise-native/-/request-promise-native-1.0.17.tgz", - "integrity": "sha512-05/d0WbmuwjtGMYEdHIBZ0tqMJJQ2AD9LG2F6rKNBGX1SSFR27XveajH//2N/XYtual8T9Axwl+4v7oBtPUZqg==", - "dev": true, - "requires": { - "@types/request": "*" - } - }, "@types/serve-static": { "version": "1.13.4", "resolved": "https://registry.npmjs.org/@types/serve-static/-/serve-static-1.13.4.tgz", @@ -4575,12 +4691,6 @@ "integrity": "sha512-l42BggppR6zLmpfU6fq9HEa2oGPEI8yrSPL3GITjfRInppYFahObbIQOQK3UGxEnyQpltZLaPe75046NOZQikw==", "dev": true }, - "@types/tough-cookie": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/@types/tough-cookie/-/tough-cookie-4.0.0.tgz", - "integrity": "sha512-I99sngh224D0M7XgW1s120zxCt3VYQ3IQsuw3P3jbq5GG4yc79+ZjyKznyOGIQrflfylLgcfekeZW/vk0yng6A==", - "dev": true - }, "@types/unist": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/@types/unist/-/unist-2.0.3.tgz", @@ -4868,9 +4978,9 @@ } }, "acorn": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.2.0.tgz", - "integrity": "sha512-apwXVmYVpQ34m/i71vrApRrRKCWQnZZF1+npOD0WV5xZFfwWOmKGQ2RWlfdy9vWITsenisM8M0Qeq8agcFHNiQ==", + "version": "7.3.1", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.3.1.tgz", + "integrity": "sha512-tLc0wSnatxAQHVHUapaHdz72pi9KUyHjq5KyHjGg9Y8Ifdc79pTh2XvI6I1/chZbnM7QtNKzh66ooDogPZSleA==", "dev": true }, "acorn-globals": { @@ -4890,9 +5000,9 @@ "dev": true }, "acorn-node": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/acorn-node/-/acorn-node-2.0.0.tgz", - "integrity": "sha512-BKPICDOEXUF/q/ltRrXLW7QGi+06r68BSQr4BNFZnY8L04KsYRttFq7SDsCdBEwfuGVdBV9AgaQtUkAbHg5Qnw==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/acorn-node/-/acorn-node-2.0.1.tgz", + "integrity": "sha512-VLR5sHqjk+8c5hrKeP2fWaIHb8eewsoxnZ8r2qpwRHXMHuC7KyOPflnOx9dLssVQUurzJ7rO0OzIFjHcndafWw==", "dev": true, "requires": { "acorn": "^7.0.0", @@ -5496,12 +5606,12 @@ "dev": true }, "aws-sdk": { - "version": "2.686.0", - "resolved": "https://registry.npmjs.org/aws-sdk/-/aws-sdk-2.686.0.tgz", - "integrity": "sha512-QhYhJ5y8tUG5SlmY3CSf9RBaa3EFbta28oarOyiwceHKmY80cMCafRI1YypT6CVDx/q91dbnSNQfWhs0cZPbBQ==", + "version": "2.697.0", + "resolved": "https://registry.npmjs.org/aws-sdk/-/aws-sdk-2.697.0.tgz", + "integrity": "sha512-aNrwiPRHQyzjJxpfgLwVOevuGTOMkU5uiP4VDIngfc/k4s2kQgLSyhLSKmNTjbubHCHfs1sQQkP3RXK2Oi8Rbw==", "dev": true, "requires": { - "buffer": "4.9.1", + "buffer": "4.9.2", "events": "1.1.1", "ieee754": "1.1.13", "jmespath": "0.15.0", @@ -5513,9 +5623,9 @@ }, "dependencies": { "buffer": { - "version": "4.9.1", - "resolved": "https://registry.npmjs.org/buffer/-/buffer-4.9.1.tgz", - "integrity": "sha1-bRu2AbB6TvztlwlBMgkwJ8lbwpg=", + "version": "4.9.2", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-4.9.2.tgz", + "integrity": "sha512-xq+q3SRMOxGivLhBNaUdC64hDTQwejJ+H0T/NB1XMtTVEwNTrfFF3gAxiyW0Bu/xWEGhjVKgUcMhCrUy2+uCWg==", "dev": true, "requires": { "base64-js": "^1.0.2", @@ -5672,9 +5782,9 @@ } }, "chalk": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.0.0.tgz", - "integrity": "sha512-N9oWFcegS0sFr9oh1oz2d7Npos6vNoWW9HvtCg5N1KRFpUhaAhvTv5Y58g880fZaEYSNm3qDz8SU1UrGvp+n7A==", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz", + "integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==", "dev": true, "requires": { "ansi-styles": "^4.1.0", @@ -5800,14 +5910,15 @@ "dev": true }, "babel-preset-current-node-syntax": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/babel-preset-current-node-syntax/-/babel-preset-current-node-syntax-0.1.2.tgz", - "integrity": "sha512-u/8cS+dEiK1SFILbOC8/rUI3ml9lboKuuMvZ/4aQnQmhecQAgPw5ew066C1ObnEAUmlx7dv/s2z52psWEtLNiw==", + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/babel-preset-current-node-syntax/-/babel-preset-current-node-syntax-0.1.3.tgz", + "integrity": "sha512-uyexu1sVwcdFnyq9o8UQYsXwXflIh8LvrF5+cKrYam93ned1CStffB3+BEcsxGSgagoA3GEyjDqO4a/58hyPYQ==", "dev": true, "requires": { "@babel/plugin-syntax-async-generators": "^7.8.4", "@babel/plugin-syntax-bigint": "^7.8.3", "@babel/plugin-syntax-class-properties": "^7.8.3", + "@babel/plugin-syntax-import-meta": "^7.8.3", "@babel/plugin-syntax-json-strings": "^7.8.3", "@babel/plugin-syntax-logical-assignment-operators": "^7.8.3", "@babel/plugin-syntax-nullish-coalescing-operator": "^7.8.3", @@ -6728,6 +6839,15 @@ "integrity": "sha1-hZgoeOIbmOHGZCXgPQF0eI9Wnug=", "dev": true }, + "busboy": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/busboy/-/busboy-0.3.1.tgz", + "integrity": "sha512-y7tTxhGKXcyBxRKAni+awqx8uqaJKrSFSNFSeRG5CsWNdmy2BIK+6VGWEW7TZnIO/533mtMEA4rOevQV815YJw==", + "dev": true, + "requires": { + "dicer": "0.3.0" + } + }, "bytes": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.0.tgz", @@ -6917,9 +7037,9 @@ } }, "caniuse-lite": { - "version": "1.0.30001066", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001066.tgz", - "integrity": "sha512-Gfj/WAastBtfxLws0RCh2sDbTK/8rJuSeZMecrSkNGYxPcv7EzblmDGfWQCFEQcSqYE2BRgQiJh8HOD07N5hIw==", + "version": "1.0.30001084", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001084.tgz", + "integrity": "sha512-ftdc5oGmhEbLUuMZ/Qp3mOpzfZLCxPYKcvGv6v2dJJ+8EdqcvZRbAGOiLmkM/PV1QGta/uwBs8/nCl6sokDW6w==", "dev": true }, "capture-exit": { @@ -7561,9 +7681,9 @@ "dev": true }, "comment-parser": { - "version": "0.7.4", - "resolved": "https://registry.npmjs.org/comment-parser/-/comment-parser-0.7.4.tgz", - "integrity": "sha512-Nnl77/mt6sj1BiYSVMeMWzvD0183F2MFOJyFRmZHimUVDYS9J40AvXpiFA7RpU5pQH+HkvYc0dnsHpwW2xmbyQ==", + "version": "0.7.5", + "resolved": "https://registry.npmjs.org/comment-parser/-/comment-parser-0.7.5.tgz", + "integrity": "sha512-iH9YA35ccw94nx5244GVkpyC9eVTsL71jZz6iz5w6RIf79JLF2AsXHXq9p6Oaohyl3sx5qSMnGsWUDFIAfWL4w==", "dev": true }, "common-tags": { @@ -8384,9 +8504,9 @@ "dev": true }, "cypress": { - "version": "4.7.0", - "resolved": "https://registry.npmjs.org/cypress/-/cypress-4.7.0.tgz", - "integrity": "sha512-Vav6wUFhPRlImIND/2lOQlUnAWzgCC/iXyJlJjX9nJOJul5LC1vUpf/m8Oiae870PFPyT0ZLLwPHKTXZNdXmHw==", + "version": "4.8.0", + "resolved": "https://registry.npmjs.org/cypress/-/cypress-4.8.0.tgz", + "integrity": "sha512-Lsff8lF8pq6k/ioNua783tCsxGSLp6gqGXecdIfqCkqjYiOA53XKuEf1CaQJLUVs1dHSf49eDUp/sb620oJjVQ==", "dev": true, "requires": { "@cypress/listr-verbose-renderer": "0.4.1", @@ -8415,7 +8535,7 @@ "listr": "0.14.3", "lodash": "4.17.15", "log-symbols": "3.0.0", - "minimist": "1.2.5", + "minimist": "^1.2.5", "moment": "2.24.0", "ospath": "1.2.2", "pretty-bytes": "5.3.0", @@ -8450,10 +8570,7 @@ "dev": true }, "minimist": { - "version": "1.2.5", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", - "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==", - "dev": true + "version": "^1.2.5" }, "moment": { "version": "2.24.0", @@ -9196,6 +9313,15 @@ "kuler": "1.0.x" } }, + "dicer": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/dicer/-/dicer-0.3.0.tgz", + "integrity": "sha512-MdceRRWqltEG2dZqO769g27N/3PXfcKl04VhYnBlo2YhH7zPi88VebsjTKclaOyiuMaGU72hTfw3VkUitGcVCA==", + "dev": true, + "requires": { + "streamsearch": "0.1.2" + } + }, "diff": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", @@ -9582,9 +9708,9 @@ } }, "electron-to-chromium": { - "version": "1.3.453", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.453.tgz", - "integrity": "sha512-IQbCfjJR0NDDn/+vojTlq7fPSREcALtF8M1n01gw7nQghCtfFYrJ2dfhsp8APr8bANoFC8vRTFVXMOGpT0eetw==", + "version": "1.3.474", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.474.tgz", + "integrity": "sha512-fPkSgT9IBKmVJz02XioNsIpg0WYmkPrvU1lUJblMMJALxyE7/32NGvbJQKKxpNokozPvqfqkuUqVClYsvetcLw==", "dev": true }, "elegant-spinner": { @@ -9687,9 +9813,9 @@ } }, "engine.io-client": { - "version": "3.4.2", - "resolved": "https://registry.npmjs.org/engine.io-client/-/engine.io-client-3.4.2.tgz", - "integrity": "sha512-AWjc1Xg06a6UPFOBAzJf48W1UR/qKYmv/ubgSCumo9GXgvL/xGIvo05dXoBL+2NTLMipDI7in8xK61C17L25xg==", + "version": "3.4.3", + "resolved": "https://registry.npmjs.org/engine.io-client/-/engine.io-client-3.4.3.tgz", + "integrity": "sha512-0NGY+9hioejTEJCaSJZfWZLk4FPI9dN+1H1C4+wj2iuFba47UgZbJzfWs4aNFajnX/qAaYKbe2lLTfEEWzCmcw==", "dev": true, "requires": { "component-emitter": "~1.3.0", @@ -9745,9 +9871,9 @@ } }, "enhanced-resolve": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-4.1.1.tgz", - "integrity": "sha512-98p2zE+rL7/g/DzMHMTF4zZlCgeVdJ7yr6xzEpJRYwFYrGi9ANdn5DnJURg6RpBkyk60XYDnWIv51VfIhfNGuA==", + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-4.2.0.tgz", + "integrity": "sha512-S7eiFb/erugyd1rLb6mQ3Vuq+EXHv5cpCkNqqIkYkBgN2QdFnyCZzFBleqwGEx4lgNGYij81BWnCrFNK7vxvjQ==", "dev": true, "requires": { "graceful-fs": "^4.1.2", @@ -9882,22 +10008,22 @@ } }, "es-abstract": { - "version": "1.17.5", - "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.17.5.tgz", - "integrity": "sha512-BR9auzDbySxOcfog0tLECW8l28eRGpDpU3Dm3Hp4q/N+VtLTmyj4EUN088XZWQDW/hzj6sYRDXeOFsaAODKvpg==", + "version": "1.17.6", + "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.17.6.tgz", + "integrity": "sha512-Fr89bON3WFyUi5EvAeI48QTWX0AyekGgLA8H+c+7fbfCkJwRWRMLd8CQedNEyJuoYYhmtEqY92pgte1FAhBlhw==", "dev": true, "requires": { "es-to-primitive": "^1.2.1", "function-bind": "^1.1.1", "has": "^1.0.3", "has-symbols": "^1.0.1", - "is-callable": "^1.1.5", - "is-regex": "^1.0.5", + "is-callable": "^1.2.0", + "is-regex": "^1.1.0", "object-inspect": "^1.7.0", "object-keys": "^1.1.1", "object.assign": "^4.1.0", - "string.prototype.trimleft": "^2.1.1", - "string.prototype.trimright": "^2.1.1" + "string.prototype.trimend": "^1.0.1", + "string.prototype.trimstart": "^1.0.1" } }, "es-to-primitive": { @@ -10014,9 +10140,9 @@ "dev": true }, "escodegen": { - "version": "1.14.1", - "resolved": "https://registry.npmjs.org/escodegen/-/escodegen-1.14.1.tgz", - "integrity": "sha512-Bmt7NcRySdIfNPfU2ZoXDrrXsG9ZjvDxcAlMfDUgRBjLOWTuIACXPBFJH7Z+cLb40JeQco5toikyc9t9P8E9SQ==", + "version": "1.14.2", + "resolved": "https://registry.npmjs.org/escodegen/-/escodegen-1.14.2.tgz", + "integrity": "sha512-InuOIiKk8wwuOFg6x9BQXbzjrQhtyXh46K9bqVTPzSo2FnyMBaYGBMC6PhQy7yxxil9vIedFBweQBMK74/7o8A==", "dev": true, "requires": { "esprima": "^4.0.1", @@ -10075,9 +10201,9 @@ } }, "eslint": { - "version": "7.1.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-7.1.0.tgz", - "integrity": "sha512-DfS3b8iHMK5z/YLSme8K5cge168I8j8o1uiVmFCgnnjxZQbCGyraF8bMl7Ju4yfBmCuxD7shOF7eqGkcuIHfsA==", + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-7.2.0.tgz", + "integrity": "sha512-B3BtEyaDKC5MlfDa2Ha8/D6DsS4fju95zs0hjS3HdGazw+LNayai38A25qMppK37wWGWNYSPOR6oYzlz5MHsRQ==", "dev": true, "requires": { "@babel/code-frame": "^7.0.0", @@ -10086,10 +10212,10 @@ "cross-spawn": "^7.0.2", "debug": "^4.0.1", "doctrine": "^3.0.0", - "eslint-scope": "^5.0.0", + "eslint-scope": "^5.1.0", "eslint-utils": "^2.0.0", - "eslint-visitor-keys": "^1.1.0", - "espree": "^7.0.0", + "eslint-visitor-keys": "^1.2.0", + "espree": "^7.1.0", "esquery": "^1.2.0", "esutils": "^2.0.2", "file-entry-cache": "^5.0.1", @@ -10135,9 +10261,9 @@ } }, "chalk": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.0.0.tgz", - "integrity": "sha512-N9oWFcegS0sFr9oh1oz2d7Npos6vNoWW9HvtCg5N1KRFpUhaAhvTv5Y58g880fZaEYSNm3qDz8SU1UrGvp+n7A==", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz", + "integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==", "dev": true, "requires": { "ansi-styles": "^4.1.0", @@ -10306,23 +10432,24 @@ } }, "eslint-plugin-import": { - "version": "2.20.2", - "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.20.2.tgz", - "integrity": "sha512-FObidqpXrR8OnCh4iNsxy+WACztJLXAHBO5hK79T1Hc77PgQZkyDGA5Ag9xAvRpglvLNxhH/zSmZ70/pZ31dHg==", + "version": "2.21.2", + "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.21.2.tgz", + "integrity": "sha512-FEmxeGI6yaz+SnEB6YgNHlQK1Bs2DKLM+YF+vuTk5H8J9CLbJLtlPvRFgZZ2+sXiKAlN5dpdlrWOjK8ZoZJpQA==", "dev": true, "requires": { - "array-includes": "^3.0.3", - "array.prototype.flat": "^1.2.1", + "array-includes": "^3.1.1", + "array.prototype.flat": "^1.2.3", "contains-path": "^0.1.0", "debug": "^2.6.9", "doctrine": "1.5.0", - "eslint-import-resolver-node": "^0.3.2", - "eslint-module-utils": "^2.4.1", + "eslint-import-resolver-node": "^0.3.3", + "eslint-module-utils": "^2.6.0", "has": "^1.0.3", "minimatch": "^3.0.4", - "object.values": "^1.1.0", + "object.values": "^1.1.1", "read-pkg-up": "^2.0.0", - "resolve": "^1.12.0" + "resolve": "^1.17.0", + "tsconfig-paths": "^3.9.0" }, "dependencies": { "doctrine": { @@ -10410,9 +10537,9 @@ } }, "eslint-plugin-prettier": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/eslint-plugin-prettier/-/eslint-plugin-prettier-3.1.3.tgz", - "integrity": "sha512-+HG5jmu/dN3ZV3T6eCD7a4BlAySdN7mLIbJYo0z1cFQuI+r2DiTJEFeF68ots93PsnrMxbzIZ2S/ieX+mkrBeQ==", + "version": "3.1.4", + "resolved": "https://registry.npmjs.org/eslint-plugin-prettier/-/eslint-plugin-prettier-3.1.4.tgz", + "integrity": "sha512-jZDa8z76klRqo+TdGDTFJSavwbnWK2ZpqGKNZ+VvweMW516pDUMmQ2koXvxEE4JhzNvTv+radye/bWGBmA6jmg==", "dev": true, "requires": { "prettier-linter-helpers": "^1.0.0" @@ -10674,9 +10801,9 @@ }, "dependencies": { "globals": { - "version": "13.0.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-13.0.0.tgz", - "integrity": "sha512-TdLO3ykvHpNsJZiMr+RfkwoMI+XdDaFbH87w/UZGrSzNvZ5cUU6W50oPKSDZgb6eoMWZ6Pltf5Y3oQBpKLUSkA==", + "version": "13.1.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-13.1.0.tgz", + "integrity": "sha512-4N8AdK8YMcr4nLOUsCP62jhMVAaJVdrEevrmuqHQ/TTXCXVL8ywhd/whKrufcp1zGtKBqw4DHcvsokQ60khOJA==", "dev": true, "requires": { "type-fest": "^0.8.1" @@ -10685,9 +10812,9 @@ } }, "eslint-scope": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.0.0.tgz", - "integrity": "sha512-oYrhJW7S0bxAFDvWqzvMPRm6pcgcnWc4QnofCAqRTRfQC0JcwenzGglTtsLyIuuWFfkqDG9vz67cnttSd53djw==", + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.0.tgz", + "integrity": "sha512-iiGRvtxWqgtx5m8EyQUJihBloE4EnYeGE/bz1wSPwJE6tZuJUtHlhqDM4Xj2ukE8Dyy1+HCZ4hE0fzIVMzb58w==", "dev": true, "requires": { "esrecurse": "^4.1.0", @@ -10695,18 +10822,18 @@ } }, "eslint-utils": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-2.0.0.tgz", - "integrity": "sha512-0HCPuJv+7Wv1bACm8y5/ECVfYdfsAm9xmVb7saeFlxjPYALefjhbYoCkBjPdPzGH8wWyTpAez82Fh3VKYEZ8OA==", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-2.1.0.tgz", + "integrity": "sha512-w94dQYoauyvlDc43XnGB8lU3Zt713vNChgt4EWwhXAP2XkBvndfxF0AgIqKOOasjPIPzj9JqgwkwbCYD0/V3Zg==", "dev": true, "requires": { "eslint-visitor-keys": "^1.1.0" } }, "eslint-visitor-keys": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.1.0.tgz", - "integrity": "sha512-8y9YjtM1JBJU/A9Kc+SbaOV4y29sSWckBwMHa+FGtVj5gN/sbnKDf6xJUl+8g7FAij9LVaP8C24DUiH/f/2Z9A==", + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.2.0.tgz", + "integrity": "sha512-WFb4ihckKil6hu3Dp798xdzSfddwKKU3+nGniKF6HfeW6OLd2OUDEPP7TcHtB5+QXOKg2s6B2DaMPE1Nn/kxKQ==", "dev": true }, "esniff": { @@ -10720,14 +10847,14 @@ } }, "espree": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/espree/-/espree-7.0.0.tgz", - "integrity": "sha512-/r2XEx5Mw4pgKdyb7GNLQNsu++asx/dltf/CI8RFi9oGHxmQFgvLbc5Op4U6i8Oaj+kdslhJtVlEZeAqH5qOTw==", + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/espree/-/espree-7.1.0.tgz", + "integrity": "sha512-dcorZSyfmm4WTuTnE5Y7MEN1DyoPYy1ZR783QW1FJoenn7RailyWFsq/UL6ZAAA7uXurN9FIpYyUs3OfiIW+Qw==", "dev": true, "requires": { - "acorn": "^7.1.1", + "acorn": "^7.2.0", "acorn-jsx": "^5.2.0", - "eslint-visitor-keys": "^1.1.0" + "eslint-visitor-keys": "^1.2.0" } }, "esprima": { @@ -11218,9 +11345,9 @@ } }, "fast-deep-equal": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.1.tgz", - "integrity": "sha512-8UEa58QDLauDNfpbrX55Q9jrGHThw2ZMdOky5Gl1CDtVeJDPVrG4Jxx1N8jw2gkWaff5UUuX1KJd+9zGe2B+ZA==", + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", + "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", "dev": true }, "fast-diff": { @@ -11230,9 +11357,9 @@ "dev": true }, "fast-glob": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.2.2.tgz", - "integrity": "sha512-UDV82o4uQyljznxwMxyVRJgZZt3O5wENYojjzbaGEGZgeOxkLFf+V4cnUD+krzb2F72E18RhamkMZ7AdeggF7A==", + "version": "3.2.4", + "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.2.4.tgz", + "integrity": "sha512-kr/Oo6PX51265qeuCYsyGypiO5uJFgBS0jksyG7FUeCyQzNwYnzrNIMR1NXfkZXsMYXYLRAHgISHBz8gQcxKHQ==", "dev": true, "requires": { "@nodelib/fs.stat": "^2.0.2", @@ -11316,9 +11443,9 @@ "dev": true }, "fast-xml-parser": { - "version": "3.17.3", - "resolved": "https://registry.npmjs.org/fast-xml-parser/-/fast-xml-parser-3.17.3.tgz", - "integrity": "sha512-g3OSnHBWq5hrpS4LUgFWOS87F7B6UDklkI6v2VLC/89Ech00fabXleKEHTVXQBkKyVsfOxD+1QY6fkoIZMIO/Q==", + "version": "3.17.4", + "resolved": "https://registry.npmjs.org/fast-xml-parser/-/fast-xml-parser-3.17.4.tgz", + "integrity": "sha512-qudnQuyYBgnvzf5Lj/yxMcf4L9NcVWihXJg7CiU1L+oUCq8MUnFEfH2/nXR/W5uq+yvUN1h7z6s7vs2v1WkL1A==", "dev": true }, "fastparse": { @@ -11800,9 +11927,9 @@ }, "dependencies": { "ignore": { - "version": "5.1.6", - "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.1.6.tgz", - "integrity": "sha512-cgXgkypZBcCnOgSihyeqbo6gjIaIyDqPQB7Ra4vhE9m6kigdGoQDMHjviFhRZo3IMlRy6yElosoviMs5YxZXUA==", + "version": "5.1.8", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.1.8.tgz", + "integrity": "sha512-BMpfD7PpiETpBl/A6S498BaIJ6Y/ABT93ETbby2fP00v4EbvPBXWEoaR1UBPKs3iR53pJY7EtZk5KACI57i1Uw==", "dev": true }, "type": { @@ -12159,9 +12286,9 @@ }, "dependencies": { "ignore": { - "version": "5.1.6", - "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.1.6.tgz", - "integrity": "sha512-cgXgkypZBcCnOgSihyeqbo6gjIaIyDqPQB7Ra4vhE9m6kigdGoQDMHjviFhRZo3IMlRy6yElosoviMs5YxZXUA==", + "version": "5.1.8", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.1.8.tgz", + "integrity": "sha512-BMpfD7PpiETpBl/A6S498BaIJ6Y/ABT93ETbby2fP00v4EbvPBXWEoaR1UBPKs3iR53pJY7EtZk5KACI57i1Uw==", "dev": true }, "slash": { @@ -12179,13 +12306,13 @@ "dev": true }, "globule": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/globule/-/globule-1.3.1.tgz", - "integrity": "sha512-OVyWOHgw29yosRHCHo7NncwR1hW5ew0W/UrvtwvjefVJeQ26q4/8r8FmPsSF1hJ93IgWkyv16pCTz6WblMzm/g==", + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/globule/-/globule-1.3.2.tgz", + "integrity": "sha512-7IDTQTIu2xzXkT+6mlluidnWo+BypnbSoEVVQCGfzqnl5Ik8d3e1d4wycb8Rj9tWW+Z39uPWsdlquqiqPCd/pA==", "dev": true, "requires": { "glob": "~7.1.1", - "lodash": "~4.17.12", + "lodash": "~4.17.10", "minimatch": "~3.0.2" } }, @@ -12199,10 +12326,7 @@ }, "dependencies": { "minimist": { - "version": "1.2.5", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", - "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==", - "dev": true + "version": "^1.2.5" } } }, @@ -12922,9 +13046,9 @@ } }, "chalk": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.0.0.tgz", - "integrity": "sha512-N9oWFcegS0sFr9oh1oz2d7Npos6vNoWW9HvtCg5N1KRFpUhaAhvTv5Y58g880fZaEYSNm3qDz8SU1UrGvp+n7A==", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz", + "integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==", "dev": true, "requires": { "ansi-styles": "^4.1.0", @@ -13290,9 +13414,9 @@ "dev": true }, "inquirer": { - "version": "7.1.0", - "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-7.1.0.tgz", - "integrity": "sha512-5fJMWEmikSYu0nv/flMc475MhGbB7TSPd/2IpFV4I4rMklboCH2rQjYY5kKiYGHqUF9gvaambupcJFFG9dvReg==", + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-7.2.0.tgz", + "integrity": "sha512-E0c4rPwr9ByePfNlTIB8z51kK1s2n6jrHuJeEHENl/sbq2G/S1auvibgEwNR4uSyiU+PiYHqSwsgGiXjG8p5ZQ==", "dev": true, "requires": { "ansi-escapes": "^4.2.1", @@ -13600,9 +13724,9 @@ "dev": true }, "is-callable": { - "version": "1.1.5", - "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.1.5.tgz", - "integrity": "sha512-ESKv5sMCJB2jnHTWZ3O5itG+O128Hsus4K4Qh1h2/cgn2vbgnLSVqfV46AeJA9D5EeeLa9w81KUXMtn34zhX+Q==", + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.0.tgz", + "integrity": "sha512-pyVD9AaGLxtg6srb2Ng6ynWJqkHU9bEM087AKck0w8QwDarTfNcpIYoU8x8Hv2Icm8u6kFJM18Dag8lyqGkviw==", "dev": true }, "is-ci": { @@ -14030,12 +14154,12 @@ "dev": true }, "is-regex": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.0.5.tgz", - "integrity": "sha512-vlKW17SNq44owv5AQR3Cq0bQPEb8+kF3UKZ2fiZNOWtztYE5i0CzCZxFDwO58qAOWtxdBRVO/V5Qin1wjCqFYQ==", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.1.0.tgz", + "integrity": "sha512-iI97M8KTWID2la5uYXlkbSDQIg4F6o1sYboZKKTDpnDQMLtUL86zxhgDet3Q2SriaYsyGqZ6Mn2SjbRKeLHdqw==", "dev": true, "requires": { - "has": "^1.0.3" + "has-symbols": "^1.0.1" } }, "is-regexp": { @@ -14319,9 +14443,9 @@ } }, "jake": { - "version": "10.7.1", - "resolved": "https://registry.npmjs.org/jake/-/jake-10.7.1.tgz", - "integrity": "sha512-FUkLZXms1LSTQop5EJBdXVzbM0q6yYWMM4vo/TiLQeHJ4UMJVO8DBTZFiAgMBJctin9q92xnr2vdH7Wrpn7tTQ==", + "version": "10.8.2", + "resolved": "https://registry.npmjs.org/jake/-/jake-10.8.2.tgz", + "integrity": "sha512-eLpKyrfG3mzvGE2Du8VoPbeSkRry093+tyNjdYaBbJS9v17knImYGNXQCUV0gLxQtF82m3E8iRb/wdSQZLoq7A==", "dev": true, "requires": { "async": "0.9.x", @@ -14360,9 +14484,9 @@ } }, "chalk": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.0.0.tgz", - "integrity": "sha512-N9oWFcegS0sFr9oh1oz2d7Npos6vNoWW9HvtCg5N1KRFpUhaAhvTv5Y58g880fZaEYSNm3qDz8SU1UrGvp+n7A==", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz", + "integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==", "dev": true, "requires": { "ansi-styles": "^4.1.0", @@ -14569,9 +14693,9 @@ } }, "chalk": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.0.0.tgz", - "integrity": "sha512-N9oWFcegS0sFr9oh1oz2d7Npos6vNoWW9HvtCg5N1KRFpUhaAhvTv5Y58g880fZaEYSNm3qDz8SU1UrGvp+n7A==", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz", + "integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==", "dev": true, "requires": { "ansi-styles": "^4.1.0", @@ -14667,9 +14791,9 @@ } }, "chalk": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.0.0.tgz", - "integrity": "sha512-N9oWFcegS0sFr9oh1oz2d7Npos6vNoWW9HvtCg5N1KRFpUhaAhvTv5Y58g880fZaEYSNm3qDz8SU1UrGvp+n7A==", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz", + "integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==", "dev": true, "requires": { "ansi-styles": "^4.1.0", @@ -14741,9 +14865,9 @@ } }, "chalk": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.0.0.tgz", - "integrity": "sha512-N9oWFcegS0sFr9oh1oz2d7Npos6vNoWW9HvtCg5N1KRFpUhaAhvTv5Y58g880fZaEYSNm3qDz8SU1UrGvp+n7A==", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz", + "integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==", "dev": true, "requires": { "ansi-styles": "^4.1.0", @@ -14934,9 +15058,9 @@ } }, "chalk": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.0.0.tgz", - "integrity": "sha512-N9oWFcegS0sFr9oh1oz2d7Npos6vNoWW9HvtCg5N1KRFpUhaAhvTv5Y58g880fZaEYSNm3qDz8SU1UrGvp+n7A==", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz", + "integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==", "dev": true, "requires": { "ansi-styles": "^4.1.0", @@ -15008,9 +15132,9 @@ } }, "chalk": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.0.0.tgz", - "integrity": "sha512-N9oWFcegS0sFr9oh1oz2d7Npos6vNoWW9HvtCg5N1KRFpUhaAhvTv5Y58g880fZaEYSNm3qDz8SU1UrGvp+n7A==", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz", + "integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==", "dev": true, "requires": { "ansi-styles": "^4.1.0", @@ -15085,9 +15209,9 @@ } }, "chalk": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.0.0.tgz", - "integrity": "sha512-N9oWFcegS0sFr9oh1oz2d7Npos6vNoWW9HvtCg5N1KRFpUhaAhvTv5Y58g880fZaEYSNm3qDz8SU1UrGvp+n7A==", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz", + "integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==", "dev": true, "requires": { "ansi-styles": "^4.1.0", @@ -15214,9 +15338,9 @@ } }, "chalk": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.0.0.tgz", - "integrity": "sha512-N9oWFcegS0sFr9oh1oz2d7Npos6vNoWW9HvtCg5N1KRFpUhaAhvTv5Y58g880fZaEYSNm3qDz8SU1UrGvp+n7A==", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz", + "integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==", "dev": true, "requires": { "ansi-styles": "^4.1.0", @@ -15402,9 +15526,9 @@ } }, "chalk": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.0.0.tgz", - "integrity": "sha512-N9oWFcegS0sFr9oh1oz2d7Npos6vNoWW9HvtCg5N1KRFpUhaAhvTv5Y58g880fZaEYSNm3qDz8SU1UrGvp+n7A==", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz", + "integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==", "dev": true, "requires": { "ansi-styles": "^4.1.0", @@ -15488,9 +15612,9 @@ } }, "chalk": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.0.0.tgz", - "integrity": "sha512-N9oWFcegS0sFr9oh1oz2d7Npos6vNoWW9HvtCg5N1KRFpUhaAhvTv5Y58g880fZaEYSNm3qDz8SU1UrGvp+n7A==", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz", + "integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==", "dev": true, "requires": { "ansi-styles": "^4.1.0", @@ -15584,9 +15708,9 @@ } }, "chalk": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.0.0.tgz", - "integrity": "sha512-N9oWFcegS0sFr9oh1oz2d7Npos6vNoWW9HvtCg5N1KRFpUhaAhvTv5Y58g880fZaEYSNm3qDz8SU1UrGvp+n7A==", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz", + "integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==", "dev": true, "requires": { "ansi-styles": "^4.1.0", @@ -15672,9 +15796,9 @@ } }, "chalk": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.0.0.tgz", - "integrity": "sha512-N9oWFcegS0sFr9oh1oz2d7Npos6vNoWW9HvtCg5N1KRFpUhaAhvTv5Y58g880fZaEYSNm3qDz8SU1UrGvp+n7A==", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz", + "integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==", "dev": true, "requires": { "ansi-styles": "^4.1.0", @@ -15759,9 +15883,9 @@ "dev": true }, "chalk": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.0.0.tgz", - "integrity": "sha512-N9oWFcegS0sFr9oh1oz2d7Npos6vNoWW9HvtCg5N1KRFpUhaAhvTv5Y58g880fZaEYSNm3qDz8SU1UrGvp+n7A==", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz", + "integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==", "dev": true, "requires": { "ansi-styles": "^4.1.0", @@ -15834,9 +15958,9 @@ } }, "chalk": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.0.0.tgz", - "integrity": "sha512-N9oWFcegS0sFr9oh1oz2d7Npos6vNoWW9HvtCg5N1KRFpUhaAhvTv5Y58g880fZaEYSNm3qDz8SU1UrGvp+n7A==", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz", + "integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==", "dev": true, "requires": { "ansi-styles": "^4.1.0", @@ -16193,6 +16317,11 @@ "dev": true, "requires": { "minimist": "^1.2.5" + }, + "dependencies": { + "minimist": { + "version": "^1.2.5" + } } }, "jsonata": { @@ -16265,9 +16394,9 @@ } }, "jsx-ast-utils": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/jsx-ast-utils/-/jsx-ast-utils-2.3.0.tgz", - "integrity": "sha512-3HNoc7nZ1hpZIKB3hJ7BlFRkzCx2BynRtfSwbkqZdpRdvAPsGMnzclPwrvDBS7/lalHTj21NwIeaEpysHBOudg==", + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/jsx-ast-utils/-/jsx-ast-utils-2.4.1.tgz", + "integrity": "sha512-z1xSldJ6imESSzOjd3NNkieVJKRlKYSOtMG8SFyCj2FIrvSaSuli/WjpBkEzCBoR9bYYYFgqJw61Xhu7Lcgk+w==", "dev": true, "requires": { "array-includes": "^3.1.1", @@ -16275,9 +16404,9 @@ } }, "jszip": { - "version": "3.4.0", - "resolved": "https://registry.npmjs.org/jszip/-/jszip-3.4.0.tgz", - "integrity": "sha512-gZAOYuPl4EhPTXT0GjhI3o+ZAz3su6EhLrKUoAivcKqyqC7laS5JEv4XWZND9BgcDcF83vI85yGbDmDR6UhrIg==", + "version": "3.5.0", + "resolved": "https://registry.npmjs.org/jszip/-/jszip-3.5.0.tgz", + "integrity": "sha512-WRtu7TPCmYePR1nazfrtuF216cIVon/3GWOvHS9QR5bIwSbnxtdpma6un3jyGGNhHsKCSzn5Ypk+EkDRvTGiFA==", "dev": true, "requires": { "lie": "~3.3.0", @@ -16396,9 +16525,9 @@ "dev": true }, "koa": { - "version": "2.12.0", - "resolved": "https://registry.npmjs.org/koa/-/koa-2.12.0.tgz", - "integrity": "sha512-WlUBj6PXoVhjI5ljMmlyK+eqkbVFW5XQu8twz6bd4WM2E67IwKgPMu5wIFXGxAsZT7sW5xAB54KhY8WAEkLPug==", + "version": "2.12.1", + "resolved": "https://registry.npmjs.org/koa/-/koa-2.12.1.tgz", + "integrity": "sha512-NuYVKjnBxeEe19VljPO9yNcaKKVrMagcax3jjzZtOlxRY2nThWKQqgnI3Pr1OG7mFtvySoDRixoUWZIt6R9C3A==", "dev": true, "requires": { "accepts": "^1.3.5", @@ -16476,46 +16605,6 @@ "passthrough-counter": "^1.0.0" } }, - "koa-router": { - "version": "7.4.0", - "resolved": "https://registry.npmjs.org/koa-router/-/koa-router-7.4.0.tgz", - "integrity": "sha512-IWhaDXeAnfDBEpWS6hkGdZ1ablgr6Q6pGdXCyK38RbzuH4LkUOpPqPw+3f8l8aTDrQmBQ7xJc0bs2yV4dzcO+g==", - "dev": true, - "requires": { - "debug": "^3.1.0", - "http-errors": "^1.3.1", - "koa-compose": "^3.0.0", - "methods": "^1.0.1", - "path-to-regexp": "^1.1.1", - "urijs": "^1.19.0" - }, - "dependencies": { - "debug": { - "version": "3.2.6", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.6.tgz", - "integrity": "sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==", - "dev": true, - "requires": { - "ms": "^2.1.1" - } - }, - "koa-compose": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/koa-compose/-/koa-compose-3.2.1.tgz", - "integrity": "sha1-qFzLQLfZhtjlo0Wzoazo6rz1Tec=", - "dev": true, - "requires": { - "any-promise": "^1.1.0" - } - }, - "ms": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", - "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", - "dev": true - } - } - }, "kuler": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/kuler/-/kuler-1.0.1.tgz", @@ -16536,8 +16625,7 @@ "dependencies": { "bl": { "version": "3.0.0", - "resolved": "https://registry.npmjs.org/bl/-/bl-3.0.0.tgz", - "integrity": "sha512-EUAyP5UHU5hxF8BPT0LKW8gjYLhq1DQIcneOX/pL/m2Alo+OYDQAJlHq+yseMP50Os2nHXOSic6Ss3vSQeyf4A==", + "bundled": true, "dev": true, "requires": { "readable-stream": "^3.0.1" @@ -16545,14 +16633,12 @@ }, "chownr": { "version": "1.1.2", - "resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.2.tgz", - "integrity": "sha512-GkfeAQh+QNy3wquu9oIZr6SS5x7wGdSgNQvD10X3r+AZr1Oys22HW8kAmDMvNg2+Dm0TeGaEuO8gFwdBXxwO8A==", + "bundled": true, "dev": true }, "end-of-stream": { "version": "1.4.1", - "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.1.tgz", - "integrity": "sha512-1MkrZNvWTKCaigbn+W15elq2BB/L22nqrSY5DKlo3X6+vclJm8Bb5djXJBmEX6fS3+zCh/F4VBK5Z2KxJt4s2Q==", + "bundled": true, "dev": true, "requires": { "once": "^1.4.0" @@ -16560,42 +16646,34 @@ }, "fs-constants": { "version": "1.0.0", - "resolved": "https://registry.npmjs.org/fs-constants/-/fs-constants-1.0.0.tgz", - "integrity": "sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==", + "bundled": true, "dev": true }, "inherits": { "version": "2.0.4", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", - "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "bundled": true, "dev": true }, "minimist": { - "version": "1.2.5", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", - "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==" + "dev": true, + "version": "^1.2.5" }, "mkdirp": { "version": "0.5.1", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", - "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", + "bundled": true, "dev": true, "requires": { - "minimist": "0.0.8" + "minimist": "^1.2.5" }, "dependencies": { "minimist": { - "version": "0.0.8", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", - "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", - "dev": true + "version": "^1.2.5" } } }, "once": { "version": "1.4.0", - "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", - "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "bundled": true, "dev": true, "requires": { "wrappy": "1" @@ -16603,8 +16681,7 @@ }, "pump": { "version": "3.0.0", - "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz", - "integrity": "sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww==", + "bundled": true, "dev": true, "requires": { "end-of-stream": "^1.1.0", @@ -16613,8 +16690,7 @@ }, "readable-stream": { "version": "3.4.0", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.4.0.tgz", - "integrity": "sha512-jItXPLmrSR8jmTRmRWJXCnGJsfy85mB3Wd/uINMXA65yrnFo0cPClFIUWzo2najVNSl+mx7/4W8ttlLWJe99pQ==", + "bundled": true, "dev": true, "requires": { "inherits": "^2.0.3", @@ -16624,14 +16700,12 @@ }, "safe-buffer": { "version": "5.2.0", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.0.tgz", - "integrity": "sha512-fZEwUGbVl7kouZs1jCdMLdt95hdIv0ZeHg6L7qPeciMZhZ+/gdesW4wgTARkrFWEpspjEATAzUGPG8N2jJiwbg==", + "bundled": true, "dev": true }, "string_decoder": { "version": "1.3.0", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", - "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", + "bundled": true, "dev": true, "requires": { "safe-buffer": "~5.2.0" @@ -16639,8 +16713,7 @@ }, "tar-fs": { "version": "2.0.0", - "resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-2.0.0.tgz", - "integrity": "sha512-vaY0obB6Om/fso8a8vakQBzwholQ7v5+uy+tF3Ozvxv1KNezmVQAiWtcNmMHFSFPqL3dJA8ha6gdtFbfX9mcxA==", + "bundled": true, "dev": true, "requires": { "chownr": "^1.1.1", @@ -16651,8 +16724,7 @@ }, "tar-stream": { "version": "2.1.0", - "resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-2.1.0.tgz", - "integrity": "sha512-+DAn4Nb4+gz6WZigRzKEZl1QuJVOLtAwwF+WUxy1fJ6X63CaGaUAxJRD2KEn1OMfcbCjySTYpNC6WmfQoIEOdw==", + "bundled": true, "dev": true, "requires": { "bl": "^3.0.0", @@ -16664,14 +16736,12 @@ }, "util-deprecate": { "version": "1.0.2", - "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", - "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", + "bundled": true, "dev": true }, "wrappy": { "version": "1.0.2", - "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", + "bundled": true, "dev": true } } @@ -16823,9 +16893,9 @@ } }, "lint-staged": { - "version": "10.2.7", - "resolved": "https://registry.npmjs.org/lint-staged/-/lint-staged-10.2.7.tgz", - "integrity": "sha512-srod2bTpF8riaLz+Bgr6v0mI/nSntE8M9jbh4WwAhoosx0G7RKEUIG7mI5Nu5SMbTF9o8GROPgK0Lhf5cDnUUw==", + "version": "10.2.10", + "resolved": "https://registry.npmjs.org/lint-staged/-/lint-staged-10.2.10.tgz", + "integrity": "sha512-dgelFaNH6puUGAcU+OVMgbfpKSerNYsPSn6+nlbRDjovL0KigpsVpCu0PFZG6BJxX8gnHJqaZlR9krZamQsb0w==", "dev": true, "requires": { "chalk": "^4.0.0", @@ -16834,8 +16904,9 @@ "cosmiconfig": "^6.0.0", "debug": "^4.1.1", "dedent": "^0.7.0", + "enquirer": "^2.3.5", "execa": "^4.0.1", - "listr2": "^2.0.2", + "listr2": "^2.1.0", "log-symbols": "^4.0.0", "micromatch": "^4.0.2", "normalize-path": "^3.0.0", @@ -16876,9 +16947,9 @@ } }, "chalk": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.0.0.tgz", - "integrity": "sha512-N9oWFcegS0sFr9oh1oz2d7Npos6vNoWW9HvtCg5N1KRFpUhaAhvTv5Y58g880fZaEYSNm3qDz8SU1UrGvp+n7A==", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz", + "integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==", "dev": true, "requires": { "ansi-styles": "^4.1.0", @@ -17243,25 +17314,19 @@ } }, "listr2": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/listr2/-/listr2-2.0.4.tgz", - "integrity": "sha512-oJaAcplPsa72rKW0eg4P4LbEJjhH+UO2I8uqR/I2wzHrVg16ohSfUy0SlcHS21zfYXxtsUpL8YXGHjyfWMR0cg==", + "version": "2.1.7", + "resolved": "https://registry.npmjs.org/listr2/-/listr2-2.1.7.tgz", + "integrity": "sha512-XCC1sWLkBFFIMIRwG/LedgHUzN2XLEo02ZqXn6fwuP0GlXGE5BCuL6EAbQFb4vZB+++YEonzEXDPWQe+jCoF6Q==", "dev": true, "requires": { - "@samverschueren/stream-to-observable": "^0.3.0", "chalk": "^4.0.0", - "cli-cursor": "^3.1.0", "cli-truncate": "^2.1.0", - "elegant-spinner": "^2.0.0", - "enquirer": "^2.3.5", "figures": "^3.2.0", "indent-string": "^4.0.0", "log-update": "^4.0.0", "p-map": "^4.0.0", - "pad": "^3.2.0", "rxjs": "^6.5.5", - "through": "^2.3.8", - "uuid": "^7.0.2" + "through": "^2.3.8" }, "dependencies": { "ansi-escapes": { @@ -17296,9 +17361,9 @@ "dev": true }, "chalk": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.0.0.tgz", - "integrity": "sha512-N9oWFcegS0sFr9oh1oz2d7Npos6vNoWW9HvtCg5N1KRFpUhaAhvTv5Y58g880fZaEYSNm3qDz8SU1UrGvp+n7A==", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz", + "integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==", "dev": true, "requires": { "ansi-styles": "^4.1.0", @@ -17339,12 +17404,6 @@ "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", "dev": true }, - "elegant-spinner": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/elegant-spinner/-/elegant-spinner-2.0.0.tgz", - "integrity": "sha512-5YRYHhvhYzV/FC4AiMdeSIg3jAYGq9xFvbhZMpPlJoBsfYgrw2DSCYeXfat6tYBu45PWiyRr3+flaCPPmviPaA==", - "dev": true - }, "figures": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/figures/-/figures-3.2.0.tgz", @@ -17477,12 +17536,6 @@ "integrity": "sha512-OdjXJxnCN1AvyLSzeKIgXTXxV+99ZuXl3Hpo9XpJAv9MBcHrrJOQ5kV7ypXOuQie+AmWG25hLbiKdwYTifzcfQ==", "dev": true }, - "uuid": { - "version": "7.0.3", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-7.0.3.tgz", - "integrity": "sha512-DPSke0pXhTZgoF/d+WSt2QaKMCFSfx7QegxEWT+JOuHF5aWrKEn0G+ztjuJg/gG8/ItK+rbPCD/yNv8yyih6Cg==", - "dev": true - }, "wrap-ansi": { "version": "6.2.0", "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-6.2.0.tgz", @@ -17539,14 +17592,11 @@ "integrity": "sha512-aKS4WQjPenRxiQsC93MNfjx+nbF4PAdYzmd/1JIj8HYzqfbu86beTuNgXDzPknWk0n0uARlyewZo4s++ES36Ow==", "dev": true, "requires": { - "minimist": "^1.2.0" + "minimist": "^1.2.5" }, "dependencies": { "minimist": { - "version": "1.2.5", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", - "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==", - "dev": true + "version": "^1.2.5" } } } @@ -17953,12 +18003,12 @@ "dev": true }, "madge": { - "version": "3.9.0", - "resolved": "https://registry.npmjs.org/madge/-/madge-3.9.0.tgz", - "integrity": "sha512-ABR2ZTFga+TPLzlu2u46lcv8WwOzoI6VMTMqe3DyaY0igzyGpXiOIH1vAtziSKC4UHuyTpwkfhjWN5qOYR/5OA==", + "version": "3.9.2", + "resolved": "https://registry.npmjs.org/madge/-/madge-3.9.2.tgz", + "integrity": "sha512-6ZvyKinAOOzcRpvpm1iyOuds+LvWIq3o3GmUYAHMJdIpDAgVY3mphxVzeWNo3agIOv0X0T/zbLycXQm9Rn19nA==", "dev": true, "requires": { - "chalk": "^4.0.0", + "chalk": "^4.1.0", "commander": "^5.1.0", "commondir": "^1.0.1", "debug": "^4.0.1", @@ -17976,8 +18026,10 @@ "ora": "^4.0.4", "pify": "^5.0.0", "pluralize": "^8.0.0", + "precinct": "^6.3.1", "pretty-ms": "^7.0.0", "rc": "^1.2.7", + "typescript": "^3.9.5", "walkdir": "^0.4.1" }, "dependencies": { @@ -17992,9 +18044,9 @@ } }, "chalk": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.0.0.tgz", - "integrity": "sha512-N9oWFcegS0sFr9oh1oz2d7Npos6vNoWW9HvtCg5N1KRFpUhaAhvTv5Y58g880fZaEYSNm3qDz8SU1UrGvp+n7A==", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz", + "integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==", "dev": true, "requires": { "ansi-styles": "^4.1.0", @@ -18138,9 +18190,9 @@ }, "dependencies": { "entities": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/entities/-/entities-2.0.2.tgz", - "integrity": "sha512-dmD3AvJQBUjKpcNkoqr+x+IF0SdRtPz9Vk0uTy4yWqga9ibB6s4v++QFWNohjiUGoMlF552ZvNyXDxz5iW0qmw==", + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/entities/-/entities-2.0.3.tgz", + "integrity": "sha512-MyoZ0jgnLvB2X3Lg5HqpFmn1kybDiIfEQmKzTb5apr51Rb+T3KdmMiqa70T+bhGnyv7bQ6WMj2QMHpGMmlrUYQ==", "dev": true } } @@ -18187,12 +18239,6 @@ "integrity": "sha512-APMBEanjybaPzUrfqU0IMU5I0AswKMH7k8OTLs0vvV4KZpExkTkY87nR/zpbuTPj+gARop7aGUbl11pnDfW6xg==", "dev": true }, - "md5-file": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/md5-file/-/md5-file-4.0.0.tgz", - "integrity": "sha512-UC0qFwyAjn4YdPpKaDNw6gNxRf7Mcx7jC1UGCY4boCzgvU2Aoc1mOGzTtrjjLKhM5ivsnhoKpQVxKPp+1j1qwg==", - "dev": true - }, "md5.js": { "version": "1.3.5", "resolved": "https://registry.npmjs.org/md5.js/-/md5.js-1.3.5.tgz", @@ -18304,7 +18350,7 @@ "decamelize": "^1.1.2", "loud-rejection": "^1.0.0", "map-obj": "^1.0.1", - "minimist": "^1.1.3", + "minimist": "^1.2.5", "normalize-package-data": "^2.3.4", "object-assign": "^4.0.1", "read-pkg-up": "^1.0.1", @@ -18336,10 +18382,7 @@ } }, "minimist": { - "version": "1.2.5", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", - "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==", - "dev": true + "version": "^1.2.5" }, "path-exists": { "version": "2.1.0", @@ -18427,9 +18470,9 @@ "dev": true }, "merge2": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/merge2/-/merge2-1.3.0.tgz", - "integrity": "sha512-2j4DAdlBOkiSZIsaXk4mTE3sRS02yBHAtfy127xRV3bQUFqXkjHCHLW6Scv7DwNRbIWNHH8zpnz9zMaKXIdvYw==", + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz", + "integrity": "sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==", "dev": true }, "methods": { @@ -18530,10 +18573,8 @@ } }, "minimist": { - "version": "1.2.5", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", - "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==", - "dev": true + "dev": true, + "version": "^1.2.5" }, "minimist-options": { "version": "4.1.0", @@ -18617,10 +18658,7 @@ }, "dependencies": { "minimist": { - "version": "1.2.5", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", - "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==", - "dev": true + "version": "^1.2.5" } } }, @@ -18724,18 +18762,6 @@ "isarray": "^1.0.0" } }, - "multiparty": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/multiparty/-/multiparty-4.2.1.tgz", - "integrity": "sha512-AvESCnNoQlZiOfP9R4mxN8M9csy2L16EIbWIkt3l4FuGti9kXBS8QVzlfyg4HEnarJhrzZilgNFlZtqmoiAIIA==", - "dev": true, - "requires": { - "fd-slicer": "1.1.0", - "http-errors": "~1.7.0", - "safe-buffer": "5.1.2", - "uid-safe": "2.1.5" - } - }, "mute-stream": { "version": "0.0.8", "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.8.tgz", @@ -18873,9 +18899,9 @@ } }, "node-addon-api": { - "version": "1.7.1", - "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-1.7.1.tgz", - "integrity": "sha512-2+DuKodWvwRTrCfKOeR24KIc5unKjOh8mz17NCzVnHWfjAdDqbfbjqh7gUT+BkXBRQM52+xCHciKWonJ3CbJMQ==", + "version": "1.7.2", + "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-1.7.2.tgz", + "integrity": "sha512-ibPK3iA+vaY1eEjESkQkM0BbCqFOaZMiXRTtdB0u7b4djtY6JnsjvPdUHVMg6xQt3B8fpTTWHI9A+ADjM9frzg==", "dev": true }, "node-dir": { @@ -19050,9 +19076,9 @@ } }, "node-releases": { - "version": "1.1.57", - "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-1.1.57.tgz", - "integrity": "sha512-ZQmnWS7adi61A9JsllJ2gdj2PauElcjnOwTp2O011iGzoakTxUsDGSe+6vD7wXbKdqhSFymC0OSx35aAMhrSdw==", + "version": "1.1.58", + "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-1.1.58.tgz", + "integrity": "sha512-NxBudgVKiRh/2aPWMgPR7bPTX0VPmGx5QBwCtdHitnqFE5/O8DeBXuIMH1nwNnw/aMo6AjOrpsHzfY3UbUJ7yg==", "dev": true }, "node-sass": { @@ -20245,15 +20271,6 @@ } } }, - "pad": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/pad/-/pad-3.2.0.tgz", - "integrity": "sha512-2u0TrjcGbOjBTJpyewEl4hBO3OeX5wWue7eIFPzQTg6wFSvoaHcBTTUY5m+n0hd04gmTCPuY0kCpVIVuw5etwg==", - "dev": true, - "requires": { - "wcwidth": "^1.0.1" - } - }, "pako": { "version": "0.2.9", "resolved": "https://registry.npmjs.org/pako/-/pako-0.2.9.tgz", @@ -20382,14 +20399,11 @@ "integrity": "sha512-aKS4WQjPenRxiQsC93MNfjx+nbF4PAdYzmd/1JIj8HYzqfbu86beTuNgXDzPknWk0n0uARlyewZo4s++ES36Ow==", "dev": true, "requires": { - "minimist": "^1.2.0" + "minimist": "^1.2.5" }, "dependencies": { "minimist": { - "version": "1.2.5", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", - "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==", - "dev": true + "version": "^1.2.5" } } }, @@ -20556,9 +20570,9 @@ } }, "parcel-plugin-static-files-copy": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/parcel-plugin-static-files-copy/-/parcel-plugin-static-files-copy-2.4.1.tgz", - "integrity": "sha512-PbKm+75L2dTJYOrJYN7b2aV3bCshehz/XLVyuplDDZAbi1au0FyJxu52dYdWnDHvu2df9x6mNMtTY/+hvqWbzQ==", + "version": "2.4.3", + "resolved": "https://registry.npmjs.org/parcel-plugin-static-files-copy/-/parcel-plugin-static-files-copy-2.4.3.tgz", + "integrity": "sha512-tUZn54XsZIZ9hhhNQkyaWaHLvjOj2wra8pp4yPjp1b5p1frQ+YEwG6eaNtaQVyA+UvORsZg+Wni7n9gIOBE8eA==", "dev": true, "requires": { "minimatch": "3.0.4", @@ -20795,9 +20809,9 @@ } }, "pbkdf2": { - "version": "3.0.17", - "resolved": "https://registry.npmjs.org/pbkdf2/-/pbkdf2-3.0.17.tgz", - "integrity": "sha512-U/il5MsrZp7mGg3mSQfn742na2T+1/vHDCG5/iTI3X9MKUuYUZVLQhyRsg06mCgDBTd57TxzgZt7P+fYfjRLtA==", + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/pbkdf2/-/pbkdf2-3.1.1.tgz", + "integrity": "sha512-4Ejy1OPxi9f2tt1rRV7Go7zmfDQ+ZectEQz3VGUQhgq62HtIRPDyG/JtnwIxs6x3uNMwo2V7q1fMvKjb+Tnpqg==", "dev": true, "requires": { "create-hash": "^1.1.2", @@ -21052,9 +21066,9 @@ "dev": true }, "postcss": { - "version": "7.0.31", - "resolved": "https://registry.npmjs.org/postcss/-/postcss-7.0.31.tgz", - "integrity": "sha512-a937VDHE1ftkjk+8/7nj/mrjtmkn69xxzJgRETXdAUU+IgOYPQNJF17haGWbeDxSyk++HA14UA98FurvPyBJOA==", + "version": "7.0.32", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-7.0.32.tgz", + "integrity": "sha512-03eXong5NLnNCD05xscnGKGDZ98CyzoqPSMjOe6SuoQY7Z2hIj0Ld1g/O/UQRuOle2aRtiIRDg9tDcTGAkLfKw==", "dev": true, "requires": { "chalk": "^2.4.2", @@ -21814,22 +21828,22 @@ "dev": true }, "precinct": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/precinct/-/precinct-6.2.0.tgz", - "integrity": "sha512-BCAmnOxZzobF3H1/h/gq70pEyvX/BVLWCrzi8beFD22dqu5Z14qOghNUsI24Wg8oaTsGFcIjOGtFX5L9ttmjVg==", + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/precinct/-/precinct-6.3.1.tgz", + "integrity": "sha512-JAwyLCgTylWminoD7V0VJwMElWmwrVSR6r9HaPWCoswkB4iFzX7aNtO7VBfAVPy+NhmjKb8IF8UmlWJXzUkOIQ==", "dev": true, "requires": { - "commander": "^2.19.0", + "commander": "^2.20.3", "debug": "^4.1.1", "detective-amd": "^3.0.0", "detective-cjs": "^3.1.1", - "detective-es6": "^2.0.0", + "detective-es6": "^2.1.0", "detective-less": "^1.0.2", - "detective-postcss": "^3.0.0", - "detective-sass": "^3.0.0", - "detective-scss": "^2.0.0", + "detective-postcss": "^3.0.1", + "detective-sass": "^3.0.1", + "detective-scss": "^2.0.1", "detective-stylus": "^1.0.0", - "detective-typescript": "^5.1.1", + "detective-typescript": "^5.8.0", "module-definition": "^3.3.0", "node-source-walk": "^4.2.0" }, @@ -22074,9 +22088,9 @@ }, "dependencies": { "@types/node": { - "version": "13.13.9", - "resolved": "https://registry.npmjs.org/@types/node/-/node-13.13.9.tgz", - "integrity": "sha512-EPZBIGed5gNnfWCiwEIwTE2Jdg4813odnG8iNPMQGrqVxrI+wL68SPtPeCX+ZxGBaA6pKAVc6jaKgP/Q0QzfdQ==", + "version": "13.13.12", + "resolved": "https://registry.npmjs.org/@types/node/-/node-13.13.12.tgz", + "integrity": "sha512-zWz/8NEPxoXNT9YyF2osqyA9WjssZukYpgI4UYZpOjcyqwIUqWGkcCionaEb9Ki+FULyPyvNFpg/329Kd2/pbw==", "dev": true } } @@ -22565,9 +22579,9 @@ "dev": true }, "query-string": { - "version": "6.12.1", - "resolved": "https://registry.npmjs.org/query-string/-/query-string-6.12.1.tgz", - "integrity": "sha512-OHj+zzfRMyj3rmo/6G8a5Ifvw3AleL/EbcHMD27YA31Q+cO5lfmQxECkImuNVjcskLcvBRVHNAB3w6udMs1eAA==", + "version": "6.13.1", + "resolved": "https://registry.npmjs.org/query-string/-/query-string-6.13.1.tgz", + "integrity": "sha512-RfoButmcK+yCta1+FuU8REvisx1oEzhMKwhLUNcepQTPGcNMp1sIqjnfCtfnvGSQZQEhaBHvccujtWoUV3TTbA==", "dev": true, "requires": { "decode-uri-component": "^0.2.0", @@ -22661,15 +22675,12 @@ "dev": true, "requires": { "buffer-equal": "0.0.1", - "minimist": "^1.1.3", + "minimist": "^1.2.5", "through2": "^2.0.0" }, "dependencies": { "minimist": { - "version": "1.2.5", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", - "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==", - "dev": true + "version": "^1.2.5" } } }, @@ -22704,12 +22715,6 @@ "ret": "~0.1.10" } }, - "random-bytes": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/random-bytes/-/random-bytes-1.0.0.tgz", - "integrity": "sha1-T2ih3Arli9P7lYSMMDJNt11kNgs=", - "dev": true - }, "randombytes": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz", @@ -22755,15 +22760,12 @@ "requires": { "deep-extend": "^0.6.0", "ini": "~1.3.0", - "minimist": "^1.2.0", + "minimist": "^1.2.5", "strip-json-comments": "~2.0.1" }, "dependencies": { "minimist": { - "version": "1.2.5", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", - "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==", - "dev": true + "version": "^1.2.5" }, "strip-json-comments": { "version": "2.0.1", @@ -22850,9 +22852,9 @@ } }, "react-responsive": { - "version": "8.0.3", - "resolved": "https://registry.npmjs.org/react-responsive/-/react-responsive-8.0.3.tgz", - "integrity": "sha512-F9VXyLao7O8XHXbLjQbIr4+mC6Zr0RDTwNjd7ixTmYEAyKyNanBkLkFchNaMZgszoSK6PgSs/3m/QDWw33/gpg==", + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/react-responsive/-/react-responsive-8.1.0.tgz", + "integrity": "sha512-U8Nv2/ZWACIw/fAE9XNPbc2Xo33X5q1bcCASc2SufvJ9ifB+o/rokfogfznSVcvS22hN1rafGi0uZD6GiVFEHw==", "dev": true, "requires": { "hyphenate-style-name": "^1.0.0", @@ -22994,9 +22996,9 @@ "dev": true }, "regenerate": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/regenerate/-/regenerate-1.4.0.tgz", - "integrity": "sha512-1G6jJVDWrt0rK99kBjvEtziZNCICAuvIPkSiUFIQxVP06RCVpq3dmDo2oi6ABpYaDYaTRr67BEhL8r1wgEZZKg==", + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/regenerate/-/regenerate-1.4.1.tgz", + "integrity": "sha512-j2+C8+NtXQgEKWk49MMP5P/u2GhnahTtVkRIHr5R5lVRlbKvmQ+oS+A5aLKWp2ma5VkT8sh6v+v4hbH0YHR66A==", "dev": true }, "regenerate-unicode-properties": { @@ -23147,9 +23149,9 @@ } }, "remark-stringify": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/remark-stringify/-/remark-stringify-8.0.0.tgz", - "integrity": "sha512-cABVYVloFH+2ZI5bdqzoOmemcz/ZuhQSH6W6ZNYnLojAUUn3xtX7u+6BpnYp35qHoGr2NFBsERV14t4vCIeW8w==", + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/remark-stringify/-/remark-stringify-8.1.0.tgz", + "integrity": "sha512-FSPZv1ds76oAZjurhhuV5qXSUSoz6QRPuwYK38S41sLHwg4oB7ejnmZshj7qwjgYLf93kdz6BOX9j5aidNE7rA==", "dev": true, "requires": { "ccount": "^1.0.0", @@ -23572,29 +23574,28 @@ } }, "s3rver": { - "version": "3.5.0", - "resolved": "https://registry.npmjs.org/s3rver/-/s3rver-3.5.0.tgz", - "integrity": "sha512-hZdrWvAzPr3Np8TJTEqDog41qUqdZaPDW7i5EhgQ2QfsQIwGxw56zQCXmQ+vVD2ks23vpn4u400kWVnWdGft0w==", + "version": "3.6.1", + "resolved": "https://registry.npmjs.org/s3rver/-/s3rver-3.6.1.tgz", + "integrity": "sha512-8PI1yIUJ6WQbDYjidZo/EOknMRxos3uukM1a70VQE2lqzH9A8FUTOhlUGaRiAU/K0teROou1mesUsfrYwpwkCw==", "dev": true, "requires": { - "commander": "^3.0.0", + "@koa/router": "^9.0.0", + "busboy": "^0.3.1", + "commander": "^5.0.0", "fast-xml-parser": "^3.12.19", "fs-extra": "^8.0.0", "he": "^1.2.0", "koa": "^2.7.0", "koa-logger": "^3.2.0", - "koa-router": "^7.4.0", "lodash": "^4.17.5", - "md5-file": "^4.0.0", - "multiparty": "^4.2.1", - "statuses": "^1.5.0", + "statuses": "^2.0.0", "winston": "^3.0.0" }, "dependencies": { "commander": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/commander/-/commander-3.0.2.tgz", - "integrity": "sha512-Gar0ASD4BDyKC4hl4DwHqDrmvjoxWKZigVnAbn5H1owvm4CxCPdb0HQDehwNYMJpla5+M2tPmPARzhtYuwpHow==", + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-5.1.0.tgz", + "integrity": "sha512-P0CysNDQ7rtVw4QIQtm+MRxV66vKFSvlsQvGYXZWR3qFU0jlMKHZZZgw8e+8DSah4UDKMqnknRDQz+xuQXQ/Zg==", "dev": true }, "readable-stream": { @@ -23608,6 +23609,12 @@ "util-deprecate": "^1.0.1" } }, + "statuses": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.0.tgz", + "integrity": "sha512-w9jNUUQdpuVoYqXxnyOakhckBbOxRaoYqJscyIBYCS5ixyCnO7nQn7zBZvP9zf5QOPZcz2DLUpE3KsNPbJBOFA==", + "dev": true + }, "winston": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/winston/-/winston-3.2.1.tgz", @@ -23661,15 +23668,12 @@ "execa": "^1.0.0", "fb-watchman": "^2.0.0", "micromatch": "^3.1.4", - "minimist": "^1.1.1", + "minimist": "^1.2.5", "walker": "~1.0.5" }, "dependencies": { "minimist": { - "version": "1.2.5", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", - "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==", - "dev": true + "version": "^1.2.5" } } }, @@ -23683,9 +23687,9 @@ } }, "sass": { - "version": "1.26.7", - "resolved": "https://registry.npmjs.org/sass/-/sass-1.26.7.tgz", - "integrity": "sha512-xgNazdkr6yvgHEfNaOjKtZzhDZmKYMCmoRKMPrTDo7YvjaITIzU2DDYsIUuN/atAg7/JOxPeCQHH7TtCo5Tq2g==", + "version": "1.26.8", + "resolved": "https://registry.npmjs.org/sass/-/sass-1.26.8.tgz", + "integrity": "sha512-yvtzyrKLGiXQu7H12ekXqsfoGT/aTKeMDyVzCB675k1HYuaj0py63i8Uf4SI9CHXj6apDhpfwbUr3gGOjdpu2Q==", "dev": true, "requires": { "chokidar": ">=2.0.0 <4.0.0" @@ -23989,10 +23993,13 @@ } }, "serialize-javascript": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-2.1.2.tgz", - "integrity": "sha512-rs9OggEUF0V4jUSecXazOYsLfu7OGK2qIn3c7IPBiffz32XniEp/TX9Xmc9LQfK2nQ2QKHvZ2oygKUGU0lG4jQ==", - "dev": true + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-3.1.0.tgz", + "integrity": "sha512-JIJT1DGiWmIKhzRsG91aS6Ze4sFUrYbltlkg2onR5OrnNM02Kl/hnY/T4FN2omvyeBbQmMJv+K4cPOpGzOTFBg==", + "dev": true, + "requires": { + "randombytes": "^2.1.0" + } }, "serialize-to-js": { "version": "3.1.1", @@ -24073,9 +24080,9 @@ }, "dependencies": { "@serverless/components": { - "version": "2.30.11", - "resolved": "https://registry.npmjs.org/@serverless/components/-/components-2.30.11.tgz", - "integrity": "sha512-hji/a7li5prjGYf958kxXfwmiJZlVhrIR7WrdyV84FYUdqnwXc15ReJaL5LDl0TU0AeXnye7mpcHJ/Dlilzc8w==", + "version": "2.30.15", + "resolved": "https://registry.npmjs.org/@serverless/components/-/components-2.30.15.tgz", + "integrity": "sha512-1K8L1DV1pUEYeBtUyJZfCSpfzBuuvCEPwAuu/D89g4Lxlp5DcrnkXUItKFf1sprTR/20q3tS9iKdcgPsU5QFCA==", "dev": true, "requires": { "@serverless/inquirer": "^1.1.0", @@ -24135,10 +24142,7 @@ } }, "minimist": { - "version": "1.2.5", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", - "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==", - "dev": true + "version": "^1.2.5" }, "semver": { "version": "7.3.2", @@ -24405,9 +24409,9 @@ } }, "ignore": { - "version": "5.1.6", - "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.1.6.tgz", - "integrity": "sha512-cgXgkypZBcCnOgSihyeqbo6gjIaIyDqPQB7Ra4vhE9m6kigdGoQDMHjviFhRZo3IMlRy6yElosoviMs5YxZXUA==", + "version": "5.1.8", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.1.8.tgz", + "integrity": "sha512-BMpfD7PpiETpBl/A6S498BaIJ6Y/ABT93ETbby2fP00v4EbvPBXWEoaR1UBPKs3iR53pJY7EtZk5KACI57i1Uw==", "dev": true }, "inquirer": { @@ -24971,9 +24975,9 @@ } }, "serverless-plugin-aws-alerts": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/serverless-plugin-aws-alerts/-/serverless-plugin-aws-alerts-1.5.0.tgz", - "integrity": "sha512-/zqcn39vwEHsVweVYx9wAA37XCQjoyTZJnSWOlhOZrggvevyRYF8u0lKueUoD1Z2M8HgYScPC62ESRNiEGKtSg==", + "version": "1.5.2", + "resolved": "https://registry.npmjs.org/serverless-plugin-aws-alerts/-/serverless-plugin-aws-alerts-1.5.2.tgz", + "integrity": "sha512-ZQ4adV2r9pSX0ARcvLO2bXr0Ql359lYW8w/a0FmmtynjwhYrEw1jhlYQhToZQ/ruS4OrOsRGEvyuf58aTZhhkQ==", "dev": true, "requires": { "lodash": "^4.17.10" @@ -25048,9 +25052,9 @@ }, "dependencies": { "fs-extra": { - "version": "9.0.0", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-9.0.0.tgz", - "integrity": "sha512-pmEYSk3vYsG/bF651KPUXZ+hvjpgWYw/Gc7W9NFUe3ZVLczKKWIij3IKpOrQcdw4TILtibFslZ0UmR8Vvzig4g==", + "version": "9.0.1", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-9.0.1.tgz", + "integrity": "sha512-h2iAoN838FqAFJY2/qVpzFXy+EBxfVE220PalAqQLDVsFOHLJrZvut5puAbCdNv6WJk+B8ihI+k0c7JK5erwqQ==", "dev": true, "requires": { "at-least-node": "^1.0.0", @@ -25777,9 +25781,9 @@ "dev": true }, "static-eval": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/static-eval/-/static-eval-2.0.5.tgz", - "integrity": "sha512-nNbV6LbGtMBgv7e9LFkt5JV8RVlRsyJrphfAt9tOtBBW/SfnzZDf2KnS72an8e434A+9e/BmJuTxeGPvrAK7KA==", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/static-eval/-/static-eval-2.1.0.tgz", + "integrity": "sha512-agtxZ/kWSsCkI5E4QifRwsaPs0P0JmZV6dkLz6ILYfFYQGn+5plctanRN+IC8dJRiFkyXHrwEE3W9Wmx67uDbw==", "dev": true, "requires": { "escodegen": "^1.11.1" @@ -26010,6 +26014,33 @@ "integrity": "sha512-AiisoFqQ0vbGcZgQPY1cdP2I76glaVA/RauYR4G4thNFgkTqr90yXTo4LYX60Jl+sIlPNHHdGSwo01AvbKUSVQ==", "dev": true }, + "stream.finished": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/stream.finished/-/stream.finished-1.2.0.tgz", + "integrity": "sha512-xSp45f/glqd035qAtFUxAGvhotjY/EfqDNV+rQW8o7ffligiOjPaguTEvRzeQAhiQMCdkPEBrp5++S/rQyavWQ==", + "dev": true, + "requires": { + "define-properties": "^1.1.3", + "function-bind": "^1.1.1" + } + }, + "stream.pipeline-shim": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/stream.pipeline-shim/-/stream.pipeline-shim-1.1.0.tgz", + "integrity": "sha512-pSi/SZZDbSA5l3YYjSmJadCoD74/qSe79r9ZVR21lD4bpf+khn5Umi6AlfJrD8I0KQfGSqm/7Yp48dmithM+Vw==", + "dev": true, + "requires": { + "define-properties": "^1.1.3", + "function-bind": "^1.1.1", + "stream.finished": "^1.2.0" + } + }, + "streamsearch": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/streamsearch/-/streamsearch-0.1.2.tgz", + "integrity": "sha1-gIudDlb8Jz2Am6VzOOkpkZoanxo=", + "dev": true + }, "strict-uri-encode": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/strict-uri-encode/-/strict-uri-encode-1.1.0.tgz", @@ -26121,28 +26152,6 @@ "es-abstract": "^1.17.5" } }, - "string.prototype.trimleft": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/string.prototype.trimleft/-/string.prototype.trimleft-2.1.2.tgz", - "integrity": "sha512-gCA0tza1JBvqr3bfAIFJGqfdRTyPae82+KTnm3coDXkZN9wnuW3HjGgN386D7hfv5CHQYCI022/rJPVlqXyHSw==", - "dev": true, - "requires": { - "define-properties": "^1.1.3", - "es-abstract": "^1.17.5", - "string.prototype.trimstart": "^1.0.0" - } - }, - "string.prototype.trimright": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/string.prototype.trimright/-/string.prototype.trimright-2.1.2.tgz", - "integrity": "sha512-ZNRQ7sY3KroTaYjRS6EbNiiHrOkjihL9aQE/8gfQ4DtAC/aEBRHFJa44OmoWxGGqXuJlfKkZW4WcXErGr+9ZFg==", - "dev": true, - "requires": { - "define-properties": "^1.1.3", - "es-abstract": "^1.17.5", - "string.prototype.trimend": "^1.0.0" - } - }, "string.prototype.trimstart": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/string.prototype.trimstart/-/string.prototype.trimstart-1.0.1.tgz", @@ -26285,14 +26294,14 @@ } }, "stylelint": { - "version": "13.5.0", - "resolved": "https://registry.npmjs.org/stylelint/-/stylelint-13.5.0.tgz", - "integrity": "sha512-+Jy7ieKAWKTf2tmcAE7jgScxH39Urb87i0bjK/enScFaGWWaFn4kAPwepGOSk2b7CLUDVt/O6kwA0x0p/V7moQ==", + "version": "13.6.0", + "resolved": "https://registry.npmjs.org/stylelint/-/stylelint-13.6.0.tgz", + "integrity": "sha512-55gG2pNjVr183JJM/tlr3KAua6vTVX7Ho/lgKKuCIWszTZ1gmrXjX4Wok53SI8wRYFPbwKAcJGULQ77OJxTcNw==", "dev": true, "requires": { "@stylelint/postcss-css-in-js": "^0.37.1", "@stylelint/postcss-markdown": "^0.36.1", - "autoprefixer": "^9.7.6", + "autoprefixer": "^9.8.0", "balanced-match": "^1.0.0", "chalk": "^4.0.0", "cosmiconfig": "^6.0.0", @@ -26301,10 +26310,10 @@ "file-entry-cache": "^5.0.1", "get-stdin": "^8.0.0", "global-modules": "^2.0.0", - "globby": "^11.0.0", + "globby": "^11.0.1", "globjoin": "^0.1.4", "html-tags": "^3.1.0", - "ignore": "^5.1.4", + "ignore": "^5.1.8", "import-lazy": "^4.0.0", "imurmurhash": "^0.1.4", "known-css-properties": "^0.19.0", @@ -26315,7 +26324,7 @@ "meow": "^7.0.1", "micromatch": "^4.0.2", "normalize-selector": "^0.2.0", - "postcss": "^7.0.30", + "postcss": "^7.0.32", "postcss-html": "^0.36.0", "postcss-less": "^3.1.4", "postcss-media-query-parser": "^0.2.3", @@ -26323,7 +26332,7 @@ "postcss-resolve-nested-selector": "^0.1.1", "postcss-safe-parser": "^4.0.2", "postcss-sass": "^0.4.4", - "postcss-scss": "^2.0.0", + "postcss-scss": "^2.1.1", "postcss-selector-parser": "^6.0.2", "postcss-syntax": "^0.36.2", "postcss-value-parser": "^4.1.0", @@ -26336,7 +26345,7 @@ "sugarss": "^2.0.0", "svg-tags": "^1.0.0", "table": "^5.4.6", - "v8-compile-cache": "^2.1.0", + "v8-compile-cache": "^2.1.1", "write-file-atomic": "^3.0.3" }, "dependencies": { @@ -26391,9 +26400,9 @@ } }, "chalk": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.0.0.tgz", - "integrity": "sha512-N9oWFcegS0sFr9oh1oz2d7Npos6vNoWW9HvtCg5N1KRFpUhaAhvTv5Y58g880fZaEYSNm3qDz8SU1UrGvp+n7A==", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz", + "integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==", "dev": true, "requires": { "ansi-styles": "^4.1.0", @@ -26450,9 +26459,9 @@ "dev": true }, "globby": { - "version": "11.0.0", - "resolved": "https://registry.npmjs.org/globby/-/globby-11.0.0.tgz", - "integrity": "sha512-iuehFnR3xu5wBBtm4xi0dMe92Ob87ufyu/dHwpDYfbcpYpIbrO5OnS8M1vWvrBhSGEJ3/Ecj7gnX76P8YxpPEg==", + "version": "11.0.1", + "resolved": "https://registry.npmjs.org/globby/-/globby-11.0.1.tgz", + "integrity": "sha512-iH9RmgwCmUJHi2z5o2l3eTtGBtXek1OYlHrbcxOYugyHLmAsZrPj43OtHThd62Buh/Vv6VyCBD2bdyWcGNQqoQ==", "dev": true, "requires": { "array-union": "^2.1.0", @@ -26476,9 +26485,9 @@ "dev": true }, "ignore": { - "version": "5.1.6", - "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.1.6.tgz", - "integrity": "sha512-cgXgkypZBcCnOgSihyeqbo6gjIaIyDqPQB7Ra4vhE9m6kigdGoQDMHjviFhRZo3IMlRy6yElosoviMs5YxZXUA==", + "version": "5.1.8", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.1.8.tgz", + "integrity": "sha512-BMpfD7PpiETpBl/A6S498BaIJ6Y/ABT93ETbby2fP00v4EbvPBXWEoaR1UBPKs3iR53pJY7EtZk5KACI57i1Uw==", "dev": true }, "import-lazy": { @@ -26923,9 +26932,9 @@ } }, "css-what": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/css-what/-/css-what-3.2.1.tgz", - "integrity": "sha512-WwOrosiQTvyms+Ti5ZC5vGEK0Vod3FTt1ca+payZqvKuGJF+dq7bG63DstxtN0dpm6FxY27a/zS3Wten+gEtGw==", + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/css-what/-/css-what-3.3.0.tgz", + "integrity": "sha512-pv9JPyatiPaQ6pf4OvD/dbfm0o5LviWmwxNWzblYf/1u9QZd0ihV+PMwy5jdQWQ3349kZmKEx9WXuSka2dM4cg==", "dev": true }, "domutils": { @@ -26978,9 +26987,9 @@ } }, "chalk": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.0.0.tgz", - "integrity": "sha512-N9oWFcegS0sFr9oh1oz2d7Npos6vNoWW9HvtCg5N1KRFpUhaAhvTv5Y58g880fZaEYSNm3qDz8SU1UrGvp+n7A==", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz", + "integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==", "dev": true, "requires": { "ansi-styles": "^4.1.0", @@ -27097,7 +27106,7 @@ "debug": "^4.0.1", "es6-promisify": "^6.0.0", "inquirer": "^6.0.0", - "minimist": "^1.2.0", + "minimist": "^1.2.5", "mkdirp": "^0.5.1", "untildify": "^3.0.3" }, @@ -27163,10 +27172,7 @@ } }, "minimist": { - "version": "1.2.5", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", - "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==", - "dev": true + "version": "^1.2.5" }, "ms": { "version": "2.1.2", @@ -27400,16 +27406,16 @@ } }, "terser-webpack-plugin": { - "version": "1.4.3", - "resolved": "https://registry.npmjs.org/terser-webpack-plugin/-/terser-webpack-plugin-1.4.3.tgz", - "integrity": "sha512-QMxecFz/gHQwteWwSo5nTc6UaICqN1bMedC5sMtUc7y3Ha3Q8y6ZO0iCR8pq4RJC8Hjf0FEPEHZqcMB/+DFCrA==", + "version": "1.4.4", + "resolved": "https://registry.npmjs.org/terser-webpack-plugin/-/terser-webpack-plugin-1.4.4.tgz", + "integrity": "sha512-U4mACBHIegmfoEe5fdongHESNJWqsGU+W0S/9+BmYGVQDw1+c2Ow05TpMhxjPK1sRb7cuYq1BPl1e5YHJMTCqA==", "dev": true, "requires": { "cacache": "^12.0.2", "find-cache-dir": "^2.1.0", "is-wsl": "^1.1.0", "schema-utils": "^1.0.0", - "serialize-javascript": "^2.1.2", + "serialize-javascript": "^3.1.0", "source-map": "^0.6.1", "terser": "^4.1.2", "webpack-sources": "^1.4.0", @@ -27776,6 +27782,37 @@ "integrity": "sha512-c3zayb8/kWWpycWYg87P71E1S1ZL6b6IJxfb5fvsUgsf0S2MVGaDhDXXjDMpdCpfWXqptc+4mXwmiy1ypXqRAA==", "dev": true }, + "tsconfig-paths": { + "version": "3.9.0", + "resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-3.9.0.tgz", + "integrity": "sha512-dRcuzokWhajtZWkQsDVKbWyY+jgcLC5sqJhg2PSgf4ZkH2aHPvaOY8YWGhmjb68b5qqTfasSsDO9k7RUiEmZAw==", + "dev": true, + "requires": { + "@types/json5": "^0.0.29", + "json5": "^1.0.1", + "minimist": "^1.2.5", + "strip-bom": "^3.0.0" + }, + "dependencies": { + "json5": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.1.tgz", + "integrity": "sha512-aKS4WQjPenRxiQsC93MNfjx+nbF4PAdYzmd/1JIj8HYzqfbu86beTuNgXDzPknWk0n0uARlyewZo4s++ES36Ow==", + "dev": true, + "requires": { + "minimist": "^1.2.5" + }, + "dependencies": { + "minimist": { + "version": "^1.2.5" + } + } + }, + "minimist": { + "version": "^1.2.5" + } + } + }, "tslib": { "version": "1.13.0", "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.13.0.tgz", @@ -27871,9 +27908,9 @@ } }, "typescript": { - "version": "3.9.3", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.9.3.tgz", - "integrity": "sha512-D/wqnB2xzNFIcoBG9FG8cXRDjiqSTbG2wd8DMZeQyJlP1vfTkIxH4GKveWaEBYySKIg+USu+E+EDIR47SqnaMQ==", + "version": "3.9.5", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.9.5.tgz", + "integrity": "sha512-hSAifV3k+i6lEoCJ2k6R2Z/rp/H3+8sdmcn5NrS3/3kE7+RyZXm9aqvxWqjEXHAd8b0pShatpcdMTvEdvAJltQ==", "dev": true }, "uc.micro": { @@ -27937,15 +27974,6 @@ "dev": true, "optional": true }, - "uid-safe": { - "version": "2.1.5", - "resolved": "https://registry.npmjs.org/uid-safe/-/uid-safe-2.1.5.tgz", - "integrity": "sha512-KPHm4VL5dDXKz01UuEd88Df+KzynaohSL9fBh096KWAxSKZQDI2uBrVqtvRM4rwrIrRRKsdLNML/lnaaVSRioA==", - "dev": true, - "requires": { - "random-bytes": "~1.0.0" - } - }, "ultron": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/ultron/-/ultron-1.1.1.tgz", @@ -28602,9 +28630,9 @@ }, "dependencies": { "@types/node": { - "version": "13.13.9", - "resolved": "https://registry.npmjs.org/@types/node/-/node-13.13.9.tgz", - "integrity": "sha512-EPZBIGed5gNnfWCiwEIwTE2Jdg4813odnG8iNPMQGrqVxrI+wL68SPtPeCX+ZxGBaA6pKAVc6jaKgP/Q0QzfdQ==", + "version": "13.13.12", + "resolved": "https://registry.npmjs.org/@types/node/-/node-13.13.12.tgz", + "integrity": "sha512-zWz/8NEPxoXNT9YyF2osqyA9WjssZukYpgI4UYZpOjcyqwIUqWGkcCionaEb9Ki+FULyPyvNFpg/329Kd2/pbw==", "dev": true }, "typescript": { @@ -28675,9 +28703,9 @@ "dev": true }, "v8-compile-cache": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.1.0.tgz", - "integrity": "sha512-usZBT3PW+LOjM25wbqIlZwPeJV+3OSz3M1k1Ws8snlW39dZyYL9lOGC5FgPVHfk0jKmjiDV8Z0mIbVQPiwFs7g==", + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.1.1.tgz", + "integrity": "sha512-8OQ9CL+VWyt3JStj7HX7/ciTL2V3Rl1Wf5OL+SNTm0yK1KvtReVulksyeRnCANHHuUxHlQig+JJDlUhBt1NQDQ==", "dev": true }, "v8-to-istanbul": { @@ -29450,16 +29478,6 @@ "integrity": "sha512-2PTINUwsRqSd+s8XxKaJWQlUuEMHJQyEuh2edBbW8KNJz0SJPwUSD2zRWqezFEdN7IzAgeuYHFUCF7o8zRdZ0A==", "dev": true }, - "yamljs": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/yamljs/-/yamljs-0.3.0.tgz", - "integrity": "sha512-C/FsVVhht4iPQYXOInoxUM/1ELSf9EsgKH34FofQOp6hwCPrW4vG4w5++TED3xRUo8gD7l0P1J1dLlDYzODsTQ==", - "dev": true, - "requires": { - "argparse": "^1.0.7", - "glob": "^7.0.5" - } - }, "yargs": { "version": "15.3.1", "resolved": "https://registry.npmjs.org/yargs/-/yargs-15.3.1.tgz", @@ -29640,4 +29658,4 @@ } } } -} +} \ No newline at end of file diff --git a/package.json b/package.json index 297636ad2f4..d0563a1d9a7 100644 --- a/package.json +++ b/package.json @@ -5,22 +5,22 @@ "license": "CC0-1.0", "repository": "https://github.com/ustaxcourt/ef-cms", "devDependencies": { - "@babel/cli": "^7.8.4", + "@babel/cli": "^7.10.1", "@babel/core": "^7.10.2", "@babel/preset-env": "^7.10.2", "@babel/preset-react": "^7.10.0", - "@babel/register": "^7.9.0", + "@babel/register": "^7.10.1", "@cerebral/react": "4.2.1-1584683380023", "@fortawesome/fontawesome-svg-core": "^1.2.28", "@fortawesome/free-regular-svg-icons": "^5.13.0", "@fortawesome/free-solid-svg-icons": "^5.13.0", - "@fortawesome/react-fontawesome": "^0.1.9", - "@hapi/joi-date": "^2.0.1", + "@fortawesome/react-fontawesome": "^0.1.10", "@hapi/joi": "^17.1.0", + "@hapi/joi-date": "^2.0.1", "archiver": "3.1.1", "autoprefixer": "^9.8.0", + "aws-sdk": "^2.693.0", "aws-sdk-mock": "^5.0.0", - "aws-sdk": "^2.686.0", "aws-xray-sdk": "^2.5.0", "axios": "^0.19.2", "babel-eslint": "^10.0.3", @@ -32,18 +32,19 @@ "classnames": "^2.2.6", "core-js": "^3.6.5", "csv-parse": "^4.10.1", - "cypress": "^4.6.0", + "cypress": "^4.8.0", "deep-freeze": "0.0.1", "diff-arrays-of-objects": "^1.1.5", "dynamodb-admin": "^4.0.0", "elasticsearch": "^16.6.0", - "enzyme-adapter-react-16": "^1.15.2", "enzyme": "^3.11.0", + "enzyme-adapter-react-16": "^1.15.2", + "eslint": "^7.1.0", "eslint-config-prettier": "^6.11.0", - "eslint-plugin-cypress": "^2.10.3", + "eslint-plugin-cypress": "^2.11.1", "eslint-plugin-import": "^2.20.2", - "eslint-plugin-jest": "^23.13.1", - "eslint-plugin-jsdoc": "^25.4.2", + "eslint-plugin-jest": "^23.13.2", + "eslint-plugin-jsdoc": "^25.4.3", "eslint-plugin-jsx-a11y": "^6.2.3", "eslint-plugin-prettier": "^3.1.3", "eslint-plugin-promise": "^4.2.1", @@ -54,19 +55,18 @@ "eslint-plugin-sort-keys-fix": "^1.1.0", "eslint-plugin-sort-requires": "^2.1.0", "eslint-plugin-spellcheck": "0.0.16", - "eslint": "^7.1.0", "express": "^4.17.1", "faker": "^4.1.0", "form-data": "^3.0.0", - "honeybadger-js": "^2.2.2", "honeybadger": "^1.4.0", + "honeybadger-js": "^2.2.2", "http-aws-es": "^6.0.0", - "http-proxy-middleware": "^1.0.4", "http-proxy": "^1.18.1", + "http-proxy-middleware": "^1.0.4", "husky": "^4.2.5", "i": "^0.3.6", - "imagemin-pngquant": "^8.0.0", "imagemin": "^7.0.1", + "imagemin-pngquant": "^8.0.0", "is-reachable": "^4.0.0", "isomorphic-fetch": "^2.2.1", "jest": "^26.0.1", @@ -77,11 +77,11 @@ "json2yaml": "^1.1.0", "jsonwebtoken": "^8.5.1", "jwk-to-pem": "^2.0.3", - "lint-staged": "^10.2.7", + "lint-staged": "^10.2.9", "lodash": "^4.17.15", "madge": "^3.9.0", - "moment-timezone": "^0.5.31", "moment": "^2.25.3", + "moment-timezone": "^0.5.31", "node-sass": "^4.14.0", "npm-force-resolutions": "0.0.3", "npm-run-all": "^4.1.5", @@ -90,49 +90,49 @@ "parcel-plugin-bundle-visualiser": "^1.2.0", "parcel-plugin-static-files-copy": "^2.4.1", "pdf-lib": "^1.7.0", - "pdfjs-dist": "^2.3.200", + "pdfjs-dist": "2.3.200", "pixelmatch": "^5.2.0", "pngjs": "^5.0.0", "prettier": "^2.0.4", "prop-types": "^15.7.2", "pug": "^2.0.3", - "puppeteer-core": "1.20.0", "puppeteer": "1.20.0", + "puppeteer-core": "1.20.0", "qs": "^6.9.2", "query-string": "^6.12.1", "quill-delta-to-html": "^0.11.0", + "react": "^16.13.1", "react-calendar": "^3.1.0", "react-dom": "^16.13.1", "react-idle-timer": "^4.2.12", "react-number-format": "^4.4.1", "react-quill": "^2.0.0-beta.2", - "react-responsive": "^8.0.2", + "react-responsive": "^8.1.0", "react-select": "^3.1.0", "react-test-renderer": "^16.13.1", - "react": "^16.13.1", "readline": "^1.3.0", "riot-route": "^3.1.4", "s3-files": "^2.0.1", "s3-zip": "^3.1.3", "s3rver": "^3.5.0", "sanitize-filename": "^1.6.3", - "sass": "^1.26.7", - "serverless-domain-manager": "^4.1.0", + "sass": "^1.26.8", + "serverless": "1.70.1", + "serverless-domain-manager": "^4.1.1", "serverless-jetpack": "^0.10.4", "serverless-latest-layer-version": "^2.1.0", "serverless-log-forwarding": "^1.4.0", - "serverless-offline-dynamodb-streams": "^3.0.2", "serverless-offline": "^5.12.1", - "serverless-plugin-aws-alerts": "^1.5.0", + "serverless-offline-dynamodb-streams": "^3.0.2", + "serverless-plugin-aws-alerts": "^1.5.1", "serverless-plugin-git-variables": "^4.0.0", "serverless-plugin-split-stacks": "^1.9.3", "serverless-plugin-tracing": "^2.0.0", "serverless-plugin-warmup": "^4.9.0", "serverless-prune-plugin": "^1.4.3", - "serverless": "1.70.1", + "stylelint": "^13.6.0", "stylelint-config-idiomatic-order": "^8.1.0", "stylelint-config-standard": "^20.0.0", - "stylelint": "^13.4.1", "swagger-cli": "^4.0.3", "tmp": "^0.2.1", "umzug": "^2.3.0", @@ -168,6 +168,7 @@ "build:api:case:parties": "npm run build:_api -- web-api/src/casePartiesHandlers.js", "build:api:cases": "npm run build:_api -- web-api/src/casesHandlers.js", "build:api:documents": "npm run build:_api -- web-api/src/documentsHandlers.js", + "build:api:messages": "npm run build:_api -- web-api/src/messagesHandlers.js", "build:api:migrate": "npm run build:_api -- web-api/src/migrateHandlers.js", "build:api:notifications": "npm run build:_api -- web-api/src/notificationHandlers.js", "build:api:practitioners": "npm run build:_api -- web-api/src/practitionersHandlers.js", @@ -205,7 +206,7 @@ "lint:fix": "run-p lint:css:fix lint:js:fix", "lint:js:fix:plain": "npm run lint:js:fix -- --rule 'prettier/prettier: 0'", "lint:js:fix": "npm run lint:js -- --fix", - "lint:js": "TIMING=1 eslint --ext .js,.jsx shared/src/ web-api/src/ web-client/src/ web-client/integration-tests/", + "lint:js": "TIMING=1 eslint --ext .js,.jsx shared/src/ web-api/storage/ web-api/src/ web-client/src/ web-client/integration-tests/", "lint:serverless": "node ./validateServerless.js", "lint:swagger": "swagger-cli validate web-api/swagger.json", "lint": "npx run-p lint:swagger lint:css lint:js lint:serverless", @@ -265,4 +266,4 @@ "resolutions": { "minimist": "^1.2.5" } -} +} \ No newline at end of file diff --git a/run-local.sh b/run-local.sh index dc3335d4bf0..d185f9b11ac 100755 --- a/run-local.sh +++ b/run-local.sh @@ -107,6 +107,8 @@ echo "starting reports service" npx sls offline start "$@" --config web-api/serverless-reports.yml & echo "starting practitioners service" npx sls offline start "$@" --config web-api/serverless-practitioners.yml & +echo "starting messages service" +npx sls offline start "$@" --config web-api/serverless-messages.yml & echo "starting proxy" node ./web-api/proxy.js diff --git a/shared/createModule.js b/shared/createModule.js index 032f32e4154..8920058465c 100644 --- a/shared/createModule.js +++ b/shared/createModule.js @@ -4,7 +4,6 @@ const fs = require('fs'); // USAGE EXAMPLE: node createModule.js path1/file1 path2/file2 const targets = [ 'shared/src/business/assets/ustcPdf.scss', - 'shared/src/business/useCaseHelper/caseConfirmation/caseConfirmation.pug', 'shared/src/business/utilities/htmlGenerator/index.pug', 'shared/src/business/utilities/htmlGenerator/index.scss', 'shared/src/business/utilities/generateHTMLTemplateForPDF/noticeOfTrialIssued.pug', diff --git a/shared/src/authorization/authorizationClientService.js b/shared/src/authorization/authorizationClientService.js index 895de7ef55e..24594086035 100644 --- a/shared/src/authorization/authorizationClientService.js +++ b/shared/src/authorization/authorizationClientService.js @@ -28,6 +28,7 @@ const ROLE_PERMISSIONS = { GET_USERS_IN_SECTION: 'GET_USERS_IN_SECTION', JUDGES_NOTES: 'JUDGES_NOTES', MANAGE_PRACTITIONER_USERS: 'MANAGE_PRACTITIONER_USERS', + MESSAGES: 'MESSAGES', MIGRATE_CASE: 'MIGRATE_CASE', PENDING_ITEMS: 'PENDING_ITEMS', PETITION: 'PETITION', @@ -64,6 +65,7 @@ const allInternalUserPermissions = [ ROLE_PERMISSIONS.GET_CASE, ROLE_PERMISSIONS.GET_READ_MESSAGES, ROLE_PERMISSIONS.GET_USERS_IN_SECTION, + ROLE_PERMISSIONS.MESSAGES, ROLE_PERMISSIONS.PENDING_ITEMS, ROLE_PERMISSIONS.CASE_NOTES, ROLE_PERMISSIONS.PRIORITIZE_CASE, diff --git a/shared/src/authorization/authorizationClientService.test.js b/shared/src/authorization/authorizationClientService.test.js index b0221197b3c..3daafdb15fb 100644 --- a/shared/src/authorization/authorizationClientService.test.js +++ b/shared/src/authorization/authorizationClientService.test.js @@ -3,13 +3,13 @@ const { isAuthorized, ROLE_PERMISSIONS, } = require('./authorizationClientService'); -const { User } = require('../business/entities/User'); +const { ROLES } = require('../business/entities/EntityConstants'); describe('Authorization client service', () => { it('returns true for any user whose userId matches the 3rd owner argument, in this case "someUser" === "someUser"', () => { expect( isAuthorized( - { role: User.ROLES.petitioner, userId: 'someUser' }, + { role: ROLES.petitioner, userId: 'someUser' }, 'unknown action', 'someUser', ), @@ -19,7 +19,7 @@ describe('Authorization client service', () => { it('should authorize a petitionsclerk for getCase', () => { expect( isAuthorized( - { role: User.ROLES.petitionsClerk, userId: 'petitionsclerk' }, + { role: ROLES.petitionsClerk, userId: 'petitionsclerk' }, ROLE_PERMISSIONS.GET_CASE, ), ).toBeTruthy(); @@ -28,7 +28,7 @@ describe('Authorization client service', () => { it("should return false when a user doesn't have a petitionsclerk role", () => { expect( isAuthorized( - { role: User.ROLES.petitioner, userId: 'someUser' }, + { role: ROLES.petitioner, userId: 'someUser' }, ROLE_PERMISSIONS.GET_CASES_BY_STATUS, ), ).toBeFalsy(); @@ -37,7 +37,7 @@ describe('Authorization client service', () => { it('should authorize a petitions clerk for work items', () => { expect( isAuthorized( - { role: User.ROLES.petitionsClerk, userId: 'petitionsclerk' }, + { role: ROLES.petitionsClerk, userId: 'petitionsclerk' }, ROLE_PERMISSIONS.WORKITEM, ), ).toBeTruthy(); @@ -46,7 +46,7 @@ describe('Authorization client service', () => { it('should authorize a petitions clerk for start a case from paper', () => { expect( isAuthorized( - { role: User.ROLES.petitionsClerk, userId: 'petitionsclerk' }, + { role: ROLES.petitionsClerk, userId: 'petitionsclerk' }, ROLE_PERMISSIONS.START_PAPER_CASE, ), ).toBeTruthy(); @@ -55,7 +55,7 @@ describe('Authorization client service', () => { it('should authorize a docket clerk for work items', () => { expect( isAuthorized( - { role: User.ROLES.docketClerk, userId: 'docketclerk' }, + { role: ROLES.docketClerk, userId: 'docketclerk' }, ROLE_PERMISSIONS.WORKITEM, ), ).toBeTruthy(); @@ -64,7 +64,7 @@ describe('Authorization client service', () => { it('should authorize an adc user for work items', () => { expect( isAuthorized( - { role: User.ROLES.adc, userId: 'adc' }, + { role: ROLES.adc, userId: 'adc' }, ROLE_PERMISSIONS.WORKITEM, ), ).toBeTruthy(); @@ -73,7 +73,7 @@ describe('Authorization client service', () => { it('should authorize an irsPractitioner for getCase', () => { expect( isAuthorized( - { role: User.ROLES.irsPractitioner, userId: 'irsPractitioner' }, + { role: ROLES.irsPractitioner, userId: 'irsPractitioner' }, ROLE_PERMISSIONS.GET_CASE, ), ).toBeTruthy(); @@ -82,7 +82,7 @@ describe('Authorization client service', () => { it('should authorize a docketclerk for update case', () => { expect( isAuthorized( - { role: User.ROLES.docketClerk, userId: 'docketclerk' }, + { role: ROLES.docketClerk, userId: 'docketclerk' }, ROLE_PERMISSIONS.UPDATE_CASE, ), ).toBeTruthy(); @@ -91,7 +91,7 @@ describe('Authorization client service', () => { it('should evaluate owner when the owner param is provided', () => { expect( isAuthorized( - { role: User.ROLES.docketClerk, userId: '123456' }, + { role: ROLES.docketClerk, userId: '123456' }, ROLE_PERMISSIONS.UPDATE_CASE, 123456, ), diff --git a/shared/src/authorization/getUserPermissions.test.js b/shared/src/authorization/getUserPermissions.test.js index d222c5b26d5..bfb32cc5862 100644 --- a/shared/src/authorization/getUserPermissions.test.js +++ b/shared/src/authorization/getUserPermissions.test.js @@ -1,11 +1,11 @@ +import { ROLES } from '../business/entities/EntityConstants'; import { ROLE_PERMISSIONS } from './authorizationClientService'; -import { User } from '../business/entities/User'; import { getUserPermissions } from './getUserPermissions'; describe('getUserPermissions', () => { it('returns an object containing ROLE_PERMISSIONS and a boolean value based on the given user role', () => { const user = { - role: User.ROLES.docketClerk, + role: ROLES.docketClerk, }; const permissions = getUserPermissions(user); diff --git a/shared/src/business/entities/CaseMessage.js b/shared/src/business/entities/CaseMessage.js index 7d566294c5d..1d5434e9c46 100644 --- a/shared/src/business/entities/CaseMessage.js +++ b/shared/src/business/entities/CaseMessage.js @@ -5,6 +5,11 @@ const { const { createISODateString } = require('../utilities/DateHandler'); const { getTimestampSchema } = require('../../utilities/dateSchema'); const joiStrictTimestamp = getTimestampSchema(); +const { + CHAMBERS_SECTIONS, + DOCKET_NUMBER_MATCHER, + SECTIONS, +} = require('./EntityConstants'); /** * constructor @@ -16,10 +21,14 @@ function CaseMessage(rawMessage, { applicationContext }) { if (!applicationContext) { throw new TypeError('applicationContext must be defined'); } - this.entityName = 'CaseMessage'; + this.attachments = rawMessage.attachments; this.caseId = rawMessage.caseId; + this.caseStatus = rawMessage.caseStatus; this.createdAt = rawMessage.createdAt || createISODateString(); + this.docketNumber = rawMessage.docketNumber; + this.docketNumberWithSuffix = rawMessage.docketNumberWithSuffix; + this.entityName = 'CaseMessage'; this.from = rawMessage.from; this.fromSection = rawMessage.fromSection; this.fromUserId = rawMessage.fromUserId; @@ -33,43 +42,98 @@ function CaseMessage(rawMessage, { applicationContext }) { CaseMessage.validationName = 'CaseMessage'; +CaseMessage.VALIDATION_ERROR_MESSAGES = { + message: 'Enter a message', + subject: 'Enter a subject line', + toSection: 'Select a section', + toUserId: 'Select a recipient', +}; + +CaseMessage.VALIDATION_RULES = { + attachments: joi + .array() + .optional() + .description('Array of document metadata objects attached to the message.'), + caseId: joi + .string() + .uuid({ + version: ['uuidv4'], + }) + .required() + .description('ID of the case the message is attached to.'), + caseStatus: joi + .string() + .optional() + .description('The status of the associated case.'), + createdAt: joiStrictTimestamp + .required() + .description('When the message was created.'), + docketNumber: joi.string().regex(DOCKET_NUMBER_MATCHER).required(), + docketNumberWithSuffix: joi + .string() + .allow(null) + .optional() + .description('The docket number and suffix for the associated case.'), + entityName: joi.string().valid('CaseMessage').required(), + from: joi + .string() + .max(100) + .required() + .description('The name of the user who sent the message.'), + fromSection: joi + .string() + .valid(...SECTIONS, ...CHAMBERS_SECTIONS) + .required() + .description('The section of the user who sent the message.'), + fromUserId: joi + .string() + .uuid({ + version: ['uuidv4'], + }) + .required() + .description('The ID of the user who sent the message.'), + message: joi.string().max(500).required().description('The message text.'), + messageId: joi + .string() + .uuid({ + version: ['uuidv4'], + }) + .required() + .description( + 'A unique ID generated by the system to represent the message.', + ), + subject: joi + .string() + .max(250) + .required() + .description('The subject line of the message.'), + to: joi + .string() + .max(100) + .required() + .allow(null) + .description('The name of the user who is the recipient of the message.'), + toSection: joi + .string() + .valid(...SECTIONS, ...CHAMBERS_SECTIONS) + .required() + .description( + 'The section of the user who is the recipient of the message.', + ), + toUserId: joi + .string() + .uuid({ + version: ['uuidv4'], + }) + .required() + .allow(null) + .description('The ID of the user who is the recipient of the message.'), +}; + joiValidationDecorator( CaseMessage, - joi.object().keys({ - caseId: joi - .string() - .uuid({ - version: ['uuidv4'], - }) - .required(), - createdAt: joiStrictTimestamp.required(), - entityName: joi.string().valid('CaseMessage').required(), - from: joi.string().max(100).required(), - fromSection: joi.string().max(100).required(), //todo valid sections - fromUserId: joi - .string() - .uuid({ - version: ['uuidv4'], - }) - .required(), - message: joi.string().max(500).required(), - messageId: joi - .string() - .uuid({ - version: ['uuidv4'], - }) - .required(), - subject: joi.string().max(100).required(), - to: joi.string().max(100).optional().allow(null), - toSection: joi.string().max(100).optional(), //todo valid sections - toUserId: joi - .string() - .uuid({ - version: ['uuidv4'], - }) - .optional() - .allow(null), - }), + joi.object().keys(CaseMessage.VALIDATION_RULES), + CaseMessage.VALIDATION_ERROR_MESSAGES, ); module.exports = { CaseMessage }; diff --git a/shared/src/business/entities/CaseMessage.test.js b/shared/src/business/entities/CaseMessage.test.js index b29e8c4d62e..954fde1c921 100644 --- a/shared/src/business/entities/CaseMessage.test.js +++ b/shared/src/business/entities/CaseMessage.test.js @@ -11,11 +11,18 @@ describe('CaseMessage', () => { const message = new CaseMessage( { caseId: '3079c990-cc6c-4b99-8fca-8e31f2d9e7a8', + caseStatus: 'General Docket - Not at Issue', + createdAt: '2019-01-01T17:29:13.122Z', + docketNumber: '123-45', + docketNumberWithSuffix: '123-45S', from: 'gg', fromSection: 'petitions', fromUserId: '6805d1ab-18d0-43ec-bafb-654e83405416', message: 'hello world', subject: 'hey!', + to: 'bob', + toSection: 'petitions', + toUserId: '6805d1ab-18d0-43ec-bafb-654e83405416', }, { applicationContext }, ); diff --git a/shared/src/business/entities/DocketRecord.js b/shared/src/business/entities/DocketRecord.js index 18f80a410db..90a3ae77d15 100644 --- a/shared/src/business/entities/DocketRecord.js +++ b/shared/src/business/entities/DocketRecord.js @@ -67,7 +67,7 @@ joiValidationDecorator( .description('ID of the associated PDF document in the S3 bucket.'), editState: joi .string() - .max(1000) + .max(3000) .allow(null) .optional() .meta({ tags: ['Restricted'] }) diff --git a/shared/src/business/entities/Document.js b/shared/src/business/entities/Document.js index 6817942c5ca..20ddc1d4466 100644 --- a/shared/src/business/entities/Document.js +++ b/shared/src/business/entities/Document.js @@ -1,97 +1,31 @@ -const courtIssuedEventCodes = require('../../tools/courtIssuedEventCodes.json'); -const documentMapExternal = require('../../tools/externalFilingEvents.json'); -const documentMapInternal = require('../../tools/internalFilingEvents.json'); const joi = require('@hapi/joi'); +const { + COURT_ISSUED_EVENT_CODES, + DOCKET_NUMBER_MATCHER, + DOCUMENT_CATEGORY_MAP, + DOCUMENT_INTERNAL_CATEGORY_MAP, + DOCUMENT_RELATIONSHIPS, + INITIAL_DOCUMENT_TYPES, + OBJECTIONS_OPTIONS, + ORDER_TYPES, + PRACTITIONER_ASSOCIATION_DOCUMENT_TYPES, + SCENARIOS, + SIGNED_DOCUMENT_TYPES, + SYSTEM_GENERATED_DOCUMENT_TYPES, + TRACKED_DOCUMENT_TYPES, +} = require('./EntityConstants'); const { joiValidationDecorator, } = require('../../utilities/JoiValidationDecorator'); const { createISODateString } = require('../utilities/DateHandler'); -const { DOCKET_NUMBER_MATCHER } = require('./cases/CaseConstants'); const { flatten } = require('lodash'); const { getTimestampSchema } = require('../../utilities/dateSchema'); -const { Order } = require('./orders/Order'); const { User } = require('./User'); const { WorkItem } = require('./WorkItem'); const joiStrictTimestamp = getTimestampSchema(); -Document.CATEGORIES = Object.keys(documentMapExternal); -Document.CATEGORY_MAP = documentMapExternal; -Document.NOTICE_EVENT_CODES = ['NOT']; -Document.COURT_ISSUED_EVENT_CODES = courtIssuedEventCodes; -Document.INTERNAL_CATEGORIES = Object.keys(documentMapInternal); -Document.INTERNAL_CATEGORY_MAP = documentMapInternal; -Document.PETITION_DOCUMENT_TYPES = ['Petition']; -Document.OPINION_DOCUMENT_TYPES = ['MOP', 'SOP', 'TCOP']; -Document.ORDER_DOCUMENT_TYPES = [ - 'O', - 'OAJ', - 'OAL', - 'OAP', - 'OAPF', - 'OAR', - 'OAS', - 'OASL', - 'OAW', - 'OAX', - 'OCA', - 'OD', - 'ODD', - 'ODL', - 'ODP', - 'ODR', - 'ODS', - 'ODSL', - 'ODW', - 'ODX', - 'OF', - 'OFAB', - 'OFFX', - 'OFWD', - 'OFX', - 'OIP', - 'OJR', - 'OODS', - 'OPFX', - 'OPX', - 'ORAP', - 'OROP', - 'OSC', - 'OSCP', - 'OST', - 'OSUB', - 'OAD', - 'ODJ', -]; Document.validationName = 'Document'; -Document.SCENARIOS = [ - 'Standard', - 'Nonstandard A', - 'Nonstandard B', - 'Nonstandard C', - 'Nonstandard D', - 'Nonstandard E', - 'Nonstandard F', - 'Nonstandard G', - 'Nonstandard H', - 'Type A', - 'Type B', - 'Type C', - 'Type D', - 'Type E', - 'Type F', - 'Type G', - 'Type H', -]; - -Document.RELATIONSHIPS = [ - 'primaryDocument', - 'primarySupportingDocument', - 'secondaryDocument', - 'secondarySupportingDocument', - 'supportingDocument', -]; - /** * constructor * @@ -188,142 +122,37 @@ function Document(rawDocument, { applicationContext, filtered = false }) { this.generateFiledBy(rawDocument); } -const practitionerAssociationDocumentTypes = [ - 'Entry of Appearance', - 'Substitution of Counsel', -]; - -/** - * documentTypes - * - * @type {{petitionFile: string, requestForPlaceOfTrial: string, stin: string}} - */ -Document.INITIAL_DOCUMENT_TYPES = { - applicationForWaiverOfFilingFee: { - documentType: 'Application for Waiver of Filing Fee', - eventCode: 'APW', - }, - ownershipDisclosure: { - documentType: 'Ownership Disclosure Statement', - eventCode: 'DISC', - }, - petition: { - documentType: 'Petition', - eventCode: 'P', - }, - requestForPlaceOfTrial: { - documentTitle: 'Request for Place of Trial at [Place]', - documentType: 'Request for Place of Trial', - eventCode: 'RQT', - }, - stin: { - documentType: 'Statement of Taxpayer Identification', - eventCode: 'STIN', - }, -}; - -Document.NOTICE_OF_DOCKET_CHANGE = { - documentTitle: 'Notice of Docket Change for Docket Entry No. [Index]', - documentType: 'Notice of Docket Change', - eventCode: 'NODC', -}; - -Document.NOTICE_OF_TRIAL = { - documentTitle: 'Notice of Trial on [Date] at [Time]', - documentType: 'Notice of Trial', - eventCode: 'NDT', -}; - -Document.STANDING_PRETRIAL_NOTICE = { - documentTitle: 'Standing Pretrial Notice', - documentType: 'Standing Pretrial Notice', - eventCode: 'SPTN', -}; - -Document.STANDING_PRETRIAL_ORDER = { - documentTitle: 'Standing Pretrial Order', - documentType: 'Standing Pretrial Order', - eventCode: 'SPTO', -}; - -Document.SYSTEM_GENERATED_DOCUMENT_TYPES = { - noticeOfDocketChange: Document.NOTICE_OF_DOCKET_CHANGE, - noticeOfTrial: Document.NOTICE_OF_TRIAL, - standingPretrialNotice: Document.STANDING_PRETRIAL_NOTICE, - standingPretrialOrder: Document.STANDING_PRETRIAL_ORDER, -}; - -Document.SIGNED_DOCUMENT_TYPES = { - signedStipulatedDecision: { - documentType: 'Stipulated Decision', - eventCode: 'SDEC', - }, -}; - -Document.TRACKED_DOCUMENT_TYPES = { - application: { - category: 'Application', - }, - motion: { - category: 'Motion', - }, - orderToShowCause: { - documentType: 'Order to Show Cause', - eventCode: 'OSC', - }, - proposedStipulatedDecision: { - documentType: 'Proposed Stipulated Decision', - eventCode: 'PSDE', - }, -}; - -Document.CONTACT_CHANGE_DOCUMENT_TYPES = [ - 'Notice of Change of Address', - 'Notice of Change of Telephone Number', - 'Notice of Change of Address and Telephone Number', -]; - -Document.TRANSCRIPT_EVENT_CODE = 'TRAN'; - -Document.OBJECTIONS_OPTIONS = ['No', 'Yes', 'Unknown']; - Document.isPendingOnCreation = rawDocument => { - const isPending = Object.values(Document.TRACKED_DOCUMENT_TYPES).some( - trackedType => { - return ( - (rawDocument.category && - trackedType.category === rawDocument.category) || - (rawDocument.eventCode && - trackedType.eventCode === rawDocument.eventCode) - ); - }, - ); + const isPending = Object.values(TRACKED_DOCUMENT_TYPES).some(trackedType => { + return ( + (rawDocument.category && trackedType.category === rawDocument.category) || + (rawDocument.eventCode && trackedType.eventCode === rawDocument.eventCode) + ); + }); return isPending; }; Document.getDocumentTypes = () => { const allFilingEvents = flatten([ - ...Object.values(documentMapExternal), - ...Object.values(documentMapInternal), + ...Object.values(DOCUMENT_CATEGORY_MAP), + ...Object.values(DOCUMENT_INTERNAL_CATEGORY_MAP), ]); const filingEventTypes = allFilingEvents.map(t => t.documentType); - const orderDocTypes = Order.ORDER_TYPES.map(t => t.documentType); - const courtIssuedDocTypes = Document.COURT_ISSUED_EVENT_CODES.map( - t => t.documentType, + const orderDocTypes = ORDER_TYPES.map(t => t.documentType); + const courtIssuedDocTypes = COURT_ISSUED_EVENT_CODES.map(t => t.documentType); + const initialTypes = Object.keys(INITIAL_DOCUMENT_TYPES).map( + t => INITIAL_DOCUMENT_TYPES[t].documentType, ); - const initialTypes = Object.keys(Document.INITIAL_DOCUMENT_TYPES).map( - t => Document.INITIAL_DOCUMENT_TYPES[t].documentType, + const signedTypes = Object.keys(SIGNED_DOCUMENT_TYPES).map( + t => SIGNED_DOCUMENT_TYPES[t].documentType, ); - const signedTypes = Object.keys(Document.SIGNED_DOCUMENT_TYPES).map( - t => Document.SIGNED_DOCUMENT_TYPES[t].documentType, + const systemGeneratedTypes = Object.keys(SYSTEM_GENERATED_DOCUMENT_TYPES).map( + t => SYSTEM_GENERATED_DOCUMENT_TYPES[t].documentType, ); - const systemGeneratedTypes = Object.keys( - Document.SYSTEM_GENERATED_DOCUMENT_TYPES, - ).map(t => Document.SYSTEM_GENERATED_DOCUMENT_TYPES[t].documentType); const documentTypes = [ ...initialTypes, - ...practitionerAssociationDocumentTypes, + ...PRACTITIONER_ASSOCIATION_DOCUMENT_TYPES, ...filingEventTypes, ...orderDocTypes, ...courtIssuedDocTypes, @@ -334,37 +163,6 @@ Document.getDocumentTypes = () => { return documentTypes; }; -/** - * - * @returns {Array} event codes defined in the Document entity - */ -Document.eventCodes = [ - Document.INITIAL_DOCUMENT_TYPES.applicationForWaiverOfFilingFee.eventCode, - Document.INITIAL_DOCUMENT_TYPES.ownershipDisclosure.eventCode, - Document.INITIAL_DOCUMENT_TYPES.petition.eventCode, - Document.INITIAL_DOCUMENT_TYPES.requestForPlaceOfTrial.eventCode, - Document.INITIAL_DOCUMENT_TYPES.stin.eventCode, - Document.NOTICE_OF_DOCKET_CHANGE.eventCode, - Document.NOTICE_OF_TRIAL.eventCode, - Document.STANDING_PRETRIAL_NOTICE.eventCode, - Document.STANDING_PRETRIAL_ORDER.eventCode, - // TODO: Move these constants - 'MISL', - 'FEE', - 'FEEW', - 'MGRTED', - 'MIND', - 'MINC', -]; - -/** - * - * @returns {boolean} true if the document is a petition document type, false otherwise - */ -Document.prototype.isPetitionDocument = function () { - return Document.PETITION_DOCUMENT_TYPES.includes(this.documentType); -}; - joiValidationDecorator( Document, joi.object().keys({ @@ -457,7 +255,7 @@ joiValidationDecorator( numberOfPages: joi.number().optional().allow(null), objections: joi .string() - .valid(...Document.OBJECTIONS_OPTIONS) + .valid(...OBJECTIONS_OPTIONS) .optional(), ordinalValue: joi.string().optional(), partyIrsPractitioner: joi.boolean().optional(), @@ -490,11 +288,11 @@ joiValidationDecorator( receivedAt: joiStrictTimestamp.optional(), relationship: joi .string() - .valid(...Document.RELATIONSHIPS) + .valid(...DOCUMENT_RELATIONSHIPS) .optional(), scenario: joi .string() - .valid(...Document.SCENARIOS) + .valid(...SCENARIOS) .optional(), secondaryDate: joiStrictTimestamp .optional() @@ -650,14 +448,14 @@ Document.prototype.getQCWorkItem = function () { }; Document.prototype.isAutoServed = function () { - const externalDocumentTypes = flatten(Object.values(documentMapExternal)).map( - t => t.documentType, - ); + const externalDocumentTypes = flatten( + Object.values(DOCUMENT_CATEGORY_MAP), + ).map(t => t.documentType); const isExternalDocumentType = externalDocumentTypes.includes( this.documentType, ); - const isPractitionerAssociationDocumentType = practitionerAssociationDocumentTypes.includes( + const isPractitionerAssociationDocumentType = PRACTITIONER_ASSOCIATION_DOCUMENT_TYPES.includes( this.documentType, ); //if fully concatenated document title includes the word Simultaneous, do not auto-serve diff --git a/shared/src/business/entities/Document.test.js b/shared/src/business/entities/Document.test.js index d92ca08cb59..46f30175e51 100644 --- a/shared/src/business/entities/Document.test.js +++ b/shared/src/business/entities/Document.test.js @@ -1,12 +1,12 @@ const { applicationContext } = require('../test/createTestApplicationContext'); const { Document } = require('./Document'); const { Message } = require('./Message'); -const { User } = require('./User'); +const { ROLES } = require('./EntityConstants'); const { WorkItem } = require('./WorkItem'); const A_VALID_DOCUMENT = { documentType: 'Petition', - role: User.ROLES.petitioner, + role: ROLES.petitioner, userId: '02323349-87fe-4d29-91fe-8dd6916d2fda', }; const caseDetail = { diff --git a/shared/src/business/entities/EntityConstants.js b/shared/src/business/entities/EntityConstants.js new file mode 100644 index 00000000000..1aff4289117 --- /dev/null +++ b/shared/src/business/entities/EntityConstants.js @@ -0,0 +1,781 @@ +const courtIssuedEventCodes = require('../../tools/courtIssuedEventCodes.json'); +const documentMapExternal = require('../../tools/externalFilingEvents.json'); +const documentMapInternal = require('../../tools/internalFilingEvents.json'); +const { sortBy } = require('lodash'); + +const SERVICE_INDICATOR_TYPES = { + SI_ELECTRONIC: 'Electronic', + SI_NONE: 'None', + SI_PAPER: 'Paper', +}; + +const DOCKET_NUMBER_MATCHER = /^([1-9]\d{2,4}-\d{2})$/; + +const TRIAL_LOCATION_MATCHER = /^[a-zA-Z ]+, [a-zA-Z ]+, [0-9]+$/; + +const CHIEF_JUDGE = 'Chief Judge'; + +const DOCKET_NUMBER_SUFFIXES = ['W', 'P', 'X', 'R', 'SL', 'L', 'S']; + +const CASE_STATUS_TYPES = { + assignedCase: 'Assigned - Case', // Case has been assigned to a judge + assignedMotion: 'Assigned - Motion', // Someone has requested a judge for the case + calendared: 'Calendared', // Case has been scheduled for trial + cav: 'CAV', // Core alternative valuation + closed: 'Closed', // Judge has made a ruling to close the case + generalDocket: 'General Docket - Not at Issue', // Submitted to the IRS + generalDocketReadyForTrial: 'General Docket - At Issue (Ready for Trial)', // Case is ready for trial + jurisdictionRetained: 'Jurisdiction Retained', // Jurisdiction of a case is retained by a specific judge — usually after the case is on a judge’s trial calendar + new: 'New', // Case has not been QCed + onAppeal: 'On Appeal', // After the trial, the case has gone to the appeals court + rule155: 'Rule 155', // Where the Court has filed or stated its opinion or issued a dispositive order determining the issues in a case, it may withhold entry of its decision for the purpose of permitting the parties to submit computations pursuant to the Court’s determination of the issues, showing the correct amount to be included in the decision. + submitted: 'Submitted', // Submitted to the judge for decision +}; + +const DOCUMENT_RELATIONSHIPS = [ + 'primaryDocument', + 'primarySupportingDocument', + 'secondaryDocument', + 'secondarySupportingDocument', + 'supportingDocument', +]; + +const ORDER_DOCUMENT_TYPES = [ + 'O', + 'OAJ', + 'OAL', + 'OAP', + 'OAPF', + 'OAR', + 'OAS', + 'OASL', + 'OAW', + 'OAX', + 'OCA', + 'OD', + 'ODD', + 'ODL', + 'ODP', + 'ODR', + 'ODS', + 'ODSL', + 'ODW', + 'ODX', + 'OF', + 'OFAB', + 'OFFX', + 'OFWD', + 'OFX', + 'OIP', + 'OJR', + 'OODS', + 'OPFX', + 'OPX', + 'ORAP', + 'OROP', + 'OSC', + 'OSCP', + 'OST', + 'OSUB', + 'OAD', + 'ODJ', +]; + +const DOCUMENT_NOTICE_EVENT_CODES = ['NOT']; +const DOCUMENT_CATEGORIES = Object.keys(documentMapExternal); +const DOCUMENT_CATEGORY_MAP = documentMapExternal; +const DOCUMENT_INTERNAL_CATEGORIES = Object.keys(documentMapInternal); +const DOCUMENT_INTERNAL_CATEGORY_MAP = documentMapInternal; +const COURT_ISSUED_EVENT_CODES = courtIssuedEventCodes; +const OPINION_DOCUMENT_TYPES = ['MOP', 'SOP', 'TCOP']; + +const SCENARIOS = [ + 'Standard', + 'Nonstandard A', + 'Nonstandard B', + 'Nonstandard C', + 'Nonstandard D', + 'Nonstandard E', + 'Nonstandard F', + 'Nonstandard G', + 'Nonstandard H', + 'Type A', + 'Type B', + 'Type C', + 'Type D', + 'Type E', + 'Type F', + 'Type G', + 'Type H', +]; + +const TRANSCRIPT_EVENT_CODE = 'TRAN'; + +const OBJECTIONS_OPTIONS = ['No', 'Yes', 'Unknown']; + +const CONTACT_CHANGE_DOCUMENT_TYPES = [ + 'Notice of Change of Address', + 'Notice of Change of Telephone Number', + 'Notice of Change of Address and Telephone Number', +]; + +const TRACKED_DOCUMENT_TYPES = { + application: { + category: 'Application', + }, + motion: { + category: 'Motion', + }, + orderToShowCause: { + documentType: 'Order to Show Cause', + eventCode: 'OSC', + }, + proposedStipulatedDecision: { + documentType: 'Proposed Stipulated Decision', + eventCode: 'PSDE', + }, +}; + +const INITIAL_DOCUMENT_TYPES = { + applicationForWaiverOfFilingFee: { + documentType: 'Application for Waiver of Filing Fee', + eventCode: 'APW', + }, + ownershipDisclosure: { + documentType: 'Ownership Disclosure Statement', + eventCode: 'DISC', + }, + petition: { + documentType: 'Petition', + eventCode: 'P', + }, + requestForPlaceOfTrial: { + documentTitle: 'Request for Place of Trial at [Place]', + documentType: 'Request for Place of Trial', + eventCode: 'RQT', + }, + stin: { + documentType: 'Statement of Taxpayer Identification', + eventCode: 'STIN', + }, +}; + +const NOTICE_OF_DOCKET_CHANGE = { + documentTitle: 'Notice of Docket Change for Docket Entry No. [Index]', + documentType: 'Notice of Docket Change', + eventCode: 'NODC', +}; + +const NOTICE_OF_TRIAL = { + documentTitle: 'Notice of Trial on [Date] at [Time]', + documentType: 'Notice of Trial', + eventCode: 'NDT', +}; + +const STANDING_PRETRIAL_NOTICE = { + documentTitle: 'Standing Pretrial Notice', + documentType: 'Standing Pretrial Notice', + eventCode: 'SPTN', +}; + +const STANDING_PRETRIAL_ORDER = { + documentTitle: 'Standing Pretrial Order', + documentType: 'Standing Pretrial Order', + eventCode: 'SPTO', +}; + +const SYSTEM_GENERATED_DOCUMENT_TYPES = { + noticeOfDocketChange: NOTICE_OF_DOCKET_CHANGE, + noticeOfTrial: NOTICE_OF_TRIAL, + standingPretrialNotice: STANDING_PRETRIAL_NOTICE, + standingPretrialOrder: STANDING_PRETRIAL_ORDER, +}; + +const SIGNED_DOCUMENT_TYPES = { + signedStipulatedDecision: { + documentType: 'Stipulated Decision', + eventCode: 'SDEC', + }, +}; + +const PRACTITIONER_ASSOCIATION_DOCUMENT_TYPES = [ + 'Entry of Appearance', + 'Substitution of Counsel', +]; + +const EVENT_CODES = [ + INITIAL_DOCUMENT_TYPES.applicationForWaiverOfFilingFee.eventCode, + INITIAL_DOCUMENT_TYPES.ownershipDisclosure.eventCode, + INITIAL_DOCUMENT_TYPES.petition.eventCode, + INITIAL_DOCUMENT_TYPES.requestForPlaceOfTrial.eventCode, + INITIAL_DOCUMENT_TYPES.stin.eventCode, + NOTICE_OF_DOCKET_CHANGE.eventCode, + NOTICE_OF_TRIAL.eventCode, + STANDING_PRETRIAL_NOTICE.eventCode, + STANDING_PRETRIAL_ORDER.eventCode, + 'MISL', + 'FEE', + 'FEEW', + 'MGRTED', + 'MIND', + 'MINC', +]; + +const PAYMENT_STATUS = { + PAID: 'Paid', + UNPAID: 'Not Paid', + WAIVED: 'Waived', +}; + +const PROCEDURE_TYPES = ['Regular', 'Small']; // This is the order that they appear in the UI + +const STATUS_TYPES_WITH_ASSOCIATED_JUDGE = [ + CASE_STATUS_TYPES.assignedCase, + CASE_STATUS_TYPES.assignedMotion, + CASE_STATUS_TYPES.cav, + CASE_STATUS_TYPES.jurisdictionRetained, + CASE_STATUS_TYPES.rule155, + CASE_STATUS_TYPES.submitted, +]; + +const STATUS_TYPES_MANUAL_UPDATE = [ + CASE_STATUS_TYPES.assignedCase, + CASE_STATUS_TYPES.assignedMotion, + CASE_STATUS_TYPES.cav, + CASE_STATUS_TYPES.closed, + CASE_STATUS_TYPES.generalDocket, + CASE_STATUS_TYPES.generalDocketReadyForTrial, + CASE_STATUS_TYPES.jurisdictionRetained, + CASE_STATUS_TYPES.onAppeal, + CASE_STATUS_TYPES.rule155, + CASE_STATUS_TYPES.submitted, +]; + +const ANSWER_DOCUMENT_CODES = [ + 'A', + 'AAAP', + 'AAPN', + 'AATP', + 'AATS', + 'AATT', + 'APA', + 'ASAP', + 'ASUP', + 'ATAP', + 'ATSP', +]; + +const CASE_CAPTION_POSTFIX = 'v. Commissioner of Internal Revenue, Respondent'; + +const AUTOMATIC_BLOCKED_REASONS = { + dueDate: 'Due Date', + pending: 'Pending Item', + pendingAndDueDate: 'Pending Item and Due Date', +}; + +const CASE_TYPES_MAP = { + cdp: 'CDP (Lien/Levy)', + deficiency: 'Deficiency', + djExemptOrg: 'Declaratory Judgment (Exempt Organization)', + djRetirementPlan: 'Declaratory Judgment (Retirement Plan)', + innocentSpouse: 'Innocent Spouse', + interestAbatement: 'Interest Abatement', + other: 'Other', + partnershipSection1101: 'Partnership (BBA Section 1101)', + partnershipSection6226: 'Partnership (Section 6226)', + partnershipSection6228: 'Partnership (Section 6228)', + passport: 'Passport', + whistleblower: 'Whistleblower', + workerClassification: 'Worker Classification', +}; + +const CASE_TYPES = Object.values(CASE_TYPES_MAP); + +const ROLES = { + adc: 'adc', + admin: 'admin', + admissionsClerk: 'admissionsclerk', + chambers: 'chambers', + clerkOfCourt: 'clerkofcourt', + docketClerk: 'docketclerk', + floater: 'floater', + inactivePractitioner: 'inactivePractitioner', + irsPractitioner: 'irsPractitioner', + irsSuperuser: 'irsSuperuser', + judge: 'judge', + petitioner: 'petitioner', + petitionsClerk: 'petitionsclerk', + privatePractitioner: 'privatePractitioner', + trialClerk: 'trialclerk', +}; + +const FILING_TYPES = { + [ROLES.petitioner]: ['Myself', 'Myself and my spouse', 'A business', 'Other'], + [ROLES.privatePractitioner]: [ + 'Individual petitioner', + 'Petitioner and spouse', + 'A business', + 'Other', + ], +}; + +const ANSWER_CUTOFF_AMOUNT_IN_DAYS = 45; + +const ANSWER_CUTOFF_UNIT = 'day'; + +const COUNTRY_TYPES = { + DOMESTIC: 'domestic', + INTERNATIONAL: 'international', +}; + +const US_STATES = { + AK: 'Alaska', + AL: 'Alabama', + AR: 'Arkansas', + AZ: 'Arizona', + CA: 'California', + CO: 'Colorado', + CT: 'Connecticut', + DC: 'District of Columbia', + DE: 'Delaware', + FL: 'Florida', + GA: 'Georgia', + HI: 'Hawaii', + IA: 'Iowa', + ID: 'Idaho', + IL: 'Illinois', + IN: 'Indiana', + KS: 'Kansas', + KY: 'Kentucky', + LA: 'Louisiana', + MA: 'Massachusetts', + MD: 'Maryland', + ME: 'Maine', + MI: 'Michigan', + MN: 'Minnesota', + MO: 'Missouri', + MS: 'Mississippi', + MT: 'Montana', + NC: 'North Carolina', + ND: 'North Dakota', + NE: 'Nebraska', + NH: 'New Hampshire', + NJ: 'New Jersey', + NM: 'New Mexico', + NV: 'Nevada', + NY: 'New York', + OH: 'Ohio', + OK: 'Oklahoma', + OR: 'Oregon', + PA: 'Pennsylvania', + RI: 'Rhode Island', + SC: 'South Carolina', + SD: 'South Dakota', + TN: 'Tennessee', + TX: 'Texas', + UT: 'Utah', + VA: 'Virginia', + VT: 'Vermont', + WA: 'Washington', + WI: 'Wisconsin', + WV: 'West Virginia', + WY: 'Wyoming', +}; + +const PARTY_TYPES = { + conservator: 'Conservator', + corporation: 'Corporation', + custodian: 'Custodian', + donor: 'Donor', + estate: 'Estate with an executor/personal representative/fiduciary/etc.', + estateWithoutExecutor: + 'Estate without an executor/personal representative/fiduciary/etc.', + guardian: 'Guardian', + nextFriendForIncompetentPerson: + 'Next friend for a legally incompetent person (without a guardian, conservator, or other like fiduciary)', + nextFriendForMinor: + 'Next friend for a minor (without a guardian, conservator, or other like fiduciary)', + partnershipAsTaxMattersPartner: 'Partnership (as the Tax Matters Partner)', + partnershipBBA: + 'Partnership (as a partnership representative under the BBA regime)', + partnershipOtherThanTaxMatters: + 'Partnership (as a partner other than Tax Matters Partner)', + petitioner: 'Petitioner', + petitionerDeceasedSpouse: 'Petitioner & deceased spouse', + petitionerSpouse: 'Petitioner & spouse', + survivingSpouse: 'Surviving spouse', + transferee: 'Transferee', + trust: 'Trust', +}; + +const BUSINESS_TYPES = { + corporation: PARTY_TYPES.corporation, + partnershipAsTaxMattersPartner: PARTY_TYPES.partnershipAsTaxMattersPartner, + partnershipBBA: PARTY_TYPES.partnershipBBA, + partnershipOtherThanTaxMatters: PARTY_TYPES.partnershipOtherThanTaxMatters, +}; + +const ESTATE_TYPES = { + estate: PARTY_TYPES.estate, + estateWithoutExecutor: PARTY_TYPES.estateWithoutExecutor, + trust: PARTY_TYPES.trust, +}; + +const OTHER_TYPES = { + conservator: PARTY_TYPES.conservator, + custodian: PARTY_TYPES.custodian, + guardian: PARTY_TYPES.guardian, + nextFriendForIncompetentPerson: PARTY_TYPES.nextFriendForIncompetentPerson, + nextFriendForMinor: PARTY_TYPES.nextFriendForMinor, +}; + +const ORDER_TYPES = [ + { + documentType: 'Order', + eventCode: 'O', + }, + { + documentTitle: 'Order of Dismissal for Lack of Jurisdiction', + documentType: 'Order of Dismissal for Lack of Jurisdiction', + eventCode: 'ODJ', + }, + { + documentTitle: 'Order of Dismissal', + documentType: 'Order of Dismissal', + eventCode: 'OD', + }, + { + documentTitle: 'Order of Dismissal and Decision', + documentType: 'Order of Dismissal and Decision', + eventCode: 'ODD', + }, + { + documentTitle: 'Order to Show Cause', + documentType: 'Order to Show Cause', + eventCode: 'OSC', + }, + { + documentTitle: 'Order and Decision', + documentType: 'Order and Decision', + eventCode: 'OAD', + }, + { + documentTitle: 'Decision', + documentType: 'Decision', + eventCode: 'DEC', + }, + { + documentType: 'Notice', + eventCode: 'NOT', + }, +]; + +const COMMON_CITIES = [ + { city: 'Birmingham', state: 'Alabama' }, + { city: 'Mobile', state: 'Alabama' }, + { city: 'Anchorage', state: 'Alaska' }, + { city: 'Phoenix', state: 'Arizona' }, + { city: 'Little Rock', state: 'Arkansas' }, + { city: 'Los Angeles', state: 'California' }, + { city: 'San Diego', state: 'California' }, + { city: 'San Francisco', state: 'California' }, + { city: 'Denver', state: 'Colorado' }, + { city: 'Hartford', state: 'Connecticut' }, + { city: 'Washington', state: 'District of Columbia' }, + { city: 'Jacksonville', state: 'Florida' }, + { city: 'Miami', state: 'Florida' }, + { city: 'Tampa', state: 'Florida' }, + { city: 'Atlanta', state: 'Georgia' }, + { city: 'Honolulu', state: 'Hawaii' }, + { city: 'Boise', state: 'Idaho' }, + { city: 'Chicago', state: 'Illinois' }, + { city: 'Indianapolis', state: 'Indiana' }, + { city: 'Des Moines', state: 'Iowa' }, + { city: 'Louisville', state: 'Kentucky' }, + { city: 'New Orleans', state: 'Louisiana' }, + { city: 'Baltimore', state: 'Maryland' }, + { city: 'Boston', state: 'Massachusetts' }, + { city: 'Detroit', state: 'Michigan' }, + { city: 'St. Paul', state: 'Minnesota' }, + { city: 'Jackson', state: 'Mississippi' }, + { city: 'Kansas City', state: 'Missouri' }, + { city: 'St. Louis', state: 'Missouri' }, + { city: 'Helena', state: 'Montana' }, + { city: 'Omaha', state: 'Nebraska' }, + { city: 'Las Vegas', state: 'Nevada' }, + { city: 'Reno', state: 'Nevada' }, + { city: 'Albuquerque', state: 'New Mexico' }, + { city: 'Buffalo', state: 'New York' }, + { city: 'New York City', state: 'New York' }, + { city: 'Winston-Salem', state: 'North Carolina' }, + { city: 'Cincinnati', state: 'Ohio' }, + { city: 'Cleveland', state: 'Ohio' }, + { city: 'Columbus', state: 'Ohio' }, + { city: 'Oklahoma City', state: 'Oklahoma' }, + { city: 'Portland', state: 'Oregon' }, + { city: 'Philadelphia', state: 'Pennsylvania' }, + { city: 'Pittsburgh', state: 'Pennsylvania' }, + { city: 'Columbia', state: 'South Carolina' }, + { city: 'Knoxville', state: 'Tennessee' }, + { city: 'Memphis', state: 'Tennessee' }, + { city: 'Nashville', state: 'Tennessee' }, + { city: 'Dallas', state: 'Texas' }, + { city: 'El Paso', state: 'Texas' }, + { city: 'Houston', state: 'Texas' }, + { city: 'Lubbock', state: 'Texas' }, + { city: 'San Antonio', state: 'Texas' }, + { city: 'Salt Lake City', state: 'Utah' }, + { city: 'Richmond', state: 'Virginia' }, + { city: 'Seattle', state: 'Washington' }, + { city: 'Spokane', state: 'Washington' }, + { city: 'Charleston', state: 'West Virginia' }, + { city: 'Milwaukee', state: 'Wisconsin' }, +]; + +const SMALL_CITIES = [ + { city: 'Fresno', state: 'California' }, + { city: 'Tallahassee', state: 'Florida' }, + { city: 'Pocatello', state: 'Idaho' }, + { city: 'Peoria', state: 'Illinois' }, + { city: 'Wichita', state: 'Kansas' }, + { city: 'Shreveport', state: 'Louisiana' }, + { city: 'Portland', state: 'Maine' }, + { city: 'Billings', state: 'Montana' }, + { city: 'Albany', state: 'New York' }, + { city: 'Syracuse', state: 'New York' }, + { city: 'Bismarck', state: 'North Dakota' }, + { city: 'Aberdeen', state: 'South Dakota' }, + { city: 'Burlington', state: 'Vermont' }, + { city: 'Roanoke', state: 'Virginia' }, + { city: 'Cheyenne', state: 'Wyoming' }, + ...COMMON_CITIES, +]; + +const TRIAL_CITIES = { + ALL: SMALL_CITIES, + REGULAR: COMMON_CITIES, + SMALL: SMALL_CITIES, +}; + +const TRIAL_CITY_STRINGS = SMALL_CITIES.map( + location => `${location.city}, ${location.state}`, +); + +const SESSION_TERMS = ['Winter', 'Fall', 'Spring', 'Summer']; + +const SESSION_TYPES = [ + 'Regular', + 'Small', + 'Hybrid', + 'Special', + 'Motion/Hearing', +]; + +const SESSION_STATUS_GROUPS = { + all: 'All', + closed: 'Closed', + new: 'New', + open: 'Open', +}; + +const MAX_FILE_SIZE_MB = 250; // megabytes +const MAX_FILE_SIZE_BYTES = MAX_FILE_SIZE_MB * 1024 * 1024; // bytes -> megabytes + +const ADC_SECTION = 'adc'; +const ADMISSIONS_SECTION = 'admissions'; +const CHAMBERS_SECTION = 'chambers'; +const CLERK_OF_COURT_SECTION = 'clerkofcourt'; +const DOCKET_SECTION = 'docket'; +const IRS_SYSTEM_SECTION = 'irsSystem'; +const PETITIONS_SECTION = 'petitions'; +const TRIAL_CLERKS_SECTION = 'trialClerks'; + +const ARMENS_CHAMBERS_SECTION = 'armensChambers'; +const ASHFORDS_CHAMBERS_SECTION = 'ashfordsChambers'; +const BUCHS_CHAMBERS_SECTION = 'buchsChambers'; +const CARLUZZOS_CHAMBERS_SECTION = 'carluzzosChambers'; +const COHENS_CHAMBERS_SECTION = 'cohensChambers'; +const COLVINS_CHAMBERS_SECTION = 'colvinsChambers'; +const COPELANDS_CHAMBERS_SECTION = 'copelandsChambers'; +const FOLEYS_CHAMBERS_SECTION = 'foleysChambers'; +const GALES_CHAMBERS_SECTION = 'galesChambers'; +const GERBERS_CHAMBERS_SECTION = 'gerbersChambers'; +const GOEKES_CHAMBERS_SECTION = 'goekesChambers'; +const GUSTAFSONS_CHAMBERS_SECTION = 'gustafsonsChambers'; +const GUYS_CHAMBERS_SECTION = 'guysChambers'; +const HALPERNS_CHAMBERS_SECTION = 'halpernsChambers'; +const HOLMES_CHAMBERS_SECTION = 'holmesChambers'; +const JACOBS_CHAMBERS_SECTION = 'jacobsChambers'; +const JONES_CHAMBERS_SECTION = 'jonesChambers'; +const KERRIGANS_CHAMBERS_SECTION = 'kerrigansChambers'; +const LAUBERS_CHAMBERS_SECTION = 'laubersChambers'; +const LEYDENS_CHAMBERS_SECTION = 'leydensChambers'; +const MARVELS_CHAMBERS_SECTION = 'marvelsChambers'; +const MORRISONS_CHAMBERS_SECTION = 'morrisonsChambers'; +const NEGAS_CHAMBERS_SECTION = 'negasChambers'; +const PANUTHOS_CHAMBERS_SECTION = 'panuthosChambers'; +const PARIS_CHAMBERS_SECTION = 'parisChambers'; +const PUGHS_CHAMBERS_SECTION = 'pughsChambers'; +const RUWES_CHAMBERS_SECTION = 'ruwesChambers'; +const THORNTONS_CHAMBERS_SECTION = 'thorntonsChambers'; +const TOROS_CHAMBERS_SECTION = 'torosChambers'; +const URDAS_CHAMBERS_SECTION = 'urdasChambers'; +const VASQUEZS_CHAMBERS_SECTION = 'vasquezsChambers'; +const WELLS_CHAMBERS_SECTION = 'wellsChambers'; + +const SECTIONS = sortBy([ + ADC_SECTION, + ADMISSIONS_SECTION, + CHAMBERS_SECTION, + CLERK_OF_COURT_SECTION, + DOCKET_SECTION, + PETITIONS_SECTION, + TRIAL_CLERKS_SECTION, +]); + +const CHAMBERS_SECTIONS = sortBy([ + ARMENS_CHAMBERS_SECTION, + ASHFORDS_CHAMBERS_SECTION, + BUCHS_CHAMBERS_SECTION, + CARLUZZOS_CHAMBERS_SECTION, + COHENS_CHAMBERS_SECTION, + COLVINS_CHAMBERS_SECTION, + COPELANDS_CHAMBERS_SECTION, + FOLEYS_CHAMBERS_SECTION, + GALES_CHAMBERS_SECTION, + GERBERS_CHAMBERS_SECTION, + GOEKES_CHAMBERS_SECTION, + GUSTAFSONS_CHAMBERS_SECTION, + GUYS_CHAMBERS_SECTION, + HALPERNS_CHAMBERS_SECTION, + HOLMES_CHAMBERS_SECTION, + JACOBS_CHAMBERS_SECTION, + JONES_CHAMBERS_SECTION, + KERRIGANS_CHAMBERS_SECTION, + LAUBERS_CHAMBERS_SECTION, + LEYDENS_CHAMBERS_SECTION, + MARVELS_CHAMBERS_SECTION, + MORRISONS_CHAMBERS_SECTION, + NEGAS_CHAMBERS_SECTION, + PANUTHOS_CHAMBERS_SECTION, + PARIS_CHAMBERS_SECTION, + PUGHS_CHAMBERS_SECTION, + RUWES_CHAMBERS_SECTION, + THORNTONS_CHAMBERS_SECTION, + URDAS_CHAMBERS_SECTION, + TOROS_CHAMBERS_SECTION, + VASQUEZS_CHAMBERS_SECTION, + WELLS_CHAMBERS_SECTION, +]); + +const TRIAL_STATUS_TYPES = [ + 'Set for Trial', + 'Dismissed', + 'Continued', + 'Rule 122', + 'A Basis Reached', + 'Settled', + 'Recall', + 'Taken Under Advisement', +]; + +const SCAN_MODES = { + DUPLEX: 'duplex', + FEEDER: 'feeder', + FLATBED: 'flatbed', +}; + +const EMPLOYER_OPTIONS = ['IRS', 'DOJ', 'Private']; + +const PRACTITIONER_TYPE_OPTIONS = ['Attorney', 'Non-Attorney']; + +const ADMISSIONS_STATUS_OPTIONS = [ + 'Active', + 'Suspended', + 'Disbarred', + 'Resigned', + 'Deceased', + 'Inactive', +]; + +const DEFAULT_PROCEDURE_TYPE = PROCEDURE_TYPES[0]; + +const CASE_SEARCH_MIN_YEAR = 1986; +const CASE_SEARCH_PAGE_SIZE = 5; + +module.exports = { + ADC_SECTION, + ADMISSIONS_SECTION, + ADMISSIONS_STATUS_OPTIONS, + ANSWER_CUTOFF_AMOUNT_IN_DAYS, + ANSWER_CUTOFF_UNIT, + ANSWER_DOCUMENT_CODES, + AUTOMATIC_BLOCKED_REASONS, + BUSINESS_TYPES, + CASE_CAPTION_POSTFIX, + CASE_SEARCH_MIN_YEAR, + CASE_SEARCH_PAGE_SIZE, + CASE_STATUS_TYPES, + CASE_TYPES, + CASE_TYPES_MAP, + CHAMBERS_SECTION, + CHAMBERS_SECTIONS, + CHIEF_JUDGE, + CLERK_OF_COURT_SECTION, + CONTACT_CHANGE_DOCUMENT_TYPES, + COUNTRY_TYPES, + COURT_ISSUED_EVENT_CODES, + DEFAULT_PROCEDURE_TYPE, + DOCKET_NUMBER_MATCHER, + DOCKET_NUMBER_SUFFIXES, + DOCKET_SECTION, + DOCUMENT_CATEGORIES, + DOCUMENT_CATEGORY_MAP, + DOCUMENT_INTERNAL_CATEGORIES, + DOCUMENT_INTERNAL_CATEGORY_MAP, + DOCUMENT_NOTICE_EVENT_CODES, + DOCUMENT_RELATIONSHIPS, + EMPLOYER_OPTIONS, + ESTATE_TYPES, + EVENT_CODES, + FILING_TYPES, + INITIAL_DOCUMENT_TYPES, + IRS_SYSTEM_SECTION, + MAX_FILE_SIZE_BYTES, + MAX_FILE_SIZE_MB, + NOTICE_OF_DOCKET_CHANGE, + NOTICE_OF_TRIAL, + OBJECTIONS_OPTIONS, + OPINION_DOCUMENT_TYPES, + ORDER_DOCUMENT_TYPES, + ORDER_TYPES, + OTHER_TYPES, + PARTY_TYPES, + PAYMENT_STATUS, + PETITIONS_SECTION, + PRACTITIONER_ASSOCIATION_DOCUMENT_TYPES, + PRACTITIONER_TYPE_OPTIONS, + PROCEDURE_TYPES, + ROLES, + SCAN_MODES, + SCENARIOS, + SECTIONS, + SERVICE_INDICATOR_TYPES, + SESSION_STATUS_GROUPS, + SESSION_TERMS, + SESSION_TYPES, + SIGNED_DOCUMENT_TYPES, + STANDING_PRETRIAL_NOTICE, + STANDING_PRETRIAL_ORDER, + STATUS_TYPES_MANUAL_UPDATE, + STATUS_TYPES_WITH_ASSOCIATED_JUDGE, + SYSTEM_GENERATED_DOCUMENT_TYPES, + TRACKED_DOCUMENT_TYPES, + TRANSCRIPT_EVENT_CODE, + TRIAL_CITIES, + TRIAL_CITY_STRINGS, + TRIAL_CLERKS_SECTION, + TRIAL_LOCATION_MATCHER, + TRIAL_STATUS_TYPES, + US_STATES, +}; diff --git a/shared/src/business/entities/ForwardMessage.js b/shared/src/business/entities/ForwardMessage.js index 3675ed27631..676da8fd3ab 100644 --- a/shared/src/business/entities/ForwardMessage.js +++ b/shared/src/business/entities/ForwardMessage.js @@ -2,7 +2,7 @@ const joi = require('@hapi/joi'); const { joiValidationDecorator, } = require('../../utilities/JoiValidationDecorator'); -const { CHAMBERS_SECTIONS, SECTIONS } = require('./WorkQueue'); +const { CHAMBERS_SECTIONS, SECTIONS } = require('./EntityConstants'); ForwardMessage.VALIDATION_ERROR_MESSAGES = { assigneeId: 'Select a recipient', diff --git a/shared/src/business/entities/InitialWorkItemMessage.js b/shared/src/business/entities/InitialWorkItemMessage.js index d566daad5cf..27395e73468 100644 --- a/shared/src/business/entities/InitialWorkItemMessage.js +++ b/shared/src/business/entities/InitialWorkItemMessage.js @@ -2,7 +2,7 @@ const joi = require('@hapi/joi'); const { joiValidationDecorator, } = require('../../utilities/JoiValidationDecorator'); -const { CHAMBERS_SECTIONS, SECTIONS } = require('./WorkQueue'); +const { CHAMBERS_SECTIONS, SECTIONS } = require('./EntityConstants'); InitialWorkItemMessage.VALIDATION_ERROR_MESSAGES = { assigneeId: 'Select a recipient', diff --git a/shared/src/business/entities/IrsPractitioner.js b/shared/src/business/entities/IrsPractitioner.js index a7a563bba83..f8e1c9c22a3 100644 --- a/shared/src/business/entities/IrsPractitioner.js +++ b/shared/src/business/entities/IrsPractitioner.js @@ -3,12 +3,11 @@ const { joiValidationDecorator, } = require('../../utilities/JoiValidationDecorator'); const { - User, userDecorator, userValidation, VALIDATION_ERROR_MESSAGES, } = require('./User'); -const { SERVICE_INDICATOR_TYPES } = require('./cases/CaseConstants'); +const { ROLES, SERVICE_INDICATOR_TYPES } = require('./EntityConstants'); /** * constructor @@ -28,7 +27,7 @@ joiValidationDecorator( joi.object().keys({ ...userValidation, entityName: joi.string().valid('IrsPractitioner').required(), - role: joi.string().valid(User.ROLES.irsPractitioner).required(), + role: joi.string().valid(ROLES.irsPractitioner).required(), serviceIndicator: joi .string() .valid(...Object.values(SERVICE_INDICATOR_TYPES)) diff --git a/shared/src/business/entities/IrsPractitioner.test.js b/shared/src/business/entities/IrsPractitioner.test.js index 8a4e5d9f3ed..1a3efe3c1ae 100644 --- a/shared/src/business/entities/IrsPractitioner.test.js +++ b/shared/src/business/entities/IrsPractitioner.test.js @@ -1,5 +1,5 @@ const { IrsPractitioner } = require('./IrsPractitioner'); -const { User } = require('./User'); +const { ROLES } = require('./EntityConstants'); describe('IrsPractitioner', () => { it('Creates a valid IrsPractitioner', () => { @@ -17,7 +17,7 @@ describe('IrsPractitioner', () => { }, firstName: 'firstName', lastName: 'lastName', - role: User.ROLES.irsPractitioner, + role: ROLES.irsPractitioner, userId: '9ea9732c-9751-4159-9619-bd27556eb9bc', }); @@ -27,7 +27,7 @@ describe('IrsPractitioner', () => { it('Creates an invalid', () => { const user = new IrsPractitioner({ - role: User.ROLES.inactivePractitioner, + role: ROLES.inactivePractitioner, }); expect(user.isValid()).toBeFalsy(); diff --git a/shared/src/business/entities/NewCaseMessage.js b/shared/src/business/entities/NewCaseMessage.js new file mode 100644 index 00000000000..4ad32fbb12f --- /dev/null +++ b/shared/src/business/entities/NewCaseMessage.js @@ -0,0 +1,47 @@ +const joi = require('@hapi/joi'); +const { + joiValidationDecorator, +} = require('../../utilities/JoiValidationDecorator'); +const { CaseMessage } = require('./CaseMessage'); + +/** + * NewCaseMessage entity - used for validating + * the Create Case Message modal form + * + * @param {object} rawMessage the raw message data + * @constructor + */ +function NewCaseMessage(rawMessage, { applicationContext }) { + if (!applicationContext) { + throw new TypeError('applicationContext must be defined'); + } + this.entityName = 'NewCaseMessage'; + + this.message = rawMessage.message; + this.subject = rawMessage.subject; + this.toSection = rawMessage.toSection; + this.toUserId = rawMessage.toUserId; +} + +NewCaseMessage.validationName = 'NewCaseMessage'; + +NewCaseMessage.VALIDATION_ERROR_MESSAGES = { + message: 'Enter a message', + subject: 'Enter a subject line', + toSection: 'Select a section', + toUserId: 'Select a recipient', +}; + +joiValidationDecorator( + NewCaseMessage, + joi.object().keys({ + entityName: joi.string().valid('NewCaseMessage').required(), + message: CaseMessage.VALIDATION_RULES.message, + subject: CaseMessage.VALIDATION_RULES.subject, + toSection: CaseMessage.VALIDATION_RULES.toSection, + toUserId: CaseMessage.VALIDATION_RULES.toUserId, + }), + NewCaseMessage.VALIDATION_ERROR_MESSAGES, +); + +module.exports = { NewCaseMessage }; diff --git a/shared/src/business/entities/NewCaseMessage.test.js b/shared/src/business/entities/NewCaseMessage.test.js new file mode 100644 index 00000000000..83eeda5f2ed --- /dev/null +++ b/shared/src/business/entities/NewCaseMessage.test.js @@ -0,0 +1,37 @@ +const { applicationContext } = require('../test/createTestApplicationContext'); +const { NewCaseMessage } = require('./NewCaseMessage'); + +describe('NewCaseMessage', () => { + describe('isValid', () => { + it('should throw an error if app context is not passed in', () => { + expect(() => new NewCaseMessage({}, {})).toThrow(); + }); + + it('creates a valid NewCaseMessage', () => { + const message = new NewCaseMessage( + { + message: 'hello world', + subject: 'hey!', + to: 'bob', + toSection: 'petitions', + toUserId: '6805d1ab-18d0-43ec-bafb-654e83405416', + }, + { applicationContext }, + ); + expect(message.isValid()).toBeTruthy(); + }); + + it('creates an invalid NewCaseMessage with no message', () => { + const message = new NewCaseMessage( + { + subject: 'hey!', + to: 'bob', + toSection: 'petitions', + toUserId: '6805d1ab-18d0-43ec-bafb-654e83405416', + }, + { applicationContext }, + ); + expect(message.isValid()).toBeFalsy(); + }); + }); +}); diff --git a/shared/src/business/entities/NewPractitioner.test.js b/shared/src/business/entities/NewPractitioner.test.js index 7d3f0e7bc09..188c6993632 100644 --- a/shared/src/business/entities/NewPractitioner.test.js +++ b/shared/src/business/entities/NewPractitioner.test.js @@ -1,5 +1,5 @@ const { NewPractitioner } = require('./NewPractitioner'); -const { User } = require('./User'); +const { ROLES } = require('./EntityConstants'); describe('NewPractitioner', () => { it('Creates a valid NewPractitioner with all required fields', () => { @@ -25,14 +25,14 @@ describe('NewPractitioner', () => { lastName: 'Practitioner', originalBarState: 'Illinois', practitionerType: 'Attorney', - role: User.ROLES.NewPractitioner, + role: ROLES.NewPractitioner, }); expect(user.isValid()).toBeTruthy(); }); it('Creates an invalid NewPractitioner with missing required fields', () => { const user = new NewPractitioner({ - role: User.ROLES.NewPractitioner, + role: ROLES.NewPractitioner, }); expect(user.isValid()).toBeFalsy(); }); @@ -58,7 +58,7 @@ describe('NewPractitioner', () => { firmName: 'GW Law Offices', originalBarState: 'Illinois', practitionerType: 'Attorney', - role: User.ROLES.NewPractitioner, + role: ROLES.NewPractitioner, }); expect(user.isValid()).toBeFalsy(); }); diff --git a/shared/src/business/entities/Practitioner.js b/shared/src/business/entities/Practitioner.js index daa2d112a96..e94989e23da 100644 --- a/shared/src/business/entities/Practitioner.js +++ b/shared/src/business/entities/Practitioner.js @@ -1,25 +1,20 @@ const joi = require('@hapi/joi'); +const { + ADMISSIONS_STATUS_OPTIONS, + EMPLOYER_OPTIONS, + PRACTITIONER_TYPE_OPTIONS, + ROLES, +} = require('./EntityConstants'); const { joiValidationDecorator, } = require('../../utilities/JoiValidationDecorator'); const { - User, userDecorator, userValidation, VALIDATION_ERROR_MESSAGES: USER_VALIDATION_ERROR_MESSAGES, } = require('./User'); const { getTimestampSchema } = require('../../utilities/dateSchema'); const joiStrictTimestamp = getTimestampSchema(); -const EMPLOYER_OPTIONS = ['IRS', 'DOJ', 'Private']; -const PRACTITIONER_TYPE_OPTIONS = ['Attorney', 'Non-Attorney']; -const ADMISSIONS_STATUS_OPTIONS = [ - 'Active', - 'Suspended', - 'Disbarred', - 'Resigned', - 'Deceased', - 'Inactive', -]; /** * constructor @@ -32,9 +27,9 @@ function Practitioner(rawUser) { } const roleMap = { - DOJ: User.ROLES.irsPractitioner, - IRS: User.ROLES.irsPractitioner, - Private: User.ROLES.privatePractitioner, + DOJ: ROLES.irsPractitioner, + IRS: ROLES.irsPractitioner, + Private: ROLES.privatePractitioner, }; Practitioner.prototype.init = function (rawUser) { @@ -56,7 +51,7 @@ Practitioner.prototype.init = function (rawUser) { if (this.admissionsStatus === 'Active') { this.role = roleMap[this.employer]; } else { - this.role = User.ROLES.inactivePractitioner; + this.role = ROLES.inactivePractitioner; } this.suffix = rawUser.suffix; this.section = this.role; @@ -166,10 +161,10 @@ const practitionerValidation = { .description('The type of practitioner - either Attorney or Non-Attorney.'), role: joi.alternatives().conditional('admissionsStatus', { is: joi.valid('Active'), - otherwise: joi.string().valid(User.ROLES.inactivePractitioner).required(), + otherwise: joi.string().valid(ROLES.inactivePractitioner).required(), then: joi .string() - .valid(...[User.ROLES.irsPractitioner, User.ROLES.privatePractitioner]) + .valid(...[ROLES.irsPractitioner, ROLES.privatePractitioner]) .required(), }), suffix: joi @@ -189,12 +184,8 @@ joiValidationDecorator( ); Practitioner.validationName = 'Practitioner'; - -Practitioner.PRACTITIONER_TYPE_OPTIONS = PRACTITIONER_TYPE_OPTIONS; -Practitioner.EMPLOYER_OPTIONS = EMPLOYER_OPTIONS; Practitioner.validationRules = practitionerValidation; Practitioner.VALIDATION_ERROR_MESSAGES = VALIDATION_ERROR_MESSAGES; -Practitioner.ADMISSIONS_STATUS_OPTIONS = ADMISSIONS_STATUS_OPTIONS; /** * returns the full concatenated name for the given practitioner data diff --git a/shared/src/business/entities/Practitioner.test.js b/shared/src/business/entities/Practitioner.test.js index 1510755416f..4bea0688b0d 100644 --- a/shared/src/business/entities/Practitioner.test.js +++ b/shared/src/business/entities/Practitioner.test.js @@ -1,5 +1,5 @@ const { Practitioner } = require('./Practitioner'); -const { User } = require('./User'); +const { ROLES } = require('./EntityConstants'); describe('Practitioner', () => { it('Creates a valid Practitioner with all required fields', () => { @@ -26,7 +26,7 @@ describe('Practitioner', () => { name: 'Test Practitioner', originalBarState: 'Illinois', practitionerType: 'Attorney', - role: User.ROLES.Practitioner, + role: ROLES.Practitioner, userId: '3ab77c88-1dd0-4adb-a03c-c466ad72d417', }); expect(user.isValid()).toBeTruthy(); @@ -34,7 +34,7 @@ describe('Practitioner', () => { it('Creates an invalid Practitioner with missing required fields', () => { const user = new Practitioner({ - role: User.ROLES.Practitioner, + role: ROLES.Practitioner, }); expect(user.isValid()).toBeFalsy(); }); @@ -61,7 +61,7 @@ describe('Practitioner', () => { lastName: 'Practitioner', name: 'Test Practitioner', practitionerType: 'Attorney', - role: User.ROLES.Practitioner, + role: ROLES.Practitioner, userId: '3ab77c88-1dd0-4adb-a03c-c466ad72d417', }); expect(user.isValid()).toBeFalsy(); @@ -90,7 +90,7 @@ describe('Practitioner', () => { lastName: 'Practitioner', name: 'Test Practitioner', practitionerType: 'Purple', - role: User.ROLES.Practitioner, + role: ROLES.Practitioner, userId: 'ec4fe2e7-52cf-4084-84de-d8e8d151e927', }); expect(user.isValid()).toBeFalsy(); @@ -119,7 +119,7 @@ describe('Practitioner', () => { lastName: 'Practitioner', name: 'Test Practitioner', practitionerType: 'Purple', - role: User.ROLES.Practitioner, + role: ROLES.Practitioner, userId: 'ec4fe2e7-52cf-4084-84de-d8e8d151e927', }); expect(user.isValid()).toBeFalsy(); @@ -129,7 +129,7 @@ describe('Practitioner', () => { const user = new Practitioner({ admissionsStatus: 'Active', employer: 'IRS', - role: User.ROLES.inactivePractitioner, + role: ROLES.inactivePractitioner, }); expect(user.isValid()).toBeFalsy(); @@ -159,7 +159,7 @@ describe('Practitioner', () => { name: 'Test Practitioner', originalBarState: 'Illinois', practitionerType: 'Attorney', - role: User.ROLES.inactivePractitioner, + role: ROLES.inactivePractitioner, userId: 'ec4fe2e7-52cf-4084-84de-d8e8d151e927', }); @@ -190,7 +190,7 @@ describe('Practitioner', () => { name: 'Test Practitioner', originalBarState: 'Illinois', practitionerType: 'Attorney', - role: User.ROLES.privatePractitioner, + role: ROLES.privatePractitioner, userId: 'ec4fe2e7-52cf-4084-84de-d8e8d151e927', }); @@ -202,7 +202,7 @@ describe('Practitioner', () => { admissionsStatus: 'Active', employer: 'IRS', }); - expect(user.role).toEqual(User.ROLES.irsPractitioner); + expect(user.role).toEqual(ROLES.irsPractitioner); }); it('should set the role to "irsPractitioner" when employer is "DOJ" and admissionsStatus is Active', () => { @@ -210,7 +210,7 @@ describe('Practitioner', () => { admissionsStatus: 'Active', employer: 'DOJ', }); - expect(user.role).toEqual(User.ROLES.irsPractitioner); + expect(user.role).toEqual(ROLES.irsPractitioner); }); it('should set the role to "privatePractitioner" when employer is "Private" and admissionsStatus is Active', () => { @@ -218,7 +218,7 @@ describe('Practitioner', () => { admissionsStatus: 'Active', employer: 'Private', }); - expect(user.role).toEqual(User.ROLES.privatePractitioner); + expect(user.role).toEqual(ROLES.privatePractitioner); }); it('should set the role to "inactivePractitioner" when employer is "Private" and admissionsStatus is Inactive', () => { @@ -226,7 +226,7 @@ describe('Practitioner', () => { admissionsStatus: 'Inactive', employer: 'Private', }); - expect(user.role).toEqual(User.ROLES.inactivePractitioner); + expect(user.role).toEqual(ROLES.inactivePractitioner); }); it('Combines firstName, middleName, lastName, and suffix properties to set the name property', () => { @@ -253,7 +253,7 @@ describe('Practitioner', () => { middleName: 'Middle', originalBarState: 'Illinois', practitionerType: 'Attorney', - role: User.ROLES.Practitioner, + role: ROLES.Practitioner, suffix: 'Sfx', userId: 'ec4fe2e7-52cf-4084-84de-d8e8d151e927', }); @@ -286,7 +286,7 @@ describe('Practitioner', () => { lastName: 'Practitioner', originalBarState: 'Illinois', practitionerType: 'Attorney', - role: User.ROLES.Practitioner, + role: ROLES.Practitioner, userId: 'ec4fe2e7-52cf-4084-84de-d8e8d151e927', }; }); diff --git a/shared/src/business/entities/PrivatePractitioner.js b/shared/src/business/entities/PrivatePractitioner.js index 7b40736f8b3..280c6b04ace 100644 --- a/shared/src/business/entities/PrivatePractitioner.js +++ b/shared/src/business/entities/PrivatePractitioner.js @@ -2,8 +2,9 @@ const joi = require('@hapi/joi'); const { joiValidationDecorator, } = require('../../utilities/JoiValidationDecorator'); -const { SERVICE_INDICATOR_TYPES } = require('./cases/CaseConstants'); -const { User, userDecorator, userValidation } = require('./User'); +const { ROLES } = require('./EntityConstants'); +const { SERVICE_INDICATOR_TYPES } = require('./EntityConstants'); +const { userDecorator, userValidation } = require('./User'); /** * constructor @@ -27,7 +28,7 @@ joiValidationDecorator( entityName: joi.string().valid('PrivatePractitioner').required(), representingPrimary: joi.boolean().optional(), representingSecondary: joi.boolean().optional(), - role: joi.string().required().valid(User.ROLES.privatePractitioner), + role: joi.string().required().valid(ROLES.privatePractitioner), serviceIndicator: joi .string() .valid(...Object.values(SERVICE_INDICATOR_TYPES)) diff --git a/shared/src/business/entities/PrivatePractitioner.test.js b/shared/src/business/entities/PrivatePractitioner.test.js index 33e85d48b5c..a1760e0021c 100644 --- a/shared/src/business/entities/PrivatePractitioner.test.js +++ b/shared/src/business/entities/PrivatePractitioner.test.js @@ -1,5 +1,5 @@ const { PrivatePractitioner } = require('./PrivatePractitioner'); -const { User } = require('./User'); +const { ROLES } = require('./EntityConstants'); describe('PrivatePractitioner', () => { it('Creates a valid PrivatePractitioner', () => { @@ -17,7 +17,7 @@ describe('PrivatePractitioner', () => { }, firstName: 'firstName', lastName: 'lastName', - role: User.ROLES.privatePractitioner, + role: ROLES.privatePractitioner, userId: '3ab77c88-1dd0-4adb-a03c-c466ad72d417', }); @@ -27,7 +27,7 @@ describe('PrivatePractitioner', () => { it('Creates an invalid', () => { const user = new PrivatePractitioner({ - role: User.ROLES.irsPractitioner, + role: ROLES.irsPractitioner, }); expect(user.isValid()).toBeFalsy(); }); diff --git a/shared/src/business/entities/PublicUser.js b/shared/src/business/entities/PublicUser.js index b6796dfd8d1..1ff9a4d99f3 100644 --- a/shared/src/business/entities/PublicUser.js +++ b/shared/src/business/entities/PublicUser.js @@ -2,37 +2,20 @@ const joi = require('@hapi/joi'); const { joiValidationDecorator, } = require('../../utilities/JoiValidationDecorator'); -const { User } = require('./User'); +const { baseUserValidation: userValidation } = require('./User'); +const { ROLES } = require('./EntityConstants'); PublicUser.validationName = 'PublicUser'; const userDecorator = (obj, rawObj) => { obj.name = rawObj.name; obj.role = rawObj.role; - if (obj.role === User.ROLES.judge) { + if (obj.role === ROLES.judge) { obj.judgeFullName = rawObj.judgeFullName; obj.judgeTitle = rawObj.judgeTitle; } }; -const userValidation = { - judgeFullName: joi.when('role', { - is: User.ROLES.judge, - otherwise: joi.optional().allow(null), - then: joi.string().max(100).optional(), - }), - judgeTitle: joi.when('role', { - is: User.ROLES.judge, - otherwise: joi.optional().allow(null), - then: joi.string().max(100).optional(), - }), - name: joi.string().max(100).optional(), - role: joi - .string() - .valid(...Object.values(User.ROLES)) - .required(), -}; - const VALIDATION_ERROR_MESSAGES = { role: 'Role is required', }; diff --git a/shared/src/business/entities/Scan.js b/shared/src/business/entities/Scan.js index dc9a2b25edb..bc5a842f6b8 100644 --- a/shared/src/business/entities/Scan.js +++ b/shared/src/business/entities/Scan.js @@ -5,6 +5,7 @@ const { const { createISODateString } = require('../utilities/DateHandler'); const { getTimestampSchema } = require('../../utilities/dateSchema'); const { remove } = require('lodash'); + const joiStrictTimestamp = getTimestampSchema(); /** * constructor @@ -21,11 +22,6 @@ function Scan({ applicationContext, rawScan }) { } Scan.validationName = 'Scan'; -Scan.SCAN_MODES = { - DUPLEX: 'duplex', - FEEDER: 'feeder', - FLATBED: 'flatbed', -}; /** * adds a batch to the current scan diff --git a/shared/src/business/entities/User.js b/shared/src/business/entities/User.js index 18fb39d73b4..f1cfd75eb9b 100644 --- a/shared/src/business/entities/User.js +++ b/shared/src/business/entities/User.js @@ -5,33 +5,14 @@ const { const { joiValidationDecorator, } = require('../../utilities/JoiValidationDecorator'); -const { CHAMBERS_SECTIONS, SECTIONS } = require('./WorkQueue'); -const { ContactFactory } = require('../entities/contacts/ContactFactory'); - -User.ROLES = { - adc: 'adc', - admin: 'admin', - admissionsClerk: 'admissionsclerk', - chambers: 'chambers', - clerkOfCourt: 'clerkofcourt', - docketClerk: 'docketclerk', - floater: 'floater', - inactivePractitioner: 'inactivePractitioner', - irsPractitioner: 'irsPractitioner', - irsSuperuser: 'irsSuperuser', - judge: 'judge', - petitioner: 'petitioner', - petitionsClerk: 'petitionsclerk', - privatePractitioner: 'privatePractitioner', - trialClerk: 'trialclerk', -}; +const { COUNTRY_TYPES, ROLES } = require('./EntityConstants'); const userDecorator = (obj, rawObj) => { obj.entityName = 'User'; obj.barNumber = rawObj.barNumber; obj.email = rawObj.email; obj.name = rawObj.name; - obj.role = rawObj.role || User.ROLES.petitioner; + obj.role = rawObj.role || ROLES.petitioner; obj.section = rawObj.section; obj.token = rawObj.token; obj.userId = rawObj.userId; @@ -48,12 +29,30 @@ const userDecorator = (obj, rawObj) => { state: rawObj.contact.state, }; } - if (obj.role === User.ROLES.judge) { + if (obj.role === ROLES.judge) { obj.judgeFullName = rawObj.judgeFullName; obj.judgeTitle = rawObj.judgeTitle; } }; +const baseUserValidation = { + judgeFullName: joi.when('role', { + is: ROLES.judge, + otherwise: joi.optional().allow(null), + then: joi.string().max(100).optional(), + }), + judgeTitle: joi.when('role', { + is: ROLES.judge, + otherwise: joi.optional().allow(null), + then: joi.string().max(100).optional(), + }), + name: joi.string().max(100).optional(), + role: joi + .string() + .valid(...Object.values(ROLES)) + .required(), +}; + const userValidation = { barNumber: joi.string().optional().allow(null), contact: joi @@ -64,28 +63,25 @@ const userValidation = { address3: joi.string().max(100).optional().allow(null), city: joi.string().max(100).required(), country: joi.when('countryType', { - is: ContactFactory.COUNTRY_TYPES.INTERNATIONAL, + is: COUNTRY_TYPES.INTERNATIONAL, otherwise: joi.string().optional().allow(null), then: joi.string().required(), }), countryType: joi .string() - .valid( - ContactFactory.COUNTRY_TYPES.DOMESTIC, - ContactFactory.COUNTRY_TYPES.INTERNATIONAL, - ) + .valid(COUNTRY_TYPES.DOMESTIC, COUNTRY_TYPES.INTERNATIONAL) .required(), phone: joi.string().max(100).required(), postalCode: joi.when('countryType', { - is: ContactFactory.COUNTRY_TYPES.INTERNATIONAL, + is: COUNTRY_TYPES.INTERNATIONAL, otherwise: JoiValidationConstants.US_POSTAL_CODE.required(), then: joi.string().max(100).required(), }), state: joi.when('countryType', { - is: ContactFactory.COUNTRY_TYPES.INTERNATIONAL, + is: COUNTRY_TYPES.INTERNATIONAL, otherwise: joi.string().max(100).required(), then: joi.string().optional().allow(null), }), @@ -93,24 +89,10 @@ const userValidation = { .optional(), email: joi.string().max(100).optional(), entityName: joi.string().valid('User').required(), - judgeFullName: joi.when('role', { - is: User.ROLES.judge, - otherwise: joi.optional().allow(null), - then: joi.string().max(100).optional(), - }), - judgeTitle: joi.when('role', { - is: User.ROLES.judge, - otherwise: joi.optional().allow(null), - then: joi.string().max(100).optional(), - }), - name: joi.string().max(100).optional(), - role: joi - .string() - .valid(...Object.values(User.ROLES)) - .required(), section: joi .string() - .valid(...SECTIONS, ...CHAMBERS_SECTIONS, ...Object.values(User.ROLES)) + // Removed temporarily: Eric will re-add + // .valid(...SECTIONS, ...CHAMBERS_SECTIONS, ...Object.values(ROLES)) .optional(), token: joi.string().optional(), userId: joi @@ -119,6 +101,7 @@ const userValidation = { version: ['uuidv4'], }) .required(), + ...baseUserValidation, }; const VALIDATION_ERROR_MESSAGES = { @@ -158,25 +141,25 @@ joiValidationDecorator( User.isExternalUser = function (role) { const externalRoles = [ - User.ROLES.petitioner, - User.ROLES.privatePractitioner, - User.ROLES.irsPractitioner, - User.ROLES.irsSuperuser, + ROLES.petitioner, + ROLES.privatePractitioner, + ROLES.irsPractitioner, + ROLES.irsSuperuser, ]; return externalRoles.includes(role); }; User.isInternalUser = function (role) { const internalRoles = [ - User.ROLES.adc, - User.ROLES.admissionsClerk, - User.ROLES.chambers, - User.ROLES.clerkOfCourt, - User.ROLES.docketClerk, - User.ROLES.floater, - User.ROLES.judge, - User.ROLES.petitionsClerk, - User.ROLES.trialClerk, + ROLES.adc, + ROLES.admissionsClerk, + ROLES.chambers, + ROLES.clerkOfCourt, + ROLES.docketClerk, + ROLES.floater, + ROLES.judge, + ROLES.petitionsClerk, + ROLES.trialClerk, ]; return internalRoles.includes(role); }; @@ -184,6 +167,7 @@ User.isInternalUser = function (role) { module.exports = { User, VALIDATION_ERROR_MESSAGES, + baseUserValidation, userDecorator, userValidation, }; diff --git a/shared/src/business/entities/User.test.js b/shared/src/business/entities/User.test.js index 15f72d0cf4c..bae8537aaae 100644 --- a/shared/src/business/entities/User.test.js +++ b/shared/src/business/entities/User.test.js @@ -1,3 +1,4 @@ +const { ROLES } = require('./EntityConstants'); const { User } = require('./User'); describe('User entity', () => { @@ -16,7 +17,7 @@ describe('User entity', () => { }, firstName: 'firstName', lastName: 'lastName', - role: User.ROLES.petitioner, + role: ROLES.petitioner, userId: '3ab77c88-1dd0-4adb-a03c-c466ad72d417', }); expect(user.isValid()).toBeTruthy(); @@ -36,7 +37,7 @@ describe('User entity', () => { }, firstName: 'firstName', lastName: 'lastName', - role: User.ROLES.petitioner, + role: ROLES.petitioner, userId: '3ab77c88-1dd0-4adb-a03c-c466ad72d417', }); expect(user.isValid()).toBeTruthy(); @@ -54,7 +55,7 @@ describe('User entity', () => { }, firstName: 'firstName', lastName: 'lastName', - role: User.ROLES.petitioner, + role: ROLES.petitioner, userId: '3ab77c88-1dd0-4adb-a03c-c466ad72d417', }); expect(user.isValid()).toBeTruthy(); @@ -64,7 +65,7 @@ describe('User entity', () => { const user = new User({ firstName: 'firstName', lastName: 'lastName', - role: User.ROLES.petitioner, + role: ROLES.petitioner, userId: '3ab77c88-1dd0-4adb-a03c-c466ad72d417', }); expect(user.isValid()).toBeTruthy(); @@ -76,7 +77,7 @@ describe('User entity', () => { barNumber: 'gg', firstName: 'firstName', lastName: 'bob', - role: User.ROLES.privatePractitioner, + role: ROLES.privatePractitioner, token: 'abc', userId: '3ab77c88-1dd0-4adb-a03c-c466ad72d417', }); @@ -85,7 +86,7 @@ describe('User entity', () => { it('Creates a valid irsPractitioner user', () => { const user = new User({ - role: User.ROLES.irsPractitioner, + role: ROLES.irsPractitioner, userId: '3ab77c88-1dd0-4adb-a03c-c466ad72d417', }); expect(user.isValid()).toBeTruthy(); @@ -98,45 +99,45 @@ describe('User entity', () => { role: undefined, userId: '3ab77c88-1dd0-4adb-a03c-c466ad72d417', }); - expect(user.role).toBe(User.ROLES.petitioner); + expect(user.role).toBe(ROLES.petitioner); }); describe('isExternalUser', () => { it('should return true when the user role is petitioner', () => { - expect(User.isExternalUser(User.ROLES.petitioner)).toEqual(true); + expect(User.isExternalUser(ROLES.petitioner)).toEqual(true); }); it('should return true when the user role is privatePractitioner', () => { - expect(User.isExternalUser(User.ROLES.privatePractitioner)).toEqual(true); + expect(User.isExternalUser(ROLES.privatePractitioner)).toEqual(true); }); it('should return true when the user role is irsPractitioner', () => { - expect(User.isExternalUser(User.ROLES.irsPractitioner)).toEqual(true); + expect(User.isExternalUser(ROLES.irsPractitioner)).toEqual(true); }); }); describe('isInternalUser', () => { it('should return true when the user role is docketclerk', () => { - expect(User.isInternalUser(User.ROLES.docketClerk)).toEqual(true); + expect(User.isInternalUser(ROLES.docketClerk)).toEqual(true); }); it('should return true when the user role is petitionsclerk', () => { - expect(User.isInternalUser(User.ROLES.petitionsClerk)).toEqual(true); + expect(User.isInternalUser(ROLES.petitionsClerk)).toEqual(true); }); it('should return true when the user role is judge', () => { - expect(User.isInternalUser(User.ROLES.judge)).toEqual(true); + expect(User.isInternalUser(ROLES.judge)).toEqual(true); }); it('should return true when the user role is adc', () => { - expect(User.isInternalUser(User.ROLES.adc)).toEqual(true); + expect(User.isInternalUser(ROLES.adc)).toEqual(true); }); it('should return true when the user role is admissionsclerk', () => { - expect(User.isInternalUser(User.ROLES.admissionsClerk)).toEqual(true); + expect(User.isInternalUser(ROLES.admissionsClerk)).toEqual(true); }); it('should return true when the user role is chambers', () => { - expect(User.isInternalUser(User.ROLES.chambers)).toEqual(true); + expect(User.isInternalUser(ROLES.chambers)).toEqual(true); }); it('should return true when the user role is clerkofcourt', () => { - expect(User.isInternalUser(User.ROLES.clerkOfCourt)).toEqual(true); + expect(User.isInternalUser(ROLES.clerkOfCourt)).toEqual(true); }); it('should return true when the user role is trialclerk', () => { - expect(User.isInternalUser(User.ROLES.trialClerk)).toEqual(true); + expect(User.isInternalUser(ROLES.trialClerk)).toEqual(true); }); }); }); diff --git a/shared/src/business/entities/UserCase.js b/shared/src/business/entities/UserCase.js index 6d4731d0b84..022d10430df 100644 --- a/shared/src/business/entities/UserCase.js +++ b/shared/src/business/entities/UserCase.js @@ -14,22 +14,25 @@ UserCase.validationName = 'UserCase'; * @constructor */ function UserCase(rawUserCase) { + this.entityName = 'UserCase'; this.caseId = rawUserCase.caseId; this.caseCaption = rawUserCase.caseCaption; this.createdAt = rawUserCase.createdAt; this.docketNumber = rawUserCase.docketNumber; this.docketNumberWithSuffix = rawUserCase.docketNumberWithSuffix; this.leadCaseId = rawUserCase.leadCaseId; + this.status = rawUserCase.status; } joiValidationDecorator( UserCase, joi.object().keys({ - caseCaption: Case.validationRules.caseCaption, - caseId: Case.validationRules.caseId, - docketNumber: Case.validationRules.docketNumber, - docketNumberWithSuffix: Case.validationRules.docketNumberWithSuffix, - leadCaseId: Case.validationRules.leadCaseId, + caseCaption: Case.VALIDATION_RULES.caseCaption, + caseId: Case.VALIDATION_RULES.caseId, + docketNumber: Case.VALIDATION_RULES.docketNumber, + docketNumberWithSuffix: Case.VALIDATION_RULES.docketNumberWithSuffix, + leadCaseId: Case.VALIDATION_RULES.leadCaseId, + status: Case.VALIDATION_RULES.status, }), Case.VALIDATION_ERROR_MESSAGES, ); diff --git a/shared/src/business/entities/WorkItem.js b/shared/src/business/entities/WorkItem.js index f597b79a799..779d19307b0 100644 --- a/shared/src/business/entities/WorkItem.js +++ b/shared/src/business/entities/WorkItem.js @@ -2,12 +2,23 @@ const joi = require('@hapi/joi'); const { joiValidationDecorator, } = require('../../utilities/JoiValidationDecorator'); -const { CHIEF_JUDGE } = require('./cases/CaseConstants'); +const { CHIEF_JUDGE, ROLES } = require('./EntityConstants'); const { createISODateString } = require('../utilities/DateHandler'); const { getTimestampSchema } = require('../../utilities/dateSchema'); const { Message } = require('./Message'); const { omit, orderBy } = require('lodash'); const joiStrictTimestamp = getTimestampSchema(); +const { + CASE_STATUS_TYPES, + DOCKET_NUMBER_MATCHER, + DOCKET_NUMBER_SUFFIXES, +} = require('./EntityConstants'); +const { + CHAMBERS_SECTIONS, + IRS_SYSTEM_SECTION, + SECTIONS, +} = require('./EntityConstants'); + /** * constructor * @@ -18,11 +29,9 @@ function WorkItem(rawWorkItem, { applicationContext }) { if (!applicationContext) { throw new TypeError('applicationContext must be defined'); } - this.entityName = 'WorkItem'; - - this.associatedJudge = rawWorkItem.associatedJudge || CHIEF_JUDGE; this.assigneeId = rawWorkItem.assigneeId; this.assigneeName = rawWorkItem.assigneeName; + this.associatedJudge = rawWorkItem.associatedJudge || CHIEF_JUDGE; this.caseId = rawWorkItem.caseId; this.caseIsInProgress = rawWorkItem.caseIsInProgress; this.caseStatus = rawWorkItem.caseStatus; @@ -35,6 +44,7 @@ function WorkItem(rawWorkItem, { applicationContext }) { this.docketNumber = rawWorkItem.docketNumber; this.docketNumberWithSuffix = rawWorkItem.docketNumberWithSuffix; this.document = omit(rawWorkItem.document, 'workItems'); + this.entityName = 'WorkItem'; this.hideFromPendingMessages = rawWorkItem.hideFromPendingMessages; this.highPriority = rawWorkItem.highPriority; this.inProgress = rawWorkItem.inProgress; @@ -48,6 +58,7 @@ function WorkItem(rawWorkItem, { applicationContext }) { this.trialDate = rawWorkItem.trialDate; this.updatedAt = rawWorkItem.updatedAt || createISODateString(); this.workItemId = rawWorkItem.workItemId || applicationContext.getUniqueId(); + this.messages = (rawWorkItem.messages || []).map( message => new Message(message, { applicationContext }), ); @@ -65,8 +76,8 @@ joiValidationDecorator( }) .allow(null) .optional(), - assigneeName: joi.string().allow(null).optional(), // should be a Message entity at some point - associatedJudge: joi.string().required(), + assigneeName: joi.string().max(100).allow(null).optional(), // should be a Message entity at some point + associatedJudge: joi.string().max(100).required(), caseId: joi .string() .uuid({ @@ -74,10 +85,13 @@ joiValidationDecorator( }) .required(), caseIsInProgress: joi.boolean().optional(), - caseStatus: joi.string().optional(), - caseTitle: joi.string().optional(), + caseStatus: joi + .string() + .valid(...Object.values(CASE_STATUS_TYPES)) + .optional(), + caseTitle: joi.string().max(500).optional(), completedAt: joiStrictTimestamp.optional(), - completedBy: joi.string().optional().allow(null), + completedBy: joi.string().max(100).optional().allow(null), completedByUserId: joi .string() .uuid({ @@ -85,10 +99,14 @@ joiValidationDecorator( }) .optional() .allow(null), - completedMessage: joi.string().optional().allow(null), + completedMessage: joi.string().max(100).optional().allow(null), createdAt: joiStrictTimestamp.optional(), - docketNumber: joi.string().required(), - docketNumberSuffix: joi.string().allow(null).optional(), + docketNumber: joi.string().regex(DOCKET_NUMBER_MATCHER).required(), + docketNumberSuffix: joi + .string() + .valid(...Object.values(DOCKET_NUMBER_SUFFIXES)) + .allow(null) + .optional(), document: joi.object().required(), entityName: joi.string().valid('WorkItem').required(), hideFromPendingMessages: joi.boolean().optional(), @@ -98,9 +116,20 @@ joiValidationDecorator( isQC: joi.boolean().required(), isRead: joi.boolean().optional(), messages: joi.array().items(joi.object()).required(), - section: joi.string().required(), - sentBy: joi.string().required(), - sentBySection: joi.string().optional(), + section: joi + .string() + .valid( + ...SECTIONS, + ...CHAMBERS_SECTIONS, + ...Object.values(ROLES), + IRS_SYSTEM_SECTION, + ) + .required(), + sentBy: joi.string().max(100).required(), + sentBySection: joi + .string() + .valid(...SECTIONS, ...CHAMBERS_SECTIONS, ...Object.values(ROLES)) + .optional(), sentByUserId: joi .string() .uuid({ diff --git a/shared/src/business/entities/WorkItem.test.js b/shared/src/business/entities/WorkItem.test.js index 587088728e0..bc637ba1752 100644 --- a/shared/src/business/entities/WorkItem.test.js +++ b/shared/src/business/entities/WorkItem.test.js @@ -1,5 +1,5 @@ const { applicationContext } = require('../test/createTestApplicationContext'); -const { Case } = require('./cases/Case'); +const { CASE_STATUS_TYPES } = require('./EntityConstants'); const { Message } = require('./Message'); const { WorkItem } = require('./WorkItem'); @@ -15,7 +15,7 @@ describe('WorkItem', () => { assigneeId: '8b4cd447-6278-461b-b62b-d9e357eea62c', assigneeName: 'bob', caseId: 'c6b81f4d-1e47-423a-8caf-6d2fdc3d3859', - caseStatus: Case.STATUS_TYPES.new, + caseStatus: CASE_STATUS_TYPES.new, caseTitle: 'Johnny Joe Jacobson', docketNumber: '101-18', docketNumberSuffix: 'S', @@ -36,7 +36,7 @@ describe('WorkItem', () => { assigneeId: '8b4cd447-6278-461b-b62b-d9e357eea62c', assigneeName: 'bob', caseId: 'c6b81f4d-1e47-423a-8caf-6d2fdc3d3859', - caseStatus: Case.STATUS_TYPES.new, + caseStatus: CASE_STATUS_TYPES.new, caseTitle: 'Johnny Joe Jacobson', docketNumber: '101-18', docketNumberSuffix: 'S', @@ -58,7 +58,7 @@ describe('WorkItem', () => { assigneeId: '8b4cd447-6278-461b-b62b-d9e357eea62c', assigneeName: 'bob', caseId: 'c6b81f4d-1e47-423a-8caf-6d2fdc3d3859', - caseStatus: Case.STATUS_TYPES.new, + caseStatus: CASE_STATUS_TYPES.new, caseTitle: 'Johnny Joe Jacobson', docketNumber: '101-18', docketNumberSuffix: 'S', @@ -81,7 +81,7 @@ describe('WorkItem', () => { assigneeId: '8b4cd447-6278-461b-b62b-d9e357eea62c', assigneeName: 'bob', caseId: 'c6b81f4d-1e47-423a-8caf-6d2fdc3d3859', - caseStatus: Case.STATUS_TYPES.new, + caseStatus: CASE_STATUS_TYPES.new, caseTitle: 'Johnny Joe Jacobson', docketNumber: '101-18', docketNumberSuffix: 'S', @@ -101,7 +101,7 @@ describe('WorkItem', () => { assigneeId: '8b4cd447-6278-461b-b62b-d9e357eea62c', assigneeName: 'bob', caseId: 'c6b81f4d-1e47-423a-8caf-6d2fdc3d3859', - caseStatus: Case.STATUS_TYPES.new, + caseStatus: CASE_STATUS_TYPES.new, caseTitle: 'Johnny Joe Jacobson', docketNumber: '101-18', docketNumberSuffix: 'S', @@ -130,7 +130,7 @@ describe('WorkItem', () => { assigneeId: '8b4cd447-6278-461b-b62b-d9e357eea62c', assigneeName: 'bob', caseId: 'c6b81f4d-1e47-423a-8caf-6d2fdc3d3859', - caseStatus: Case.STATUS_TYPES.new, + caseStatus: CASE_STATUS_TYPES.new, caseTitle: 'Johnny Joe Jacobson', docketNumber: '101-18', docketNumberSuffix: 'S', @@ -160,7 +160,7 @@ describe('WorkItem', () => { assigneeId: '8b4cd447-6278-461b-b62b-d9e357eea62c', assigneeName: 'bob', caseId: 'c6b81f4d-1e47-423a-8caf-6d2fdc3d3859', - caseStatus: Case.STATUS_TYPES.new, + caseStatus: CASE_STATUS_TYPES.new, caseTitle: 'Johnny Joe Jacobson', docketNumber: '101-18', docketNumberSuffix: 'S', diff --git a/shared/src/business/entities/WorkQueue.js b/shared/src/business/entities/WorkQueue.js deleted file mode 100644 index 48eec6ffb50..00000000000 --- a/shared/src/business/entities/WorkQueue.js +++ /dev/null @@ -1,88 +0,0 @@ -const { sortBy } = require('lodash'); - -exports.ADC_SECTION = 'adc'; -exports.ADMISSIONS_SECTION = 'admissions'; -exports.CHAMBERS_SECTION = 'chambers'; -exports.CLERK_OF_COURT_SECTION = 'clerkofcourt'; -exports.DOCKET_SECTION = 'docket'; -exports.PETITIONS_SECTION = 'petitions'; -exports.IRS_SYSTEM_SECTION = 'irsSystem'; -exports.TRIAL_CLERKS_SECTION = 'trialClerks'; - -exports.ARMENS_CHAMBERS_SECTION = 'armensChambers'; -exports.ASHFORDS_CHAMBERS_SECTION = 'ashfordsChambers'; -exports.BUCHS_CHAMBERS_SECTION = 'buchsChambers'; -exports.CARLUZZOS_CHAMBERS_SECTION = 'carluzzosChambers'; -exports.COHENS_CHAMBERS_SECTION = 'cohensChambers'; -exports.COLVINS_CHAMBERS_SECTION = 'colvinsChambers'; -exports.COPELANDS_CHAMBERS_SECTION = 'copelandsChambers'; -exports.FOLEYS_CHAMBERS_SECTION = 'foleysChambers'; -exports.GALES_CHAMBERS_SECTION = 'galesChambers'; -exports.GERBERS_CHAMBERS_SECTION = 'gerbersChambers'; -exports.GOEKES_CHAMBERS_SECTION = 'goekesChambers'; -exports.GUSTAFSONS_CHAMBERS_SECTION = 'gustafsonsChambers'; -exports.GUYS_CHAMBERS_SECTION = 'guysChambers'; -exports.HALPERNS_CHAMBERS_SECTION = 'halpernsChambers'; -exports.HOLMES_CHAMBERS_SECTION = 'holmesChambers'; -exports.JACOBS_CHAMBERS_SECTION = 'jacobsChambers'; -exports.JONES_CHAMBERS_SECTION = 'jonesChambers'; -exports.KERRIGANS_CHAMBERS_SECTION = 'kerrigansChambers'; -exports.LAUBERS_CHAMBERS_SECTION = 'laubersChambers'; -exports.LEYDENS_CHAMBERS_SECTION = 'leydensChambers'; -exports.MARVELS_CHAMBERS_SECTION = 'marvelsChambers'; -exports.MORRISONS_CHAMBERS_SECTION = 'morrisonsChambers'; -exports.NEGAS_CHAMBERS_SECTION = 'negasChambers'; -exports.PANUTHOS_CHAMBERS_SECTION = 'panuthosChambers'; -exports.PARIS_CHAMBERS_SECTION = 'parisChambers'; -exports.PUGHS_CHAMBERS_SECTION = 'pughsChambers'; -exports.RUWES_CHAMBERS_SECTION = 'ruwesChambers'; -exports.THORNTONS_CHAMBERS_SECTION = 'thorntonsChambers'; -exports.TOROS_CHAMBERS_SECTION = 'torosChambers'; -exports.URDAS_CHAMBERS_SECTION = 'urdasChambers'; -exports.VASQUEZS_CHAMBERS_SECTION = 'vasquezsChambers'; -exports.WELLS_CHAMBERS_SECTION = 'wellsChambers'; - -exports.SECTIONS = sortBy([ - exports.ADC_SECTION, - exports.ADMISSIONS_SECTION, - exports.CHAMBERS_SECTION, - exports.CLERK_OF_COURT_SECTION, - exports.DOCKET_SECTION, - exports.PETITIONS_SECTION, - exports.TRIAL_CLERKS_SECTION, -]); - -exports.CHAMBERS_SECTIONS = sortBy([ - exports.ARMENS_CHAMBERS_SECTION, - exports.ASHFORDS_CHAMBERS_SECTION, - exports.BUCHS_CHAMBERS_SECTION, - exports.CARLUZZOS_CHAMBERS_SECTION, - exports.COHENS_CHAMBERS_SECTION, - exports.COLVINS_CHAMBERS_SECTION, - exports.COPELANDS_CHAMBERS_SECTION, - exports.FOLEYS_CHAMBERS_SECTION, - exports.GALES_CHAMBERS_SECTION, - exports.GERBERS_CHAMBERS_SECTION, - exports.GOEKES_CHAMBERS_SECTION, - exports.GUSTAFSONS_CHAMBERS_SECTION, - exports.GUYS_CHAMBERS_SECTION, - exports.HALPERNS_CHAMBERS_SECTION, - exports.HOLMES_CHAMBERS_SECTION, - exports.JACOBS_CHAMBERS_SECTION, - exports.JONES_CHAMBERS_SECTION, - exports.KERRIGANS_CHAMBERS_SECTION, - exports.LAUBERS_CHAMBERS_SECTION, - exports.LEYDENS_CHAMBERS_SECTION, - exports.MARVELS_CHAMBERS_SECTION, - exports.MORRISONS_CHAMBERS_SECTION, - exports.NEGAS_CHAMBERS_SECTION, - exports.PANUTHOS_CHAMBERS_SECTION, - exports.PARIS_CHAMBERS_SECTION, - exports.PUGHS_CHAMBERS_SECTION, - exports.RUWES_CHAMBERS_SECTION, - exports.THORNTONS_CHAMBERS_SECTION, - exports.TOROS_CHAMBERS_SECTION, - exports.URDAS_CHAMBERS_SECTION, - exports.VASQUEZS_CHAMBERS_SECTION, - exports.WELLS_CHAMBERS_SECTION, -]); diff --git a/shared/src/business/entities/cases/Case.js b/shared/src/business/entities/cases/Case.js index 96ccd109b00..d9a4edb921f 100644 --- a/shared/src/business/entities/cases/Case.js +++ b/shared/src/business/entities/cases/Case.js @@ -1,4 +1,27 @@ const joi = require('@hapi/joi'); +const { + ANSWER_CUTOFF_AMOUNT_IN_DAYS, + ANSWER_DOCUMENT_CODES, + AUTOMATIC_BLOCKED_REASONS, + CASE_CAPTION_POSTFIX, + CASE_STATUS_TYPES, + CASE_TYPES, + CASE_TYPES_MAP, + CHIEF_JUDGE, + COURT_ISSUED_EVENT_CODES, + DOCKET_NUMBER_MATCHER, + DOCKET_NUMBER_SUFFIXES, + FILING_TYPES, + INITIAL_DOCUMENT_TYPES, + MAX_FILE_SIZE_MB, + ORDER_TYPES, + PARTY_TYPES, + PAYMENT_STATUS, + PROCEDURE_TYPES, + ROLES, + TRIAL_CITY_STRINGS, + TRIAL_LOCATION_MATCHER, +} = require('../EntityConstants'); const { calculateDifferenceInDays, createISODateString, @@ -6,11 +29,6 @@ const { PATTERNS, prepareDateFromString, } = require('../../utilities/DateHandler'); -const { - CHIEF_JUDGE, - DOCKET_NUMBER_MATCHER, - TRIAL_LOCATION_MATCHER, -} = require('./CaseConstants'); const { getDocketNumberSuffix, } = require('../../utilities/getDocketNumberSuffix'); @@ -25,127 +43,10 @@ const { Document } = require('../Document'); const { find, includes, isEmpty } = require('lodash'); const { getTimestampSchema } = require('../../../utilities/dateSchema'); const { IrsPractitioner } = require('../IrsPractitioner'); -const { MAX_FILE_SIZE_MB } = require('../../../persistence/s3/getUploadPolicy'); -const { Order } = require('../orders/Order'); const { PrivatePractitioner } = require('../PrivatePractitioner'); const { Statistic } = require('../Statistic'); -const { TrialSession } = require('../trialSessions/TrialSession'); const { User } = require('../User'); const joiStrictTimestamp = getTimestampSchema(); -const orderDocumentTypes = Order.ORDER_TYPES.map( - orderType => orderType.documentType, -); -const courtIssuedDocumentTypes = Document.COURT_ISSUED_EVENT_CODES.map( - courtIssuedDoc => courtIssuedDoc.documentType, -); - -Case.PAYMENT_STATUS = { - PAID: 'Paid', - UNPAID: 'Not Paid', - WAIVED: 'Waived', -}; - -Case.STATUS_TYPES = { - assignedCase: 'Assigned - Case', // Case has been assigned to a judge - assignedMotion: 'Assigned - Motion', // Someone has requested a judge for the case - calendared: 'Calendared', // Case has been scheduled for trial - cav: 'CAV', // Core alternative valuation - closed: 'Closed', // Judge has made a ruling to close the case - generalDocket: 'General Docket - Not at Issue', // Submitted to the IRS - generalDocketReadyForTrial: 'General Docket - At Issue (Ready for Trial)', // Case is ready for trial - jurisdictionRetained: 'Jurisdiction Retained', // Jurisdiction of a case is retained by a specific judge — usually after the case is on a judge’s trial calendar - new: 'New', // Case has not been QCed - onAppeal: 'On Appeal', // After the trial, the case has gone to the appeals court - rule155: 'Rule 155', // Where the Court has filed or stated its opinion or issued a dispositive order determining the issues in a case, it may withhold entry of its decision for the purpose of permitting the parties to submit computations pursuant to the Court’s determination of the issues, showing the correct amount to be included in the decision. - submitted: 'Submitted', // Submitted to the judge for decision -}; - -Case.STATUS_TYPES_WITH_ASSOCIATED_JUDGE = [ - Case.STATUS_TYPES.assignedCase, - Case.STATUS_TYPES.assignedMotion, - Case.STATUS_TYPES.cav, - Case.STATUS_TYPES.jurisdictionRetained, - Case.STATUS_TYPES.rule155, - Case.STATUS_TYPES.submitted, -]; - -Case.STATUS_TYPES_MANUAL_UPDATE = [ - Case.STATUS_TYPES.assignedCase, - Case.STATUS_TYPES.assignedMotion, - Case.STATUS_TYPES.cav, - Case.STATUS_TYPES.closed, - Case.STATUS_TYPES.generalDocket, - Case.STATUS_TYPES.generalDocketReadyForTrial, - Case.STATUS_TYPES.jurisdictionRetained, - Case.STATUS_TYPES.onAppeal, - Case.STATUS_TYPES.rule155, - Case.STATUS_TYPES.submitted, -]; - -Case.ANSWER_CUTOFF_AMOUNT_IN_DAYS = 45; -Case.ANSWER_CUTOFF_UNIT = 'day'; - -Case.CASE_TYPES_MAP = { - cdp: 'CDP (Lien/Levy)', - deficiency: 'Deficiency', - djExemptOrg: 'Declaratory Judgment (Exempt Organization)', - djRetirementPlan: 'Declaratory Judgment (Retirement Plan)', - innocentSpouse: 'Innocent Spouse', - interestAbatement: 'Interest Abatement', - other: 'Other', - partnershipSection1101: 'Partnership (BBA Section 1101)', - partnershipSection6226: 'Partnership (Section 6226)', - partnershipSection6228: 'Partnership (Section 6228)', - passport: 'Passport', - whistleblower: 'Whistleblower', - workerClassification: 'Worker Classification', -}; - -Case.CASE_TYPES = Object.values(Case.CASE_TYPES_MAP); - -// This is the order that they appear in the UI -Case.PROCEDURE_TYPES = ['Regular', 'Small']; - -Case.FILING_TYPES = { - [User.ROLES.petitioner]: [ - 'Myself', - 'Myself and my spouse', - 'A business', - 'Other', - ], - [User.ROLES.privatePractitioner]: [ - 'Individual petitioner', - 'Petitioner and spouse', - 'A business', - 'Other', - ], -}; - -Case.CASE_CAPTION_POSTFIX = 'v. Commissioner of Internal Revenue, Respondent'; - -Case.ANSWER_DOCUMENT_CODES = [ - 'A', - 'AAAP', - 'AAPN', - 'AATP', - 'AATS', - 'AATT', - 'APA', - 'ASAP', - 'ASUP', - 'ATAP', - 'ATSP', -]; - -Case.AUTOMATIC_BLOCKED_REASONS = { - dueDate: 'Due Date', - pending: 'Pending Item', - pendingAndDueDate: 'Pending Item and Due Date', -}; - -Case.CHIEF_JUDGE = CHIEF_JUDGE; - -Case.DOCKET_NUMBER_SUFFIXES = ['W', 'P', 'X', 'R', 'SL', 'L', 'S']; Case.VALIDATION_ERROR_MESSAGES = { applicationForWaiverOfFilingFeeFile: @@ -241,7 +142,7 @@ function Case(rawCase, { applicationContext, filtered = false }) { !filtered || User.isInternalUser(applicationContext.getCurrentUser().role) ) { - this.associatedJudge = rawCase.associatedJudge || Case.CHIEF_JUDGE; + this.associatedJudge = rawCase.associatedJudge || CHIEF_JUDGE; this.automaticBlocked = rawCase.automaticBlocked; this.automaticBlockedDate = rawCase.automaticBlockedDate; this.automaticBlockedReason = rawCase.automaticBlockedReason; @@ -254,7 +155,7 @@ function Case(rawCase, { applicationContext, filtered = false }) { this.highPriorityReason = rawCase.highPriorityReason; this.litigationCosts = rawCase.litigationCosts; this.qcCompleteForTrial = rawCase.qcCompleteForTrial || {}; - this.status = rawCase.status || Case.STATUS_TYPES.new; + this.status = rawCase.status || CASE_STATUS_TYPES.new; this.userId = rawCase.userId; if (Array.isArray(rawCase.statistics)) { @@ -271,7 +172,9 @@ function Case(rawCase, { applicationContext, filtered = false }) { this.caseType = rawCase.caseType; this.closedDate = rawCase.closedDate; this.createdAt = rawCase.createdAt || createISODateString(); - this.docketNumber = rawCase.docketNumber; + if (rawCase.docketNumber) { + this.docketNumber = rawCase.docketNumber.replace(/^0+/, ''); // strip leading zeroes + } this.docketNumberSuffix = getDocketNumberSuffix(rawCase); this.filingType = rawCase.filingType; this.hasVerifiedIrsNotice = rawCase.hasVerifiedIrsNotice; @@ -284,7 +187,7 @@ function Case(rawCase, { applicationContext, filtered = false }) { this.petitionPaymentDate = rawCase.petitionPaymentDate; this.petitionPaymentMethod = rawCase.petitionPaymentMethod; this.petitionPaymentStatus = - rawCase.petitionPaymentStatus || Case.PAYMENT_STATUS.UNPAID; + rawCase.petitionPaymentStatus || PAYMENT_STATUS.UNPAID; this.petitionPaymentWaivedDate = rawCase.petitionPaymentWaivedDate; this.preferredTrialCity = rawCase.preferredTrialCity; this.procedureType = rawCase.procedureType; @@ -389,7 +292,7 @@ function Case(rawCase, { applicationContext, filtered = false }) { this.contactSecondary = contacts.secondary; } -Case.validationRules = { +Case.VALIDATION_RULES = { associatedJudge: joi .string() .max(50) @@ -412,7 +315,7 @@ Case.validationRules = { otherwise: joi.optional().allow(null), then: joi .string() - .valid(...Object.values(Case.AUTOMATIC_BLOCKED_REASONS)) + .valid(...Object.values(AUTOMATIC_BLOCKED_REASONS)) .required() .description('The reason the case was automatically blocked from trial.'), }), @@ -462,10 +365,10 @@ Case.validationRules = { .meta({ tags: ['Restricted'] }), caseType: joi .string() - .valid(...Case.CASE_TYPES) + .valid(...CASE_TYPES) .required(), closedDate: joi.when('status', { - is: Case.STATUS_TYPES.closed, + is: CASE_STATUS_TYPES.closed, otherwise: joi.optional().allow(null), then: joiStrictTimestamp.required(), }), @@ -493,7 +396,7 @@ Case.validationRules = { docketNumberSuffix: joi .string() .allow(null) - .valid(...Object.values(Case.DOCKET_NUMBER_SUFFIXES)) + .valid(...Object.values(DOCKET_NUMBER_SUFFIXES)) .optional(), docketNumberWithSuffix: joi .string() @@ -514,8 +417,8 @@ Case.validationRules = { filingType: joi .string() .valid( - ...Case.FILING_TYPES[User.ROLES.petitioner], - ...Case.FILING_TYPES[User.ROLES.privatePractitioner], + ...FILING_TYPES[ROLES.petitioner], + ...FILING_TYPES[ROLES.privatePractitioner], ) .optional(), hasVerifiedIrsNotice: joi @@ -630,31 +533,31 @@ Case.validationRules = { .description('Reminder for clerks to review the Order to Show Cause.'), partyType: joi .string() - .valid(...Object.values(ContactFactory.PARTY_TYPES)) + .valid(...Object.values(PARTY_TYPES)) .required() .description('Party type of the case petitioner.'), petitionPaymentDate: joi .when('petitionPaymentStatus', { - is: Case.PAYMENT_STATUS.PAID, + is: PAYMENT_STATUS.PAID, otherwise: joiStrictTimestamp.optional().allow(null), then: joiStrictTimestamp.required(), }) .description('When the petitioner paid the case fee.'), petitionPaymentMethod: joi .when('petitionPaymentStatus', { - is: Case.PAYMENT_STATUS.PAID, + is: PAYMENT_STATUS.PAID, otherwise: joi.string().allow(null).optional(), then: joi.string().max(50).required(), }) .description('How the petitioner paid the case fee.'), petitionPaymentStatus: joi .string() - .valid(...Object.values(Case.PAYMENT_STATUS)) + .valid(...Object.values(PAYMENT_STATUS)) .required() .description('Status of the case fee payment.'), petitionPaymentWaivedDate: joi .when('petitionPaymentStatus', { - is: Case.PAYMENT_STATUS.WAIVED, + is: PAYMENT_STATUS.WAIVED, otherwise: joiStrictTimestamp.allow(null).optional(), then: joiStrictTimestamp.required(), }) @@ -662,7 +565,7 @@ Case.validationRules = { preferredTrialCity: joi .alternatives() .try( - joi.string().valid(...TrialSession.TRIAL_CITY_STRINGS, null), + joi.string().valid(...TRIAL_CITY_STRINGS, null), joi.string().pattern(TRIAL_LOCATION_MATCHER), // Allow unique values for testing ) .optional() @@ -673,7 +576,7 @@ Case.validationRules = { .description('List of private practitioners associated with the case.'), procedureType: joi .string() - .valid(...Case.PROCEDURE_TYPES) + .valid(...PROCEDURE_TYPES) .required() .description('Procedure type of the case.'), qcCompleteForTrial: joi @@ -706,7 +609,7 @@ Case.validationRules = { .items(joi.object().meta({ entityName: 'Statistic' })) .optional(), then: joi.when('caseType', { - is: Case.CASE_TYPES_MAP.deficiency, + is: CASE_TYPES_MAP.deficiency, otherwise: joi .array() .items(joi.object().meta({ entityName: 'Statistic' })) @@ -721,7 +624,7 @@ Case.validationRules = { .description('List of Statistic Entities for the case.'), status: joi .string() - .valid(...Object.values(Case.STATUS_TYPES)) + .valid(...Object.values(CASE_STATUS_TYPES)) .optional() .meta({ tags: ['Restricted'] }) .description('Status of the case.'), @@ -732,7 +635,7 @@ Case.validationRules = { trialLocation: joi .alternatives() .try( - joi.string().valid(...TrialSession.TRIAL_CITY_STRINGS, null), + joi.string().valid(...TRIAL_CITY_STRINGS, null), joi.string().pattern(TRIAL_LOCATION_MATCHER), // Allow unique values for testing ) .optional() @@ -774,10 +677,15 @@ Case.validationRules = { joiValidationDecorator( Case, - joi.object().keys(Case.validationRules), + joi.object().keys(Case.VALIDATION_RULES), Case.VALIDATION_ERROR_MESSAGES, ); +const orderDocumentTypes = ORDER_TYPES.map(orderType => orderType.documentType); +const courtIssuedDocumentTypes = COURT_ISSUED_EVENT_CODES.map( + courtIssuedDoc => courtIssuedDoc.documentType, +); + /** * builds the case caption from case contact name(s) based on party type * @@ -787,56 +695,56 @@ joiValidationDecorator( Case.getCaseCaption = function (rawCase) { let caseCaption; switch (rawCase.partyType) { - case ContactFactory.PARTY_TYPES.corporation: - case ContactFactory.PARTY_TYPES.petitioner: + case PARTY_TYPES.corporation: + case PARTY_TYPES.petitioner: caseCaption = `${rawCase.contactPrimary.name}, Petitioner`; break; - case ContactFactory.PARTY_TYPES.petitionerSpouse: + case PARTY_TYPES.petitionerSpouse: caseCaption = `${rawCase.contactPrimary.name} & ${rawCase.contactSecondary.name}, Petitioners`; break; - case ContactFactory.PARTY_TYPES.petitionerDeceasedSpouse: + case PARTY_TYPES.petitionerDeceasedSpouse: caseCaption = `${rawCase.contactPrimary.name} & ${rawCase.contactSecondary.name}, Deceased, ${rawCase.contactPrimary.name}, Surviving Spouse, Petitioners`; break; - case ContactFactory.PARTY_TYPES.estate: + case PARTY_TYPES.estate: caseCaption = `Estate of ${rawCase.contactPrimary.name}, Deceased, ${rawCase.contactPrimary.secondaryName}, ${rawCase.contactPrimary.title}, Petitioner(s)`; break; - case ContactFactory.PARTY_TYPES.estateWithoutExecutor: + case PARTY_TYPES.estateWithoutExecutor: caseCaption = `Estate of ${rawCase.contactPrimary.name}, Deceased, Petitioner`; break; - case ContactFactory.PARTY_TYPES.trust: + case PARTY_TYPES.trust: caseCaption = `${rawCase.contactPrimary.name}, ${rawCase.contactPrimary.secondaryName}, Trustee, Petitioner(s)`; break; - case ContactFactory.PARTY_TYPES.partnershipAsTaxMattersPartner: + case PARTY_TYPES.partnershipAsTaxMattersPartner: caseCaption = `${rawCase.contactPrimary.name}, ${rawCase.contactPrimary.secondaryName}, Tax Matters Partner, Petitioner`; break; - case ContactFactory.PARTY_TYPES.partnershipOtherThanTaxMatters: + case PARTY_TYPES.partnershipOtherThanTaxMatters: caseCaption = `${rawCase.contactPrimary.name}, ${rawCase.contactPrimary.secondaryName}, A Partner Other Than the Tax Matters Partner, Petitioner`; break; - case ContactFactory.PARTY_TYPES.partnershipBBA: + case PARTY_TYPES.partnershipBBA: caseCaption = `${rawCase.contactPrimary.name}, ${rawCase.contactPrimary.secondaryName}, Partnership Representative, Petitioner(s)`; break; - case ContactFactory.PARTY_TYPES.conservator: + case PARTY_TYPES.conservator: caseCaption = `${rawCase.contactPrimary.name}, ${rawCase.contactPrimary.secondaryName}, Conservator, Petitioner`; break; - case ContactFactory.PARTY_TYPES.guardian: + case PARTY_TYPES.guardian: caseCaption = `${rawCase.contactPrimary.name}, ${rawCase.contactPrimary.secondaryName}, Guardian, Petitioner`; break; - case ContactFactory.PARTY_TYPES.custodian: + case PARTY_TYPES.custodian: caseCaption = `${rawCase.contactPrimary.name}, ${rawCase.contactPrimary.secondaryName}, Custodian, Petitioner`; break; - case ContactFactory.PARTY_TYPES.nextFriendForMinor: + case PARTY_TYPES.nextFriendForMinor: caseCaption = `${rawCase.contactPrimary.name}, Minor, ${rawCase.contactPrimary.secondaryName}, Next Friend, Petitioner`; break; - case ContactFactory.PARTY_TYPES.nextFriendForIncompetentPerson: + case PARTY_TYPES.nextFriendForIncompetentPerson: caseCaption = `${rawCase.contactPrimary.name}, Incompetent, ${rawCase.contactPrimary.secondaryName}, Next Friend, Petitioner`; break; - case ContactFactory.PARTY_TYPES.donor: + case PARTY_TYPES.donor: caseCaption = `${rawCase.contactPrimary.name}, Donor, Petitioner`; break; - case ContactFactory.PARTY_TYPES.transferee: + case PARTY_TYPES.transferee: caseCaption = `${rawCase.contactPrimary.name}, Transferee, Petitioner`; break; - case ContactFactory.PARTY_TYPES.survivingSpouse: + case PARTY_TYPES.survivingSpouse: caseCaption = `${rawCase.contactPrimary.name}, Deceased, ${rawCase.contactPrimary.secondaryName}, Surviving Spouse, Petitioner`; break; } @@ -970,7 +878,7 @@ Case.prototype.addDocumentWithoutDocketRecord = function (document) { Case.prototype.closeCase = function () { this.closedDate = createISODateString(); - this.status = Case.STATUS_TYPES.closed; + this.status = CASE_STATUS_TYPES.closed; this.unsetAsBlocked(); this.unsetAsHighPriority(); return this; @@ -982,7 +890,7 @@ Case.prototype.closeCase = function () { * @returns {Case} the updated case entity */ Case.prototype.markAsSentToIRS = function () { - this.status = Case.STATUS_TYPES.generalDocket; + this.status = CASE_STATUS_TYPES.generalDocket; return this; }; @@ -1001,7 +909,7 @@ Case.prototype.updateCaseCaptionDocketRecord = function ({ const result = caseCaptionRegex.exec(docketRecord.description); if (result) { const [, , changedCaption] = result; - lastCaption = changedCaption.replace(` ${Case.CASE_CAPTION_POSTFIX}`, ''); + lastCaption = changedCaption.replace(` ${CASE_CAPTION_POSTFIX}`, ''); } }); @@ -1012,7 +920,7 @@ Case.prototype.updateCaseCaptionDocketRecord = function ({ this.addDocketRecord( new DocketRecord( { - description: `Caption of case is amended from '${lastCaption} ${Case.CASE_CAPTION_POSTFIX}' to '${this.caseCaption} ${Case.CASE_CAPTION_POSTFIX}'`, + description: `Caption of case is amended from '${lastCaption} ${CASE_CAPTION_POSTFIX}' to '${this.caseCaption} ${CASE_CAPTION_POSTFIX}'`, eventCode: 'MINC', filingDate: createISODateString(), }, @@ -1075,8 +983,7 @@ Case.prototype.getDocumentById = function ({ documentId }) { Case.prototype.getPetitionDocument = function () { return this.documents.find( document => - document.documentType === - Document.INITIAL_DOCUMENT_TYPES.petition.documentType, + document.documentType === INITIAL_DOCUMENT_TYPES.petition.documentType, ); }; @@ -1107,8 +1014,7 @@ Case.prototype.setRequestForTrialDocketRecord = function ( new DocketRecord( { description: `Request for Place of Trial at ${this.preferredTrialCity}`, - eventCode: - Document.INITIAL_DOCUMENT_TYPES.requestForPlaceOfTrial.eventCode, + eventCode: INITIAL_DOCUMENT_TYPES.requestForPlaceOfTrial.eventCode, filingDate: this.receivedAt || this.createdAt, }, { applicationContext }, @@ -1204,20 +1110,6 @@ Case.isValidCaseId = caseId => caseId, ); -/** - * isValidDocketNumber - * - * @param {string} docketNumber the docket number to validate - * @returns {*|boolean} true if the docketNumber is valid, false otherwise - */ -Case.isValidDocketNumber = docketNumber => { - return ( - docketNumber && - DOCKET_NUMBER_MATCHER.test(docketNumber) && - parseInt(docketNumber.split('-')[0]) > 100 - ); -}; - /** * stripLeadingZeros * @@ -1252,12 +1144,12 @@ Case.prototype.checkForReadyForTrial = function () { const currentDate = prepareDateFromString().toISOString(); const isCaseGeneralDocketNotAtIssue = - this.status === Case.STATUS_TYPES.generalDocket; + this.status === CASE_STATUS_TYPES.generalDocket; if (isCaseGeneralDocketNotAtIssue) { this.documents.forEach(document => { const isAnswerDocument = includes( - Case.ANSWER_DOCUMENT_CODES, + ANSWER_DOCUMENT_CODES, document.eventCode, ); @@ -1267,10 +1159,10 @@ Case.prototype.checkForReadyForTrial = function () { ); const requiredTimeElapsedSinceFiling = - daysElapsedSinceDocumentWasFiled > Case.ANSWER_CUTOFF_AMOUNT_IN_DAYS; + daysElapsedSinceDocumentWasFiled > ANSWER_CUTOFF_AMOUNT_IN_DAYS; if (isAnswerDocument && requiredTimeElapsedSinceFiling) { - this.status = Case.STATUS_TYPES.generalDocketReadyForTrial; + this.status = CASE_STATUS_TYPES.generalDocketReadyForTrial; } }); } @@ -1365,7 +1257,7 @@ Case.prototype.setAsCalendared = function (trialSessionEntity) { this.trialTime = trialSessionEntity.startTime; this.trialLocation = trialSessionEntity.trialLocation; if (trialSessionEntity.isCalendared === true) { - this.status = Case.STATUS_TYPES.calendared; + this.status = CASE_STATUS_TYPES.calendared; } return this; }; @@ -1386,7 +1278,7 @@ const isAssociatedUser = function ({ caseRaw, user }) { caseRaw.privatePractitioners && caseRaw.privatePractitioners.find(p => p.userId === user.userId); - const isIrsSuperuser = user.role === User.ROLES.irsSuperuser; + const isIrsSuperuser = user.role === ROLES.irsSuperuser; const petitionDocument = (caseRaw.documents || []).find( doc => doc.documentType === 'Petition', @@ -1407,7 +1299,7 @@ const isAssociatedUser = function ({ caseRaw, user }) { * @returns {boolean} if the case is calendared */ Case.prototype.isCalendared = function () { - return this.status === Case.STATUS_TYPES.calendared; + return this.status === CASE_STATUS_TYPES.calendared; }; /** @@ -1416,7 +1308,7 @@ Case.prototype.isCalendared = function () { * @returns {boolean} if the case is calendared */ Case.prototype.isReadyForTrial = function () { - return this.status === Case.STATUS_TYPES.generalDocketReadyForTrial; + return this.status === CASE_STATUS_TYPES.generalDocketReadyForTrial; }; /** @@ -1455,11 +1347,11 @@ Case.prototype.updateAutomaticBlocked = function ({ caseDeadlines }) { const hasPendingItems = this.doesHavePendingItems(); let automaticBlockedReason; if (hasPendingItems && !isEmpty(caseDeadlines)) { - automaticBlockedReason = Case.AUTOMATIC_BLOCKED_REASONS.pendingAndDueDate; + automaticBlockedReason = AUTOMATIC_BLOCKED_REASONS.pendingAndDueDate; } else if (hasPendingItems) { - automaticBlockedReason = Case.AUTOMATIC_BLOCKED_REASONS.pending; + automaticBlockedReason = AUTOMATIC_BLOCKED_REASONS.pending; } else if (!isEmpty(caseDeadlines)) { - automaticBlockedReason = Case.AUTOMATIC_BLOCKED_REASONS.dueDate; + automaticBlockedReason = AUTOMATIC_BLOCKED_REASONS.dueDate; } if (automaticBlockedReason) { this.automaticBlocked = true; @@ -1502,8 +1394,8 @@ Case.prototype.unsetAsHighPriority = function () { * @returns {Case} the updated case entity */ Case.prototype.removeFromTrial = function () { - this.status = Case.STATUS_TYPES.generalDocketReadyForTrial; - this.associatedJudge = Case.CHIEF_JUDGE; + this.status = CASE_STATUS_TYPES.generalDocketReadyForTrial; + this.associatedJudge = CHIEF_JUDGE; this.trialDate = undefined; this.trialLocation = undefined; this.trialSessionId = undefined; @@ -1550,12 +1442,12 @@ Case.prototype.setCaseStatus = function (caseStatus) { this.status = caseStatus; if ( [ - Case.STATUS_TYPES.generalDocket, - Case.STATUS_TYPES.generalDocketReadyForTrial, + CASE_STATUS_TYPES.generalDocket, + CASE_STATUS_TYPES.generalDocketReadyForTrial, ].includes(caseStatus) ) { - this.associatedJudge = Case.CHIEF_JUDGE; - } else if (caseStatus === Case.STATUS_TYPES.closed) { + this.associatedJudge = CHIEF_JUDGE; + } else if (caseStatus === CASE_STATUS_TYPES.closed) { this.closeCase(); } return this; @@ -1649,10 +1541,10 @@ Case.prototype.getConsolidationStatus = function ({ caseEntity }) { */ Case.prototype.canConsolidate = function (caseToConsolidate) { const ineligibleStatusTypes = [ - Case.STATUS_TYPES.new, - Case.STATUS_TYPES.generalDocket, - Case.STATUS_TYPES.closed, - Case.STATUS_TYPES.onAppeal, + CASE_STATUS_TYPES.new, + CASE_STATUS_TYPES.generalDocket, + CASE_STATUS_TYPES.closed, + CASE_STATUS_TYPES.onAppeal, ]; const caseToCheck = caseToConsolidate || this; diff --git a/shared/src/business/entities/cases/Case.test.js b/shared/src/business/entities/cases/Case.test.js index 8671b929fc7..9b1c23efaeb 100644 --- a/shared/src/business/entities/cases/Case.test.js +++ b/shared/src/business/entities/cases/Case.test.js @@ -1,3 +1,15 @@ +const { + ANSWER_CUTOFF_AMOUNT_IN_DAYS, + ANSWER_CUTOFF_UNIT, + AUTOMATIC_BLOCKED_REASONS, + CASE_STATUS_TYPES, + CHIEF_JUDGE, + COUNTRY_TYPES, + INITIAL_DOCUMENT_TYPES, + PARTY_TYPES, + PAYMENT_STATUS, + ROLES, +} = require('../EntityConstants'); const { applicationContext, } = require('../../test/createTestApplicationContext'); @@ -9,7 +21,6 @@ const { Case, isAssociatedUser } = require('./Case'); const { ContactFactory } = require('../contacts/ContactFactory'); const { Correspondence } = require('../Correspondence'); const { DocketRecord } = require('../DocketRecord'); -const { Document } = require('../Document'); const { IrsPractitioner } = require('../IrsPractitioner'); const { MOCK_DOCUMENTS } = require('../../../test/mockDocuments'); const { MOCK_USERS } = require('../../../test/mockUsers'); @@ -17,7 +28,6 @@ const { prepareDateFromString } = require('../../utilities/DateHandler'); const { PrivatePractitioner } = require('../PrivatePractitioner'); const { Statistic } = require('../Statistic'); const { TrialSession } = require('../trialSessions/TrialSession'); -const { User } = require('../User'); const { WorkItem } = require('../WorkItem'); describe('Case entity', () => { @@ -174,6 +184,17 @@ describe('Case entity', () => { expect(myCase.isValid()).toBeTruthy(); }); + it('Creates a valid case from an already existing case json when the docketNumber has leading zeroes', () => { + const myCase = new Case( + { ...MOCK_CASE, docketNumber: '00101-20' }, + { + applicationContext, + }, + ); + expect(myCase.isValid()).toBeTruthy(); + expect(myCase.docketNumber).toBe('101-20'); + }); + it('Creates an invalid case with an invalid nested contact object', () => { const myCase = new Case( { @@ -361,7 +382,7 @@ describe('Case entity', () => { ...MOCK_CASE, automaticBlocked: true, automaticBlockedDate: '2019-03-01T21:42:29.073Z', - automaticBlockedReason: Case.AUTOMATIC_BLOCKED_REASONS.pending, + automaticBlockedReason: AUTOMATIC_BLOCKED_REASONS.pending, }, { applicationContext, @@ -416,7 +437,7 @@ describe('Case entity', () => { const myCase = new Case( { ...MOCK_CASE, - status: Case.STATUS_TYPES.closed, + status: CASE_STATUS_TYPES.closed, }, { applicationContext, @@ -433,7 +454,7 @@ describe('Case entity', () => { { ...MOCK_CASE, closedDate: '2019-03-01T21:40:46.415Z', - status: Case.STATUS_TYPES.closed, + status: CASE_STATUS_TYPES.closed, }, { applicationContext, @@ -460,7 +481,7 @@ describe('Case entity', () => { const myCase = new Case( { ...MOCK_CASE, - petitionPaymentStatus: Case.PAYMENT_STATUS.PAID, + petitionPaymentStatus: PAYMENT_STATUS.PAID, }, { applicationContext, @@ -476,7 +497,7 @@ describe('Case entity', () => { const myCase = new Case( { ...MOCK_CASE, - petitionPaymentStatus: Case.PAYMENT_STATUS.WAIVED, + petitionPaymentStatus: PAYMENT_STATUS.WAIVED, }, { applicationContext, @@ -555,16 +576,6 @@ describe('Case entity', () => { }); }); - describe('isValidDocketNumber', () => { - it('returns true if a valid docketNumber', () => { - expect(Case.isValidDocketNumber('00101-00')).toBeTruthy(); - }); - - it('returns false if an invalid docket number', () => { - expect(Case.isValidDocketNumber('00')).toBeFalsy(); - }); - }); - describe('markAsSentToIRS', () => { it('updates case status to general docket not at issue', () => { const caseRecord = new Case( @@ -589,7 +600,7 @@ describe('Case entity', () => { }, ); caseRecord.markAsSentToIRS(); - expect(caseRecord.status).toEqual(Case.STATUS_TYPES.generalDocket); + expect(caseRecord.status).toEqual(CASE_STATUS_TYPES.generalDocket); }); }); @@ -605,7 +616,7 @@ describe('Case entity', () => { contactSecondary: { name: 'Test Petitioner 2', }, - partyType: ContactFactory.PARTY_TYPES.petitionerSpouse, + partyType: PARTY_TYPES.petitionerSpouse, }); expect(caseCaption).toEqual( 'Test Petitioner & Test Petitioner 2, Petitioners', @@ -618,7 +629,7 @@ describe('Case entity', () => { contactSecondary: { name: 'Test Petitioner 2', }, - partyType: ContactFactory.PARTY_TYPES.petitionerDeceasedSpouse, + partyType: PARTY_TYPES.petitionerDeceasedSpouse, }); expect(caseCaption).toEqual( 'Test Petitioner & Test Petitioner 2, Deceased, Test Petitioner, Surviving Spouse, Petitioners', @@ -628,7 +639,7 @@ describe('Case entity', () => { it('party type Estate with an Executor/Personal Representative/Fiduciary/etc.', () => { const mockCase = { ...MOCK_CASE, - partyType: ContactFactory.PARTY_TYPES.estate, + partyType: PARTY_TYPES.estate, }; mockCase.contactPrimary.secondaryName = 'Test Petitioner 2'; const caseCaption = Case.getCaseCaption(mockCase); @@ -640,7 +651,7 @@ describe('Case entity', () => { it('party type Estate without an Executor/Personal Representative/Fiduciary/etc.', () => { const caseCaption = Case.getCaseCaption({ ...MOCK_CASE, - partyType: ContactFactory.PARTY_TYPES.estateWithoutExecutor, + partyType: PARTY_TYPES.estateWithoutExecutor, }); expect(caseCaption).toEqual( 'Estate of Test Petitioner, Deceased, Petitioner', @@ -650,7 +661,7 @@ describe('Case entity', () => { it('party type Trust', () => { const mockCase = { ...MOCK_CASE, - partyType: ContactFactory.PARTY_TYPES.trust, + partyType: PARTY_TYPES.trust, }; mockCase.contactPrimary.secondaryName = 'Test Petitioner 2'; const caseCaption = Case.getCaseCaption(mockCase); @@ -662,7 +673,7 @@ describe('Case entity', () => { it('party type Corporation', () => { const caseCaption = Case.getCaseCaption({ ...MOCK_CASE, - partyType: ContactFactory.PARTY_TYPES.corporation, + partyType: PARTY_TYPES.corporation, }); expect(caseCaption).toEqual('Test Petitioner, Petitioner'); }); @@ -670,7 +681,7 @@ describe('Case entity', () => { it('party type Partnership Tax Matters', () => { const mockCase = { ...MOCK_CASE, - partyType: ContactFactory.PARTY_TYPES.partnershipAsTaxMattersPartner, + partyType: PARTY_TYPES.partnershipAsTaxMattersPartner, }; mockCase.contactPrimary.secondaryName = 'Test Petitioner 2'; const caseCaption = Case.getCaseCaption(mockCase); @@ -682,7 +693,7 @@ describe('Case entity', () => { it('party type Partnership Other Than Tax Matters', () => { const mockCase = { ...MOCK_CASE, - partyType: ContactFactory.PARTY_TYPES.partnershipOtherThanTaxMatters, + partyType: PARTY_TYPES.partnershipOtherThanTaxMatters, }; mockCase.contactPrimary.secondaryName = 'Test Petitioner 2'; const caseCaption = Case.getCaseCaption(mockCase); @@ -694,7 +705,7 @@ describe('Case entity', () => { it('party type Partnership BBA', () => { const mockCase = { ...MOCK_CASE, - partyType: ContactFactory.PARTY_TYPES.partnershipBBA, + partyType: PARTY_TYPES.partnershipBBA, }; mockCase.contactPrimary.secondaryName = 'Test Petitioner 2'; const caseCaption = Case.getCaseCaption(mockCase); @@ -706,7 +717,7 @@ describe('Case entity', () => { it('party type Conservator', () => { const mockCase = { ...MOCK_CASE, - partyType: ContactFactory.PARTY_TYPES.conservator, + partyType: PARTY_TYPES.conservator, }; mockCase.contactPrimary.secondaryName = 'Test Petitioner 2'; const caseCaption = Case.getCaseCaption(mockCase); @@ -718,7 +729,7 @@ describe('Case entity', () => { it('party type Guardian', () => { const mockCase = { ...MOCK_CASE, - partyType: ContactFactory.PARTY_TYPES.guardian, + partyType: PARTY_TYPES.guardian, }; mockCase.contactPrimary.secondaryName = 'Test Petitioner 2'; const caseCaption = Case.getCaseCaption(mockCase); @@ -730,7 +741,7 @@ describe('Case entity', () => { it('party type Custodian', () => { const mockCase = { ...MOCK_CASE, - partyType: ContactFactory.PARTY_TYPES.custodian, + partyType: PARTY_TYPES.custodian, }; mockCase.contactPrimary.secondaryName = 'Test Petitioner 2'; const caseCaption = Case.getCaseCaption(mockCase); @@ -742,7 +753,7 @@ describe('Case entity', () => { it('party type Minor', () => { const mockCase = { ...MOCK_CASE, - partyType: ContactFactory.PARTY_TYPES.nextFriendForMinor, + partyType: PARTY_TYPES.nextFriendForMinor, }; mockCase.contactPrimary.secondaryName = 'Test Petitioner 2'; const caseCaption = Case.getCaseCaption(mockCase); @@ -754,7 +765,7 @@ describe('Case entity', () => { it('party type Legally Incompetent Person', () => { const mockCase = { ...MOCK_CASE, - partyType: ContactFactory.PARTY_TYPES.nextFriendForIncompetentPerson, + partyType: PARTY_TYPES.nextFriendForIncompetentPerson, }; mockCase.contactPrimary.secondaryName = 'Test Petitioner 2'; const caseCaption = Case.getCaseCaption(mockCase); @@ -766,7 +777,7 @@ describe('Case entity', () => { it('party type Donor', () => { const caseCaption = Case.getCaseCaption({ ...MOCK_CASE, - partyType: ContactFactory.PARTY_TYPES.donor, + partyType: PARTY_TYPES.donor, }); expect(caseCaption).toEqual('Test Petitioner, Donor, Petitioner'); }); @@ -774,7 +785,7 @@ describe('Case entity', () => { it('party type Transferee', () => { const caseCaption = Case.getCaseCaption({ ...MOCK_CASE, - partyType: ContactFactory.PARTY_TYPES.transferee, + partyType: PARTY_TYPES.transferee, }); expect(caseCaption).toEqual('Test Petitioner, Transferee, Petitioner'); }); @@ -782,7 +793,7 @@ describe('Case entity', () => { it('party type Surviving Spouse', () => { const mockCase = { ...MOCK_CASE, - partyType: ContactFactory.PARTY_TYPES.survivingSpouse, + partyType: PARTY_TYPES.survivingSpouse, }; mockCase.contactPrimary.secondaryName = 'Test Petitioner 2'; const caseCaption = Case.getCaseCaption(mockCase); @@ -1010,7 +1021,7 @@ describe('Case entity', () => { { docketNumber: '123-19', isPaper: false, - status: Case.STATUS_TYPES.generalDocket, + status: CASE_STATUS_TYPES.generalDocket, }, { applicationContext, @@ -1029,7 +1040,7 @@ describe('Case entity', () => { { docketNumber: '123-19', isPaper: true, - status: Case.STATUS_TYPES.generalDocket, + status: CASE_STATUS_TYPES.generalDocket, }, { applicationContext, @@ -1070,7 +1081,7 @@ describe('Case entity', () => { "Docket Number is amended from '123-19B' to '123-19P'", }, ], - status: Case.STATUS_TYPES.generalDocket, + status: CASE_STATUS_TYPES.generalDocket, }, { applicationContext, @@ -1135,7 +1146,7 @@ describe('Case entity', () => { { caseCaption: 'A New Caption', initialCaption: 'Caption', - status: Case.STATUS_TYPES.generalDocket, + status: CASE_STATUS_TYPES.generalDocket, }, { applicationContext, @@ -1187,7 +1198,7 @@ describe('Case entity', () => { }, ], initialCaption: 'Caption', - status: Case.STATUS_TYPES.generalDocket, + status: CASE_STATUS_TYPES.generalDocket, }, { applicationContext, @@ -1217,7 +1228,7 @@ describe('Case entity', () => { assigneeId: '8b4cd447-6278-461b-b62b-d9e357eea62c', assigneeName: 'bob', caseId: 'c6b81f4d-1e47-423a-8caf-6d2fdc3d3859', - caseStatus: Case.STATUS_TYPES.new, + caseStatus: CASE_STATUS_TYPES.new, caseTitle: 'Johnny Joe Jacobson', docketNumber: '101-18', document: {}, @@ -1234,7 +1245,7 @@ describe('Case entity', () => { assigneeId: '8b4cd447-6278-461b-b62b-d9e357eea62c', assigneeName: 'bob', caseId: 'c6b81f4d-1e47-423a-8caf-6d2fdc3d3859', - caseStatus: Case.STATUS_TYPES.new, + caseStatus: CASE_STATUS_TYPES.new, caseTitle: 'Johnny Joe Jacobson', docketNumber: '101-18', document: {}, @@ -1250,13 +1261,13 @@ describe('Case entity', () => { const caseToCheck = new Case( { documents: [], - status: Case.STATUS_TYPES.generalDocket, + status: CASE_STATUS_TYPES.generalDocket, }, { applicationContext, }, ).checkForReadyForTrial(); - expect(caseToCheck.status).toEqual(Case.STATUS_TYPES.generalDocket); + expect(caseToCheck.status).toEqual(CASE_STATUS_TYPES.generalDocket); }); it('should not change the status if an answer document has been filed, but the cutoff has not elapsed', () => { @@ -1268,13 +1279,13 @@ describe('Case entity', () => { eventCode: 'A', }, ], - status: Case.STATUS_TYPES.generalDocket, + status: CASE_STATUS_TYPES.generalDocket, }, { applicationContext, }, ).checkForReadyForTrial(); - expect(caseToCheck.status).toEqual(Case.STATUS_TYPES.generalDocket); + expect(caseToCheck.status).toEqual(CASE_STATUS_TYPES.generalDocket); }); it('should not change the status if a non answer document has been filed before the cutoff', () => { @@ -1288,13 +1299,13 @@ describe('Case entity', () => { eventCode: 'ZZZs', }, ], - status: Case.STATUS_TYPES.generalDocket, + status: CASE_STATUS_TYPES.generalDocket, }, { applicationContext, }, ).checkForReadyForTrial(); - expect(caseToCheck.status).toEqual(Case.STATUS_TYPES.generalDocket); + expect(caseToCheck.status).toEqual(CASE_STATUS_TYPES.generalDocket); }); it("should NOT change the status to 'Ready for Trial' when an answer document has been filed on the cutoff", () => { @@ -1309,15 +1320,12 @@ describe('Case entity', () => { documents: [ { createdAt: prepareDateFromString() - .subtract( - Case.ANSWER_CUTOFF_AMOUNT_IN_DAYS, - Case.ANSWER_CUTOFF_UNIT, - ) + .subtract(ANSWER_CUTOFF_AMOUNT_IN_DAYS, ANSWER_CUTOFF_UNIT) .toISOString(), eventCode: 'A', }, ], - status: Case.STATUS_TYPES.generalDocket, + status: CASE_STATUS_TYPES.generalDocket, }, { applicationContext, @@ -1325,16 +1333,13 @@ describe('Case entity', () => { ).checkForReadyForTrial(); expect(caseToCheck.status).not.toEqual( - Case.STATUS_TYPES.generalDocketReadyForTrial, + CASE_STATUS_TYPES.generalDocketReadyForTrial, ); }); it("should not change the status to 'Ready for Trial' when an answer document has been filed before the cutoff but case is not 'Not at issue'", () => { const createdAt = prepareDateFromString() - .subtract( - Case.ANSWER_CUTOFF_AMOUNT_IN_DAYS + 10, - Case.ANSWER_CUTOFF_UNIT, - ) + .subtract(ANSWER_CUTOFF_AMOUNT_IN_DAYS + 10, ANSWER_CUTOFF_UNIT) .toISOString(); const caseToCheck = new Case( @@ -1345,22 +1350,19 @@ describe('Case entity', () => { eventCode: 'A', }, ], - status: Case.STATUS_TYPES.new, + status: CASE_STATUS_TYPES.new, }, { applicationContext, }, ).checkForReadyForTrial(); - expect(caseToCheck.status).toEqual(Case.STATUS_TYPES.new); + expect(caseToCheck.status).toEqual(CASE_STATUS_TYPES.new); }); it("should change the status to 'Ready for Trial' when an answer document has been filed before the cutoff", () => { const createdAt = prepareDateFromString() - .subtract( - Case.ANSWER_CUTOFF_AMOUNT_IN_DAYS + 10, - Case.ANSWER_CUTOFF_UNIT, - ) + .subtract(ANSWER_CUTOFF_AMOUNT_IN_DAYS + 10, ANSWER_CUTOFF_UNIT) .toISOString(); const caseToCheck = new Case( @@ -1371,7 +1373,7 @@ describe('Case entity', () => { eventCode: 'A', }, ], - status: Case.STATUS_TYPES.generalDocket, + status: CASE_STATUS_TYPES.generalDocket, }, { applicationContext, @@ -1379,7 +1381,7 @@ describe('Case entity', () => { ).checkForReadyForTrial(); expect(caseToCheck.status).toEqual( - Case.STATUS_TYPES.generalDocketReadyForTrial, + CASE_STATUS_TYPES.generalDocketReadyForTrial, ); }); }); @@ -1544,7 +1546,7 @@ describe('Case entity', () => { trialSessionId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', }); expect(myCase.trialSessionId).toBeTruthy(); - expect(myCase.status).toEqual(Case.STATUS_TYPES.calendared); + expect(myCase.status).toEqual(CASE_STATUS_TYPES.calendared); }); it('should set case as calendared with all trial session fields if the trial session is calendared', () => { @@ -1571,7 +1573,7 @@ describe('Case entity', () => { ); myCase.setAsCalendared(trialSession); - expect(myCase.status).toEqual(Case.STATUS_TYPES.calendared); + expect(myCase.status).toEqual(CASE_STATUS_TYPES.calendared); expect(myCase.trialDate).toBeTruthy(); expect(myCase.associatedJudge).toBeTruthy(); expect(myCase.trialLocation).toBeTruthy(); @@ -1603,9 +1605,9 @@ describe('Case entity', () => { ); myCase.setAsCalendared(trialSession); - expect(myCase.status).toEqual(Case.STATUS_TYPES.new); + expect(myCase.status).toEqual(CASE_STATUS_TYPES.new); expect(myCase.trialDate).toBeTruthy(); - expect(myCase.associatedJudge).toEqual(Case.CHIEF_JUDGE); + expect(myCase.associatedJudge).toEqual(CHIEF_JUDGE); expect(myCase.trialLocation).toBeTruthy(); expect(myCase.trialSessionId).toBeTruthy(); expect(myCase.trialTime).toBeTruthy(); @@ -1635,7 +1637,7 @@ describe('Case entity', () => { closedDate: expect.anything(), highPriority: false, highPriorityReason: undefined, - status: Case.STATUS_TYPES.closed, + status: CASE_STATUS_TYPES.closed, }); }); }); @@ -1679,7 +1681,7 @@ describe('Case entity', () => { }); const result = myCase.getPetitionDocument(); expect(result.documentType).toEqual( - Document.INITIAL_DOCUMENT_TYPES.petition.documentType, + INITIAL_DOCUMENT_TYPES.petition.documentType, ); }); }); @@ -1977,7 +1979,7 @@ describe('Case entity', () => { expect(caseToUpdate.automaticBlocked).toEqual(true); expect(caseToUpdate.automaticBlockedReason).toEqual( - Case.AUTOMATIC_BLOCKED_REASONS.pending, + AUTOMATIC_BLOCKED_REASONS.pending, ); expect(caseToUpdate.automaticBlockedDate).toBeDefined(); expect(caseToUpdate.isValid()).toBeTruthy(); @@ -2074,7 +2076,7 @@ describe('Case entity', () => { ); caseToUpdate.setAsCalendared(trialSession); - expect(caseToUpdate.status).toEqual(Case.STATUS_TYPES.calendared); + expect(caseToUpdate.status).toEqual(CASE_STATUS_TYPES.calendared); expect(caseToUpdate.trialDate).toBeTruthy(); expect(caseToUpdate.associatedJudge).toEqual('Judge Buch'); expect(caseToUpdate.trialLocation).toBeTruthy(); @@ -2084,10 +2086,10 @@ describe('Case entity', () => { caseToUpdate.removeFromTrial(); expect(caseToUpdate.status).toEqual( - Case.STATUS_TYPES.generalDocketReadyForTrial, + CASE_STATUS_TYPES.generalDocketReadyForTrial, ); expect(caseToUpdate.trialDate).toBeFalsy(); - expect(caseToUpdate.associatedJudge).toEqual(Case.CHIEF_JUDGE); + expect(caseToUpdate.associatedJudge).toEqual(CHIEF_JUDGE); expect(caseToUpdate.trialLocation).toBeFalsy(); expect(caseToUpdate.trialSessionId).toBeFalsy(); expect(caseToUpdate.trialTime).toBeFalsy(); @@ -2119,7 +2121,7 @@ describe('Case entity', () => { ); caseToUpdate.setAsCalendared(trialSession); - expect(caseToUpdate.status).toEqual(Case.STATUS_TYPES.calendared); + expect(caseToUpdate.status).toEqual(CASE_STATUS_TYPES.calendared); expect(caseToUpdate.trialDate).toBeTruthy(); expect(caseToUpdate.associatedJudge).toEqual('Judge Buch'); expect(caseToUpdate.trialLocation).toBeTruthy(); @@ -2159,7 +2161,7 @@ describe('Case entity', () => { ); caseToUpdate.setAsCalendared(trialSession); - expect(caseToUpdate.status).toEqual(Case.STATUS_TYPES.calendared); + expect(caseToUpdate.status).toEqual(CASE_STATUS_TYPES.calendared); expect(caseToUpdate.trialDate).toBeTruthy(); expect(caseToUpdate.associatedJudge).toEqual('Judge Buch'); expect(caseToUpdate.trialLocation).toBeTruthy(); @@ -2217,10 +2219,10 @@ describe('Case entity', () => { }, ); - updatedCase.setCaseStatus(Case.STATUS_TYPES.generalDocket); + updatedCase.setCaseStatus(CASE_STATUS_TYPES.generalDocket); - expect(updatedCase.status).toEqual(Case.STATUS_TYPES.generalDocket); - expect(updatedCase.associatedJudge).toEqual(Case.CHIEF_JUDGE); + expect(updatedCase.status).toEqual(CASE_STATUS_TYPES.generalDocket); + expect(updatedCase.associatedJudge).toEqual(CHIEF_JUDGE); }); it('should update the case status, leave the associated judge unchanged, and call closeCase if the new status is Closed', () => { @@ -2236,9 +2238,9 @@ describe('Case entity', () => { }, ); - updatedCase.setCaseStatus(Case.STATUS_TYPES.closed); + updatedCase.setCaseStatus(CASE_STATUS_TYPES.closed); - expect(updatedCase.status).toEqual(Case.STATUS_TYPES.closed); + expect(updatedCase.status).toEqual(CASE_STATUS_TYPES.closed); expect(updatedCase.associatedJudge).toEqual('Judge Buch'); expect(closeCaseSpy).toBeCalled(); closeCaseSpy.mockRestore(); @@ -2266,7 +2268,7 @@ describe('Case entity', () => { const contactPrimary = { address1: '123 Main St', city: 'Somewhere', - countryType: ContactFactory.COUNTRY_TYPES.DOMESTIC, + countryType: COUNTRY_TYPES.DOMESTIC, name: 'Test Petitioner', postalCode: '12345', state: 'TN', @@ -2276,7 +2278,7 @@ describe('Case entity', () => { const contactSecondary = { address1: '123 Main St', city: 'Somewhere', - countryType: ContactFactory.COUNTRY_TYPES.DOMESTIC, + countryType: COUNTRY_TYPES.DOMESTIC, name: 'Contact Secondary', postalCode: '12345', state: 'TN', @@ -2302,7 +2304,7 @@ describe('Case entity', () => { contactPrimary, contactSecondary, irsPractitioners, - partyType: ContactFactory.PARTY_TYPES.petitionerSpouse, + partyType: PARTY_TYPES.petitionerSpouse, privatePractitioners, }, { @@ -2326,7 +2328,7 @@ describe('Case entity', () => { contactPrimary, contactSecondary, irsPractitioners, - partyType: ContactFactory.PARTY_TYPES.petitionerSpouse, + partyType: PARTY_TYPES.petitionerSpouse, privatePractitioners, }, { @@ -2870,7 +2872,7 @@ describe('Case entity', () => { const isAssociated = isAssociatedUser({ caseRaw: caseEntity.toRawObject(), user: { - role: User.ROLES.irsSuperuser, + role: ROLES.irsSuperuser, userId: '098d5055-dd90-42af-aec9-056a9843a7e0', }, }); @@ -2889,7 +2891,7 @@ describe('Case entity', () => { const isAssociated = isAssociatedUser({ caseRaw: caseEntity.toRawObject(), user: { - role: User.ROLES.irsSuperuser, + role: ROLES.irsSuperuser, userId: '098d5055-dd90-42af-aec9-056a9843a7e0', }, }); @@ -2903,7 +2905,7 @@ describe('Case entity', () => { const isAssociated = isAssociatedUser({ caseRaw: caseEntity, user: { - role: User.ROLES.irsSuperuser, + role: ROLES.irsSuperuser, userId: '098d5055-dd90-42af-aec9-056a9843a7e0', }, }); diff --git a/shared/src/business/entities/cases/CaseConstants.js b/shared/src/business/entities/cases/CaseConstants.js deleted file mode 100644 index abf4245c6f3..00000000000 --- a/shared/src/business/entities/cases/CaseConstants.js +++ /dev/null @@ -1,13 +0,0 @@ -const SERVICE_INDICATOR_TYPES = { - SI_ELECTRONIC: 'Electronic', - SI_NONE: 'None', - SI_PAPER: 'Paper', -}; - -exports.SERVICE_INDICATOR_TYPES = SERVICE_INDICATOR_TYPES; - -exports.DOCKET_NUMBER_MATCHER = /^(\d{3,5}-\d{2})$/; - -exports.TRIAL_LOCATION_MATCHER = /^[a-zA-Z ]+, [a-zA-Z ]+, [0-9]+$/; - -exports.CHIEF_JUDGE = 'Chief Judge'; diff --git a/shared/src/business/entities/cases/CaseExternal.js b/shared/src/business/entities/cases/CaseExternal.js index 05dca925991..4de10f9f198 100644 --- a/shared/src/business/entities/cases/CaseExternal.js +++ b/shared/src/business/entities/cases/CaseExternal.js @@ -2,11 +2,9 @@ const joi = require('@hapi/joi'); const { joiValidationDecorator, } = require('../../../utilities/JoiValidationDecorator'); -const { - MAX_FILE_SIZE_BYTES, -} = require('../../../persistence/s3/getUploadPolicy'); const { Case } = require('./Case'); const { ContactFactory } = require('../contacts/ContactFactory'); +const { MAX_FILE_SIZE_BYTES } = require('../EntityConstants'); /** * CaseExternal Entity diff --git a/shared/src/business/entities/cases/CaseExternal.test.js b/shared/src/business/entities/cases/CaseExternal.test.js index 004b09a3452..099e541f461 100644 --- a/shared/src/business/entities/cases/CaseExternal.test.js +++ b/shared/src/business/entities/cases/CaseExternal.test.js @@ -1,8 +1,5 @@ -const { - MAX_FILE_SIZE_BYTES, -} = require('../../../persistence/s3/getUploadPolicy'); const { CaseExternal } = require('./CaseExternal'); -const { ContactFactory } = require('../contacts/ContactFactory'); +const { MAX_FILE_SIZE_BYTES, PARTY_TYPES } = require('../EntityConstants'); const { VALIDATION_ERROR_MESSAGES } = CaseExternal; @@ -10,7 +7,7 @@ describe('CaseExternal entity', () => { describe('isValid', () => { it('requires ownership disclosure if filing type is a business', () => { const caseExternal = new CaseExternal({ - businessType: ContactFactory.PARTY_TYPES.corporation, + businessType: PARTY_TYPES.corporation, caseType: 'Other', filingType: 'A business', hasIrsNotice: false, @@ -46,7 +43,7 @@ describe('CaseExternal entity', () => { }); it('requires stinFile', () => { const caseExternal = new CaseExternal({ - businessType: ContactFactory.PARTY_TYPES.corporation, + businessType: PARTY_TYPES.corporation, caseType: 'Other', filingType: 'A business', hasIrsNotice: false, @@ -65,7 +62,7 @@ describe('CaseExternal entity', () => { caseType: 'Other', filingType: 'Myself', hasIrsNotice: true, - partyType: ContactFactory.PARTY_TYPES.nextFriendForMinor, + partyType: PARTY_TYPES.nextFriendForMinor, petitionFile: new File([], 'test.pdf'), petitionFileSize: MAX_FILE_SIZE_BYTES + 5, preferredTrialCity: 'Chattanooga, Tennessee', @@ -81,7 +78,7 @@ describe('CaseExternal entity', () => { caseType: 'Other', filingType: 'Myself', hasIrsNotice: true, - partyType: ContactFactory.PARTY_TYPES.nextFriendForMinor, + partyType: PARTY_TYPES.nextFriendForMinor, petitionFile: {}, petitionFileSize: 0, preferredTrialCity: 'Chattanooga, Tennessee', @@ -97,7 +94,7 @@ describe('CaseExternal entity', () => { caseType: 'Other', filingType: 'Myself', hasIrsNotice: true, - partyType: ContactFactory.PARTY_TYPES.nextFriendForMinor, + partyType: PARTY_TYPES.nextFriendForMinor, preferredTrialCity: 'Chattanooga, Tennessee', procedureType: 'Small', }); @@ -111,7 +108,7 @@ describe('CaseExternal entity', () => { caseType: 'Other', filingType: 'Myself', hasIrsNotice: true, - partyType: ContactFactory.PARTY_TYPES.nextFriendForMinor, + partyType: PARTY_TYPES.nextFriendForMinor, petitionFile: new File([], 'testPetitionFile.pdf'), preferredTrialCity: 'Chattanooga, Tennessee', procedureType: 'Small', @@ -128,7 +125,7 @@ describe('CaseExternal entity', () => { caseType: 'Other', filingType: 'Myself', hasIrsNotice: true, - partyType: ContactFactory.PARTY_TYPES.nextFriendForMinor, + partyType: PARTY_TYPES.nextFriendForMinor, preferredTrialCity: 'Chattanooga, Tennessee', procedureType: 'Small', stinFile: new File([], 'test.pdf'), @@ -144,7 +141,7 @@ describe('CaseExternal entity', () => { caseType: 'Other', filingType: 'Myself', hasIrsNotice: true, - partyType: ContactFactory.PARTY_TYPES.nextFriendForMinor, + partyType: PARTY_TYPES.nextFriendForMinor, preferredTrialCity: 'Chattanooga, Tennessee', procedureType: 'Small', stinFile: new File([], 'test.pdf'), @@ -160,7 +157,7 @@ describe('CaseExternal entity', () => { caseType: 'Other', filingType: 'Myself', hasIrsNotice: true, - partyType: ContactFactory.PARTY_TYPES.nextFriendForMinor, + partyType: PARTY_TYPES.nextFriendForMinor, preferredTrialCity: 'Chattanooga, Tennessee', procedureType: 'Small', }); @@ -174,7 +171,7 @@ describe('CaseExternal entity', () => { caseType: 'Other', filingType: 'Myself', hasIrsNotice: true, - partyType: ContactFactory.PARTY_TYPES.nextFriendForMinor, + partyType: PARTY_TYPES.nextFriendForMinor, preferredTrialCity: 'Chattanooga, Tennessee', procedureType: 'Small', stinFile: new File([], 'testStinFile.pdf'), @@ -193,7 +190,7 @@ describe('CaseExternal entity', () => { hasIrsNotice: true, ownershipDisclosureFile: new File([], 'odsFile.pdf'), ownershipDisclosureFileSize: MAX_FILE_SIZE_BYTES + 5, - partyType: ContactFactory.PARTY_TYPES.nextFriendForMinor, + partyType: PARTY_TYPES.nextFriendForMinor, preferredTrialCity: 'Chattanooga, Tennessee', procedureType: 'Small', }); @@ -211,7 +208,7 @@ describe('CaseExternal entity', () => { hasIrsNotice: true, ownershipDisclosureFile: new File([], 'test.pdf'), ownershipDisclosureFileSize: 0, - partyType: ContactFactory.PARTY_TYPES.nextFriendForMinor, + partyType: PARTY_TYPES.nextFriendForMinor, preferredTrialCity: 'Chattanooga, Tennessee', procedureType: 'Small', }); @@ -225,7 +222,7 @@ describe('CaseExternal entity', () => { caseType: 'Other', filingType: 'Myself', hasIrsNotice: true, - partyType: ContactFactory.PARTY_TYPES.nextFriendForMinor, + partyType: PARTY_TYPES.nextFriendForMinor, preferredTrialCity: 'Chattanooga, Tennessee', procedureType: 'Small', }); @@ -240,7 +237,7 @@ describe('CaseExternal entity', () => { filingType: 'Myself', hasIrsNotice: true, ownershipDisclosureFile: new File([], 'testStinFile.pdf'), - partyType: ContactFactory.PARTY_TYPES.nextFriendForMinor, + partyType: PARTY_TYPES.nextFriendForMinor, preferredTrialCity: 'Chattanooga, Tennessee', procedureType: 'Small', }); diff --git a/shared/src/business/entities/cases/CaseExternalForCorporationContacts.test.js b/shared/src/business/entities/cases/CaseExternalForCorporationContacts.test.js index f926048b2da..d5526e2cc22 100644 --- a/shared/src/business/entities/cases/CaseExternalForCorporationContacts.test.js +++ b/shared/src/business/entities/cases/CaseExternalForCorporationContacts.test.js @@ -1,5 +1,5 @@ const { CaseExternal } = require('./CaseExternal'); -const { ContactFactory } = require('../contacts/ContactFactory'); +const { PARTY_TYPES } = require('../EntityConstants'); describe('CaseExternal', () => { describe('for Corporation Contacts', () => { @@ -9,7 +9,7 @@ describe('CaseExternal', () => { filingType: 'Myself', hasIrsNotice: true, irsNoticeDate: '2009-10-13', - partyType: ContactFactory.PARTY_TYPES.corporation, + partyType: PARTY_TYPES.corporation, petitionFile: {}, petitionFileSize: 1, preferredTrialCity: 'Chattanooga, Tennessee', @@ -38,7 +38,7 @@ describe('CaseExternal', () => { filingType: 'Myself', hasIrsNotice: true, irsNoticeDate: '2009-10-13', - partyType: ContactFactory.PARTY_TYPES.corporation, + partyType: PARTY_TYPES.corporation, petitionFile: {}, petitionFileSize: 1, preferredTrialCity: 'Chattanooga, Tennessee', @@ -66,7 +66,7 @@ describe('CaseExternal', () => { filingType: 'Myself', hasIrsNotice: true, irsNoticeDate: '2009-10-13', - partyType: ContactFactory.PARTY_TYPES.corporation, + partyType: PARTY_TYPES.corporation, petitionFile: {}, petitionFileSize: 1, preferredTrialCity: 'Chattanooga, Tennessee', diff --git a/shared/src/business/entities/cases/CaseExternalForEstateWithoutExecutorContacts.test.js b/shared/src/business/entities/cases/CaseExternalForEstateWithoutExecutorContacts.test.js index aed0ca0512d..d34b949273a 100644 --- a/shared/src/business/entities/cases/CaseExternalForEstateWithoutExecutorContacts.test.js +++ b/shared/src/business/entities/cases/CaseExternalForEstateWithoutExecutorContacts.test.js @@ -1,5 +1,5 @@ const { CaseExternal } = require('./CaseExternal'); -const { ContactFactory } = require('../contacts/ContactFactory'); +const { PARTY_TYPES } = require('../EntityConstants'); describe('CaseExternal', () => { describe('for Estate without an Executor/Personal Representative/Fiduciary/etc. Contacts', () => { @@ -9,7 +9,7 @@ describe('CaseExternal', () => { filingType: 'Myself', hasIrsNotice: true, irsNoticeDate: '2009-10-13', - partyType: ContactFactory.PARTY_TYPES.estateWithoutExecutor, + partyType: PARTY_TYPES.estateWithoutExecutor, petitionFile: {}, petitionFileSize: 1, preferredTrialCity: 'Chattanooga, Tennessee', @@ -38,7 +38,7 @@ describe('CaseExternal', () => { filingType: 'Myself', hasIrsNotice: true, irsNoticeDate: '2009-10-13', - partyType: ContactFactory.PARTY_TYPES.estateWithoutExecutor, + partyType: PARTY_TYPES.estateWithoutExecutor, petitionFile: {}, petitionFileSize: 1, preferredTrialCity: 'Chattanooga, Tennessee', @@ -68,7 +68,7 @@ describe('CaseExternal', () => { filingType: 'Myself', hasIrsNotice: true, irsNoticeDate: '2009-10-13', - partyType: ContactFactory.PARTY_TYPES.estateWithoutExecutor, + partyType: PARTY_TYPES.estateWithoutExecutor, petitionFile: {}, petitionFileSize: 1, preferredTrialCity: 'Chattanooga, Tennessee', diff --git a/shared/src/business/entities/cases/CaseExternalForInternationalContacts.test.js b/shared/src/business/entities/cases/CaseExternalForInternationalContacts.test.js index 4b0b3ed2b3d..f6b5a25989b 100644 --- a/shared/src/business/entities/cases/CaseExternalForInternationalContacts.test.js +++ b/shared/src/business/entities/cases/CaseExternalForInternationalContacts.test.js @@ -1,5 +1,6 @@ const { CaseExternal } = require('./CaseExternal'); const { ContactFactory } = require('../contacts/ContactFactory'); +const { PARTY_TYPES } = require('../EntityConstants'); const contactErrorMessages = ContactFactory.INTERNATIONAL_VALIDATION_ERROR_MESSAGES; @@ -22,7 +23,7 @@ describe('CaseExternal', () => { filingType: 'Myself', hasIrsNotice: true, irsNoticeDate: '2009-10-13', - partyType: ContactFactory.PARTY_TYPES.petitioner, + partyType: PARTY_TYPES.petitioner, petitionFile: {}, petitionFileSize: 1, preferredTrialCity: 'Chattanooga, Tennessee', @@ -53,7 +54,7 @@ describe('CaseExternal', () => { filingType: 'Myself', hasIrsNotice: true, irsNoticeDate: '2009-10-13', - partyType: ContactFactory.PARTY_TYPES.petitioner, + partyType: PARTY_TYPES.petitioner, petitionFile: {}, petitionFileSize: 1, preferredTrialCity: 'Chattanooga, Tennessee', diff --git a/shared/src/business/entities/cases/CaseExternalForMinorWithoutGuardianContacts.test.js b/shared/src/business/entities/cases/CaseExternalForMinorWithoutGuardianContacts.test.js index 66f62959be7..b68d650afe9 100644 --- a/shared/src/business/entities/cases/CaseExternalForMinorWithoutGuardianContacts.test.js +++ b/shared/src/business/entities/cases/CaseExternalForMinorWithoutGuardianContacts.test.js @@ -1,5 +1,5 @@ const { CaseExternal } = require('./CaseExternal'); -const { ContactFactory } = require('../contacts/ContactFactory'); +const { PARTY_TYPES } = require('../EntityConstants'); describe('CaseExternal', () => { describe('for Minor without Guardian Contacts', () => { @@ -9,7 +9,7 @@ describe('CaseExternal', () => { filingType: 'Myself', hasIrsNotice: true, irsNoticeDate: '2009-10-13', - partyType: ContactFactory.PARTY_TYPES.nextFriendForMinor, + partyType: PARTY_TYPES.nextFriendForMinor, petitionFile: {}, petitionFileSize: 1, preferredTrialCity: 'Chattanooga, Tennessee', @@ -39,7 +39,7 @@ describe('CaseExternal', () => { filingType: 'Myself', hasIrsNotice: true, irsNoticeDate: '2009-10-13', - partyType: ContactFactory.PARTY_TYPES.nextFriendForMinor, + partyType: PARTY_TYPES.nextFriendForMinor, petitionFile: {}, petitionFileSize: 1, preferredTrialCity: 'Chattanooga, Tennessee', diff --git a/shared/src/business/entities/cases/CaseExternalForPartnershipTaxMattersPartnerContacts.test.js b/shared/src/business/entities/cases/CaseExternalForPartnershipTaxMattersPartnerContacts.test.js index 1bc7a871594..f8adf764cb6 100644 --- a/shared/src/business/entities/cases/CaseExternalForPartnershipTaxMattersPartnerContacts.test.js +++ b/shared/src/business/entities/cases/CaseExternalForPartnershipTaxMattersPartnerContacts.test.js @@ -1,5 +1,5 @@ const { CaseExternal } = require('./CaseExternal'); -const { ContactFactory } = require('../contacts/ContactFactory'); +const { PARTY_TYPES } = require('../EntityConstants'); describe('CaseExternal', () => { describe('for Partnership (as the Tax Matters Partner) Contacts', () => { @@ -9,7 +9,7 @@ describe('CaseExternal', () => { filingType: 'Myself', hasIrsNotice: true, irsNoticeDate: '2009-10-13', - partyType: ContactFactory.PARTY_TYPES.partnershipAsTaxMattersPartner, + partyType: PARTY_TYPES.partnershipAsTaxMattersPartner, petitionFile: {}, petitionFileSize: 1, preferredTrialCity: 'Chattanooga, Tennessee', @@ -39,7 +39,7 @@ describe('CaseExternal', () => { filingType: 'Myself', hasIrsNotice: true, irsNoticeDate: '2009-10-13', - partyType: ContactFactory.PARTY_TYPES.partnershipAsTaxMattersPartner, + partyType: PARTY_TYPES.partnershipAsTaxMattersPartner, petitionFile: {}, petitionFileSize: 1, preferredTrialCity: 'Chattanooga, Tennessee', diff --git a/shared/src/business/entities/cases/CaseExternalForPetitionerAndDeceasedSpouseContacts.test.js b/shared/src/business/entities/cases/CaseExternalForPetitionerAndDeceasedSpouseContacts.test.js index 04656c13c21..dce71470cf0 100644 --- a/shared/src/business/entities/cases/CaseExternalForPetitionerAndDeceasedSpouseContacts.test.js +++ b/shared/src/business/entities/cases/CaseExternalForPetitionerAndDeceasedSpouseContacts.test.js @@ -1,5 +1,5 @@ const { CaseExternal } = require('./CaseExternal'); -const { ContactFactory } = require('../contacts/ContactFactory'); +const { PARTY_TYPES } = require('../EntityConstants'); describe('CaseExternal', () => { describe('for Petitioner And Deceased Spouse Contacts', () => { @@ -9,7 +9,7 @@ describe('CaseExternal', () => { filingType: 'Myself', hasIrsNotice: true, irsNoticeDate: '2009-10-13', - partyType: ContactFactory.PARTY_TYPES.petitionerDeceasedSpouse, + partyType: PARTY_TYPES.petitionerDeceasedSpouse, petitionFile: {}, petitionFileSize: 1, preferredTrialCity: 'Chattanooga, Tennessee', @@ -47,7 +47,7 @@ describe('CaseExternal', () => { filingType: 'Myself', hasIrsNotice: true, irsNoticeDate: '2009-10-13', - partyType: ContactFactory.PARTY_TYPES.petitionerDeceasedSpouse, + partyType: PARTY_TYPES.petitionerDeceasedSpouse, petitionFile: {}, petitionFileSize: 1, preferredTrialCity: 'Chattanooga, Tennessee', diff --git a/shared/src/business/entities/cases/CaseExternalForPetitionerAndSpouseContacts.test.js b/shared/src/business/entities/cases/CaseExternalForPetitionerAndSpouseContacts.test.js index 85d830afb6a..2943d5a7767 100644 --- a/shared/src/business/entities/cases/CaseExternalForPetitionerAndSpouseContacts.test.js +++ b/shared/src/business/entities/cases/CaseExternalForPetitionerAndSpouseContacts.test.js @@ -1,5 +1,5 @@ const { CaseExternal } = require('./CaseExternal'); -const { ContactFactory } = require('../contacts/ContactFactory'); +const { PARTY_TYPES } = require('../EntityConstants'); describe('CaseExternal', () => { describe('for Petitioner And Spouse Contacts', () => { @@ -9,7 +9,7 @@ describe('CaseExternal', () => { filingType: 'Myself', hasIrsNotice: true, irsNoticeDate: '2009-10-13', - partyType: ContactFactory.PARTY_TYPES.petitionerSpouse, + partyType: PARTY_TYPES.petitionerSpouse, petitionFile: {}, petitionFileSize: 1, preferredTrialCity: 'Chattanooga, Tennessee', @@ -48,7 +48,7 @@ describe('CaseExternal', () => { filingType: 'Myself', hasIrsNotice: true, irsNoticeDate: '2009-10-13', - partyType: ContactFactory.PARTY_TYPES.petitionerSpouse, + partyType: PARTY_TYPES.petitionerSpouse, petitionFile: {}, petitionFileSize: 1, preferredTrialCity: 'Chattanooga, Tennessee', diff --git a/shared/src/business/entities/cases/CaseExternalIncomplete.test.js b/shared/src/business/entities/cases/CaseExternalIncomplete.test.js index 82cba162f6e..7d3110053de 100644 --- a/shared/src/business/entities/cases/CaseExternalIncomplete.test.js +++ b/shared/src/business/entities/cases/CaseExternalIncomplete.test.js @@ -1,5 +1,5 @@ const { CaseExternalIncomplete } = require('./CaseExternalIncomplete'); -const { ContactFactory } = require('../contacts/ContactFactory'); +const { PARTY_TYPES } = require('../EntityConstants'); describe('CaseExternalIncomplete entity', () => { describe('isValid', () => { @@ -22,7 +22,7 @@ describe('CaseExternalIncomplete entity', () => { filingType: 'Myself', hasIrsNotice: false, irsNoticeDate: null, - partyType: ContactFactory.PARTY_TYPES.petitioner, + partyType: PARTY_TYPES.petitioner, petitionFileId: '102e29fa-bb8c-43ff-b18f-ddce9089dd80', preferredTrialCity: 'Chattanooga, Tennessee', procedureType: 'Small', diff --git a/shared/src/business/entities/cases/CaseExternalInformationFactory.test.js b/shared/src/business/entities/cases/CaseExternalInformationFactory.test.js index d5b5e230207..dc311509550 100644 --- a/shared/src/business/entities/cases/CaseExternalInformationFactory.test.js +++ b/shared/src/business/entities/cases/CaseExternalInformationFactory.test.js @@ -1,10 +1,8 @@ const { CaseExternalInformationFactory, } = require('./CaseExternalInformationFactory'); -const { - MAX_FILE_SIZE_BYTES, -} = require('../../../persistence/s3/getUploadPolicy'); const { ContactFactory } = require('../contacts/ContactFactory'); +const { MAX_FILE_SIZE_BYTES, PARTY_TYPES } = require('../EntityConstants'); const caseExternalErrorMessages = CaseExternalInformationFactory.VALIDATION_ERROR_MESSAGES; @@ -150,7 +148,7 @@ describe('CaseExternalInformationFactory entity', () => { name: 'Something', }, hasIrsNotice: true, - partyType: ContactFactory.PARTY_TYPES.petitioner, + partyType: PARTY_TYPES.petitioner, petitionFile: new File([], 'test.pdf'), petitionFileSize: 1, stinFile: new File([], 'test.pdf'), @@ -261,7 +259,7 @@ describe('CaseExternalInformationFactory entity', () => { caseType: 'Deficiency', filingType: 'A business', hasIrsNotice: true, - partyType: ContactFactory.PARTY_TYPES.corporation, + partyType: PARTY_TYPES.corporation, petitionFile: new File([], 'test.pdf'), petitionFileSize: 1, stinFile: new File([], 'test.pdf'), @@ -278,7 +276,7 @@ describe('CaseExternalInformationFactory entity', () => { caseType: 'Deficiency', filingType: 'something else', hasIrsNotice: true, - partyType: ContactFactory.PARTY_TYPES.corporation, + partyType: PARTY_TYPES.corporation, petitionFile: new File([], 'test.pdf'), petitionFileSize: 1, stinFile: new File([], 'test.pdf'), @@ -295,7 +293,7 @@ describe('CaseExternalInformationFactory entity', () => { caseType: 'Deficiency', filingType: 'Myself', hasIrsNotice: true, - partyType: ContactFactory.PARTY_TYPES.petitioner, + partyType: PARTY_TYPES.petitioner, petitionFile: new File([], 'test.pdf'), petitionFileSize: 1, stinFile: new File([], 'test.pdf'), @@ -320,7 +318,7 @@ describe('CaseExternalInformationFactory entity', () => { caseType: 'Deficiency', filingType: 'Myself', hasIrsNotice: true, - partyType: ContactFactory.PARTY_TYPES.petitionerSpouse, + partyType: PARTY_TYPES.petitionerSpouse, petitionFile: new File([], 'test.pdf'), petitionFileSize: 1, stinFile: new File([], 'test.pdf'), @@ -403,7 +401,7 @@ describe('CaseExternalInformationFactory entity', () => { caseExternal = new CaseExternalInformationFactory({ filingType: 'Myself', hasIrsNotice: true, - partyType: ContactFactory.PARTY_TYPES.petitionerSpouse, + partyType: PARTY_TYPES.petitionerSpouse, petitionFile: new File([], 'test.pdf'), stinFile: new File([], 'test.pdf'), wizardStep: '4', @@ -458,7 +456,7 @@ describe('CaseExternalInformationFactory entity', () => { }, filingType: 'Myself', hasIrsNotice: true, - partyType: ContactFactory.PARTY_TYPES.petitionerSpouse, + partyType: PARTY_TYPES.petitionerSpouse, petitionFile: new File([], 'test.pdf'), petitionFileSize: 1, preferredTrialCity: 'Boise, Idaho', diff --git a/shared/src/business/entities/cases/CaseInternal.js b/shared/src/business/entities/cases/CaseInternal.js index fb5c5ab9c9d..fb4fb277901 100644 --- a/shared/src/business/entities/cases/CaseInternal.js +++ b/shared/src/business/entities/cases/CaseInternal.js @@ -1,17 +1,20 @@ const joi = require('@hapi/joi'); +const { + DEFAULT_PROCEDURE_TYPE, + MAX_FILE_SIZE_BYTES, + PARTY_TYPES, + PAYMENT_STATUS, +} = require('../EntityConstants'); const { joiValidationDecorator, } = require('../../../utilities/JoiValidationDecorator'); -const { - MAX_FILE_SIZE_BYTES, -} = require('../../../persistence/s3/getUploadPolicy'); const { Case } = require('./Case'); const { ContactFactory } = require('../contacts/ContactFactory'); const { getTimestampSchema } = require('../../../utilities/dateSchema'); const { Statistic } = require('../Statistic'); const joiStrictTimestamp = getTimestampSchema(); -CaseInternal.DEFAULT_PROCEDURE_TYPE = Case.PROCEDURE_TYPES[0]; +CaseInternal.DEFAULT_PROCEDURE_TYPE = DEFAULT_PROCEDURE_TYPE; /** * CaseInternal Entity @@ -110,7 +113,7 @@ const paperRequirements = joi .object() .keys({ applicationForWaiverOfFilingFeeFile: joi.when('petitionPaymentStatus', { - is: Case.PAYMENT_STATUS.WAIVED, + is: PAYMENT_STATUS.WAIVED, otherwise: joi.optional().allow(null), then: joi.object().required(), }), @@ -125,26 +128,26 @@ const paperRequirements = joi caseCaption: joi.string().required(), caseType: joi.string().required(), hasVerifiedIrsNotice: joi.boolean().required(), - irsNoticeDate: Case.validationRules.irsNoticeDate, + irsNoticeDate: Case.VALIDATION_RULES.irsNoticeDate, mailingDate: joi.string().max(25).required(), - noticeOfAttachments: Case.validationRules.noticeOfAttachments, + noticeOfAttachments: Case.VALIDATION_RULES.noticeOfAttachments, orderDesignatingPlaceOfTrial: - Case.validationRules.orderDesignatingPlaceOfTrial, - orderForAmendedPetition: Case.validationRules.orderForAmendedPetition, + Case.VALIDATION_RULES.orderDesignatingPlaceOfTrial, + orderForAmendedPetition: Case.VALIDATION_RULES.orderForAmendedPetition, orderForAmendedPetitionAndFilingFee: - Case.validationRules.orderForAmendedPetitionAndFilingFee, - orderForFilingFee: Case.validationRules.orderForFilingFee, - orderForOds: Case.validationRules.orderForOds, - orderForRatification: Case.validationRules.orderForRatification, - orderToShowCause: Case.validationRules.orderToShowCause, + Case.VALIDATION_RULES.orderForAmendedPetitionAndFilingFee, + orderForFilingFee: Case.VALIDATION_RULES.orderForFilingFee, + orderForOds: Case.VALIDATION_RULES.orderForOds, + orderForRatification: Case.VALIDATION_RULES.orderForRatification, + orderToShowCause: Case.VALIDATION_RULES.orderToShowCause, ownershipDisclosureFile: joi.when('partyType', { is: joi .exist() .valid( - ContactFactory.PARTY_TYPES.corporation, - ContactFactory.PARTY_TYPES.partnershipAsTaxMattersPartner, - ContactFactory.PARTY_TYPES.partnershipBBA, - ContactFactory.PARTY_TYPES.partnershipOtherThanTaxMatters, + PARTY_TYPES.corporation, + PARTY_TYPES.partnershipAsTaxMattersPartner, + PARTY_TYPES.partnershipBBA, + PARTY_TYPES.partnershipOtherThanTaxMatters, ), otherwise: joi.optional().allow(null), then: joi.when('orderForOds', { @@ -166,13 +169,13 @@ const paperRequirements = joi then: joi.number().required().min(1).max(MAX_FILE_SIZE_BYTES).integer(), }), petitionPaymentDate: joi.when('petitionPaymentStatus', { - is: Case.PAYMENT_STATUS.PAID, + is: PAYMENT_STATUS.PAID, otherwise: joiStrictTimestamp.optional().allow(null), then: joiStrictTimestamp.max('now').required(), }), - petitionPaymentMethod: Case.validationRules.petitionPaymentMethod, - petitionPaymentStatus: Case.validationRules.petitionPaymentStatus, - petitionPaymentWaivedDate: Case.validationRules.petitionPaymentWaivedDate, + petitionPaymentMethod: Case.VALIDATION_RULES.petitionPaymentMethod, + petitionPaymentStatus: Case.VALIDATION_RULES.petitionPaymentStatus, + petitionPaymentWaivedDate: Case.VALIDATION_RULES.petitionPaymentWaivedDate, preferredTrialCity: joi .alternatives() .conditional('requestForPlaceOfTrialFile', { @@ -194,14 +197,14 @@ const paperRequirements = joi otherwise: joi.optional().allow(null), then: joi.number().required().min(1).max(MAX_FILE_SIZE_BYTES).integer(), }), - statistics: Case.validationRules.statistics, + statistics: Case.VALIDATION_RULES.statistics, stinFile: joi.object().optional(), stinFileSize: joi.when('stinFile', { is: joi.exist().not(null), otherwise: joi.optional().allow(null), then: joi.number().required().min(1).max(MAX_FILE_SIZE_BYTES).integer(), }), - useSameAsPrimary: Case.validationRules.useSameAsPrimary, + useSameAsPrimary: Case.VALIDATION_RULES.useSameAsPrimary, }) .or( 'preferredTrialCity', diff --git a/shared/src/business/entities/cases/CaseInternal.test.js b/shared/src/business/entities/cases/CaseInternal.test.js index ccec0e52dfa..129cc4a19db 100644 --- a/shared/src/business/entities/cases/CaseInternal.test.js +++ b/shared/src/business/entities/cases/CaseInternal.test.js @@ -1,9 +1,9 @@ const { applicationContext, } = require('../../test/createTestApplicationContext'); -const { Case } = require('./Case'); const { CaseInternal } = require('./CaseInternal'); -const { ContactFactory } = require('../contacts/ContactFactory'); +const { PARTY_TYPES } = require('../EntityConstants'); +const { PAYMENT_STATUS } = require('../EntityConstants'); const { VALIDATION_ERROR_MESSAGES } = CaseInternal; @@ -41,10 +41,10 @@ describe('CaseInternal entity', () => { state: 'AK', }, mailingDate: 'test', - partyType: ContactFactory.PARTY_TYPES.petitioner, + partyType: PARTY_TYPES.petitioner, petitionFile: { anObject: true }, petitionFileSize: 1, - petitionPaymentStatus: Case.PAYMENT_STATUS.UNPAID, + petitionPaymentStatus: PAYMENT_STATUS.UNPAID, preferredTrialCity: 'Boise, Idaho', procedureType: 'Small', receivedAt: new Date().toISOString(), @@ -86,10 +86,10 @@ describe('CaseInternal entity', () => { orderDesignatingPlaceOfTrial: true, ownershipDisclosureFile: { anObject: true }, ownershipDisclosureFileSize: 1, - partyType: ContactFactory.PARTY_TYPES.corporation, + partyType: PARTY_TYPES.corporation, petitionFile: { anObject: true }, petitionFileSize: 1, - petitionPaymentStatus: Case.PAYMENT_STATUS.UNPAID, + petitionPaymentStatus: PAYMENT_STATUS.UNPAID, procedureType: 'Small', receivedAt: new Date().toISOString(), }, @@ -119,10 +119,10 @@ describe('CaseInternal entity', () => { mailingDate: 'test', orderDesignatingPlaceOfTrial: true, orderForOds: true, - partyType: ContactFactory.PARTY_TYPES.corporation, + partyType: PARTY_TYPES.corporation, petitionFile: { anObject: true }, petitionFileSize: 1, - petitionPaymentStatus: Case.PAYMENT_STATUS.UNPAID, + petitionPaymentStatus: PAYMENT_STATUS.UNPAID, procedureType: 'Small', receivedAt: new Date().toISOString(), }, @@ -164,7 +164,7 @@ describe('CaseInternal entity', () => { const caseInternal = new CaseInternal( { caseCaption: 'Dr. Leo Marvin, Petitioner', - petitionPaymentStatus: Case.PAYMENT_STATUS.WAIVED, + petitionPaymentStatus: PAYMENT_STATUS.WAIVED, receivedAt: new Date().toISOString(), }, { applicationContext }, @@ -179,7 +179,7 @@ describe('CaseInternal entity', () => { it('fails validation if partyType is Corporation and orderForOds is undefined', () => { const caseInternal = new CaseInternal( { - partyType: ContactFactory.PARTY_TYPES.corporation, + partyType: PARTY_TYPES.corporation, }, { applicationContext }, ); @@ -193,7 +193,7 @@ describe('CaseInternal entity', () => { const caseInternal = new CaseInternal( { orderForOds: false, - partyType: ContactFactory.PARTY_TYPES.partnershipAsTaxMattersPartner, + partyType: PARTY_TYPES.partnershipAsTaxMattersPartner, }, { applicationContext }, ); @@ -317,10 +317,10 @@ describe('CaseInternal entity', () => { mailingDate: 'test', ownershipDisclosureFile: { anObject: true }, ownershipDisclosureFileSize: 1, - partyType: ContactFactory.PARTY_TYPES.corporation, + partyType: PARTY_TYPES.corporation, petitionFile: { anObject: true }, petitionFileSize: 1, - petitionPaymentStatus: Case.PAYMENT_STATUS.UNPAID, + petitionPaymentStatus: PAYMENT_STATUS.UNPAID, procedureType: 'Small', receivedAt: new Date().toISOString(), stinFile: { anObject: true }, @@ -355,10 +355,10 @@ describe('CaseInternal entity', () => { orderDesignatingPlaceOfTrial: false, ownershipDisclosureFile: { anObject: true }, ownershipDisclosureFileSize: 1, - partyType: ContactFactory.PARTY_TYPES.corporation, + partyType: PARTY_TYPES.corporation, petitionFile: { anObject: true }, petitionFileSize: 1, - petitionPaymentStatus: Case.PAYMENT_STATUS.UNPAID, + petitionPaymentStatus: PAYMENT_STATUS.UNPAID, procedureType: 'Small', receivedAt: new Date().toISOString(), stinFile: { anObject: true }, diff --git a/shared/src/business/entities/cases/CaseSearch.js b/shared/src/business/entities/cases/CaseSearch.js index 3a0fbc382f8..42185074c8b 100644 --- a/shared/src/business/entities/cases/CaseSearch.js +++ b/shared/src/business/entities/cases/CaseSearch.js @@ -2,9 +2,7 @@ const joi = require('@hapi/joi'); const { joiValidationDecorator, } = require('../../../utilities/JoiValidationDecorator'); - -CaseSearch.CASE_SEARCH_MIN_YEAR = 1986; -CaseSearch.CASE_SEARCH_PAGE_SIZE = 5; +const { CASE_SEARCH_MIN_YEAR } = require('../EntityConstants'); CaseSearch.validationName = 'CaseSearch'; @@ -16,7 +14,7 @@ CaseSearch.validationName = 'CaseSearch'; */ function CaseSearch(rawProps) { this.petitionerName = rawProps.petitionerName; - this.yearFiledMin = rawProps.yearFiledMin || CaseSearch.CASE_SEARCH_MIN_YEAR; + this.yearFiledMin = rawProps.yearFiledMin || CASE_SEARCH_MIN_YEAR; this.yearFiledMax = rawProps.yearFiledMax || undefined; this.petitionerState = rawProps.petitionerState || undefined; this.countryType = rawProps.countryType || undefined; diff --git a/shared/src/business/entities/cases/CaseSearch.test.js b/shared/src/business/entities/cases/CaseSearch.test.js index 66efcb86a3c..13f244518d7 100644 --- a/shared/src/business/entities/cases/CaseSearch.test.js +++ b/shared/src/business/entities/cases/CaseSearch.test.js @@ -1,7 +1,7 @@ +const { CASE_SEARCH_MIN_YEAR } = require('../EntityConstants'); const { CaseSearch } = require('./CaseSearch'); const errorMessages = CaseSearch.VALIDATION_ERROR_MESSAGES; -const minYear = CaseSearch.CASE_SEARCH_MIN_YEAR; describe('Case Search entity', () => { it('needs only a petitioner name to be valid', () => { @@ -11,7 +11,7 @@ describe('Case Search entity', () => { petitionerName: 'Solomon Grundy', petitionerState: undefined, yearFiledMax: undefined, - yearFiledMin: minYear, + yearFiledMin: CASE_SEARCH_MIN_YEAR, }); const validationErrors = caseSearch.getFormattedValidationErrors(); expect(validationErrors).toEqual(null); diff --git a/shared/src/business/entities/cases/PublicCase.js b/shared/src/business/entities/cases/PublicCase.js index 5712fb48691..8966c7536ca 100644 --- a/shared/src/business/entities/cases/PublicCase.js +++ b/shared/src/business/entities/cases/PublicCase.js @@ -1,12 +1,15 @@ const joi = require('@hapi/joi'); +const { + COURT_ISSUED_EVENT_CODES, + ORDER_TYPES, + TRANSCRIPT_EVENT_CODE, +} = require('../EntityConstants'); const { joiValidationDecorator, } = require('../../../utilities/JoiValidationDecorator'); const { compareStrings } = require('../../utilities/sortFunctions'); -const { Document } = require('../Document'); const { getTimestampSchema } = require('../../../utilities/dateSchema'); const { map } = require('lodash'); -const { Order } = require('../orders/Order'); const { PublicContact } = require('./PublicContact'); const { PublicDocketRecordEntry } = require('./PublicDocketRecordEntry'); const { PublicDocument } = require('./PublicDocument'); @@ -26,7 +29,9 @@ function PublicCase(rawCase, { applicationContext }) { this.createdAt = rawCase.createdAt; this.docketNumber = rawCase.docketNumber; this.docketNumberSuffix = rawCase.docketNumberSuffix; - this.docketNumberWithSuffix = rawCase.docketNumberWithSuffix; + this.docketNumberWithSuffix = + rawCase.docketNumberWithSuffix || + `${this.docketNumber}${this.docketNumberSuffix || ''}`; this.receivedAt = rawCase.receivedAt; this.isSealed = !!rawCase.sealedDate; @@ -86,9 +91,9 @@ joiValidationDecorator( ); const isDraftDocument = function (document, docketRecord) { - const orderDocumentTypes = map(Order.ORDER_TYPES, 'documentType'); + const orderDocumentTypes = map(ORDER_TYPES, 'documentType'); const courtIssuedDocumentTypes = map( - Document.COURT_ISSUED_EVENT_CODES, + COURT_ISSUED_EVENT_CODES, 'documentType', ); @@ -108,14 +113,14 @@ const isDraftDocument = function (document, docketRecord) { }; const isPrivateDocument = function (document, docketRecord) { - const orderDocumentTypes = map(Order.ORDER_TYPES, 'documentType'); + const orderDocumentTypes = map(ORDER_TYPES, 'documentType'); const courtIssuedDocumentTypes = map( - Document.COURT_ISSUED_EVENT_CODES, + COURT_ISSUED_EVENT_CODES, 'documentType', ); const isStipDecision = document.documentType === 'Stipulated Decision'; - const isTranscript = document.eventCode === Document.TRANSCRIPT_EVENT_CODE; + const isTranscript = document.eventCode === TRANSCRIPT_EVENT_CODE; const isOrder = orderDocumentTypes.includes(document.documentType); const isCourtIssuedDocument = courtIssuedDocumentTypes.includes( document.documentType, diff --git a/shared/src/business/entities/cases/PublicCase.test.js b/shared/src/business/entities/cases/PublicCase.test.js index b063dc53011..ca1e1e06378 100644 --- a/shared/src/business/entities/cases/PublicCase.test.js +++ b/shared/src/business/entities/cases/PublicCase.test.js @@ -87,6 +87,7 @@ describe('PublicCase', () => { createdAt: 'testing', docketNumber: 'testing', docketNumberSuffix: 'testing', + docketNumberWithSuffix: 'testingtesting', docketRecord: [], documents: [], isSealed: false, @@ -119,6 +120,7 @@ describe('PublicCase', () => { createdAt: 'testing', docketNumber: 'testing', docketNumberSuffix: 'testing', + docketNumberWithSuffix: 'testingtesting', docketRecord: [], documents: [], isSealed: false, @@ -159,6 +161,7 @@ describe('PublicCase', () => { createdAt: 'testing', docketNumber: 'testing', docketNumberSuffix: 'testing', + docketNumberWithSuffix: 'testingtesting', docketRecord: [ { description: undefined, @@ -332,4 +335,44 @@ describe('PublicCase', () => { expect(isPrivate).toEqual(true); }); }); + + it('should compute docketNumberWithSuffix if it is not provided', () => { + const entity = new PublicCase( + { + caseCaption: 'testing', + caseId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', + contactPrimary: {}, + contactSecondary: {}, + createdAt: '2020-01-02T03:30:45.007Z', + docketNumber: '102-20', + docketNumberSuffix: 'SL', + docketNumberWithSuffix: null, + docketRecord: [{}], + documents: [{}], + receivedAt: '2020-01-05T03:30:45.007Z', + }, + {}, + ); + expect(entity.docketNumberWithSuffix).toBe('102-20SL'); + }); + + it('should compute docketNumberWithSuffix with just docketNumber if there is no suffix', () => { + const entity = new PublicCase( + { + caseCaption: 'testing', + caseId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', + contactPrimary: {}, + contactSecondary: {}, + createdAt: '2020-01-02T03:30:45.007Z', + docketNumber: '102-20', + docketNumberSuffix: null, + docketNumberWithSuffix: null, + docketRecord: [{}], + documents: [{}], + receivedAt: '2020-01-05T03:30:45.007Z', + }, + {}, + ); + expect(entity.docketNumberWithSuffix).toBe('102-20'); + }); }); diff --git a/shared/src/business/entities/contacts/ContactFactory.js b/shared/src/business/entities/contacts/ContactFactory.js index cbe384ddd9b..ef59bff24bf 100644 --- a/shared/src/business/entities/contacts/ContactFactory.js +++ b/shared/src/business/entities/contacts/ContactFactory.js @@ -1,122 +1,17 @@ const joi = require('@hapi/joi'); - +const { + COUNTRY_TYPES, + PARTY_TYPES, + SERVICE_INDICATOR_TYPES, +} = require('../EntityConstants'); const { JoiValidationConstants, } = require('../../../utilities/JoiValidationConstants'); const { joiValidationDecorator, } = require('../../../utilities/JoiValidationDecorator'); -const { SERVICE_INDICATOR_TYPES } = require('../cases/CaseConstants'); -const ContactFactory = {}; - -ContactFactory.COUNTRY_TYPES = { - DOMESTIC: 'domestic', - INTERNATIONAL: 'international', -}; - -ContactFactory.US_STATES = { - AK: 'Alaska', - AL: 'Alabama', - AR: 'Arkansas', - AZ: 'Arizona', - CA: 'California', - CO: 'Colorado', - CT: 'Connecticut', - DC: 'District of Columbia', - DE: 'Delaware', - FL: 'Florida', - GA: 'Georgia', - HI: 'Hawaii', - IA: 'Iowa', - ID: 'Idaho', - IL: 'Illinois', - IN: 'Indiana', - KS: 'Kansas', - KY: 'Kentucky', - LA: 'Louisiana', - MA: 'Massachusetts', - MD: 'Maryland', - ME: 'Maine', - MI: 'Michigan', - MN: 'Minnesota', - MO: 'Missouri', - MS: 'Mississippi', - MT: 'Montana', - NC: 'North Carolina', - ND: 'North Dakota', - NE: 'Nebraska', - NH: 'New Hampshire', - NJ: 'New Jersey', - NM: 'New Mexico', - NV: 'Nevada', - NY: 'New York', - OH: 'Ohio', - OK: 'Oklahoma', - OR: 'Oregon', - PA: 'Pennsylvania', - RI: 'Rhode Island', - SC: 'South Carolina', - SD: 'South Dakota', - TN: 'Tennessee', - TX: 'Texas', - UT: 'Utah', - VA: 'Virginia', - VT: 'Vermont', - WA: 'Washington', - WI: 'Wisconsin', - WV: 'West Virginia', - WY: 'Wyoming', -}; - -ContactFactory.PARTY_TYPES = { - conservator: 'Conservator', - corporation: 'Corporation', - custodian: 'Custodian', - donor: 'Donor', - estate: 'Estate with an executor/personal representative/fiduciary/etc.', - estateWithoutExecutor: - 'Estate without an executor/personal representative/fiduciary/etc.', - guardian: 'Guardian', - nextFriendForIncompetentPerson: - 'Next friend for a legally incompetent person (without a guardian, conservator, or other like fiduciary)', - nextFriendForMinor: - 'Next friend for a minor (without a guardian, conservator, or other like fiduciary)', - partnershipAsTaxMattersPartner: 'Partnership (as the Tax Matters Partner)', - partnershipBBA: - 'Partnership (as a partnership representative under the BBA regime)', - partnershipOtherThanTaxMatters: - 'Partnership (as a partner other than Tax Matters Partner)', - petitioner: 'Petitioner', - petitionerDeceasedSpouse: 'Petitioner & deceased spouse', - petitionerSpouse: 'Petitioner & spouse', - survivingSpouse: 'Surviving spouse', - transferee: 'Transferee', - trust: 'Trust', -}; -ContactFactory.BUSINESS_TYPES = { - corporation: ContactFactory.PARTY_TYPES.corporation, - partnershipAsTaxMattersPartner: - ContactFactory.PARTY_TYPES.partnershipAsTaxMattersPartner, - partnershipBBA: ContactFactory.PARTY_TYPES.partnershipBBA, - partnershipOtherThanTaxMatters: - ContactFactory.PARTY_TYPES.partnershipOtherThanTaxMatters, -}; - -ContactFactory.ESTATE_TYPES = { - estate: ContactFactory.PARTY_TYPES.estate, - estateWithoutExecutor: ContactFactory.PARTY_TYPES.estateWithoutExecutor, - trust: ContactFactory.PARTY_TYPES.trust, -}; - -ContactFactory.OTHER_TYPES = { - conservator: ContactFactory.PARTY_TYPES.conservator, - custodian: ContactFactory.PARTY_TYPES.custodian, - guardian: ContactFactory.PARTY_TYPES.guardian, - nextFriendForIncompetentPerson: - ContactFactory.PARTY_TYPES.nextFriendForIncompetentPerson, - nextFriendForMinor: ContactFactory.PARTY_TYPES.nextFriendForMinor, -}; +const ContactFactory = {}; ContactFactory.DOMESTIC_VALIDATION_ERROR_MESSAGES = { address1: 'Enter mailing address', @@ -163,10 +58,7 @@ const commonValidationRequirements = { .optional(), }; const domesticValidationObject = { - countryType: joi - .string() - .valid(ContactFactory.COUNTRY_TYPES.DOMESTIC) - .required(), + countryType: joi.string().valid(COUNTRY_TYPES.DOMESTIC).required(), ...commonValidationRequirements, state: joi.string().required(), postalCode: JoiValidationConstants.US_POSTAL_CODE.required(), @@ -174,10 +66,7 @@ const domesticValidationObject = { const internationalValidationObject = { country: joi.string().required(), - countryType: joi - .string() - .valid(ContactFactory.COUNTRY_TYPES.INTERNATIONAL) - .required(), + countryType: joi.string().valid(COUNTRY_TYPES.INTERNATIONAL).required(), ...commonValidationRequirements, postalCode: joi.string().required(), }; @@ -192,11 +81,11 @@ const internationalValidationObject = { * @returns {object} the joi validation object */ ContactFactory.getValidationObject = ({ - countryType = ContactFactory.COUNTRY_TYPES.DOMESTIC, + countryType = COUNTRY_TYPES.DOMESTIC, isPaper = false, }) => { const baseValidationObject = - countryType === ContactFactory.COUNTRY_TYPES.DOMESTIC + countryType === COUNTRY_TYPES.DOMESTIC ? domesticValidationObject : internationalValidationObject; @@ -214,9 +103,9 @@ ContactFactory.getValidationObject = ({ * @returns {object} the error message map object which maps errors to custom messages */ ContactFactory.getErrorToMessageMap = ({ - countryType = ContactFactory.COUNTRY_TYPES.DOMESTIC, + countryType = COUNTRY_TYPES.DOMESTIC, }) => { - return countryType === ContactFactory.COUNTRY_TYPES.DOMESTIC + return countryType === COUNTRY_TYPES.DOMESTIC ? ContactFactory.DOMESTIC_VALIDATION_ERROR_MESSAGES : ContactFactory.INTERNATIONAL_VALIDATION_ERROR_MESSAGES; }; @@ -278,87 +167,87 @@ const getContactConstructor = ({ const { getPetitionerTrustContact } = require('./PetitionerTrustContact'); const { getSurvivingSpouseContact } = require('./SurvivingSpouseContact'); return { - [ContactFactory.PARTY_TYPES.petitioner]: { + [PARTY_TYPES.petitioner]: { primary: getPetitionerPrimaryContact({ countryType, isPaper }), secondary: null, }[contactType], - [ContactFactory.PARTY_TYPES.transferee]: { + [PARTY_TYPES.transferee]: { primary: getPetitionerPrimaryContact({ countryType, isPaper }), secondary: null, }[contactType], - [ContactFactory.PARTY_TYPES.donor]: { + [PARTY_TYPES.donor]: { primary: getPetitionerPrimaryContact({ countryType, isPaper }), secondary: null, }[contactType], - [ContactFactory.PARTY_TYPES.petitionerDeceasedSpouse]: { + [PARTY_TYPES.petitionerDeceasedSpouse]: { primary: getPetitionerPrimaryContact({ countryType, isPaper }), secondary: getPetitionerDeceasedSpouseContact({ countryType, isPaper }), }[contactType], - [ContactFactory.PARTY_TYPES.survivingSpouse]: { + [PARTY_TYPES.survivingSpouse]: { primary: getSurvivingSpouseContact({ countryType, isPaper }), secondary: null, }[contactType], - [ContactFactory.PARTY_TYPES.petitionerSpouse]: { + [PARTY_TYPES.petitionerSpouse]: { primary: getPetitionerPrimaryContact({ countryType, isPaper }), secondary: getPetitionerSpouseContact({ countryType, isPaper }), }[contactType], - [ContactFactory.PARTY_TYPES.corporation]: { + [PARTY_TYPES.corporation]: { primary: getPetitionerCorporationContact({ countryType, isPaper }), secondary: null, }[contactType], - [ContactFactory.PARTY_TYPES.estateWithoutExecutor]: { + [PARTY_TYPES.estateWithoutExecutor]: { primary: getPetitionerIntermediaryContact({ countryType, isPaper }), secondary: null, }[contactType], - [ContactFactory.PARTY_TYPES.partnershipAsTaxMattersPartner]: { + [PARTY_TYPES.partnershipAsTaxMattersPartner]: { primary: getPartnershipAsTaxMattersPartnerPrimaryContact({ countryType, isPaper, }), secondary: null, }[contactType], - [ContactFactory.PARTY_TYPES.partnershipOtherThanTaxMatters]: { + [PARTY_TYPES.partnershipOtherThanTaxMatters]: { primary: getPartnershipOtherThanTaxMattersPrimaryContact({ countryType, isPaper, }), secondary: null, }[contactType], - [ContactFactory.PARTY_TYPES.nextFriendForMinor]: { + [PARTY_TYPES.nextFriendForMinor]: { primary: getNextFriendForMinorContact({ countryType, isPaper }), secondary: null, }[contactType], - [ContactFactory.PARTY_TYPES.nextFriendForIncompetentPerson]: { + [PARTY_TYPES.nextFriendForIncompetentPerson]: { primary: getNextFriendForIncompetentPersonContact({ countryType, isPaper, }), secondary: null, }[contactType], - [ContactFactory.PARTY_TYPES.estate]: { + [PARTY_TYPES.estate]: { primary: getPetitionerEstateWithExecutorPrimaryContact({ countryType, isPaper, }), secondary: null, }[contactType], - [ContactFactory.PARTY_TYPES.partnershipBBA]: { + [PARTY_TYPES.partnershipBBA]: { primary: getPartnershipBBAPrimaryContact({ countryType, isPaper }), secondary: null, }[contactType], - [ContactFactory.PARTY_TYPES.trust]: { + [PARTY_TYPES.trust]: { primary: getPetitionerTrustContact({ countryType, isPaper }), secondary: null, }[contactType], - [ContactFactory.PARTY_TYPES.conservator]: { + [PARTY_TYPES.conservator]: { primary: getPetitionerConservatorContact({ countryType, isPaper }), secondary: null, }[contactType], - [ContactFactory.PARTY_TYPES.guardian]: { + [PARTY_TYPES.guardian]: { primary: getPetitionerGuardianContact({ countryType, isPaper }), secondary: null, }[contactType], - [ContactFactory.PARTY_TYPES.custodian]: { + [PARTY_TYPES.custodian]: { primary: getPetitionerCustodianContact({ countryType, isPaper }), secondary: null, }[contactType], diff --git a/shared/src/business/entities/contacts/ContactFactory.test.js b/shared/src/business/entities/contacts/ContactFactory.test.js index 110ef206038..93da960c05c 100644 --- a/shared/src/business/entities/contacts/ContactFactory.test.js +++ b/shared/src/business/entities/contacts/ContactFactory.test.js @@ -1,10 +1,9 @@ const { applicationContext, } = require('../../test/createTestApplicationContext'); -const { Case } = require('../cases/Case'); const { CaseExternal } = require('../cases/CaseExternal'); const { CaseInternal } = require('../cases/CaseInternal'); -const { ContactFactory } = require('./ContactFactory'); +const { PARTY_TYPES, PAYMENT_STATUS } = require('../EntityConstants'); let caseExternal; @@ -17,7 +16,7 @@ describe('Petition', () => { hasIrsNotice: true, irsNoticeDate: '2009-10-13T08:06:07.539Z', mailingDate: 'testing', - partyType: ContactFactory.PARTY_TYPES.corporation, + partyType: PARTY_TYPES.corporation, petitionFile: {}, petitionFileSize: 1, preferredTrialCity: 'Chattanooga, Tennessee', @@ -48,7 +47,7 @@ describe('Petition', () => { hasIrsNotice: true, irsNoticeDate: '2009-10-13T08:06:07.539Z', mailingDate: 'testing', - partyType: ContactFactory.PARTY_TYPES.corporation, + partyType: PARTY_TYPES.corporation, petitionFile: {}, petitionFileSize: 1, preferredTrialCity: 'Chattanooga, Tennessee', @@ -80,7 +79,7 @@ describe('Petition', () => { hasIrsNotice: true, irsNoticeDate: '2009-10-13T08:06:07.539Z', mailingDate: 'testing', - partyType: ContactFactory.PARTY_TYPES.petitioner, + partyType: PARTY_TYPES.petitioner, petitionFile: {}, petitionFileSize: 1, preferredTrialCity: 'Fresno, California', @@ -111,7 +110,7 @@ describe('Petition', () => { hasIrsNotice: true, irsNoticeDate: '2009-10-13T08:06:07.539Z', mailingDate: 'testing', - partyType: ContactFactory.PARTY_TYPES.estateWithoutExecutor, + partyType: PARTY_TYPES.estateWithoutExecutor, petitionFile: {}, petitionFileSize: 1, preferredTrialCity: 'Chattanooga, Tennessee', @@ -130,7 +129,7 @@ describe('Petition', () => { hasIrsNotice: true, irsNoticeDate: '2009-10-13T08:06:07.539Z', mailingDate: 'testing', - partyType: ContactFactory.PARTY_TYPES.estate, + partyType: PARTY_TYPES.estate, petitionFile: {}, petitionFileSize: 1, preferredTrialCity: 'Chattanooga, Tennessee', @@ -162,7 +161,7 @@ describe('Petition', () => { hasIrsNotice: true, irsNoticeDate: '2009-10-13T08:06:07.539Z', mailingDate: 'testing', - partyType: ContactFactory.PARTY_TYPES.estate, + partyType: PARTY_TYPES.estate, petitionFile: {}, petitionFileSize: 1, preferredTrialCity: 'Chattanooga, Tennessee', @@ -193,7 +192,7 @@ describe('Petition', () => { hasIrsNotice: true, irsNoticeDate: '2009-10-13T08:06:07.539Z', mailingDate: 'testing', - partyType: ContactFactory.PARTY_TYPES.estate, + partyType: PARTY_TYPES.estate, petitionFile: {}, petitionFileSize: 1, preferredTrialCity: 'Chattanooga, Tennessee', @@ -213,7 +212,7 @@ describe('Petition', () => { hasIrsNotice: true, irsNoticeDate: '2009-10-13T08:06:07.539Z', mailingDate: 'testing', - partyType: ContactFactory.PARTY_TYPES.partnershipBBA, + partyType: PARTY_TYPES.partnershipBBA, petitionFile: {}, petitionFileSize: 1, preferredTrialCity: 'Chattanooga, Tennessee', @@ -246,7 +245,7 @@ describe('Petition', () => { hasIrsNotice: true, irsNoticeDate: '2009-10-13T08:06:07.539Z', mailingDate: 'testing', - partyType: ContactFactory.PARTY_TYPES.partnershipBBA, + partyType: PARTY_TYPES.partnershipBBA, petitionFile: {}, petitionFileSize: 1, preferredTrialCity: 'Chattanooga, Tennessee', @@ -266,7 +265,7 @@ describe('Petition', () => { hasIrsNotice: true, irsNoticeDate: '2009-10-13T08:06:07.539Z', mailingDate: 'testing', - partyType: ContactFactory.PARTY_TYPES.trust, + partyType: PARTY_TYPES.trust, petitionFile: {}, petitionFileSize: 1, preferredTrialCity: 'Chattanooga, Tennessee', @@ -298,7 +297,7 @@ describe('Petition', () => { hasIrsNotice: true, irsNoticeDate: '2009-10-13T08:06:07.539Z', mailingDate: 'testing', - partyType: ContactFactory.PARTY_TYPES.trust, + partyType: PARTY_TYPES.trust, petitionFile: {}, petitionFileSize: 1, preferredTrialCity: 'Chattanooga, Tennessee', @@ -318,7 +317,7 @@ describe('Petition', () => { hasIrsNotice: true, irsNoticeDate: '2009-10-13T08:06:07.539Z', mailingDate: 'testing', - partyType: ContactFactory.PARTY_TYPES.conservator, + partyType: PARTY_TYPES.conservator, petitionFile: {}, petitionFileSize: 1, preferredTrialCity: 'Chattanooga, Tennessee', @@ -348,7 +347,7 @@ describe('Petition', () => { hasIrsNotice: true, irsNoticeDate: '2009-10-13T08:06:07.539Z', mailingDate: 'testing', - partyType: ContactFactory.PARTY_TYPES.conservator, + partyType: PARTY_TYPES.conservator, petitionFile: {}, petitionFileSize: 1, preferredTrialCity: 'Chattanooga, Tennessee', @@ -368,7 +367,7 @@ describe('Petition', () => { hasIrsNotice: true, irsNoticeDate: '2009-10-13T08:06:07.539Z', mailingDate: 'testing', - partyType: ContactFactory.PARTY_TYPES.guardian, + partyType: PARTY_TYPES.guardian, petitionFile: {}, petitionFileSize: 1, preferredTrialCity: 'Chattanooga, Tennessee', @@ -398,7 +397,7 @@ describe('Petition', () => { hasIrsNotice: true, irsNoticeDate: '2009-10-13T08:06:07.539Z', mailingDate: 'testing', - partyType: ContactFactory.PARTY_TYPES.guardian, + partyType: PARTY_TYPES.guardian, petitionFile: {}, petitionFileSize: 1, preferredTrialCity: 'Chattanooga, Tennessee', @@ -418,7 +417,7 @@ describe('Petition', () => { hasIrsNotice: true, irsNoticeDate: '2009-10-13T08:06:07.539Z', mailingDate: 'testing', - partyType: ContactFactory.PARTY_TYPES.custodian, + partyType: PARTY_TYPES.custodian, petitionFile: {}, petitionFileSize: 1, preferredTrialCity: 'Chattanooga, Tennessee', @@ -448,7 +447,7 @@ describe('Petition', () => { hasIrsNotice: true, irsNoticeDate: '2009-10-13T08:06:07.539Z', mailingDate: 'testing', - partyType: ContactFactory.PARTY_TYPES.custodian, + partyType: PARTY_TYPES.custodian, petitionFile: {}, petitionFileSize: 1, preferredTrialCity: 'Chattanooga, Tennessee', @@ -468,7 +467,7 @@ describe('Petition', () => { hasIrsNotice: true, irsNoticeDate: '2009-10-13T08:06:07.539Z', mailingDate: 'testing', - partyType: ContactFactory.PARTY_TYPES.donor, + partyType: PARTY_TYPES.donor, petitionFile: {}, petitionFileSize: 1, preferredTrialCity: 'Chattanooga, Tennessee', @@ -499,7 +498,7 @@ describe('Petition', () => { hasIrsNotice: true, irsNoticeDate: '2009-10-13T08:06:07.539Z', mailingDate: 'testing', - partyType: ContactFactory.PARTY_TYPES.donor, + partyType: PARTY_TYPES.donor, petitionFile: {}, petitionFileSize: 1, preferredTrialCity: 'Chattanooga, Tennessee', @@ -519,7 +518,7 @@ describe('Petition', () => { hasIrsNotice: true, irsNoticeDate: '2009-10-13T08:06:07.539Z', mailingDate: 'testing', - partyType: ContactFactory.PARTY_TYPES.transferee, + partyType: PARTY_TYPES.transferee, petitionFile: {}, petitionFileSize: 1, preferredTrialCity: 'Chattanooga, Tennessee', @@ -550,7 +549,7 @@ describe('Petition', () => { hasIrsNotice: true, irsNoticeDate: '2009-10-13T08:06:07.539Z', mailingDate: 'testing', - partyType: ContactFactory.PARTY_TYPES.transferee, + partyType: PARTY_TYPES.transferee, petitionFile: {}, petitionFileSize: 1, preferredTrialCity: 'Chattanooga, Tennessee', @@ -581,10 +580,10 @@ describe('Petition', () => { hasIrsNotice: true, irsNoticeDate: '2009-10-13T08:06:07.539Z', mailingDate: 'testing', - partyType: ContactFactory.PARTY_TYPES.transferee, + partyType: PARTY_TYPES.transferee, petitionFile: {}, petitionFileSize: 1, - petitionPaymentStatus: Case.PAYMENT_STATUS.UNPAID, + petitionPaymentStatus: PAYMENT_STATUS.UNPAID, preferredTrialCity: 'Chattanooga, Tennessee', procedureType: 'Small', receivedAt: '2009-10-13T08:06:07.539Z', diff --git a/shared/src/business/entities/docketEntry/DocketEntryFactory.js b/shared/src/business/entities/docketEntry/DocketEntryFactory.js index cdc75de66b5..3668c43bdb2 100644 --- a/shared/src/business/entities/docketEntry/DocketEntryFactory.js +++ b/shared/src/business/entities/docketEntry/DocketEntryFactory.js @@ -1,18 +1,18 @@ const joi = require('@hapi/joi'); +const { + DOCUMENT_CATEGORY_MAP, + MAX_FILE_SIZE_BYTES, + MAX_FILE_SIZE_MB, +} = require('../EntityConstants'); const { ExternalDocumentFactory, } = require('../externalDocument/ExternalDocumentFactory'); const { joiValidationDecorator, } = require('../../../utilities/JoiValidationDecorator'); -const { - MAX_FILE_SIZE_BYTES, - MAX_FILE_SIZE_MB, -} = require('../../../persistence/s3/getUploadPolicy'); const { VALIDATION_ERROR_MESSAGES, } = require('../externalDocument/ExternalDocumentInformationFactory'); -const { Document } = require('../Document'); const { getTimestampSchema } = require('../../../utilities/dateSchema'); const joiStrictTimestamp = getTimestampSchema(); @@ -126,7 +126,7 @@ function DocketEntryFactory(rawProps) { } const objectionDocumentTypes = [ - ...Document.CATEGORY_MAP['Motion'].map(entry => { + ...DOCUMENT_CATEGORY_MAP['Motion'].map(entry => { return entry.documentType; }), 'Motion to Withdraw Counsel (filed by petitioner)', diff --git a/shared/src/business/entities/externalDocument/ExternalDocumentInformationFactory.js b/shared/src/business/entities/externalDocument/ExternalDocumentInformationFactory.js index 160615602b7..49a6962385b 100644 --- a/shared/src/business/entities/externalDocument/ExternalDocumentInformationFactory.js +++ b/shared/src/business/entities/externalDocument/ExternalDocumentInformationFactory.js @@ -4,19 +4,19 @@ const { makeRequiredHelper, } = require('./externalDocumentHelpers'); const { - joiValidationDecorator, -} = require('../../../utilities/JoiValidationDecorator'); -const { + DOCUMENT_CATEGORY_MAP, MAX_FILE_SIZE_BYTES, MAX_FILE_SIZE_MB, -} = require('../../../persistence/s3/getUploadPolicy'); +} = require('../EntityConstants'); +const { + joiValidationDecorator, +} = require('../../../utilities/JoiValidationDecorator'); const { SecondaryDocumentInformationFactory, } = require('./SecondaryDocumentInformationFactory'); const { SupportingDocumentInformationFactory, } = require('./SupportingDocumentInformationFactory'); -const { Document } = require('../Document'); const { getTimestampSchema } = require('../../../utilities/dateSchema'); const { includes, isEqual, reduce, some, sortBy, values } = require('lodash'); @@ -221,7 +221,7 @@ ExternalDocumentInformationFactory.get = documentMetadata => { } const objectionDocumentTypes = [ - ...Document.CATEGORY_MAP['Motion'].map(entry => { + ...DOCUMENT_CATEGORY_MAP['Motion'].map(entry => { return entry.documentType; }), 'Motion to Withdraw Counsel (filed by petitioner)', diff --git a/shared/src/business/entities/externalDocument/SupportingDocumentInformationFactory.js b/shared/src/business/entities/externalDocument/SupportingDocumentInformationFactory.js index 9436c4644ba..ee1e8ef2859 100644 --- a/shared/src/business/entities/externalDocument/SupportingDocumentInformationFactory.js +++ b/shared/src/business/entities/externalDocument/SupportingDocumentInformationFactory.js @@ -2,12 +2,10 @@ const joi = require('@hapi/joi'); const { joiValidationDecorator, } = require('../../../utilities/JoiValidationDecorator'); -const { - MAX_FILE_SIZE_BYTES, -} = require('../../../persistence/s3/getUploadPolicy'); const { getTimestampSchema } = require('../../../utilities/dateSchema'); const { includes } = require('lodash'); const { makeRequiredHelper } = require('./externalDocumentHelpers'); +const { MAX_FILE_SIZE_BYTES } = require('../EntityConstants'); const joiStrictTimestamp = getTimestampSchema(); /** diff --git a/shared/src/business/entities/orders/Order.js b/shared/src/business/entities/orders/Order.js index 4f1c71a001c..8dfade0fea3 100644 --- a/shared/src/business/entities/orders/Order.js +++ b/shared/src/business/entities/orders/Order.js @@ -3,47 +3,6 @@ const { joiValidationDecorator, } = require('../../../utilities/JoiValidationDecorator'); -Order.ORDER_TYPES = [ - { - documentType: 'Order', - eventCode: 'O', - }, - { - documentTitle: 'Order of Dismissal for Lack of Jurisdiction', - documentType: 'Order of Dismissal for Lack of Jurisdiction', - eventCode: 'ODJ', - }, - { - documentTitle: 'Order of Dismissal', - documentType: 'Order of Dismissal', - eventCode: 'OD', - }, - { - documentTitle: 'Order of Dismissal and Decision', - documentType: 'Order of Dismissal and Decision', - eventCode: 'ODD', - }, - { - documentTitle: 'Order to Show Cause', - documentType: 'Order to Show Cause', - eventCode: 'OSC', - }, - { - documentTitle: 'Order and Decision', - documentType: 'Order and Decision', - eventCode: 'OAD', - }, - { - documentTitle: 'Decision', - documentType: 'Decision', - eventCode: 'DEC', - }, - { - documentType: 'Notice', - eventCode: 'NOT', - }, -]; - /** * @param {object} rawOrder the raw order data * @constructor @@ -61,14 +20,16 @@ Order.VALIDATION_ERROR_MESSAGES = { orderBody: 'Order body is required.', }; +Order.VALIDATION_RULES = { + documentTitle: joi.string().max(100).required(), + documentType: joi.string().required(), // TODO: add enum + eventCode: joi.string().optional(), // TODO: add enum + orderBody: joi.string().max(500).required(), +}; + joiValidationDecorator( Order, - joi.object().keys({ - documentTitle: joi.string().required(), - documentType: joi.string().required(), - eventCode: joi.string().optional(), - orderBody: joi.string().required(), - }), + joi.object().keys(Order.VALIDATION_RULES), Order.VALIDATION_ERROR_MESSAGES, ); diff --git a/shared/src/business/entities/trialSessions/TrialSession.js b/shared/src/business/entities/trialSessions/TrialSession.js index da850ffbfe6..4eacc1b78af 100644 --- a/shared/src/business/entities/trialSessions/TrialSession.js +++ b/shared/src/business/entities/trialSessions/TrialSession.js @@ -8,125 +8,10 @@ const { const { createISODateString } = require('../../utilities/DateHandler'); const { getTimestampSchema } = require('../../../utilities/dateSchema'); const { isEmpty } = require('lodash'); +const { SESSION_TERMS, SESSION_TYPES } = require('../EntityConstants'); const joiStrictTimestamp = getTimestampSchema(); -const COMMON_CITIES = [ - { city: 'Birmingham', state: 'Alabama' }, - { city: 'Mobile', state: 'Alabama' }, - { city: 'Anchorage', state: 'Alaska' }, - { city: 'Phoenix', state: 'Arizona' }, - { city: 'Little Rock', state: 'Arkansas' }, - { city: 'Los Angeles', state: 'California' }, - { city: 'San Diego', state: 'California' }, - { city: 'San Francisco', state: 'California' }, - { city: 'Denver', state: 'Colorado' }, - { city: 'Hartford', state: 'Connecticut' }, - { city: 'Washington', state: 'District of Columbia' }, - { city: 'Jacksonville', state: 'Florida' }, - { city: 'Miami', state: 'Florida' }, - { city: 'Tampa', state: 'Florida' }, - { city: 'Atlanta', state: 'Georgia' }, - { city: 'Honolulu', state: 'Hawaii' }, - { city: 'Boise', state: 'Idaho' }, - { city: 'Chicago', state: 'Illinois' }, - { city: 'Indianapolis', state: 'Indiana' }, - { city: 'Des Moines', state: 'Iowa' }, - { city: 'Louisville', state: 'Kentucky' }, - { city: 'New Orleans', state: 'Louisiana' }, - { city: 'Baltimore', state: 'Maryland' }, - { city: 'Boston', state: 'Massachusetts' }, - { city: 'Detroit', state: 'Michigan' }, - { city: 'St. Paul', state: 'Minnesota' }, - { city: 'Jackson', state: 'Mississippi' }, - { city: 'Kansas City', state: 'Missouri' }, - { city: 'St. Louis', state: 'Missouri' }, - { city: 'Helena', state: 'Montana' }, - { city: 'Omaha', state: 'Nebraska' }, - { city: 'Las Vegas', state: 'Nevada' }, - { city: 'Reno', state: 'Nevada' }, - { city: 'Albuquerque', state: 'New Mexico' }, - { city: 'Buffalo', state: 'New York' }, - { city: 'New York City', state: 'New York' }, - { city: 'Winston-Salem', state: 'North Carolina' }, - { city: 'Cincinnati', state: 'Ohio' }, - { city: 'Cleveland', state: 'Ohio' }, - { city: 'Columbus', state: 'Ohio' }, - { city: 'Oklahoma City', state: 'Oklahoma' }, - { city: 'Portland', state: 'Oregon' }, - { city: 'Philadelphia', state: 'Pennsylvania' }, - { city: 'Pittsburgh', state: 'Pennsylvania' }, - { city: 'Columbia', state: 'South Carolina' }, - { city: 'Knoxville', state: 'Tennessee' }, - { city: 'Memphis', state: 'Tennessee' }, - { city: 'Nashville', state: 'Tennessee' }, - { city: 'Dallas', state: 'Texas' }, - { city: 'El Paso', state: 'Texas' }, - { city: 'Houston', state: 'Texas' }, - { city: 'Lubbock', state: 'Texas' }, - { city: 'San Antonio', state: 'Texas' }, - { city: 'Salt Lake City', state: 'Utah' }, - { city: 'Richmond', state: 'Virginia' }, - { city: 'Seattle', state: 'Washington' }, - { city: 'Spokane', state: 'Washington' }, - { city: 'Charleston', state: 'West Virginia' }, - { city: 'Milwaukee', state: 'Wisconsin' }, -]; - -const SMALL_CITIES = [ - { city: 'Fresno', state: 'California' }, - { city: 'Tallahassee', state: 'Florida' }, - { city: 'Pocatello', state: 'Idaho' }, - { city: 'Peoria', state: 'Illinois' }, - { city: 'Wichita', state: 'Kansas' }, - { city: 'Shreveport', state: 'Louisiana' }, - { city: 'Portland', state: 'Maine' }, - { city: 'Billings', state: 'Montana' }, - { city: 'Albany', state: 'New York' }, - { city: 'Syracuse', state: 'New York' }, - { city: 'Bismarck', state: 'North Dakota' }, - { city: 'Aberdeen', state: 'South Dakota' }, - { city: 'Burlington', state: 'Vermont' }, - { city: 'Roanoke', state: 'Virginia' }, - { city: 'Cheyenne', state: 'Wyoming' }, - ...COMMON_CITIES, -]; - -TrialSession.TRIAL_CITIES = { - ALL: SMALL_CITIES, - REGULAR: COMMON_CITIES, - SMALL: SMALL_CITIES, -}; - -TrialSession.TRIAL_CITY_STRINGS = SMALL_CITIES.map( - location => `${location.city}, ${location.state}`, -); - -TrialSession.SESSION_TERMS = ['Winter', 'Fall', 'Spring', 'Summer']; - -TrialSession.SESSION_TYPES = [ - 'Regular', - 'Small', - 'Hybrid', - 'Special', - 'Motion/Hearing', -]; - -TrialSession.SESSION_STATUS_GROUPS = { - all: 'All', - closed: 'Closed', - new: 'New', - open: 'Open', -}; - -TrialSession.PROPERTIES_REQUIRED_FOR_CALENDARING = [ - 'address1', - 'city', - 'state', - 'postalCode', - 'judge', -]; - TrialSession.validationName = 'TrialSession'; /** @@ -202,6 +87,14 @@ TrialSession.VALIDATION_ERROR_MESSAGES = { trialLocation: 'Select a trial session location', }; +TrialSession.PROPERTIES_REQUIRED_FOR_CALENDARING = [ + 'address1', + 'city', + 'state', + 'postalCode', + 'judge', +]; + TrialSession.validationRules = { COMMON: { address1: joi.string().allow('').optional(), @@ -220,7 +113,7 @@ TrialSession.validationRules = { postalCode: JoiValidationConstants.US_POSTAL_CODE.optional(), sessionType: joi .string() - .valid(...TrialSession.SESSION_TYPES) + .valid(...SESSION_TYPES) .required(), startDate: joiStrictTimestamp.required(), startTime: JoiValidationConstants.TWENTYFOUR_HOUR_MINUTES, @@ -238,7 +131,7 @@ TrialSession.validationRules = { }), term: joi .string() - .valid(...TrialSession.SESSION_TERMS) + .valid(...SESSION_TERMS) .required(), termYear: joi.string().required(), trialClerk: joi.object().optional(), diff --git a/shared/src/business/entities/trialSessions/TrialSessionWorkingCopy.js b/shared/src/business/entities/trialSessions/TrialSessionWorkingCopy.js index 411a46ba18c..0bbbedab938 100644 --- a/shared/src/business/entities/trialSessions/TrialSessionWorkingCopy.js +++ b/shared/src/business/entities/trialSessions/TrialSessionWorkingCopy.js @@ -2,18 +2,7 @@ const joi = require('@hapi/joi'); const { joiValidationDecorator, } = require('../../../utilities/JoiValidationDecorator'); -const { DOCKET_NUMBER_MATCHER } = require('../cases/CaseConstants'); - -TrialSessionWorkingCopy.TRIAL_STATUS_TYPES = [ - 'Set for Trial', - 'Dismissed', - 'Continued', - 'Rule 122', - 'A Basis Reached', - 'Settled', - 'Recall', - 'Taken Under Advisement', -]; +const { DOCKET_NUMBER_MATCHER } = require('../EntityConstants'); TrialSessionWorkingCopy.validationName = 'TrialSessionWorkingCopy'; diff --git a/shared/src/business/test/assignWorkItemsInteractor.e2e.test.js b/shared/src/business/test/assignWorkItemsInteractor.e2e.test.js index 54e70704828..7b15e9d8ca8 100644 --- a/shared/src/business/test/assignWorkItemsInteractor.e2e.test.js +++ b/shared/src/business/test/assignWorkItemsInteractor.e2e.test.js @@ -5,9 +5,9 @@ const { getDocumentQCInboxForUserInteractor, } = require('../useCases/workitems/getDocumentQCInboxForUserInteractor'); const { applicationContext } = require('../test/createTestApplicationContext'); -const { ContactFactory } = require('../entities/contacts/ContactFactory'); const { createCaseInteractor } = require('../useCases/createCaseInteractor'); const { getCaseInteractor } = require('../useCases/getCaseInteractor'); +const { PARTY_TYPES, ROLES } = require('../entities/EntityConstants'); const { User } = require('../entities/User'); describe('assignWorkItemsInteractor integration test', () => { @@ -48,7 +48,7 @@ describe('assignWorkItemsInteractor integration test', () => { ], filingType: 'Myself', hasIrsNotice: false, - partyType: ContactFactory.PARTY_TYPES.petitioner, + partyType: PARTY_TYPES.petitioner, preferredTrialCity: 'Aberdeen, South Dakota', procedureType: 'Small', }, @@ -58,7 +58,7 @@ describe('assignWorkItemsInteractor integration test', () => { applicationContext.getCurrentUser.mockReturnValue( new User({ name: 'Test Petitionsclerk', - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: '3805d1ab-18d0-43ec-bafb-654e83405416', }), ); diff --git a/shared/src/business/test/completeWorkItemInteractor.e2e.test.js b/shared/src/business/test/completeWorkItemInteractor.e2e.test.js index 90d38962024..6425c305622 100644 --- a/shared/src/business/test/completeWorkItemInteractor.e2e.test.js +++ b/shared/src/business/test/completeWorkItemInteractor.e2e.test.js @@ -11,9 +11,9 @@ const { getSentMessagesForUserInteractor, } = require('../useCases/workitems/getSentMessagesForUserInteractor'); const { applicationContext } = require('../test/createTestApplicationContext'); -const { ContactFactory } = require('../entities/contacts/ContactFactory'); const { createCaseInteractor } = require('../useCases/createCaseInteractor'); const { getCaseInteractor } = require('../useCases/getCaseInteractor'); +const { PARTY_TYPES, ROLES } = require('../entities/EntityConstants'); const { User } = require('../entities/User'); describe('completeWorkItemInteractor integration test', () => { @@ -44,7 +44,7 @@ describe('completeWorkItemInteractor integration test', () => { contactSecondary: {}, filingType: 'Myself', hasIrsNotice: false, - partyType: ContactFactory.PARTY_TYPES.petitioner, + partyType: PARTY_TYPES.petitioner, preferredTrialCity: 'Aberdeen, South Dakota', procedureType: 'Small', }, @@ -54,7 +54,7 @@ describe('completeWorkItemInteractor integration test', () => { applicationContext.getCurrentUser.mockReturnValue( new User({ name: 'richard', - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: '3805d1ab-18d0-43ec-bafb-654e83405416', }), ); diff --git a/shared/src/business/test/createCaseFromPaperInteractor.e2e.test.js b/shared/src/business/test/createCaseFromPaperInteractor.e2e.test.js index 4fd5e61ddff..bbe192b83bd 100644 --- a/shared/src/business/test/createCaseFromPaperInteractor.e2e.test.js +++ b/shared/src/business/test/createCaseFromPaperInteractor.e2e.test.js @@ -1,3 +1,7 @@ +const { + CASE_STATUS_TYPES, + PAYMENT_STATUS, +} = require('../entities/EntityConstants'); const { createCaseFromPaperInteractor, } = require('../useCases/createCaseFromPaperInteractor'); @@ -8,10 +12,9 @@ const { getDocumentQCInboxForUserInteractor, } = require('../useCases/workitems/getDocumentQCInboxForUserInteractor'); const { applicationContext } = require('../test/createTestApplicationContext'); -const { Case } = require('../entities/cases/Case'); const { getCaseInteractor } = require('../useCases/getCaseInteractor'); const { MOCK_CASE } = require('../../test/mockCase'); -const { User } = require('../entities/User'); +const { ROLES } = require('../entities/EntityConstants'); describe('createCaseFromPaperInteractor integration test', () => { const RECEIVED_DATE = '2019-02-01T22:54:06.000Z'; @@ -23,7 +26,7 @@ describe('createCaseFromPaperInteractor integration test', () => { applicationContext.getCurrentUser.mockReturnValue({ name: 'Alex Petitionsclerk', - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: 'a805d1ab-18d0-43ec-bafb-654e83405416', }); }); @@ -49,7 +52,7 @@ describe('createCaseFromPaperInteractor integration test', () => { mailingDate: 'testing', petitionFile: { name: 'something' }, petitionFileSize: 1, - petitionPaymentStatus: Case.PAYMENT_STATUS.UNPAID, + petitionPaymentStatus: PAYMENT_STATUS.UNPAID, receivedAt: RECEIVED_DATE, requestForPlaceOfTrialFile: new File( [], @@ -90,7 +93,7 @@ describe('createCaseFromPaperInteractor integration test', () => { { assigneeId: 'a805d1ab-18d0-43ec-bafb-654e83405416', assigneeName: 'Alex Petitionsclerk', - caseStatus: Case.STATUS_TYPES.new, + caseStatus: CASE_STATUS_TYPES.new, createdAt: RECEIVED_DATE, docketNumber: '101-19', docketNumberSuffix: null, @@ -133,7 +136,7 @@ describe('createCaseFromPaperInteractor integration test', () => { orderForRatification: false, orderToShowCause: false, receivedAt: RECEIVED_DATE, - status: Case.STATUS_TYPES.new, + status: CASE_STATUS_TYPES.new, userId: 'a805d1ab-18d0-43ec-bafb-654e83405416', }); @@ -145,7 +148,7 @@ describe('createCaseFromPaperInteractor integration test', () => { expect(petitionsclerkInbox).toMatchObject([ { assigneeName: 'Alex Petitionsclerk', - caseStatus: Case.STATUS_TYPES.new, + caseStatus: CASE_STATUS_TYPES.new, docketNumber: '101-19', docketNumberWithSuffix: '101-19', document: { @@ -174,7 +177,7 @@ describe('createCaseFromPaperInteractor integration test', () => { expect(petitionsSectionInbox).toMatchObject([ { assigneeName: 'Alex Petitionsclerk', - caseStatus: Case.STATUS_TYPES.new, + caseStatus: CASE_STATUS_TYPES.new, docketNumber: '101-19', docketNumberWithSuffix: '101-19', document: { diff --git a/shared/src/business/test/createCaseInteractor.e2e.test.js b/shared/src/business/test/createCaseInteractor.e2e.test.js index fa0f20eac99..50b7f5b4cc6 100644 --- a/shared/src/business/test/createCaseInteractor.e2e.test.js +++ b/shared/src/business/test/createCaseInteractor.e2e.test.js @@ -2,10 +2,10 @@ const { getDocumentQCInboxForSectionInteractor, } = require('../useCases/workitems/getDocumentQCInboxForSectionInteractor'); const { applicationContext } = require('../test/createTestApplicationContext'); -const { Case } = require('../entities/cases/Case'); -const { ContactFactory } = require('../entities/contacts/ContactFactory'); +const { CASE_STATUS_TYPES } = require('../entities/EntityConstants'); const { createCaseInteractor } = require('../useCases/createCaseInteractor'); const { getCaseInteractor } = require('../useCases/getCaseInteractor'); +const { PARTY_TYPES, ROLES } = require('../entities/EntityConstants'); const { User } = require('../entities/User'); describe('createCase integration test', () => { @@ -36,7 +36,7 @@ describe('createCase integration test', () => { contactSecondary: {}, filingType: 'Myself', hasIrsNotice: false, - partyType: ContactFactory.PARTY_TYPES.petitioner, + partyType: PARTY_TYPES.petitioner, preferredTrialCity: 'Aberdeen, South Dakota', procedureType: 'Small', }, @@ -71,7 +71,7 @@ describe('createCase integration test', () => { { assigneeId: null, assigneeName: null, - caseStatus: Case.STATUS_TYPES.new, + caseStatus: CASE_STATUS_TYPES.new, docketNumber: '101-19', docketNumberWithSuffix: '101-19S', document: { @@ -110,14 +110,14 @@ describe('createCase integration test', () => { orderForOds: false, orderForRatification: false, orderToShowCause: false, - status: Case.STATUS_TYPES.new, + status: CASE_STATUS_TYPES.new, userId: 'a805d1ab-18d0-43ec-bafb-654e83405416', }); applicationContext.getCurrentUser.mockReturnValue( new User({ name: 'richard', - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: '3805d1ab-18d0-43ec-bafb-654e83405416', }), ); @@ -130,7 +130,7 @@ describe('createCase integration test', () => { expect(docketsSectionInbox).toMatchObject([ { assigneeName: null, - caseStatus: Case.STATUS_TYPES.new, + caseStatus: CASE_STATUS_TYPES.new, docketNumber: '101-19', docketNumberWithSuffix: '101-19S', document: { diff --git a/shared/src/business/test/createMockDocumentClient.js b/shared/src/business/test/createMockDocumentClient.js index dcc7dda5691..6846824a839 100644 --- a/shared/src/business/test/createMockDocumentClient.js +++ b/shared/src/business/test/createMockDocumentClient.js @@ -1,11 +1,11 @@ -const { User } = require('../entities/User'); +const { ROLES } = require('../entities/EntityConstants'); const mockDynamoUsers = { ['user|1805d1ab-18d0-43ec-bafb-654e83405416 user|1805d1ab-18d0-43ec-bafb-654e83405416']: { email: 'docketclerk', name: 'Test Docketclerk', pk: 'user|1805d1ab-18d0-43ec-bafb-654e83405416', - role: User.ROLES.docketClerk, + role: ROLES.docketClerk, section: 'docket', sk: 'user|1805d1ab-18d0-43ec-bafb-654e83405416', userId: '1805d1ab-18d0-43ec-bafb-654e83405416', @@ -14,7 +14,7 @@ const mockDynamoUsers = { email: 'petitionsclerk', name: 'Test Petitionsclerk', pk: 'user|3805d1ab-18d0-43ec-bafb-654e83405416', - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, section: 'petitions', sk: 'user|3805d1ab-18d0-43ec-bafb-654e83405416', userId: '3805d1ab-18d0-43ec-bafb-654e83405416', @@ -23,7 +23,7 @@ const mockDynamoUsers = { email: 'petitioner', name: 'Test Petitioner', pk: 'user|7805d1ab-18d0-43ec-bafb-654e83405416', - role: User.ROLES.petitioner, + role: ROLES.petitioner, sk: 'user|7805d1ab-18d0-43ec-bafb-654e83405416', userId: '7805d1ab-18d0-43ec-bafb-654e83405416', }, @@ -31,7 +31,7 @@ const mockDynamoUsers = { email: 'pettitionsclerk', name: 'Alex Petitionsclerk', pk: 'user|a805d1ab-18d0-43ec-bafb-654e83405416', - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, section: 'petitions', sk: 'user|a805d1ab-18d0-43ec-bafb-654e83405416', userId: 'a805d1ab-18d0-43ec-bafb-654e83405416', diff --git a/shared/src/business/test/createTestApplicationContext.js b/shared/src/business/test/createTestApplicationContext.js index 02710262c5c..9213d80f188 100644 --- a/shared/src/business/test/createTestApplicationContext.js +++ b/shared/src/business/test/createTestApplicationContext.js @@ -110,6 +110,7 @@ const { formatDollars } = require('../utilities/formatDollars'); const { getConstants } = require('../../../../web-client/src/getConstants'); const { getItem } = require('../../persistence/localStorage/getItem'); const { removeItem } = require('../../persistence/localStorage/removeItem'); +const { ROLES } = require('../entities/EntityConstants'); const { setItem } = require('../../persistence/localStorage/setItem'); const { updateCase } = require('../../persistence/dynamo/cases/updateCase'); const { User } = require('../entities/User'); @@ -240,8 +241,10 @@ const createTestApplicationContext = ({ user } = {}) => { addressLabelCoverSheet: jest.fn().mockImplementation(getFakeFileUint8Array), caseInventoryReport: jest.fn().mockImplementation(getFakeFile), changeOfAddress: jest.fn().mockImplementation(getFakeFile), + coverSheet: jest.fn().mockImplementation(getFakeFile), docketRecord: jest.fn().mockImplementation(getFakeFile), noticeOfDocketChange: jest.fn().mockImplementation(getFakeFile), + noticeOfReceiptOfPetition: jest.fn().mockImplementation(getFakeFile), order: jest.fn().mockImplementation(getFakeFile), pendingReport: jest.fn().mockImplementation(getFakeFile), receiptOfFiling: jest.fn().mockImplementation(getFakeFile), @@ -383,7 +386,7 @@ const createTestApplicationContext = ({ user } = {}) => { return new User( user || { name: 'richard', - role: User.ROLES.petitioner, + role: ROLES.petitioner, userId: 'a805d1ab-18d0-43ec-bafb-654e83405416', }, ); diff --git a/shared/src/business/test/fileExternalDocumentInteractor.e2e.test.js b/shared/src/business/test/fileExternalDocumentInteractor.e2e.test.js index cef98b083a9..9ee8af2daf9 100644 --- a/shared/src/business/test/fileExternalDocumentInteractor.e2e.test.js +++ b/shared/src/business/test/fileExternalDocumentInteractor.e2e.test.js @@ -1,3 +1,7 @@ +const { + CASE_STATUS_TYPES, + PARTY_TYPES, +} = require('../entities/EntityConstants'); const { fileExternalDocumentInteractor, } = require('../useCases/externalDocument/fileExternalDocumentInteractor'); @@ -5,10 +9,9 @@ const { getDocumentQCInboxForSectionInteractor, } = require('../useCases/workitems/getDocumentQCInboxForSectionInteractor'); const { applicationContext } = require('../test/createTestApplicationContext'); -const { Case } = require('../entities/cases/Case'); -const { ContactFactory } = require('../entities/contacts/ContactFactory'); const { createCaseInteractor } = require('../useCases/createCaseInteractor'); const { getCaseInteractor } = require('../useCases/getCaseInteractor'); +const { ROLES } = require('../entities/EntityConstants'); const { User } = require('../entities/User'); describe('fileExternalDocumentInteractor integration test', () => { @@ -19,7 +22,7 @@ describe('fileExternalDocumentInteractor integration test', () => { applicationContext.getCurrentUser.mockReturnValue({ name: 'Test Petitioner', - role: User.ROLES.petitioner, + role: ROLES.petitioner, userId: '7805d1ab-18d0-43ec-bafb-654e83405416', }); }); @@ -55,7 +58,7 @@ describe('fileExternalDocumentInteractor integration test', () => { ], filingType: 'Myself', hasIrsNotice: false, - partyType: ContactFactory.PARTY_TYPES.petitioner, + partyType: PARTY_TYPES.petitioner, preferredTrialCity: 'Aberdeen, South Dakota', procedureType: 'Small', }, @@ -178,7 +181,7 @@ describe('fileExternalDocumentInteractor integration test', () => { assigneeId: null, assigneeName: null, caseId, - caseStatus: Case.STATUS_TYPES.new, + caseStatus: CASE_STATUS_TYPES.new, docketNumber: '101-19', docketNumberWithSuffix: '101-19S', document: { @@ -227,7 +230,7 @@ describe('fileExternalDocumentInteractor integration test', () => { assigneeId: null, assigneeName: null, caseId, - caseStatus: Case.STATUS_TYPES.new, + caseStatus: CASE_STATUS_TYPES.new, docketNumber: '101-19', docketNumberWithSuffix: '101-19S', document: { @@ -274,7 +277,7 @@ describe('fileExternalDocumentInteractor integration test', () => { assigneeId: null, assigneeName: null, caseId, - caseStatus: Case.STATUS_TYPES.new, + caseStatus: CASE_STATUS_TYPES.new, docketNumber: '101-19', docketNumberWithSuffix: '101-19S', document: { @@ -316,7 +319,7 @@ describe('fileExternalDocumentInteractor integration test', () => { { assigneeId: null, assigneeName: null, - caseStatus: Case.STATUS_TYPES.new, + caseStatus: CASE_STATUS_TYPES.new, docketNumber: '101-19', docketNumberWithSuffix: '101-19S', document: { @@ -359,7 +362,7 @@ describe('fileExternalDocumentInteractor integration test', () => { { assigneeId: null, assigneeName: null, - caseStatus: Case.STATUS_TYPES.new, + caseStatus: CASE_STATUS_TYPES.new, docketNumber: '101-19', docketNumberWithSuffix: '101-19S', document: { @@ -401,18 +404,18 @@ describe('fileExternalDocumentInteractor integration test', () => { orderForOds: false, orderForRatification: false, orderToShowCause: false, - partyType: ContactFactory.PARTY_TYPES.petitioner, + partyType: PARTY_TYPES.petitioner, preferredTrialCity: 'Aberdeen, South Dakota', privatePractitioners: [], procedureType: 'Small', - status: Case.STATUS_TYPES.new, + status: CASE_STATUS_TYPES.new, userId: '7805d1ab-18d0-43ec-bafb-654e83405416', }); applicationContext.getCurrentUser.mockReturnValue( new User({ name: 'Test Docketclerk', - role: User.ROLES.docketClerk, + role: ROLES.docketClerk, userId: '1805d1ab-18d0-43ec-bafb-654e83405416', }), ); @@ -428,7 +431,7 @@ describe('fileExternalDocumentInteractor integration test', () => { { assigneeId: null, assigneeName: null, - caseStatus: Case.STATUS_TYPES.new, + caseStatus: CASE_STATUS_TYPES.new, docketNumber: '101-19', docketNumberWithSuffix: '101-19S', document: { @@ -459,7 +462,7 @@ describe('fileExternalDocumentInteractor integration test', () => { { assigneeId: null, assigneeName: null, - caseStatus: Case.STATUS_TYPES.new, + caseStatus: CASE_STATUS_TYPES.new, docketNumber: '101-19', docketNumberWithSuffix: '101-19S', document: { @@ -489,7 +492,7 @@ describe('fileExternalDocumentInteractor integration test', () => { { assigneeId: null, assigneeName: null, - caseStatus: Case.STATUS_TYPES.new, + caseStatus: CASE_STATUS_TYPES.new, docketNumber: '101-19', docketNumberWithSuffix: '101-19S', document: { @@ -517,7 +520,7 @@ describe('fileExternalDocumentInteractor integration test', () => { { assigneeId: null, assigneeName: null, - caseStatus: Case.STATUS_TYPES.new, + caseStatus: CASE_STATUS_TYPES.new, docketNumber: '101-19', docketNumberWithSuffix: '101-19S', document: { diff --git a/shared/src/business/test/forwardWorkItemInteractor.e2e.test.js b/shared/src/business/test/forwardWorkItemInteractor.e2e.test.js index a0f8336f58e..cde51a19bc1 100644 --- a/shared/src/business/test/forwardWorkItemInteractor.e2e.test.js +++ b/shared/src/business/test/forwardWorkItemInteractor.e2e.test.js @@ -8,9 +8,9 @@ const { getSentMessagesForUserInteractor, } = require('../useCases/workitems/getSentMessagesForUserInteractor'); const { applicationContext } = require('../test/createTestApplicationContext'); -const { ContactFactory } = require('../entities/contacts/ContactFactory'); const { createCaseInteractor } = require('../useCases/createCaseInteractor'); const { getCaseInteractor } = require('../useCases/getCaseInteractor'); +const { PARTY_TYPES, ROLES } = require('../entities/EntityConstants'); const { User } = require('../entities/User'); describe('forwardWorkItemInteractor integration test', () => { @@ -41,7 +41,7 @@ describe('forwardWorkItemInteractor integration test', () => { contactSecondary: {}, filingType: 'Myself', hasIrsNotice: false, - partyType: ContactFactory.PARTY_TYPES.petitioner, + partyType: PARTY_TYPES.petitioner, preferredTrialCity: 'Aberdeen, South Dakota', procedureType: 'Small', }, @@ -51,7 +51,7 @@ describe('forwardWorkItemInteractor integration test', () => { applicationContext.getCurrentUser.mockReturnValue( new User({ name: 'richard', - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: '3805d1ab-18d0-43ec-bafb-654e83405416', }), ); @@ -116,7 +116,7 @@ describe('forwardWorkItemInteractor integration test', () => { applicationContext.getCurrentUser = () => { return new User({ name: 'bob', - role: User.ROLES.docketClerk, + role: ROLES.docketClerk, userId: '1805d1ab-18d0-43ec-bafb-654e83405416', }); }; diff --git a/shared/src/business/test/setWorkItemAsReadInteractor.e2e.test.js b/shared/src/business/test/setWorkItemAsReadInteractor.e2e.test.js index f003677a75b..898f8c4d0ad 100644 --- a/shared/src/business/test/setWorkItemAsReadInteractor.e2e.test.js +++ b/shared/src/business/test/setWorkItemAsReadInteractor.e2e.test.js @@ -8,9 +8,9 @@ const { setWorkItemAsReadInteractor, } = require('../useCases/workitems/setWorkItemAsReadInteractor'); const { applicationContext } = require('../test/createTestApplicationContext'); -const { ContactFactory } = require('../entities/contacts/ContactFactory'); const { createCaseInteractor } = require('../useCases/createCaseInteractor'); const { getCaseInteractor } = require('../useCases/getCaseInteractor'); +const { PARTY_TYPES, ROLES } = require('../entities/EntityConstants'); const { User } = require('../entities/User'); const { WorkItem } = require('../entities/WorkItem'); @@ -42,7 +42,7 @@ describe('setWorkItemAsReadInteractor integration test', () => { contactSecondary: {}, filingType: 'Myself', hasIrsNotice: false, - partyType: ContactFactory.PARTY_TYPES.petitioner, + partyType: PARTY_TYPES.petitioner, preferredTrialCity: 'Aberdeen, South Dakota', procedureType: 'Small', }, @@ -52,7 +52,7 @@ describe('setWorkItemAsReadInteractor integration test', () => { applicationContext.getCurrentUser.mockReturnValue( new User({ name: 'richard', - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: '3805d1ab-18d0-43ec-bafb-654e83405416', }), ); diff --git a/shared/src/business/useCaseHelper/automaticBlock/updateCaseAutomaticBlock.js b/shared/src/business/useCaseHelper/automaticBlock/updateCaseAutomaticBlock.js index 1679e7ea8ba..12d5d984516 100644 --- a/shared/src/business/useCaseHelper/automaticBlock/updateCaseAutomaticBlock.js +++ b/shared/src/business/useCaseHelper/automaticBlock/updateCaseAutomaticBlock.js @@ -1,4 +1,4 @@ -const { Case } = require('../../entities/cases/Case'); +const { CASE_STATUS_TYPES } = require('../../entities/EntityConstants'); /** * updateCaseAutomaticBlock @@ -30,7 +30,7 @@ exports.updateCaseAutomaticBlock = async ({ caseId: caseEntity.caseId, }); } else if ( - caseEntity.status === Case.STATUS_TYPES.generalDocketReadyForTrial && + caseEntity.status === CASE_STATUS_TYPES.generalDocketReadyForTrial && !caseEntity.blocked ) { await applicationContext diff --git a/shared/src/business/useCaseHelper/automaticBlock/updateCaseAutomaticBlock.test.js b/shared/src/business/useCaseHelper/automaticBlock/updateCaseAutomaticBlock.test.js index f5d7a586471..e2bbd7867b6 100644 --- a/shared/src/business/useCaseHelper/automaticBlock/updateCaseAutomaticBlock.test.js +++ b/shared/src/business/useCaseHelper/automaticBlock/updateCaseAutomaticBlock.test.js @@ -1,6 +1,10 @@ const { applicationContext, } = require('../../test/createTestApplicationContext'); +const { + AUTOMATIC_BLOCKED_REASONS, + CASE_STATUS_TYPES, +} = require('../../entities/EntityConstants'); const { MOCK_CASE, MOCK_CASE_WITHOUT_PENDING, @@ -31,7 +35,7 @@ describe('updateCaseAutomaticBlock', () => { expect(updatedCase).toMatchObject({ automaticBlocked: true, automaticBlockedDate: expect.anything(), - automaticBlockedReason: Case.AUTOMATIC_BLOCKED_REASONS.pending, + automaticBlockedReason: AUTOMATIC_BLOCKED_REASONS.pending, }); expect( applicationContext.getPersistenceGateway() @@ -55,7 +59,7 @@ describe('updateCaseAutomaticBlock', () => { expect(updatedCase).toMatchObject({ automaticBlocked: true, automaticBlockedDate: expect.anything(), - automaticBlockedReason: Case.AUTOMATIC_BLOCKED_REASONS.dueDate, + automaticBlockedReason: AUTOMATIC_BLOCKED_REASONS.dueDate, }); expect( applicationContext.getPersistenceGateway() @@ -118,7 +122,7 @@ describe('updateCaseAutomaticBlock', () => { const caseEntity = new Case( { ...MOCK_CASE_WITHOUT_PENDING, - status: Case.STATUS_TYPES.generalDocketReadyForTrial, + status: CASE_STATUS_TYPES.generalDocketReadyForTrial, }, { applicationContext, diff --git a/shared/src/business/useCaseHelper/caseAssociation/associateIrsPractitionerToCase.test.js b/shared/src/business/useCaseHelper/caseAssociation/associateIrsPractitionerToCase.test.js index d440e260ca9..db7c6c2f68f 100644 --- a/shared/src/business/useCaseHelper/caseAssociation/associateIrsPractitionerToCase.test.js +++ b/shared/src/business/useCaseHelper/caseAssociation/associateIrsPractitionerToCase.test.js @@ -4,12 +4,10 @@ const { const { associateIrsPractitionerToCase, } = require('./associateIrsPractitionerToCase'); -const { - SERVICE_INDICATOR_TYPES, -} = require('../../entities/cases/CaseConstants'); const { MOCK_CASE } = require('../../../test/mockCase.js'); const { MOCK_USERS } = require('../../../test/mockUsers'); -const { User } = require('../../entities/User'); +const { ROLES } = require('../../entities/EntityConstants'); +const { SERVICE_INDICATOR_TYPES } = require('../../entities/EntityConstants'); describe('associateIrsPractitionerToCase', () => { let caseRecord = { @@ -56,7 +54,7 @@ describe('associateIrsPractitionerToCase', () => { it('should not add mapping if already there', async () => { const user = { name: 'Emmett Lathrop "Doc" Brown, Ph.D.', - role: User.ROLES.irsPractitioner, + role: ROLES.irsPractitioner, userId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', }; @@ -86,7 +84,7 @@ describe('associateIrsPractitionerToCase', () => { const user = { name: 'Emmett Lathrop "Doc" Brown, Ph.D.', - role: User.ROLES.irsPractitioner, + role: ROLES.irsPractitioner, userId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', }; diff --git a/shared/src/business/useCaseHelper/caseAssociation/associatePrivatePractitionerToCase.js b/shared/src/business/useCaseHelper/caseAssociation/associatePrivatePractitionerToCase.js index 1b44c2eaae9..c8f6acf86b1 100644 --- a/shared/src/business/useCaseHelper/caseAssociation/associatePrivatePractitionerToCase.js +++ b/shared/src/business/useCaseHelper/caseAssociation/associatePrivatePractitionerToCase.js @@ -1,8 +1,6 @@ -const { - SERVICE_INDICATOR_TYPES, -} = require('../../entities/cases/CaseConstants'); const { Case } = require('../../entities/cases/Case'); const { PrivatePractitioner } = require('../../entities/PrivatePractitioner'); +const { SERVICE_INDICATOR_TYPES } = require('../../entities/EntityConstants'); const { UserCase } = require('../../entities/UserCase'); /** diff --git a/shared/src/business/useCaseHelper/caseAssociation/associatePrivatePractitionerToCase.test.js b/shared/src/business/useCaseHelper/caseAssociation/associatePrivatePractitionerToCase.test.js index 4aae49c2a11..ef221f135bb 100644 --- a/shared/src/business/useCaseHelper/caseAssociation/associatePrivatePractitionerToCase.test.js +++ b/shared/src/business/useCaseHelper/caseAssociation/associatePrivatePractitionerToCase.test.js @@ -5,17 +5,17 @@ const { associatePrivatePractitionerToCase, } = require('./associatePrivatePractitionerToCase'); const { + ROLES, SERVICE_INDICATOR_TYPES, -} = require('../../entities/cases/CaseConstants'); +} = require('../../entities/EntityConstants'); const { MOCK_USERS } = require('../../../test/mockUsers'); -const { User } = require('../../entities/User'); describe('associatePrivatePractitionerToCase', () => { let caseRecord; const practitionerUser = { name: 'Emmett Lathrop "Doc" Brown, Ph.D.', - role: User.ROLES.privatePractitioner, + role: ROLES.privatePractitioner, userId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', }; diff --git a/shared/src/business/useCaseHelper/caseConfirmation/caseConfirmation.pug b/shared/src/business/useCaseHelper/caseConfirmation/caseConfirmation.pug deleted file mode 100644 index c6821122047..00000000000 --- a/shared/src/business/useCaseHelper/caseConfirmation/caseConfirmation.pug +++ /dev/null @@ -1,65 +0,0 @@ -doctype html -html(lang="en") - head - meta(charset="utf-8") - title NOTIFICATION OF RECEIPT OF PETITION, U.S. Tax Court Electronic Filing and Case Management System - style= css - body - .page-container - img.logo(src=logo) - h1.text-center United States Tax Court - p.text-center - | 400 Second Street, N.W. - br - | Washington D.C. 20217 - - p.text-center= todaysDate - h2.text-center.clear NOTIFICATION OF RECEIPT OF PETITION - - p.float-left.width-half= caseCaptionWithPostfix - p.float-right Docket Number: #{docketNumber} - - p.clear.margin-top-80 The Court received and filed your petition on #{receivedAtFormatted} and served it on respondent on #{servedDate}. - p.margin-bottom-20 - | (X) Request for Place of Trial at #{preferredTrialCity}. - - .info-box - h3 Your Docket Number: #{docketNumber} - p Please use this docket number on all papers and correspondence that you send to the Tax Court. Do not include your Social Security or Taxpayer Identification numbers on any documents you file with the Court. - - .info-box - h3 Internet Access: - p - | To obtain further information about proceeding in the Tax Court, please visit - b.link www.ustaxcourt.gov - | and select “Taxpayer Information”. - - .info-box - h3 Change of Address: - p - | You must notify the Clerk of the Court if you change your address. If you filed your petition in paper, see Tax Court Form 10, Notice of Change of Address, under “Forms” on the Tax Court’s Website at - b.link www.ustaxcourt.gov - |. If you filed your petition electronically, you may update your address under the “Case Information” tab in your case online. Failure to notify the Clerk of the Court of a change of your address can mean you do not receive notices and documents essential to your case and can lead to dismissal of your case. - - p.float-right.width-third - | Stephanie A. Servoss - br - | Clerk of the Court - - hr.clear.margin-top-80 - - .address - | #{name} - br - | #{address1} - br - if address2 - | #{address2} - br - if address3 - | #{address3} - br - | #{city}, #{state} #{postalCode} - if !address3 - br - | #{countryName} \ No newline at end of file diff --git a/shared/src/business/useCaseHelper/caseConfirmation/generateCaseConfirmationPdf.js b/shared/src/business/useCaseHelper/caseConfirmation/generateCaseConfirmationPdf.js deleted file mode 100644 index 53cdd7c4380..00000000000 --- a/shared/src/business/useCaseHelper/caseConfirmation/generateCaseConfirmationPdf.js +++ /dev/null @@ -1,130 +0,0 @@ -const DateHandler = require('../../utilities/DateHandler'); -const { - isAuthorized, - ROLE_PERMISSIONS, -} = require('../../../authorization/authorizationClientService'); -const { Case } = require('../../entities/cases/Case'); -const { UnauthorizedError } = require('../../../errors/errors'); - -/** - * - * @param {object} caseInfo a case entity - * @returns {object} the formatted information needed by the PDF - */ -const formattedCaseInfo = caseInfo => { - const { servedAt } = caseInfo.documents.find(doc => doc.servedAt); - const countryName = - caseInfo.contactPrimary.countryType !== 'domestic' - ? caseInfo.contactPrimary.country - : ''; - const formattedInfo = Object.assign( - { - caseCaptionWithPostfix: `${caseInfo.caseCaption} ${Case.CASE_CAPTION_POSTFIX}`, - countryName, - docketNumber: `${caseInfo.docketNumber}${ - caseInfo.docketNumberSuffix || '' - }`, - preferredTrialCity: caseInfo.preferredTrialCity, - receivedAtFormatted: DateHandler.formatDateString( - caseInfo.receivedAt, - 'MONTH_DAY_YEAR', - ), - servedDate: DateHandler.formatDateString(servedAt, 'MONTH_DAY_YEAR'), - todaysDate: DateHandler.formatNow('MONTH_DAY_YEAR'), - }, - caseInfo.contactPrimary, - ); - return formattedInfo; -}; - -/** - * - * @param {object} caseInfo a raw object representing a petition - * @returns {string} an html string resulting from rendering template with caseInfo - */ -const generateCaseConfirmationPage = async ({ - applicationContext, - caseEntity, -}) => { - const confirmSassContent = require('./../../assets/ustcPdf.scss_'); - const confirmTemplateContent = require('./caseConfirmation.pug_'); - const ustcLogoBufferBase64 = require('../../../../static/images/ustc_seal.png_'); - - const pug = applicationContext.getPug(); - const sass = applicationContext.getNodeSass(); - - const { css } = await new Promise(resolve => { - sass.render({ data: confirmSassContent }, (err, result) => { - return resolve(result); - }); - }); - const compiledFunction = pug.compile(confirmTemplateContent); - const html = compiledFunction({ - ...formattedCaseInfo(caseEntity), - css, - logo: ustcLogoBufferBase64, - }); - return html; -}; - -/** - * generateCaseConfirmationPdfInteractor - * - * @param {object} providers the providers object - * @param {object} providers.applicationContext the application context - * @param {string} providers.caseEntity a case entity with its documents - * @returns {Promise<*>} the promise of the document having been uploaded - */ -exports.generateCaseConfirmationPdf = async ({ - applicationContext, - caseEntity, -}) => { - const user = applicationContext.getCurrentUser(); - - if (!isAuthorized(user, ROLE_PERMISSIONS.UPLOAD_DOCUMENT)) { - throw new UnauthorizedError('Unauthorized'); - } - - let browser = null; - let result = null; - - try { - browser = await applicationContext.getChromiumBrowser(); - let page = await browser.newPage(); - - const contentResult = await generateCaseConfirmationPage({ - applicationContext, - caseEntity, - }); - await page.setContent(contentResult); - - result = await page.pdf({ - displayHeaderFooter: false, - format: 'letter', - }); - } catch (error) { - applicationContext.logger.error(error); - throw error; - } finally { - if (browser !== null) { - await browser.close(); - } - } - - const caseConfirmationPdfName = caseEntity.getCaseConfirmationGeneratedPdfFileName(); - - await new Promise(resolve => { - const documentsBucket = applicationContext.getDocumentsBucketName(); - const s3Client = applicationContext.getStorageClient(); - - const params = { - Body: result, - Bucket: documentsBucket, - ContentType: 'application/pdf', - Key: caseConfirmationPdfName, - }; - - s3Client.upload(params, resolve); - }); - return result; -}; diff --git a/shared/src/business/useCaseHelper/caseConfirmation/generateCaseConfirmationPdf.test.js b/shared/src/business/useCaseHelper/caseConfirmation/generateCaseConfirmationPdf.test.js deleted file mode 100644 index 9d6c3360a46..00000000000 --- a/shared/src/business/useCaseHelper/caseConfirmation/generateCaseConfirmationPdf.test.js +++ /dev/null @@ -1,140 +0,0 @@ -const { - generateCaseConfirmationPdf, -} = require('./generateCaseConfirmationPdf'); -jest.mock('../../../authorization/authorizationClientService'); -const { - applicationContext, -} = require('../../test/createTestApplicationContext'); -const { - isAuthorized, -} = require('../../../authorization/authorizationClientService'); -const { MOCK_CASE } = require('../../../test/mockCase'); -const { User } = require('../../entities/User'); -const PDF_MOCK_BUFFER = 'Hello World'; - -const pageMock = { - addStyleTag: () => {}, - pdf: () => { - return PDF_MOCK_BUFFER; - }, - setContent: () => {}, -}; - -const chromiumBrowserMock = { - close: jest.fn(), - newPage: () => pageMock, -}; - -const mockCurrentUser = { - role: User.ROLES.petitioner, - userId: 'petitioner', -}; - -const s3Upload = jest.fn().mockImplementation((params, resolve) => resolve()); - -applicationContext.getCurrentUser.mockReturnValue(mockCurrentUser); -applicationContext.getDocumentsBucketName.mockReturnValue('DocumentBucketName'); -applicationContext.getPersistenceGateway().getCaseByCaseId.mockReturnValue({ - docketNumber: '101-19', -}); -applicationContext.getPug.mockReturnValue({ - compile: () => () => '', -}); -applicationContext.getStorageClient.mockReturnValue({ - upload: s3Upload, -}); - -describe('generateCaseConfirmationPdf', () => { - beforeEach(() => { - isAuthorized.mockReturnValue(true); - }); - afterEach(() => { - jest.restoreAllMocks(); - }); - - it('fails to get chromium browser', async () => { - jest - .spyOn(applicationContext, 'getChromiumBrowser') - .mockImplementation(() => { - return null; - }); - - let error; - try { - await generateCaseConfirmationPdf({ - applicationContext, - caseEntity: { - ...MOCK_CASE, - documents: [{ servedAt: '2009-09-17T08:06:07.530Z' }], - }, - }); - } catch (err) { - error = err; - } - - expect(error).toBeDefined(); - expect(chromiumBrowserMock.close).not.toHaveBeenCalled(); - }); - - it('requires permissions', async () => { - isAuthorized.mockReturnValue(false); - let result, error; - try { - result = await generateCaseConfirmationPdf({ - applicationContext, - caseEntity: { - ...MOCK_CASE, - documents: [{ servedAt: '2009-09-17T08:06:07.530Z' }], - }, - }); - } catch (err) { - error = err; - } - expect(result).not.toBeDefined(); - expect(error.message).toEqual('Unauthorized'); - }); - - it('handles exceptions gracefully', async () => { - jest.spyOn(chromiumBrowserMock, 'newPage').mockImplementation(() => { - throw new Error('page problem'); - }); - applicationContext.getChromiumBrowser.mockReturnValue(chromiumBrowserMock); - let error; - try { - await generateCaseConfirmationPdf({ - applicationContext, - caseEntity: { - ...MOCK_CASE, - contactPrimary: { - countryType: 'domestic', - }, - documents: [{ servedAt: '2009-09-17T08:06:07.530Z' }], - }, - }); - } catch (err) { - error = err; - } - expect(error).toBeDefined(); - expect(applicationContext.logger.error).toHaveBeenCalled(); - expect(chromiumBrowserMock.close).toHaveBeenCalled(); - }); - - it('returns the pdf buffer produced by chromium', async () => { - await generateCaseConfirmationPdf({ - applicationContext, - caseEntity: { - ...MOCK_CASE, - contactPrimary: { - country: 'Canada', - countryType: 'international', - }, - documents: [{ servedAt: '2009-09-17T08:06:07.530Z' }], - getCaseConfirmationGeneratedPdfFileName() { - return ''; - }, - }, - }); - - expect(applicationContext.getStorageClient).toHaveBeenCalled(); - }); -}); diff --git a/shared/src/business/useCaseHelper/caseInventoryReport/generateCaseInventoryReportPdf.test.js b/shared/src/business/useCaseHelper/caseInventoryReport/generateCaseInventoryReportPdf.test.js index 42bd3c0cf32..ab18605e98d 100644 --- a/shared/src/business/useCaseHelper/caseInventoryReport/generateCaseInventoryReportPdf.test.js +++ b/shared/src/business/useCaseHelper/caseInventoryReport/generateCaseInventoryReportPdf.test.js @@ -4,7 +4,7 @@ const { const { generateCaseInventoryReportPdf, } = require('./generateCaseInventoryReportPdf'); -const { User } = require('../../entities/User'); +const { ROLES } = require('../../entities/EntityConstants'); const mockCases = [ { @@ -23,7 +23,7 @@ describe('generateCaseInventoryReportPdf', () => { let user; beforeEach(() => { - user = { role: User.ROLES.petitionsClerk, userId: 'petitionsClerk' }; + user = { role: ROLES.petitionsClerk, userId: 'petitionsClerk' }; applicationContext.getCurrentUser.mockReturnValue(user); @@ -35,7 +35,7 @@ describe('generateCaseInventoryReportPdf', () => { }); it('throws an error if the user is unauthorized', async () => { - user = { role: User.ROLES.petitioner, userId: 'petitioner' }; + user = { role: ROLES.petitioner, userId: 'petitioner' }; applicationContext.getCurrentUser.mockReturnValue(user); await expect( diff --git a/shared/src/business/useCaseHelper/consolidatedCases/formatAndSortConsolidatedCases.js b/shared/src/business/useCaseHelper/consolidatedCases/formatAndSortConsolidatedCases.js new file mode 100644 index 00000000000..aa84405b6b3 --- /dev/null +++ b/shared/src/business/useCaseHelper/consolidatedCases/formatAndSortConsolidatedCases.js @@ -0,0 +1,28 @@ +const { Case } = require('../../entities/cases/Case'); + +/** + * Formats and sorts consolidated cases + * + * @param {object} arguments.consolidatedCases list of consolidated cases + * @param {object} arguments.leadCaseId the leadCaseId + * @param {object} arguments.userAssociatedCaseIdsMap the list of caseIds the user is associated with + * @returns {object} consolidated cases sorted by docket number + */ +exports.formatAndSortConsolidatedCases = ({ + consolidatedCases, + leadCaseId, + userAssociatedCaseIdsMap, +}) => { + const caseConsolidatedCases = []; + consolidatedCases.forEach(consolidatedCase => { + consolidatedCase.isRequestingUserAssociated = !!userAssociatedCaseIdsMap[ + consolidatedCase.caseId + ]; + + if (consolidatedCase.caseId !== leadCaseId) { + caseConsolidatedCases.push(consolidatedCase); + } + }); + + return Case.sortByDocketNumber(caseConsolidatedCases); +}; diff --git a/shared/src/business/useCaseHelper/consolidatedCases/formatAndSortConsolidatedCases.test.js b/shared/src/business/useCaseHelper/consolidatedCases/formatAndSortConsolidatedCases.test.js new file mode 100644 index 00000000000..d9a7fc911ef --- /dev/null +++ b/shared/src/business/useCaseHelper/consolidatedCases/formatAndSortConsolidatedCases.test.js @@ -0,0 +1,54 @@ +const { + applicationContext, +} = require('../../test/createTestApplicationContext'); +const { + formatAndSortConsolidatedCases, +} = require('./formatAndSortConsolidatedCases'); + +describe('formatAndSortConsolidatedCases', () => { + it('should set isRequestingUserAssociated for each case associated with the lead caseId', async () => { + const result = await formatAndSortConsolidatedCases({ + applicationContext, + consolidatedCases: [{ caseId: '123' }], + leadCaseId: '456', + userAssociatedCaseIdsMap: { + '123': true, + }, + }); + + expect(result[0].isRequestingUserAssociated).toBe(true); + }); + + it("should add each case to the consolidatedCases list for the lead caseId when it's not the lead case", async () => { + const result = await formatAndSortConsolidatedCases({ + applicationContext, + consolidatedCases: [{ caseId: '123' }, { caseId: '456' }], + leadCaseId: '456', + userAssociatedCaseIdsMap: { + '123': true, + }, + }); + + expect(result.length).toBe(1); + expect(result[0].caseId).toBe('123'); + }); + + it('should return the list of consolidatedCases sorted by docketNumber', async () => { + const result = await formatAndSortConsolidatedCases({ + applicationContext, + consolidatedCases: [ + { caseId: '123', docketNumber: '999-20' }, + { caseId: '321', docketNumber: '123-20' }, + ], + leadCaseId: '456', + userAssociatedCaseIdsMap: { + '123': true, + '321': true, + }, + }); + + expect(result.length).toBe(2); + expect(result[0].docketNumber).toBe('123-20'); + expect(result[1].docketNumber).toBe('999-20'); + }); +}); diff --git a/shared/src/business/useCaseHelper/consolidatedCases/getConsolidatedCasesForLeadCase.js b/shared/src/business/useCaseHelper/consolidatedCases/getConsolidatedCasesForLeadCase.js new file mode 100644 index 00000000000..06c96c3fb68 --- /dev/null +++ b/shared/src/business/useCaseHelper/consolidatedCases/getConsolidatedCasesForLeadCase.js @@ -0,0 +1,28 @@ +const { Case } = require('../../entities/cases/Case'); + +/** + * Retrieves all cases associated with the provided leadCaseId. + * + * @param {object} providers the providers object + * @param {object} providers.applicationContext the application context + * @param {object} providers.leadCaseId the leadCaseId + * @returns {object} a list of all cases associated with the leadCaseId + */ +exports.getConsolidatedCasesForLeadCase = async ({ + applicationContext, + leadCaseId, +}) => { + let consolidatedCases = await applicationContext + .getPersistenceGateway() + .getCasesByLeadCaseId({ + applicationContext, + leadCaseId, + }); + + consolidatedCases = Case.validateRawCollection(consolidatedCases, { + applicationContext, + filtered: true, + }); + + return consolidatedCases; +}; diff --git a/shared/src/business/useCaseHelper/consolidatedCases/getConsolidatedCasesForLeadCase.test.js b/shared/src/business/useCaseHelper/consolidatedCases/getConsolidatedCasesForLeadCase.test.js new file mode 100644 index 00000000000..b8d2ce7bd94 --- /dev/null +++ b/shared/src/business/useCaseHelper/consolidatedCases/getConsolidatedCasesForLeadCase.test.js @@ -0,0 +1,50 @@ +const { + applicationContext, +} = require('../../test/createTestApplicationContext'); +const { + getConsolidatedCasesForLeadCase, +} = require('./getConsolidatedCasesForLeadCase'); +const { MOCK_CASE } = require('../../../test/mockCase'); + +describe('getConsolidatedCasesForLeadCase', () => { + it('should retrieve all cases associated with the leadCaseId', async () => { + applicationContext + .getPersistenceGateway() + .getCasesByLeadCaseId.mockReturnValue([MOCK_CASE]); + + await getConsolidatedCasesForLeadCase({ + applicationContext, + casesAssociatedWithUserOrLeadCaseMap: { + '123': MOCK_CASE, + }, + leadCaseId: '123', + userAssociatedCaseIdsMap: {}, + }); + + expect( + applicationContext.getPersistenceGateway().getCasesByLeadCaseId.mock + .calls[0][0], + ).toMatchObject({ leadCaseId: '123' }); + }); + + // TODO - Refactor Case constants into their own file. + // Test currently fails when trying to mock out Case.validateRawCollection + // due to circular dependency issue, UserCase pulls in Case validation text + // it('should validate the retrieved cases', async () => { + // const mockCaseId = '123'; + // applicationContext + // .getPersistenceGateway() + // .getCasesByLeadCaseId.mockResolvedValue([MOCK_CASE]); + + // getConsolidatedCasesForLeadCase({ + // applicationContext, + // casesAssociatedWithUserOrLeadCaseMap: { + // '123': MOCK_CASE, + // }, + // leadCaseId: mockCaseId, + // userAssociatedCaseIdsMap: {}, + // }); + + // expect(Case.validateRawCollection).toBeCalled(); + // }); +}); diff --git a/shared/src/business/useCaseHelper/consolidatedCases/getUnassociatedLeadCase.js b/shared/src/business/useCaseHelper/consolidatedCases/getUnassociatedLeadCase.js new file mode 100644 index 00000000000..0351886d97a --- /dev/null +++ b/shared/src/business/useCaseHelper/consolidatedCases/getUnassociatedLeadCase.js @@ -0,0 +1,15 @@ +/** + * Finds a lead case when it is not associated with the current user + * + * @param {object} arguments.consolidatedCases the list of consolidated cases + * @param {object} arguments.leadCaseId the leadCaseId + * @returns {object} the lead case + */ +exports.getUnassociatedLeadCase = ({ consolidatedCases, leadCaseId }) => { + const leadCase = consolidatedCases.find( + consolidatedCase => consolidatedCase.caseId === leadCaseId, + ); + leadCase.isRequestingUserAssociated = false; + + return leadCase; +}; diff --git a/shared/src/business/useCaseHelper/consolidatedCases/getUnassociatedLeadCase.test.js b/shared/src/business/useCaseHelper/consolidatedCases/getUnassociatedLeadCase.test.js new file mode 100644 index 00000000000..bfc87c59e57 --- /dev/null +++ b/shared/src/business/useCaseHelper/consolidatedCases/getUnassociatedLeadCase.test.js @@ -0,0 +1,25 @@ +const { getUnassociatedLeadCase } = require('./getUnassociatedLeadCase'); +const { MOCK_CASE } = require('../../../test/mockCase'); + +describe('getUnassociatedLeadCase', () => { + it('should set the found case isRequestingUserAssociated to false', () => { + const result = getUnassociatedLeadCase({ + consolidatedCases: [MOCK_CASE], + leadCaseId: MOCK_CASE.caseId, + }); + + expect(result.isRequestingUserAssociated).toBe(false); + }); + + it('should return the found lead case', () => { + let casesAssociatedWithUserOrLeadCaseMap = {}; + + const result = getUnassociatedLeadCase({ + casesAssociatedWithUserOrLeadCaseMap, + consolidatedCases: [MOCK_CASE], + leadCaseId: MOCK_CASE.caseId, + }); + + expect(result).toMatchObject(MOCK_CASE); + }); +}); diff --git a/shared/src/business/useCaseHelper/consolidatedCases/processUserAssociatedCases.js b/shared/src/business/useCaseHelper/consolidatedCases/processUserAssociatedCases.js new file mode 100644 index 00000000000..526fb10bfdd --- /dev/null +++ b/shared/src/business/useCaseHelper/consolidatedCases/processUserAssociatedCases.js @@ -0,0 +1,36 @@ +/** + * Given a list of cases associated with the current user, creates a map of + * consolidated and lead cases. + * + * @param {object} openUserCases the list of open cases associated with the current user + * @returns {object} casesAssociatedWithUserOrLeadCaseMap - a map of + * consolidated and lead cases. leadCaseIdsAssociatedWithUser - a list of leadCaseIds + * associated with the current user. userAssociatedCaseIdsMap - a map of open cases associated + * with the current user + */ +exports.processUserAssociatedCases = openUserCases => { + let casesAssociatedWithUserOrLeadCaseMap = {}; + let userAssociatedCaseIdsMap = {}; + let leadCaseIdsAssociatedWithUser = []; + + openUserCases.forEach(caseRecord => { + const { caseId, leadCaseId } = caseRecord; + const caseIsALeadCase = leadCaseId === caseId; + + caseRecord.isRequestingUserAssociated = true; + userAssociatedCaseIdsMap[caseId] = true; + + if (!leadCaseId || caseIsALeadCase) { + casesAssociatedWithUserOrLeadCaseMap[caseId] = caseRecord; + } + if (leadCaseId && !leadCaseIdsAssociatedWithUser.includes(leadCaseId)) { + leadCaseIdsAssociatedWithUser.push(leadCaseId); + } + }); + + return { + casesAssociatedWithUserOrLeadCaseMap, + leadCaseIdsAssociatedWithUser, + userAssociatedCaseIdsMap, + }; +}; diff --git a/shared/src/business/useCaseHelper/consolidatedCases/processUserAssociatedCases.test.js b/shared/src/business/useCaseHelper/consolidatedCases/processUserAssociatedCases.test.js new file mode 100644 index 00000000000..614f452c5db --- /dev/null +++ b/shared/src/business/useCaseHelper/consolidatedCases/processUserAssociatedCases.test.js @@ -0,0 +1,74 @@ +const { + applicationContext, +} = require('../../test/createTestApplicationContext'); +const { MOCK_CASE } = require('../../../test/mockCase'); +const { processUserAssociatedCases } = require('./processUserAssociatedCases'); + +describe('processUserAssociatedCases', () => { + let mockFoundCasesList; + + beforeEach(() => { + mockFoundCasesList = [MOCK_CASE]; + }); + + it('should set isRequestingUserAssociated to true for each case', async () => { + processUserAssociatedCases(mockFoundCasesList); + + expect(MOCK_CASE.isRequestingUserAssociated).toBe(true); + }); + + it('should add a case to casesAssociatedWithUserOrLeadCaseMap when it is a lead case', async () => { + mockFoundCasesList = [{ ...MOCK_CASE, isLeadCase: true }]; + + const result = processUserAssociatedCases(mockFoundCasesList); + + expect( + result.casesAssociatedWithUserOrLeadCaseMap[MOCK_CASE.caseId], + ).toEqual({ ...MOCK_CASE, isLeadCase: true }); + }); + + it('should add a case to casesAssociatedWithUserOrLeadCaseMap when it does not have a leadCaseId', async () => { + const result = processUserAssociatedCases(mockFoundCasesList); + + expect( + result.casesAssociatedWithUserOrLeadCaseMap[MOCK_CASE.caseId], + ).toEqual(MOCK_CASE); + }); + + it("should add a case's caseId to userAssociatedCaseIdsMap", async () => { + const result = processUserAssociatedCases(mockFoundCasesList); + + expect(result.userAssociatedCaseIdsMap[MOCK_CASE.caseId]).toEqual(true); + }); + + it('should add a case to leadCaseIdsAssociatedWithUser if it has a leadCaseId and is not associated with the user', async () => { + let mockCaseWithLeadCaseId = { + ...MOCK_CASE, + leadCaseId: applicationContext.getUniqueId(), + }; + mockFoundCasesList = [mockCaseWithLeadCaseId]; + + const result = processUserAssociatedCases(mockFoundCasesList); + + expect( + result.leadCaseIdsAssociatedWithUser.includes( + mockCaseWithLeadCaseId.leadCaseId.toString(), + ), + ).toBe(true); + }); + + it('should populate casesAssociatedWithUserOrLeadCaseMap, leadCaseIdsAssociatedWithUser and userAssociatedCaseIdsMap', async () => { + let mockCaseWithLeadCaseId = { + ...MOCK_CASE, + isLeadCase: true, + leadCaseId: applicationContext.getUniqueId(), + }; + mockFoundCasesList = [mockCaseWithLeadCaseId, MOCK_CASE]; + + const result = processUserAssociatedCases(mockFoundCasesList); + + expect(result.casesAssociatedWithUserOrLeadCaseMap).not.toBe({}); + expect(result.leadCaseIdsAssociatedWithUser.length).toBe(1); + expect(result.userAssociatedCaseIdsMap).not.toBe({}); + }); +}); diff --git a/shared/src/business/useCaseHelper/service/sendServedPartiesEmails.js b/shared/src/business/useCaseHelper/service/sendServedPartiesEmails.js index 04aab1cb469..3b96f454fe8 100644 --- a/shared/src/business/useCaseHelper/service/sendServedPartiesEmails.js +++ b/shared/src/business/useCaseHelper/service/sendServedPartiesEmails.js @@ -2,6 +2,7 @@ const { reactTemplateGenerator, } = require('../../utilities/generateHTMLTemplateForPDF/reactTemplateGenerator'); const { Case } = require('../../entities/cases/Case'); +const { CASE_STATUS_TYPES } = require('../../entities/EntityConstants'); exports.sendServedPartiesEmails = async ({ applicationContext, @@ -29,7 +30,7 @@ exports.sendServedPartiesEmails = async ({ .formatNow('MMMM D, YYYY'); //serve every document on IRS superuser if case has been served to the IRS - if (caseEntity.status !== Case.STATUS_TYPES.new) { + if (caseEntity.status !== CASE_STATUS_TYPES.new) { servedParties.electronic.push({ email: applicationContext.getIrsSuperuserEmail(), name: 'IRS', diff --git a/shared/src/business/useCaseHelper/service/sendServedPartiesEmails.test.js b/shared/src/business/useCaseHelper/service/sendServedPartiesEmails.test.js index 04d6c845215..64042fb37fd 100644 --- a/shared/src/business/useCaseHelper/service/sendServedPartiesEmails.test.js +++ b/shared/src/business/useCaseHelper/service/sendServedPartiesEmails.test.js @@ -1,7 +1,7 @@ const { applicationContext, } = require('../../test/createTestApplicationContext'); -const { Case } = require('../../entities/cases/Case'); +const { CASE_STATUS_TYPES } = require('../../entities/EntityConstants'); const { sendServedPartiesEmails } = require('./sendServedPartiesEmails'); describe('sendServedPartiesEmails', () => { @@ -18,7 +18,7 @@ describe('sendServedPartiesEmails', () => { caseCaption: 'A Caption', docketNumber: '123-20', docketRecord: [{ documentId: '0c745ceb-364a-4a1e-83b0-061f6f96a360' }], - status: Case.STATUS_TYPES.generalDocket, + status: CASE_STATUS_TYPES.generalDocket, }, documentEntity: { documentId: '0c745ceb-364a-4a1e-83b0-061f6f96a360', @@ -53,7 +53,7 @@ describe('sendServedPartiesEmails', () => { caseCaption: 'A Caption', docketNumber: '123-20', docketRecord: [{ documentId: '0c745ceb-364a-4a1e-83b0-061f6f96a360' }], - status: Case.STATUS_TYPES.new, + status: CASE_STATUS_TYPES.new, }, documentEntity: { documentId: '0c745ceb-364a-4a1e-83b0-061f6f96a360', @@ -84,7 +84,7 @@ describe('sendServedPartiesEmails', () => { caseCaption: 'A Caption', docketNumber: '123-20', docketRecord: [{ documentId: '0c745ceb-364a-4a1e-83b0-061f6f96a360' }], - status: Case.STATUS_TYPES.generalDocket, + status: CASE_STATUS_TYPES.generalDocket, }, documentEntity: { documentId: '0c745ceb-364a-4a1e-83b0-061f6f96a360', diff --git a/shared/src/business/useCases/addCoversheetInteractor.js b/shared/src/business/useCases/addCoversheetInteractor.js index b537a8dafba..88f66b16fd5 100644 --- a/shared/src/business/useCases/addCoversheetInteractor.js +++ b/shared/src/business/useCases/addCoversheetInteractor.js @@ -1,6 +1,3 @@ -const { - generateCoverPagePdf, -} = require('../utilities/generateHTMLTemplateForPDF/generateCoverPagePdf'); const { Case } = require('../entities/cases/Case'); /** @@ -10,22 +7,23 @@ const { Case } = require('../entities/cases/Case'); * @param {object} options.applicationContext the application context * @param {string} options.caseEntity the case entity associated with the document we are creating the cover for * @param {object} options.documentEntity the document entity we are creating the cover for + * @param {boolean} options.useInitialData whether to use the initial docket record suffix and case caption * @returns {object} the key/value pairs of computed strings */ exports.generateCoverSheetData = ({ applicationContext, caseEntity, documentEntity, + useInitialData, }) => { const isLodged = documentEntity.lodged; - const { isPaper } = documentEntity; + const { certificateOfService, isPaper } = documentEntity; const dateServedFormatted = (documentEntity.servedAt && - 'Served ' + - applicationContext - .getUtilities() - .formatDateString(documentEntity.servedAt, 'MMDDYYYY')) || + applicationContext + .getUtilities() + .formatDateString(documentEntity.servedAt, 'MMDDYYYY')) || ''; let dateReceivedFormatted; @@ -53,7 +51,15 @@ exports.generateCoverSheetData = ({ .formatDateString(documentEntity.filingDate, 'MMDDYYYY')) || ''; - const caseCaption = caseEntity.caseCaption || Case.getCaseCaption(caseEntity); + const caseCaptionToUse = useInitialData + ? caseEntity.initialCaption + : caseEntity.caseCaption; + + const docketNumberSuffixToUse = useInitialData + ? caseEntity.initialDocketNumberSuffix.replace('_', '') + : caseEntity.docketNumberSuffix; + + const caseCaption = caseCaptionToUse || Case.getCaseCaption(caseEntity); let caseTitle = applicationContext.getCaseTitle(caseCaption); let caseCaptionExtension = ''; if (caseTitle !== caseCaption) { @@ -68,22 +74,19 @@ exports.generateCoverSheetData = ({ } const docketNumberWithSuffix = - caseEntity.docketNumber + (caseEntity.docketNumberSuffix || ''); + caseEntity.docketNumber + (docketNumberSuffixToUse || ''); const coverSheetData = { caseCaptionExtension, caseTitle, - certificateOfService: - documentEntity.certificateOfService === true - ? 'Certificate of Service' - : '', + certificateOfService, dateFiledLodged: dateFiledFormatted, dateFiledLodgedLabel: isLodged ? 'Lodged' : 'Filed', dateReceived: dateReceivedFormatted, dateServed: dateServedFormatted, docketNumber: `Docket Number: ${docketNumberWithSuffix}`, documentTitle, - electronicallyFiled: documentEntity.isPaper ? '' : 'Electronically Filed', + electronicallyFiled: !documentEntity.isPaper, mailingDate: documentEntity.mailingDate || '', }; return coverSheetData; @@ -104,11 +107,13 @@ exports.addCoverToPdf = async ({ documentEntity, pdfData, replaceCoversheet = false, + useInitialData = false, }) => { const coverSheetData = exports.generateCoverSheetData({ applicationContext, caseEntity, documentEntity, + useInitialData, }); const { PDFDocument } = await applicationContext.getPdfLib(); @@ -118,10 +123,12 @@ exports.addCoverToPdf = async ({ // allow GC to clear original loaded pdf data pdfData = null; - const coverPagePdf = await generateCoverPagePdf({ - applicationContext, - content: coverSheetData, - }); + const coverPagePdf = await applicationContext + .getDocumentGenerators() + .coverSheet({ + applicationContext, + data: coverSheetData, + }); const coverPageDocument = await PDFDocument.load(coverPagePdf); const coverPageDocumentPages = await pdfDoc.copyPages( @@ -158,6 +165,7 @@ exports.addCoversheetInteractor = async ({ caseId, documentId, replaceCoversheet = false, + useInitialData = false, }) => { const caseRecord = await applicationContext .getPersistenceGateway() @@ -192,6 +200,7 @@ exports.addCoversheetInteractor = async ({ documentEntity, pdfData, replaceCoversheet, + useInitialData, }); documentEntity.setAsProcessingStatusAsCompleted(); diff --git a/shared/src/business/useCases/addCoversheetInteractor.test.js b/shared/src/business/useCases/addCoversheetInteractor.test.js index 914ea15ac56..749d5ea7571 100644 --- a/shared/src/business/useCases/addCoversheetInteractor.test.js +++ b/shared/src/business/useCases/addCoversheetInteractor.test.js @@ -5,12 +5,7 @@ const { generateCoverSheetData, } = require('./addCoversheetInteractor.js'); const { applicationContext } = require('../test/createTestApplicationContext'); -const { ContactFactory } = require('../entities/contacts/ContactFactory'); - -jest.mock('../utilities/generateHTMLTemplateForPDF/generateCoverPagePdf'); -const { - generateCoverPagePdf, -} = require('../utilities/generateHTMLTemplateForPDF/generateCoverPagePdf'); +const { PARTY_TYPES } = require('../entities/EntityConstants'); describe('addCoversheetInteractor', () => { const testAssetsPath = path.join(__dirname, '../../../test-assets/'); @@ -42,7 +37,7 @@ describe('addCoversheetInteractor', () => { userId: '02323349-87fe-4d29-91fe-8dd6916d2fda', }, ], - partyType: ContactFactory.PARTY_TYPES.petitioner, + partyType: PARTY_TYPES.petitioner, }; const optionalTestingCaseData = { @@ -69,14 +64,12 @@ describe('addCoversheetInteractor', () => { lodged: true, }, ], - partyType: ContactFactory.PARTY_TYPES.petitionerSpouse, + partyType: PARTY_TYPES.petitionerSpouse, }; beforeAll(() => { jest.setTimeout(30000); - generateCoverPagePdf.mockImplementation(testPdfDocBytes); - applicationContext.getStorageClient().getObject.mockReturnValue({ promise: async () => ({ Body: testPdfDoc, @@ -97,6 +90,9 @@ describe('addCoversheetInteractor', () => { await addCoversheetInteractor(params); + expect( + applicationContext.getDocumentGenerators().coverSheet, + ).toHaveBeenCalled(); expect( applicationContext.getPersistenceGateway().saveDocumentFromLambda, ).toHaveBeenCalled(); @@ -116,6 +112,9 @@ describe('addCoversheetInteractor', () => { await addCoversheetInteractor(params); + expect( + applicationContext.getDocumentGenerators().coverSheet, + ).toHaveBeenCalled(); expect( applicationContext.getPersistenceGateway().saveDocumentFromLambda, ).toHaveBeenCalled(); @@ -211,7 +210,7 @@ describe('addCoversheetInteractor', () => { lodged: true, }, ], - partyType: ContactFactory.PARTY_TYPES.petitionerSpouse, + partyType: PARTY_TYPES.petitionerSpouse, }; it('displays Certificate of Service when the document is filed with a certificate of service', async () => { @@ -234,7 +233,7 @@ describe('addCoversheetInteractor', () => { }, }); - expect(result.certificateOfService).toEqual('Certificate of Service'); + expect(result.certificateOfService).toEqual(true); }); it('does NOT display Certificate of Service when the document is filed without a certificate of service', async () => { @@ -256,7 +255,7 @@ describe('addCoversheetInteractor', () => { isPaper: true, }, }); - expect(result.certificateOfService).toEqual(''); + expect(result.certificateOfService).toEqual(false); }); it('generates correct filed date', async () => { @@ -446,7 +445,7 @@ describe('addCoversheetInteractor', () => { expect(result.dateReceived).toEqual(''); }); - it('displays the date served if present in MMDDYYYY format along with a Served label', async () => { + it('displays the date served if present in MMDDYYYY format', async () => { const result = generateCoverSheetData({ applicationContext, caseEntity: { @@ -468,7 +467,7 @@ describe('addCoversheetInteractor', () => { }, }); - expect(result.dateServed).toEqual('Served 04/20/2019'); + expect(result.dateServed).toEqual('04/20/2019'); }); it('does not display the service date if servedAt is not present', async () => { @@ -564,7 +563,7 @@ describe('addCoversheetInteractor', () => { }, }); - expect(result.electronicallyFiled).toEqual('Electronically Filed'); + expect(result.electronicallyFiled).toEqual(true); }); it('does NOT display Electronically Filed when the document is filed by paper', async () => { @@ -587,7 +586,7 @@ describe('addCoversheetInteractor', () => { }, }); - expect(result.electronicallyFiled).toEqual(''); + expect(result.electronicallyFiled).toEqual(false); }); it('returns the mailing date if present', async () => { @@ -705,5 +704,33 @@ describe('addCoversheetInteractor', () => { expect(result.caseCaptionExtension).toEqual(''); }); + + it('preserves the original case caption and docket number when the useInitialData is true', () => { + const result = generateCoverSheetData({ + applicationContext, + caseEntity: { + ...caseData, + caseCaption: 'Janie Petitioner, Petitioner', + docketNumberSuffix: 'S', + initialCaption: 'Janie and Jackie Petitioner, Petitioners', + initialDocketNumberSuffix: 'Z', + }, + documentEntity: { + ...testingCaseData.documents[0], + addToCoversheet: true, + additionalInfo: 'Additional Info Something', + certificateOfService: true, + documentId: 'b6b81f4d-1e47-423a-8caf-6d2fdc3d3858', + documentType: + 'Motion for Entry of Order that Undenied Allegations be Deemed Admitted Pursuant to Rule 37(c)', + isPaper: false, + lodged: true, + }, + useInitialData: true, + }); + + expect(result.docketNumber).toEqual('Docket Number: 102-19Z'); + expect(result.caseTitle).toEqual('Janie and Jackie Petitioner, '); + }); }); }); diff --git a/shared/src/business/useCases/archiveDraftDocumentInteractor.test.js b/shared/src/business/useCases/archiveDraftDocumentInteractor.test.js index 8986ea0c33c..f909cd98f01 100644 --- a/shared/src/business/useCases/archiveDraftDocumentInteractor.test.js +++ b/shared/src/business/useCases/archiveDraftDocumentInteractor.test.js @@ -3,7 +3,7 @@ const { } = require('./archiveDraftDocumentInteractor'); const { applicationContext } = require('../test/createTestApplicationContext'); const { MOCK_CASE } = require('../../test/mockCase'); -const { User } = require('../entities/User'); +const { ROLES } = require('../entities/EntityConstants'); describe('archiveDraftDocumentInteractor', () => { it('returns an unauthorized error on non petitionsclerk users', async () => { @@ -20,7 +20,7 @@ describe('archiveDraftDocumentInteractor', () => { it('expect the updated case to contain the archived document', async () => { applicationContext.getCurrentUser.mockReturnValue({ - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, }); applicationContext .getPersistenceGateway() diff --git a/shared/src/business/useCases/blockCaseFromTrialInteractor.test.js b/shared/src/business/useCases/blockCaseFromTrialInteractor.test.js index ee9bd830af5..715748fd1b9 100644 --- a/shared/src/business/useCases/blockCaseFromTrialInteractor.test.js +++ b/shared/src/business/useCases/blockCaseFromTrialInteractor.test.js @@ -3,12 +3,12 @@ const { } = require('./blockCaseFromTrialInteractor'); const { applicationContext } = require('../test/createTestApplicationContext'); const { MOCK_CASE } = require('../../test/mockCase'); -const { User } = require('../entities/User'); +const { ROLES } = require('../entities/EntityConstants'); describe('blockCaseFromTrialInteractor', () => { beforeEach(() => { applicationContext.getCurrentUser.mockReturnValue({ - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: 'petitionsclerk', }); applicationContext diff --git a/shared/src/business/useCases/caseAssociation/deleteCounselFromCaseInteractor.js b/shared/src/business/useCases/caseAssociation/deleteCounselFromCaseInteractor.js index 6cb31cf71b7..05a8159b3a4 100644 --- a/shared/src/business/useCases/caseAssociation/deleteCounselFromCaseInteractor.js +++ b/shared/src/business/useCases/caseAssociation/deleteCounselFromCaseInteractor.js @@ -3,8 +3,8 @@ const { ROLE_PERMISSIONS, } = require('../../../authorization/authorizationClientService'); const { Case } = require('../../entities/cases/Case'); +const { ROLES } = require('../../entities/EntityConstants'); const { UnauthorizedError } = require('../../../errors/errors'); -const { User } = require('../../entities/User'); /** * deleteCounselFromCaseInteractor @@ -42,9 +42,9 @@ exports.deleteCounselFromCaseInteractor = async ({ const caseEntity = new Case(caseToUpdate, { applicationContext }); - if (userToDelete.role === User.ROLES.privatePractitioner) { + if (userToDelete.role === ROLES.privatePractitioner) { caseEntity.removePrivatePractitioner(userToDelete); - } else if (userToDelete.role === User.ROLES.irsPractitioner) { + } else if (userToDelete.role === ROLES.irsPractitioner) { caseEntity.removeIrsPractitioner(userToDelete); } else { throw new Error('User is not a practitioner'); diff --git a/shared/src/business/useCases/caseAssociation/deleteCounselFromCaseInteractor.test.js b/shared/src/business/useCases/caseAssociation/deleteCounselFromCaseInteractor.test.js index 19164ae9778..d1ff01fe585 100644 --- a/shared/src/business/useCases/caseAssociation/deleteCounselFromCaseInteractor.test.js +++ b/shared/src/business/useCases/caseAssociation/deleteCounselFromCaseInteractor.test.js @@ -5,49 +5,49 @@ const { deleteCounselFromCaseInteractor, } = require('./deleteCounselFromCaseInteractor'); const { MOCK_CASE } = require('../../../test/mockCase.js'); -const { User } = require('../../entities/User'); +const { ROLES } = require('../../entities/EntityConstants'); describe('deleteCounselFromCaseInteractor', () => { const mockPrivatePractitioners = [ { - role: User.ROLES.privatePractitioner, + role: ROLES.privatePractitioner, userId: '02f8a9cf-3bc8-4c91-a765-2f19013cd004', }, { - role: User.ROLES.privatePractitioner, + role: ROLES.privatePractitioner, userId: '141d4c7c-4302-465d-89bd-3bc8ae16f07d', }, { - role: User.ROLES.privatePractitioner, + role: ROLES.privatePractitioner, userId: '6de95584-fbf2-42d7-bd81-bf9e10633404', }, ]; const mockIrsPractitioners = [ { - role: User.ROLES.irsPractitioner, + role: ROLES.irsPractitioner, userId: '547f2148-3bb8-408b-bbaa-40d53f14f924', }, { - role: User.ROLES.irsPractitioner, + role: ROLES.irsPractitioner, userId: 'bfd97089-cda0-45e0-8454-dd879023d0af', }, { - role: User.ROLES.irsPractitioner, + role: ROLES.irsPractitioner, userId: '55c50d5d-b2eb-466e-9775-d0e1b464472d', }, ]; const mockPetitioners = [ { - role: User.ROLES.petitioner, + role: ROLES.petitioner, userId: '835f072c-5ea1-493c-acb8-d67b05c96f85', }, ]; beforeEach(() => { applicationContext.getCurrentUser.mockReturnValue({ - role: User.ROLES.docketClerk, + role: ROLES.docketClerk, userId: 'fb39f224-7985-438d-8327-2df162c20c8e', }); @@ -72,7 +72,7 @@ describe('deleteCounselFromCaseInteractor', () => { it('returns an unauthorized error for a petitioner user', async () => { applicationContext.getCurrentUser.mockReturnValue({ - role: User.ROLES.petitioner, + role: ROLES.petitioner, }); await expect( diff --git a/shared/src/business/useCases/caseAssociation/updateCounselOnCaseInteractor.js b/shared/src/business/useCases/caseAssociation/updateCounselOnCaseInteractor.js index 251bbe5ffe8..d7b4ed0df11 100644 --- a/shared/src/business/useCases/caseAssociation/updateCounselOnCaseInteractor.js +++ b/shared/src/business/useCases/caseAssociation/updateCounselOnCaseInteractor.js @@ -3,8 +3,8 @@ const { ROLE_PERMISSIONS, } = require('../../../authorization/authorizationClientService'); const { Case } = require('../../entities/cases/Case'); +const { ROLES } = require('../../entities/EntityConstants'); const { UnauthorizedError } = require('../../../errors/errors'); -const { User } = require('../../entities/User'); /** * updateCounselOnCaseInteractor @@ -50,12 +50,12 @@ exports.updateCounselOnCaseInteractor = async ({ const caseEntity = new Case(caseToUpdate, { applicationContext }); - if (userToUpdate.role === User.ROLES.privatePractitioner) { + if (userToUpdate.role === ROLES.privatePractitioner) { caseEntity.updatePrivatePractitioner({ userId: userToUpdate.userId, ...editableFields, }); - } else if (userToUpdate.role === User.ROLES.irsPractitioner) { + } else if (userToUpdate.role === ROLES.irsPractitioner) { caseEntity.updateIrsPractitioner({ userId: userToUpdate.userId, ...editableFields, diff --git a/shared/src/business/useCases/caseAssociation/updateCounselOnCaseInteractor.test.js b/shared/src/business/useCases/caseAssociation/updateCounselOnCaseInteractor.test.js index e6049ed6891..b62f860ba42 100644 --- a/shared/src/business/useCases/caseAssociation/updateCounselOnCaseInteractor.test.js +++ b/shared/src/business/useCases/caseAssociation/updateCounselOnCaseInteractor.test.js @@ -7,49 +7,49 @@ const { const { IrsPractitioner } = require('../../entities/IrsPractitioner'); const { MOCK_CASE } = require('../../../test/mockCase.js'); const { PrivatePractitioner } = require('../../entities/PrivatePractitioner'); -const { User } = require('../../entities/User'); +const { ROLES } = require('../../entities/EntityConstants'); describe('updateCounselOnCaseInteractor', () => { const mockPrivatePractitioners = [ new PrivatePractitioner({ - role: User.ROLES.privatePractitioner, + role: ROLES.privatePractitioner, userId: 'e23e2d08-561b-4930-a2e0-1f342a481268', }), new PrivatePractitioner({ - role: User.ROLES.privatePractitioner, + role: ROLES.privatePractitioner, userId: '9d914ca2-7876-43a7-acfa-ccb645717e11', }), new PrivatePractitioner({ - role: User.ROLES.privatePractitioner, + role: ROLES.privatePractitioner, userId: '4cae261f-3653-4d2f-8d8c-31f03df62e54', }), ]; const mockIrsPractitioners = [ new IrsPractitioner({ - role: User.ROLES.irsPractitioner, + role: ROLES.irsPractitioner, userId: '9a4390b3-9d1a-4987-b918-312675956bcc', }), new IrsPractitioner({ - role: User.ROLES.irsPractitioner, + role: ROLES.irsPractitioner, userId: '76c86b6b-6aad-4128-8fa2-53c5735cc0af', }), new IrsPractitioner({ - role: User.ROLES.irsPractitioner, + role: ROLES.irsPractitioner, userId: 'dd60c66f-2f82-4f8f-824a-d15a3e8e49a3', }), ]; const mockPetitioners = [ { - role: User.ROLES.petitioner, + role: ROLES.petitioner, userId: 'aa335271-9a0f-4ad5-bcf1-3b89bd8b5dd6', }, ]; beforeEach(() => { applicationContext.getCurrentUser.mockReturnValue({ - role: User.ROLES.docketClerk, + role: ROLES.docketClerk, userId: '001', }); applicationContext diff --git a/shared/src/business/useCases/caseAssociation/userIsAssociatedInteractor.js b/shared/src/business/useCases/caseAssociation/userIsAssociatedInteractor.js index c5c3f6b79af..66545234873 100644 --- a/shared/src/business/useCases/caseAssociation/userIsAssociatedInteractor.js +++ b/shared/src/business/useCases/caseAssociation/userIsAssociatedInteractor.js @@ -1,4 +1,4 @@ -const { User } = require('../../entities/User'); +const { ROLES } = require('../../entities/EntityConstants'); /** * userIsAssociated * @@ -15,14 +15,12 @@ exports.userIsAssociated = ({ caseDetail, user }) => { return true; } - if ( - ![User.ROLES.irsPractitioner, User.ROLES.privatePractitioner].includes(role) - ) { + if (![ROLES.irsPractitioner, ROLES.privatePractitioner].includes(role)) { return false; } let association; - if (role === User.ROLES.irsPractitioner) { + if (role === ROLES.irsPractitioner) { association = 'irsPractitioners'; } else { association = 'privatePractitioners'; diff --git a/shared/src/business/useCases/caseAssociation/userIsAssociatedInteractor.test.js b/shared/src/business/useCases/caseAssociation/userIsAssociatedInteractor.test.js index e395750ac9f..e910a1589d0 100644 --- a/shared/src/business/useCases/caseAssociation/userIsAssociatedInteractor.test.js +++ b/shared/src/business/useCases/caseAssociation/userIsAssociatedInteractor.test.js @@ -1,7 +1,7 @@ const { applicationContext, } = require('../../test/createTestApplicationContext'); -const { User } = require('../../entities/User'); +const { ROLES } = require('../../entities/EntityConstants'); const { userIsAssociated } = require('./userIsAssociatedInteractor'); describe('userIsAssociated', () => { @@ -11,7 +11,7 @@ describe('userIsAssociated', () => { userId: 'abc-123', }; const user = { - role: User.ROLES.privatePractitioner, + role: ROLES.privatePractitioner, userId: 'abc-123', }; @@ -30,14 +30,14 @@ describe('userIsAssociated', () => { userId: 'def-321', }; const user = { - role: User.ROLES.privatePractitioner, + role: ROLES.privatePractitioner, userId: 'abc-123', }; const result = userIsAssociated({ applicationContext, caseDetail, user }); expect(result).toEqual(true); - user.role = User.ROLES.privatePractitioner; + user.role = ROLES.privatePractitioner; caseDetail.irsPractitioners = [{ userId: 'abc-123' }]; const result2 = userIsAssociated({ applicationContext, caseDetail, user }); @@ -54,7 +54,7 @@ describe('userIsAssociated', () => { userId: 'def-321', }; const user = { - role: User.ROLES.privatePractitioner, + role: ROLES.privatePractitioner, userId: 'abc-123', }; @@ -68,7 +68,7 @@ describe('userIsAssociated', () => { userId: 'def-321', }; const user = { - role: User.ROLES.docketClerk, + role: ROLES.docketClerk, userId: 'abc-123', }; diff --git a/shared/src/business/useCases/caseAssociationRequest/submitCaseAssociationRequestInteractor.js b/shared/src/business/useCases/caseAssociationRequest/submitCaseAssociationRequestInteractor.js index b1dda7b9f2f..a7ee273cff2 100644 --- a/shared/src/business/useCases/caseAssociationRequest/submitCaseAssociationRequestInteractor.js +++ b/shared/src/business/useCases/caseAssociationRequest/submitCaseAssociationRequestInteractor.js @@ -8,8 +8,8 @@ const { isAuthorized, ROLE_PERMISSIONS, } = require('../../../authorization/authorizationClientService'); +const { ROLES } = require('../../entities/EntityConstants'); const { UnauthorizedError } = require('../../../errors/errors'); -const { User } = require('../../entities/User'); /** * submitCaseAssociationRequestInteractor @@ -42,8 +42,8 @@ exports.submitCaseAssociationRequestInteractor = async ({ .getUserById({ applicationContext, userId: authorizedUser.userId }); const isPrivatePractitioner = - authorizedUser.role === User.ROLES.privatePractitioner; - const isIrsPractitioner = authorizedUser.role === User.ROLES.irsPractitioner; + authorizedUser.role === ROLES.privatePractitioner; + const isIrsPractitioner = authorizedUser.role === ROLES.irsPractitioner; if (isPrivatePractitioner) { return await associatePrivatePractitionerToCase({ diff --git a/shared/src/business/useCases/caseAssociationRequest/submitCaseAssociationRequestInteractor.test.js b/shared/src/business/useCases/caseAssociationRequest/submitCaseAssociationRequestInteractor.test.js index 48aa205537b..aa279b1bb52 100644 --- a/shared/src/business/useCases/caseAssociationRequest/submitCaseAssociationRequestInteractor.test.js +++ b/shared/src/business/useCases/caseAssociationRequest/submitCaseAssociationRequestInteractor.test.js @@ -5,7 +5,7 @@ const { submitCaseAssociationRequestInteractor, } = require('./submitCaseAssociationRequestInteractor'); const { MOCK_CASE } = require('../../../test/mockCase.js'); -const { User } = require('../../entities/User'); +const { ROLES } = require('../../entities/EntityConstants'); describe('submitCaseAssociationRequest', () => { let caseRecord = { @@ -57,7 +57,7 @@ describe('submitCaseAssociationRequest', () => { it('should throw an error when not authorized', async () => { mockCurrentUser = { name: 'Emmett Lathrop "Doc" Brown, Ph.D.', - role: User.ROLES.adc, + role: ROLES.adc, userId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', }; @@ -73,7 +73,7 @@ describe('submitCaseAssociationRequest', () => { it('should not add mapping if already there', async () => { mockCurrentUser = { name: 'Emmett Lathrop "Doc" Brown, Ph.D.', - role: User.ROLES.privatePractitioner, + role: ROLES.privatePractitioner, userId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', }; mockGetUserById = { @@ -88,7 +88,7 @@ describe('submitCaseAssociationRequest', () => { state: 'IL', }, name: 'Emmett Lathrop "Doc" Brown, Ph.D.', - role: User.ROLES.privatePractitioner, + role: ROLES.privatePractitioner, userId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', }; applicationContext @@ -121,7 +121,7 @@ describe('submitCaseAssociationRequest', () => { state: 'IL', }, name: 'Emmett Lathrop "Doc" Brown, Ph.D.', - role: User.ROLES.privatePractitioner, + role: ROLES.privatePractitioner, userId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', }; applicationContext @@ -145,7 +145,7 @@ describe('submitCaseAssociationRequest', () => { it('should add mapping for an irsPractitioner', async () => { mockCurrentUser = { name: 'Emmett Lathrop "Doc" Brown, Ph.D.', - role: User.ROLES.irsPractitioner, + role: ROLES.irsPractitioner, userId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', }; mockGetUserById = { @@ -160,7 +160,7 @@ describe('submitCaseAssociationRequest', () => { state: 'IL', }, name: 'Emmett Lathrop "Doc" Brown, Ph.D.', - role: User.ROLES.irsPractitioner, + role: ROLES.irsPractitioner, userId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', }; applicationContext diff --git a/shared/src/business/useCases/caseAssociationRequest/submitPendingCaseAssociationRequestInteractor.test.js b/shared/src/business/useCases/caseAssociationRequest/submitPendingCaseAssociationRequestInteractor.test.js index fa9bcc04a8b..ceb6163b7e9 100644 --- a/shared/src/business/useCases/caseAssociationRequest/submitPendingCaseAssociationRequestInteractor.test.js +++ b/shared/src/business/useCases/caseAssociationRequest/submitPendingCaseAssociationRequestInteractor.test.js @@ -4,7 +4,7 @@ const { const { submitPendingCaseAssociationRequestInteractor, } = require('./submitPendingCaseAssociationRequestInteractor'); -const { User } = require('../../entities/User'); +const { ROLES } = require('../../entities/EntityConstants'); describe('submitPendingCaseAssociationRequest', () => { let caseRecord = { @@ -15,7 +15,7 @@ describe('submitPendingCaseAssociationRequest', () => { it('should throw an error when not authorized', async () => { applicationContext.getCurrentUser.mockReturnValue({ name: 'Emmett Lathrop "Doc" Brown, Ph.D.', - role: User.ROLES.adc, + role: ROLES.adc, userId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', }); @@ -31,12 +31,12 @@ describe('submitPendingCaseAssociationRequest', () => { it('should not add mapping if already associated', async () => { applicationContext.getCurrentUser.mockReturnValue({ name: 'Emmett Lathrop "Doc" Brown, Ph.D.', - role: User.ROLES.privatePractitioner, + role: ROLES.privatePractitioner, userId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', }); applicationContext.getPersistenceGateway().getUserById.mockReturnValue({ name: 'Emmett Lathrop "Doc" Brown, Ph.D.', - role: User.ROLES.privatePractitioner, + role: ROLES.privatePractitioner, userId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', }); applicationContext diff --git a/shared/src/business/useCases/caseConsolidation/addConsolidatedCaseInteractor.test.js b/shared/src/business/useCases/caseConsolidation/addConsolidatedCaseInteractor.test.js index 6881c11a3a7..860b054ca26 100644 --- a/shared/src/business/useCases/caseConsolidation/addConsolidatedCaseInteractor.test.js +++ b/shared/src/business/useCases/caseConsolidation/addConsolidatedCaseInteractor.test.js @@ -5,7 +5,7 @@ const { applicationContext, } = require('../../test/createTestApplicationContext'); const { MOCK_CASE } = require('../../../test/mockCase'); -const { User } = require('../../entities/User'); +const { ROLES } = require('../../entities/EntityConstants'); let mockCases; @@ -61,7 +61,7 @@ describe('addConsolidatedCaseInteractor', () => { }; applicationContext.getCurrentUser.mockReturnValue({ - role: User.ROLES.docketClerk, + role: ROLES.docketClerk, }); applicationContext .getPersistenceGateway() @@ -84,7 +84,7 @@ describe('addConsolidatedCaseInteractor', () => { let error; applicationContext.getCurrentUser.mockReturnValue({ - role: User.ROLES.petitioner, + role: ROLES.petitioner, }); try { diff --git a/shared/src/business/useCases/caseConsolidation/removeConsolidatedCasesInteractor.test.js b/shared/src/business/useCases/caseConsolidation/removeConsolidatedCasesInteractor.test.js index 28beb64cd02..9ba873b6a67 100644 --- a/shared/src/business/useCases/caseConsolidation/removeConsolidatedCasesInteractor.test.js +++ b/shared/src/business/useCases/caseConsolidation/removeConsolidatedCasesInteractor.test.js @@ -5,7 +5,7 @@ const { removeConsolidatedCasesInteractor, } = require('./removeConsolidatedCasesInteractor'); const { MOCK_CASE } = require('../../../test/mockCase'); -const { User } = require('../../entities/User'); +const { ROLES } = require('../../entities/EntityConstants'); let mockCases; @@ -50,7 +50,7 @@ describe('removeConsolidatedCasesInteractor', () => { }; applicationContext.getCurrentUser.mockReturnValue({ - role: User.ROLES.docketClerk, + role: ROLES.docketClerk, }); applicationContext .getPersistenceGateway() @@ -73,7 +73,7 @@ describe('removeConsolidatedCasesInteractor', () => { let error; applicationContext.getCurrentUser.mockReturnValue({ - role: User.ROLES.petitioner, + role: ROLES.petitioner, }); try { diff --git a/shared/src/business/useCases/caseDeadline/createCaseDeadlineInteractor.test.js b/shared/src/business/useCases/caseDeadline/createCaseDeadlineInteractor.test.js index 5f01152b3b3..46d33e894d3 100644 --- a/shared/src/business/useCases/caseDeadline/createCaseDeadlineInteractor.test.js +++ b/shared/src/business/useCases/caseDeadline/createCaseDeadlineInteractor.test.js @@ -8,7 +8,8 @@ const { MOCK_CASE, MOCK_CASE_WITHOUT_PENDING, } = require('../../../test/mockCase'); -const { Case } = require('../../entities/cases/Case'); +const { AUTOMATIC_BLOCKED_REASONS } = require('../../entities/EntityConstants'); +const { ROLES } = require('../../entities/EntityConstants'); const { UnauthorizedError } = require('../../../errors/errors'); const { User } = require('../../entities/User'); @@ -24,7 +25,7 @@ describe('createCaseDeadlineInteractor', () => { beforeEach(() => { user = new User({ name: 'Test Petitionsclerk', - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: '6805d1ab-18d0-43ec-bafb-654e83405416', }); @@ -68,7 +69,7 @@ describe('createCaseDeadlineInteractor', () => { ).toMatchObject({ automaticBlocked: true, automaticBlockedDate: expect.anything(), - automaticBlockedReason: Case.AUTOMATIC_BLOCKED_REASONS.dueDate, + automaticBlockedReason: AUTOMATIC_BLOCKED_REASONS.dueDate, }); expect( applicationContext.getPersistenceGateway() @@ -92,7 +93,7 @@ describe('createCaseDeadlineInteractor', () => { ).toMatchObject({ automaticBlocked: true, automaticBlockedDate: expect.anything(), - automaticBlockedReason: Case.AUTOMATIC_BLOCKED_REASONS.pendingAndDueDate, + automaticBlockedReason: AUTOMATIC_BLOCKED_REASONS.pendingAndDueDate, }); expect( applicationContext.getPersistenceGateway() diff --git a/shared/src/business/useCases/caseDeadline/deleteCaseDeadlineInteractor.test.js b/shared/src/business/useCases/caseDeadline/deleteCaseDeadlineInteractor.test.js index 8ce8233e252..d7211706180 100644 --- a/shared/src/business/useCases/caseDeadline/deleteCaseDeadlineInteractor.test.js +++ b/shared/src/business/useCases/caseDeadline/deleteCaseDeadlineInteractor.test.js @@ -4,8 +4,9 @@ const { const { deleteCaseDeadlineInteractor, } = require('./deleteCaseDeadlineInteractor'); -const { Case } = require('../../entities/cases/Case'); +const { AUTOMATIC_BLOCKED_REASONS } = require('../../entities/EntityConstants'); const { MOCK_CASE_WITHOUT_PENDING } = require('../../../test/mockCase'); +const { ROLES } = require('../../entities/EntityConstants'); const { UnauthorizedError } = require('../../../errors/errors'); const { User } = require('../../entities/User'); @@ -30,7 +31,7 @@ describe('deleteCaseDeadlineInteractor', () => { beforeEach(() => { user = new User({ name: 'Test Petitionsclerk', - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: '6805d1ab-18d0-43ec-bafb-654e83405416', }); @@ -100,7 +101,7 @@ describe('deleteCaseDeadlineInteractor', () => { ).toMatchObject({ automaticBlocked: true, automaticBlockedDate: expect.anything(), - automaticBlockedReason: Case.AUTOMATIC_BLOCKED_REASONS.dueDate, + automaticBlockedReason: AUTOMATIC_BLOCKED_REASONS.dueDate, }); expect( applicationContext.getPersistenceGateway() diff --git a/shared/src/business/useCases/caseDeadline/getAllCaseDeadlinesInteractor.test.js b/shared/src/business/useCases/caseDeadline/getAllCaseDeadlinesInteractor.test.js index 55016996119..e60e8d53379 100644 --- a/shared/src/business/useCases/caseDeadline/getAllCaseDeadlinesInteractor.test.js +++ b/shared/src/business/useCases/caseDeadline/getAllCaseDeadlinesInteractor.test.js @@ -4,6 +4,7 @@ const { const { getAllCaseDeadlinesInteractor, } = require('./getAllCaseDeadlinesInteractor'); +const { ROLES } = require('../../entities/EntityConstants'); const { User } = require('../../entities/User'); describe('getAllCaseDeadlinesInteractor', () => { @@ -61,7 +62,7 @@ describe('getAllCaseDeadlinesInteractor', () => { it('gets all the case deadlines and combines them with case data', async () => { const mockPetitionsClerk = new User({ name: 'Test Petitionsclerk', - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: '6805d1ab-18d0-43ec-bafb-654e83405416', }); applicationContext.getCurrentUser.mockReturnValue(mockPetitionsClerk); diff --git a/shared/src/business/useCases/caseDeadline/getCaseDeadlinesForCaseInteractor.test.js b/shared/src/business/useCases/caseDeadline/getCaseDeadlinesForCaseInteractor.test.js index d35acbe8d8a..6847d585ae4 100644 --- a/shared/src/business/useCases/caseDeadline/getCaseDeadlinesForCaseInteractor.test.js +++ b/shared/src/business/useCases/caseDeadline/getCaseDeadlinesForCaseInteractor.test.js @@ -4,6 +4,7 @@ const { const { getCaseDeadlinesForCaseInteractor, } = require('./getCaseDeadlinesForCaseInteractor'); +const { ROLES } = require('../../entities/EntityConstants'); const { User } = require('../../entities/User'); describe('getCaseDeadlinesForCaseInteractor', () => { @@ -15,7 +16,7 @@ describe('getCaseDeadlinesForCaseInteractor', () => { const mockUser = new User({ name: 'Test Petitionsclerk', - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: '6805d1ab-18d0-43ec-bafb-654e83405416', }); diff --git a/shared/src/business/useCases/caseDeadline/updateCaseDeadlineInteractor.test.js b/shared/src/business/useCases/caseDeadline/updateCaseDeadlineInteractor.test.js index 2a10fac8b49..f5ee742b19e 100644 --- a/shared/src/business/useCases/caseDeadline/updateCaseDeadlineInteractor.test.js +++ b/shared/src/business/useCases/caseDeadline/updateCaseDeadlineInteractor.test.js @@ -4,6 +4,7 @@ const { const { updateCaseDeadlineInteractor, } = require('./updateCaseDeadlineInteractor'); +const { ROLES } = require('../../entities/EntityConstants'); const { UnauthorizedError } = require('../../../errors/errors'); const { User } = require('../../entities/User'); @@ -34,7 +35,7 @@ describe('updateCaseDeadlineInteractor', () => { it('updates a case deadline', async () => { const mockPetitionsClerk = new User({ name: 'Test Petitionsclerk', - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: '6805d1ab-18d0-43ec-bafb-654e83405416', }); applicationContext.environment.stage = 'local'; diff --git a/shared/src/business/useCases/caseInventoryReport/generatePrintableCaseInventoryReportInteractor.test.js b/shared/src/business/useCases/caseInventoryReport/generatePrintableCaseInventoryReportInteractor.test.js index e7d57c6f67c..055b0d8945c 100644 --- a/shared/src/business/useCases/caseInventoryReport/generatePrintableCaseInventoryReportInteractor.test.js +++ b/shared/src/business/useCases/caseInventoryReport/generatePrintableCaseInventoryReportInteractor.test.js @@ -4,12 +4,12 @@ const { const { generatePrintableCaseInventoryReportInteractor, } = require('./generatePrintableCaseInventoryReportInteractor'); -const { User } = require('../../entities/User'); +const { ROLES } = require('../../entities/EntityConstants'); describe('generatePrintableCaseInventoryReportInteractor', () => { it('calls generateCaseInventoryReportPdf function and returns result', async () => { applicationContext.getCurrentUser.mockReturnValue({ - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: 'petitionsclerk', }); applicationContext @@ -32,7 +32,7 @@ describe('generatePrintableCaseInventoryReportInteractor', () => { it('should throw an unauthorized error if the user does not have access', async () => { applicationContext.getCurrentUser.mockReturnValue({ - role: User.ROLES.petitioner, + role: ROLES.petitioner, userId: 'petitioner', }); @@ -46,7 +46,7 @@ describe('generatePrintableCaseInventoryReportInteractor', () => { it('should throw an error if associatedJudge and status are not passed in', async () => { applicationContext.getCurrentUser.mockReturnValue({ - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: 'petitionsclerk', }); diff --git a/shared/src/business/useCases/caseInventoryReport/getCaseInventoryReportInteractor.test.js b/shared/src/business/useCases/caseInventoryReport/getCaseInventoryReportInteractor.test.js index 421f511869e..db38144a438 100644 --- a/shared/src/business/useCases/caseInventoryReport/getCaseInventoryReportInteractor.test.js +++ b/shared/src/business/useCases/caseInventoryReport/getCaseInventoryReportInteractor.test.js @@ -4,19 +4,19 @@ const { const { getCaseInventoryReportInteractor, } = require('./getCaseInventoryReportInteractor'); -const { User } = require('../../entities/User'); +const { ROLES } = require('../../entities/EntityConstants'); describe('getCaseInventoryReportInteractor', () => { beforeEach(() => { applicationContext.getCurrentUser.mockReturnValue({ - role: User.ROLES.docketClerk, + role: ROLES.docketClerk, userId: '9754a349-1013-44fa-9e61-d39aba2637e0', }); }); it('throws an error if user is not authorized for case inventory report', async () => { applicationContext.getCurrentUser.mockReturnValue({ - role: User.ROLES.petitioner, //petitioner does not have CASE_INVENTORY_REPORT permission + role: ROLES.petitioner, //petitioner does not have CASE_INVENTORY_REPORT permission userId: '8e20dd1b-d142-40f4-8362-6297f1be68bf', }); diff --git a/shared/src/business/useCases/caseNote/deleteCaseNoteInteractor.test.js b/shared/src/business/useCases/caseNote/deleteCaseNoteInteractor.test.js index 9f1e4cdc207..8c91f2936dd 100644 --- a/shared/src/business/useCases/caseNote/deleteCaseNoteInteractor.test.js +++ b/shared/src/business/useCases/caseNote/deleteCaseNoteInteractor.test.js @@ -3,6 +3,7 @@ const { } = require('../../test/createTestApplicationContext'); const { deleteCaseNoteInteractor } = require('./deleteCaseNoteInteractor'); const { MOCK_CASE } = require('../../../test/mockCase'); +const { ROLES } = require('../../entities/EntityConstants'); const { UnauthorizedError } = require('../../../errors/errors'); const { User } = require('../../entities/User'); @@ -26,7 +27,7 @@ describe('deleteCaseNoteInteractor', () => { it('deletes a procedural note', async () => { const mockUser = new User({ name: 'Judge Armen', - role: User.ROLES.judge, + role: ROLES.judge, userId: '6805d1ab-18d0-43ec-bafb-654e83405416', }); diff --git a/shared/src/business/useCases/caseNote/deleteUserCaseNoteInteractor.test.js b/shared/src/business/useCases/caseNote/deleteUserCaseNoteInteractor.test.js index 8913b26b10c..91cb0a88fc4 100644 --- a/shared/src/business/useCases/caseNote/deleteUserCaseNoteInteractor.test.js +++ b/shared/src/business/useCases/caseNote/deleteUserCaseNoteInteractor.test.js @@ -4,6 +4,7 @@ const { const { deleteUserCaseNoteInteractor, } = require('./deleteUserCaseNoteInteractor'); +const { ROLES } = require('../../entities/EntityConstants'); const { UnauthorizedError } = require('../../../errors/errors'); const { User } = require('../../entities/User'); @@ -28,7 +29,7 @@ describe('deleteUserCaseNoteInteractor', () => { it('deletes a case note', async () => { const mockUser = new User({ name: 'Judge Armen', - role: User.ROLES.judge, + role: ROLES.judge, userId: '6805d1ab-18d0-43ec-bafb-654e83405416', }); @@ -37,7 +38,7 @@ describe('deleteUserCaseNoteInteractor', () => { applicationContext.getUseCases.mockReturnValue({ getJudgeForUserChambersInteractor: () => ({ - role: User.ROLES.judge, + role: ROLES.judge, userId: '6805d1ab-18d0-43ec-bafb-654e83405416', }), }); diff --git a/shared/src/business/useCases/caseNote/getUserCaseNoteForCasesInteractor.test.js b/shared/src/business/useCases/caseNote/getUserCaseNoteForCasesInteractor.test.js index 1224d270a66..60bc8c4ad10 100644 --- a/shared/src/business/useCases/caseNote/getUserCaseNoteForCasesInteractor.test.js +++ b/shared/src/business/useCases/caseNote/getUserCaseNoteForCasesInteractor.test.js @@ -5,8 +5,8 @@ const { getUserCaseNoteForCasesInteractor, } = require('./getUserCaseNoteForCasesInteractor'); const { omit } = require('lodash'); +const { ROLES } = require('../../entities/EntityConstants'); const { UnauthorizedError } = require('../../../errors/errors'); -const { User } = require('../../entities/User'); const MOCK_NOTE = { caseId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', @@ -15,7 +15,7 @@ const MOCK_NOTE = { }; const mockJudge = { - role: User.ROLES.judge, + role: ROLES.judge, userId: 'd7d90c05-f6cd-442c-a168-202db587f16f', }; diff --git a/shared/src/business/useCases/caseNote/getUserCaseNoteInteractor.test.js b/shared/src/business/useCases/caseNote/getUserCaseNoteInteractor.test.js index d0cb6cde476..5170b52b4ed 100644 --- a/shared/src/business/useCases/caseNote/getUserCaseNoteInteractor.test.js +++ b/shared/src/business/useCases/caseNote/getUserCaseNoteInteractor.test.js @@ -3,8 +3,8 @@ const { } = require('../../test/createTestApplicationContext'); const { getUserCaseNoteInteractor } = require('./getUserCaseNoteInteractor'); const { omit } = require('lodash'); +const { ROLES } = require('../../entities/EntityConstants'); const { UnauthorizedError } = require('../../../errors/errors'); -const { User } = require('../../entities/User'); const MOCK_NOTE = { caseId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', @@ -18,7 +18,7 @@ const mockUnauthorizedUser = { }; const mockJudge = { - role: User.ROLES.judge, + role: ROLES.judge, userId: 'd7d90c05-f6cd-442c-a168-202db587f16f', }; diff --git a/shared/src/business/useCases/caseNote/saveCaseNoteInteractor.test.js b/shared/src/business/useCases/caseNote/saveCaseNoteInteractor.test.js index ddf33b2ee14..ddfbac5ff1f 100644 --- a/shared/src/business/useCases/caseNote/saveCaseNoteInteractor.test.js +++ b/shared/src/business/useCases/caseNote/saveCaseNoteInteractor.test.js @@ -2,6 +2,7 @@ const { applicationContext, } = require('../../test/createTestApplicationContext'); const { MOCK_CASE } = require('../../../test/mockCase'); +const { ROLES } = require('../../entities/EntityConstants'); const { saveCaseNoteInteractor } = require('./saveCaseNoteInteractor'); const { UnauthorizedError } = require('../../../errors/errors'); const { User } = require('../../entities/User'); @@ -26,7 +27,7 @@ describe('saveCaseNoteInteractor', () => { it('saves a case note', async () => { const mockJudge = new User({ name: 'Judge Armen', - role: User.ROLES.judge, + role: ROLES.judge, userId: '6805d1ab-18d0-43ec-bafb-654e83405416', }); diff --git a/shared/src/business/useCases/caseNote/updateUserCaseNoteInteractor.test.js b/shared/src/business/useCases/caseNote/updateUserCaseNoteInteractor.test.js index e8e25998f73..1d9d9f1c9e9 100644 --- a/shared/src/business/useCases/caseNote/updateUserCaseNoteInteractor.test.js +++ b/shared/src/business/useCases/caseNote/updateUserCaseNoteInteractor.test.js @@ -4,6 +4,7 @@ const { const { updateUserCaseNoteInteractor, } = require('./updateUserCaseNoteInteractor'); +const { ROLES } = require('../../entities/EntityConstants'); const { UnauthorizedError } = require('../../../errors/errors'); const { User } = require('../../entities/User'); @@ -34,7 +35,7 @@ describe('updateUserCaseNoteInteractor', () => { it('updates a case note', async () => { const mockUser = new User({ name: 'Judge Armen', - role: User.ROLES.judge, + role: ROLES.judge, userId: '6805d1ab-18d0-43ec-bafb-654e83405416', }); applicationContext.getCurrentUser.mockReturnValue(mockUser); @@ -42,7 +43,7 @@ describe('updateUserCaseNoteInteractor', () => { v.caseNoteToUpdate; applicationContext.getUseCases.mockReturnValue({ getJudgeForUserChambersInteractor: () => ({ - role: User.ROLES.judge, + role: ROLES.judge, userId: '6805d1ab-18d0-43ec-bafb-654e83405416', }), }); diff --git a/shared/src/business/useCases/caseStatistics/addDeficiencyStatisticInteractor.test.js b/shared/src/business/useCases/caseStatistics/addDeficiencyStatisticInteractor.test.js index ab245a7858d..792798d0a12 100644 --- a/shared/src/business/useCases/caseStatistics/addDeficiencyStatisticInteractor.test.js +++ b/shared/src/business/useCases/caseStatistics/addDeficiencyStatisticInteractor.test.js @@ -5,12 +5,12 @@ const { applicationContext, } = require('../../test/createTestApplicationContext'); const { MOCK_CASE } = require('../../../test/mockCase'); -const { User } = require('../../entities/User'); +const { ROLES } = require('../../entities/EntityConstants'); describe('addDeficiencyStatisticInteractor', () => { beforeEach(() => { applicationContext.getCurrentUser.mockReturnValue({ - role: User.ROLES.docketClerk, + role: ROLES.docketClerk, userId: 'docketClerk', }); diff --git a/shared/src/business/useCases/caseStatistics/deleteDeficiencyStatisticInteractor.test.js b/shared/src/business/useCases/caseStatistics/deleteDeficiencyStatisticInteractor.test.js index 4b1b136f774..b2cb39dc98a 100644 --- a/shared/src/business/useCases/caseStatistics/deleteDeficiencyStatisticInteractor.test.js +++ b/shared/src/business/useCases/caseStatistics/deleteDeficiencyStatisticInteractor.test.js @@ -4,9 +4,9 @@ const { const { deleteDeficiencyStatisticInteractor, } = require('./deleteDeficiencyStatisticInteractor'); -const { Case } = require('../../entities/cases/Case'); +const { CASE_TYPES_MAP } = require('../../entities/EntityConstants'); const { MOCK_CASE } = require('../../../test/mockCase'); -const { User } = require('../../entities/User'); +const { ROLES } = require('../../entities/EntityConstants'); describe('deleteDeficiencyStatisticInteractor', () => { const statisticId = 'f7a1cdb5-f534-4d12-a046-86ca3b46ddc4'; @@ -23,7 +23,7 @@ describe('deleteDeficiencyStatisticInteractor', () => { beforeEach(() => { applicationContext.getCurrentUser.mockReturnValue({ - role: User.ROLES.docketClerk, + role: ROLES.docketClerk, userId: 'docketClerk', }); @@ -81,7 +81,7 @@ describe('deleteDeficiencyStatisticInteractor', () => { applicationContext.getPersistenceGateway().getCaseByCaseId.mockReturnValue( Promise.resolve({ ...MOCK_CASE, - caseType: Case.CASE_TYPES_MAP.deficiency, + caseType: CASE_TYPES_MAP.deficiency, hasVerifiedIrsNotice: true, statistics: [statistic], }), diff --git a/shared/src/business/useCases/caseStatistics/updateDeficiencyStatisticInteractor.test.js b/shared/src/business/useCases/caseStatistics/updateDeficiencyStatisticInteractor.test.js index ec89a97b434..848ef957825 100644 --- a/shared/src/business/useCases/caseStatistics/updateDeficiencyStatisticInteractor.test.js +++ b/shared/src/business/useCases/caseStatistics/updateDeficiencyStatisticInteractor.test.js @@ -5,7 +5,7 @@ const { updateDeficiencyStatisticInteractor, } = require('./updateDeficiencyStatisticInteractor'); const { MOCK_CASE } = require('../../../test/mockCase'); -const { User } = require('../../entities/User'); +const { ROLES } = require('../../entities/EntityConstants'); describe('updateDeficiencyStatisticInteractor', () => { let statistic = { @@ -20,7 +20,7 @@ describe('updateDeficiencyStatisticInteractor', () => { beforeEach(() => { applicationContext.getCurrentUser.mockReturnValue({ - role: User.ROLES.docketClerk, + role: ROLES.docketClerk, userId: 'docketClerk', }); diff --git a/shared/src/business/useCases/caseStatistics/updateOtherStatisticsInteractor.test.js b/shared/src/business/useCases/caseStatistics/updateOtherStatisticsInteractor.test.js index 8ca6e3dbb39..d1826359db4 100644 --- a/shared/src/business/useCases/caseStatistics/updateOtherStatisticsInteractor.test.js +++ b/shared/src/business/useCases/caseStatistics/updateOtherStatisticsInteractor.test.js @@ -5,12 +5,12 @@ const { updateOtherStatisticsInteractor, } = require('./updateOtherStatisticsInteractor'); const { MOCK_CASE } = require('../../../test/mockCase'); -const { User } = require('../../entities/User'); +const { ROLES } = require('../../entities/EntityConstants'); describe('updateOtherStatisticsInteractor', () => { beforeEach(() => { applicationContext.getCurrentUser.mockReturnValue({ - role: User.ROLES.docketClerk, + role: ROLES.docketClerk, userId: 'docketClerk', }); diff --git a/shared/src/business/useCases/checkForReadyForTrialCasesInteractor.js b/shared/src/business/useCases/checkForReadyForTrialCasesInteractor.js index f5e9a03c645..ec4921e4650 100644 --- a/shared/src/business/useCases/checkForReadyForTrialCasesInteractor.js +++ b/shared/src/business/useCases/checkForReadyForTrialCasesInteractor.js @@ -1,4 +1,5 @@ const { Case } = require('../entities/cases/Case'); +const { CASE_STATUS_TYPES } = require('../entities/EntityConstants'); const { createISODateString } = require('../utilities/DateHandler'); /** @@ -47,11 +48,11 @@ exports.checkForReadyForTrialCasesInteractor = async ({ if (caseToCheck) { const caseEntity = new Case(caseToCheck, { applicationContext }); - if (caseEntity.status === Case.STATUS_TYPES.generalDocket) { + if (caseEntity.status === CASE_STATUS_TYPES.generalDocket) { caseEntity.checkForReadyForTrial(); if ( - caseEntity.status === Case.STATUS_TYPES.generalDocketReadyForTrial + caseEntity.status === CASE_STATUS_TYPES.generalDocketReadyForTrial ) { updatedCases.push(updateForTrial(caseEntity)); } diff --git a/shared/src/business/useCases/checkForReadyForTrialCasesInteractor.test.js b/shared/src/business/useCases/checkForReadyForTrialCasesInteractor.test.js index d52c439c3ac..b1e194011f1 100644 --- a/shared/src/business/useCases/checkForReadyForTrialCasesInteractor.test.js +++ b/shared/src/business/useCases/checkForReadyForTrialCasesInteractor.test.js @@ -2,7 +2,7 @@ const { checkForReadyForTrialCasesInteractor, } = require('./checkForReadyForTrialCasesInteractor'); const { applicationContext } = require('../test/createTestApplicationContext'); -const { Case } = require('../entities/cases/Case'); +const { CASE_STATUS_TYPES } = require('../entities/EntityConstants'); const { MOCK_CASE } = require('../../test/mockCase'); const { MOCK_USERS } = require('../../test/mockUsers'); @@ -91,7 +91,7 @@ describe('checkForReadyForTrialCasesInteractor', () => { workItems: [], }, ], - status: Case.STATUS_TYPES.generalDocket, + status: CASE_STATUS_TYPES.generalDocket, }); applicationContext.getPersistenceGateway().updateCase.mockReturnValue({}); @@ -118,7 +118,7 @@ describe('checkForReadyForTrialCasesInteractor', () => { */ applicationContext.getPersistenceGateway().getCaseByCaseId.mockReturnValue({ ...MOCK_CASE, - status: Case.STATUS_TYPES.generalDocket, + status: CASE_STATUS_TYPES.generalDocket, }); applicationContext.getPersistenceGateway().updateCase.mockReturnValue({}); diff --git a/shared/src/business/useCases/correspondence/deleteCorrespondenceDocumentInteractor.test.js b/shared/src/business/useCases/correspondence/deleteCorrespondenceDocumentInteractor.test.js index f41ce76d7e3..d6a63046623 100644 --- a/shared/src/business/useCases/correspondence/deleteCorrespondenceDocumentInteractor.test.js +++ b/shared/src/business/useCases/correspondence/deleteCorrespondenceDocumentInteractor.test.js @@ -4,7 +4,7 @@ const { const { deleteCorrespondenceDocumentInteractor, } = require('./deleteCorrespondenceDocumentInteractor'); -const { User } = require('../../entities/User'); +const { ROLES } = require('../../entities/EntityConstants'); describe('deleteCorrespondenceDocumentInteractor', () => { let mockUser; @@ -12,14 +12,14 @@ describe('deleteCorrespondenceDocumentInteractor', () => { beforeEach(() => { mockUser = { name: 'Docket Clerk', - role: User.ROLES.docketClerk, + role: ROLES.docketClerk, userId: '2474e5c0-f741-4120-befa-b77378ac8bf0', }; applicationContext.getCurrentUser.mockImplementation(() => mockUser); }); it('should throw an Unauthorized error if the user role does not have the CASE_CORRESPONDENCE permission', async () => { - const user = { ...mockUser, role: User.ROLES.petitioner }; + const user = { ...mockUser, role: ROLES.petitioner }; applicationContext.getCurrentUser.mockReturnValue(user); await expect( diff --git a/shared/src/business/useCases/correspondence/fileCorrespondenceDocumentInteractor.test.js b/shared/src/business/useCases/correspondence/fileCorrespondenceDocumentInteractor.test.js index e24a130b775..bc67ec18854 100644 --- a/shared/src/business/useCases/correspondence/fileCorrespondenceDocumentInteractor.test.js +++ b/shared/src/business/useCases/correspondence/fileCorrespondenceDocumentInteractor.test.js @@ -1,19 +1,22 @@ const { applicationContext, } = require('../../test/createTestApplicationContext'); +const { + COUNTRY_TYPES, + PARTY_TYPES, + ROLES, +} = require('../../entities/EntityConstants'); const { fileCorrespondenceDocumentInteractor, } = require('./fileCorrespondenceDocumentInteractor'); -const { ContactFactory } = require('../../entities/contacts/ContactFactory'); const { createISODateString } = require('../../utilities/DateHandler'); -const { User } = require('../../entities/User'); describe('fileCorrespondenceDocumentInteractor', () => { const mockDocumentId = 'cf105788-5d34-4451-aa8d-dfd9a851b675'; const mockUser = { name: 'Docket Clerk', - role: User.ROLES.docketClerk, + role: ROLES.docketClerk, userId: '2474e5c0-f741-4120-befa-b77378ac8bf0', }; const mockCase = { @@ -23,7 +26,7 @@ describe('fileCorrespondenceDocumentInteractor', () => { contactPrimary: { address1: '123 Main St', city: 'Somewhere', - countryType: ContactFactory.COUNTRY_TYPES.DOMESTIC, + countryType: COUNTRY_TYPES.DOMESTIC, email: 'contact@example.com', name: 'Contact Primary', phone: '123123134', @@ -65,7 +68,7 @@ describe('fileCorrespondenceDocumentInteractor', () => { }, ], filingType: 'Myself', - partyType: ContactFactory.PARTY_TYPES.petitioner, + partyType: PARTY_TYPES.petitioner, preferredTrialCity: 'Fresno, California', procedureType: 'Regular', }; @@ -82,7 +85,7 @@ describe('fileCorrespondenceDocumentInteractor', () => { }); it('should throw an Unauthorized error if the user role does not have theCASE_CORRESPONDENCE permission', async () => { - const user = { ...mockUser, role: User.ROLES.petitioner }; + const user = { ...mockUser, role: ROLES.petitioner }; applicationContext.getCurrentUser.mockReturnValue(user); await expect( diff --git a/shared/src/business/useCases/correspondence/updateCorrespondenceDocumentInteractor.test.js b/shared/src/business/useCases/correspondence/updateCorrespondenceDocumentInteractor.test.js index ee3a178bc8a..86c519b4585 100644 --- a/shared/src/business/useCases/correspondence/updateCorrespondenceDocumentInteractor.test.js +++ b/shared/src/business/useCases/correspondence/updateCorrespondenceDocumentInteractor.test.js @@ -1,20 +1,23 @@ const { applicationContext, } = require('../../test/createTestApplicationContext'); +const { + COUNTRY_TYPES, + PARTY_TYPES, + ROLES, +} = require('../../entities/EntityConstants'); const { updateCorrespondenceDocumentInteractor, } = require('./updateCorrespondenceDocumentInteractor'); -const { ContactFactory } = require('../../entities/contacts/ContactFactory'); const { Correspondence } = require('../../entities/Correspondence'); const { createISODateString } = require('../../utilities/DateHandler'); -const { User } = require('../../entities/User'); describe('updateCorrespondenceDocumentInteractor', () => { let mockUser; const mockDocumentId = 'cf105788-5d34-4451-aa8d-dfd9a851b675'; const mockUserFixture = { name: 'Docket Clerk', - role: User.ROLES.docketClerk, + role: ROLES.docketClerk, userId: '2474e5c0-f741-4120-befa-b77378ac8bf0', }; const mockCorrespondence = new Correspondence({ @@ -30,7 +33,7 @@ describe('updateCorrespondenceDocumentInteractor', () => { contactPrimary: { address1: '123 Main St', city: 'Somewhere', - countryType: ContactFactory.COUNTRY_TYPES.DOMESTIC, + countryType: COUNTRY_TYPES.DOMESTIC, email: 'contact@example.com', name: 'Contact Primary', phone: '123123134', @@ -73,7 +76,7 @@ describe('updateCorrespondenceDocumentInteractor', () => { }, ], filingType: 'Myself', - partyType: ContactFactory.PARTY_TYPES.petitioner, + partyType: PARTY_TYPES.petitioner, preferredTrialCity: 'Fresno, California', procedureType: 'Regular', }; @@ -88,7 +91,7 @@ describe('updateCorrespondenceDocumentInteractor', () => { }); it('should throw an Unauthorized error if the user role does not have the CASE_CORRESPONDENCE permission', async () => { - mockUser = { ...mockUser, role: User.ROLES.petitioner }; + mockUser = { ...mockUser, role: ROLES.petitioner }; await expect( updateCorrespondenceDocumentInteractor({ diff --git a/shared/src/business/useCases/courtIssuedDocument/generateCourtIssuedDocumentTitleInteractor.js b/shared/src/business/useCases/courtIssuedDocument/generateCourtIssuedDocumentTitleInteractor.js index 3b77c40eaea..d564e2e9d45 100644 --- a/shared/src/business/useCases/courtIssuedDocument/generateCourtIssuedDocumentTitleInteractor.js +++ b/shared/src/business/useCases/courtIssuedDocument/generateCourtIssuedDocumentTitleInteractor.js @@ -1,7 +1,7 @@ const { CourtIssuedDocumentFactory, } = require('../../entities/courtIssuedDocument/CourtIssuedDocumentFactory'); -const { Document } = require('../../entities/Document'); +const { COURT_ISSUED_EVENT_CODES } = require('../../entities/EntityConstants'); /** * generateCourtIssuedDocumentTitleInteractor @@ -11,7 +11,7 @@ const { Document } = require('../../entities/Document'); * @returns {string} document title */ exports.generateCourtIssuedDocumentTitleInteractor = ({ documentMetadata }) => { - const filingEvent = Document.COURT_ISSUED_EVENT_CODES.find( + const filingEvent = COURT_ISSUED_EVENT_CODES.find( document => documentMetadata.eventCode === document.eventCode, ); diff --git a/shared/src/business/useCases/courtIssuedDocument/serveCourtIssuedDocumentInteractor.test.js b/shared/src/business/useCases/courtIssuedDocument/serveCourtIssuedDocumentInteractor.test.js index 1fa51e6b043..eceee7dc7e2 100644 --- a/shared/src/business/useCases/courtIssuedDocument/serveCourtIssuedDocumentInteractor.test.js +++ b/shared/src/business/useCases/courtIssuedDocument/serveCourtIssuedDocumentInteractor.test.js @@ -3,18 +3,20 @@ const path = require('path'); const { applicationContext, } = require('../../test/createTestApplicationContext'); +const { + CASE_STATUS_TYPES, + COUNTRY_TYPES, + COURT_ISSUED_EVENT_CODES, +} = require('../../entities/EntityConstants'); const { ENTERED_AND_SERVED_EVENT_CODES, } = require('../../entities/courtIssuedDocument/CourtIssuedDocumentConstants'); const { serveCourtIssuedDocumentInteractor, } = require('./serveCourtIssuedDocumentInteractor'); -const { Case } = require('../../entities/cases/Case'); -const { ContactFactory } = require('../../entities/contacts/ContactFactory'); const { createISODateString } = require('../../utilities/DateHandler'); -const { DOCKET_SECTION } = require('../../entities/WorkQueue'); -const { Document } = require('../../entities/Document'); -const { User } = require('../../entities/User'); +const { DOCKET_SECTION } = require('../../entities/EntityConstants'); +const { PARTY_TYPES, ROLES } = require('../../entities/EntityConstants'); const { v4: uuidv4 } = require('uuid'); const testAssetsPath = path.join(__dirname, '../../../../test-assets/'); @@ -34,7 +36,7 @@ describe('serveCourtIssuedDocumentInteractor', () => { const mockUser = { name: 'Docket Clerk', - role: User.ROLES.docketClerk, + role: ROLES.docketClerk, userId: '2474e5c0-f741-4120-befa-b77378ac8bf0', }; @@ -65,7 +67,7 @@ describe('serveCourtIssuedDocumentInteractor', () => { index, }); - const eventCodeMap = Document.COURT_ISSUED_EVENT_CODES.find( + const eventCodeMap = COURT_ISSUED_EVENT_CODES.find( entry => entry.eventCode === eventCode, ); @@ -87,7 +89,7 @@ describe('serveCourtIssuedDocumentInteractor', () => { contactPrimary: { address1: '123 Main St', city: 'Somewhere', - countryType: ContactFactory.COUNTRY_TYPES.DOMESTIC, + countryType: COUNTRY_TYPES.DOMESTIC, email: 'contact@example.com', name: 'Contact Primary', phone: '123123134', @@ -133,7 +135,7 @@ describe('serveCourtIssuedDocumentInteractor', () => { ...documentsWithCaseClosingEventCodes, ], filingType: 'Myself', - partyType: ContactFactory.PARTY_TYPES.petitioner, + partyType: PARTY_TYPES.petitioner, preferredTrialCity: 'Fresno, California', procedureType: 'Regular', }, @@ -144,7 +146,7 @@ describe('serveCourtIssuedDocumentInteractor', () => { contactPrimary: { address1: '123 Main St', city: 'Somewhere', - countryType: ContactFactory.COUNTRY_TYPES.DOMESTIC, + countryType: COUNTRY_TYPES.DOMESTIC, name: 'Contact Primary', phone: '123123134', postalCode: '12345', @@ -153,7 +155,7 @@ describe('serveCourtIssuedDocumentInteractor', () => { contactSecondary: { address1: '123 Main St', city: 'Somewhere', - countryType: ContactFactory.COUNTRY_TYPES.DOMESTIC, + countryType: COUNTRY_TYPES.DOMESTIC, name: 'Contact Secondary', phone: '123123134', postalCode: '12345', @@ -200,7 +202,7 @@ describe('serveCourtIssuedDocumentInteractor', () => { filingType: 'Myself', isPaper: true, mailingDate: 'testing', - partyType: ContactFactory.PARTY_TYPES.petitionerSpouse, + partyType: PARTY_TYPES.petitionerSpouse, preferredTrialCity: 'Fresno, California', procedureType: 'Regular', }, @@ -271,7 +273,7 @@ describe('serveCourtIssuedDocumentInteractor', () => { it('should throw an Unauthorized error if the user role does not have the SERVE_DOCUMENT permission', async () => { // petitioner role does NOT have the SERVE_DOCUMENT permission - const user = { ...mockUser, role: User.ROLES.petitioner }; + const user = { ...mockUser, role: ROLES.petitioner }; applicationContext.getCurrentUser.mockReturnValue(user); await expect( @@ -484,7 +486,7 @@ describe('serveCourtIssuedDocumentInteractor', () => { const updatedCase = applicationContext.getPersistenceGateway().updateCase .mock.calls[0][0].caseToUpdate; - expect(updatedCase.status).toEqual(Case.STATUS_TYPES.closed); + expect(updatedCase.status).toEqual(CASE_STATUS_TYPES.closed); expect( applicationContext.getPersistenceGateway() .deleteCaseTrialSortMappingRecords, diff --git a/shared/src/business/useCases/courtIssuedOrder/fileCourtIssuedOrderInteractor.test.js b/shared/src/business/useCases/courtIssuedOrder/fileCourtIssuedOrderInteractor.test.js index 2c161b67297..a8e3c05db96 100644 --- a/shared/src/business/useCases/courtIssuedOrder/fileCourtIssuedOrderInteractor.test.js +++ b/shared/src/business/useCases/courtIssuedOrder/fileCourtIssuedOrderInteractor.test.js @@ -5,6 +5,7 @@ const { const { fileCourtIssuedOrderInteractor, } = require('./fileCourtIssuedOrderInteractor'); +const { ROLES } = require('../../entities/EntityConstants'); const { User } = require('../../entities/User'); describe('fileCourtIssuedOrderInteractor', () => { @@ -57,7 +58,7 @@ describe('fileCourtIssuedOrderInteractor', () => { partyType: 'Petitioner', preferredTrialCity: 'Fresno, California', procedureType: 'Regular', - role: User.ROLES.petitioner, + role: ROLES.petitioner, userId: 'ddd6c900-388b-4151-8014-b3378076bfb0', }; @@ -65,7 +66,7 @@ describe('fileCourtIssuedOrderInteractor', () => { applicationContext.getCurrentUser.mockReturnValue( new User({ name: 'Emmett Lathrop "Doc" Brown, Ph.D.', - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', }), ); @@ -73,7 +74,7 @@ describe('fileCourtIssuedOrderInteractor', () => { applicationContext.getPersistenceGateway().getUserById.mockReturnValue( new User({ name: 'Emmett Lathrop "Doc" Brown, Ph.D.', - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', }), ); diff --git a/shared/src/business/useCases/courtIssuedOrder/updateCourtIssuedOrderInteractor.js b/shared/src/business/useCases/courtIssuedOrder/updateCourtIssuedOrderInteractor.js index 7c592a3d7ac..cc2c6f60535 100644 --- a/shared/src/business/useCases/courtIssuedOrder/updateCourtIssuedOrderInteractor.js +++ b/shared/src/business/useCases/courtIssuedOrder/updateCourtIssuedOrderInteractor.js @@ -55,7 +55,7 @@ exports.updateCourtIssuedOrderInteractor = async ({ richText: documentMetadata.draftState.richText, }; - applicationContext.getPersistenceGateway().saveDocumentFromLambda({ + await applicationContext.getPersistenceGateway().saveDocumentFromLambda({ applicationContext, document: Buffer.from(JSON.stringify(contentToStore)), documentId: documentContentsId, diff --git a/shared/src/business/useCases/courtIssuedOrder/updateCourtIssuedOrderInteractor.test.js b/shared/src/business/useCases/courtIssuedOrder/updateCourtIssuedOrderInteractor.test.js index 3f34f2fc597..9eee1fa8502 100644 --- a/shared/src/business/useCases/courtIssuedOrder/updateCourtIssuedOrderInteractor.test.js +++ b/shared/src/business/useCases/courtIssuedOrder/updateCourtIssuedOrderInteractor.test.js @@ -4,6 +4,7 @@ const { const { updateCourtIssuedOrderInteractor, } = require('./updateCourtIssuedOrderInteractor'); +const { ROLES } = require('../../entities/EntityConstants'); const { User } = require('../../entities/User'); describe('updateCourtIssuedOrderInteractor', () => { @@ -60,14 +61,14 @@ describe('updateCourtIssuedOrderInteractor', () => { partyType: 'Petitioner', preferredTrialCity: 'Fresno, California', procedureType: 'Regular', - role: User.ROLES.petitioner, + role: ROLES.petitioner, userId: '3433e36f-3b50-4c92-aa55-6efb4e432883', }; beforeEach(() => { mockCurrentUser = new User({ name: 'Olivia Jade', - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', }); @@ -88,7 +89,7 @@ describe('updateCourtIssuedOrderInteractor', () => { }); it('should throw an error if not authorized', async () => { - mockCurrentUser.role = User.ROLES.privatePractitioner; + mockCurrentUser.role = ROLES.privatePractitioner; mockUserById = { name: 'bob' }; await expect( diff --git a/shared/src/business/useCases/createCaseFromPaperInteractor.js b/shared/src/business/useCases/createCaseFromPaperInteractor.js index b619ab21219..08e2553a0bf 100644 --- a/shared/src/business/useCases/createCaseFromPaperInteractor.js +++ b/shared/src/business/useCases/createCaseFromPaperInteractor.js @@ -5,6 +5,7 @@ const { const { Case } = require('../entities/cases/Case'); const { CaseInternal } = require('../entities/cases/CaseInternal'); const { Document } = require('../entities/Document'); +const { INITIAL_DOCUMENT_TYPES } = require('../entities/EntityConstants'); const { Message } = require('../entities/Message'); const { replaceBracketed } = require('../utilities/replaceBracketed'); const { UnauthorizedError } = require('../../errors/errors'); @@ -140,8 +141,8 @@ exports.createCaseFromPaperInteractor = async ({ { createdAt: caseToAdd.receivedAt, documentId: petitionFileId, - documentType: Document.INITIAL_DOCUMENT_TYPES.petition.documentType, - eventCode: Document.INITIAL_DOCUMENT_TYPES.petition.eventCode, + documentType: INITIAL_DOCUMENT_TYPES.petition.documentType, + eventCode: INITIAL_DOCUMENT_TYPES.petition.eventCode, filingDate: caseToAdd.receivedAt, isPaper: true, mailingDate: petitionEntity.mailingDate, @@ -167,7 +168,7 @@ exports.createCaseFromPaperInteractor = async ({ if (applicationForWaiverOfFilingFeeFileId) { let { documentTitle, - } = Document.INITIAL_DOCUMENT_TYPES.applicationForWaiverOfFilingFee; + } = INITIAL_DOCUMENT_TYPES.applicationForWaiverOfFilingFee; const applicationForWaiverOfFilingFeeDocumentEntity = new Document( { @@ -175,11 +176,9 @@ exports.createCaseFromPaperInteractor = async ({ documentId: applicationForWaiverOfFilingFeeFileId, documentTitle, documentType: - Document.INITIAL_DOCUMENT_TYPES.applicationForWaiverOfFilingFee - .documentType, + INITIAL_DOCUMENT_TYPES.applicationForWaiverOfFilingFee.documentType, eventCode: - Document.INITIAL_DOCUMENT_TYPES.applicationForWaiverOfFilingFee - .eventCode, + INITIAL_DOCUMENT_TYPES.applicationForWaiverOfFilingFee.eventCode, filingDate: caseToAdd.receivedAt, isPaper: true, mailingDate: petitionEntity.mailingDate, @@ -201,9 +200,7 @@ exports.createCaseFromPaperInteractor = async ({ } if (requestForPlaceOfTrialFileId) { - let { - documentTitle, - } = Document.INITIAL_DOCUMENT_TYPES.requestForPlaceOfTrial; + let { documentTitle } = INITIAL_DOCUMENT_TYPES.requestForPlaceOfTrial; if (caseToAdd.preferredTrialCity) { documentTitle = replaceBracketed( documentTitle, @@ -217,9 +214,8 @@ exports.createCaseFromPaperInteractor = async ({ documentId: requestForPlaceOfTrialFileId, documentTitle, documentType: - Document.INITIAL_DOCUMENT_TYPES.requestForPlaceOfTrial.documentType, - eventCode: - Document.INITIAL_DOCUMENT_TYPES.requestForPlaceOfTrial.eventCode, + INITIAL_DOCUMENT_TYPES.requestForPlaceOfTrial.documentType, + eventCode: INITIAL_DOCUMENT_TYPES.requestForPlaceOfTrial.eventCode, filingDate: caseToAdd.receivedAt, isPaper: true, mailingDate: petitionEntity.mailingDate, @@ -245,8 +241,8 @@ exports.createCaseFromPaperInteractor = async ({ { createdAt: caseToAdd.receivedAt, documentId: stinFileId, - documentType: Document.INITIAL_DOCUMENT_TYPES.stin.documentType, - eventCode: Document.INITIAL_DOCUMENT_TYPES.stin.eventCode, + documentType: INITIAL_DOCUMENT_TYPES.stin.documentType, + eventCode: INITIAL_DOCUMENT_TYPES.stin.eventCode, filingDate: caseToAdd.receivedAt, isPaper: true, mailingDate: petitionEntity.mailingDate, @@ -272,10 +268,8 @@ exports.createCaseFromPaperInteractor = async ({ { createdAt: caseToAdd.receivedAt, documentId: ownershipDisclosureFileId, - documentType: - Document.INITIAL_DOCUMENT_TYPES.ownershipDisclosure.documentType, - eventCode: - Document.INITIAL_DOCUMENT_TYPES.ownershipDisclosure.eventCode, + documentType: INITIAL_DOCUMENT_TYPES.ownershipDisclosure.documentType, + eventCode: INITIAL_DOCUMENT_TYPES.ownershipDisclosure.eventCode, filingDate: caseToAdd.receivedAt, isPaper: true, mailingDate: petitionEntity.mailingDate, diff --git a/shared/src/business/useCases/createCaseFromPaperInteractor.test.js b/shared/src/business/useCases/createCaseFromPaperInteractor.test.js index b7d5a0fb934..805e21f0e8a 100644 --- a/shared/src/business/useCases/createCaseFromPaperInteractor.test.js +++ b/shared/src/business/useCases/createCaseFromPaperInteractor.test.js @@ -4,8 +4,8 @@ const { createCaseFromPaperInteractor, } = require('./createCaseFromPaperInteractor'); const { applicationContext } = require('../test/createTestApplicationContext'); -const { Case } = require('../entities/cases/Case'); -const { ContactFactory } = require('../entities/contacts/ContactFactory'); +const { PARTY_TYPES, PAYMENT_STATUS } = require('../entities/EntityConstants'); +const { ROLES } = require('../entities/EntityConstants'); const { UnauthorizedError } = require('../../errors/errors'); const { User } = require('../entities/User'); @@ -24,7 +24,7 @@ describe('createCaseFromPaperInteractor', () => { applicationContext.getCurrentUser.mockReturnValue( new User({ name: 'Test Petitionsclerk', - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: '6805d1ab-18d0-43ec-bafb-654e83405416', }), ); @@ -35,7 +35,7 @@ describe('createCaseFromPaperInteractor', () => { applicationContext.getPersistenceGateway().getUserById.mockReturnValue({ name: 'Test Petitionsclerk', - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, section: 'petitions', userId: '6805d1ab-18d0-43ec-bafb-654e83405416', }); @@ -87,10 +87,10 @@ describe('createCaseFromPaperInteractor', () => { hasIrsNotice: true, irsNoticeDate: DATE, mailingDate: 'testing', - partyType: ContactFactory.PARTY_TYPES.petitioner, + partyType: PARTY_TYPES.petitioner, petitionFile: new File([], 'petitionFile.pdf'), petitionFileSize: 1, - petitionPaymentStatus: Case.PAYMENT_STATUS.UNPAID, + petitionPaymentStatus: PAYMENT_STATUS.UNPAID, preferredTrialCity: 'Fresno, California', procedureType: 'Small', receivedAt: new Date().toISOString(), @@ -134,10 +134,10 @@ describe('createCaseFromPaperInteractor', () => { hasIrsNotice: true, irsNoticeDate: DATE, mailingDate: 'test', - partyType: ContactFactory.PARTY_TYPES.petitioner, + partyType: PARTY_TYPES.petitioner, petitionFile: new File([], 'petitionFile.pdf'), petitionFileSize: 1, - petitionPaymentStatus: Case.PAYMENT_STATUS.UNPAID, + petitionPaymentStatus: PAYMENT_STATUS.UNPAID, preferredTrialCity: 'Fresno, California', procedureType: 'Small', receivedAt: new Date().toISOString(), @@ -181,10 +181,10 @@ describe('createCaseFromPaperInteractor', () => { hasIrsNotice: true, irsNoticeDate: DATE, mailingDate: 'testing', - partyType: ContactFactory.PARTY_TYPES.petitioner, + partyType: PARTY_TYPES.petitioner, petitionFile: new File([], 'petitionFile.pdf'), petitionFileSize: 1, - petitionPaymentStatus: Case.PAYMENT_STATUS.UNPAID, + petitionPaymentStatus: PAYMENT_STATUS.UNPAID, preferredTrialCity: 'Fresno, California', procedureType: 'Small', receivedAt: new Date().toISOString(), @@ -229,10 +229,10 @@ describe('createCaseFromPaperInteractor', () => { hasIrsNotice: true, irsNoticeDate: DATE, mailingDate: 'testing', - partyType: ContactFactory.PARTY_TYPES.petitioner, + partyType: PARTY_TYPES.petitioner, petitionFile: new File([], 'petitionFile.pdf'), petitionFileSize: 1, - petitionPaymentStatus: Case.PAYMENT_STATUS.UNPAID, + petitionPaymentStatus: PAYMENT_STATUS.UNPAID, preferredTrialCity: 'Fresno, California', procedureType: 'Small', receivedAt: new Date().toISOString(), diff --git a/shared/src/business/useCases/createCaseInteractor.js b/shared/src/business/useCases/createCaseInteractor.js index 7f96e402437..da0b05fb72f 100644 --- a/shared/src/business/useCases/createCaseInteractor.js +++ b/shared/src/business/useCases/createCaseInteractor.js @@ -8,10 +8,11 @@ const { const { Case } = require('../entities/cases/Case'); const { DocketRecord } = require('../entities/DocketRecord'); const { Document } = require('../entities/Document'); +const { INITIAL_DOCUMENT_TYPES } = require('../entities/EntityConstants'); const { Message } = require('../entities/Message'); -const { PETITIONS_SECTION } = require('../entities/WorkQueue'); +const { PETITIONS_SECTION } = require('../entities/EntityConstants'); +const { ROLES } = require('../entities/EntityConstants'); const { UnauthorizedError } = require('../../errors/errors'); -const { User } = require('../entities/User'); const { UserCase } = require('../entities/UserCase'); const { WorkItem } = require('../entities/WorkItem'); @@ -105,7 +106,7 @@ exports.createCaseInteractor = async ({ ); let privatePractitioners = []; - if (user.role === User.ROLES.privatePractitioner) { + if (user.role === ROLES.privatePractitioner) { const practitionerUser = await applicationContext .getPersistenceGateway() .getUserById({ @@ -152,8 +153,8 @@ exports.createCaseInteractor = async ({ const petitionDocumentEntity = new Document( { documentId: petitionFileId, - documentType: Document.INITIAL_DOCUMENT_TYPES.petition.documentType, - eventCode: Document.INITIAL_DOCUMENT_TYPES.petition.eventCode, + documentType: INITIAL_DOCUMENT_TYPES.petition.documentType, + eventCode: INITIAL_DOCUMENT_TYPES.petition.eventCode, filingDate: caseToAdd.createdAt, partyPrimary: true, partySecondary, @@ -178,8 +179,7 @@ exports.createCaseInteractor = async ({ new DocketRecord( { description: `Request for Place of Trial at ${caseToAdd.preferredTrialCity}`, - eventCode: - Document.INITIAL_DOCUMENT_TYPES.requestForPlaceOfTrial.eventCode, + eventCode: INITIAL_DOCUMENT_TYPES.requestForPlaceOfTrial.eventCode, filingDate: caseToAdd.createdAt, }, { applicationContext }, @@ -189,8 +189,8 @@ exports.createCaseInteractor = async ({ const stinDocumentEntity = new Document( { documentId: stinFileId, - documentType: Document.INITIAL_DOCUMENT_TYPES.stin.documentType, - eventCode: Document.INITIAL_DOCUMENT_TYPES.stin.eventCode, + documentType: INITIAL_DOCUMENT_TYPES.stin.documentType, + eventCode: INITIAL_DOCUMENT_TYPES.stin.eventCode, filingDate: caseToAdd.createdAt, partyPrimary: true, partySecondary, @@ -210,10 +210,8 @@ exports.createCaseInteractor = async ({ const odsDocumentEntity = new Document( { documentId: ownershipDisclosureFileId, - documentType: - Document.INITIAL_DOCUMENT_TYPES.ownershipDisclosure.documentType, - eventCode: - Document.INITIAL_DOCUMENT_TYPES.ownershipDisclosure.eventCode, + documentType: INITIAL_DOCUMENT_TYPES.ownershipDisclosure.documentType, + eventCode: INITIAL_DOCUMENT_TYPES.ownershipDisclosure.eventCode, filingDate: caseToAdd.createdAt, partyPrimary: true, partySecondary, diff --git a/shared/src/business/useCases/createCaseInteractor.test.js b/shared/src/business/useCases/createCaseInteractor.test.js index 3488d463569..9ef0a7d9a43 100644 --- a/shared/src/business/useCases/createCaseInteractor.test.js +++ b/shared/src/business/useCases/createCaseInteractor.test.js @@ -1,6 +1,6 @@ const { applicationContext } = require('../test/createTestApplicationContext'); -const { ContactFactory } = require('../entities/contacts/ContactFactory'); const { createCaseInteractor } = require('./createCaseInteractor'); +const { PARTY_TYPES, ROLES } = require('../entities/EntityConstants'); const { User } = require('../entities/User'); describe('createCaseInteractor', () => { @@ -9,7 +9,7 @@ describe('createCaseInteractor', () => { beforeEach(() => { user = new User({ name: 'Test Petitioner', - role: User.ROLES.petitioner, + role: ROLES.petitioner, userId: '6805d1ab-18d0-43ec-bafb-654e83405416', }); @@ -39,7 +39,7 @@ describe('createCaseInteractor', () => { caseType: 'Other', filingType: 'Myself', hasIrsNotice: true, - partyType: ContactFactory.PARTY_TYPES.petitioner, + partyType: PARTY_TYPES.petitioner, preferredTrialCity: 'Fresno, California', procedureType: 'Small', }, @@ -75,7 +75,7 @@ describe('createCaseInteractor', () => { contactSecondary: {}, filingType: 'Myself', hasIrsNotice: true, - partyType: ContactFactory.PARTY_TYPES.petitioner, + partyType: PARTY_TYPES.petitioner, petitionFile: new File([], 'test.pdf'), petitionFileSize: 1, preferredTrialCity: 'Fresno, California', @@ -100,7 +100,7 @@ describe('createCaseInteractor', () => { it('should create a case successfully as a practitioner', async () => { user = new User({ name: 'Mister Peanutbutter', - role: User.ROLES.privatePractitioner, + role: ROLES.privatePractitioner, userId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', }); @@ -125,7 +125,7 @@ describe('createCaseInteractor', () => { contactSecondary: {}, filingType: 'Myself', hasIrsNotice: true, - partyType: ContactFactory.PARTY_TYPES.petitioner, + partyType: PARTY_TYPES.petitioner, petitionFile: new File([], 'test.pdf'), petitionFileSize: 1, preferredTrialCity: 'Fresno, California', @@ -151,7 +151,7 @@ describe('createCaseInteractor', () => { it('should create a case with contact primary and secondary successfully as a practitioner', async () => { user = new User({ name: 'Carole Baskin', - role: User.ROLES.privatePractitioner, + role: ROLES.privatePractitioner, userId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', }); @@ -187,7 +187,7 @@ describe('createCaseInteractor', () => { filingType: 'Myself and my spouse', hasIrsNotice: true, isSpouseDeceased: 'No', - partyType: ContactFactory.PARTY_TYPES.petitionerSpouse, + partyType: PARTY_TYPES.petitionerSpouse, petitionFile: new File([], 'test.pdf'), petitionFileSize: 1, preferredTrialCity: 'Fresno, California', diff --git a/shared/src/business/useCases/docketEntry/fileCourtIssuedDocketEntryInteractor.js b/shared/src/business/useCases/docketEntry/fileCourtIssuedDocketEntryInteractor.js index 5f62ac4cdf3..6d67a6864fe 100644 --- a/shared/src/business/useCases/docketEntry/fileCourtIssuedDocketEntryInteractor.js +++ b/shared/src/business/useCases/docketEntry/fileCourtIssuedDocketEntryInteractor.js @@ -5,11 +5,12 @@ const { const { capitalize, omit } = require('lodash'); const { Case } = require('../../entities/cases/Case'); const { createISODateString } = require('../../utilities/DateHandler'); -const { DOCKET_SECTION } = require('../../entities/WorkQueue'); +const { DOCKET_SECTION } = require('../../entities/EntityConstants'); const { DocketRecord } = require('../../entities/DocketRecord'); const { Document } = require('../../entities/Document'); const { Message } = require('../../entities/Message'); const { NotFoundError, UnauthorizedError } = require('../../../errors/errors'); +const { TRANSCRIPT_EVENT_CODE } = require('../../entities/EntityConstants'); const { WorkItem } = require('../../entities/WorkItem'); /** @@ -57,7 +58,7 @@ exports.fileCourtIssuedDocketEntryInteractor = async ({ .getUserById({ applicationContext, userId: authorizedUser.userId }); let secondaryDate; - if (documentMeta.eventCode === Document.TRANSCRIPT_EVENT_CODE) { + if (documentMeta.eventCode === TRANSCRIPT_EVENT_CODE) { secondaryDate = documentMeta.date; } diff --git a/shared/src/business/useCases/docketEntry/fileCourtIssuedDocketEntryInteractor.test.js b/shared/src/business/useCases/docketEntry/fileCourtIssuedDocketEntryInteractor.test.js index a9ea9b2d71c..1b5c0134a0e 100644 --- a/shared/src/business/useCases/docketEntry/fileCourtIssuedDocketEntryInteractor.test.js +++ b/shared/src/business/useCases/docketEntry/fileCourtIssuedDocketEntryInteractor.test.js @@ -1,12 +1,14 @@ const { applicationContext, } = require('../../test/createTestApplicationContext'); +const { + AUTOMATIC_BLOCKED_REASONS, + PARTY_TYPES, +} = require('../../entities/EntityConstants'); const { fileCourtIssuedDocketEntryInteractor, } = require('./fileCourtIssuedDocketEntryInteractor'); -const { Case } = require('../../entities/cases/Case'); -const { ContactFactory } = require('../../entities/contacts/ContactFactory'); -const { User } = require('../../entities/User'); +const { ROLES } = require('../../entities/EntityConstants'); describe('fileCourtIssuedDocketEntryInteractor', () => { let caseRecord; @@ -14,7 +16,7 @@ describe('fileCourtIssuedDocketEntryInteractor', () => { beforeEach(() => { applicationContext.getPersistenceGateway().getUserById.mockReturnValue({ name: 'Emmett Lathrop "Doc" Brown, Ph.D.', - role: User.ROLES.docketClerk, + role: ROLES.docketClerk, section: 'docket', userId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', }); @@ -99,10 +101,10 @@ describe('fileCourtIssuedDocketEntryInteractor', () => { }, ], filingType: 'Myself', - partyType: ContactFactory.PARTY_TYPES.petitioner, + partyType: PARTY_TYPES.petitioner, preferredTrialCity: 'Fresno, California', procedureType: 'Regular', - role: User.ROLES.petitioner, + role: ROLES.petitioner, userId: '8100e22a-c7f2-4574-b4f6-eb092fca9f35', }; }); @@ -125,7 +127,7 @@ describe('fileCourtIssuedDocketEntryInteractor', () => { it('should throw an error if the document is not found on the case', async () => { applicationContext.getCurrentUser.mockReturnValue({ name: 'Emmett Lathrop "Doc" Brown, Ph.D.', - role: User.ROLES.docketClerk, + role: ROLES.docketClerk, userId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', }); @@ -144,7 +146,7 @@ describe('fileCourtIssuedDocketEntryInteractor', () => { it('should call countPagesInDocument, updateCase, createUserInboxRecord, and createSectionInboxRecord', async () => { applicationContext.getCurrentUser.mockReturnValue({ name: 'Emmett Lathrop "Doc" Brown, Ph.D.', - role: User.ROLES.docketClerk, + role: ROLES.docketClerk, section: 'docket', userId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', }); @@ -175,7 +177,7 @@ describe('fileCourtIssuedDocketEntryInteractor', () => { it('should call updateCase and set the case as automatic blocked if the document is a tracked document', async () => { applicationContext.getCurrentUser.mockReturnValue({ name: 'Emmett Lathrop "Doc" Brown, Ph.D.', - role: User.ROLES.docketClerk, + role: ROLES.docketClerk, section: 'docket', userId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', }); @@ -201,7 +203,7 @@ describe('fileCourtIssuedDocketEntryInteractor', () => { ).toMatchObject({ automaticBlocked: true, automaticBlockedDate: expect.anything(), - automaticBlockedReason: Case.AUTOMATIC_BLOCKED_REASONS.pending, + automaticBlockedReason: AUTOMATIC_BLOCKED_REASONS.pending, }); expect( applicationContext.getPersistenceGateway() @@ -219,7 +221,7 @@ describe('fileCourtIssuedDocketEntryInteractor', () => { ]); applicationContext.getCurrentUser.mockReturnValue({ name: 'Emmett Lathrop "Doc" Brown, Ph.D.', - role: User.ROLES.docketClerk, + role: ROLES.docketClerk, section: 'docket', userId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', }); @@ -245,7 +247,7 @@ describe('fileCourtIssuedDocketEntryInteractor', () => { ).toMatchObject({ automaticBlocked: true, automaticBlockedDate: expect.anything(), - automaticBlockedReason: Case.AUTOMATIC_BLOCKED_REASONS.pendingAndDueDate, + automaticBlockedReason: AUTOMATIC_BLOCKED_REASONS.pendingAndDueDate, }); expect( applicationContext.getPersistenceGateway() @@ -256,7 +258,7 @@ describe('fileCourtIssuedDocketEntryInteractor', () => { it('should set secondaryDate on the created document if the eventCode is TRAN', async () => { applicationContext.getCurrentUser.mockReturnValue({ name: 'Emmett Lathrop "Doc" Brown, Ph.D.', - role: User.ROLES.docketClerk, + role: ROLES.docketClerk, section: 'docket', userId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', }); diff --git a/shared/src/business/useCases/docketEntry/fileDocketEntryInteractor.js b/shared/src/business/useCases/docketEntry/fileDocketEntryInteractor.js index 1ad3b7a6d39..e469ee4d0a6 100644 --- a/shared/src/business/useCases/docketEntry/fileDocketEntryInteractor.js +++ b/shared/src/business/useCases/docketEntry/fileDocketEntryInteractor.js @@ -4,12 +4,12 @@ const { } = require('../../../authorization/authorizationClientService'); const { capitalize, pick } = require('lodash'); const { Case } = require('../../entities/cases/Case'); -const { DOCKET_SECTION } = require('../../entities/WorkQueue'); +const { DOCKET_SECTION } = require('../../entities/EntityConstants'); const { DocketRecord } = require('../../entities/DocketRecord'); const { Document } = require('../../entities/Document'); const { Message } = require('../../entities/Message'); +const { ROLES } = require('../../entities/EntityConstants'); const { UnauthorizedError } = require('../../../errors/errors'); -const { User } = require('../../entities/User'); const { WorkItem } = require('../../entities/WorkItem'); /** @@ -132,7 +132,7 @@ exports.fileDocketEntryInteractor = async ({ createdAt: documentEntity.createdAt, }, isQC: true, - isRead: user.role !== User.ROLES.privatePractitioner, + isRead: user.role !== ROLES.privatePractitioner, section: DOCKET_SECTION, sentBy: user.name, sentByUserId: user.userId, diff --git a/shared/src/business/useCases/docketEntry/fileDocketEntryInteractor.test.js b/shared/src/business/useCases/docketEntry/fileDocketEntryInteractor.test.js index 2d0acfdc3fe..ccf414d46ea 100644 --- a/shared/src/business/useCases/docketEntry/fileDocketEntryInteractor.test.js +++ b/shared/src/business/useCases/docketEntry/fileDocketEntryInteractor.test.js @@ -1,15 +1,14 @@ const { applicationContext, } = require('../../test/createTestApplicationContext'); -const { Case } = require('../../entities/cases/Case'); -const { ContactFactory } = require('../../entities/contacts/ContactFactory'); +const { AUTOMATIC_BLOCKED_REASONS } = require('../../entities/EntityConstants'); const { fileDocketEntryInteractor } = require('./fileDocketEntryInteractor'); -const { User } = require('../../entities/User'); +const { PARTY_TYPES, ROLES } = require('../../entities/EntityConstants'); describe('fileDocketEntryInteractor', () => { const user = { name: 'Emmett Lathrop "Doc" Brown, Ph.D.', - role: User.ROLES.docketClerk, + role: ROLES.docketClerk, section: 'docket', userId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', }; @@ -59,10 +58,10 @@ describe('fileDocketEntryInteractor', () => { }, ], filingType: 'Myself', - partyType: ContactFactory.PARTY_TYPES.petitioner, + partyType: PARTY_TYPES.petitioner, preferredTrialCity: 'Fresno, California', procedureType: 'Regular', - role: User.ROLES.petitioner, + role: ROLES.petitioner, userId: '7805d1ab-18d0-43ec-bafb-654e83405416', }; @@ -199,7 +198,7 @@ describe('fileDocketEntryInteractor', () => { ).toMatchObject({ automaticBlocked: true, automaticBlockedDate: expect.anything(), - automaticBlockedReason: Case.AUTOMATIC_BLOCKED_REASONS.pending, + automaticBlockedReason: AUTOMATIC_BLOCKED_REASONS.pending, }); expect( applicationContext.getPersistenceGateway() @@ -232,7 +231,7 @@ describe('fileDocketEntryInteractor', () => { ).toMatchObject({ automaticBlocked: true, automaticBlockedDate: expect.anything(), - automaticBlockedReason: Case.AUTOMATIC_BLOCKED_REASONS.pendingAndDueDate, + automaticBlockedReason: AUTOMATIC_BLOCKED_REASONS.pendingAndDueDate, }); expect( applicationContext.getPersistenceGateway() diff --git a/shared/src/business/useCases/docketEntry/updateCourtIssuedDocketEntryInteractor.js b/shared/src/business/useCases/docketEntry/updateCourtIssuedDocketEntryInteractor.js index e5f08a73f9a..cbc2e586005 100644 --- a/shared/src/business/useCases/docketEntry/updateCourtIssuedDocketEntryInteractor.js +++ b/shared/src/business/useCases/docketEntry/updateCourtIssuedDocketEntryInteractor.js @@ -7,6 +7,7 @@ const { DocketRecord } = require('../../entities/DocketRecord'); const { Document } = require('../../entities/Document'); const { NotFoundError, UnauthorizedError } = require('../../../errors/errors'); const { omit } = require('lodash'); +const { TRANSCRIPT_EVENT_CODE } = require('../../entities/EntityConstants'); /** * @@ -53,7 +54,7 @@ exports.updateCourtIssuedDocketEntryInteractor = async ({ .getUserById({ applicationContext, userId: authorizedUser.userId }); let secondaryDate; - if (documentMeta.eventCode === Document.TRANSCRIPT_EVENT_CODE) { + if (documentMeta.eventCode === TRANSCRIPT_EVENT_CODE) { secondaryDate = documentMeta.date; } diff --git a/shared/src/business/useCases/docketEntry/updateCourtIssuedDocketEntryInteractor.test.js b/shared/src/business/useCases/docketEntry/updateCourtIssuedDocketEntryInteractor.test.js index 96cba94d16c..595ea34472f 100644 --- a/shared/src/business/useCases/docketEntry/updateCourtIssuedDocketEntryInteractor.test.js +++ b/shared/src/business/useCases/docketEntry/updateCourtIssuedDocketEntryInteractor.test.js @@ -2,9 +2,8 @@ import { updateCourtIssuedDocketEntryInteractor } from './updateCourtIssuedDocke const { applicationContext, } = require('../../test/createTestApplicationContext'); -const { Case } = require('../../entities/cases/Case'); -const { ContactFactory } = require('../../entities/contacts/ContactFactory'); -const { User } = require('../../entities/User'); +const { CASE_STATUS_TYPES } = require('../../entities/EntityConstants'); +const { PARTY_TYPES, ROLES } = require('../../entities/EntityConstants'); describe('updateCourtIssuedDocketEntryInteractor', () => { let caseRecord; @@ -65,7 +64,7 @@ describe('updateCourtIssuedDocketEntryInteractor', () => { assigneeId: '8b4cd447-6278-461b-b62b-d9e357eea62c', assigneeName: 'bob', caseId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - caseStatus: Case.STATUS_TYPES.new, + caseStatus: CASE_STATUS_TYPES.new, caseTitle: 'Johnny Joe Jacobson', docketNumber: '101-18', docketNumberSuffix: 'S', @@ -89,7 +88,7 @@ describe('updateCourtIssuedDocketEntryInteractor', () => { assigneeId: '8b4cd447-6278-461b-b62b-d9e357eea62c', assigneeName: 'bob', caseId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - caseStatus: Case.STATUS_TYPES.new, + caseStatus: CASE_STATUS_TYPES.new, docketNumber: '101-18', docketNumberSuffix: 'S', document: {}, @@ -102,10 +101,10 @@ describe('updateCourtIssuedDocketEntryInteractor', () => { }, ], filingType: 'Myself', - partyType: ContactFactory.PARTY_TYPES.petitioner, + partyType: PARTY_TYPES.petitioner, preferredTrialCity: 'Fresno, California', procedureType: 'Regular', - role: User.ROLES.petitioner, + role: ROLES.petitioner, userId: '8100e22a-c7f2-4574-b4f6-eb092fca9f35', }; @@ -137,7 +136,7 @@ describe('updateCourtIssuedDocketEntryInteractor', () => { it('should throw an error if the document is not found on the case', async () => { applicationContext.getCurrentUser.mockReturnValue({ name: 'Emmett Lathrop "Doc" Brown, Ph.D.', - role: User.ROLES.docketClerk, + role: ROLES.docketClerk, userId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', }); @@ -156,7 +155,7 @@ describe('updateCourtIssuedDocketEntryInteractor', () => { it('should call updateCase, createUserInboxRecord, and createSectionInboxRecord', async () => { applicationContext.getCurrentUser.mockReturnValue({ name: 'Emmett Lathrop "Doc" Brown, Ph.D.', - role: User.ROLES.docketClerk, + role: ROLES.docketClerk, userId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', }); @@ -183,7 +182,7 @@ describe('updateCourtIssuedDocketEntryInteractor', () => { it('should set secondaryDate on the created document if the eventCode is TRAN', async () => { applicationContext.getCurrentUser.mockReturnValue({ name: 'Emmett Lathrop "Doc" Brown, Ph.D.', - role: User.ROLES.docketClerk, + role: ROLES.docketClerk, section: 'docket', userId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', }); @@ -216,7 +215,7 @@ describe('updateCourtIssuedDocketEntryInteractor', () => { it('should not update non-editable fields on the document', async () => { applicationContext.getCurrentUser.mockReturnValue({ name: 'Emmett Lathrop "Doc" Brown, Ph.D.', - role: User.ROLES.docketClerk, + role: ROLES.docketClerk, userId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', }); diff --git a/shared/src/business/useCases/docketEntry/updateDocketEntryInteractor.js b/shared/src/business/useCases/docketEntry/updateDocketEntryInteractor.js index f78ccefa66f..9e1da2b5909 100644 --- a/shared/src/business/useCases/docketEntry/updateDocketEntryInteractor.js +++ b/shared/src/business/useCases/docketEntry/updateDocketEntryInteractor.js @@ -3,7 +3,7 @@ const { ROLE_PERMISSIONS, } = require('../../../authorization/authorizationClientService'); const { Case } = require('../../entities/cases/Case'); -const { DOCKET_SECTION } = require('../../entities/WorkQueue'); +const { DOCKET_SECTION } = require('../../entities/EntityConstants'); const { DocketRecord } = require('../../entities/DocketRecord'); const { Document } = require('../../entities/Document'); const { omit } = require('lodash'); diff --git a/shared/src/business/useCases/docketEntry/updateDocketEntryInteractor.test.js b/shared/src/business/useCases/docketEntry/updateDocketEntryInteractor.test.js index 0aa3b6daa9d..ad79e045051 100644 --- a/shared/src/business/useCases/docketEntry/updateDocketEntryInteractor.test.js +++ b/shared/src/business/useCases/docketEntry/updateDocketEntryInteractor.test.js @@ -4,7 +4,7 @@ const { const { updateDocketEntryInteractor, } = require('./updateDocketEntryInteractor'); -const { User } = require('../../entities/User'); +const { ROLES } = require('../../entities/EntityConstants'); describe('updateDocketEntryInteractor', () => { let mockCurrentUser; @@ -77,14 +77,14 @@ describe('updateDocketEntryInteractor', () => { partyType: 'Petitioner', preferredTrialCity: 'Fresno, California', procedureType: 'Regular', - role: User.ROLES.petitioner, + role: ROLES.petitioner, userId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', }; beforeEach(() => { mockCurrentUser = { name: 'Emmett Lathrop "Doc" Brown, Ph.D.', - role: User.ROLES.docketClerk, + role: ROLES.docketClerk, section: 'docket', userId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', }; @@ -92,7 +92,7 @@ describe('updateDocketEntryInteractor', () => { applicationContext.getCurrentUser.mockImplementation(() => mockCurrentUser); applicationContext.getPersistenceGateway().getUserById.mockReturnValue({ name: 'Emmett Lathrop "Doc" Brown, Ph.D.', - role: User.ROLES.docketClerk, + role: ROLES.docketClerk, section: 'docket', userId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', }); diff --git a/shared/src/business/useCases/docketEntry/updateDocketEntryMetaInteractor.test.js b/shared/src/business/useCases/docketEntry/updateDocketEntryMetaInteractor.test.js index 4b97155a413..95595ab175a 100644 --- a/shared/src/business/useCases/docketEntry/updateDocketEntryMetaInteractor.test.js +++ b/shared/src/business/useCases/docketEntry/updateDocketEntryMetaInteractor.test.js @@ -4,8 +4,8 @@ const { } = require('../../test/createTestApplicationContext'); const { MOCK_CASE } = require('../../../test/mockCase'); const { NotFoundError } = require('../../../errors/errors'); +const { ROLES } = require('../../entities/EntityConstants'); const { UnauthorizedError } = require('../../../errors/errors'); -const { User } = require('../../entities/User'); describe('updateDocketEntryMetaInteractor', () => { let docketRecord; @@ -70,7 +70,7 @@ describe('updateDocketEntryMetaInteractor', () => { }; applicationContext.getCurrentUser.mockReturnValue({ - role: User.ROLES.docketClerk, + role: ROLES.docketClerk, userId: 'abcba5a9-b37b-479d-9201-067ec6e33abc', }); diff --git a/shared/src/business/useCases/editDocketEntry/completeDocketEntryQCInteractor.js b/shared/src/business/useCases/editDocketEntry/completeDocketEntryQCInteractor.js index 9b683c15b73..653ec89c552 100644 --- a/shared/src/business/useCases/editDocketEntry/completeDocketEntryQCInteractor.js +++ b/shared/src/business/useCases/editDocketEntry/completeDocketEntryQCInteractor.js @@ -4,6 +4,10 @@ const { const { aggregatePartiesForService, } = require('../../utilities/aggregatePartiesForService'); +const { + CONTACT_CHANGE_DOCUMENT_TYPES, + NOTICE_OF_DOCKET_CHANGE, +} = require('../../entities/EntityConstants'); const { formatDocument, getFilingsAndProceedings, @@ -16,7 +20,8 @@ const { ROLE_PERMISSIONS, } = require('../../../authorization/authorizationClientService'); const { Case } = require('../../entities/cases/Case'); -const { DOCKET_SECTION } = require('../../entities/WorkQueue'); +const { CASE_CAPTION_POSTFIX } = require('../../entities/EntityConstants'); +const { DOCKET_SECTION } = require('../../entities/EntityConstants'); const { DocketRecord } = require('../../entities/DocketRecord'); const { Document } = require('../../entities/Document'); const { formatDateString } = require('../../utilities/DateHandler'); @@ -144,7 +149,7 @@ exports.completeDocketEntryQCInteractor = async ({ const docketChangeInfo = { caseCaptionExtension, - caseCaptionWithPostfix: `${caseToUpdate.caseCaption} ${Case.CASE_CAPTION_POSTFIX}`, + caseCaptionWithPostfix: `${caseToUpdate.caseCaption} ${CASE_CAPTION_POSTFIX}`, caseTitle, docketEntryIndex: docketRecordIndexUpdated, docketNumber: `${caseToUpdate.docketNumber}${ @@ -234,11 +239,7 @@ exports.completeDocketEntryQCInteractor = async ({ let paperServicePdfUrl; let paperServiceDocumentTitle; - if ( - Document.CONTACT_CHANGE_DOCUMENT_TYPES.includes( - updatedDocument.documentType, - ) - ) { + if (CONTACT_CHANGE_DOCUMENT_TYPES.includes(updatedDocument.documentType)) { if (servedParties.paper.length > 0) { const { Body: pdfData } = await applicationContext .getStorageClient() @@ -294,7 +295,7 @@ exports.completeDocketEntryQCInteractor = async ({ let noticeUpdatedDocument = new Document( { - ...Document.NOTICE_OF_DOCKET_CHANGE, + ...NOTICE_OF_DOCKET_CHANGE, documentId: noticeDocumentId, userId: user.userId, }, @@ -302,7 +303,7 @@ exports.completeDocketEntryQCInteractor = async ({ ); noticeUpdatedDocument.documentTitle = replaceBracketed( - Document.NOTICE_OF_DOCKET_CHANGE.documentTitle, + NOTICE_OF_DOCKET_CHANGE.documentTitle, docketChangeInfo.docketEntryIndex, ); diff --git a/shared/src/business/useCases/editDocketEntry/completeDocketEntryQCInteractor.test.js b/shared/src/business/useCases/editDocketEntry/completeDocketEntryQCInteractor.test.js index 9bdbd1087ea..bd86a6ad41b 100644 --- a/shared/src/business/useCases/editDocketEntry/completeDocketEntryQCInteractor.test.js +++ b/shared/src/business/useCases/editDocketEntry/completeDocketEntryQCInteractor.test.js @@ -6,7 +6,8 @@ const { const { completeDocketEntryQCInteractor, } = require('./completeDocketEntryQCInteractor'); -const { User } = require('../../entities/User'); +const { ROLES } = require('../../entities/EntityConstants'); + const testAssetsPath = path.join(__dirname, '../../../../test-assets/'); describe('completeDocketEntryQCInteractor', () => { @@ -89,7 +90,7 @@ describe('completeDocketEntryQCInteractor', () => { partyType: 'Petitioner', preferredTrialCity: 'Fresno, California', procedureType: 'Regular', - role: User.ROLES.petitioner, + role: ROLES.petitioner, userId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', }; @@ -98,13 +99,13 @@ describe('completeDocketEntryQCInteractor', () => { })); applicationContext.getCurrentUser.mockReturnValue({ name: 'Emmett Lathrop "Doc" Brown, Ph.D.', - role: User.ROLES.docketClerk, + role: ROLES.docketClerk, section: 'docket', userId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', }); applicationContext.getPersistenceGateway().getUserById.mockReturnValue({ name: 'Emmett Lathrop "Doc" Brown, Ph.D.', - role: User.ROLES.docketClerk, + role: ROLES.docketClerk, section: 'docket', userId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', }); diff --git a/shared/src/business/useCases/externalDocument/fileExternalDocumentForConsolidatedInteractor.js b/shared/src/business/useCases/externalDocument/fileExternalDocumentForConsolidatedInteractor.js index 5e2a9e4532a..2de6e0fed71 100644 --- a/shared/src/business/useCases/externalDocument/fileExternalDocumentForConsolidatedInteractor.js +++ b/shared/src/business/useCases/externalDocument/fileExternalDocumentForConsolidatedInteractor.js @@ -7,7 +7,7 @@ const { } = require('../../../authorization/authorizationClientService'); const { capitalize, pick } = require('lodash'); const { Case } = require('../../entities/cases/Case'); -const { DOCKET_SECTION } = require('../../entities/WorkQueue'); +const { DOCKET_SECTION } = require('../../entities/EntityConstants'); const { DocketRecord } = require('../../entities/DocketRecord'); const { Document } = require('../../entities/Document'); const { Message } = require('../../entities/Message'); diff --git a/shared/src/business/useCases/externalDocument/fileExternalDocumentForConsolidatedInteractor.test.js b/shared/src/business/useCases/externalDocument/fileExternalDocumentForConsolidatedInteractor.test.js index 7cc483b8f5d..13510647d6e 100644 --- a/shared/src/business/useCases/externalDocument/fileExternalDocumentForConsolidatedInteractor.test.js +++ b/shared/src/business/useCases/externalDocument/fileExternalDocumentForConsolidatedInteractor.test.js @@ -4,9 +4,8 @@ const { const { fileExternalDocumentForConsolidatedInteractor, } = require('./fileExternalDocumentForConsolidatedInteractor'); -const { ContactFactory } = require('../../entities/contacts/ContactFactory'); const { MOCK_CASE } = require('../../../test/mockCase.js'); -const { User } = require('../../entities/User'); +const { PARTY_TYPES, ROLES } = require('../../entities/EntityConstants'); describe('fileExternalDocumentForConsolidatedInteractor', () => { let caseRecords; @@ -41,10 +40,10 @@ describe('fileExternalDocumentForConsolidatedInteractor', () => { documents: MOCK_CASE.documents, filingType: 'Myself', leadCaseId: caseId0, - partyType: ContactFactory.PARTY_TYPES.petitioner, + partyType: PARTY_TYPES.petitioner, preferredTrialCity: 'Fresno, California', procedureType: 'Regular', - role: User.ROLES.petitioner, + role: ROLES.petitioner, userId: 'petitioner', }, { @@ -67,10 +66,10 @@ describe('fileExternalDocumentForConsolidatedInteractor', () => { documents: MOCK_CASE.documents, filingType: 'Myself', leadCaseId: caseId0, - partyType: ContactFactory.PARTY_TYPES.petitioner, + partyType: PARTY_TYPES.petitioner, preferredTrialCity: 'Fresno, California', procedureType: 'Regular', - role: User.ROLES.petitioner, + role: ROLES.petitioner, userId: 'petitioner', }, { @@ -93,10 +92,10 @@ describe('fileExternalDocumentForConsolidatedInteractor', () => { documents: MOCK_CASE.documents, filingType: 'Myself', leadCaseId: caseId0, - partyType: ContactFactory.PARTY_TYPES.petitioner, + partyType: PARTY_TYPES.petitioner, preferredTrialCity: 'Fresno, California', procedureType: 'Regular', - role: User.ROLES.petitioner, + role: ROLES.petitioner, userId: 'petitioner', }, ]; diff --git a/shared/src/business/useCases/externalDocument/fileExternalDocumentInteractor.js b/shared/src/business/useCases/externalDocument/fileExternalDocumentInteractor.js index 9dcacefd9f0..1f3b46cca4d 100644 --- a/shared/src/business/useCases/externalDocument/fileExternalDocumentInteractor.js +++ b/shared/src/business/useCases/externalDocument/fileExternalDocumentInteractor.js @@ -7,7 +7,8 @@ const { } = require('../../../authorization/authorizationClientService'); const { capitalize, pick } = require('lodash'); const { Case } = require('../../entities/cases/Case'); -const { DOCKET_SECTION } = require('../../entities/WorkQueue'); +const { CASE_STATUS_TYPES } = require('../../entities/EntityConstants'); +const { DOCKET_SECTION } = require('../../entities/EntityConstants'); const { DocketRecord } = require('../../entities/DocketRecord'); const { Document } = require('../../entities/Document'); const { Message } = require('../../entities/Message'); @@ -127,7 +128,7 @@ exports.fileExternalDocumentInteractor = async ({ ); const highPriorityWorkItem = - caseEntity.status === Case.STATUS_TYPES.calendared; + caseEntity.status === CASE_STATUS_TYPES.calendared; const workItem = new WorkItem( { diff --git a/shared/src/business/useCases/externalDocument/fileExternalDocumentInteractor.test.js b/shared/src/business/useCases/externalDocument/fileExternalDocumentInteractor.test.js index 2ee244728f6..afe4da5e82a 100644 --- a/shared/src/business/useCases/externalDocument/fileExternalDocumentInteractor.test.js +++ b/shared/src/business/useCases/externalDocument/fileExternalDocumentInteractor.test.js @@ -4,9 +4,10 @@ const { const { fileExternalDocumentInteractor, } = require('./fileExternalDocumentInteractor'); -const { Case } = require('../../entities/cases/Case'); -const { ContactFactory } = require('../../entities/contacts/ContactFactory'); +const { AUTOMATIC_BLOCKED_REASONS } = require('../../entities/EntityConstants'); +const { CASE_STATUS_TYPES } = require('../../entities/EntityConstants'); const { MOCK_USERS } = require('../../../test/mockUsers'); +const { PARTY_TYPES, ROLES } = require('../../entities/EntityConstants'); const { User } = require('../../entities/User'); describe('fileExternalDocumentInteractor', () => { @@ -63,17 +64,17 @@ describe('fileExternalDocumentInteractor', () => { }, ], filingType: 'Myself', - partyType: ContactFactory.PARTY_TYPES.petitioner, + partyType: PARTY_TYPES.petitioner, preferredTrialCity: 'Fresno, California', procedureType: 'Regular', - role: User.ROLES.petitioner, + role: ROLES.petitioner, userId: '0e97c6b4-d299-44f5-af99-2ce905d520f2', }; applicationContext.getCurrentUser.mockReturnValue( new User({ name: 'irsPractitioner', - role: User.ROLES.irsPractitioner, + role: ROLES.irsPractitioner, userId: 'f7d90c05-f6cd-442c-a168-202db587f16f', }), ); @@ -223,7 +224,7 @@ describe('fileExternalDocumentInteractor', () => { }); it('should create a high-priority work item if the case status is calendared', async () => { - caseRecord.status = Case.STATUS_TYPES.calendared; + caseRecord.status = CASE_STATUS_TYPES.calendared; caseRecord.trialDate = '2019-03-01T21:40:46.415Z'; await fileExternalDocumentInteractor({ @@ -250,7 +251,7 @@ describe('fileExternalDocumentInteractor', () => { }); it('should create a not-high-priority work item if the case status is not calendared', async () => { - caseRecord.status = Case.STATUS_TYPES.new; + caseRecord.status = CASE_STATUS_TYPES.new; await fileExternalDocumentInteractor({ applicationContext, @@ -295,7 +296,7 @@ describe('fileExternalDocumentInteractor', () => { ).toMatchObject({ automaticBlocked: true, automaticBlockedDate: expect.anything(), - automaticBlockedReason: Case.AUTOMATIC_BLOCKED_REASONS.pending, + automaticBlockedReason: AUTOMATIC_BLOCKED_REASONS.pending, }); expect( applicationContext.getPersistenceGateway() @@ -331,7 +332,7 @@ describe('fileExternalDocumentInteractor', () => { ).toMatchObject({ automaticBlocked: true, automaticBlockedDate: expect.anything(), - automaticBlockedReason: Case.AUTOMATIC_BLOCKED_REASONS.pendingAndDueDate, + automaticBlockedReason: AUTOMATIC_BLOCKED_REASONS.pendingAndDueDate, }); expect( applicationContext.getPersistenceGateway() diff --git a/shared/src/business/useCases/externalDocument/uploadDocumentInteractor.test.js b/shared/src/business/useCases/externalDocument/uploadDocumentInteractor.test.js index 2e80fd8060e..5bb4fd6b924 100644 --- a/shared/src/business/useCases/externalDocument/uploadDocumentInteractor.test.js +++ b/shared/src/business/useCases/externalDocument/uploadDocumentInteractor.test.js @@ -1,8 +1,8 @@ const { applicationContext, } = require('../../test/createTestApplicationContext'); +const { ROLES } = require('../../entities/EntityConstants'); const { uploadDocumentInteractor } = require('./uploadDocumentInteractor'); -const { User } = require('../../entities/User'); describe('uploadDocumentInteractor', () => { it('throws an error when an unauthorized user tries to access the use case', async () => { @@ -26,7 +26,7 @@ describe('uploadDocumentInteractor', () => { it('runs successfully with no errors with a valid user', async () => { applicationContext.getCurrentUser.mockReturnValue({ - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: 'petitionsclerk', }); @@ -46,7 +46,7 @@ describe('uploadDocumentInteractor', () => { it('runs successfully with no errors with all data and valid user', async () => { applicationContext.getCurrentUser.mockReturnValue({ - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: 'petitionsclerk', }); @@ -77,7 +77,7 @@ describe('uploadDocumentInteractor', () => { it('runs successfully with no errors with all data and valid user who is a docketclerk', async () => { applicationContext.getCurrentUser.mockReturnValue({ - role: User.ROLES.docketClerk, + role: ROLES.docketClerk, userId: 'docketclerk', }); diff --git a/shared/src/business/useCases/externalDocument/uploadExternalDocumentsInteractor.test.js b/shared/src/business/useCases/externalDocument/uploadExternalDocumentsInteractor.test.js index 95c33896ad4..b97ee98fd08 100644 --- a/shared/src/business/useCases/externalDocument/uploadExternalDocumentsInteractor.test.js +++ b/shared/src/business/useCases/externalDocument/uploadExternalDocumentsInteractor.test.js @@ -4,12 +4,12 @@ const { const { uploadExternalDocumentsInteractor, } = require('./uploadExternalDocumentsInteractor'); -const { User } = require('../../entities/User'); +const { ROLES } = require('../../entities/EntityConstants'); describe('uploadExternalDocumentsInteractor', () => { it('throws an error when an unauthorized user tries to access the use case', async () => { applicationContext.getCurrentUser.mockReturnValue({ - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: 'petitionsclerk', }); @@ -28,7 +28,7 @@ describe('uploadExternalDocumentsInteractor', () => { it('runs successfully with no errors with minimum data and valid user', async () => { applicationContext.getCurrentUser.mockReturnValue({ - role: User.ROLES.irsPractitioner, + role: ROLES.irsPractitioner, userId: 'irsPractitioner', }); @@ -48,7 +48,7 @@ describe('uploadExternalDocumentsInteractor', () => { it('runs successfully with no errors with all data and valid user', async () => { applicationContext.getCurrentUser.mockReturnValue({ - role: User.ROLES.irsPractitioner, + role: ROLES.irsPractitioner, userId: 'irsPractitioner', }); @@ -79,7 +79,7 @@ describe('uploadExternalDocumentsInteractor', () => { it('runs successfully with no errors with all data and valid user who is a practitioner', async () => { applicationContext.getCurrentUser.mockReturnValue({ - role: User.ROLES.irsPractitioner, + role: ROLES.irsPractitioner, userId: 'irsPractitioner', }); diff --git a/shared/src/business/useCases/externalDocument/uploadOrderDocumentInteractor.test.js b/shared/src/business/useCases/externalDocument/uploadOrderDocumentInteractor.test.js index 44a9a94d8ae..7948d16f3aa 100644 --- a/shared/src/business/useCases/externalDocument/uploadOrderDocumentInteractor.test.js +++ b/shared/src/business/useCases/externalDocument/uploadOrderDocumentInteractor.test.js @@ -4,8 +4,8 @@ const { const { uploadOrderDocumentInteractor, } = require('./uploadOrderDocumentInteractor'); +const { ROLES } = require('../../entities/EntityConstants'); const { UnauthorizedError } = require('../../../errors/errors'); -const { User } = require('../../entities/User'); describe('uploadOrderDocumentInteractor', () => { it('throws an error when an unauthorized user tries to access the use case', async () => { @@ -20,7 +20,7 @@ describe('uploadOrderDocumentInteractor', () => { it('uploads documents on behalf of authorized users', async () => { applicationContext.getCurrentUser.mockReturnValue({ - role: User.ROLES.docketClerk, + role: ROLES.docketClerk, userId: 'admin', }); diff --git a/shared/src/business/useCases/filePetitionFromPaperInteractor.test.js b/shared/src/business/useCases/filePetitionFromPaperInteractor.test.js index c00c74b00aa..aca38ed8581 100644 --- a/shared/src/business/useCases/filePetitionFromPaperInteractor.test.js +++ b/shared/src/business/useCases/filePetitionFromPaperInteractor.test.js @@ -2,7 +2,7 @@ const { filePetitionFromPaperInteractor, } = require('./filePetitionFromPaperInteractor'); const { applicationContext } = require('../test/createTestApplicationContext'); -const { User } = require('../entities/User'); +const { ROLES } = require('../entities/EntityConstants'); beforeAll(() => { applicationContext @@ -30,7 +30,7 @@ describe('filePetitionFromPaperInteractor', () => { it('throws an error when an unauthorized user tries to access the case', async () => { applicationContext.getCurrentUser.mockReturnValue({ - role: User.ROLES.irsPractitioner, + role: ROLES.irsPractitioner, userId: 'irsPractitioner', }); let error; @@ -48,7 +48,7 @@ describe('filePetitionFromPaperInteractor', () => { it('calls upload on a Petition file', async () => { applicationContext.getCurrentUser.mockReturnValue({ - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: 'petitionsClerk', }); await filePetitionFromPaperInteractor({ diff --git a/shared/src/business/useCases/filePetitionInteractor.test.js b/shared/src/business/useCases/filePetitionInteractor.test.js index 78874f06c76..caa1780179a 100644 --- a/shared/src/business/useCases/filePetitionInteractor.test.js +++ b/shared/src/business/useCases/filePetitionInteractor.test.js @@ -1,6 +1,6 @@ const { applicationContext } = require('../test/createTestApplicationContext'); const { filePetitionInteractor } = require('./filePetitionInteractor'); -const { User } = require('../entities/User'); +const { ROLES } = require('../entities/EntityConstants'); beforeAll(() => { applicationContext @@ -26,7 +26,7 @@ describe('filePetitionInteractor', () => { it('throws an error when an unauthorized user tries to access the case', async () => { applicationContext.getCurrentUser.mockReturnValue({ - role: User.ROLES.irsPractitioner, + role: ROLES.irsPractitioner, userId: 'irsPractitioner', }); let error; @@ -44,7 +44,7 @@ describe('filePetitionInteractor', () => { it('calls upload on a Petition file', async () => { applicationContext.getCurrentUser.mockReturnValue({ - role: User.ROLES.petitioner, + role: ROLES.petitioner, userId: 'petitioner', }); await filePetitionInteractor({ diff --git a/shared/src/business/useCases/generateDocketRecordPdfInteractor.test.js b/shared/src/business/useCases/generateDocketRecordPdfInteractor.test.js index f67c46db52b..2a761518233 100644 --- a/shared/src/business/useCases/generateDocketRecordPdfInteractor.test.js +++ b/shared/src/business/useCases/generateDocketRecordPdfInteractor.test.js @@ -1,4 +1,4 @@ -import { ContactFactory } from '../entities/contacts/ContactFactory'; +import { COUNTRY_TYPES, PARTY_TYPES } from '../entities/EntityConstants'; import { generateDocketRecordPdfInteractor } from './generateDocketRecordPdfInteractor'; const { applicationContext } = require('../test/createTestApplicationContext'); const { MOCK_USERS } = require('../../test/mockUsers'); @@ -11,7 +11,7 @@ const caseDetail = { contactPrimary: { address1: 'address 1', city: 'City', - countryType: ContactFactory.COUNTRY_TYPES.DOMESTIC, + countryType: COUNTRY_TYPES.DOMESTIC, name: 'Test Petitioner', phone: '123-123-1234', postalCode: '12345', @@ -58,7 +58,7 @@ const caseDetail = { }, ], irsPractitioners: [], - partyType: ContactFactory.PARTY_TYPES.petitioner, + partyType: PARTY_TYPES.petitioner, privatePractitioners: [], }; diff --git a/shared/src/business/useCases/getBlockedCasesInteractor.test.js b/shared/src/business/useCases/getBlockedCasesInteractor.test.js index 7f36d98d67c..beca3a2083f 100644 --- a/shared/src/business/useCases/getBlockedCasesInteractor.test.js +++ b/shared/src/business/useCases/getBlockedCasesInteractor.test.js @@ -1,11 +1,11 @@ const { applicationContext } = require('../test/createTestApplicationContext'); const { getBlockedCasesInteractor } = require('./getBlockedCasesInteractor'); -const { User } = require('../entities/User'); +const { ROLES } = require('../entities/EntityConstants'); describe('getBlockedCasesInteractor', () => { it('calls search function with correct params and returns records', async () => { applicationContext.getCurrentUser.mockReturnValue({ - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: 'petitionsclerk', }); @@ -35,7 +35,7 @@ describe('getBlockedCasesInteractor', () => { it('should throw an unauthorized error if the user does not have access to blocked cases', async () => { applicationContext.getCurrentUser.mockReturnValue({ - role: User.ROLES.petitioner, + role: ROLES.petitioner, userId: 'petitioner', }); diff --git a/shared/src/business/useCases/getCaseInteractor.js b/shared/src/business/useCases/getCaseInteractor.js index c73e9fa170b..c7625f9da16 100644 --- a/shared/src/business/useCases/getCaseInteractor.js +++ b/shared/src/business/useCases/getCaseInteractor.js @@ -61,7 +61,7 @@ exports.getCaseInteractor = async ({ applicationContext, caseId }) => { applicationContext, caseId, }); - } else if (Case.isValidDocketNumber(caseId)) { + } else { caseRecord = await applicationContext .getPersistenceGateway() .getCaseByDocketNumber({ diff --git a/shared/src/business/useCases/getCaseInteractor.test.js b/shared/src/business/useCases/getCaseInteractor.test.js index a058fe7fc91..80a26dfed9d 100644 --- a/shared/src/business/useCases/getCaseInteractor.test.js +++ b/shared/src/business/useCases/getCaseInteractor.test.js @@ -1,8 +1,7 @@ const { applicationContext } = require('../test/createTestApplicationContext'); -const { ContactFactory } = require('../entities/contacts/ContactFactory'); const { getCaseInteractor } = require('./getCaseInteractor'); const { MOCK_CASE } = require('../../test/mockCase'); -const { User } = require('../entities/User'); +const { PARTY_TYPES, ROLES } = require('../entities/EntityConstants'); const { documents } = MOCK_CASE; const petitionsclerkId = '23c4d382-1136-492f-b1f4-45e893c34771'; @@ -14,7 +13,7 @@ const practitioner2Id = '42614976-4228-49aa-a4c3-597dae1c7220'; describe('Get case', () => { it('success case by case id', async () => { applicationContext.getCurrentUser.mockReturnValue({ - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: petitionsclerkId, }); applicationContext @@ -49,7 +48,7 @@ describe('Get case', () => { ], }; applicationContext.getCurrentUser.mockReturnValue({ - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: petitionsclerkId, }); applicationContext @@ -88,7 +87,7 @@ describe('Get case', () => { it('failure case by case id', async () => { applicationContext.getCurrentUser.mockReturnValue({ - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: petitionsclerkId, }); applicationContext @@ -108,7 +107,7 @@ describe('Get case', () => { it('success case by docket number', async () => { applicationContext.getCurrentUser.mockReturnValue({ - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: petitionsclerkId, }); applicationContext @@ -128,6 +127,9 @@ describe('Get case', () => { }); it('failure case by docket number', async () => { + applicationContext + .getPersistenceGateway() + .getCaseByDocketNumber.mockResolvedValue(undefined); await expect( getCaseInteractor({ applicationContext, @@ -148,7 +150,7 @@ describe('Get case', () => { caseId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', caseType: 'Other', createdAt: new Date().toISOString(), - docketNumber: '00101-00', + docketNumber: '101-00', documents, petitioners: [{ name: 'Test Petitioner' }], preferredTrialCity: 'Washington, District of Columbia', @@ -179,12 +181,12 @@ describe('Get case', () => { docketNumber: '00101-18', documents, irsPractitioners: [ - { role: User.ROLES.irsPractitioner, userId: irsPractitionerId }, + { role: ROLES.irsPractitioner, userId: irsPractitionerId }, ], petitioners: [{ name: 'Test Petitioner' }], preferredTrialCity: 'Washington, District of Columbia', privatePractitioners: [ - { role: User.ROLES.privatePractitioner, userId: practitionerId }, + { role: ROLES.privatePractitioner, userId: practitionerId }, ], procedureType: 'Regular', sealedDate: new Date().toISOString(), @@ -194,7 +196,7 @@ describe('Get case', () => { it('restricted case by inadequate permissions', async () => { applicationContext.getCurrentUser.mockReturnValue({ - role: User.ROLES.privatePractitioner, + role: ROLES.privatePractitioner, userId: 'practitioner2', }); @@ -215,7 +217,7 @@ describe('Get case', () => { it('full case access via sealed case permissions', async () => { applicationContext.getCurrentUser.mockReturnValue({ - role: User.ROLES.docketClerk, + role: ROLES.docketClerk, userId: practitioner2Id, }); @@ -240,7 +242,7 @@ describe('Get case', () => { it('throws an error if the entity returned from persistence is invalid', async () => { applicationContext.getCurrentUser.mockReturnValue({ - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: petitionsclerkId, }); applicationContext @@ -250,7 +252,7 @@ describe('Get case', () => { caseId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', caseType: 'Other', createdAt: new Date().toISOString(), - partyType: ContactFactory.PARTY_TYPES.petitioner, + partyType: PARTY_TYPES.petitioner, petitioners: [{ name: 'Test Petitioner' }], preferredTrialCity: 'Washington, District of Columbia', procedureType: 'Regular', diff --git a/shared/src/business/useCases/getClosedCasesInteractor.js b/shared/src/business/useCases/getClosedCasesInteractor.js new file mode 100644 index 00000000000..d32832b1a8d --- /dev/null +++ b/shared/src/business/useCases/getClosedCasesInteractor.js @@ -0,0 +1,30 @@ +const { CASE_STATUS_TYPES } = require('../entities/EntityConstants'); +const { UserCase } = require('../entities/UserCase'); + +/** + * getClosedCasesInteractor + * + * @param {object} providers the providers object + * @param {object} providers.applicationContext the application context + * @returns {object} the closed cases data + */ +exports.getClosedCasesInteractor = async ({ applicationContext }) => { + let closedCases; + let foundCases = []; + + const { userId } = await applicationContext.getCurrentUser(); + + closedCases = await applicationContext + .getPersistenceGateway() + .getIndexedCasesForUser({ + applicationContext, + statuses: [CASE_STATUS_TYPES.closed], + userId, + }); + + foundCases = UserCase.validateRawCollection(closedCases, { + applicationContext, + }); + + return foundCases; +}; diff --git a/shared/src/business/useCases/getOpenCasesInteractor.test.js b/shared/src/business/useCases/getClosedCasesInteractor.test.js similarity index 50% rename from shared/src/business/useCases/getOpenCasesInteractor.test.js rename to shared/src/business/useCases/getClosedCasesInteractor.test.js index ceac46cc0b3..f5b001b14e2 100644 --- a/shared/src/business/useCases/getOpenCasesInteractor.test.js +++ b/shared/src/business/useCases/getClosedCasesInteractor.test.js @@ -1,13 +1,16 @@ const { applicationContext } = require('../test/createTestApplicationContext'); -const { getOpenCasesInteractor } = require('./getOpenCasesInteractor'); +const { CASE_STATUS_TYPES } = require('../entities/EntityConstants'); +const { getClosedCasesInteractor } = require('./getClosedCasesInteractor'); const { MOCK_CASE } = require('../../test/mockCase'); const { MOCK_USERS } = require('../../test/mockUsers'); +jest.mock('../entities/UserCase'); +const { UserCase } = require('../entities/UserCase'); -describe('getOpenCasesInteractor', () => { - let mockCase; +describe('getClosedCasesInteractor', () => { + let mockFoundCasesList; beforeEach(() => { - mockCase = [MOCK_CASE]; + mockFoundCasesList = [MOCK_CASE]; applicationContext .getPersistenceGateway() @@ -19,42 +22,54 @@ describe('getOpenCasesInteractor', () => { ); applicationContext .getPersistenceGateway() - .getOpenCasesByUser.mockImplementation(() => mockCase); + .getIndexedCasesForUser.mockImplementation(() => mockFoundCasesList); + UserCase.validateRawCollection.mockImplementation( + foundCases => foundCases || [], + ); }); it('should retrieve the current user information', async () => { - await getOpenCasesInteractor({ + await getClosedCasesInteractor({ applicationContext, }); expect(applicationContext.getCurrentUser).toBeCalled(); }); - it('should make a call to retrieve open cases by user', async () => { - await getOpenCasesInteractor({ + it('should make a call to retrieve closed cases by user', async () => { + await getClosedCasesInteractor({ applicationContext, }); expect( - applicationContext.getPersistenceGateway().getOpenCasesByUser, + applicationContext.getPersistenceGateway().getIndexedCasesForUser, ).toHaveBeenCalledWith({ applicationContext, + statuses: [CASE_STATUS_TYPES.closed], userId: 'd7d90c05-f6cd-442c-a168-202db587f16f', }); }); - it('should return an empty list when no open cases are found', async () => { - mockCase = null; + it('should return an empty list when no closed cases are found', async () => { + mockFoundCasesList = null; - const result = await getOpenCasesInteractor({ + const result = await getClosedCasesInteractor({ applicationContext, }); expect(result).toEqual([]); }); - it('should return a list of open cases', async () => { - const result = await getOpenCasesInteractor({ + it('should validate the found closed cases', async () => { + await getClosedCasesInteractor({ + applicationContext, + }); + + expect(UserCase.validateRawCollection).toBeCalled(); + }); + + it('should return a list of closed cases', async () => { + const result = await getClosedCasesInteractor({ applicationContext, }); @@ -64,7 +79,6 @@ describe('getOpenCasesInteractor', () => { caseId: MOCK_CASE.caseId, docketNumber: MOCK_CASE.docketNumber, docketNumberWithSuffix: MOCK_CASE.docketNumberWithSuffix, - leadCaseId: MOCK_CASE.leadCaseId, }, ]); }); diff --git a/shared/src/business/useCases/getConsolidatedCasesByUserInteractor.js b/shared/src/business/useCases/getConsolidatedCasesByUserInteractor.js deleted file mode 100644 index 313231fe849..00000000000 --- a/shared/src/business/useCases/getConsolidatedCasesByUserInteractor.js +++ /dev/null @@ -1,86 +0,0 @@ -const { Case } = require('../entities/cases/Case'); -const { UserCase } = require('../entities/UserCase'); - -/** - * getConsolidatedCasesByUserInteractor - * - * @param {object} providers the providers object - * @param {object} providers.applicationContext the application context - * @param {string} providers.userId id of the user to get cases for - * @returns {Array} the cases the user is associated with - */ -// TODO - delete after implementing closed case endpoint -exports.getConsolidatedCasesByUserInteractor = async ({ - applicationContext, - userId, -}) => { - let foundCases = []; - let userCaseIdsMap = {}; - - const userCases = await applicationContext - .getPersistenceGateway() - .getUserDashboardCases({ applicationContext, userId }); - - if (userCases.length) { - const caseMapping = {}; - const leadCaseIdsToGet = []; - - userCases.forEach(caseRecord => { - const userCaseEntity = new UserCase(caseRecord).validate().toRawObject(); - const { caseId, leadCaseId } = userCaseEntity; - - userCaseEntity.isRequestingUserAssociated = true; - userCaseIdsMap[caseId] = true; - - if (!leadCaseId || leadCaseId === caseId) { - caseMapping[caseId] = userCaseEntity; - } - - if (leadCaseId) { - if (leadCaseIdsToGet.indexOf(leadCaseId) === -1) { - leadCaseIdsToGet.push(leadCaseId); - } - } - }); - - for (const leadCaseId of leadCaseIdsToGet) { - const consolidatedCases = await applicationContext - .getPersistenceGateway() - .getCasesByLeadCaseId({ - applicationContext, - leadCaseId, - }); - - const consolidatedCasesValidated = Case.validateRawCollection( - consolidatedCases, - { applicationContext, filtered: true }, - ); - - if (!caseMapping[leadCaseId]) { - const leadCase = consolidatedCasesValidated.find( - consolidatedCase => consolidatedCase.caseId === leadCaseId, - ); - leadCase.isRequestingUserAssociated = false; - caseMapping[leadCaseId] = leadCase; - } - - const caseConsolidatedCases = []; - consolidatedCasesValidated.forEach(consolidatedCase => { - consolidatedCase.isRequestingUserAssociated = !!userCaseIdsMap[ - consolidatedCase.caseId - ]; - if (consolidatedCase.caseId !== leadCaseId) { - caseConsolidatedCases.push(consolidatedCase); - } - }); - - caseMapping[leadCaseId].consolidatedCases = Case.sortByDocketNumber( - caseConsolidatedCases, - ); - } - - foundCases = Object.keys(caseMapping).map(caseId => caseMapping[caseId]); - } - - return foundCases; -}; diff --git a/shared/src/business/useCases/getConsolidatedCasesByUserInteractor.test.js b/shared/src/business/useCases/getConsolidatedCasesByUserInteractor.test.js deleted file mode 100644 index 862976b52ce..00000000000 --- a/shared/src/business/useCases/getConsolidatedCasesByUserInteractor.test.js +++ /dev/null @@ -1,142 +0,0 @@ -const { - getConsolidatedCasesByUserInteractor, -} = require('./getConsolidatedCasesByUserInteractor'); -const { applicationContext } = require('../test/createTestApplicationContext'); -const { MOCK_CASE } = require('../../test/mockCase'); -const { MOCK_USERS } = require('../../test/mockUsers'); - -describe('getConsolidatedCasesByUserInteractor', () => { - beforeEach(() => {}); - - it('returns a collection of consolidated cases for the given user id', async () => { - applicationContext.getCurrentUser.mockReturnValue( - MOCK_USERS['a7d90c05-f6cd-442c-a168-202db587f16f'], - ); - applicationContext - .getPersistenceGateway() - .getUserDashboardCases.mockImplementation(({ userId }) => { - const casesByUserId = { - '74fa8ba9-4f05-45db-9e2d-260a306d0b5e': [ - { - ...MOCK_CASE, - caseId: 'e1f7668e-4504-4f33-8c5a-d4dc17f009ee', - leadCaseId: 'e1f7668e-4504-4f33-8c5a-d4dc17f009ee', - }, - { - ...MOCK_CASE, - caseId: '6ddedc7e-6947-4cfd-a143-833f6de24e95', - }, - { - ...MOCK_CASE, - caseId: '9a1ee699-90d7-4439-a6a8-f910d3441af4', - leadCaseId: 'f6a764ed-f826-41d4-8214-74e959b19ac1', - }, - ], - 'ab2dc429-9055-429f-a7a9-06d3d5324b97': [ - { - ...MOCK_CASE, - caseId: '8453c80c-b1d5-4975-899c-419ff323a506', - leadCaseId: '', - }, - ], - }; - - return casesByUserId[userId]; - }); - - applicationContext - .getPersistenceGateway() - .getCasesByLeadCaseId.mockImplementation(({ leadCaseId }) => { - const casesByLeadCaseId = { - 'e1f7668e-4504-4f33-8c5a-d4dc17f009ee': [ - { - ...MOCK_CASE, - caseId: 'e1f7668e-4504-4f33-8c5a-d4dc17f009ee', - leadCaseId: 'e1f7668e-4504-4f33-8c5a-d4dc17f009ee', - }, - { - ...MOCK_CASE, - caseId: 'bd6d4823-92bc-4ea7-a3af-179a07dfda9e', - docketNumber: '234-02', - leadCaseId: 'e1f7668e-4504-4f33-8c5a-d4dc17f009ee', - }, - { - ...MOCK_CASE, - caseId: '6ddedc7e-6947-4cfd-a143-833f6de24e95', - docketNumber: '345-01', - leadCaseId: 'e1f7668e-4504-4f33-8c5a-d4dc17f009ee', - }, - { - ...MOCK_CASE, - caseId: '8453c80c-b1d5-4975-899c-419ff323a506', - docketNumber: '456-01', - leadCaseId: 'e1f7668e-4504-4f33-8c5a-d4dc17f009ee', - }, - ], - 'f6a764ed-f826-41d4-8214-74e959b19ac1': [ - { - ...MOCK_CASE, - caseId: 'f6a764ed-f826-41d4-8214-74e959b19ac1', - leadCaseId: 'f6a764ed-f826-41d4-8214-74e959b19ac1', - }, - { - ...MOCK_CASE, - caseId: '9a1ee699-90d7-4439-a6a8-f910d3441af4', - leadCaseId: 'f6a764ed-f826-41d4-8214-74e959b19ac1', - }, - ], - }; - return casesByLeadCaseId[leadCaseId]; - }); - - const cases = await getConsolidatedCasesByUserInteractor({ - applicationContext, - userId: '74fa8ba9-4f05-45db-9e2d-260a306d0b5e', - }); - - expect(cases.length).toBeGreaterThan(0); - expect(cases).toMatchObject([ - { - caseId: 'e1f7668e-4504-4f33-8c5a-d4dc17f009ee', - consolidatedCases: [ - { - caseId: '6ddedc7e-6947-4cfd-a143-833f6de24e95', - docketNumber: '345-01', - isRequestingUserAssociated: true, - leadCaseId: 'e1f7668e-4504-4f33-8c5a-d4dc17f009ee', - }, - { - caseId: '8453c80c-b1d5-4975-899c-419ff323a506', - docketNumber: '456-01', - isRequestingUserAssociated: false, - leadCaseId: 'e1f7668e-4504-4f33-8c5a-d4dc17f009ee', - }, - { - caseId: 'bd6d4823-92bc-4ea7-a3af-179a07dfda9e', - docketNumber: '234-02', - isRequestingUserAssociated: false, - leadCaseId: 'e1f7668e-4504-4f33-8c5a-d4dc17f009ee', - }, - ], - isRequestingUserAssociated: true, - leadCaseId: 'e1f7668e-4504-4f33-8c5a-d4dc17f009ee', - }, - { - caseId: '6ddedc7e-6947-4cfd-a143-833f6de24e95', - isRequestingUserAssociated: true, - }, - { - caseId: 'f6a764ed-f826-41d4-8214-74e959b19ac1', - consolidatedCases: [ - { - caseId: '9a1ee699-90d7-4439-a6a8-f910d3441af4', - isRequestingUserAssociated: true, - leadCaseId: 'f6a764ed-f826-41d4-8214-74e959b19ac1', - }, - ], - isRequestingUserAssociated: false, - leadCaseId: 'f6a764ed-f826-41d4-8214-74e959b19ac1', - }, - ]); - }); -}); diff --git a/shared/src/business/useCases/getDownloadPolicyUrlInteractor.js b/shared/src/business/useCases/getDownloadPolicyUrlInteractor.js index d3de94d954b..af4b8697f13 100644 --- a/shared/src/business/useCases/getDownloadPolicyUrlInteractor.js +++ b/shared/src/business/useCases/getDownloadPolicyUrlInteractor.js @@ -6,6 +6,7 @@ const { ROLE_PERMISSIONS, } = require('../../authorization/authorizationClientService'); const { Case } = require('../entities/cases/Case'); +const { ROLES } = require('../entities/EntityConstants'); const { UnauthorizedError } = require('../../errors/errors'); const { User } = require('../entities/User'); @@ -27,8 +28,7 @@ exports.getDownloadPolicyUrlInteractor = async ({ } const isInternalUser = User.isInternalUser(user && user.role); - const isIrsSuperuser = - user && user.role && user.role === User.ROLES.irsSuperuser; + const isIrsSuperuser = user && user.role && user.role === ROLES.irsSuperuser; if (!isInternalUser && !isIrsSuperuser) { //verify that the user has access to this document diff --git a/shared/src/business/useCases/getDownloadPolicyUrlInteractor.test.js b/shared/src/business/useCases/getDownloadPolicyUrlInteractor.test.js index 142881e79b3..76f2624a477 100644 --- a/shared/src/business/useCases/getDownloadPolicyUrlInteractor.test.js +++ b/shared/src/business/useCases/getDownloadPolicyUrlInteractor.test.js @@ -4,7 +4,7 @@ const { const { applicationContext } = require('../test/createTestApplicationContext'); const { cloneDeep } = require('lodash'); const { MOCK_CASE } = require('../../test/mockCase'); -const { User } = require('../entities/User'); +const { ROLES } = require('../entities/EntityConstants'); describe('getDownloadPolicyUrlInteractor', () => { beforeEach(() => { @@ -33,7 +33,7 @@ describe('getDownloadPolicyUrlInteractor', () => { it('throw unauthorized error if user is not associated with case', async () => { applicationContext.getCurrentUser.mockReturnValue({ - role: User.ROLES.petitioner, + role: ROLES.petitioner, userId: 'petitioner', }); applicationContext @@ -51,7 +51,7 @@ describe('getDownloadPolicyUrlInteractor', () => { it('throw unauthorized error if user is associated with the case but the document is not available for viewing at this time', async () => { applicationContext.getCurrentUser.mockReturnValue({ - role: User.ROLES.petitioner, + role: ROLES.petitioner, userId: 'petitioner', }); applicationContext @@ -86,7 +86,7 @@ describe('getDownloadPolicyUrlInteractor', () => { it('returns the expected policy url for a petitioner who is associated with the case and viewing an available document', async () => { applicationContext.getCurrentUser.mockReturnValue({ - role: User.ROLES.petitioner, + role: ROLES.petitioner, userId: 'petitioner', }); applicationContext @@ -103,7 +103,7 @@ describe('getDownloadPolicyUrlInteractor', () => { it('returns the expected policy url for a petitioner who is associated with the case and viewing a case confirmation pdf', async () => { applicationContext.getCurrentUser.mockReturnValue({ - role: User.ROLES.petitioner, + role: ROLES.petitioner, userId: 'petitioner', }); applicationContext @@ -120,7 +120,7 @@ describe('getDownloadPolicyUrlInteractor', () => { it('throws an Unauthorized error for a petitioner attempting to access an case confirmation pdf for a different case', async () => { applicationContext.getCurrentUser.mockReturnValue({ - role: User.ROLES.petitioner, + role: ROLES.petitioner, userId: 'petitioner', }); applicationContext @@ -138,7 +138,7 @@ describe('getDownloadPolicyUrlInteractor', () => { it('returns the url for an internal user role even if verifyCaseForUser returns false', async () => { applicationContext.getCurrentUser.mockReturnValue({ - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: 'petitionsClerk', }); applicationContext @@ -155,7 +155,7 @@ describe('getDownloadPolicyUrlInteractor', () => { it('throws an error if the user role is irsSuperuser and the petition document on the case is not served', async () => { applicationContext.getCurrentUser.mockReturnValue({ - role: User.ROLES.irsSuperuser, + role: ROLES.irsSuperuser, userId: 'irsSuperuser', }); @@ -179,7 +179,7 @@ describe('getDownloadPolicyUrlInteractor', () => { it('returns the url if the user role is irsSuperuser and the petition document on the case is served', async () => { applicationContext.getCurrentUser.mockReturnValue({ - role: User.ROLES.irsSuperuser, + role: ROLES.irsSuperuser, userId: 'irsSuperuser', }); diff --git a/shared/src/business/useCases/getOpenCasesInteractor.js b/shared/src/business/useCases/getOpenCasesInteractor.js deleted file mode 100644 index ccfe19328df..00000000000 --- a/shared/src/business/useCases/getOpenCasesInteractor.js +++ /dev/null @@ -1,81 +0,0 @@ -const { Case } = require('../entities/cases/Case'); -const { UserCase } = require('../entities/UserCase'); - -/** - * getOpenCasesInteractor - * - * @param {object} providers the providers object - * @param {object} providers.applicationContext the application context - * @returns {object} the open cases data - */ -exports.getOpenCasesInteractor = async ({ applicationContext }) => { - let foundCases = []; - let userCaseIdsMap = {}; - - const { userId } = await applicationContext.getCurrentUser(); - - const openCases = await applicationContext - .getPersistenceGateway() - .getOpenCasesByUser({ applicationContext, userId }); - - if (openCases && openCases.length) { - const caseMapping = {}; - const leadCaseIdsToGet = []; - - openCases.forEach(caseRecord => { - const userCaseEntity = new UserCase(caseRecord).validate().toRawObject(); - const { caseId, leadCaseId } = userCaseEntity; - - userCaseEntity.isRequestingUserAssociated = true; - userCaseIdsMap[caseId] = true; - - if (!leadCaseId || leadCaseId === caseId) { - caseMapping[caseId] = userCaseEntity; - } - - if (leadCaseId && !leadCaseIdsToGet.includes(leadCaseId)) { - leadCaseIdsToGet.push(leadCaseId); - } - }); - - for (const leadCaseId of leadCaseIdsToGet) { - const consolidatedCases = await applicationContext - .getPersistenceGateway() - .getCasesByLeadCaseId({ - applicationContext, - leadCaseId, - }); - - const consolidatedCasesValidated = Case.validateRawCollection( - consolidatedCases, - { applicationContext, filtered: true }, - ); - - if (!caseMapping[leadCaseId]) { - const leadCase = consolidatedCasesValidated.find( - consolidatedCase => consolidatedCase.caseId === leadCaseId, - ); - leadCase.isRequestingUserAssociated = false; - caseMapping[leadCaseId] = leadCase; - } - - const caseConsolidatedCases = []; - consolidatedCasesValidated.forEach(consolidatedCase => { - consolidatedCase.isRequestingUserAssociated = !!userCaseIdsMap[ - consolidatedCase.caseId - ]; - if (consolidatedCase.caseId !== leadCaseId) { - caseConsolidatedCases.push(consolidatedCase); - } - }); - - caseMapping[leadCaseId].consolidatedCases = Case.sortByDocketNumber( - caseConsolidatedCases, - ); - } - - foundCases = Object.keys(caseMapping).map(caseId => caseMapping[caseId]); - } - - return foundCases; -}; diff --git a/shared/src/business/useCases/getOpenConsolidatedCasesInteractor.js b/shared/src/business/useCases/getOpenConsolidatedCasesInteractor.js new file mode 100644 index 00000000000..073dfc8f375 --- /dev/null +++ b/shared/src/business/useCases/getOpenConsolidatedCasesInteractor.js @@ -0,0 +1,66 @@ +const { UserCase } = require('../entities/UserCase'); + +/** + * getOpenConsolidatedCasesInteractor + * + * @param {object} providers the providers object + * @param {object} providers.applicationContext the application context + * @returns {object} the open cases data + */ +exports.getOpenConsolidatedCasesInteractor = async ({ applicationContext }) => { + const { userId } = await applicationContext.getCurrentUser(); + + let openUserCases = await applicationContext + .getPersistenceGateway() + .getIndexedCasesForUser({ + applicationContext, + statuses: applicationContext.getConstants().OPEN_CASE_STATUSES, + userId, + }); + + openUserCases = UserCase.validateRawCollection(openUserCases, { + applicationContext, + }); + + if (!openUserCases.length) { + return []; + } + + let { + casesAssociatedWithUserOrLeadCaseMap, + leadCaseIdsAssociatedWithUser, + userAssociatedCaseIdsMap, + } = applicationContext + .getUseCaseHelpers() + .processUserAssociatedCases(openUserCases); + + for (const leadCaseId of leadCaseIdsAssociatedWithUser) { + const consolidatedCases = await applicationContext + .getUseCaseHelpers() + .getConsolidatedCasesForLeadCase({ applicationContext, leadCaseId }); + + if (!casesAssociatedWithUserOrLeadCaseMap[leadCaseId]) { + casesAssociatedWithUserOrLeadCaseMap[ + leadCaseId + ] = applicationContext.getUseCaseHelpers().getUnassociatedLeadCase({ + casesAssociatedWithUserOrLeadCaseMap, + consolidatedCases, + leadCaseId, + }); + } + + casesAssociatedWithUserOrLeadCaseMap[ + leadCaseId + ].consolidatedCases = applicationContext + .getUseCaseHelpers() + .formatAndSortConsolidatedCases({ + consolidatedCases, + leadCaseId, + userAssociatedCaseIdsMap, + }); + } + + const foundCases = Object.values(casesAssociatedWithUserOrLeadCaseMap); + + return foundCases; +}; diff --git a/shared/src/business/useCases/getOpenConsolidatedCasesInteractor.test.js b/shared/src/business/useCases/getOpenConsolidatedCasesInteractor.test.js new file mode 100644 index 00000000000..e81abb6238c --- /dev/null +++ b/shared/src/business/useCases/getOpenConsolidatedCasesInteractor.test.js @@ -0,0 +1,134 @@ +const { + getOpenConsolidatedCasesInteractor, +} = require('./getOpenConsolidatedCasesInteractor'); +const { applicationContext } = require('../test/createTestApplicationContext'); +const { MOCK_CASE } = require('../../test/mockCase'); +const { MOCK_USERS } = require('../../test/mockUsers'); +jest.mock('../entities/UserCase'); +const { UserCase } = require('../entities/UserCase'); + +describe('getOpenConsolidatedCasesInteractor', () => { + let mockFoundCasesList; + + beforeEach(() => { + mockFoundCasesList = [MOCK_CASE]; + + applicationContext + .getPersistenceGateway() + .getUserById.mockReturnValue( + MOCK_USERS['d7d90c05-f6cd-442c-a168-202db587f16f'], + ); + applicationContext.getCurrentUser.mockReturnValue( + MOCK_USERS['d7d90c05-f6cd-442c-a168-202db587f16f'], + ); + applicationContext + .getPersistenceGateway() + .getIndexedCasesForUser.mockImplementation(() => mockFoundCasesList); + applicationContext + .getUseCaseHelpers() + .processUserAssociatedCases.mockReturnValue({ + casesAssociatedWithUserOrLeadCaseMap: { + 'c54ba5a9-b37b-479d-9201-067ec6e335bb': MOCK_CASE, + }, + leadCaseIdsAssociatedWithUser: [MOCK_CASE.caseId], + userAssociatedCaseIdsMap: {}, + }); + applicationContext + .getUseCaseHelpers() + .getConsolidatedCasesForLeadCase.mockReturnValue([]); + UserCase.validateRawCollection.mockImplementation(foundCases => foundCases); + }); + + it('should retrieve the current user information', async () => { + await getOpenConsolidatedCasesInteractor({ + applicationContext, + }); + + expect(applicationContext.getCurrentUser).toBeCalled(); + }); + + it('should make a call to retrieve open cases by user', async () => { + await getOpenConsolidatedCasesInteractor({ + applicationContext, + }); + + expect( + applicationContext.getPersistenceGateway().getIndexedCasesForUser, + ).toHaveBeenCalledWith({ + applicationContext, + statuses: applicationContext.getConstants().OPEN_CASE_STATUSES, + userId: 'd7d90c05-f6cd-442c-a168-202db587f16f', + }); + }); + + it('should validate the list of found open cases', async () => { + await getOpenConsolidatedCasesInteractor({ + applicationContext, + }); + + expect(UserCase.validateRawCollection).toBeCalled(); + }); + + it('should return an empty list when no open cases are found', async () => { + mockFoundCasesList = []; + + const result = await getOpenConsolidatedCasesInteractor({ + applicationContext, + }); + + expect(result).toEqual([]); + }); + + it('should return a list of open cases', async () => { + const result = await getOpenConsolidatedCasesInteractor({ + applicationContext, + }); + + expect(result).toMatchObject([ + { + caseCaption: MOCK_CASE.caseCaption, + caseId: MOCK_CASE.caseId, + docketNumber: MOCK_CASE.docketNumber, + docketNumberWithSuffix: MOCK_CASE.docketNumberWithSuffix, + }, + ]); + }); + + it('should return a list of open cases when the user is associated with a consolidated case that is not the lead case', async () => { + const consolidatedCaseThatIsNotTheLeadCase = { + ...MOCK_CASE, + caseId: applicationContext.getUniqueId(), + isLeadCase: false, + }; + const mockUserAssociatedCaseIdsMap = {}; + mockUserAssociatedCaseIdsMap[ + consolidatedCaseThatIsNotTheLeadCase.caseId + ] = true; + applicationContext + .getUseCaseHelpers() + .processUserAssociatedCases.mockReturnValue({ + casesAssociatedWithUserOrLeadCaseMap: {}, + leadCaseIdsAssociatedWithUser: [ + consolidatedCaseThatIsNotTheLeadCase.caseId, + ], + userAssociatedCaseIdsMap: mockUserAssociatedCaseIdsMap, + }); + applicationContext + .getUseCaseHelpers() + .getUnassociatedLeadCase.mockReturnValue(MOCK_CASE); + applicationContext + .getUseCaseHelpers() + .formatAndSortConsolidatedCases.mockReturnValue([ + consolidatedCaseThatIsNotTheLeadCase, + ]); + + const result = await getOpenConsolidatedCasesInteractor({ + applicationContext, + }); + + expect(result[0]).toBe(MOCK_CASE); + expect(result[0].consolidatedCases[0]).toBe( + consolidatedCaseThatIsNotTheLeadCase, + ); + }); +}); diff --git a/shared/src/business/useCases/getUploadPolicyInteractor.test.js b/shared/src/business/useCases/getUploadPolicyInteractor.test.js index ced6a01e07a..dbe3875d3ec 100644 --- a/shared/src/business/useCases/getUploadPolicyInteractor.test.js +++ b/shared/src/business/useCases/getUploadPolicyInteractor.test.js @@ -1,6 +1,6 @@ const { applicationContext } = require('../test/createTestApplicationContext'); const { getUploadPolicyInteractor } = require('./getUploadPolicyInteractor'); -const { User } = require('../entities/User'); +const { ROLES } = require('../entities/EntityConstants'); describe('getUploadPolicyInteractor', () => { it('throw unauthorized error on invalid role', async () => { @@ -22,7 +22,7 @@ describe('getUploadPolicyInteractor', () => { it('returns the expected policy when the file does not already exist', async () => { applicationContext.getCurrentUser.mockReturnValue({ isExternalUser: () => true, - role: User.ROLES.petitioner, + role: ROLES.petitioner, userId: 'petitioner', }); applicationContext @@ -41,7 +41,7 @@ describe('getUploadPolicyInteractor', () => { it('throws an unauthorized exception when file already exists', async () => { applicationContext.getCurrentUser.mockReturnValue({ isExternalUser: () => true, - role: User.ROLES.petitioner, + role: ROLES.petitioner, userId: 'petitioner', }); applicationContext diff --git a/shared/src/business/useCases/getUserByIdInteractor.js b/shared/src/business/useCases/getUserByIdInteractor.js index 2666fa581fb..bda125fb4c0 100644 --- a/shared/src/business/useCases/getUserByIdInteractor.js +++ b/shared/src/business/useCases/getUserByIdInteractor.js @@ -2,6 +2,7 @@ const { isAuthorized, ROLE_PERMISSIONS, } = require('../../authorization/authorizationClientService'); +const { ROLES } = require('../entities/EntityConstants'); const { UnauthorizedError } = require('../../errors/errors'); const { User } = require('../entities/User'); @@ -22,11 +23,7 @@ exports.getUserByIdInteractor = async ({ applicationContext, userId }) => { .getPersistenceGateway() .getUserById({ applicationContext, userId }); - if ( - ![User.ROLES.privatePractitioner, User.ROLES.irsPractitioner].includes( - user.role, - ) - ) { + if (![ROLES.privatePractitioner, ROLES.irsPractitioner].includes(user.role)) { throw new UnauthorizedError( 'Unauthorized to retrieve users other than practitioners', ); diff --git a/shared/src/business/useCases/getUserByIdInteractor.test.js b/shared/src/business/useCases/getUserByIdInteractor.test.js index 5971f338381..5a9936b0c08 100644 --- a/shared/src/business/useCases/getUserByIdInteractor.test.js +++ b/shared/src/business/useCases/getUserByIdInteractor.test.js @@ -1,16 +1,17 @@ const { applicationContext } = require('../test/createTestApplicationContext'); const { getUserByIdInteractor } = require('./getUserByIdInteractor'); +const { ROLES } = require('../entities/EntityConstants'); const { User } = require('../entities/User'); const MOCK_REQUEST_USER = new User({ name: 'Test Petitions clerk', - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: '6805d1ab-18d0-43ec-bafb-654e83405416', }); const MOCK_RETRIEVED_USER = { name: 'Test Practitioner', - role: User.ROLES.privatePractitioner, + role: ROLES.privatePractitioner, section: 'privatePractitioner', userId: '4f67802c-1948-4749-b070-38f7316b15c5', }; @@ -20,7 +21,7 @@ describe('getUserByIdInteractor', () => { applicationContext.getCurrentUser.mockReturnValue( new User({ name: 'Test Petitioner', - role: User.ROLES.petitioner, + role: ROLES.petitioner, userId: 'e93ce149-b42b-4764-802f-5d321ba36950', }), ); @@ -38,7 +39,7 @@ describe('getUserByIdInteractor', () => { applicationContext.getPersistenceGateway().getUserById.mockReturnValue( new User({ name: 'Test Petitioner', - role: User.ROLES.petitioner, + role: ROLES.petitioner, userId: 'e93ce149-b42b-4764-802f-5d321ba36950', }), ); @@ -69,7 +70,7 @@ describe('getUserByIdInteractor', () => { email: undefined, entityName: 'User', name: 'Test Practitioner', - role: User.ROLES.privatePractitioner, + role: ROLES.privatePractitioner, section: 'privatePractitioner', token: undefined, userId: '4f67802c-1948-4749-b070-38f7316b15c5', diff --git a/shared/src/business/useCases/getUserInteractor.test.js b/shared/src/business/useCases/getUserInteractor.test.js index 7a630be8eb3..5199030ccb0 100644 --- a/shared/src/business/useCases/getUserInteractor.test.js +++ b/shared/src/business/useCases/getUserInteractor.test.js @@ -1,5 +1,6 @@ const { applicationContext } = require('../test/createTestApplicationContext'); const { getUserInteractor } = require('./getUserInteractor'); +const { ROLES } = require('../entities/EntityConstants'); const { User } = require('../entities/User'); describe('getUserInteractor', () => { @@ -7,13 +8,13 @@ describe('getUserInteractor', () => { applicationContext.getCurrentUser.mockReturnValue( new User({ name: 'Test Petitionsclerk', - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: '6805d1ab-18d0-43ec-bafb-654e83405416', }), ); applicationContext.getPersistenceGateway().getUserById.mockReturnValue({ name: 'Test Petitionsclerk', - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, section: 'petitions', userId: '6805d1ab-18d0-43ec-bafb-654e83405416', }); @@ -28,7 +29,7 @@ describe('getUserInteractor', () => { email: undefined, entityName: 'User', name: 'Test Petitionsclerk', - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, section: 'petitions', token: undefined, userId: '6805d1ab-18d0-43ec-bafb-654e83405416', @@ -39,13 +40,13 @@ describe('getUserInteractor', () => { applicationContext.getCurrentUser.mockReturnValue( new User({ name: 'Test Judge', - role: User.ROLES.judge, + role: ROLES.judge, userId: '6805d1ab-18d0-43ec-bafb-654e83405416', }), ); applicationContext.getPersistenceGateway().getUserById.mockReturnValue({ name: 'Test Judge', - role: User.ROLES.judge, + role: ROLES.judge, section: 'judge', userId: '6805d1ab-18d0-43ec-bafb-654e83405416', }); @@ -60,7 +61,7 @@ describe('getUserInteractor', () => { email: undefined, entityName: 'User', name: 'Test Judge', - role: User.ROLES.judge, + role: ROLES.judge, section: 'judge', token: undefined, userId: '6805d1ab-18d0-43ec-bafb-654e83405416', diff --git a/shared/src/business/useCases/manualAssociation/associateIrsPractitionerWithCaseInteractor.test.js b/shared/src/business/useCases/manualAssociation/associateIrsPractitionerWithCaseInteractor.test.js index 47e0e323678..be5a9f5047d 100644 --- a/shared/src/business/useCases/manualAssociation/associateIrsPractitionerWithCaseInteractor.test.js +++ b/shared/src/business/useCases/manualAssociation/associateIrsPractitionerWithCaseInteractor.test.js @@ -4,11 +4,9 @@ const { const { associateIrsPractitionerWithCaseInteractor, } = require('./associateIrsPractitionerWithCaseInteractor'); -const { - SERVICE_INDICATOR_TYPES, -} = require('../../entities/cases/CaseConstants'); const { MOCK_CASE } = require('../../../test/mockCase.js'); -const { User } = require('../../entities/User'); +const { ROLES } = require('../../entities/EntityConstants'); +const { SERVICE_INDICATOR_TYPES } = require('../../entities/EntityConstants'); describe('associateIrsPractitionerWithCaseInteractor', () => { let caseRecord = { @@ -65,12 +63,12 @@ describe('associateIrsPractitionerWithCaseInteractor', () => { it('should add mapping for an irsPractitioner', async () => { mockCurrentUser = { name: 'Emmett Lathrop "Doc" Brown, Ph.D.', - role: User.ROLES.adc, + role: ROLES.adc, userId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', }; mockUserById = { name: 'Emmett Lathrop "Doc" Brown, Ph.D.', - role: User.ROLES.irsPractitioner, + role: ROLES.irsPractitioner, userId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', }; applicationContext diff --git a/shared/src/business/useCases/manualAssociation/associatePrivatePractitionerWithCaseInteractor.test.js b/shared/src/business/useCases/manualAssociation/associatePrivatePractitionerWithCaseInteractor.test.js index 6dd0b24a6ec..ecb2aedc40a 100644 --- a/shared/src/business/useCases/manualAssociation/associatePrivatePractitionerWithCaseInteractor.test.js +++ b/shared/src/business/useCases/manualAssociation/associatePrivatePractitionerWithCaseInteractor.test.js @@ -4,7 +4,7 @@ const { const { associatePrivatePractitionerWithCaseInteractor, } = require('./associatePrivatePractitionerWithCaseInteractor'); -const { User } = require('../../entities/User'); +const { ROLES } = require('../../entities/EntityConstants'); describe('associatePrivatePractitionerWithCaseInteractor', () => { let caseRecord = { @@ -60,7 +60,7 @@ describe('associatePrivatePractitionerWithCaseInteractor', () => { it('should add mapping for a practitioner', async () => { applicationContext.getCurrentUser.mockReturnValue({ name: 'Emmett Lathrop "Doc" Brown, Ph.D.', - role: User.ROLES.adc, + role: ROLES.adc, userId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', }); applicationContext @@ -68,7 +68,7 @@ describe('associatePrivatePractitionerWithCaseInteractor', () => { .getUserById.mockImplementation(() => { return { name: 'Emmett Lathrop "Doc" Brown, Ph.D.', - role: User.ROLES.privatePractitioner, + role: ROLES.privatePractitioner, userId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', }; }); diff --git a/shared/src/business/useCases/messages/createCaseMessageInteractor.js b/shared/src/business/useCases/messages/createCaseMessageInteractor.js new file mode 100644 index 00000000000..2a41ddbc885 --- /dev/null +++ b/shared/src/business/useCases/messages/createCaseMessageInteractor.js @@ -0,0 +1,80 @@ +const { + isAuthorized, + ROLE_PERMISSIONS, +} = require('../../../authorization/authorizationClientService'); +const { CaseMessage } = require('../../entities/CaseMessage'); +const { UnauthorizedError } = require('../../../errors/errors'); + +/** + * creates a message on a case + * + * @param {object} providers the providers object + * @param {object} providers.applicationContext the application context + * @param {array} providers.attachments array of objects containing documentId and documentTitle + * @param {string} providers.caseId the id of the case + * @param {string} providers.message the message text + * @param {string} providers.subject the message subject + * @param {string} providers.toSection the section of the user receiving the message + * @param {string} providers.toUserId the user id of the user receiving the message + * @returns {object} the created message + */ +exports.createCaseMessageInteractor = async ({ + applicationContext, + attachments, + caseId, + message, + subject, + toSection, + toUserId, +}) => { + const authorizedUser = applicationContext.getCurrentUser(); + + if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.MESSAGES)) { + throw new UnauthorizedError('Unauthorized'); + } + + // TODO: Would it be better to just pass this in since case detail is already loaded in the action? + const { + docketNumber, + docketNumberWithSuffix, + status, + } = await applicationContext + .getPersistenceGateway() + .getCaseByCaseId({ applicationContext, caseId }); + + const fromUser = await applicationContext + .getPersistenceGateway() + .getUserById({ applicationContext, userId: authorizedUser.userId }); + + const toUser = await applicationContext + .getPersistenceGateway() + .getUserById({ applicationContext, userId: toUserId }); + + const caseMessage = new CaseMessage( + { + attachments, + caseId, + caseStatus: status, + docketNumber, + docketNumberWithSuffix, + from: fromUser.name, + fromSection: fromUser.section, + fromUserId: fromUser.userId, + message, + subject, + to: toUser.name, + toSection, + toUserId, + }, + { applicationContext }, + ) + .validate() + .toRawObject(); + + await applicationContext.getPersistenceGateway().createCaseMessage({ + applicationContext, + caseMessage, + }); + + return caseMessage; +}; diff --git a/shared/src/business/useCases/messages/createCaseMessageInteractor.test.js b/shared/src/business/useCases/messages/createCaseMessageInteractor.test.js new file mode 100644 index 00000000000..bded6f3bd14 --- /dev/null +++ b/shared/src/business/useCases/messages/createCaseMessageInteractor.test.js @@ -0,0 +1,87 @@ +const { + applicationContext, +} = require('../../test/createTestApplicationContext'); +const { + createCaseMessageInteractor, +} = require('./createCaseMessageInteractor'); +const { + UnauthorizedError, +} = require('../../../../../shared/src/errors/errors'); +const { ROLES } = require('../../entities/EntityConstants'); + +describe('createCaseMessageInteractor', () => { + it('throws unauthorized for a user without MESSAGES permission', async () => { + applicationContext.getCurrentUser.mockReturnValue({ + role: ROLES.petitioner, + userId: '9bd0308c-2b06-4589-b36e-242398bea31b', + }); + + await expect( + createCaseMessageInteractor({ + applicationContext, + }), + ).rejects.toThrow(UnauthorizedError); + }); + + it('creates the case message', async () => { + const caseMessageData = { + attachments: [ + { + documentId: 'b1130321-0a76-43bc-b3eb-64a18f079873', + documentTitle: 'Petition', + }, + ], + caseId: '7a130321-0a76-43bc-b3eb-64a18f07987d', + message: "How's it going?", + subject: 'Hey!', + toSection: 'petitions', + toUserId: 'b427ca37-0df1-48ac-94bb-47aed073d6f7', + }; + applicationContext.getCurrentUser.mockReturnValue({ + role: ROLES.petitionsClerk, + userId: 'b9fcabc8-3c83-4cbf-9f4a-d2ecbdc591e1', + }); + applicationContext + .getPersistenceGateway() + .getUserById.mockReturnValueOnce({ + name: 'Test Petitionsclerk', + role: ROLES.petitionsClerk, + section: 'petitions', + userId: 'b9fcabc8-3c83-4cbf-9f4a-d2ecbdc591e1', + }) + .mockReturnValueOnce({ + name: 'Test Petitionsclerk2', + role: ROLES.petitionsClerk, + section: 'petitions', + userId: 'd90c8a79-9628-4ca9-97c6-02a161a02904', + }); + + applicationContext.getPersistenceGateway().getCaseByCaseId.mockReturnValue({ + docketNumber: '123-45', + docketNumberWithSuffix: '123-45S', + status: 'General Docket - Not at Issue', + }); + + await createCaseMessageInteractor({ + applicationContext, + ...caseMessageData, + }); + + expect( + applicationContext.getPersistenceGateway().createCaseMessage, + ).toBeCalled(); + expect( + applicationContext.getPersistenceGateway().createCaseMessage.mock + .calls[0][0].caseMessage, + ).toMatchObject({ + ...caseMessageData, + caseStatus: 'General Docket - Not at Issue', + docketNumber: '123-45', + docketNumberWithSuffix: '123-45S', + from: 'Test Petitionsclerk', + fromSection: 'petitions', + fromUserId: 'b9fcabc8-3c83-4cbf-9f4a-d2ecbdc591e1', + to: 'Test Petitionsclerk2', + }); + }); +}); diff --git a/shared/src/business/useCases/messages/getCaseMessageInteractor.js b/shared/src/business/useCases/messages/getCaseMessageInteractor.js new file mode 100644 index 00000000000..cdd549358e6 --- /dev/null +++ b/shared/src/business/useCases/messages/getCaseMessageInteractor.js @@ -0,0 +1,36 @@ +const { + isAuthorized, + ROLE_PERMISSIONS, +} = require('../../../authorization/authorizationClientService'); +const { CaseMessage } = require('../../entities/CaseMessage'); +const { UnauthorizedError } = require('../../../errors/errors'); + +/** + * gets a case message + * + * @param {object} providers the providers object + * @param {object} providers.applicationContext the application context + * @param {string} providers.messageId the id of the message to retrieve + * @returns {object} the case message + */ +exports.getCaseMessageInteractor = async ({ + applicationContext, + messageId, +}) => { + const authorizedUser = applicationContext.getCurrentUser(); + + if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.MESSAGES)) { + throw new UnauthorizedError('Unauthorized'); + } + + const caseMessage = await applicationContext + .getPersistenceGateway() + .getCaseMessageById({ + applicationContext, + messageId, + }); + + return new CaseMessage(caseMessage, { applicationContext }) + .validate() + .toRawObject(); +}; diff --git a/shared/src/business/useCases/messages/getCaseMessageInteractor.test.js b/shared/src/business/useCases/messages/getCaseMessageInteractor.test.js new file mode 100644 index 00000000000..e9046be250d --- /dev/null +++ b/shared/src/business/useCases/messages/getCaseMessageInteractor.test.js @@ -0,0 +1,60 @@ +const { + applicationContext, +} = require('../../test/createTestApplicationContext'); +const { + UnauthorizedError, +} = require('../../../../../shared/src/errors/errors'); +const { getCaseMessageInteractor } = require('./getCaseMessageInteractor'); +const { ROLES } = require('../../entities/EntityConstants'); + +describe('getCaseMessageInteractor', () => { + it('throws unauthorized for a user without MESSAGES permission', async () => { + applicationContext.getCurrentUser.mockReturnValue({ + role: ROLES.petitioner, + userId: '9bd0308c-2b06-4589-b36e-242398bea31b', + }); + + await expect( + getCaseMessageInteractor({ + applicationContext, + }), + ).rejects.toThrow(UnauthorizedError); + }); + + it('retrieves the case message from persistence and returns it', async () => { + const caseMessageData = { + caseId: '7a130321-0a76-43bc-b3eb-64a18f07987d', + caseStatus: 'General Docket - Not at Issue', + createdAt: '2019-03-01T21:40:46.415Z', + docketNumber: '123-45', + docketNumberWithSuffix: '123-45S', + entityName: 'CaseMessage', + from: 'Test Petitionsclerk2', + fromSection: 'petitions', + fromUserId: 'fe6eeadd-e4e8-4e56-9ddf-0ebe9516df6b', + message: "How's it going?", + messageId: '9ca37b65-9aac-4621-b5d7-e4a7c8a26a21', + subject: 'Hey!', + to: 'Test Petitionsclerk', + toSection: 'petitions', + toUserId: 'b427ca37-0df1-48ac-94bb-47aed073d6f7', + }; + applicationContext.getCurrentUser.mockReturnValue({ + role: ROLES.petitionsClerk, + userId: 'b9fcabc8-3c83-4cbf-9f4a-d2ecbdc591e1', + }); + applicationContext + .getPersistenceGateway() + .getCaseMessageById.mockReturnValue(caseMessageData); + + const returnedMessage = await getCaseMessageInteractor({ + applicationContext, + messageId: caseMessageData.messageId, + }); + + expect( + applicationContext.getPersistenceGateway().getCaseMessageById, + ).toBeCalled(); + expect(returnedMessage).toEqual(caseMessageData); + }); +}); diff --git a/shared/src/business/useCases/messages/getInboxCaseMessagesForSectionInteractor.js b/shared/src/business/useCases/messages/getInboxCaseMessagesForSectionInteractor.js new file mode 100644 index 00000000000..54b42eb479e --- /dev/null +++ b/shared/src/business/useCases/messages/getInboxCaseMessagesForSectionInteractor.js @@ -0,0 +1,36 @@ +const { + isAuthorized, + ROLE_PERMISSIONS, +} = require('../../../authorization/authorizationClientService'); +const { CaseMessage } = require('../../entities/CaseMessage'); +const { UnauthorizedError } = require('../../../errors/errors'); + +/** + * getInboxCaseMessagesForSectionInteractor + * + * @param {object} providers the providers object + * @param {object} providers.applicationContext the application context + * @param {string} providers.section the section to get the inbox messages + * @returns {object} the messages in the section inbox + */ +exports.getInboxCaseMessagesForSectionInteractor = async ({ + applicationContext, + section, +}) => { + const authorizedUser = applicationContext.getCurrentUser(); + + if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.MESSAGES)) { + throw new UnauthorizedError('Unauthorized'); + } + + const messages = await applicationContext + .getPersistenceGateway() + .getSectionInboxMessages({ + applicationContext, + section, + }); + + return CaseMessage.validateRawCollection(messages, { + applicationContext, + }); +}; diff --git a/shared/src/business/useCases/messages/getInboxCaseMessagesForSectionInteractor.test.js b/shared/src/business/useCases/messages/getInboxCaseMessagesForSectionInteractor.test.js new file mode 100644 index 00000000000..6273ca5d284 --- /dev/null +++ b/shared/src/business/useCases/messages/getInboxCaseMessagesForSectionInteractor.test.js @@ -0,0 +1,64 @@ +const { + applicationContext, +} = require('../../test/createTestApplicationContext'); +const { + getInboxCaseMessagesForSectionInteractor, +} = require('./getInboxCaseMessagesForSectionInteractor'); +const { + UnauthorizedError, +} = require('../../../../../shared/src/errors/errors'); +const { omit } = require('lodash'); +const { ROLES } = require('../../entities/EntityConstants'); + +describe('getInboxCaseMessagesForSectionInteractor', () => { + it('throws unauthorized for a user without MESSAGES permission', async () => { + applicationContext.getCurrentUser.mockReturnValue({ + role: ROLES.petitioner, + userId: '9bd0308c-2b06-4589-b36e-242398bea31b', + }); + + await expect( + getInboxCaseMessagesForSectionInteractor({ + applicationContext, + }), + ).rejects.toThrow(UnauthorizedError); + }); + + it('retrieves the case messages from persistence and returns them', async () => { + const caseMessageData = { + caseId: '7a130321-0a76-43bc-b3eb-64a18f07987d', + createdAt: '2019-03-01T21:40:46.415Z', + docketNumber: '123-45', + docketNumberWithSuffix: '123-45S', + entityName: 'CaseMessage', + from: 'Test Petitionsclerk2', + fromSection: 'petitions', + fromUserId: 'fe6eeadd-e4e8-4e56-9ddf-0ebe9516df6b', + message: "How's it going?", + messageId: '9ca37b65-9aac-4621-b5d7-e4a7c8a26a21', + pk: 'case|9ca37b65-9aac-4621-b5d7-e4a7c8a26a21', + sk: 'message|9ca37b65-9aac-4621-b5d7-e4a7c8a26a21', + subject: 'Hey!', + to: 'Test Petitionsclerk', + toSection: 'petitions', + toUserId: 'b427ca37-0df1-48ac-94bb-47aed073d6f7', + }; + applicationContext.getCurrentUser.mockReturnValue({ + role: ROLES.petitionsClerk, + userId: 'b9fcabc8-3c83-4cbf-9f4a-d2ecbdc591e1', + }); + applicationContext + .getPersistenceGateway() + .getSectionInboxMessages.mockReturnValue([caseMessageData]); + + const returnedMessages = await getInboxCaseMessagesForSectionInteractor({ + applicationContext, + section: caseMessageData.section, + }); + + expect( + applicationContext.getPersistenceGateway().getSectionInboxMessages, + ).toBeCalled(); + expect(returnedMessages).toEqual([omit(caseMessageData, 'pk', 'sk')]); + }); +}); diff --git a/shared/src/business/useCases/messages/getInboxCaseMessagesForUserInteractor.js b/shared/src/business/useCases/messages/getInboxCaseMessagesForUserInteractor.js new file mode 100644 index 00000000000..dd9e00d9728 --- /dev/null +++ b/shared/src/business/useCases/messages/getInboxCaseMessagesForUserInteractor.js @@ -0,0 +1,36 @@ +const { + isAuthorized, + ROLE_PERMISSIONS, +} = require('../../../authorization/authorizationClientService'); +const { CaseMessage } = require('../../entities/CaseMessage'); +const { UnauthorizedError } = require('../../../errors/errors'); + +/** + * getInboxCaseMessagesForUserInteractor + * + * @param {object} providers the providers object + * @param {object} providers.applicationContext the application context + * @param {string} providers.userId the user to get the inbox messages + * @returns {object} the messages in the user inbox + */ +exports.getInboxCaseMessagesForUserInteractor = async ({ + applicationContext, + userId, +}) => { + const authorizedUser = applicationContext.getCurrentUser(); + + if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.MESSAGES)) { + throw new UnauthorizedError('Unauthorized'); + } + + const messages = await applicationContext + .getPersistenceGateway() + .getUserInboxMessages({ + applicationContext, + userId, + }); + + return CaseMessage.validateRawCollection(messages, { + applicationContext, + }); +}; diff --git a/shared/src/business/useCases/messages/getInboxCaseMessagesForUserInteractor.test.js b/shared/src/business/useCases/messages/getInboxCaseMessagesForUserInteractor.test.js new file mode 100644 index 00000000000..f18e5a6d943 --- /dev/null +++ b/shared/src/business/useCases/messages/getInboxCaseMessagesForUserInteractor.test.js @@ -0,0 +1,64 @@ +const { + applicationContext, +} = require('../../test/createTestApplicationContext'); +const { + getInboxCaseMessagesForUserInteractor, +} = require('./getInboxCaseMessagesForUserInteractor'); +const { + UnauthorizedError, +} = require('../../../../../shared/src/errors/errors'); +const { omit } = require('lodash'); +const { ROLES } = require('../../entities/EntityConstants'); + +describe('getInboxCaseMessagesForUserInteractor', () => { + it('throws unauthorized for a user without MESSAGES permission', async () => { + applicationContext.getCurrentUser.mockReturnValue({ + role: ROLES.petitioner, + userId: '9bd0308c-2b06-4589-b36e-242398bea31b', + }); + + await expect( + getInboxCaseMessagesForUserInteractor({ + applicationContext, + }), + ).rejects.toThrow(UnauthorizedError); + }); + + it('retrieves the case messages from persistence and returns them', async () => { + const caseMessageData = { + caseId: '7a130321-0a76-43bc-b3eb-64a18f07987d', + createdAt: '2019-03-01T21:40:46.415Z', + docketNumber: '123-45', + docketNumberWithSuffix: '123-45S', + entityName: 'CaseMessage', + from: 'Test Petitionsclerk2', + fromSection: 'petitions', + fromUserId: 'fe6eeadd-e4e8-4e56-9ddf-0ebe9516df6b', + message: "How's it going?", + messageId: '9ca37b65-9aac-4621-b5d7-e4a7c8a26a21', + pk: 'case|9ca37b65-9aac-4621-b5d7-e4a7c8a26a21', + sk: 'message|9ca37b65-9aac-4621-b5d7-e4a7c8a26a21', + subject: 'Hey!', + to: 'Test Petitionsclerk', + toSection: 'petitions', + toUserId: 'b427ca37-0df1-48ac-94bb-47aed073d6f7', + }; + applicationContext.getCurrentUser.mockReturnValue({ + role: ROLES.petitionsClerk, + userId: 'b9fcabc8-3c83-4cbf-9f4a-d2ecbdc591e1', + }); + applicationContext + .getPersistenceGateway() + .getUserInboxMessages.mockReturnValue([caseMessageData]); + + const returnedMessages = await getInboxCaseMessagesForUserInteractor({ + applicationContext, + messageId: caseMessageData.messageId, + }); + + expect( + applicationContext.getPersistenceGateway().getUserInboxMessages, + ).toBeCalled(); + expect(returnedMessages).toEqual([omit(caseMessageData, 'pk', 'sk')]); + }); +}); diff --git a/shared/src/business/useCases/messages/getOutboxCaseMessagesForSectionInteractor.js b/shared/src/business/useCases/messages/getOutboxCaseMessagesForSectionInteractor.js new file mode 100644 index 00000000000..8364e2d6609 --- /dev/null +++ b/shared/src/business/useCases/messages/getOutboxCaseMessagesForSectionInteractor.js @@ -0,0 +1,36 @@ +const { + isAuthorized, + ROLE_PERMISSIONS, +} = require('../../../authorization/authorizationClientService'); +const { CaseMessage } = require('../../entities/CaseMessage'); +const { UnauthorizedError } = require('../../../errors/errors'); + +/** + * getOutboxCaseMessagesForSectionInteractor + * + * @param {object} providers the providers object + * @param {object} providers.applicationContext the application context + * @param {string} providers.section the section to get the outbox messages + * @returns {object} the messages in the section outbox + */ +exports.getOutboxCaseMessagesForSectionInteractor = async ({ + applicationContext, + section, +}) => { + const authorizedUser = applicationContext.getCurrentUser(); + + if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.MESSAGES)) { + throw new UnauthorizedError('Unauthorized'); + } + + const messages = await applicationContext + .getPersistenceGateway() + .getSectionOutboxMessages({ + applicationContext, + section, + }); + + return CaseMessage.validateRawCollection(messages, { + applicationContext, + }); +}; diff --git a/shared/src/business/useCases/messages/getOutboxCaseMessagesForSectionInteractor.test.js b/shared/src/business/useCases/messages/getOutboxCaseMessagesForSectionInteractor.test.js new file mode 100644 index 00000000000..92c4bcf8813 --- /dev/null +++ b/shared/src/business/useCases/messages/getOutboxCaseMessagesForSectionInteractor.test.js @@ -0,0 +1,64 @@ +const { + applicationContext, +} = require('../../test/createTestApplicationContext'); +const { + getOutboxCaseMessagesForSectionInteractor, +} = require('./getOutboxCaseMessagesForSectionInteractor'); +const { + UnauthorizedError, +} = require('../../../../../shared/src/errors/errors'); +const { omit } = require('lodash'); +const { ROLES } = require('../../entities/EntityConstants'); + +describe('getOutboxCaseMessagesForSectionInteractor', () => { + it('throws unauthorized for a user without MESSAGES permission', async () => { + applicationContext.getCurrentUser.mockReturnValue({ + role: ROLES.petitioner, + userId: '9bd0308c-2b06-4589-b36e-242398bea31b', + }); + + await expect( + getOutboxCaseMessagesForSectionInteractor({ + applicationContext, + }), + ).rejects.toThrow(UnauthorizedError); + }); + + it('retrieves the case messages from persistence and returns them', async () => { + const caseMessageData = { + caseId: '7a130321-0a76-43bc-b3eb-64a18f07987d', + createdAt: '2019-03-01T21:40:46.415Z', + docketNumber: '123-45', + docketNumberWithSuffix: '123-45S', + entityName: 'CaseMessage', + from: 'Test Petitionsclerk2', + fromSection: 'petitions', + fromUserId: 'fe6eeadd-e4e8-4e56-9ddf-0ebe9516df6b', + message: "How's it going?", + messageId: '9ca37b65-9aac-4621-b5d7-e4a7c8a26a21', + pk: 'case|9ca37b65-9aac-4621-b5d7-e4a7c8a26a21', + sk: 'message|9ca37b65-9aac-4621-b5d7-e4a7c8a26a21', + subject: 'Hey!', + to: 'Test Petitionsclerk', + toSection: 'petitions', + toUserId: 'b427ca37-0df1-48ac-94bb-47aed073d6f7', + }; + applicationContext.getCurrentUser.mockReturnValue({ + role: ROLES.petitionsClerk, + userId: 'b9fcabc8-3c83-4cbf-9f4a-d2ecbdc591e1', + }); + applicationContext + .getPersistenceGateway() + .getSectionOutboxMessages.mockReturnValue([caseMessageData]); + + const returnedMessages = await getOutboxCaseMessagesForSectionInteractor({ + applicationContext, + section: caseMessageData.section, + }); + + expect( + applicationContext.getPersistenceGateway().getSectionOutboxMessages, + ).toBeCalled(); + expect(returnedMessages).toEqual([omit(caseMessageData, 'pk', 'sk')]); + }); +}); diff --git a/shared/src/business/useCases/messages/getOutboxCaseMessagesForUserInteractor.js b/shared/src/business/useCases/messages/getOutboxCaseMessagesForUserInteractor.js new file mode 100644 index 00000000000..ee24a5e7d9b --- /dev/null +++ b/shared/src/business/useCases/messages/getOutboxCaseMessagesForUserInteractor.js @@ -0,0 +1,36 @@ +const { + isAuthorized, + ROLE_PERMISSIONS, +} = require('../../../authorization/authorizationClientService'); +const { CaseMessage } = require('../../entities/CaseMessage'); +const { UnauthorizedError } = require('../../../errors/errors'); + +/** + * getOutboxCaseMessagesForUserInteractor + * + * @param {object} providers the providers object + * @param {object} providers.applicationContext the application context + * @param {string} providers.userId the user to get the outbox messages + * @returns {object} the messages in the user outbox + */ +exports.getOutboxCaseMessagesForUserInteractor = async ({ + applicationContext, + userId, +}) => { + const authorizedUser = applicationContext.getCurrentUser(); + + if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.MESSAGES)) { + throw new UnauthorizedError('Unauthorized'); + } + + const messages = await applicationContext + .getPersistenceGateway() + .getUserOutboxMessages({ + applicationContext, + userId, + }); + + return CaseMessage.validateRawCollection(messages, { + applicationContext, + }); +}; diff --git a/shared/src/business/useCases/messages/getOutboxCaseMessagesForUserInteractor.test.js b/shared/src/business/useCases/messages/getOutboxCaseMessagesForUserInteractor.test.js new file mode 100644 index 00000000000..a2b20d7ddb8 --- /dev/null +++ b/shared/src/business/useCases/messages/getOutboxCaseMessagesForUserInteractor.test.js @@ -0,0 +1,64 @@ +const { + applicationContext, +} = require('../../test/createTestApplicationContext'); +const { + getOutboxCaseMessagesForUserInteractor, +} = require('./getOutboxCaseMessagesForUserInteractor'); +const { + UnauthorizedError, +} = require('../../../../../shared/src/errors/errors'); +const { omit } = require('lodash'); +const { ROLES } = require('../../entities/EntityConstants'); + +describe('getOutboxCaseMessagesForUserInteractor', () => { + it('throws unauthorized for a user without MESSAGES permission', async () => { + applicationContext.getCurrentUser.mockReturnValue({ + role: ROLES.petitioner, + userId: '9bd0308c-2b06-4589-b36e-242398bea31b', + }); + + await expect( + getOutboxCaseMessagesForUserInteractor({ + applicationContext, + }), + ).rejects.toThrow(UnauthorizedError); + }); + + it('retrieves the case messages from persistence and returns them', async () => { + const caseMessageData = { + caseId: '7a130321-0a76-43bc-b3eb-64a18f07987d', + createdAt: '2019-03-01T21:40:46.415Z', + docketNumber: '123-45', + docketNumberWithSuffix: '123-45S', + entityName: 'CaseMessage', + from: 'Test Petitionsclerk2', + fromSection: 'petitions', + fromUserId: 'fe6eeadd-e4e8-4e56-9ddf-0ebe9516df6b', + message: "How's it going?", + messageId: '9ca37b65-9aac-4621-b5d7-e4a7c8a26a21', + pk: 'case|9ca37b65-9aac-4621-b5d7-e4a7c8a26a21', + sk: 'message|9ca37b65-9aac-4621-b5d7-e4a7c8a26a21', + subject: 'Hey!', + to: 'Test Petitionsclerk', + toSection: 'petitions', + toUserId: 'b427ca37-0df1-48ac-94bb-47aed073d6f7', + }; + applicationContext.getCurrentUser.mockReturnValue({ + role: ROLES.petitionsClerk, + userId: 'b9fcabc8-3c83-4cbf-9f4a-d2ecbdc591e1', + }); + applicationContext + .getPersistenceGateway() + .getUserOutboxMessages.mockReturnValue([caseMessageData]); + + const returnedMessages = await getOutboxCaseMessagesForUserInteractor({ + applicationContext, + userId: caseMessageData.userId, + }); + + expect( + applicationContext.getPersistenceGateway().getUserOutboxMessages, + ).toBeCalled(); + expect(returnedMessages).toEqual([omit(caseMessageData, 'pk', 'sk')]); + }); +}); diff --git a/shared/src/business/useCases/messages/validateCreateCaseMessageInteractor.js b/shared/src/business/useCases/messages/validateCreateCaseMessageInteractor.js new file mode 100644 index 00000000000..82b8ec62b02 --- /dev/null +++ b/shared/src/business/useCases/messages/validateCreateCaseMessageInteractor.js @@ -0,0 +1,18 @@ +const { NewCaseMessage } = require('../../entities/NewCaseMessage'); + +/** + * validateCreateCaseMessageInteractor + * + * @param {object} providers the providers object + * @param {object} providers.applicationContext the application context + * @param {object} providers.message the message data + * @returns {object} errors (null if no errors) + */ +exports.validateCreateCaseMessageInteractor = ({ + applicationContext, + message, +}) => { + return new NewCaseMessage(message, { + applicationContext, + }).getFormattedValidationErrors(); +}; diff --git a/shared/src/business/useCases/messages/validateCreateCaseMessageInteractor.test.js b/shared/src/business/useCases/messages/validateCreateCaseMessageInteractor.test.js new file mode 100644 index 00000000000..0d137daf6df --- /dev/null +++ b/shared/src/business/useCases/messages/validateCreateCaseMessageInteractor.test.js @@ -0,0 +1,37 @@ +const { + applicationContext, +} = require('../../test/createTestApplicationContext'); +const { + validateCreateCaseMessageInteractor, +} = require('./validateCreateCaseMessageInteractor'); + +describe('validateCreateCaseMessageInteractor', () => { + it('returns null when no errors exist in the CaseMessage', () => { + const errors = validateCreateCaseMessageInteractor({ + applicationContext, + message: { + message: 'yup', + subject: 'hi', + toSection: 'petitions', + toUserId: 'fa1179bd-04f5-4934-a716-964d8d7babc6', + }, + }); + + expect(errors).toBeNull(); + }); + + it('returns an error when a subject is missing', () => { + const errors = validateCreateCaseMessageInteractor({ + applicationContext, + message: { + message: 'yup', + toSection: 'petitions', + toUserId: 'fa1179bd-04f5-4934-a716-964d8d7babc6', + }, + }); + + expect(errors).toMatchObject({ + subject: 'Enter a subject line', + }); + }); +}); diff --git a/shared/src/business/useCases/migrateCaseInteractor.test.js b/shared/src/business/useCases/migrateCaseInteractor.test.js index 56acf6a4643..78a5b11901a 100644 --- a/shared/src/business/useCases/migrateCaseInteractor.test.js +++ b/shared/src/business/useCases/migrateCaseInteractor.test.js @@ -1,7 +1,7 @@ const { applicationContext } = require('../test/createTestApplicationContext'); -const { ContactFactory } = require('../entities/contacts/ContactFactory'); const { migrateCaseInteractor } = require('./migrateCaseInteractor'); const { MOCK_CASE } = require('../../test/mockCase.js'); +const { PARTY_TYPES } = require('../entities/EntityConstants'); const { User } = require('../entities/User'); const DATE = '2018-11-21T20:49:28.192Z'; @@ -61,7 +61,7 @@ describe('migrateCaseInteractor', () => { documents: MOCK_CASE.documents, filingType: 'Myself', hasIrsNotice: true, - partyType: ContactFactory.PARTY_TYPES.petitioner, + partyType: PARTY_TYPES.petitioner, petitionFile: new File([], 'test.pdf'), petitionFileSize: 1, preferredTrialCity: 'Fresno, California', @@ -92,7 +92,7 @@ describe('migrateCaseInteractor', () => { docketNumber: '00101-00', filingType: 'Myself', hasIrsNotice: true, - partyType: ContactFactory.PARTY_TYPES.petitioner, + partyType: PARTY_TYPES.petitioner, preferredTrialCity: 'Fresno, California', procedureType: 'Small', }, diff --git a/shared/src/business/useCases/opinionAdvancedSearchInteractor.js b/shared/src/business/useCases/opinionAdvancedSearchInteractor.js index 12e982b3381..fc002f73d08 100644 --- a/shared/src/business/useCases/opinionAdvancedSearchInteractor.js +++ b/shared/src/business/useCases/opinionAdvancedSearchInteractor.js @@ -5,7 +5,9 @@ const { isAuthorized, ROLE_PERMISSIONS, } = require('../../authorization/authorizationClientService'); -const { Document } = require('../../business/entities/Document'); +const { + OPINION_DOCUMENT_TYPES, +} = require('../../business/entities/EntityConstants'); const { UnauthorizedError } = require('../../errors/errors'); /** @@ -56,7 +58,7 @@ exports.opinionAdvancedSearchInteractor = async ({ .getPersistenceGateway() .advancedDocumentSearch({ applicationContext, - documentEventCodes: Document.OPINION_DOCUMENT_TYPES, + documentEventCodes: OPINION_DOCUMENT_TYPES, judgeType: 'judge', ...rawSearch, }); diff --git a/shared/src/business/useCases/opinionAdvancedSearchInteractor.test.js b/shared/src/business/useCases/opinionAdvancedSearchInteractor.test.js index 06643ba648d..7528fe65496 100644 --- a/shared/src/business/useCases/opinionAdvancedSearchInteractor.test.js +++ b/shared/src/business/useCases/opinionAdvancedSearchInteractor.test.js @@ -1,8 +1,10 @@ +const { + OPINION_DOCUMENT_TYPES, +} = require('../../business/entities/EntityConstants'); const { opinionAdvancedSearchInteractor, } = require('./opinionAdvancedSearchInteractor'); const { applicationContext } = require('../test/createTestApplicationContext'); -const { Document } = require('../../business/entities/Document'); describe('opinionAdvancedSearchInteractor', () => { beforeEach(() => { @@ -96,7 +98,7 @@ describe('opinionAdvancedSearchInteractor', () => { applicationContext.getPersistenceGateway().advancedDocumentSearch.mock .calls[0][0], ).toMatchObject({ - documentEventCodes: Document.OPINION_DOCUMENT_TYPES, + documentEventCodes: OPINION_DOCUMENT_TYPES, }); }); }); diff --git a/shared/src/business/useCases/orderAdvancedSearchInteractor.js b/shared/src/business/useCases/orderAdvancedSearchInteractor.js index e5db9ac380d..ecaf06ccc5c 100644 --- a/shared/src/business/useCases/orderAdvancedSearchInteractor.js +++ b/shared/src/business/useCases/orderAdvancedSearchInteractor.js @@ -5,8 +5,10 @@ const { isAuthorized, ROLE_PERMISSIONS, } = require('../../authorization/authorizationClientService'); +const { + ORDER_DOCUMENT_TYPES, +} = require('../../business/entities/EntityConstants'); const { caseSearchFilter } = require('../utilities/caseFilter'); -const { Document } = require('../../business/entities/Document'); const { UnauthorizedError } = require('../../errors/errors'); /** @@ -53,7 +55,7 @@ exports.orderAdvancedSearchInteractor = async ({ .getPersistenceGateway() .advancedDocumentSearch({ applicationContext, - documentEventCodes: Document.ORDER_DOCUMENT_TYPES, + documentEventCodes: ORDER_DOCUMENT_TYPES, judgeType: 'signedJudgeName', ...rawSearch, }); diff --git a/shared/src/business/useCases/orderAdvancedSearchInteractor.test.js b/shared/src/business/useCases/orderAdvancedSearchInteractor.test.js index ec9a5172ff6..a139cc29b3d 100644 --- a/shared/src/business/useCases/orderAdvancedSearchInteractor.test.js +++ b/shared/src/business/useCases/orderAdvancedSearchInteractor.test.js @@ -1,8 +1,10 @@ +const { + ORDER_DOCUMENT_TYPES, +} = require('../../business/entities/EntityConstants'); const { orderAdvancedSearchInteractor, } = require('./orderAdvancedSearchInteractor'); const { applicationContext } = require('../test/createTestApplicationContext'); -const { Document } = require('../../business/entities/Document'); describe('orderAdvancedSearchInteractor', () => { beforeEach(() => { @@ -92,7 +94,7 @@ describe('orderAdvancedSearchInteractor', () => { applicationContext.getPersistenceGateway().advancedDocumentSearch.mock .calls[0][0], ).toMatchObject({ - documentEventCodes: Document.ORDER_DOCUMENT_TYPES, + documentEventCodes: ORDER_DOCUMENT_TYPES, }); }); }); diff --git a/shared/src/business/useCases/pendingItems/fetchPendingItemsInteractor.test.js b/shared/src/business/useCases/pendingItems/fetchPendingItemsInteractor.test.js index 525f4542dfe..5c1e00d39ce 100644 --- a/shared/src/business/useCases/pendingItems/fetchPendingItemsInteractor.test.js +++ b/shared/src/business/useCases/pendingItems/fetchPendingItemsInteractor.test.js @@ -1,7 +1,7 @@ const { fetchPendingItemsInteractor, } = require('./fetchPendingItemsInteractor'); -const { User } = require('../../entities/User'); +const { ROLES } = require('../../entities/EntityConstants'); describe('fetchPendingItemsInteractor', () => { let searchSpy; @@ -10,7 +10,7 @@ describe('fetchPendingItemsInteractor', () => { environment: { stage: 'local' }, getCurrentUser: () => { return { - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: 'petitionsclerk', }; }, @@ -42,7 +42,7 @@ describe('fetchPendingItemsInteractor', () => { it('should throw an unauthorized error if the user does not have access to blocked cases', async () => { applicationContext.getCurrentUser = () => { return { - role: User.ROLES.petitioner, + role: ROLES.petitioner, userId: 'petitioner', }; }; diff --git a/shared/src/business/useCases/pendingItems/generatePrintablePendingReportInteractor.test.js b/shared/src/business/useCases/pendingItems/generatePrintablePendingReportInteractor.test.js index d525f6f922e..480fb80de41 100644 --- a/shared/src/business/useCases/pendingItems/generatePrintablePendingReportInteractor.test.js +++ b/shared/src/business/useCases/pendingItems/generatePrintablePendingReportInteractor.test.js @@ -5,7 +5,7 @@ const { generatePrintablePendingReportInteractor, } = require('./generatePrintablePendingReportInteractor'); const { MOCK_CASE } = require('../../../test/mockCase'); -const { User } = require('../../entities/User'); +const { ROLES } = require('../../entities/EntityConstants'); describe('generatePrintablePendingReportInteractor', () => { beforeAll(() => { @@ -38,7 +38,7 @@ describe('generatePrintablePendingReportInteractor', () => { beforeEach(() => { applicationContext.getCurrentUser.mockReturnValue({ - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: 'petitionsclerk', }); @@ -53,7 +53,7 @@ describe('generatePrintablePendingReportInteractor', () => { it('should throw an unauthorized error if the user does not have access', async () => { applicationContext.getCurrentUser.mockReturnValue({ - role: User.ROLES.petitioner, + role: ROLES.petitioner, userId: 'petitioner', }); diff --git a/shared/src/business/useCases/practitioners/createPractitionerUserInteractor.test.js b/shared/src/business/useCases/practitioners/createPractitionerUserInteractor.test.js index df5971ac3aa..f835a0e6262 100644 --- a/shared/src/business/useCases/practitioners/createPractitionerUserInteractor.test.js +++ b/shared/src/business/useCases/practitioners/createPractitionerUserInteractor.test.js @@ -4,8 +4,8 @@ const { const { createPractitionerUserInteractor, } = require('./createPractitionerUserInteractor'); +const { ROLES } = require('../../entities/EntityConstants'); const { UnauthorizedError } = require('../../../errors/errors'); -const { User } = require('../../entities/User'); const mockUser = { admissionsDate: '2019-03-01T21:40:46.415Z', @@ -19,7 +19,7 @@ const mockUser = { name: 'Test Attorney', originalBarState: 'Oklahoma', practitionerType: 'Attorney', - role: User.ROLES.privatePractitioner, + role: ROLES.privatePractitioner, userId: '07044afe-641b-4d75-a84f-0698870b7650', }; @@ -49,7 +49,7 @@ describe('create practitioner user', () => { it('throws unauthorized for a non-internal user', async () => { testUser = { - role: User.ROLES.petitioner, + role: ROLES.petitioner, userId: '6a2a8f95-0223-442e-8e55-5f094c6bca15', }; diff --git a/shared/src/business/useCases/practitioners/getPractitionerByBarNumberInteractor.test.js b/shared/src/business/useCases/practitioners/getPractitionerByBarNumberInteractor.test.js index 4e9a8f6c153..a98c6e69c10 100644 --- a/shared/src/business/useCases/practitioners/getPractitionerByBarNumberInteractor.test.js +++ b/shared/src/business/useCases/practitioners/getPractitionerByBarNumberInteractor.test.js @@ -4,6 +4,7 @@ const { const { getPractitionerByBarNumberInteractor, } = require('./getPractitionerByBarNumberInteractor'); +const { ROLES } = require('../../entities/EntityConstants'); const { User } = require('../../entities/User'); describe('getPractitionerByBarNumberInteractor', () => { @@ -11,7 +12,7 @@ describe('getPractitionerByBarNumberInteractor', () => { applicationContext.getCurrentUser.mockReturnValue( new User({ name: 'Test Petitioner', - role: User.ROLES.petitioner, + role: ROLES.petitioner, userId: '1005d1ab-18d0-43ec-bafb-654e83405416', }), ); @@ -28,7 +29,7 @@ describe('getPractitionerByBarNumberInteractor', () => { applicationContext.getCurrentUser.mockReturnValue( new User({ name: 'Test Petitionsclerk', - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: '6805d1ab-18d0-43ec-bafb-654e83405416', }), ); @@ -46,7 +47,7 @@ describe('getPractitionerByBarNumberInteractor', () => { name: 'Private Practitioner', originalBarState: 'Oklahoma', practitionerType: 'Attorney', - role: User.ROLES.privatePractitioner, + role: ROLES.privatePractitioner, section: 'privatePractitioner', userId: '6805d1ab-18d0-43ec-bafb-654e83405416', }); @@ -73,7 +74,7 @@ describe('getPractitionerByBarNumberInteractor', () => { name: 'Private Practitioner', originalBarState: 'Oklahoma', practitionerType: 'Attorney', - role: User.ROLES.privatePractitioner, + role: ROLES.privatePractitioner, section: 'privatePractitioner', suffix: undefined, token: undefined, @@ -85,7 +86,7 @@ describe('getPractitionerByBarNumberInteractor', () => { applicationContext.getCurrentUser.mockReturnValue( new User({ name: 'Test Petitionsclerk', - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: '6805d1ab-18d0-43ec-bafb-654e83405416', }), ); @@ -103,7 +104,7 @@ describe('getPractitionerByBarNumberInteractor', () => { name: 'IRS Practitioner', originalBarState: 'Oklahoma', practitionerType: 'Attorney', - role: User.ROLES.irsPractitioner, + role: ROLES.irsPractitioner, section: 'privatePractitioner', userId: '6805d1ab-18d0-43ec-bafb-654e83405416', }); @@ -142,7 +143,7 @@ describe('getPractitionerByBarNumberInteractor', () => { applicationContext.getCurrentUser.mockReturnValue( new User({ name: 'Test Petitionsclerk', - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: '6805d1ab-18d0-43ec-bafb-654e83405416', }), ); diff --git a/shared/src/business/useCases/practitioners/getPractitionersByNameInteractor.test.js b/shared/src/business/useCases/practitioners/getPractitionersByNameInteractor.test.js index a833a9cbe6c..b0c02f24495 100644 --- a/shared/src/business/useCases/practitioners/getPractitionersByNameInteractor.test.js +++ b/shared/src/business/useCases/practitioners/getPractitionersByNameInteractor.test.js @@ -4,19 +4,19 @@ const { const { getPractitionersByNameInteractor, } = require('./getPractitionersByNameInteractor'); -const { User } = require('../../entities/User'); +const { ROLES } = require('../../entities/EntityConstants'); describe('getPractitionersByNameInteractor', () => { beforeEach(() => { applicationContext.getCurrentUser.mockReturnValue({ - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: 'petitionsClerk', }); }); it('returns an unauthorized error on petitioner user role', async () => { applicationContext.getCurrentUser.mockReturnValue({ - role: User.ROLES.petitioner, + role: ROLES.petitioner, userId: 'petitioner', }); diff --git a/shared/src/business/useCases/practitioners/updatePractitionerUserInteractor.test.js b/shared/src/business/useCases/practitioners/updatePractitionerUserInteractor.test.js index efc59647f6b..2d4bd67e9b8 100644 --- a/shared/src/business/useCases/practitioners/updatePractitionerUserInteractor.test.js +++ b/shared/src/business/useCases/practitioners/updatePractitionerUserInteractor.test.js @@ -4,8 +4,8 @@ const { const { updatePractitionerUserInteractor, } = require('./updatePractitionerUserInteractor'); +const { ROLES } = require('../../entities/EntityConstants'); const { UnauthorizedError } = require('../../../errors/errors'); -const { User } = require('../../entities/User'); const mockUser = { admissionsDate: '2019-03-01T21:40:46.415Z', @@ -20,7 +20,7 @@ const mockUser = { name: 'Test Attorney', originalBarState: 'Oklahoma', practitionerType: 'Attorney', - role: User.ROLES.privatePractitioner, + role: ROLES.privatePractitioner, userId: 'df56e4f8-b302-46ec-b9b3-a6a5e2142092', }; @@ -86,7 +86,7 @@ describe('update practitioner user', () => { it('throws unauthorized for a non-internal user', async () => { testUser = { - role: User.ROLES.petitioner, + role: ROLES.petitioner, userId: 'petitioner', }; diff --git a/shared/src/business/useCases/prioritizeCaseInteractor.test.js b/shared/src/business/useCases/prioritizeCaseInteractor.test.js index f98d8d34ca4..6991d356d41 100644 --- a/shared/src/business/useCases/prioritizeCaseInteractor.test.js +++ b/shared/src/business/useCases/prioritizeCaseInteractor.test.js @@ -1,13 +1,13 @@ const { applicationContext } = require('../test/createTestApplicationContext'); -const { Case } = require('../entities/cases/Case'); +const { CASE_STATUS_TYPES } = require('../entities/EntityConstants'); const { MOCK_CASE } = require('../../test/mockCase'); const { prioritizeCaseInteractor } = require('./prioritizeCaseInteractor'); -const { User } = require('../entities/User'); +const { ROLES } = require('../entities/EntityConstants'); describe('prioritizeCaseInteractor', () => { it('should update the case with the highPriority flag set as true and attach a reason', async () => { applicationContext.getCurrentUser.mockReturnValue({ - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: 'petitionsclerk', }); applicationContext @@ -47,13 +47,13 @@ describe('prioritizeCaseInteractor', () => { it('should throw an error if the case status is calendared', async () => { applicationContext.getCurrentUser.mockReturnValue({ - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: 'petitionsclerk', }); applicationContext.getPersistenceGateway().getCaseByCaseId.mockReturnValue( Promise.resolve({ ...MOCK_CASE, - status: Case.STATUS_TYPES.calendared, + status: CASE_STATUS_TYPES.calendared, }), ); diff --git a/shared/src/business/useCases/processStreamRecordsInteractor.test.js b/shared/src/business/useCases/processStreamRecordsInteractor.test.js index 6d7e6e59075..f54c99df154 100644 --- a/shared/src/business/useCases/processStreamRecordsInteractor.test.js +++ b/shared/src/business/useCases/processStreamRecordsInteractor.test.js @@ -230,17 +230,20 @@ describe('processStreamRecordsInteractor', () => { it('attempts to reindex if bulk indexing returns error data', async () => { applicationContext.getSearchClient().bulk.mockResolvedValue({ - body: { - errors: [{ badError: true }], - items: [ - { - index: { error: false }, - }, - { - index: { error: true }, + errors: true, + items: [ + { + index: {}, + }, + { + index: { + error: { + reason: 'document missing', + type: 'document_missing_exception', + }, }, - ], - }, + }, + ], }); await processStreamRecordsInteractor({ @@ -276,24 +279,25 @@ describe('processStreamRecordsInteractor', () => { expect(applicationContext.getSearchClient().index).toBeCalled(); expect( applicationContext.getSearchClient().index.mock.calls[0][0], - ).toMatchObject({ - body: { caseId: { S: '2' } }, - }); + ).toMatchObject({ body: { caseId: { S: '2' } } }); }); it('creates a reindex record if bulk indexing returns error data and individual indexing fails', async () => { applicationContext.getSearchClient().bulk.mockResolvedValue({ - body: { - errors: [{ badError: true }], - items: [ - { - index: { error: false }, - }, - { - index: { error: true }, + errors: true, + items: [ + { + index: { error: false }, + }, + { + index: { + error: { + reason: 'document missing', + type: 'document_missing_exception', + }, }, - ], - }, + }, + ], }); applicationContext.getSearchClient().index.mockImplementation(() => { throw new Error('bad!'); diff --git a/shared/src/business/useCases/public/casePublicSearchInteractor.test.js b/shared/src/business/useCases/public/casePublicSearchInteractor.test.js index 7114e83e977..dcca57f4625 100644 --- a/shared/src/business/useCases/public/casePublicSearchInteractor.test.js +++ b/shared/src/business/useCases/public/casePublicSearchInteractor.test.js @@ -60,6 +60,7 @@ describe('casePublicSearchInteractor', () => { createdAt: undefined, docketNumber: '123-19', docketNumberSuffix: 'S', + docketNumberWithSuffix: '123-19S', docketRecord: [], documents: [], isSealed: false, @@ -73,6 +74,7 @@ describe('casePublicSearchInteractor', () => { createdAt: undefined, docketNumber: '456-19', docketNumberSuffix: 'S', + docketNumberWithSuffix: '456-19S', docketRecord: [], documents: [], isSealed: false, @@ -111,6 +113,7 @@ describe('casePublicSearchInteractor', () => { createdAt: undefined, docketNumber: '123-19', docketNumberSuffix: 'S', + docketNumberWithSuffix: '123-19S', docketRecord: [], documents: [], isSealed: false, @@ -149,6 +152,7 @@ describe('casePublicSearchInteractor', () => { createdAt: undefined, docketNumber: '123-19', docketNumberSuffix: 'S', + docketNumberWithSuffix: '123-19S', docketRecord: [], documents: [], isSealed: false, diff --git a/shared/src/business/useCases/public/getCaseForPublicDocketSearchInteractor.js b/shared/src/business/useCases/public/getCaseForPublicDocketSearchInteractor.js index b72ca5d8c7a..5145b92742c 100644 --- a/shared/src/business/useCases/public/getCaseForPublicDocketSearchInteractor.js +++ b/shared/src/business/useCases/public/getCaseForPublicDocketSearchInteractor.js @@ -23,7 +23,7 @@ exports.getCaseForPublicDocketSearchInteractor = async ({ applicationContext, docketNumber, }); - } else if (Case.isValidDocketNumber(docketNumber)) { + } else { caseRecord = await applicationContext .getPersistenceGateway() .getCaseByDocketNumber({ diff --git a/shared/src/business/useCases/public/getCaseForPublicDocketSearchInteractor.test.js b/shared/src/business/useCases/public/getCaseForPublicDocketSearchInteractor.test.js index 71338e316bd..88a0d298274 100644 --- a/shared/src/business/useCases/public/getCaseForPublicDocketSearchInteractor.test.js +++ b/shared/src/business/useCases/public/getCaseForPublicDocketSearchInteractor.test.js @@ -47,6 +47,10 @@ describe('Get case for public docket record search', () => { }); it('should throw an error when unable to find a case by docket number', async () => { + applicationContext + .getPersistenceGateway() + .getCaseByDocketNumber.mockResolvedValue(undefined); + await expect( getCaseForPublicDocketSearchInteractor({ applicationContext, diff --git a/shared/src/business/useCases/public/getJudgesForPublicSearchInteractor.js b/shared/src/business/useCases/public/getJudgesForPublicSearchInteractor.js index 6b2cc951490..29917d1abce 100644 --- a/shared/src/business/useCases/public/getJudgesForPublicSearchInteractor.js +++ b/shared/src/business/useCases/public/getJudgesForPublicSearchInteractor.js @@ -1,5 +1,5 @@ const { PublicUser } = require('../../entities/PublicUser'); -const { User } = require('../../entities/User'); +const { ROLES } = require('../../entities/EntityConstants'); /** * getJudgesForPublicSearchInteractor @@ -13,7 +13,7 @@ exports.getJudgesForPublicSearchInteractor = async ({ applicationContext }) => { .getPersistenceGateway() .getUsersInSection({ applicationContext, - section: User.ROLES.judge, + section: ROLES.judge, }); return PublicUser.validateRawCollection(rawJudges, { applicationContext }); diff --git a/shared/src/business/useCases/public/getJudgesForPublicSearchInteractor.test.js b/shared/src/business/useCases/public/getJudgesForPublicSearchInteractor.test.js index b960bcf8256..3669bf25842 100644 --- a/shared/src/business/useCases/public/getJudgesForPublicSearchInteractor.test.js +++ b/shared/src/business/useCases/public/getJudgesForPublicSearchInteractor.test.js @@ -4,7 +4,7 @@ const { const { getJudgesForPublicSearchInteractor, } = require('./getJudgesForPublicSearchInteractor'); -const { User } = require('../../entities/User'); +const { ROLES } = require('../../entities/EntityConstants'); describe('getJudgesForPublicSearchInteractor', () => { it('strips out all non public data', async () => { @@ -37,7 +37,7 @@ describe('getJudgesForPublicSearchInteractor', () => { expect( applicationContext.getPersistenceGateway().getUsersInSection, - ).toHaveBeenCalledWith({ applicationContext, section: User.ROLES.judge }); + ).toHaveBeenCalledWith({ applicationContext, section: ROLES.judge }); expect(results).toEqual([ { judgeFullName: 'Lila A. Fenwick', diff --git a/shared/src/business/useCases/public/getPublicCaseInteractor.js b/shared/src/business/useCases/public/getPublicCaseInteractor.js index 7b8fd32c25f..185ffb77b1f 100644 --- a/shared/src/business/useCases/public/getPublicCaseInteractor.js +++ b/shared/src/business/useCases/public/getPublicCaseInteractor.js @@ -21,7 +21,7 @@ exports.getPublicCaseInteractor = async ({ applicationContext, caseId }) => { applicationContext, caseId, }); - } else if (Case.isValidDocketNumber(caseId)) { + } else { caseRecord = await applicationContext .getPersistenceGateway() .getCaseByDocketNumber({ diff --git a/shared/src/business/useCases/public/getTodaysOpinionsInteractor.js b/shared/src/business/useCases/public/getTodaysOpinionsInteractor.js new file mode 100644 index 00000000000..59eee37bde7 --- /dev/null +++ b/shared/src/business/useCases/public/getTodaysOpinionsInteractor.js @@ -0,0 +1,30 @@ +const { + createEndOfDayISO, + createISODateString, + createStartOfDayISO, + deconstructDate, +} = require('../../utilities/DateHandler'); +const { OPINION_DOCUMENT_TYPES } = require('../../entities/EntityConstants'); + +/** + * getTodaysOpinionsInteractor + * + * @param {object} providers the providers object containing applicationContext + * @param {object} providers.applicationContext application context object + * @returns {array} an array of opinions (if any) + */ +exports.getTodaysOpinionsInteractor = async ({ applicationContext }) => { + const { day, month, year } = deconstructDate(createISODateString()); + const currentDateStart = createStartOfDayISO({ day, month, year }); + const currentDateEnd = createEndOfDayISO({ day, month, year }); + + return await applicationContext + .getPersistenceGateway() + .advancedDocumentSearch({ + applicationContext, + documentEventCodes: OPINION_DOCUMENT_TYPES, + endDate: currentDateEnd, + judgeType: 'judge', + startDate: currentDateStart, + }); +}; diff --git a/shared/src/business/useCases/public/getTodaysOpinionsInteractor.test.js b/shared/src/business/useCases/public/getTodaysOpinionsInteractor.test.js new file mode 100644 index 00000000000..0daa162ee6f --- /dev/null +++ b/shared/src/business/useCases/public/getTodaysOpinionsInteractor.test.js @@ -0,0 +1,71 @@ +const { + applicationContext, +} = require('../../test/createTestApplicationContext'); +const { + createEndOfDayISO, + createISODateString, + createStartOfDayISO, + deconstructDate, +} = require('../../utilities/DateHandler'); +const { + getTodaysOpinionsInteractor, +} = require('./getTodaysOpinionsInteractor'); +const { OPINION_DOCUMENT_TYPES } = require('../../entities/EntityConstants'); + +describe('getTodaysOpinionsInteractor', () => { + const mockOpinionSearchResult = [ + { + caseCaption: 'Reuben Blair, Petitioner', + caseId: '24fcb050-9c95-4d69-a149-96acba0196b8', + contactPrimary: { + address1: '66 East Clarendon Parkway', + address2: 'Ut culpa cum sint ', + address3: 'In laboris hic volup', + city: 'Omnis dignissimos at', + countryType: 'domestic', + email: 'petitioner', + name: 'Reuben Blair', + phone: '+1 (338) 996-7072', + postalCode: '92017', + serviceIndicator: 'Electronic', + state: 'DC', + }, + contactSecondary: {}, + docketNumber: '103-20', + docketNumberSuffix: 'L', + documentId: '6945cdff-fd12-422b-bf2c-63b792b7f618', + documentTitle: 'Memorandum Opinion Judge Armen', + filingDate: '2020-05-12T18:42:10.471Z', + irsPractitioners: [], + isSealed: false, + numberOfPages: 1, + privatePractitioners: [], + signedJudgeName: 'Maurice B. Foley', + }, + ]; + + beforeEach(() => { + applicationContext + .getPersistenceGateway() + .advancedDocumentSearch.mockResolvedValue(mockOpinionSearchResult); + }); + + it('should only search for opinion document types', async () => { + await getTodaysOpinionsInteractor({ + applicationContext, + }); + + const { day, month, year } = deconstructDate(createISODateString()); + const currentDateStart = createStartOfDayISO({ day, month, year }); + const currentDateEnd = createEndOfDayISO({ day, month, year }); + + expect( + applicationContext.getPersistenceGateway().advancedDocumentSearch.mock + .calls[0][0], + ).toMatchObject({ + documentEventCodes: OPINION_DOCUMENT_TYPES, + endDate: currentDateEnd, + startDate: currentDateStart, + }); + }); +}); diff --git a/shared/src/business/useCases/public/opinionPublicSearchInteractor.js b/shared/src/business/useCases/public/opinionPublicSearchInteractor.js index 9d1f4ea339a..81c85349d3d 100644 --- a/shared/src/business/useCases/public/opinionPublicSearchInteractor.js +++ b/shared/src/business/useCases/public/opinionPublicSearchInteractor.js @@ -1,5 +1,5 @@ -const { Document } = require('../../entities/Document'); const { DocumentSearch } = require('../../entities/documents/DocumentSearch'); +const { OPINION_DOCUMENT_TYPES } = require('../../entities/EntityConstants'); /** * opinionPublicSearchInteractor @@ -42,7 +42,7 @@ exports.opinionPublicSearchInteractor = async ({ .getPersistenceGateway() .advancedDocumentSearch({ applicationContext, - documentEventCodes: Document.OPINION_DOCUMENT_TYPES, + documentEventCodes: OPINION_DOCUMENT_TYPES, judgeType: 'judge', ...rawSearch, }); diff --git a/shared/src/business/useCases/public/opinionPublicSearchInteractor.test.js b/shared/src/business/useCases/public/opinionPublicSearchInteractor.test.js index f806d26570c..e463b4e03ba 100644 --- a/shared/src/business/useCases/public/opinionPublicSearchInteractor.test.js +++ b/shared/src/business/useCases/public/opinionPublicSearchInteractor.test.js @@ -4,7 +4,7 @@ const { const { opinionPublicSearchInteractor, } = require('./opinionPublicSearchInteractor'); -const { Document } = require('../../entities/Document'); +const { OPINION_DOCUMENT_TYPES } = require('../../entities/EntityConstants'); describe('opinionPublicSearchInteractor', () => { const mockOpinionSearchResult = [ @@ -54,7 +54,7 @@ describe('opinionPublicSearchInteractor', () => { applicationContext.getPersistenceGateway().advancedDocumentSearch.mock .calls[0][0], ).toMatchObject({ - documentEventCodes: Document.OPINION_DOCUMENT_TYPES, + documentEventCodes: OPINION_DOCUMENT_TYPES, }); }); diff --git a/shared/src/business/useCases/public/orderPublicSearchInteractor.js b/shared/src/business/useCases/public/orderPublicSearchInteractor.js index be3628ea520..c86ed161c8b 100644 --- a/shared/src/business/useCases/public/orderPublicSearchInteractor.js +++ b/shared/src/business/useCases/public/orderPublicSearchInteractor.js @@ -1,5 +1,5 @@ -const { Document } = require('../../entities/Document'); const { DocumentSearch } = require('../../entities/documents/DocumentSearch'); +const { ORDER_DOCUMENT_TYPES } = require('../../entities/EntityConstants'); /** * orderPublicSearchInteractor @@ -40,7 +40,7 @@ exports.orderPublicSearchInteractor = async ({ .getPersistenceGateway() .advancedDocumentSearch({ applicationContext, - documentEventCodes: Document.ORDER_DOCUMENT_TYPES, + documentEventCodes: ORDER_DOCUMENT_TYPES, judgeType: 'signedJudgeName', ...rawSearch, }); diff --git a/shared/src/business/useCases/public/orderPublicSearchInteractor.test.js b/shared/src/business/useCases/public/orderPublicSearchInteractor.test.js index ff1ca574e95..9857c70da34 100644 --- a/shared/src/business/useCases/public/orderPublicSearchInteractor.test.js +++ b/shared/src/business/useCases/public/orderPublicSearchInteractor.test.js @@ -4,7 +4,7 @@ const { const { orderPublicSearchInteractor, } = require('./orderPublicSearchInteractor'); -const { Document } = require('../../entities/Document'); +const { ORDER_DOCUMENT_TYPES } = require('../../entities/EntityConstants'); describe('orderPublicSearchInteractor', () => { beforeEach(() => { @@ -56,7 +56,7 @@ describe('orderPublicSearchInteractor', () => { applicationContext.getPersistenceGateway().advancedDocumentSearch.mock .calls[0][0], ).toMatchObject({ - documentEventCodes: Document.ORDER_DOCUMENT_TYPES, + documentEventCodes: ORDER_DOCUMENT_TYPES, }); }); diff --git a/shared/src/business/useCases/removeCasePendingItemInteractor.test.js b/shared/src/business/useCases/removeCasePendingItemInteractor.test.js index 7ea237d2adf..71d13c33287 100644 --- a/shared/src/business/useCases/removeCasePendingItemInteractor.test.js +++ b/shared/src/business/useCases/removeCasePendingItemInteractor.test.js @@ -2,8 +2,9 @@ const { removeCasePendingItemInteractor, } = require('./removeCasePendingItemInteractor'); const { applicationContext } = require('../test/createTestApplicationContext'); -const { Case } = require('../entities/cases/Case'); +const { AUTOMATIC_BLOCKED_REASONS } = require('../entities/EntityConstants'); const { MOCK_CASE } = require('../../test/mockCase'); +const { ROLES } = require('../entities/EntityConstants'); const { User } = require('../entities/User'); describe('removeCasePendingItemInteractor', () => { @@ -12,7 +13,7 @@ describe('removeCasePendingItemInteractor', () => { beforeEach(() => { user = new User({ name: 'Petitions Clerk', - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: '6805d1ab-18d0-43ec-bafb-654e83405416', }); @@ -28,7 +29,7 @@ describe('removeCasePendingItemInteractor', () => { it('should throw an unauthorized error if user is unauthorized for updating a case', async () => { user = new User({ name: 'Petitioner', - role: User.ROLES.petitioner, + role: ROLES.petitioner, userId: '2c464719-646c-463e-9826-16443500ed88', }); @@ -92,7 +93,7 @@ describe('removeCasePendingItemInteractor', () => { ).toMatchObject({ automaticBlocked: true, automaticBlockedDate: expect.anything(), - automaticBlockedReason: Case.AUTOMATIC_BLOCKED_REASONS.dueDate, + automaticBlockedReason: AUTOMATIC_BLOCKED_REASONS.dueDate, }); expect( applicationContext.getPersistenceGateway() diff --git a/shared/src/business/useCases/saveCaseDetailInternalEditInteractor.test.js b/shared/src/business/useCases/saveCaseDetailInternalEditInteractor.test.js index b9903699918..0837aaa6c13 100644 --- a/shared/src/business/useCases/saveCaseDetailInternalEditInteractor.test.js +++ b/shared/src/business/useCases/saveCaseDetailInternalEditInteractor.test.js @@ -1,11 +1,13 @@ +const { + CASE_STATUS_TYPES, + PARTY_TYPES, +} = require('../entities/EntityConstants'); const { saveCaseDetailInternalEditInteractor, } = require('./saveCaseDetailInternalEditInteractor'); const { applicationContext } = require('../test/createTestApplicationContext'); -const { Case } = require('../entities/cases/Case'); -const { ContactFactory } = require('../entities/contacts/ContactFactory'); const { omit } = require('lodash'); -const { User } = require('../entities/User'); +const { ROLES } = require('../entities/EntityConstants'); describe('updateCase', () => { const MOCK_CASE = { @@ -54,17 +56,17 @@ describe('updateCase', () => { }, ], filingType: 'Myself', - partyType: ContactFactory.PARTY_TYPES.petitioner, + partyType: PARTY_TYPES.petitioner, petitioners: [{ name: 'Test Petitioner' }], preferredTrialCity: 'Washington, District of Columbia', procedureType: 'Regular', - status: Case.STATUS_TYPES.new, + status: CASE_STATUS_TYPES.new, userId: 'userId', }; const petitionsClerkUser = { name: 'petitions clerk', - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: '54cddcd9-d012-4874-b74f-73732c95d42b', }; @@ -138,7 +140,7 @@ describe('updateCase', () => { filingType: 'Myself and my spouse', hasVerifiedIrsNotice: false, isPaper: false, - partyType: ContactFactory.PARTY_TYPES.petitionerSpouse, + partyType: PARTY_TYPES.petitionerSpouse, preferredTrialCity: 'Mobile, Alabama', privatePractitioners: [], procedureType: 'Small', diff --git a/shared/src/business/useCases/saveSignedDocumentInteractor.js b/shared/src/business/useCases/saveSignedDocumentInteractor.js index b86682cb03d..654e676459b 100644 --- a/shared/src/business/useCases/saveSignedDocumentInteractor.js +++ b/shared/src/business/useCases/saveSignedDocumentInteractor.js @@ -1,5 +1,6 @@ const { Case } = require('../entities/cases/Case'); const { Document } = require('../entities/Document'); +const { SIGNED_DOCUMENT_TYPES } = require('../entities/EntityConstants'); /** * saveSignedDocumentInteractor @@ -41,11 +42,10 @@ exports.saveSignedDocumentInteractor = async ({ createdAt: applicationContext.getUtilities().createISODateString(), documentId: signedDocumentId, documentTitle: - Document.SIGNED_DOCUMENT_TYPES.signedStipulatedDecision.documentType, + SIGNED_DOCUMENT_TYPES.signedStipulatedDecision.documentType, documentType: - Document.SIGNED_DOCUMENT_TYPES.signedStipulatedDecision.documentType, - eventCode: - Document.SIGNED_DOCUMENT_TYPES.signedStipulatedDecision.eventCode, + SIGNED_DOCUMENT_TYPES.signedStipulatedDecision.documentType, + eventCode: SIGNED_DOCUMENT_TYPES.signedStipulatedDecision.eventCode, filedBy: originalDocumentEntity.filedBy, isPaper: false, processingStatus: 'complete', diff --git a/shared/src/business/useCases/sealCaseInteractor.test.js b/shared/src/business/useCases/sealCaseInteractor.test.js index 86758ab1938..0418b0e076f 100644 --- a/shared/src/business/useCases/sealCaseInteractor.test.js +++ b/shared/src/business/useCases/sealCaseInteractor.test.js @@ -1,7 +1,7 @@ const { applicationContext } = require('../test/createTestApplicationContext'); const { MOCK_CASE } = require('../../test/mockCase'); +const { ROLES } = require('../entities/EntityConstants'); const { sealCaseInteractor } = require('./sealCaseInteractor'); -const { User } = require('../entities/User'); describe('sealCaseInteractor', () => { beforeAll(() => { @@ -23,7 +23,7 @@ describe('sealCaseInteractor', () => { it('should call updateCase with the sealedDate set on the case and return the updated case', async () => { applicationContext.getCurrentUser.mockReturnValue({ - role: User.ROLES.docketClerk, + role: ROLES.docketClerk, userId: 'docketClerk', }); diff --git a/shared/src/business/useCases/serveCaseToIrs/serveCaseToIrsInteractor.js b/shared/src/business/useCases/serveCaseToIrs/serveCaseToIrsInteractor.js index 7171e29d043..2ce2da5d992 100644 --- a/shared/src/business/useCases/serveCaseToIrs/serveCaseToIrsInteractor.js +++ b/shared/src/business/useCases/serveCaseToIrs/serveCaseToIrsInteractor.js @@ -1,18 +1,22 @@ +const { + INITIAL_DOCUMENT_TYPES, + PAYMENT_STATUS, +} = require('../../entities/EntityConstants'); const { isAuthorized, ROLE_PERMISSIONS, } = require('../../../authorization/authorizationClientService'); const { Case } = require('../../entities/cases/Case'); const { DocketRecord } = require('../../entities/DocketRecord'); -const { Document } = require('../../entities/Document'); -const { PETITIONS_SECTION } = require('../../entities/WorkQueue'); +const { getCaseCaptionMeta } = require('../../utilities/getCaseCaptionMeta'); +const { PETITIONS_SECTION } = require('../../entities/EntityConstants'); const { UnauthorizedError } = require('../../../errors/errors'); exports.addDocketEntryForPaymentStatus = ({ applicationContext, caseEntity, }) => { - if (caseEntity.petitionPaymentStatus === Case.PAYMENT_STATUS.PAID) { + if (caseEntity.petitionPaymentStatus === PAYMENT_STATUS.PAID) { caseEntity.addDocketRecord( new DocketRecord( { @@ -23,7 +27,7 @@ exports.addDocketEntryForPaymentStatus = ({ { applicationContext }, ), ); - } else if (caseEntity.petitionPaymentStatus === Case.PAYMENT_STATUS.WAIVED) { + } else if (caseEntity.petitionPaymentStatus === PAYMENT_STATUS.WAIVED) { caseEntity.addDocketRecord( new DocketRecord( { @@ -40,8 +44,7 @@ exports.addDocketEntryForPaymentStatus = ({ exports.deleteStinIfAvailable = async ({ applicationContext, caseEntity }) => { const stinDocument = caseEntity.documents.find( document => - document.documentType === - Document.INITIAL_DOCUMENT_TYPES.stin.documentType, + document.documentType === INITIAL_DOCUMENT_TYPES.stin.documentType, ); if (stinDocument) { @@ -80,11 +83,8 @@ exports.serveCaseToIrsInteractor = async ({ applicationContext, caseId }) => { caseEntity.markAsSentToIRS(); - for (const initialDocumentTypeKey of Object.keys( - Document.INITIAL_DOCUMENT_TYPES, - )) { - const initialDocumentType = - Document.INITIAL_DOCUMENT_TYPES[initialDocumentTypeKey]; + for (const initialDocumentTypeKey of Object.keys(INITIAL_DOCUMENT_TYPES)) { + const initialDocumentType = INITIAL_DOCUMENT_TYPES[initialDocumentTypeKey]; const initialDocument = caseEntity.documents.find( document => document.documentType === initialDocumentType.documentType, @@ -101,7 +101,7 @@ exports.serveCaseToIrsInteractor = async ({ applicationContext, caseId }) => { if ( initialDocument.documentType === - Document.INITIAL_DOCUMENT_TYPES.petition.documentType + INITIAL_DOCUMENT_TYPES.petition.documentType ) { await applicationContext .getUseCaseHelpers() @@ -142,8 +142,7 @@ exports.serveCaseToIrsInteractor = async ({ applicationContext, caseId }) => { const petitionDocument = caseEntity.documents.find( document => - document.documentType === - Document.INITIAL_DOCUMENT_TYPES.petition.documentType, + document.documentType === INITIAL_DOCUMENT_TYPES.petition.documentType, ); const initializeCaseWorkItem = petitionDocument.workItems.find( @@ -188,19 +187,58 @@ exports.serveCaseToIrsInteractor = async ({ applicationContext, caseId }) => { caseId: caseEntity.caseId, documentId: doc.documentId, replaceCoversheet: !caseEntity.isPaper, + useInitialData: !caseEntity.isPaper, }); } + const { caseCaptionExtension, caseTitle } = getCaseCaptionMeta(caseEntity); + const { docketNumberWithSuffix, preferredTrialCity, receivedAt } = caseEntity; + + const address = { + ...caseEntity.contactPrimary, + countryName: + caseEntity.contactPrimary.countryType !== 'domestic' + ? caseEntity.contactPrimary.country + : '', + }; + const pdfData = await applicationContext - .getUseCaseHelpers() - .generateCaseConfirmationPdf({ + .getDocumentGenerators() + .noticeOfReceiptOfPetition({ applicationContext, - caseEntity, + data: { + address, + caseCaptionExtension, + caseTitle, + docketNumberWithSuffix, + preferredTrialCity, + receivedAtFormatted: applicationContext + .getUtilities() + .formatDateString(receivedAt, 'MMMM D, YYYY'), + servedDate: applicationContext + .getUtilities() + .formatDateString(caseEntity.getIrsSendDate(), 'MMMM D, YYYY'), + }, }); + const caseConfirmationPdfName = caseEntity.getCaseConfirmationGeneratedPdfFileName(); + + await new Promise(resolve => { + const documentsBucket = applicationContext.getDocumentsBucketName(); + const s3Client = applicationContext.getStorageClient(); + + const params = { + Body: pdfData, + Bucket: documentsBucket, + ContentType: 'application/pdf', + Key: caseConfirmationPdfName, + }; + + s3Client.upload(params, resolve); + }); + if (caseEntity.isPaper) { const paperServicePdfBuffer = Buffer.from(pdfData); - return paperServicePdfBuffer; } }; diff --git a/shared/src/business/useCases/serveCaseToIrs/serveCaseToIrsInteractor.test.js b/shared/src/business/useCases/serveCaseToIrs/serveCaseToIrsInteractor.test.js index 63a84c160bb..93395193e5c 100644 --- a/shared/src/business/useCases/serveCaseToIrs/serveCaseToIrsInteractor.test.js +++ b/shared/src/business/useCases/serveCaseToIrs/serveCaseToIrsInteractor.test.js @@ -5,9 +5,14 @@ const { const { applicationContext, } = require('../../test/createTestApplicationContext'); +const { + CASE_STATUS_TYPES, + INITIAL_DOCUMENT_TYPES, + PAYMENT_STATUS, +} = require('../../entities/EntityConstants'); const { Case } = require('../../entities/cases/Case'); -const { Document } = require('../../entities/Document'); const { MOCK_CASE } = require('../../../test/mockCase'); +const { ROLES } = require('../../entities/EntityConstants'); const { User } = require('../../entities/User'); describe('serveCaseToIrsInteractor', () => { @@ -16,7 +21,7 @@ describe('serveCaseToIrsInteractor', () => { assigneeId: null, assigneeName: 'IRSBatchSystem', caseId: 'e631d81f-a579-4de5-b8a8-b3f10ef619fd', - caseStatus: Case.STATUS_TYPES.new, + caseStatus: CASE_STATUS_TYPES.new, completedAt: '2018-12-27T18:06:02.968Z', completedBy: 'Petitioner', completedByUserId: '6805d1ab-18d0-43ec-bafb-654e83405416', @@ -26,7 +31,7 @@ describe('serveCaseToIrsInteractor', () => { document: { createdAt: '2018-12-27T18:06:02.968Z', documentId: 'b6238482-5f0e-48a8-bb8e-da2957074a08', - documentType: Document.INITIAL_DOCUMENT_TYPES.petition.documentType, + documentType: INITIAL_DOCUMENT_TYPES.petition.documentType, }, isInitializeCase: true, isQC: true, @@ -37,39 +42,29 @@ describe('serveCaseToIrsInteractor', () => { fromUserId: '6805d1ab-18d0-43ec-bafb-654e83405416', message: 'Petition ready for review', messageId: '343f5b21-a3a9-4657-8e2b-df782f920e45', - role: User.ROLES.petitioner, + role: ROLES.petitioner, to: null, }, ], - section: 'irsBatchSection', + section: 'docket', sentBy: 'petitioner', updatedAt: '2018-12-27T18:06:02.968Z', workItemId: '78de1ba3-add3-4329-8372-ce37bda6bc93', }, ]; - const MOCK_PDF_DATA = - 'JVBERi0xLjcKJYGBgYEKCjUgMCBvYmoKPDwKL0ZpbHRlciAvRmxhdGVEZWNvZGUKL0xlbm' + - 'd0aCAxMDQKPj4Kc3RyZWFtCniccwrhMlAAwaJ0Ln2P1Jyy1JLM5ERdc0MjCwUjE4WQNC4Q' + - '6cNlCFZkqGCqYGSqEJLLZWNuYGZiZmbkYuZsZmlmZGRgZmluDCQNzc3NTM2NzdzMXMxMjQ' + - 'ztFEKyuEK0uFxDuAAOERdVCmVuZHN0cmVhbQplbmRvYmoKCjYgMCBvYmoKPDwKL0ZpbHRl' + - 'ciAvRmxhdGVEZWNvZGUKL1R5cGUgL09ialN0bQovTiA0Ci9GaXJzdCAyMAovTGVuZ3RoID' + - 'IxNQo+PgpzdHJlYW0KeJxVj9GqwjAMhu/zFHkBzTo3nCCCiiKIHPEICuJF3cKoSCu2E8/b' + - '20wPIr1p8v9/8kVhgilmGfawX2CGaVrgcAi0/bsy0lrX7IGWpvJ4iJYEN3gEmrrGBlQwGs' + - 'HHO9VBX1wNrxAqMX87RBD5xpJuddqwd82tjAHxzV1U5LPgy52DKXWnr1Lheg+j/c/pzGVr' + - 'iqV0VlwZPXGPCJjElw/ybkwUmeoWgxesDXGhHJC/D/iikp1Av80ptKU0FdBEe25pPihAM1' + - 'u6ytgaaWfs2Hrz35CJT1+EWmAKZW5kc3RyZWFtCmVuZG9iagoKNyAwIG9iago8PAovU2l6' + - 'ZSA4Ci9Sb290IDIgMCBSCi9GaWx0ZXIgL0ZsYXRlRGVjb2RlCi9UeXBlIC9YUmVmCi9MZW' + - '5ndGggMzgKL1cgWyAxIDIgMiBdCi9JbmRleCBbIDAgOCBdCj4+CnN0cmVhbQp4nBXEwREA' + - 'EBAEsCwz3vrvRmOOyyOoGhZdutHN2MT55fIAVocD+AplbmRzdHJlYW0KZW5kb2JqCgpzdG' + - 'FydHhyZWYKNTEwCiUlRU9G'; - let mockCase; beforeAll(() => { mockCase = MOCK_CASE; mockCase.documents[0].workItems = MOCK_WORK_ITEMS; applicationContext.getPersistenceGateway().updateWorkItem = jest.fn(); + + applicationContext.getStorageClient.mockReturnValue({ + upload: (params, cb) => { + return cb(true); + }, + }); }); it('should throw unauthorized error when user is unauthorized', async () => { @@ -94,16 +89,13 @@ describe('serveCaseToIrsInteractor', () => { applicationContext.getCurrentUser.mockReturnValue( new User({ name: 'bob', - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: '6805d1ab-18d0-43ec-bafb-654e83405416', }), ); applicationContext .getPersistenceGateway() .getCaseByCaseId.mockReturnValue(mockCase); - applicationContext - .getUseCaseHelpers() - .generateCaseConfirmationPdf.mockReturnValue(MOCK_PDF_DATA); await serveCaseToIrsInteractor({ applicationContext, @@ -124,16 +116,40 @@ describe('serveCaseToIrsInteractor', () => { applicationContext.getCurrentUser.mockReturnValue( new User({ name: 'bob', - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: '6805d1ab-18d0-43ec-bafb-654e83405416', }), ); applicationContext .getPersistenceGateway() .getCaseByCaseId.mockReturnValue(MOCK_CASE); + + await serveCaseToIrsInteractor({ + applicationContext, + caseId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', + }); + + expect( + applicationContext.getUseCases().addCoversheetInteractor, + ).toHaveBeenCalled(); + expect( + applicationContext.getUseCases().addCoversheetInteractor.mock.calls[0][0], + ).toMatchObject({ + replaceCoversheet: true, + }); + }); + + it('should preserve original case caption and docket number on the coversheet if the case is not paper', async () => { + applicationContext.getCurrentUser.mockReturnValue( + new User({ + name: 'bob', + role: ROLES.petitionsClerk, + userId: '6805d1ab-18d0-43ec-bafb-654e83405416', + }), + ); applicationContext - .getUseCaseHelpers() - .generateCaseConfirmationPdf.mockReturnValue(MOCK_PDF_DATA); + .getPersistenceGateway() + .getCaseByCaseId.mockReturnValue(MOCK_CASE); await serveCaseToIrsInteractor({ applicationContext, @@ -147,7 +163,35 @@ describe('serveCaseToIrsInteractor', () => { applicationContext.getUseCases().addCoversheetInteractor.mock.calls[0][0], ).toMatchObject({ replaceCoversheet: true, + useInitialData: true, + }); + }); + + it('should generate a notice of receipt of petition document and upload it to s3', async () => { + mockCase = { + ...MOCK_CASE, + isPaper: false, + }; + applicationContext.getCurrentUser.mockReturnValue( + new User({ + name: 'bob', + role: ROLES.petitionsClerk, + userId: '6805d1ab-18d0-43ec-bafb-654e83405416', + }), + ); + applicationContext + .getPersistenceGateway() + .getCaseByCaseId.mockReturnValue(mockCase); + + await serveCaseToIrsInteractor({ + applicationContext, + caseId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', }); + + expect( + applicationContext.getDocumentGenerators().noticeOfReceiptOfPetition, + ).toHaveBeenCalled(); + expect(applicationContext.getStorageClient).toHaveBeenCalled(); }); it('should not return a paper service pdf when the case is electronic', async () => { @@ -158,7 +202,7 @@ describe('serveCaseToIrsInteractor', () => { applicationContext.getCurrentUser.mockReturnValue( new User({ name: 'bob', - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: '6805d1ab-18d0-43ec-bafb-654e83405416', }), ); @@ -183,7 +227,7 @@ describe('serveCaseToIrsInteractor', () => { applicationContext.getCurrentUser.mockReturnValue( new User({ name: 'bob', - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: '6805d1ab-18d0-43ec-bafb-654e83405416', }), ); @@ -233,7 +277,7 @@ describe('serveCaseToIrsInteractor', () => { applicationContext.getCurrentUser.mockReturnValue( new User({ name: 'bob', - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: '6805d1ab-18d0-43ec-bafb-654e83405416', }), ); @@ -251,7 +295,7 @@ describe('serveCaseToIrsInteractor', () => { .updateCase.mock.calls[0][0].caseToUpdate.documents.find( document => document.documentType === - Document.INITIAL_DOCUMENT_TYPES.requestForPlaceOfTrial.documentType, + INITIAL_DOCUMENT_TYPES.requestForPlaceOfTrial.documentType, ); expect(result).toBeDefined(); expect(documentWithServedParties.servedParties).toBeDefined(); @@ -277,7 +321,7 @@ describe('addDocketEntryForPaymentStatus', () => { { ...MOCK_CASE, petitionPaymentDate: 'Today', - petitionPaymentStatus: Case.PAYMENT_STATUS.PAID, + petitionPaymentStatus: PAYMENT_STATUS.PAID, }, { applicationContext }, ); @@ -297,7 +341,7 @@ describe('addDocketEntryForPaymentStatus', () => { ...MOCK_CASE, contactPrimary: undefined, documents: [], - petitionPaymentStatus: Case.PAYMENT_STATUS.WAIVED, + petitionPaymentStatus: PAYMENT_STATUS.WAIVED, petitionPaymentWaivedDate: 'Today', }, { applicationContext }, diff --git a/shared/src/business/useCases/trialSessions/addCaseToTrialSessionInteractor.test.js b/shared/src/business/useCases/trialSessions/addCaseToTrialSessionInteractor.test.js index 96f6855a46f..9f0b9b2c645 100644 --- a/shared/src/business/useCases/trialSessions/addCaseToTrialSessionInteractor.test.js +++ b/shared/src/business/useCases/trialSessions/addCaseToTrialSessionInteractor.test.js @@ -1,7 +1,6 @@ import { addCaseToTrialSessionInteractor } from './addCaseToTrialSessionInteractor'; -const { Case } = require('../../entities/cases/Case'); +const { CHIEF_JUDGE, ROLES } = require('../../entities/EntityConstants'); const { MOCK_CASE } = require('../../../test/mockCase'); -const { User } = require('../../entities/User'); const MOCK_TRIAL = { maxCases: 100, @@ -19,7 +18,7 @@ describe('addCaseToTrialSessionInteractor', () => { await addCaseToTrialSessionInteractor({ applicationContext: { getCurrentUser: () => ({ - role: User.ROLES.petitioner, + role: ROLES.petitioner, userId: '8675309b-18d0-43ec-bafb-654e83405411', }), getPersistenceGateway: () => ({ @@ -45,7 +44,7 @@ describe('addCaseToTrialSessionInteractor', () => { await addCaseToTrialSessionInteractor({ applicationContext: { getCurrentUser: () => ({ - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: '8675309b-18d0-43ec-bafb-654e83405411', }), getPersistenceGateway: () => ({ @@ -75,7 +74,7 @@ describe('addCaseToTrialSessionInteractor', () => { await addCaseToTrialSessionInteractor({ applicationContext: { getCurrentUser: () => ({ - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: '8675309b-18d0-43ec-bafb-654e83405411', }), getPersistenceGateway: () => ({ @@ -107,7 +106,7 @@ describe('addCaseToTrialSessionInteractor', () => { const latestCase = await addCaseToTrialSessionInteractor({ applicationContext: { getCurrentUser: () => ({ - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: '8675309b-18d0-43ec-bafb-654e83405411', }), getPersistenceGateway: () => ({ @@ -129,7 +128,7 @@ describe('addCaseToTrialSessionInteractor', () => { }); expect(latestCase).toMatchObject({ - associatedJudge: Case.CHIEF_JUDGE, + associatedJudge: CHIEF_JUDGE, status: 'Calendared', trialDate: '2025-12-01T00:00:00.000Z', trialLocation: 'Birmingham, Alabama', @@ -144,7 +143,7 @@ describe('addCaseToTrialSessionInteractor', () => { await addCaseToTrialSessionInteractor({ applicationContext: { getCurrentUser: () => ({ - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: '8675309b-18d0-43ec-bafb-654e83405411', }), getPersistenceGateway: () => ({ diff --git a/shared/src/business/useCases/trialSessions/batchDownloadTrialSessionInteractor.js b/shared/src/business/useCases/trialSessions/batchDownloadTrialSessionInteractor.js index d677c58c1ff..8fbbfb0dd65 100644 --- a/shared/src/business/useCases/trialSessions/batchDownloadTrialSessionInteractor.js +++ b/shared/src/business/useCases/trialSessions/batchDownloadTrialSessionInteractor.js @@ -4,6 +4,7 @@ const { ROLE_PERMISSIONS, } = require('../../../authorization/authorizationClientService'); const { Case } = require('../../entities/cases/Case'); +const { CASE_STATUS_TYPES } = require('../../entities/EntityConstants'); const { formatDateString } = require('../../../business/utilities/DateHandler'); const { padStart } = require('lodash'); const { UnauthorizedError } = require('../../../errors/errors'); @@ -55,7 +56,7 @@ const batchDownloadTrialSessionInteractor = async ({ .replace(/,/g, ''); // TODO - create a sanitize utility for s3 ids // TODO - should we make these unique somehow? sessionCases = sessionCases - .filter(caseToFilter => caseToFilter.status !== Case.STATUS_TYPES.closed) + .filter(caseToFilter => caseToFilter.status !== CASE_STATUS_TYPES.closed) .map(caseToBatch => { const caseTitle = Case.getCaseTitle(caseToBatch.caseCaption); const caseFolder = `${caseToBatch.docketNumber}, ${caseTitle}`; diff --git a/shared/src/business/useCases/trialSessions/batchDownloadTrialSessionInteractor.test.js b/shared/src/business/useCases/trialSessions/batchDownloadTrialSessionInteractor.test.js index f5254d6a6fd..00511fd5ba6 100644 --- a/shared/src/business/useCases/trialSessions/batchDownloadTrialSessionInteractor.test.js +++ b/shared/src/business/useCases/trialSessions/batchDownloadTrialSessionInteractor.test.js @@ -2,9 +2,9 @@ import { batchDownloadTrialSessionInteractor } from './batchDownloadTrialSession const { applicationContext, } = require('../../test/createTestApplicationContext'); -const { Case } = require('../../entities/cases/Case'); +const { CASE_STATUS_TYPES } = require('../../entities/EntityConstants'); const { MOCK_CASE } = require('../../../test/mockCase'); -const { User } = require('../../entities/User'); +const { ROLES } = require('../../entities/EntityConstants'); describe('batchDownloadTrialSessionInteractor', () => { let user; @@ -26,7 +26,7 @@ describe('batchDownloadTrialSessionInteractor', () => { ]; user = { - role: User.ROLES.judge, + role: ROLES.judge, userId: 'abc-123', }; applicationContext.getCurrentUser.mockImplementation(() => user); @@ -56,7 +56,7 @@ describe('batchDownloadTrialSessionInteractor', () => { it('throws an Unauthorized error if the user role is not allowed to access the method', async () => { user = { - role: User.ROLES.petitioner, + role: ROLES.petitioner, userId: 'abc-123', }; @@ -105,7 +105,7 @@ describe('batchDownloadTrialSessionInteractor', () => { .getCalendaredCasesForTrialSession.mockReturnValue([ { ...MOCK_CASE, - status: Case.STATUS_TYPES.closed, + status: CASE_STATUS_TYPES.closed, }, ]); diff --git a/shared/src/business/useCases/trialSessions/canSetTrialSessionAsCalendaredInteractor.test.js b/shared/src/business/useCases/trialSessions/canSetTrialSessionAsCalendaredInteractor.test.js index 5f230d796ec..9fdf5470192 100644 --- a/shared/src/business/useCases/trialSessions/canSetTrialSessionAsCalendaredInteractor.test.js +++ b/shared/src/business/useCases/trialSessions/canSetTrialSessionAsCalendaredInteractor.test.js @@ -4,7 +4,7 @@ const { const { canSetTrialSessionAsCalendaredInteractor, } = require('./canSetTrialSessionAsCalendaredInteractor'); -const { User } = require('../../entities/User'); +const { ROLES } = require('../../entities/EntityConstants'); const MOCK_TRIAL = { maxCases: 100, @@ -45,7 +45,7 @@ describe('canSetTrialSessionAsCalendaredInteractor', () => { it('gets the result back from the interactor', () => { user = { - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: 'petitionsclerk', }; diff --git a/shared/src/business/useCases/trialSessions/createTrialSessionInteractor.test.js b/shared/src/business/useCases/trialSessions/createTrialSessionInteractor.test.js index 10fb8233828..92a68e22122 100644 --- a/shared/src/business/useCases/trialSessions/createTrialSessionInteractor.test.js +++ b/shared/src/business/useCases/trialSessions/createTrialSessionInteractor.test.js @@ -4,6 +4,7 @@ const { const { createTrialSessionInteractor, } = require('./createTrialSessionInteractor'); +const { ROLES } = require('../../entities/EntityConstants'); const { User } = require('../../entities/User'); const MOCK_TRIAL = { @@ -21,7 +22,7 @@ describe('createTrialSessionInteractor', () => { beforeEach(() => { user = new User({ name: 'Docket Clerk', - role: User.ROLES.docketClerk, + role: ROLES.docketClerk, userId: '6805d1ab-18d0-43ec-bafb-654e83405416', }); @@ -39,7 +40,7 @@ describe('createTrialSessionInteractor', () => { it('throws error if user is unauthorized', async () => { user = new User({ - role: User.ROLES.petitioner, + role: ROLES.petitioner, userId: 'petitioner', }); diff --git a/shared/src/business/useCases/trialSessions/deleteTrialSessionInteractor.test.js b/shared/src/business/useCases/trialSessions/deleteTrialSessionInteractor.test.js index 31f82b09e8a..e68bfd8a549 100644 --- a/shared/src/business/useCases/trialSessions/deleteTrialSessionInteractor.test.js +++ b/shared/src/business/useCases/trialSessions/deleteTrialSessionInteractor.test.js @@ -4,6 +4,7 @@ const { const { deleteTrialSessionInteractor, } = require('./deleteTrialSessionInteractor'); +const { ROLES } = require('../../entities/EntityConstants'); const { User } = require('../../entities/User'); const { MOCK_CASE } = require('../../../test/mockCase'); @@ -40,7 +41,7 @@ describe('deleteTrialSessionInteractor', () => { it('throws error if user is unauthorized', async () => { user = { - role: User.ROLES.petitioner, + role: ROLES.petitioner, userId: 'petitioner', }; @@ -55,7 +56,7 @@ describe('deleteTrialSessionInteractor', () => { it('throws an exception when it fails to find a trial session', async () => { user = new User({ name: 'Docket Clerk', - role: User.ROLES.docketClerk, + role: ROLES.docketClerk, userId: '6805d1ab-18d0-43ec-bafb-654e83405416', }); @@ -72,7 +73,7 @@ describe('deleteTrialSessionInteractor', () => { it('throws error when trial session start date is in the past', async () => { user = new User({ name: 'Docket Clerk', - role: User.ROLES.docketClerk, + role: ROLES.docketClerk, userId: '6805d1ab-18d0-43ec-bafb-654e83405416', }); @@ -91,7 +92,7 @@ describe('deleteTrialSessionInteractor', () => { it('throws error if trial session is calendared', async () => { user = new User({ name: 'Docket Clerk', - role: User.ROLES.docketClerk, + role: ROLES.docketClerk, userId: '6805d1ab-18d0-43ec-bafb-654e83405416', }); @@ -112,7 +113,7 @@ describe('deleteTrialSessionInteractor', () => { it('deletes the trial session and invokes expected persistence methods', async () => { user = new User({ name: 'Docket Clerk', - role: User.ROLES.docketClerk, + role: ROLES.docketClerk, userId: '6805d1ab-18d0-43ec-bafb-654e83405416', }); diff --git a/shared/src/business/useCases/trialSessions/getCalendaredCasesForTrialSessionInteractor.test.js b/shared/src/business/useCases/trialSessions/getCalendaredCasesForTrialSessionInteractor.test.js index 2216d0b55dc..7808b06a068 100644 --- a/shared/src/business/useCases/trialSessions/getCalendaredCasesForTrialSessionInteractor.test.js +++ b/shared/src/business/useCases/trialSessions/getCalendaredCasesForTrialSessionInteractor.test.js @@ -4,6 +4,7 @@ const { const { getCalendaredCasesForTrialSessionInteractor, } = require('./getCalendaredCasesForTrialSessionInteractor'); +const { ROLES } = require('../../entities/EntityConstants'); const { UnauthorizedError } = require('../../../errors/errors'); const { User } = require('../../entities/User'); @@ -31,7 +32,7 @@ describe('getCalendaredCasesForTrialSessionInteractor', () => { it('throws an exception when the user is unauthorized', async () => { user = new User({ name: 'Petitioner', - role: User.ROLES.petitioner, + role: ROLES.petitioner, userId: '6805d1ab-18d0-43ec-bafb-654e83405416', }); @@ -46,7 +47,7 @@ describe('getCalendaredCasesForTrialSessionInteractor', () => { it('should find the cases for a trial session successfully', async () => { user = new User({ name: 'Docket Clerk', - role: User.ROLES.docketClerk, + role: ROLES.docketClerk, userId: '6805d1ab-18d0-43ec-bafb-654e83405416', }); diff --git a/shared/src/business/useCases/trialSessions/getEligibleCasesForTrialSessionInteractor.test.js b/shared/src/business/useCases/trialSessions/getEligibleCasesForTrialSessionInteractor.test.js index 1fee5d8d8c6..40461364e45 100644 --- a/shared/src/business/useCases/trialSessions/getEligibleCasesForTrialSessionInteractor.test.js +++ b/shared/src/business/useCases/trialSessions/getEligibleCasesForTrialSessionInteractor.test.js @@ -4,6 +4,7 @@ const { const { getEligibleCasesForTrialSessionInteractor, } = require('./getEligibleCasesForTrialSessionInteractor'); +const { ROLES } = require('../../entities/EntityConstants'); const { User } = require('../../entities/User'); const { MOCK_CASE } = require('../../../test/mockCase'); @@ -43,7 +44,7 @@ describe('getEligibleCasesForTrialSessionInteractor', () => { () => new User({ name: 'Docket Clerk', - role: User.ROLES.docketClerk, + role: ROLES.docketClerk, userId: '6805d1ab-18d0-43ec-bafb-654e83405416', }), ); @@ -73,7 +74,7 @@ describe('getEligibleCasesForTrialSessionInteractor', () => { () => new User({ name: 'Docket Clerk', - role: User.ROLES.docketClerk, + role: ROLES.docketClerk, userId: '6805d1ab-18d0-43ec-bafb-654e83405416', }), ); diff --git a/shared/src/business/useCases/trialSessions/getTrialSessionDetailsInteractor.test.js b/shared/src/business/useCases/trialSessions/getTrialSessionDetailsInteractor.test.js index e30c337c75d..7c5d5050385 100644 --- a/shared/src/business/useCases/trialSessions/getTrialSessionDetailsInteractor.test.js +++ b/shared/src/business/useCases/trialSessions/getTrialSessionDetailsInteractor.test.js @@ -5,8 +5,8 @@ const { getTrialSessionDetailsInteractor, } = require('./getTrialSessionDetailsInteractor'); const { omit } = require('lodash'); +const { ROLES } = require('../../entities/EntityConstants'); const { UnauthorizedError } = require('../../../errors/errors'); -const { User } = require('../../entities/User'); describe('Get trial session details', () => { const MOCK_TRIAL_SESSION = { @@ -21,7 +21,7 @@ describe('Get trial session details', () => { beforeEach(() => { applicationContext.getCurrentUser.mockReturnValue({ - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: 'petitionsclerk', }); }); diff --git a/shared/src/business/useCases/trialSessions/getTrialSessionWorkingCopyInteractor.test.js b/shared/src/business/useCases/trialSessions/getTrialSessionWorkingCopyInteractor.test.js index bc89b6e8677..450771854f8 100644 --- a/shared/src/business/useCases/trialSessions/getTrialSessionWorkingCopyInteractor.test.js +++ b/shared/src/business/useCases/trialSessions/getTrialSessionWorkingCopyInteractor.test.js @@ -5,8 +5,8 @@ const { getTrialSessionWorkingCopyInteractor, } = require('./getTrialSessionWorkingCopyInteractor'); const { omit } = require('lodash'); +const { ROLES } = require('../../entities/EntityConstants'); const { UnauthorizedError } = require('../../../errors/errors'); -const { User } = require('../../entities/User'); const MOCK_WORKING_COPY = { sort: 'practitioner', @@ -20,7 +20,7 @@ describe('Get trial session working copy', () => { beforeEach(() => { user = { - role: User.ROLES.judge, + role: ROLES.judge, userId: 'd7d90c05-f6cd-442c-a168-202db587f16f', }; @@ -33,7 +33,7 @@ describe('Get trial session working copy', () => { applicationContext .getUseCases() .getJudgeForUserChambersInteractor.mockReturnValue({ - role: User.ROLES.judge, + role: ROLES.judge, userId: 'd7d90c05-f6cd-442c-a168-202db587f16f', }); }); @@ -89,7 +89,7 @@ describe('Get trial session working copy', () => { it('correctly returns data from persistence for a trial clerk user', async () => { user = { - role: User.ROLES.trialClerk, + role: ROLES.trialClerk, userId: 'a9ae05ba-d48a-43a6-9981-ee536a7601be', }; applicationContext diff --git a/shared/src/business/useCases/trialSessions/getTrialSessionsInteractor.test.js b/shared/src/business/useCases/trialSessions/getTrialSessionsInteractor.test.js index f992e8400fa..fe11ffd8d89 100644 --- a/shared/src/business/useCases/trialSessions/getTrialSessionsInteractor.test.js +++ b/shared/src/business/useCases/trialSessions/getTrialSessionsInteractor.test.js @@ -3,7 +3,7 @@ const { } = require('../../test/createTestApplicationContext'); const { getTrialSessionsInteractor } = require('./getTrialSessionsInteractor'); const { omit } = require('lodash'); -const { User } = require('../../entities/User'); +const { ROLES } = require('../../entities/EntityConstants'); const MOCK_TRIAL_SESSION = { maxCases: 100, @@ -29,7 +29,7 @@ describe('Get trial sessions', () => { it('throws an error if the entity returned from persistence is invalid', async () => { applicationContext.getCurrentUser.mockImplementation(() => { return { - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: 'petitionsclerk', }; }); diff --git a/shared/src/business/useCases/trialSessions/removeCaseFromTrialInteractor.test.js b/shared/src/business/useCases/trialSessions/removeCaseFromTrialInteractor.test.js index e5c7ef17a23..5e09efa094f 100644 --- a/shared/src/business/useCases/trialSessions/removeCaseFromTrialInteractor.test.js +++ b/shared/src/business/useCases/trialSessions/removeCaseFromTrialInteractor.test.js @@ -1,12 +1,15 @@ const { applicationContext, } = require('../../test/createTestApplicationContext'); +const { + CASE_STATUS_TYPES, + CHIEF_JUDGE, +} = require('../../entities/EntityConstants'); const { removeCaseFromTrialInteractor, } = require('./removeCaseFromTrialInteractor'); -const { Case } = require('../../entities/cases/Case'); const { MOCK_CASE } = require('../../../test/mockCase'); -const { User } = require('../../entities/User'); +const { ROLES } = require('../../entities/EntityConstants'); describe('remove case from trial session', () => { const MOCK_TRIAL_SESSION = { @@ -28,7 +31,7 @@ describe('remove case from trial session', () => { beforeEach(() => { user = { - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: 'petitionsclerk', }; @@ -51,7 +54,7 @@ describe('remove case from trial session', () => { it('throws error if user is unauthorized', async () => { user = { - role: User.ROLES.petitioner, + role: ROLES.petitioner, userId: 'petitioner', }; mockTrialSession = MOCK_TRIAL_SESSION; @@ -120,9 +123,9 @@ describe('remove case from trial session', () => { applicationContext.getPersistenceGateway().updateCase.mock.calls[0][0] .caseToUpdate, ).toMatchObject({ - associatedJudge: Case.CHIEF_JUDGE, + associatedJudge: CHIEF_JUDGE, caseId: MOCK_CASE.caseId, - status: Case.STATUS_TYPES.generalDocketReadyForTrial, + status: CASE_STATUS_TYPES.generalDocketReadyForTrial, trialLocation: undefined, trialSessionId: undefined, }); @@ -175,9 +178,9 @@ describe('remove case from trial session', () => { applicationContext.getPersistenceGateway().updateCase.mock.calls[0][0] .caseToUpdate, ).toMatchObject({ - associatedJudge: Case.CHIEF_JUDGE, + associatedJudge: CHIEF_JUDGE, caseId: MOCK_CASE.caseId, - status: Case.STATUS_TYPES.generalDocketReadyForTrial, + status: CASE_STATUS_TYPES.generalDocketReadyForTrial, trialLocation: undefined, trialSessionId: undefined, }); diff --git a/shared/src/business/useCases/trialSessions/runTrialSessionPlanningReportInteractor.js b/shared/src/business/useCases/trialSessions/runTrialSessionPlanningReportInteractor.js index ddf8bead997..994f1ad2b4b 100644 --- a/shared/src/business/useCases/trialSessions/runTrialSessionPlanningReportInteractor.js +++ b/shared/src/business/useCases/trialSessions/runTrialSessionPlanningReportInteractor.js @@ -3,9 +3,8 @@ const { ROLE_PERMISSIONS, } = require('../../../authorization/authorizationClientService'); const { capitalize } = require('lodash'); -const { ContactFactory } = require('../../entities/contacts/ContactFactory'); const { invert } = require('lodash'); -const { TrialSession } = require('../../entities/trialSessions/TrialSession'); +const { TRIAL_CITIES, US_STATES } = require('../../entities/EntityConstants'); const { UnauthorizedError } = require('../../../errors/errors'); const getPreviousTerm = (currentTerm, currentYear) => { @@ -39,7 +38,7 @@ const getTrialSessionPlanningReportData = async ({ currentYear = previous.year; } - const trialCities = [...TrialSession.TRIAL_CITIES.ALL]; + const trialCities = [...TRIAL_CITIES.ALL]; trialCities.sort((a, b) => { if (a.state === b.state) { return applicationContext.getUtilities().compareStrings(a.city, b.city); @@ -60,9 +59,7 @@ const getTrialSessionPlanningReportData = async ({ for (const trialLocation of trialCities) { const trialCityState = `${trialLocation.city}, ${trialLocation.state}`; const trialCityStateStripped = trialCityState.replace(/[\s.,]/g, ''); - const stateAbbreviation = invert(ContactFactory.US_STATES)[ - trialLocation.state - ]; + const stateAbbreviation = invert(US_STATES)[trialLocation.state]; const eligibleCasesSmall = await applicationContext .getPersistenceGateway() diff --git a/shared/src/business/useCases/trialSessions/runTrialSessionPlanningReportInteractor.test.js b/shared/src/business/useCases/trialSessions/runTrialSessionPlanningReportInteractor.test.js index 12624d14c6c..5a056c5df5a 100644 --- a/shared/src/business/useCases/trialSessions/runTrialSessionPlanningReportInteractor.test.js +++ b/shared/src/business/useCases/trialSessions/runTrialSessionPlanningReportInteractor.test.js @@ -6,8 +6,7 @@ const { getTrialSessionPlanningReportData, runTrialSessionPlanningReportInteractor, } = require('./runTrialSessionPlanningReportInteractor'); -const { TrialSession } = require('../../entities/trialSessions/TrialSession'); -const { User } = require('../../entities/User'); +const { ROLES, TRIAL_CITIES } = require('../../entities/EntityConstants'); describe('run trial session planning report', () => { const mockPdfUrl = 'www.example.com'; @@ -22,7 +21,7 @@ describe('run trial session planning report', () => { it('throws error if user is unauthorized', async () => { user = { - role: User.ROLES.petitioner, + role: ROLES.petitioner, userId: 'petitioner', }; @@ -41,7 +40,7 @@ describe('run trial session planning report', () => { it('returns the created pdf url', async () => { user = { - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: 'petitionsClerk', }; @@ -128,7 +127,7 @@ describe('run trial session planning report', () => { }, ]; user = { - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: 'petitionsClerk', }; @@ -154,9 +153,7 @@ describe('run trial session planning report', () => { { term: 'spring', year: '2019' }, { term: 'winter', year: '2019' }, ]); - expect(results.trialLocationData.length).toEqual( - TrialSession.TRIAL_CITIES.ALL.length, - ); + expect(results.trialLocationData.length).toEqual(TRIAL_CITIES.ALL.length); expect(results.trialLocationData[0]).toMatchObject({ allCaseCount: 4, previousTermsData: [['(S) Ashford'], ['(S) Buch', '(R) Armen'], []], diff --git a/shared/src/business/useCases/trialSessions/setNoticesForCalendaredTrialSessionInteractor.js b/shared/src/business/useCases/trialSessions/setNoticesForCalendaredTrialSessionInteractor.js index c99c4ac5c6b..a0f66bad2ff 100644 --- a/shared/src/business/useCases/trialSessions/setNoticesForCalendaredTrialSessionInteractor.js +++ b/shared/src/business/useCases/trialSessions/setNoticesForCalendaredTrialSessionInteractor.js @@ -5,6 +5,11 @@ const { isAuthorized, ROLE_PERMISSIONS, } = require('../../../authorization/authorizationClientService'); +const { + NOTICE_OF_TRIAL, + STANDING_PRETRIAL_NOTICE, + STANDING_PRETRIAL_ORDER, +} = require('../../entities/EntityConstants'); const { Case } = require('../../entities/cases/Case'); const { Document } = require('../../entities/Document'); const { TrialSession } = require('../../entities/trialSessions/TrialSession'); @@ -117,8 +122,8 @@ exports.setNoticesForCalendaredTrialSessionInteractor = async ({ caseId: caseEntity.caseId, documentId: newNoticeOfTrialIssuedDocumentId, documentTitle: noticeOfTrialDocumentTitle, - documentType: Document.NOTICE_OF_TRIAL.documentType, - eventCode: Document.NOTICE_OF_TRIAL.eventCode, + documentType: NOTICE_OF_TRIAL.documentType, + eventCode: NOTICE_OF_TRIAL.eventCode, processingStatus: 'complete', userId: user.userId, }, @@ -143,10 +148,8 @@ exports.setNoticesForCalendaredTrialSessionInteractor = async ({ trialSessionId: trialSessionEntity.trialSessionId, }); - standingPretrialDocumentTitle = - Document.STANDING_PRETRIAL_NOTICE.documentType; - standingPretrialDocumentEventCode = - Document.STANDING_PRETRIAL_NOTICE.eventCode; + standingPretrialDocumentTitle = STANDING_PRETRIAL_NOTICE.documentType; + standingPretrialDocumentEventCode = STANDING_PRETRIAL_NOTICE.eventCode; } else { // Generate Standing Pretrial Order standingPretrialFile = await applicationContext @@ -157,10 +160,8 @@ exports.setNoticesForCalendaredTrialSessionInteractor = async ({ trialSessionId: trialSessionEntity.trialSessionId, }); - standingPretrialDocumentTitle = - Document.STANDING_PRETRIAL_ORDER.documentType; - standingPretrialDocumentEventCode = - Document.STANDING_PRETRIAL_ORDER.eventCode; + standingPretrialDocumentTitle = STANDING_PRETRIAL_ORDER.documentType; + standingPretrialDocumentEventCode = STANDING_PRETRIAL_ORDER.eventCode; } const newStandingPretrialDocumentId = applicationContext.getUniqueId(); diff --git a/shared/src/business/useCases/trialSessions/setNoticesForCalendaredTrialSessionInteractor.test.js b/shared/src/business/useCases/trialSessions/setNoticesForCalendaredTrialSessionInteractor.test.js index ec1b56d8941..0f11bd0a3a5 100644 --- a/shared/src/business/useCases/trialSessions/setNoticesForCalendaredTrialSessionInteractor.test.js +++ b/shared/src/business/useCases/trialSessions/setNoticesForCalendaredTrialSessionInteractor.test.js @@ -1,25 +1,29 @@ const { applicationContext, } = require('../../test/createTestApplicationContext'); +const { + NOTICE_OF_TRIAL, + STANDING_PRETRIAL_NOTICE, + STANDING_PRETRIAL_ORDER, +} = require('../../entities/EntityConstants'); const { setNoticesForCalendaredTrialSessionInteractor, } = require('./setNoticesForCalendaredTrialSessionInteractor'); -const { Document } = require('../../entities/Document'); const { MOCK_CASE } = require('../../../test/mockCase'); +const { ROLES } = require('../../entities/EntityConstants'); const { User } = require('../../entities/User'); const findNoticeOfTrial = caseRecord => { return caseRecord.documents.find( - document => document.documentType === Document.NOTICE_OF_TRIAL.documentType, + document => document.documentType === NOTICE_OF_TRIAL.documentType, ); }; const findStandingPretrialDocument = caseRecord => { return caseRecord.documents.find( document => - document.documentType === - Document.STANDING_PRETRIAL_NOTICE.documentType || - document.documentType === Document.STANDING_PRETRIAL_ORDER.documentType, + document.documentType === STANDING_PRETRIAL_NOTICE.documentType || + document.documentType === STANDING_PRETRIAL_ORDER.documentType, ); }; @@ -72,7 +76,7 @@ describe('setNoticesForCalendaredTrialSessionInteractor', () => { user = new User({ name: 'Docket Clerk', - role: User.ROLES.docketClerk, + role: ROLES.docketClerk, userId: '6805d1ab-18d0-43ec-bafb-654e83405416', }); @@ -133,7 +137,7 @@ describe('setNoticesForCalendaredTrialSessionInteractor', () => { it('Should return an unauthorized error if the user does not have the TRIAL_SESSIONS permission', async () => { user = new User({ name: 'Petitioner', - role: User.ROLES.petitioner, // Petitioners do not have the TRIAL_SESSIONS role, per authorizationClientService.js + role: ROLES.petitioner, // Petitioners do not have the TRIAL_SESSIONS role, per authorizationClientService.js userId: '6805d1ab-18d0-43ec-bafb-654e83405416', }); @@ -205,7 +209,7 @@ describe('setNoticesForCalendaredTrialSessionInteractor', () => { const findNoticeOfTrialDocketEntry = caseRecord => { return caseRecord.docketRecord.find( - entry => entry.description === Document.NOTICE_OF_TRIAL.documentType, + entry => entry.description === NOTICE_OF_TRIAL.documentType, ); }; @@ -345,7 +349,7 @@ describe('setNoticesForCalendaredTrialSessionInteractor', () => { const findNoticeOfTrialDocketEntry = caseRecord => { return caseRecord.docketRecord.find( - entry => entry.description === Document.NOTICE_OF_TRIAL.documentType, + entry => entry.description === NOTICE_OF_TRIAL.documentType, ); }; diff --git a/shared/src/business/useCases/trialSessions/setTrialSessionAsSwingSessionInteractor.test.js b/shared/src/business/useCases/trialSessions/setTrialSessionAsSwingSessionInteractor.test.js index 196e77392af..b92a2a7630e 100644 --- a/shared/src/business/useCases/trialSessions/setTrialSessionAsSwingSessionInteractor.test.js +++ b/shared/src/business/useCases/trialSessions/setTrialSessionAsSwingSessionInteractor.test.js @@ -4,7 +4,7 @@ const { const { setTrialSessionAsSwingSessionInteractor, } = require('./setTrialSessionAsSwingSessionInteractor'); -const { User } = require('../../entities/User'); +const { ROLES } = require('../../entities/EntityConstants'); const MOCK_TRIAL_SESSION = { maxCases: 100, @@ -42,7 +42,7 @@ describe('Set trial session as swing session', () => { it('throws error if user is unauthorized', async () => { user = { - role: User.ROLES.petitioner, + role: ROLES.petitioner, userId: 'petitioner', }; @@ -57,7 +57,7 @@ describe('Set trial session as swing session', () => { it('calls getTrialSessionById and updateTrialSession persistence methods with correct parameters', async () => { user = { - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: 'petitionsclerk', }; diff --git a/shared/src/business/useCases/trialSessions/setTrialSessionCalendarInteractor.test.js b/shared/src/business/useCases/trialSessions/setTrialSessionCalendarInteractor.test.js index de09b155342..1ff06121c11 100644 --- a/shared/src/business/useCases/trialSessions/setTrialSessionCalendarInteractor.test.js +++ b/shared/src/business/useCases/trialSessions/setTrialSessionCalendarInteractor.test.js @@ -4,9 +4,9 @@ const { const { setTrialSessionCalendarInteractor, } = require('./setTrialSessionCalendarInteractor'); -const { User } = require('../../entities/User'); - const { MOCK_CASE } = require('../../../test/mockCase'); +const { ROLES } = require('../../entities/EntityConstants'); +const { User } = require('../../entities/User'); const MOCK_TRIAL = { maxCases: 100, @@ -31,7 +31,7 @@ describe('setTrialSessionCalendarInteractor', () => { it('throws an exception when there is a permissions issue', async () => { user = new User({ name: 'Petitioner', - role: User.ROLES.petitioner, + role: ROLES.petitioner, userId: '6805d1ab-18d0-43ec-bafb-654e83405416', }); applicationContext @@ -63,7 +63,7 @@ describe('setTrialSessionCalendarInteractor', () => { user = new User({ name: 'petitionsClerk', - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: '6805d1ab-18d0-43ec-bafb-654e83405416', }); @@ -109,7 +109,7 @@ describe('setTrialSessionCalendarInteractor', () => { user = new User({ name: 'petitionsClerk', - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: '6805d1ab-18d0-43ec-bafb-654e83405416', }); @@ -149,7 +149,7 @@ describe('setTrialSessionCalendarInteractor', () => { it('should set work items as high priority for each case that is calendared', async () => { user = new User({ name: 'petitionsClerk', - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: '6805d1ab-18d0-43ec-bafb-654e83405416', }); applicationContext diff --git a/shared/src/business/useCases/trialSessions/updateTrialSessionInteractor.test.js b/shared/src/business/useCases/trialSessions/updateTrialSessionInteractor.test.js index 5a155661b57..04d06fc7866 100644 --- a/shared/src/business/useCases/trialSessions/updateTrialSessionInteractor.test.js +++ b/shared/src/business/useCases/trialSessions/updateTrialSessionInteractor.test.js @@ -6,6 +6,7 @@ const { } = require('./updateTrialSessionInteractor'); const { Case } = require('../../entities/cases/Case'); const { MOCK_CASE } = require('../../../test/mockCase'); +const { ROLES } = require('../../entities/EntityConstants'); const { User } = require('../../entities/User'); const MOCK_TRIAL = { @@ -66,7 +67,7 @@ describe('updateTrialSessionInteractor', () => { user = new User({ name: 'Docket Clerk', - role: User.ROLES.docketClerk, + role: ROLES.docketClerk, userId: '6805d1ab-18d0-43ec-bafb-654e83405416', }); @@ -85,7 +86,7 @@ describe('updateTrialSessionInteractor', () => { it('throws error if user is unauthorized', async () => { user = new User({ - role: User.ROLES.petitioner, + role: ROLES.petitioner, userId: 'petitioner', }); diff --git a/shared/src/business/useCases/trialSessions/updateTrialSessionWorkingCopyInteractor.test.js b/shared/src/business/useCases/trialSessions/updateTrialSessionWorkingCopyInteractor.test.js index 6baa46516bb..c8d856642e0 100644 --- a/shared/src/business/useCases/trialSessions/updateTrialSessionWorkingCopyInteractor.test.js +++ b/shared/src/business/useCases/trialSessions/updateTrialSessionWorkingCopyInteractor.test.js @@ -5,8 +5,8 @@ const { updateTrialSessionWorkingCopyInteractor, } = require('./updateTrialSessionWorkingCopyInteractor'); const { omit } = require('lodash'); +const { ROLES } = require('../../entities/EntityConstants'); const { UnauthorizedError } = require('../../../errors/errors'); -const { User } = require('../../entities/User'); let user; @@ -49,7 +49,7 @@ describe('Update trial session working copy', () => { it('throws an error if the entity returned from persistence is invalid', async () => { user = { - role: User.ROLES.judge, + role: ROLES.judge, userId: 'd7d90c05-f6cd-442c-a168-202db587f16f', }; @@ -69,7 +69,7 @@ describe('Update trial session working copy', () => { it('correctly returns data from persistence', async () => { user = { - role: User.ROLES.judge, + role: ROLES.judge, userId: 'd7d90c05-f6cd-442c-a168-202db587f16f', }; diff --git a/shared/src/business/useCases/unblockCaseFromTrialInteractor.test.js b/shared/src/business/useCases/unblockCaseFromTrialInteractor.test.js index d9bed3f4aa5..2c5804c74c2 100644 --- a/shared/src/business/useCases/unblockCaseFromTrialInteractor.test.js +++ b/shared/src/business/useCases/unblockCaseFromTrialInteractor.test.js @@ -3,12 +3,12 @@ const { } = require('./unblockCaseFromTrialInteractor'); const { applicationContext } = require('../test/createTestApplicationContext'); const { MOCK_CASE } = require('../../test/mockCase'); -const { User } = require('../entities/User'); +const { ROLES } = require('../entities/EntityConstants'); describe('unblockCaseFromTrialInteractor', () => { it('should set the blocked flag to false and remove the blockedReason', async () => { applicationContext.getCurrentUser.mockReturnValue({ - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: '7ad8dcbc-5978-4a29-8c41-02422b66f410', }); applicationContext diff --git a/shared/src/business/useCases/unprioritizeCaseInteractor.test.js b/shared/src/business/useCases/unprioritizeCaseInteractor.test.js index cabbe55b828..bc332f897e6 100644 --- a/shared/src/business/useCases/unprioritizeCaseInteractor.test.js +++ b/shared/src/business/useCases/unprioritizeCaseInteractor.test.js @@ -1,13 +1,13 @@ const { applicationContext } = require('../test/createTestApplicationContext'); -const { Case } = require('../entities/cases/Case'); +const { CASE_STATUS_TYPES } = require('../entities/EntityConstants'); const { MOCK_CASE } = require('../../test/mockCase'); +const { ROLES } = require('../entities/EntityConstants'); const { unprioritizeCaseInteractor } = require('./unprioritizeCaseInteractor'); -const { User } = require('../entities/User'); describe('unprioritizeCaseInteractor', () => { beforeAll(() => { applicationContext.getCurrentUser.mockReturnValue({ - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: '7ad8dcbc-5978-4a29-8c41-02422b66f410', }); }); @@ -18,7 +18,7 @@ describe('unprioritizeCaseInteractor', () => { ...MOCK_CASE, highPriority: true, highPriorityReason: 'because', - status: Case.STATUS_TYPES.generalDocketReadyForTrial, + status: CASE_STATUS_TYPES.generalDocketReadyForTrial, }), ); @@ -51,7 +51,7 @@ describe('unprioritizeCaseInteractor', () => { ...MOCK_CASE, highPriority: true, highPriorityReason: 'because', - status: Case.STATUS_TYPES.new, + status: CASE_STATUS_TYPES.new, }), ); diff --git a/shared/src/business/useCases/updateCaseContextInteractor.js b/shared/src/business/useCases/updateCaseContextInteractor.js index d432c44c432..7adb65e108d 100644 --- a/shared/src/business/useCases/updateCaseContextInteractor.js +++ b/shared/src/business/useCases/updateCaseContextInteractor.js @@ -3,6 +3,7 @@ const { ROLE_PERMISSIONS, } = require('../../authorization/authorizationClientService'); const { Case } = require('../entities/cases/Case'); +const { CASE_STATUS_TYPES } = require('../entities/EntityConstants'); const { TrialSession } = require('../entities/trialSessions/TrialSession'); const { UnauthorizedError } = require('../../errors/errors'); @@ -49,7 +50,7 @@ exports.updateCaseContextInteractor = async ({ // if this case status is changing FROM calendared // we need to remove it from the trial session if (caseStatus !== oldCase.status) { - if (oldCase.status === Case.STATUS_TYPES.calendared) { + if (oldCase.status === CASE_STATUS_TYPES.calendared) { const disposition = `Status was changed to ${caseStatus}`; const trialSession = await applicationContext @@ -72,7 +73,7 @@ exports.updateCaseContextInteractor = async ({ newCase.removeFromTrialWithAssociatedJudge(associatedJudge); } else if ( - oldCase.status === Case.STATUS_TYPES.generalDocketReadyForTrial + oldCase.status === CASE_STATUS_TYPES.generalDocketReadyForTrial ) { await applicationContext .getPersistenceGateway() @@ -82,7 +83,7 @@ exports.updateCaseContextInteractor = async ({ }); } - if (caseStatus === Case.STATUS_TYPES.generalDocketReadyForTrial) { + if (caseStatus === CASE_STATUS_TYPES.generalDocketReadyForTrial) { await applicationContext .getPersistenceGateway() .createCaseTrialSortMappingRecords({ diff --git a/shared/src/business/useCases/updateCaseContextInteractor.test.js b/shared/src/business/useCases/updateCaseContextInteractor.test.js index 20e2517f9c7..be447c410d8 100644 --- a/shared/src/business/useCases/updateCaseContextInteractor.test.js +++ b/shared/src/business/useCases/updateCaseContextInteractor.test.js @@ -1,15 +1,18 @@ +const { + CASE_STATUS_TYPES, + CHIEF_JUDGE, +} = require('../entities/EntityConstants'); const { updateCaseContextInteractor, } = require('./updateCaseContextInteractor'); const { applicationContext } = require('../test/createTestApplicationContext'); -const { Case } = require('../entities/cases/Case'); const { MOCK_CASE } = require('../../test/mockCase'); -const { User } = require('../entities/User'); +const { ROLES } = require('../entities/EntityConstants'); describe('updateCaseContextInteractor', () => { beforeAll(() => { applicationContext.getCurrentUser.mockReturnValue({ - role: User.ROLES.docketClerk, + role: ROLES.docketClerk, userId: '7ad8dcbc-5978-4a29-8c41-02422b66f410', }); }); @@ -27,14 +30,14 @@ describe('updateCaseContextInteractor', () => { updateCaseContextInteractor({ applicationContext, caseId: MOCK_CASE.caseId, - caseStatus: Case.STATUS_TYPES.cav, + caseStatus: CASE_STATUS_TYPES.cav, }), ).rejects.toThrow('Unauthorized for update case'); }); it('should call updateCase with the updated case status and return the updated case', async () => { applicationContext.getCurrentUser.mockReturnValue({ - role: User.ROLES.docketClerk, + role: ROLES.docketClerk, userId: '7ad8dcbc-5978-4a29-8c41-02422b66f410', }); applicationContext @@ -44,9 +47,9 @@ describe('updateCaseContextInteractor', () => { const result = await updateCaseContextInteractor({ applicationContext, caseId: MOCK_CASE.caseId, - caseStatus: Case.STATUS_TYPES.cav, + caseStatus: CASE_STATUS_TYPES.cav, }); - expect(result.status).toEqual(Case.STATUS_TYPES.cav); + expect(result.status).toEqual(CASE_STATUS_TYPES.cav); }); it('should call updateCase and remove the case from trial if the old case status was calendared and the new case status is CAV', async () => { @@ -54,10 +57,10 @@ describe('updateCaseContextInteractor', () => { applicationContext, associatedJudge: 'Judge Rachael', caseId: MOCK_CASE.caseId, - caseStatus: Case.STATUS_TYPES.cav, + caseStatus: CASE_STATUS_TYPES.cav, }); - expect(result.status).toEqual(Case.STATUS_TYPES.cav); + expect(result.status).toEqual(CASE_STATUS_TYPES.cav); expect(result.associatedJudge).toEqual('Judge Rachael'); expect(result.trialSessionId).toBeUndefined(); }); @@ -66,27 +69,27 @@ describe('updateCaseContextInteractor', () => { const result = await updateCaseContextInteractor({ applicationContext, caseId: MOCK_CASE.caseId, - caseStatus: Case.STATUS_TYPES.generalDocket, + caseStatus: CASE_STATUS_TYPES.generalDocket, }); - expect(result.status).toEqual(Case.STATUS_TYPES.generalDocket); - expect(result.associatedJudge).toEqual(Case.CHIEF_JUDGE); + expect(result.status).toEqual(CASE_STATUS_TYPES.generalDocket); + expect(result.associatedJudge).toEqual(CHIEF_JUDGE); expect(result.trialSessionId).toBeUndefined(); }); it('should call updateCase and deleteCaseTrialSortMappingRecords if the old case status was Ready for Trial and the new status is different', async () => { applicationContext.getPersistenceGateway().getCaseByCaseId.mockReturnValue({ ...MOCK_CASE, - status: Case.STATUS_TYPES.generalDocketReadyForTrial, + status: CASE_STATUS_TYPES.generalDocketReadyForTrial, }); const result = await updateCaseContextInteractor({ applicationContext, caseId: MOCK_CASE.caseId, - caseStatus: Case.STATUS_TYPES.generalDocket, + caseStatus: CASE_STATUS_TYPES.generalDocket, }); - expect(result.status).toEqual(Case.STATUS_TYPES.generalDocket); + expect(result.status).toEqual(CASE_STATUS_TYPES.generalDocket); expect( applicationContext.getPersistenceGateway() .deleteCaseTrialSortMappingRecords, @@ -97,10 +100,10 @@ describe('updateCaseContextInteractor', () => { const result = await updateCaseContextInteractor({ applicationContext, caseId: MOCK_CASE.caseId, - caseStatus: Case.STATUS_TYPES.generalDocketReadyForTrial, + caseStatus: CASE_STATUS_TYPES.generalDocketReadyForTrial, }); - expect(result.status).toEqual(Case.STATUS_TYPES.generalDocketReadyForTrial); + expect(result.status).toEqual(CASE_STATUS_TYPES.generalDocketReadyForTrial); expect( applicationContext.getPersistenceGateway() .createCaseTrialSortMappingRecords, @@ -109,13 +112,13 @@ describe('updateCaseContextInteractor', () => { it('should only update the associated judge without changing the status if only the associated judge is passed in', async () => { applicationContext.getCurrentUser.mockReturnValue({ - role: User.ROLES.docketClerk, + role: ROLES.docketClerk, userId: '7ad8dcbc-5978-4a29-8c41-02422b66f410', }); applicationContext.getPersistenceGateway().getCaseByCaseId.mockReturnValue({ ...MOCK_CASE, associatedJudge: 'Judge Buch', - status: Case.STATUS_TYPES.submitted, + status: CASE_STATUS_TYPES.submitted, }); const result = await updateCaseContextInteractor({ @@ -123,7 +126,7 @@ describe('updateCaseContextInteractor', () => { associatedJudge: 'Judge Carluzzo', caseId: MOCK_CASE.caseId, }); - expect(result.status).toEqual(Case.STATUS_TYPES.submitted); + expect(result.status).toEqual(CASE_STATUS_TYPES.submitted); expect(result.associatedJudge).toEqual('Judge Carluzzo'); }); @@ -132,10 +135,10 @@ describe('updateCaseContextInteractor', () => { applicationContext, associatedJudge: 'Judge Carluzzo', caseId: MOCK_CASE.caseId, - caseStatus: Case.STATUS_TYPES.submitted, + caseStatus: CASE_STATUS_TYPES.submitted, }); - expect(result.status).toEqual(Case.STATUS_TYPES.submitted); + expect(result.status).toEqual(CASE_STATUS_TYPES.submitted); expect(result.associatedJudge).toEqual('Judge Carluzzo'); }); diff --git a/shared/src/business/useCases/updateCaseTrialSortTagsInteractor.js b/shared/src/business/useCases/updateCaseTrialSortTagsInteractor.js index 8c612a6cca7..f34975e5f9b 100644 --- a/shared/src/business/useCases/updateCaseTrialSortTagsInteractor.js +++ b/shared/src/business/useCases/updateCaseTrialSortTagsInteractor.js @@ -3,6 +3,7 @@ const { ROLE_PERMISSIONS, } = require('../../authorization/authorizationClientService'); const { Case } = require('../entities/cases/Case'); +const { CASE_STATUS_TYPES } = require('../entities/EntityConstants'); const { NotFoundError, UnauthorizedError } = require('../../errors/errors'); /** @@ -35,7 +36,7 @@ exports.updateCaseTrialSortTagsInteractor = async ({ throw new UnauthorizedError('Unauthorized for update case'); } - if (caseEntity.status === Case.STATUS_TYPES.generalDocketReadyForTrial) { + if (caseEntity.status === CASE_STATUS_TYPES.generalDocketReadyForTrial) { const caseSortTags = caseEntity.generateTrialSortTags(); await applicationContext diff --git a/shared/src/business/useCases/updateCaseTrialSortTagsInteractor.test.js b/shared/src/business/useCases/updateCaseTrialSortTagsInteractor.test.js index 868ccc482d1..ef7a9a8d33a 100644 --- a/shared/src/business/useCases/updateCaseTrialSortTagsInteractor.test.js +++ b/shared/src/business/useCases/updateCaseTrialSortTagsInteractor.test.js @@ -3,8 +3,10 @@ const { } = require('./updateCaseTrialSortTagsInteractor'); const { applicationContext } = require('../test/createTestApplicationContext'); const { Case } = require('../entities/cases/Case'); +const { CASE_STATUS_TYPES } = require('../entities/EntityConstants'); const { MOCK_CASE } = require('../../test/mockCase'); const { omit } = require('lodash'); +const { ROLES } = require('../entities/EntityConstants'); const { User } = require('../entities/User'); describe('Update case trial sort tags', () => { @@ -16,7 +18,7 @@ describe('Update case trial sort tags', () => { applicationContext.getCurrentUser.mockReturnValue( new User({ name: 'bob', - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: '6805d1ab-18d0-43ec-bafb-654e83405416', }), ); @@ -39,7 +41,7 @@ describe('Update case trial sort tags', () => { }); it('calls persistence if case status is ready for trial', async () => { - mockCase.status = Case.STATUS_TYPES.generalDocketReadyForTrial; + mockCase.status = CASE_STATUS_TYPES.generalDocketReadyForTrial; await updateCaseTrialSortTagsInteractor({ applicationContext, @@ -79,7 +81,7 @@ describe('Update case trial sort tags', () => { }); it('throws an error if the entity returned from persistence is invalid', async () => { - mockCase.status = Case.STATUS_TYPES.generalDocketReadyForTrial; + mockCase.status = CASE_STATUS_TYPES.generalDocketReadyForTrial; applicationContext .getPersistenceGateway() .getCaseByCaseId.mockReturnValue(omit(mockCase, 'docketNumber')); diff --git a/shared/src/business/useCases/updatePetitionDetailsInteractor.js b/shared/src/business/useCases/updatePetitionDetailsInteractor.js index ea451cca13a..02d23a96933 100644 --- a/shared/src/business/useCases/updatePetitionDetailsInteractor.js +++ b/shared/src/business/useCases/updatePetitionDetailsInteractor.js @@ -4,6 +4,7 @@ const { } = require('../../authorization/authorizationClientService'); const { Case } = require('../entities/cases/Case'); const { DocketRecord } = require('../entities/DocketRecord'); +const { PAYMENT_STATUS } = require('../entities/EntityConstants'); const { UnauthorizedError } = require('../../errors/errors'); /** @@ -41,10 +42,9 @@ exports.updatePetitionDetailsInteractor = async ({ .getPersistenceGateway() .getCaseByCaseId({ applicationContext, caseId }); - const isPaid = - editableFields.petitionPaymentStatus === Case.PAYMENT_STATUS.PAID; + const isPaid = editableFields.petitionPaymentStatus === PAYMENT_STATUS.PAID; const isWaived = - editableFields.petitionPaymentStatus === Case.PAYMENT_STATUS.WAIVED; + editableFields.petitionPaymentStatus === PAYMENT_STATUS.WAIVED; const newCase = new Case( { @@ -61,7 +61,7 @@ exports.updatePetitionDetailsInteractor = async ({ { applicationContext }, ); - if (oldCase.petitionPaymentStatus === Case.PAYMENT_STATUS.UNPAID) { + if (oldCase.petitionPaymentStatus === PAYMENT_STATUS.UNPAID) { if (isPaid) { newCase.addDocketRecord( new DocketRecord( diff --git a/shared/src/business/useCases/updatePetitionDetailsInteractor.test.js b/shared/src/business/useCases/updatePetitionDetailsInteractor.test.js index 1ba5cbf5f00..c3ea2acbf51 100644 --- a/shared/src/business/useCases/updatePetitionDetailsInteractor.test.js +++ b/shared/src/business/useCases/updatePetitionDetailsInteractor.test.js @@ -2,11 +2,11 @@ const { updatePetitionDetailsInteractor, } = require('./updatePetitionDetailsInteractor'); const { applicationContext } = require('../test/createTestApplicationContext'); -const { Case } = require('../entities/cases/Case'); const { cloneDeep } = require('lodash'); const { MOCK_CASE } = require('../../test/mockCase'); +const { PAYMENT_STATUS } = require('../entities/EntityConstants'); +const { ROLES } = require('../entities/EntityConstants'); const { UnauthorizedError } = require('../../errors/errors'); -const { User } = require('../entities/User'); describe('updatePetitionDetailsInteractor', () => { let mockCase; @@ -19,7 +19,7 @@ describe('updatePetitionDetailsInteractor', () => { mockCase = cloneDeep(MOCK_CASE); applicationContext.getCurrentUser.mockReturnValue({ - role: User.ROLES.docketClerk, + role: ROLES.docketClerk, userId: 'docketClerk', }); @@ -57,7 +57,7 @@ describe('updatePetitionDetailsInteractor', () => { caseId: mockCase.caseId, petitionDetails: { ...mockCase, - petitionPaymentStatus: Case.PAYMENT_STATUS.UNPAID, + petitionPaymentStatus: PAYMENT_STATUS.UNPAID, }, }); @@ -67,7 +67,7 @@ describe('updatePetitionDetailsInteractor', () => { expect(result.petitionPaymentWaivedDate).toBe(null); expect(result.petitionPaymentMethod).toBe(null); expect(result.petitionPaymentDate).toBe(null); - expect(result.petitionPaymentStatus).toEqual(Case.PAYMENT_STATUS.UNPAID); + expect(result.petitionPaymentStatus).toEqual(PAYMENT_STATUS.UNPAID); }); it('should call updateCase with the updated case payment information (when paid) and return the updated case', async () => { @@ -78,7 +78,7 @@ describe('updatePetitionDetailsInteractor', () => { ...mockCase, petitionPaymentDate: '2019-11-30T09:10:11.000Z', petitionPaymentMethod: 'check', - petitionPaymentStatus: Case.PAYMENT_STATUS.PAID, + petitionPaymentStatus: PAYMENT_STATUS.PAID, }, }); @@ -88,7 +88,7 @@ describe('updatePetitionDetailsInteractor', () => { expect(result.petitionPaymentWaivedDate).toBe(null); expect(result.petitionPaymentDate).toEqual('2019-11-30T09:10:11.000Z'); expect(result.petitionPaymentMethod).toEqual('check'); - expect(result.petitionPaymentStatus).toEqual(Case.PAYMENT_STATUS.PAID); + expect(result.petitionPaymentStatus).toEqual(PAYMENT_STATUS.PAID); }); it('should call updateCase with the updated case payment information (when waived) and return the updated case', async () => { @@ -97,7 +97,7 @@ describe('updatePetitionDetailsInteractor', () => { caseId: mockCase.caseId, petitionDetails: { ...mockCase, - petitionPaymentStatus: Case.PAYMENT_STATUS.WAIVED, + petitionPaymentStatus: PAYMENT_STATUS.WAIVED, petitionPaymentWaivedDate: '2019-11-30T09:10:11.000Z', }, }); @@ -107,7 +107,7 @@ describe('updatePetitionDetailsInteractor', () => { ).toHaveBeenCalled(); expect(result.petitionPaymentDate).toBe(null); expect(result.petitionPaymentMethod).toBe(null); - expect(result.petitionPaymentStatus).toEqual(Case.PAYMENT_STATUS.WAIVED); + expect(result.petitionPaymentStatus).toEqual(PAYMENT_STATUS.WAIVED); expect(result.petitionPaymentWaivedDate).toEqual( '2019-11-30T09:10:11.000Z', ); @@ -116,7 +116,7 @@ describe('updatePetitionDetailsInteractor', () => { it('should create a docket entry when moved from unpaid to waived', async () => { applicationContext.getPersistenceGateway().getCaseByCaseId.mockReturnValue({ ...mockCase, - petitionPaymentStatus: Case.PAYMENT_STATUS.UNPAID, + petitionPaymentStatus: PAYMENT_STATUS.UNPAID, }); const result = await updatePetitionDetailsInteractor({ @@ -124,7 +124,7 @@ describe('updatePetitionDetailsInteractor', () => { caseId: mockCase.caseId, petitionDetails: { ...mockCase, - petitionPaymentStatus: Case.PAYMENT_STATUS.WAIVED, + petitionPaymentStatus: PAYMENT_STATUS.WAIVED, petitionPaymentWaivedDate: '2019-11-30T09:10:11.000Z', }, }); @@ -147,7 +147,7 @@ describe('updatePetitionDetailsInteractor', () => { it('should create a docket entry when moved from unpaid to paid', async () => { applicationContext.getPersistenceGateway().getCaseByCaseId.mockReturnValue({ ...MOCK_CASE, - petitionPaymentStatus: Case.PAYMENT_STATUS.UNPAID, + petitionPaymentStatus: PAYMENT_STATUS.UNPAID, }); const result = await updatePetitionDetailsInteractor({ @@ -157,7 +157,7 @@ describe('updatePetitionDetailsInteractor', () => { ...mockCase, petitionPaymentDate: '2019-11-30T09:10:11.000Z', petitionPaymentMethod: 'check', - petitionPaymentStatus: Case.PAYMENT_STATUS.PAID, + petitionPaymentStatus: PAYMENT_STATUS.PAID, }, }); diff --git a/shared/src/business/useCases/updatePetitionerInformationInteractor.test.js b/shared/src/business/useCases/updatePetitionerInformationInteractor.test.js index 88f001b30c7..696c36f8ba1 100644 --- a/shared/src/business/useCases/updatePetitionerInformationInteractor.test.js +++ b/shared/src/business/useCases/updatePetitionerInformationInteractor.test.js @@ -9,9 +9,9 @@ const { updatePetitionerInformationInteractor, } = require('./updatePetitionerInformationInteractor'); const { Case } = require('../entities/cases/Case'); -const { ContactFactory } = require('../entities/contacts/ContactFactory'); const { MOCK_CASE } = require('../../test/mockCase'); -const { SERVICE_INDICATOR_TYPES } = require('../entities/cases/CaseConstants'); +const { PARTY_TYPES, ROLES } = require('../entities/EntityConstants'); +const { SERVICE_INDICATOR_TYPES } = require('../entities/EntityConstants'); const { User } = require('../entities/User'); let { applicationContext } = require('../test/createTestApplicationContext'); @@ -45,7 +45,7 @@ const useCases = { const userData = { name: 'administrator', - role: User.ROLES.docketClerk, + role: ROLES.docketClerk, userId: '6805d1ab-18d0-43ec-bafb-654e83405416', }; let userObj = userData; @@ -113,7 +113,7 @@ describe('update petitioner contact information on a case', () => { applicationContext, caseId: 'a805d1ab-18d0-43ec-bafb-654e83405416', contactPrimary: MOCK_CASE.contactPrimary, - partyType: ContactFactory.PARTY_TYPES.petitioner, + partyType: PARTY_TYPES.petitioner, }); expect(generateChangeOfAddressTemplateStub).not.toHaveBeenCalled(); expect(generatePdfFromHtmlInteractorStub).not.toHaveBeenCalled(); @@ -127,7 +127,7 @@ describe('update petitioner contact information on a case', () => { caseId: 'a805d1ab-18d0-43ec-bafb-654e83405416', contactPrimary: MOCK_CASE.contactPrimary, contactSecondary: { countryType: 'domestic' }, - partyType: ContactFactory.PARTY_TYPES.petitionerSpouse, + partyType: PARTY_TYPES.petitionerSpouse, }), ).rejects.toThrow(); expect(generateChangeOfAddressTemplateStub).not.toHaveBeenCalled(); @@ -150,7 +150,7 @@ describe('update petitioner contact information on a case', () => { state: 'TN', title: 'Executor', }, - partyType: ContactFactory.PARTY_TYPES.petitioner, + partyType: PARTY_TYPES.petitioner, }); expect(updateCaseStub).toHaveBeenCalled(); expect(generateChangeOfAddressTemplateStub).toHaveBeenCalled(); @@ -173,7 +173,7 @@ describe('update petitioner contact information on a case', () => { state: 'TN', title: 'Executor', }, - partyType: ContactFactory.PARTY_TYPES.petitionerSpouse, + partyType: PARTY_TYPES.petitionerSpouse, }); expect(updateCaseStub).toHaveBeenCalled(); expect(generateChangeOfAddressTemplateStub).not.toHaveBeenCalled(); @@ -194,7 +194,7 @@ describe('update petitioner contact information on a case', () => { state: 'TN', title: 'Executor', }, - partyType: ContactFactory.PARTY_TYPES.petitionerSpouse, + partyType: PARTY_TYPES.petitionerSpouse, }); const result = await updatePetitionerInformationInteractor({ @@ -211,7 +211,7 @@ describe('update petitioner contact information on a case', () => { state: 'TN', title: 'Executor', }, - partyType: ContactFactory.PARTY_TYPES.petitionerSpouse, + partyType: PARTY_TYPES.petitionerSpouse, }); expect(updateCaseStub).toHaveBeenCalled(); expect(generateChangeOfAddressTemplateStub).toHaveBeenCalled(); @@ -228,7 +228,7 @@ describe('update petitioner contact information on a case', () => { ...MOCK_CASE.contactPrimary, serviceIndicator: SERVICE_INDICATOR_TYPES.SI_PAPER, }, - partyType: ContactFactory.PARTY_TYPES.petitioner, + partyType: PARTY_TYPES.petitioner, }); expect(updateCaseStub).toHaveBeenCalled(); expect(generateChangeOfAddressTemplateStub).not.toHaveBeenCalled(); @@ -245,7 +245,7 @@ describe('update petitioner contact information on a case', () => { ...MOCK_CASE.contactPrimary, email: 'test@example.com', }, - partyType: ContactFactory.PARTY_TYPES.petitioner, + partyType: PARTY_TYPES.petitioner, }); expect(updateCaseStub).toHaveBeenCalled(); expect( @@ -263,7 +263,7 @@ describe('update petitioner contact information on a case', () => { countryType: 'alien', serviceIndicator: SERVICE_INDICATOR_TYPES.SI_PAPER, }, - partyType: ContactFactory.PARTY_TYPES.petitioner, + partyType: PARTY_TYPES.petitioner, }), ).rejects.toThrow('The Case entity was invalid'); expect(updateCaseStub).not.toHaveBeenCalled(); @@ -273,7 +273,7 @@ describe('update petitioner contact information on a case', () => { persistenceGateway.getCaseByCaseId = async () => ({ ...MOCK_CASE, }); - userObj.role = User.ROLES.petitioner; + userObj.role = ROLES.petitioner; await expect( updatePetitionerInformationInteractor({ applicationContext, diff --git a/shared/src/business/useCases/updatePrimaryContactInteractor.js b/shared/src/business/useCases/updatePrimaryContactInteractor.js index c757dd768ef..ac29f0d54fe 100644 --- a/shared/src/business/useCases/updatePrimaryContactInteractor.js +++ b/shared/src/business/useCases/updatePrimaryContactInteractor.js @@ -4,7 +4,7 @@ const { const { addCoverToPdf } = require('./addCoversheetInteractor'); const { capitalize } = require('lodash'); const { Case } = require('../entities/cases/Case'); -const { DOCKET_SECTION } = require('../entities/WorkQueue'); +const { DOCKET_SECTION } = require('../entities/EntityConstants'); const { Document } = require('../entities/Document'); const { getCaseCaptionMeta } = require('../utilities/getCaseCaptionMeta'); const { Message } = require('../entities/Message'); diff --git a/shared/src/business/useCases/updatePrimaryContactInteractor.test.js b/shared/src/business/useCases/updatePrimaryContactInteractor.test.js index ce3e3b38cc6..50878993860 100644 --- a/shared/src/business/useCases/updatePrimaryContactInteractor.test.js +++ b/shared/src/business/useCases/updatePrimaryContactInteractor.test.js @@ -3,6 +3,7 @@ const { } = require('./updatePrimaryContactInteractor'); const { applicationContext } = require('../test/createTestApplicationContext'); const { MOCK_CASE } = require('../../test/mockCase'); +const { ROLES } = require('../entities/EntityConstants'); const { User } = require('../entities/User'); const fakeData = @@ -27,7 +28,7 @@ describe('update primary contact on a case', () => { applicationContext.getCurrentUser.mockReturnValue( new User({ name: 'bob', - role: User.ROLES.petitioner, + role: ROLES.petitioner, userId: '6805d1ab-18d0-43ec-bafb-654e83405416', }), ); diff --git a/shared/src/business/useCases/updateQcCompleteForTrialInteractor.test.js b/shared/src/business/useCases/updateQcCompleteForTrialInteractor.test.js index f503af60043..262ed9de807 100644 --- a/shared/src/business/useCases/updateQcCompleteForTrialInteractor.test.js +++ b/shared/src/business/useCases/updateQcCompleteForTrialInteractor.test.js @@ -3,7 +3,7 @@ const { } = require('./updateQcCompleteForTrialInteractor'); const { applicationContext } = require('../test/createTestApplicationContext'); const { MOCK_CASE } = require('../../test/mockCase'); -const { User } = require('../entities/User'); +const { ROLES } = require('../entities/EntityConstants'); describe('updateQcCompleteForTrialInteractor', () => { let user; @@ -22,7 +22,7 @@ describe('updateQcCompleteForTrialInteractor', () => { it('should throw an error if the user is unauthorized to update a trial session', async () => { user = { - role: User.ROLES.petitioner, + role: ROLES.petitioner, userId: 'petitioner', }; @@ -38,7 +38,7 @@ describe('updateQcCompleteForTrialInteractor', () => { it('should call updateCase with the updated qcCompleteForTrial value and return the updated case', async () => { user = { - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: 'petitionsClerk', }; diff --git a/shared/src/business/useCases/updateSecondaryContactInteractor.js b/shared/src/business/useCases/updateSecondaryContactInteractor.js index 2181c66da3a..404dbb798d7 100644 --- a/shared/src/business/useCases/updateSecondaryContactInteractor.js +++ b/shared/src/business/useCases/updateSecondaryContactInteractor.js @@ -4,7 +4,7 @@ const { const { addCoverToPdf } = require('./addCoversheetInteractor'); const { capitalize } = require('lodash'); const { Case } = require('../entities/cases/Case'); -const { DOCKET_SECTION } = require('../entities/WorkQueue'); +const { DOCKET_SECTION } = require('../entities/EntityConstants'); const { Document } = require('../entities/Document'); const { getCaseCaptionMeta } = require('../utilities/getCaseCaptionMeta'); const { Message } = require('../entities/Message'); diff --git a/shared/src/business/useCases/updateSecondaryContactInteractor.test.js b/shared/src/business/useCases/updateSecondaryContactInteractor.test.js index d07d144d808..37679559a15 100644 --- a/shared/src/business/useCases/updateSecondaryContactInteractor.test.js +++ b/shared/src/business/useCases/updateSecondaryContactInteractor.test.js @@ -3,6 +3,7 @@ const { } = require('./updateSecondaryContactInteractor'); const { applicationContext } = require('../test/createTestApplicationContext'); const { MOCK_CASE } = require('../../test/mockCase'); +const { ROLES } = require('../entities/EntityConstants'); const { User } = require('../entities/User'); describe('updateSecondaryContactInteractor', () => { @@ -26,7 +27,7 @@ describe('updateSecondaryContactInteractor', () => { let mockUser = new User({ name: 'bob', - role: User.ROLES.petitioner, + role: ROLES.petitioner, userId: '6805d1ab-18d0-43ec-bafb-654e83405416', }); diff --git a/shared/src/business/useCases/users/createUserInteractor.js b/shared/src/business/useCases/users/createUserInteractor.js index 4c891160eef..b1d92908c44 100644 --- a/shared/src/business/useCases/users/createUserInteractor.js +++ b/shared/src/business/useCases/users/createUserInteractor.js @@ -6,6 +6,7 @@ const { ROLE_PERMISSIONS, } = require('../../../authorization/authorizationClientService'); const { Practitioner } = require('../../entities/Practitioner'); +const { ROLES } = require('../../entities/EntityConstants'); const { UnauthorizedError } = require('../../../errors/errors'); const { User } = require('../../entities/User'); @@ -28,9 +29,9 @@ exports.createUserInteractor = async ({ applicationContext, user }) => { if ( [ - User.ROLES.privatePractitioner, - User.ROLES.irsPractitioner, - User.ROLES.inactivePractitioner, + ROLES.privatePractitioner, + ROLES.irsPractitioner, + ROLES.inactivePractitioner, ].includes(user.role) ) { userEntity = new Practitioner( diff --git a/shared/src/business/useCases/users/createUserInteractor.test.js b/shared/src/business/useCases/users/createUserInteractor.test.js index dbbc1b23531..99a29112e05 100644 --- a/shared/src/business/useCases/users/createUserInteractor.test.js +++ b/shared/src/business/useCases/users/createUserInteractor.test.js @@ -5,13 +5,13 @@ const { UnauthorizedError, } = require('../../../../../shared/src/errors/errors'); const { createUserInteractor } = require('./createUserInteractor'); -const { User } = require('../../entities/User'); +const { ROLES } = require('../../entities/EntityConstants'); describe('create user', () => { it('creates the user', async () => { const mockUser = { name: 'Test PetitionsClerk', - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: 'petitionsclerk1@example.com', }; applicationContext.getCurrentUser.mockReturnValue({ @@ -23,7 +23,7 @@ describe('create user', () => { .createUser.mockReturnValue(mockUser); const userToCreate = { - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: 'petitionsclerk1@example.com', }; const user = await createUserInteractor({ @@ -36,11 +36,11 @@ describe('create user', () => { it('throws unauthorized for any user without an "admin" role', async () => { const mockUser = { name: 'Test Petitioner', - role: User.ROLES.petitioner, + role: ROLES.petitioner, userId: 'petitioner1@example.com', }; applicationContext.getCurrentUser.mockReturnValue({ - role: User.ROLES.petitioner, + role: ROLES.petitioner, userId: 'admin', }); applicationContext @@ -64,7 +64,7 @@ describe('create user', () => { applicationContext.getPersistenceGateway().createUser.mockReturnValue({ barNumber: 'CS20001', name: 'Test PrivatePractitioner', - role: User.ROLES.privatePractitioner, + role: ROLES.privatePractitioner, userId: '745b7d39-8fae-4c2f-893c-3c829598bc71', }); @@ -77,7 +77,7 @@ describe('create user', () => { lastName: 'PrivatePractitioner', originalBarState: 'CA', practitionerType: 'Attorney', - role: User.ROLES.privatePractitioner, + role: ROLES.privatePractitioner, }; const user = await createUserInteractor({ @@ -87,7 +87,7 @@ describe('create user', () => { expect(user).toMatchObject({ barNumber: 'CS20001', - role: User.ROLES.privatePractitioner, + role: ROLES.privatePractitioner, }); }); @@ -99,7 +99,7 @@ describe('create user', () => { applicationContext.getPersistenceGateway().createUser.mockReturnValue({ barNumber: 'CS20001', name: 'Test PrivatePractitioner', - role: User.ROLES.irsPractitioner, + role: ROLES.irsPractitioner, userId: '745b7d39-8fae-4c2f-893c-3c829598bc71', }); const mockAdmissionsDate = new Date('1876/02/19').toISOString(); @@ -115,7 +115,7 @@ describe('create user', () => { lastName: 'IRSPractitioner', originalBarState: 'CA', practitionerType: 'Attorney', - role: User.ROLES.irsPractitioner, + role: ROLES.irsPractitioner, }, }); @@ -133,7 +133,7 @@ describe('create user', () => { applicationContext.getPersistenceGateway().createUser.mockReturnValue({ barNumber: 'CS20001', name: 'Test InactivePractitioner', - role: User.ROLES.inactivePractitioner, + role: ROLES.inactivePractitioner, userId: '745b7d39-8fae-4c2f-893c-3c829598bc71', }); const mockAdmissionsDate = new Date('1876/02/19').toISOString(); @@ -149,13 +149,13 @@ describe('create user', () => { lastName: 'IRSPractitioner', originalBarState: 'CA', practitionerType: 'Attorney', - role: User.ROLES.inactivePractitioner, + role: ROLES.inactivePractitioner, }, }); expect(user).toMatchObject({ barNumber: 'CS20001', - role: User.ROLES.inactivePractitioner, + role: ROLES.inactivePractitioner, }); }); }); diff --git a/shared/src/business/useCases/users/generateChangeOfAddress.js b/shared/src/business/useCases/users/generateChangeOfAddress.js index 356647441a5..f761002e445 100644 --- a/shared/src/business/useCases/users/generateChangeOfAddress.js +++ b/shared/src/business/useCases/users/generateChangeOfAddress.js @@ -8,11 +8,12 @@ const { const { addCoverToPdf } = require('../addCoversheetInteractor'); const { capitalize, clone } = require('lodash'); const { Case } = require('../../entities/cases/Case'); -const { DOCKET_SECTION } = require('../../entities/WorkQueue'); +const { CASE_STATUS_TYPES } = require('../../entities/EntityConstants'); +const { DOCKET_SECTION } = require('../../entities/EntityConstants'); const { Document } = require('../../entities/Document'); const { getCaseCaptionMeta } = require('../../utilities/getCaseCaptionMeta'); const { Message } = require('../../entities/Message'); -const { User } = require('../../entities/User'); +const { ROLES } = require('../../entities/EntityConstants'); const { WorkItem } = require('../../entities/WorkItem'); exports.generateChangeOfAddress = async ({ @@ -63,7 +64,7 @@ exports.generateChangeOfAddress = async ({ }; let closedMoreThan6Months; - if (caseEntity.status === Case.STATUS_TYPES.closed) { + if (caseEntity.status === CASE_STATUS_TYPES.closed) { const maxClosedDate = calculateISODate({ dateString: caseEntity.closedDate, howMuch: 6, @@ -73,9 +74,9 @@ exports.generateChangeOfAddress = async ({ closedMoreThan6Months = maxClosedDate <= rightNow; } - const shouldGenerateNotice = caseEntity.status !== Case.STATUS_TYPES.closed; + const shouldGenerateNotice = caseEntity.status !== CASE_STATUS_TYPES.closed; const shouldUpdateCase = - !closedMoreThan6Months || caseEntity.status !== Case.STATUS_TYPES.closed; + !closedMoreThan6Months || caseEntity.status !== CASE_STATUS_TYPES.closed; if (shouldGenerateNotice) { const documentType = applicationContext @@ -129,14 +130,14 @@ exports.generateChangeOfAddress = async ({ userId: user.userId, }; - if (user.role === User.ROLES.privatePractitioner) { + if (user.role === ROLES.privatePractitioner) { documentData.privatePractitioners = [ { name, partyPrivatePractitioner: true, }, ]; - } else if (user.role === User.ROLES.irsPractitioner) { + } else if (user.role === ROLES.irsPractitioner) { documentData.partyIrsPractitioner = true; } diff --git a/shared/src/business/useCases/users/getInternalUsersInteractor.test.js b/shared/src/business/useCases/users/getInternalUsersInteractor.test.js index e8a643c3b83..e8c250c89c7 100644 --- a/shared/src/business/useCases/users/getInternalUsersInteractor.test.js +++ b/shared/src/business/useCases/users/getInternalUsersInteractor.test.js @@ -2,12 +2,12 @@ const { applicationContext, } = require('../../test/createTestApplicationContext'); const { getInternalUsersInteractor } = require('./getInternalUsersInteractor'); -const { User } = require('../../entities/User'); +const { ROLES } = require('../../entities/EntityConstants'); describe('Get internal users', () => { beforeEach(() => { applicationContext.getCurrentUser.mockReturnValue({ - role: User.ROLES.docketClerk, + role: ROLES.docketClerk, userId: 'docketclerk', }); applicationContext @@ -42,7 +42,7 @@ describe('Get internal users', () => { it('throws unauthorized error for unauthorized users', async () => { applicationContext.getCurrentUser.mockReturnValue({ - role: User.ROLES.petitioner, + role: ROLES.petitioner, userId: 'petitioner', }); let error; diff --git a/shared/src/business/useCases/users/getIrsPractitionersBySearchKeyInteractor.test.js b/shared/src/business/useCases/users/getIrsPractitionersBySearchKeyInteractor.test.js index 213b56ee2d3..bb0e6fedc99 100644 --- a/shared/src/business/useCases/users/getIrsPractitionersBySearchKeyInteractor.test.js +++ b/shared/src/business/useCases/users/getIrsPractitionersBySearchKeyInteractor.test.js @@ -4,7 +4,7 @@ const { const { getIrsPractitionersBySearchKeyInteractor, } = require('./getIrsPractitionersBySearchKeyInteractor'); -const { User } = require('../../entities/User'); +const { ROLES } = require('../../entities/EntityConstants'); let user; @@ -17,7 +17,7 @@ describe('getIrsPractitionersBySearchKeyInteractor', () => { it('should throw an error when not authorized', async () => { user = { name: 'Emmett Lathrop "Doc" Brown, Ph.D.', - role: User.ROLES.petitioner, + role: ROLES.petitioner, userId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', }; @@ -40,7 +40,7 @@ describe('getIrsPractitionersBySearchKeyInteractor', () => { it('should return users from persistence', async () => { user = { name: 'Emmett Lathrop "Doc" Brown, Ph.D.', - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', }; diff --git a/shared/src/business/useCases/users/getJudgeForUserChambersInteractor.js b/shared/src/business/useCases/users/getJudgeForUserChambersInteractor.js index 4f248bc5203..284594558e0 100644 --- a/shared/src/business/useCases/users/getJudgeForUserChambersInteractor.js +++ b/shared/src/business/useCases/users/getJudgeForUserChambersInteractor.js @@ -1,4 +1,4 @@ -const { User } = require('../../entities/User'); +const { ROLES } = require('../../entities/EntityConstants'); /** * getJudgeForUserChambersInteractor - returns the judge user for a given user in a chambers section @@ -14,9 +14,9 @@ exports.getJudgeForUserChambersInteractor = async ({ user, }) => { let judgeUser; - if (user.role === User.ROLES.judge) { + if (user.role === ROLES.judge) { judgeUser = user; - } else if (user.role === User.ROLES.chambers) { + } else if (user.role === ROLES.chambers) { let chambersSection; if (user.section) { chambersSection = user.section; @@ -34,7 +34,7 @@ exports.getJudgeForUserChambersInteractor = async ({ section: chambersSection, }); - judgeUser = sectionUsers.find(user => user.role === User.ROLES.judge); + judgeUser = sectionUsers.find(user => user.role === ROLES.judge); } return judgeUser; diff --git a/shared/src/business/useCases/users/getJudgeForUserChambersInteractor.test.js b/shared/src/business/useCases/users/getJudgeForUserChambersInteractor.test.js index 25a5f48dbf8..8a3609f6145 100644 --- a/shared/src/business/useCases/users/getJudgeForUserChambersInteractor.test.js +++ b/shared/src/business/useCases/users/getJudgeForUserChambersInteractor.test.js @@ -2,42 +2,42 @@ const { applicationContext, } = require('../../test/createTestApplicationContext'); import { getJudgeForUserChambersInteractor } from './getJudgeForUserChambersInteractor'; -const { User } = require('../../entities/User'); +const { ROLES } = require('../../entities/EntityConstants'); let currentUser; const chambersUser = { - role: User.ROLES.chambers, + role: ROLES.chambers, section: 'judgesChambers', userId: 'chambers1', }; const judgeUser = { - role: User.ROLES.judge, + role: ROLES.judge, section: 'judgesChambers', userId: 'judge1', }; const allUsers = [ { - role: User.ROLES.docketClerk, + role: ROLES.docketClerk, section: 'docket', userId: 'docketclerk1', }, { ...judgeUser }, { - role: User.ROLES.judge, + role: ROLES.judge, section: 'judgesChambers2', userId: 'judge2', }, { ...chambersUser }, { - role: User.ROLES.chambers, + role: ROLES.chambers, section: 'judgesChambers', userId: 'chambers2', }, { - role: User.ROLES.chambers, + role: ROLES.chambers, section: 'judgesChambers2', userId: 'chambers3', }, @@ -110,7 +110,7 @@ describe('getJudgeForUserChambersInteractor', () => { it('Returns no user if the given user is not associated with any chambers section', async () => { currentUser = { - role: User.ROLES.docketClerk, + role: ROLES.docketClerk, userId: 'docketclerk1', }; diff --git a/shared/src/business/useCases/users/getPrivatePractitionersBySearchKeyInteractor.test.js b/shared/src/business/useCases/users/getPrivatePractitionersBySearchKeyInteractor.test.js index 6a72cd32932..e74b98a8eea 100644 --- a/shared/src/business/useCases/users/getPrivatePractitionersBySearchKeyInteractor.test.js +++ b/shared/src/business/useCases/users/getPrivatePractitionersBySearchKeyInteractor.test.js @@ -4,7 +4,7 @@ const { const { getPrivatePractitionersBySearchKeyInteractor, } = require('./getPrivatePractitionersBySearchKeyInteractor'); -const { User } = require('../../entities/User'); +const { ROLES } = require('../../entities/EntityConstants'); let user; describe('getPrivatePractitionersBySearchKeyInteractor', () => { @@ -17,7 +17,7 @@ describe('getPrivatePractitionersBySearchKeyInteractor', () => { let error; user = { name: 'Emmett Lathrop "Doc" Brown, Ph.D.', - role: User.ROLES.petitioner, + role: ROLES.petitioner, userId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', }; applicationContext @@ -38,7 +38,7 @@ describe('getPrivatePractitionersBySearchKeyInteractor', () => { it('should return users from persistence', async () => { user = { name: 'Emmett Lathrop "Doc" Brown, Ph.D.', - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', }; applicationContext diff --git a/shared/src/business/useCases/users/getUsersInSectionInteractor.test.js b/shared/src/business/useCases/users/getUsersInSectionInteractor.test.js index d16b8b12eb5..eebf004dea8 100644 --- a/shared/src/business/useCases/users/getUsersInSectionInteractor.test.js +++ b/shared/src/business/useCases/users/getUsersInSectionInteractor.test.js @@ -5,17 +5,17 @@ const { getUsersInSectionInteractor, } = require('./getUsersInSectionInteractor'); const { NotFoundError, UnauthorizedError } = require('../../../errors/errors'); -const { User } = require('../../entities/User'); +const { ROLES } = require('../../entities/EntityConstants'); const MOCK_SECTION = [ { name: 'Test Petitioner 1', - role: User.ROLES.petitioner, + role: ROLES.petitioner, userId: '304a756b-ce23-438a-a9bb-3732c6a439b7', }, { name: 'Test Petitioner 2', - role: User.ROLES.petitioner, + role: ROLES.petitioner, userId: 'a79d2fac-aa2c-4183-9877-01ab1cdff127', }, ]; @@ -23,12 +23,12 @@ const MOCK_SECTION = [ const MOCK_JUDGE_SECTION = [ { name: 'Test Judge 1', - role: User.ROLES.judge, + role: ROLES.judge, userId: 'ce5add74-1559-448d-a67d-c887c8351b2e', }, { name: 'Test Judge 2', - role: User.ROLES.judge, + role: ROLES.judge, userId: 'ea83cea2-5ce9-451d-b3d6-1e7c0e51d311', }, ]; @@ -36,7 +36,7 @@ const MOCK_JUDGE_SECTION = [ describe('Get users in section', () => { it('retrieves the users in the petitions section', async () => { applicationContext.getCurrentUser.mockReturnValue({ - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: '5a797be2-a4b7-469f-9cfb-32b7f169d489', }); applicationContext @@ -53,7 +53,7 @@ describe('Get users in section', () => { it('returns notfounderror when section not found', async () => { applicationContext.getCurrentUser.mockReturnValue({ - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: '5a797be2-a4b7-469f-9cfb-32b7f169d489', }); applicationContext @@ -76,7 +76,7 @@ describe('Get users in section', () => { it('returns unauthorizederror when user not authorized', async () => { applicationContext.getCurrentUser.mockReturnValue({ - role: User.ROLES.petitioner, + role: ROLES.petitioner, userId: '5a797be2-a4b7-469f-9cfb-32b7f169d489', }); applicationContext @@ -100,7 +100,7 @@ describe('Get users in section', () => { it('retrieves the users in the judge section when the current user has the appropriate permissions', async () => { applicationContext.getCurrentUser.mockReturnValue({ - role: User.ROLES.docketClerk, + role: ROLES.docketClerk, userId: '5a797be2-a4b7-469f-9cfb-32b7f169d489', }); applicationContext @@ -117,7 +117,7 @@ describe('Get users in section', () => { it('returns unauthorizederror when the desired section is judge and current user does not have appropriate permissions', async () => { applicationContext.getCurrentUser.mockReturnValue({ - role: User.ROLES.petitioner, + role: ROLES.petitioner, userId: '5a797be2-a4b7-469f-9cfb-32b7f169d489', }); applicationContext diff --git a/shared/src/business/useCases/users/updateUserContactInformationInteractor.test.js b/shared/src/business/useCases/users/updateUserContactInformationInteractor.test.js index f7e20dd7d93..1551aadf6f7 100644 --- a/shared/src/business/useCases/users/updateUserContactInformationInteractor.test.js +++ b/shared/src/business/useCases/users/updateUserContactInformationInteractor.test.js @@ -8,11 +8,11 @@ const { const { updateUserContactInformationInteractor, } = require('./updateUserContactInformationInteractor'); -const { Case } = require('../../entities/cases/Case'); +const { CASE_STATUS_TYPES } = require('../../entities/EntityConstants'); const { MOCK_CASE } = require('../../../test/mockCase'); const { MOCK_USERS } = require('../../../test/mockUsers'); +const { ROLES } = require('../../entities/EntityConstants'); const { UnauthorizedError } = require('../../../errors/errors'); -const { User } = require('../../entities/User'); const fakeData = 'JVBERi0xLjEKJcKlwrHDqwoKMSAwIG9iagogIDw8IC9UeXBlIC9DYXRhbG9nCiAgICAgL1BhZ2VzIDIgMCBSCiAgPj4KZW5kb2JqCgoyIDAgb2JqCiAgPDwgL1R5cGUgL1BhZ2VzCiAgICAgL0tpZHMgWzMgMCBSXQogICAgIC9Db3VudCAxCiAgICAgL01lZGlhQm94IFswIDAgMzAwIDE0NF0KICA+PgplbmRvYmoKCjMgMCBvYmoKICA8PCAgL1R5cGUgL1BhZ2UKICAgICAgL1BhcmVudCAyIDAgUgogICAgICAvUmVzb3VyY2VzCiAgICAgICA8PCAvRm9udAogICAgICAgICAgIDw8IC9GMQogICAgICAgICAgICAgICA8PCAvVHlwZSAvRm9udAogICAgICAgICAgICAgICAgICAvU3VidHlwZSAvVHlwZTEKICAgICAgICAgICAgICAgICAgL0Jhc2VGb250IC9UaW1lcy1Sb21hbgogICAgICAgICAgICAgICA+PgogICAgICAgICAgID4+CiAgICAgICA+PgogICAgICAvQ29udGVudHMgNCAwIFIKICA+PgplbmRvYmoKCjQgMCBvYmoKICA8PCAvTGVuZ3RoIDg0ID4+CnN0cmVhbQogIEJUCiAgICAvRjEgMTggVGYKICAgIDUgODAgVGQKICAgIChDb25ncmF0aW9ucywgeW91IGZvdW5kIHRoZSBFYXN0ZXIgRWdnLikgVGoKICBFVAplbmRzdHJlYW0KZW5kb2JqCgp4cmVmCjAgNQowMDAwMDAwMDAwIDY1NTM1IGYgCjAwMDAwMDAwMTggMDAwMDAgbiAKMDAwMDAwMDA3NyAwMDAwMCBuIAowMDAwMDAwMTc4IDAwMDAwIG4gCjAwMDAwMDA0NTcgMDAwMDAgbiAKdHJhaWxlcgogIDw8ICAvUm9vdCAxIDAgUgogICAgICAvU2l6ZSA1CiAgPj4Kc3RhcnR4cmVmCjU2NQolJUVPRgo='; @@ -99,7 +99,7 @@ describe('updateUserContactInformationInteractor', () => { irsPractitioners: [ { contact: {}, - role: User.ROLES.irsPractitioner, + role: ROLES.irsPractitioner, userId: 'f7d90c05-f6cd-442c-a168-202db587f16f', }, ], @@ -135,7 +135,7 @@ describe('updateUserContactInformationInteractor', () => { irsPractitioners: [ { contact: contactInfo, - role: User.ROLES.irsPractitioner, + role: ROLES.irsPractitioner, userId: 'f7d90c05-f6cd-442c-a168-202db587f16f', }, ], @@ -159,7 +159,7 @@ describe('updateUserContactInformationInteractor', () => { privatePractitioners: [ { contact: {}, - role: User.ROLES.privatePractitioner, + role: ROLES.privatePractitioner, userId: 'f7d90c05-f6cd-442c-a168-202db587f16f', }, ], @@ -170,11 +170,11 @@ describe('updateUserContactInformationInteractor', () => { privatePractitioners: [ { contact: {}, - role: User.ROLES.privatePractitioner, + role: ROLES.privatePractitioner, userId: 'f7d90c05-f6cd-442c-a168-202db587f16f', }, ], - status: Case.STATUS_TYPES.closed, + status: CASE_STATUS_TYPES.closed, }, { ...MOCK_CASE, @@ -182,11 +182,11 @@ describe('updateUserContactInformationInteractor', () => { privatePractitioners: [ { contact: {}, - role: User.ROLES.privatePractitioner, + role: ROLES.privatePractitioner, userId: 'f7d90c05-f6cd-442c-a168-202db587f16f', }, ], - status: Case.STATUS_TYPES.closed, + status: CASE_STATUS_TYPES.closed, }, ]; @@ -219,7 +219,7 @@ describe('updateUserContactInformationInteractor', () => { privatePractitioners: [ { contact: contactInfo, - role: User.ROLES.privatePractitioner, + role: ROLES.privatePractitioner, userId: 'f7d90c05-f6cd-442c-a168-202db587f16f', }, ], @@ -231,7 +231,7 @@ describe('updateUserContactInformationInteractor', () => { privatePractitioners: [ { contact: contactInfo, - role: User.ROLES.privatePractitioner, + role: ROLES.privatePractitioner, userId: 'f7d90c05-f6cd-442c-a168-202db587f16f', }, ], @@ -240,7 +240,7 @@ describe('updateUserContactInformationInteractor', () => { it('returns unauthorized error when user not authorized', async () => { user = { - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: 'f7d90c05-f6cd-442c-a168-202db587f16f', }; diff --git a/shared/src/business/useCases/validateCaseDetailInteractor.test.js b/shared/src/business/useCases/validateCaseDetailInteractor.test.js index ab8aed7c948..8f4b99d167f 100644 --- a/shared/src/business/useCases/validateCaseDetailInteractor.test.js +++ b/shared/src/business/useCases/validateCaseDetailInteractor.test.js @@ -1,17 +1,20 @@ +const { + COUNTRY_TYPES, + PARTY_TYPES, + ROLES, +} = require('../entities/EntityConstants'); const { validateCaseDetailInteractor, } = require('./validateCaseDetailInteractor'); const { applicationContext } = require('../test/createTestApplicationContext'); const { Case } = require('../entities/cases/Case'); -const { ContactFactory } = require('../entities/contacts/ContactFactory'); const { MOCK_USERS } = require('../../test/mockUsers'); -const { User } = require('../entities/User'); const { VALIDATION_ERROR_MESSAGES } = Case; const contactPrimary = { address1: '123 Main St', city: 'Somewhere', - countryType: ContactFactory.COUNTRY_TYPES.DOMESTIC, + countryType: COUNTRY_TYPES.DOMESTIC, name: 'Test Petitioner', phone: '1234567890', postalCode: '12345', @@ -72,7 +75,7 @@ describe('validate case detail', () => { docketNumber: '101-18', documentId: 'c6b81f4d-1e47-423a-8caf-6d2fdc3d3859', documentType: 'Petition', - role: User.ROLES.petitioner, + role: ROLES.petitioner, userId: '9271f5ca-e7c9-40e8-b465-e970e22934e8', workItems: [], }, @@ -81,7 +84,7 @@ describe('validate case detail', () => { docketNumber: '101-18', documentId: 'c6b81f4d-1e47-423a-8caf-6d2fdc3d3859', documentType: 'Petition', - role: User.ROLES.petitioner, + role: ROLES.petitioner, userId: '9271f5ca-e7c9-40e8-b465-e970e22934e8', workItems: [], }, @@ -89,7 +92,7 @@ describe('validate case detail', () => { filingType: 'Myself', hasVerifiedIrsNotice: true, irsNoticeDate: new Date().toISOString(), - partyType: ContactFactory.PARTY_TYPES.petitioner, + partyType: PARTY_TYPES.petitioner, petitioners: [{ name: 'user' }], preferredTrialCity: 'Fresno, California', procedureType: 'Regular', @@ -134,7 +137,7 @@ describe('validate case detail', () => { docketNumber: '101-18', documentId: 'c6b81f4d-1e47-423a-8caf-6d2fdc3d3859', documentType: 'Petition', - role: User.ROLES.petitioner, + role: ROLES.petitioner, userId: '9271f5ca-e7c9-40e8-b465-e970e22934e8', workItems: [], }, @@ -143,7 +146,7 @@ describe('validate case detail', () => { docketNumber: '101-18', documentId: 'c6b81f4d-1e47-423a-8caf-6d2fdc3d3859', documentType: 'Petition', - role: User.ROLES.petitioner, + role: ROLES.petitioner, userId: '9271f5ca-e7c9-40e8-b465-e970e22934e8', workItems: [], }, @@ -151,7 +154,7 @@ describe('validate case detail', () => { filingType: 'Other', hasVerifiedIrsNotice: true, irsNoticeDate: new Date().toISOString(), - partyType: ContactFactory.PARTY_TYPES.petitioner, + partyType: PARTY_TYPES.petitioner, petitioners: [{ name: 'user' }], preferredTrialCity: 'Fresno, California', procedureType: 'Regular', @@ -184,7 +187,7 @@ describe('validate case detail', () => { docketNumber: '101-18', documentId: 'c6b81f4d-1e47-423a-8caf-6d2fdc3d3859', documentType: 'Petition', - role: User.ROLES.petitioner, + role: ROLES.petitioner, userId: '9271f5ca-e7c9-40e8-b465-e970e22934e8', workItems: [], }, @@ -193,7 +196,7 @@ describe('validate case detail', () => { docketNumber: '101-18', documentId: 'c6b81f4d-1e47-423a-8caf-6d2fdc3d3859', documentType: 'Petition', - role: User.ROLES.petitioner, + role: ROLES.petitioner, userId: '9271f5ca-e7c9-40e8-b465-e970e22934e8', workItems: [], }, @@ -201,7 +204,7 @@ describe('validate case detail', () => { filingType: 'Other', hasVerifiedIrsNotice: false, irsNoticeDate: null, - partyType: ContactFactory.PARTY_TYPES.petitioner, + partyType: PARTY_TYPES.petitioner, petitioners: [{ name: 'user' }], preferredTrialCity: 'Fresno, California', procedureType: 'Regular', diff --git a/shared/src/business/useCases/validatePetitionFromPaperInteractor.test.js b/shared/src/business/useCases/validatePetitionFromPaperInteractor.test.js index de3bef12bf7..c0a12b549f9 100644 --- a/shared/src/business/useCases/validatePetitionFromPaperInteractor.test.js +++ b/shared/src/business/useCases/validatePetitionFromPaperInteractor.test.js @@ -2,7 +2,7 @@ const { validatePetitionFromPaperInteractor, } = require('./validatePetitionFromPaperInteractor'); const { applicationContext } = require('../test/createTestApplicationContext'); -const { Case } = require('../entities/cases/Case'); +const { PAYMENT_STATUS } = require('../entities/EntityConstants'); describe('validate petition from paper', () => { it('returns the expected errors object on an empty petition', () => { @@ -35,7 +35,7 @@ describe('validate petition from paper', () => { partyType: 'testing', petitionFile: {}, petitionFileSize: 100, - petitionPaymentStatus: Case.PAYMENT_STATUS.UNPAID, + petitionPaymentStatus: PAYMENT_STATUS.UNPAID, procedureType: 'testing', receivedAt: new Date().toISOString(), }, diff --git a/shared/src/business/useCases/validatePetitionerInformationFormInteractor.test.js b/shared/src/business/useCases/validatePetitionerInformationFormInteractor.test.js index 466fb688c2e..ba150adc7e6 100644 --- a/shared/src/business/useCases/validatePetitionerInformationFormInteractor.test.js +++ b/shared/src/business/useCases/validatePetitionerInformationFormInteractor.test.js @@ -1,13 +1,13 @@ const { validatePetitionerInformationFormInteractor, } = require('./validatePetitionerInformationFormInteractor'); -const { ContactFactory } = require('../entities/contacts/ContactFactory'); +const { PARTY_TYPES } = require('../entities/EntityConstants'); describe('validatePetition', () => { it('returns the expected errors object when contactPrimary is missing fields', () => { const errors = validatePetitionerInformationFormInteractor({ contactPrimary: {}, - partyType: ContactFactory.PARTY_TYPES.petitioner, + partyType: PARTY_TYPES.petitioner, }); expect(Object.keys(errors)).toEqual(['contactPrimary', 'contactSecondary']); @@ -28,7 +28,7 @@ describe('validatePetition', () => { state: 'TN', title: 'Executor', }, - partyType: ContactFactory.PARTY_TYPES.petitioner, + partyType: PARTY_TYPES.petitioner, }); expect(errors.contactPrimary).toBeNull(); @@ -58,7 +58,7 @@ describe('validatePetition', () => { state: 'TN', title: 'Executor', }, - partyType: ContactFactory.PARTY_TYPES.petitionerSpouse, + partyType: PARTY_TYPES.petitionerSpouse, }); expect(errors.contactPrimary).toBeNull(); diff --git a/shared/src/business/useCases/validatePrimaryContactInteractor.test.js b/shared/src/business/useCases/validatePrimaryContactInteractor.test.js index 863537374ea..4bd2f61f13b 100644 --- a/shared/src/business/useCases/validatePrimaryContactInteractor.test.js +++ b/shared/src/business/useCases/validatePrimaryContactInteractor.test.js @@ -2,6 +2,7 @@ const { validatePrimaryContactInteractor, } = require('./validatePrimaryContactInteractor'); const { ContactFactory } = require('../entities/contacts/ContactFactory'); +const { PARTY_TYPES } = require('../entities/EntityConstants'); describe('validatePrimaryContactInteractor', () => { it('runs validation on a contact with no invalid properties', async () => { @@ -18,7 +19,7 @@ describe('validatePrimaryContactInteractor', () => { state: 'MN', }; - const partyType = ContactFactory.PARTY_TYPES.petitioner; + const partyType = PARTY_TYPES.petitioner; const errors = validatePrimaryContactInteractor({ contactInfo: contactPrimary, @@ -42,7 +43,7 @@ describe('validatePrimaryContactInteractor', () => { state: 'MN', }; - const partyType = ContactFactory.PARTY_TYPES.petitioner; + const partyType = PARTY_TYPES.petitioner; const errors = validatePrimaryContactInteractor({ contactInfo: contactPrimary, diff --git a/shared/src/business/useCases/validateSecondaryContactInteractor.test.js b/shared/src/business/useCases/validateSecondaryContactInteractor.test.js index 4c27b5bd90e..ef705f3f59e 100644 --- a/shared/src/business/useCases/validateSecondaryContactInteractor.test.js +++ b/shared/src/business/useCases/validateSecondaryContactInteractor.test.js @@ -2,6 +2,7 @@ const { validateSecondaryContactInteractor, } = require('./validateSecondaryContactInteractor'); const { ContactFactory } = require('../entities/contacts/ContactFactory'); +const { PARTY_TYPES } = require('../entities/EntityConstants'); describe('validateSecondaryContactInteractor', () => { it('runs validation on a contact with no invalid properties', async () => { @@ -18,7 +19,7 @@ describe('validateSecondaryContactInteractor', () => { state: 'MN', }; - const partyType = ContactFactory.PARTY_TYPES.petitionerSpouse; + const partyType = PARTY_TYPES.petitionerSpouse; const errors = validateSecondaryContactInteractor({ contactInfo: contactSecondary, @@ -42,7 +43,7 @@ describe('validateSecondaryContactInteractor', () => { state: 'MN', }; - const partyType = ContactFactory.PARTY_TYPES.petitionerSpouse; + const partyType = PARTY_TYPES.petitionerSpouse; const errors = validateSecondaryContactInteractor({ contactInfo: contactSecondary, diff --git a/shared/src/business/useCases/workitems/assignWorkItemsInteractor.test.js b/shared/src/business/useCases/workitems/assignWorkItemsInteractor.test.js index 6583cb07ef3..17558ae09a5 100644 --- a/shared/src/business/useCases/workitems/assignWorkItemsInteractor.test.js +++ b/shared/src/business/useCases/workitems/assignWorkItemsInteractor.test.js @@ -2,15 +2,15 @@ const { applicationContext, } = require('../../test/createTestApplicationContext'); const { assignWorkItemsInteractor } = require('./assignWorkItemsInteractor'); -const { Case } = require('../../entities/cases/Case'); +const { CASE_STATUS_TYPES } = require('../../entities/EntityConstants'); const { omit } = require('lodash'); -const { User } = require('../../entities/User'); +const { ROLES } = require('../../entities/EntityConstants'); const MOCK_WORK_ITEM = { assigneeId: null, assigneeName: 'bob', caseId: 'e631d81f-a579-4de5-b8a8-b3f10ef619fd', - caseStatus: Case.STATUS_TYPES.generalDocket, + caseStatus: CASE_STATUS_TYPES.generalDocket, createdAt: '2018-12-27T18:06:02.971Z', docketNumber: '101-18', docketNumberSuffix: 'S', @@ -59,7 +59,7 @@ describe('assignWorkItemsInteractor', () => { applicationContext.user = { name: 'bob', - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, }; let error; try { diff --git a/shared/src/business/useCases/workitems/completeWorkItemInteractor.test.js b/shared/src/business/useCases/workitems/completeWorkItemInteractor.test.js index 5c2e4c3ed64..0a206a094e7 100644 --- a/shared/src/business/useCases/workitems/completeWorkItemInteractor.test.js +++ b/shared/src/business/useCases/workitems/completeWorkItemInteractor.test.js @@ -2,7 +2,7 @@ const { applicationContext, } = require('../../test/createTestApplicationContext'); const { completeWorkItemInteractor } = require('./completeWorkItemInteractor'); -const { User } = require('../../entities/User'); +const { ROLES } = require('../../entities/EntityConstants'); describe('completeWorkItemInteractor', () => { let mockWorkItem = { @@ -22,7 +22,7 @@ describe('completeWorkItemInteractor', () => { const mockPetitionerUser = { name: 'Petitioner', - role: User.ROLES.petitioner, + role: ROLES.petitioner, userId: 'petitioner', }; diff --git a/shared/src/business/useCases/workitems/createWorkItemInteractor.test.js b/shared/src/business/useCases/workitems/createWorkItemInteractor.test.js index 275243f8f44..57318c1356e 100644 --- a/shared/src/business/useCases/workitems/createWorkItemInteractor.test.js +++ b/shared/src/business/useCases/workitems/createWorkItemInteractor.test.js @@ -1,8 +1,8 @@ -const { Case } = require('../../entities/cases/Case'); +const { CASE_STATUS_TYPES } = require('../../entities/EntityConstants'); const { createWorkItemInteractor } = require('./createWorkItemInteractor'); const { MOCK_CASE } = require('../../../test/mockCase'); const { MOCK_USERS } = require('../../../test/mockUsers'); -const { User } = require('../../entities/User'); +const { ROLES } = require('../../entities/EntityConstants'); describe('createWorkItem', () => { let createWorkItemStub; @@ -17,7 +17,7 @@ describe('createWorkItem', () => { environment: { stage: 'local' }, getCurrentUser: () => ({ name: 'Tax Payer', - role: User.ROLES.petitioner, + role: ROLES.petitioner, userId: 'd7d90c05-f6cd-442c-a168-202db587f16f', }), getPersistenceGateway: () => ({ @@ -51,7 +51,7 @@ describe('createWorkItem', () => { const applicationContext = createApplicationContext({ getCurrentUser: () => ({ name: 'Docketclerk', - role: User.ROLES.docketClerk, + role: ROLES.docketClerk, userId: 'a7d90c05-f6cd-442c-a168-202db587f16f', }), }); @@ -68,7 +68,7 @@ describe('createWorkItem', () => { assigneeId: 'b7d90c05-f6cd-442c-a168-202db587f16f', assigneeName: 'Docketclerk1', caseId: 'b54ba5a9-b37b-479d-9201-067ec6e335bb', - caseStatus: Case.STATUS_TYPES.new, + caseStatus: CASE_STATUS_TYPES.new, docketNumber: '101-18', docketNumberWithSuffix: '101-18', document: { @@ -96,7 +96,7 @@ describe('createWorkItem', () => { const applicationContext = createApplicationContext({ getCurrentUser: () => ({ name: 'Docketclerk', - role: User.ROLES.docketClerk, + role: ROLES.docketClerk, userId: 'a7d90c05-f6cd-442c-a168-202db587f16f', }), }); @@ -115,7 +115,7 @@ describe('createWorkItem', () => { assigneeId: 'b7d90c05-f6cd-442c-a168-202db587f16f', assigneeName: 'Docketclerk1', caseId: 'b54ba5a9-b37b-479d-9201-067ec6e335bb', - caseStatus: Case.STATUS_TYPES.new, + caseStatus: CASE_STATUS_TYPES.new, docketNumber: '101-18', docketNumberWithSuffix: '101-18', document: { diff --git a/shared/src/business/useCases/workitems/forwardWorkItemInteractor.test.js b/shared/src/business/useCases/workitems/forwardWorkItemInteractor.test.js index 2489db9fbd9..3f1338bbcc9 100644 --- a/shared/src/business/useCases/workitems/forwardWorkItemInteractor.test.js +++ b/shared/src/business/useCases/workitems/forwardWorkItemInteractor.test.js @@ -1,15 +1,15 @@ const { applicationContext, } = require('../../test/createTestApplicationContext'); -const { Case } = require('../../entities/cases/Case'); +const { CASE_STATUS_TYPES } = require('../../entities/EntityConstants'); const { forwardWorkItemInteractor } = require('./forwardWorkItemInteractor'); const { MOCK_CASE } = require('../../../../src/test/mockCase'); const { MOCK_USERS } = require('../../../test/mockUsers'); -const { User } = require('../../entities/User'); +const { ROLES } = require('../../entities/EntityConstants'); const mockPetitionsClerk = { name: 'Petitionsclerk', - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, section: 'petitions', userId: 'c7d90c05-f6cd-442c-a168-202db587f16f', }; @@ -28,7 +28,7 @@ const mockCase = { assigneeId: null, assigneeName: null, caseId: 'd3d92ca6-d9b3-4bd6-8328-e94a9fc36f88', - caseStatus: Case.STATUS_TYPES.new, + caseStatus: CASE_STATUS_TYPES.new, createdAt: '2019-07-12T17:09:41.027Z', docketNumber: '106-19', docketNumberSuffix: null, @@ -66,7 +66,7 @@ const mockCase = { assigneeId: null, assigneeName: null, caseId: 'd3d92ca6-d9b3-4bd6-8328-e94a9fc36f88', - caseStatus: Case.STATUS_TYPES.new, + caseStatus: CASE_STATUS_TYPES.new, createdAt: '2019-07-12T17:09:41.027Z', docketNumber: '106-19', docketNumberSuffix: null, @@ -188,7 +188,7 @@ describe('forwardWorkItemInteractor', () => { it('throws an error when an unauthorized user tries to access the use case', async () => { const mockTaxPayer = { name: 'Tax Payer', - role: User.ROLES.petitioner, + role: ROLES.petitioner, userId: 'd7d90c05-f6cd-442c-a168-202db587f16f', }; applicationContext.getCurrentUser.mockReturnValue(mockTaxPayer); diff --git a/shared/src/business/useCases/workitems/getDocumentQCInboxForSectionInteractor.js b/shared/src/business/useCases/workitems/getDocumentQCInboxForSectionInteractor.js index f461890aadb..966f451350f 100644 --- a/shared/src/business/useCases/workitems/getDocumentQCInboxForSectionInteractor.js +++ b/shared/src/business/useCases/workitems/getDocumentQCInboxForSectionInteractor.js @@ -1,7 +1,7 @@ const { DOCKET_SECTION, PETITIONS_SECTION, -} = require('../../entities/WorkQueue'); +} = require('../../entities/EntityConstants'); const { isAuthorized, ROLE_PERMISSIONS, diff --git a/shared/src/business/useCases/workitems/getDocumentQCInboxForSectionInteractor.test.js b/shared/src/business/useCases/workitems/getDocumentQCInboxForSectionInteractor.test.js index df3b81800b3..287a5021b88 100644 --- a/shared/src/business/useCases/workitems/getDocumentQCInboxForSectionInteractor.test.js +++ b/shared/src/business/useCases/workitems/getDocumentQCInboxForSectionInteractor.test.js @@ -4,7 +4,7 @@ const { const { getDocumentQCInboxForSectionInteractor, } = require('./getDocumentQCInboxForSectionInteractor'); -const { User } = require('../../entities/User'); +const { ROLES } = require('../../entities/EntityConstants'); describe('getDocumentQCInboxForSectionInteractor', () => { let mockWorkItem = { @@ -22,7 +22,7 @@ describe('getDocumentQCInboxForSectionInteractor', () => { it('throws an error if the user does not have access to the work item', async () => { applicationContext.getCurrentUser.mockReturnValue({ - role: User.ROLES.petitioner, + role: ROLES.petitioner, userId: 'petitioner', }); applicationContext diff --git a/shared/src/business/useCases/workitems/getDocumentQCInboxForUserInteractor.test.js b/shared/src/business/useCases/workitems/getDocumentQCInboxForUserInteractor.test.js index 1d8af829b69..d1485839f3a 100644 --- a/shared/src/business/useCases/workitems/getDocumentQCInboxForUserInteractor.test.js +++ b/shared/src/business/useCases/workitems/getDocumentQCInboxForUserInteractor.test.js @@ -4,7 +4,7 @@ const { const { getDocumentQCInboxForUserInteractor, } = require('./getDocumentQCInboxForUserInteractor'); -const { User } = require('../../entities/User'); +const { ROLES } = require('../../entities/EntityConstants'); describe('getDocumentQCInboxForUserInteractor', () => { let mockWorkItem = { @@ -22,7 +22,7 @@ describe('getDocumentQCInboxForUserInteractor', () => { it('throws an error if the user does not have access to the work item', async () => { applicationContext.getCurrentUser.mockReturnValue({ - role: User.ROLES.petitioner, + role: ROLES.petitioner, userId: 'petitioner', }); applicationContext.getPersistenceGateway().getDocumentQCServedForSection = async () => diff --git a/shared/src/business/useCases/workitems/getDocumentQCServedForSectionInteractor.js b/shared/src/business/useCases/workitems/getDocumentQCServedForSectionInteractor.js index 1543cf923b7..4c1188a870b 100644 --- a/shared/src/business/useCases/workitems/getDocumentQCServedForSectionInteractor.js +++ b/shared/src/business/useCases/workitems/getDocumentQCServedForSectionInteractor.js @@ -2,8 +2,8 @@ const { isAuthorized, ROLE_PERMISSIONS, } = require('../../../authorization/authorizationClientService'); +const { ROLES } = require('../../entities/EntityConstants'); const { UnauthorizedError } = require('../../../errors/errors'); -const { User } = require('../../entities/User'); const { WorkItem } = require('../../entities/WorkItem'); /** @@ -33,7 +33,7 @@ exports.getDocumentQCServedForSectionInteractor = async ({ }); const filteredWorkItems = workItems.filter(workItem => - user.role === User.ROLES.petitionsClerk ? !!workItem.section : true, + user.role === ROLES.petitionsClerk ? !!workItem.section : true, ); return WorkItem.validateRawCollection(filteredWorkItems, { diff --git a/shared/src/business/useCases/workitems/getDocumentQCServedForSectionInteractor.test.js b/shared/src/business/useCases/workitems/getDocumentQCServedForSectionInteractor.test.js index 0d9329ab0e5..cb6347fa1e8 100644 --- a/shared/src/business/useCases/workitems/getDocumentQCServedForSectionInteractor.test.js +++ b/shared/src/business/useCases/workitems/getDocumentQCServedForSectionInteractor.test.js @@ -5,15 +5,15 @@ const { getDocumentQCServedForSectionInteractor, } = require('./getDocumentQCServedForSectionInteractor'); const { MOCK_USERS } = require('../../../test/mockUsers'); +const { ROLES } = require('../../entities/EntityConstants'); const { UnauthorizedError } = require('../../../errors/errors'); -const { User } = require('../../entities/User'); describe('getDocumentQCServedForSectionInteractor', () => { let user; beforeEach(() => { user = { - role: User.ROLES.docketClerk, + role: ROLES.docketClerk, userId: 'a7d90c05-f6cd-442c-a168-202db587f16f', }; applicationContext.getCurrentUser.mockReturnValue(user); @@ -36,7 +36,7 @@ describe('getDocumentQCServedForSectionInteractor', () => { document: { sentBy: 'petitioner' }, isQC: true, messages: [], - section: 'irsBatchSection', + section: 'docket', sentBy: 'docketclerk', }, ]; @@ -50,7 +50,7 @@ describe('getDocumentQCServedForSectionInteractor', () => { it('throws an error if the user does not have access to the work item', async () => { user = { - role: User.ROLES.petitioner, + role: ROLES.petitioner, userId: 'd7d90c05-f6cd-442c-a168-202db587f16f', }; applicationContext.getCurrentUser.mockReturnValue(user); @@ -87,7 +87,7 @@ describe('getDocumentQCServedForSectionInteractor', () => { sentBy: 'petitioner', }, messages: [], - section: 'irsBatchSection', + section: 'docket', sentBy: 'docketclerk', }, ]); @@ -95,7 +95,7 @@ describe('getDocumentQCServedForSectionInteractor', () => { it('successfully returns the work item for a petitionsclerk', async () => { user = { - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: '4b423e1f-4eb2-4011-a845-873b82bee0a8', }; applicationContext.getCurrentUser.mockReturnValue(user); @@ -123,7 +123,7 @@ describe('getDocumentQCServedForSectionInteractor', () => { sentBy: 'petitioner', }, messages: [], - section: 'irsBatchSection', + section: 'docket', sentBy: 'docketclerk', }, ]); diff --git a/shared/src/business/useCases/workitems/getDocumentQCServedForUserInteractor.js b/shared/src/business/useCases/workitems/getDocumentQCServedForUserInteractor.js index da1f80035f5..f6099b805de 100644 --- a/shared/src/business/useCases/workitems/getDocumentQCServedForUserInteractor.js +++ b/shared/src/business/useCases/workitems/getDocumentQCServedForUserInteractor.js @@ -2,8 +2,8 @@ const { isAuthorized, ROLE_PERMISSIONS, } = require('../../../authorization/authorizationClientService'); +const { ROLES } = require('../../entities/EntityConstants'); const { UnauthorizedError } = require('../../../errors/errors'); -const { User } = require('../../entities/User'); const { WorkItem } = require('../../entities/WorkItem'); /** @@ -31,7 +31,7 @@ exports.getDocumentQCServedForUserInteractor = async ({ }); const filteredWorkItems = workItems.filter(workItem => - user.role === User.ROLES.petitionsClerk ? !!workItem.section : true, + user.role === ROLES.petitionsClerk ? !!workItem.section : true, ); return WorkItem.validateRawCollection(filteredWorkItems, { diff --git a/shared/src/business/useCases/workitems/getDocumentQCServedForUserInteractor.test.js b/shared/src/business/useCases/workitems/getDocumentQCServedForUserInteractor.test.js index cc9c4856661..14e8a2dd40c 100644 --- a/shared/src/business/useCases/workitems/getDocumentQCServedForUserInteractor.test.js +++ b/shared/src/business/useCases/workitems/getDocumentQCServedForUserInteractor.test.js @@ -4,15 +4,15 @@ const { const { getDocumentQCServedForUserInteractor, } = require('./getDocumentQCServedForUserInteractor'); +const { ROLES } = require('../../entities/EntityConstants'); const { UnauthorizedError } = require('../../../errors/errors'); -const { User } = require('../../entities/User'); describe('getDocumentQCServedForUserInteractor', () => { let user; beforeEach(() => { user = { - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: 'petitionsclerk', }; applicationContext.getCurrentUser.mockReturnValue(user); @@ -35,7 +35,7 @@ describe('getDocumentQCServedForUserInteractor', () => { document: { sentBy: 'petitioner' }, isQC: true, messages: [], - section: 'irsBatchSection', + section: 'docket', sentBy: 'docketclerk', }, ]; @@ -47,7 +47,7 @@ describe('getDocumentQCServedForUserInteractor', () => { it('throws an error if the user does not have access to the work item', async () => { user = { - role: User.ROLES.petitioner, + role: ROLES.petitioner, userId: 'petitioner', }; @@ -83,7 +83,7 @@ describe('getDocumentQCServedForUserInteractor', () => { docketNumberWithSuffix: '101-18S', document: { sentBy: 'petitioner' }, messages: [], - section: 'irsBatchSection', + section: 'docket', sentBy: 'docketclerk', }, ]); @@ -91,7 +91,7 @@ describe('getDocumentQCServedForUserInteractor', () => { it('successfully returns the work items for a docket clerk', async () => { user = { - role: User.ROLES.docketClerk, + role: ROLES.docketClerk, userId: 'docketclerk', }; @@ -118,7 +118,7 @@ describe('getDocumentQCServedForUserInteractor', () => { docketNumberWithSuffix: '101-18S', document: { sentBy: 'petitioner' }, messages: [], - section: 'irsBatchSection', + section: 'docket', sentBy: 'docketclerk', }, ]); diff --git a/shared/src/business/useCases/workitems/getInboxMessagesForSectionInteractor.test.js b/shared/src/business/useCases/workitems/getInboxMessagesForSectionInteractor.test.js index 3df488f5a37..8e0c0e48ece 100644 --- a/shared/src/business/useCases/workitems/getInboxMessagesForSectionInteractor.test.js +++ b/shared/src/business/useCases/workitems/getInboxMessagesForSectionInteractor.test.js @@ -4,11 +4,11 @@ const { const { getInboxMessagesForSectionInteractor, } = require('./getInboxMessagesForSectionInteractor'); -const { User } = require('../../entities/User'); +const { ROLES } = require('../../entities/EntityConstants'); describe('getInboxMessagesForSectionInteractor', () => { const mockPetitionsClerk = { - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: 'petitionsClerk', }; @@ -47,7 +47,7 @@ describe('getInboxMessagesForSectionInteractor', () => { it('throws an error if the user does not have access to the work item', async () => { applicationContext.getCurrentUser.mockReturnValue({ - role: User.ROLES.petitioner, + role: ROLES.petitioner, userId: 'petitioner', }); diff --git a/shared/src/business/useCases/workitems/getInboxMessagesForUserInteractor.test.js b/shared/src/business/useCases/workitems/getInboxMessagesForUserInteractor.test.js index f13050fdeaa..279aacc6e11 100644 --- a/shared/src/business/useCases/workitems/getInboxMessagesForUserInteractor.test.js +++ b/shared/src/business/useCases/workitems/getInboxMessagesForUserInteractor.test.js @@ -4,11 +4,11 @@ const { const { getInboxMessagesForUserInteractor, } = require('./getInboxMessagesForUserInteractor'); -const { User } = require('../../entities/User'); +const { ROLES } = require('../../entities/EntityConstants'); describe('getInboxMessagesForUserInteractor', () => { const mockPetitionerUser = { - role: User.ROLES.petitioner, + role: ROLES.petitioner, userId: 'petitioner', }; diff --git a/shared/src/business/useCases/workitems/getSentMessagesForSectionInteractor.test.js b/shared/src/business/useCases/workitems/getSentMessagesForSectionInteractor.test.js index ff43deb6b4f..ddf856cee02 100644 --- a/shared/src/business/useCases/workitems/getSentMessagesForSectionInteractor.test.js +++ b/shared/src/business/useCases/workitems/getSentMessagesForSectionInteractor.test.js @@ -4,8 +4,8 @@ const { const { getSentMessagesForSectionInteractor, } = require('./getSentMessagesForSectionInteractor'); +const { ROLES } = require('../../entities/EntityConstants'); const { UnauthorizedError } = require('../../../errors/errors'); -const { User } = require('../../entities/User'); describe('getSentMessagesForSectionInteractor', () => { const sentMessagesForSectionMock = [ @@ -26,7 +26,7 @@ describe('getSentMessagesForSectionInteractor', () => { document: { sentBy: 'petitioner' }, isQC: false, messages: [], - section: 'irsBatchSection', + section: 'docket', sentBy: 'docketclerk', }, ]; @@ -39,7 +39,7 @@ describe('getSentMessagesForSectionInteractor', () => { it('throws an error if the user does not have access to the work item', async () => { const mockPetitionerUser = { - role: User.ROLES.petitioner, + role: ROLES.petitioner, userId: 'petitioner', }; applicationContext.getCurrentUser.mockReturnValue(mockPetitionerUser); @@ -54,8 +54,8 @@ describe('getSentMessagesForSectionInteractor', () => { it('successfully returns the work item for a docket clerk', async () => { const mockDocketClerkUser = { - role: User.ROLES.docketClerk, - userId: 'docketClerk', + role: ROLES.docketClerk, + userId: 'bf143814-1354-4c4c-be9e-ca8144a15117', }; applicationContext.getCurrentUser.mockReturnValue(mockDocketClerkUser); diff --git a/shared/src/business/useCases/workitems/getSentMessagesForUserInteractor.test.js b/shared/src/business/useCases/workitems/getSentMessagesForUserInteractor.test.js index 9a90fd2a5d6..02638c9b4b5 100644 --- a/shared/src/business/useCases/workitems/getSentMessagesForUserInteractor.test.js +++ b/shared/src/business/useCases/workitems/getSentMessagesForUserInteractor.test.js @@ -4,8 +4,8 @@ const { const { getSentMessagesForUserInteractor, } = require('./getSentMessagesForUserInteractor'); +const { ROLES } = require('../../entities/EntityConstants'); const { UnauthorizedError } = require('../../../errors/errors'); -const { User } = require('../../entities/User'); describe('getSentMessagesForUserInteractor', () => { let user; @@ -28,14 +28,14 @@ describe('getSentMessagesForUserInteractor', () => { document: { sentBy: 'petitioner' }, isQC: false, messages: [], - section: 'irsBatchSection', + section: 'docket', sentBy: 'docketclerk', }, ]; beforeEach(() => { user = { - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: 'petitionsclerk', }; applicationContext.getCurrentUser.mockReturnValue(user); @@ -43,7 +43,7 @@ describe('getSentMessagesForUserInteractor', () => { it('throws an error if the user does not have access to the work item', async () => { user = { - role: User.ROLES.petitioner, + role: ROLES.petitioner, userId: 'petitioner', }; applicationContext.getCurrentUser.mockReturnValue(user); diff --git a/shared/src/business/useCases/workitems/getWorkItemInteractor.test.js b/shared/src/business/useCases/workitems/getWorkItemInteractor.test.js index aeb5da2be4e..b411e8e4936 100644 --- a/shared/src/business/useCases/workitems/getWorkItemInteractor.test.js +++ b/shared/src/business/useCases/workitems/getWorkItemInteractor.test.js @@ -2,7 +2,7 @@ const { applicationContext, } = require('../../test/createTestApplicationContext'); const { getWorkItemInteractor } = require('./getWorkItemInteractor'); -const { User } = require('../../entities/User'); +const { ROLES } = require('../../entities/EntityConstants'); describe('getWorkItemInteractor', () => { let mockWorkItem = { @@ -21,12 +21,12 @@ describe('getWorkItemInteractor', () => { }; const mockPetitionerUser = { - role: User.ROLES.petitioner, + role: ROLES.petitioner, userId: 'petitioner', }; const mockDocketClerkUser = { - role: User.ROLES.docketClerk, + role: ROLES.docketClerk, userId: 'docketclerk', }; diff --git a/shared/src/business/useCases/workitems/setWorkItemAsReadInteractor.test.js b/shared/src/business/useCases/workitems/setWorkItemAsReadInteractor.test.js index 93febd602e9..8da75eece3e 100644 --- a/shared/src/business/useCases/workitems/setWorkItemAsReadInteractor.test.js +++ b/shared/src/business/useCases/workitems/setWorkItemAsReadInteractor.test.js @@ -4,8 +4,8 @@ const { const { setWorkItemAsReadInteractor, } = require('./setWorkItemAsReadInteractor'); +const { ROLES } = require('../../entities/EntityConstants'); const { UnauthorizedError } = require('../../../errors/errors'); -const { User } = require('../../entities/User'); describe('setWorkItemAsReadInteractor', () => { let user; @@ -34,7 +34,7 @@ describe('setWorkItemAsReadInteractor', () => { it('returns the expected result', async () => { user = { - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: 'petitionsclerk', }; applicationContext diff --git a/shared/src/business/utilities/aggregateCommonQueryParams.js b/shared/src/business/utilities/aggregateCommonQueryParams.js index 570da029a91..ec12951f599 100644 --- a/shared/src/business/utilities/aggregateCommonQueryParams.js +++ b/shared/src/business/utilities/aggregateCommonQueryParams.js @@ -1,4 +1,4 @@ -const { CaseSearch } = require('../entities/cases/CaseSearch'); +const { CASE_SEARCH_MIN_YEAR } = require('../entities/EntityConstants'); /** * aggregateCommonQueryParams @@ -117,7 +117,7 @@ const aggregateCommonQueryParams = ({ }); } if (yearFiledMin || yearFiledMax) { - const yearMin = yearFiledMin || CaseSearch.CASE_SEARCH_MIN_YEAR; + const yearMin = yearFiledMin || CASE_SEARCH_MIN_YEAR; const yearMax = yearFiledMax || applicationContext.getUtilities().formatNow('YYYY'); diff --git a/shared/src/business/utilities/aggregateCommonQueryParams.test.js b/shared/src/business/utilities/aggregateCommonQueryParams.test.js index 5dea6903067..eff6326ca51 100644 --- a/shared/src/business/utilities/aggregateCommonQueryParams.test.js +++ b/shared/src/business/utilities/aggregateCommonQueryParams.test.js @@ -1,7 +1,10 @@ +const { + CASE_SEARCH_MIN_YEAR, + COUNTRY_TYPES, + US_STATES, +} = require('../entities/EntityConstants'); const { aggregateCommonQueryParams } = require('./aggregateCommonQueryParams'); const { applicationContext } = require('../test/createTestApplicationContext'); -const { CaseSearch } = require('../entities/cases/CaseSearch'); -const { ContactFactory } = require('../entities/contacts/ContactFactory'); const { formatNow } = require('./DateHandler'); describe('aggregateCommonQueryParams', () => { @@ -108,7 +111,7 @@ describe('aggregateCommonQueryParams', () => { it('should include search params for countryType if present in query', () => { const queryParams = { applicationContext, - countryType: ContactFactory.COUNTRY_TYPES.DOMESTIC, + countryType: COUNTRY_TYPES.DOMESTIC, }; const result = aggregateCommonQueryParams(queryParams); @@ -120,14 +123,12 @@ describe('aggregateCommonQueryParams', () => { should: [ { match: { - 'contactPrimary.M.countryType.S': - ContactFactory.COUNTRY_TYPES.DOMESTIC, + 'contactPrimary.M.countryType.S': COUNTRY_TYPES.DOMESTIC, }, }, { match: { - 'contactSecondary.M.countryType.S': - ContactFactory.COUNTRY_TYPES.DOMESTIC, + 'contactSecondary.M.countryType.S': COUNTRY_TYPES.DOMESTIC, }, }, ], @@ -144,7 +145,7 @@ describe('aggregateCommonQueryParams', () => { it('should include search params for petitionerState if present in query', () => { const queryParams = { applicationContext, - petitionerState: ContactFactory.US_STATES.AR, + petitionerState: US_STATES.AR, }; const result = aggregateCommonQueryParams(queryParams); @@ -156,12 +157,12 @@ describe('aggregateCommonQueryParams', () => { should: [ { match: { - 'contactPrimary.M.state.S': ContactFactory.US_STATES.AR, + 'contactPrimary.M.state.S': US_STATES.AR, }, }, { match: { - 'contactSecondary.M.state.S': ContactFactory.US_STATES.AR, + 'contactSecondary.M.state.S': US_STATES.AR, }, }, ], @@ -241,7 +242,7 @@ describe('aggregateCommonQueryParams', () => { range: { 'receivedAt.S': { format: 'yyyy', - gte: `${CaseSearch.CASE_SEARCH_MIN_YEAR}||/y`, + gte: `${CASE_SEARCH_MIN_YEAR}||/y`, lte: '2019||/y', }, }, diff --git a/shared/src/business/utilities/aggregatePartiesForService.js b/shared/src/business/utilities/aggregatePartiesForService.js index 225406e5603..8d09235f4b4 100644 --- a/shared/src/business/utilities/aggregatePartiesForService.js +++ b/shared/src/business/utilities/aggregatePartiesForService.js @@ -1,7 +1,7 @@ const { setServiceIndicatorsForCase, } = require('./setServiceIndicatorsForCase'); -const { SERVICE_INDICATOR_TYPES } = require('../entities/cases/CaseConstants'); +const { SERVICE_INDICATOR_TYPES } = require('../entities/EntityConstants'); /** * aggregatePartiesForService diff --git a/shared/src/business/utilities/createPractitionerUser.test.js b/shared/src/business/utilities/createPractitionerUser.test.js index 8bf80e6a588..02acb7624fa 100644 --- a/shared/src/business/utilities/createPractitionerUser.test.js +++ b/shared/src/business/utilities/createPractitionerUser.test.js @@ -1,6 +1,6 @@ const { applicationContext } = require('../test/createTestApplicationContext'); const { createPractitionerUser } = require('./createPractitionerUser'); -const { User } = require('../entities/User'); +const { ROLES } = require('../entities/EntityConstants'); describe('createPractitionerUser', () => { const mockAdmissionsDate = new Date('1876/02/19'); @@ -15,7 +15,7 @@ describe('createPractitionerUser', () => { lastName: 'IRSPractitioner', originalBarState: 'CA', practitionerType: 'Attorney', - role: User.ROLES.irsPractitioner, + role: ROLES.irsPractitioner, }; const result = await createPractitionerUser({ @@ -38,7 +38,7 @@ describe('createPractitionerUser', () => { lastName: 'IRSPractitioner', originalBarState: 'CA', practitionerType: 'Attorney', - role: User.ROLES.irsPractitioner, + role: ROLES.irsPractitioner, }; const result = await createPractitionerUser({ diff --git a/shared/src/business/utilities/documentGenerators.js b/shared/src/business/utilities/documentGenerators.js index 041abdd3a37..3192981ba97 100644 --- a/shared/src/business/utilities/documentGenerators.js +++ b/shared/src/business/utilities/documentGenerators.js @@ -67,21 +67,69 @@ const changeOfAddress = async ({ applicationContext, content }) => { return pdf; }; +const coverSheet = async ({ applicationContext, data }) => { + const coverSheetTemplate = reactTemplateGenerator({ + componentName: 'CoverSheet', + data, + }); + + const pdfContentHtml = await generateHTMLTemplateForPDF({ + applicationContext, + // TODO: Remove main prop when index.pug can be refactored to remove header logic + content: { main: coverSheetTemplate }, + options: { + overwriteMain: true, + title: 'Cover Sheet', + }, + }); + + let footerHtml = ''; + if (data.dateServed) { + footerHtml = reactTemplateGenerator({ + componentName: 'DateServedFooter', + data: { + dateServed: data.dateServed, + }, + }); + } + + const pdf = await applicationContext + .getUseCases() + .generatePdfFromHtmlInteractor({ + applicationContext, + contentHtml: pdfContentHtml, + displayHeaderFooter: true, + docketNumber: data.docketNumberWithSuffix, + footerHtml, + headerHtml: '', + overwriteHeader: true, + }); + + return pdf; +}; + const docketRecord = async ({ applicationContext, data }) => { const pdfContentHtml = await generatePrintableDocketRecordTemplate({ applicationContext, data, }); - const docketNumber = data.caseDetail.docketNumberWithSuffix; - const headerHtml = reactTemplateGenerator({ componentName: 'PageMetaHeaderDocket', data: { - docketNumber, + docketNumber: data.docketNumberWithSuffix, + }, + }); + + const footerHtml = reactTemplateGenerator({ + componentName: 'DatePrintedFooter', + data: { + datePrinted: applicationContext.getUtilities().formatNow('MM/DD/YYYY'), }, }); + const docketNumber = data.caseDetail.docketNumberWithSuffix; + const pdf = await applicationContext .getUseCases() .generatePdfFromHtmlInteractor({ @@ -89,6 +137,7 @@ const docketRecord = async ({ applicationContext, data }) => { contentHtml: pdfContentHtml, displayHeaderFooter: true, docketNumber, + footerHtml, headerHtml, overwriteHeader: true, }); @@ -106,7 +155,7 @@ const noticeOfDocketChange = async ({ applicationContext, data }) => { filingsAndProceedings, } = data; - const reactStandingPretrialOrderTemplate = reactTemplateGenerator({ + const NoticeOfDocketChangeTemplate = reactTemplateGenerator({ componentName: 'NoticeOfDocketChange', data: { docketEntryIndex, @@ -123,7 +172,7 @@ const noticeOfDocketChange = async ({ applicationContext, data }) => { const pdfContentHtml = await generateHTMLTemplateForPDF({ applicationContext, // TODO: Remove main prop when index.pug can be refactored to remove header logic - content: { main: reactStandingPretrialOrderTemplate }, + content: { main: NoticeOfDocketChangeTemplate }, options: { overwriteMain: true, title: 'Notice of Docket Change', @@ -142,6 +191,42 @@ const noticeOfDocketChange = async ({ applicationContext, data }) => { return pdf; }; +const noticeOfReceiptOfPetition = async ({ applicationContext, data }) => { + const reactNoticeReceiptPetitionTemplate = reactTemplateGenerator({ + componentName: 'NoticeOfReceiptOfPetition', + data, + }); + + const pdfContentHtml = await generateHTMLTemplateForPDF({ + applicationContext, + // TODO: Remove main prop when index.pug can be refactored to remove header logic + content: { main: reactNoticeReceiptPetitionTemplate }, + options: { + overwriteMain: true, + title: 'Notice of Receipt of Petition', + }, + }); + + const headerHtml = reactTemplateGenerator({ + componentName: 'PageMetaHeaderDocket', + data: { + docketNumber: data.docketNumberWithSuffix, + }, + }); + + const pdf = await applicationContext + .getUseCases() + .generatePdfFromHtmlInteractor({ + applicationContext, + contentHtml: pdfContentHtml, + displayHeaderFooter: true, + docketNumber: data.docketNumberWithSuffix, + headerHtml, + }); + + return pdf; +}; + const order = async ({ applicationContext, data }) => { const { caseCaptionExtension, @@ -183,8 +268,6 @@ const order = async ({ applicationContext, data }) => { }, }); - // TODO: Date Served Footer - const pdf = await applicationContext .getUseCases() .generatePdfFromHtmlInteractor({ @@ -284,7 +367,7 @@ const receiptOfFiling = async ({ applicationContext, data }) => { content: { main: reactReceiptOfFilingTemplate }, options: { overwriteMain: true, - title: 'Standing Pre-trial Order', + title: 'Receipt of Filing', }, }); @@ -574,8 +657,10 @@ module.exports = { addressLabelCoverSheet, caseInventoryReport, changeOfAddress, + coverSheet, docketRecord, noticeOfDocketChange, + noticeOfReceiptOfPetition, order, pendingReport, receiptOfFiling, diff --git a/shared/src/business/utilities/documentGenerators.test.js b/shared/src/business/utilities/documentGenerators.test.js index 08ac0940e08..79a0d742214 100644 --- a/shared/src/business/utilities/documentGenerators.test.js +++ b/shared/src/business/utilities/documentGenerators.test.js @@ -11,8 +11,10 @@ const { addressLabelCoverSheet, caseInventoryReport, changeOfAddress, + coverSheet, docketRecord, noticeOfDocketChange, + noticeOfReceiptOfPetition, order, pendingReport, receiptOfFiling, @@ -164,6 +166,38 @@ describe('documentGenerators', () => { }); }); + describe('coverSheet', () => { + it('Generates a CoverSheet document', async () => { + const pdf = await coverSheet({ + applicationContext, + data: { + caseCaptionExtension: 'Petitioner', + caseTitle: 'Test Person', + certificateOfService: true, + dateFiledLodged: '01/01/2020', + dateFiledLodgedLabel: 'Filed', + dateReceived: '01/02/2020', + dateServed: '01/03/2020', + docketNumberWithSuffix: '123-45S', + documentTitle: 'Petition', + electronicallyFiled: true, + }, + }); + + // Do not write PDF when running on CircleCI + if (process.env.PDF_OUTPUT) { + writePdfFile('CoverSheet', pdf); + expect(applicationContext.getChromiumBrowser).toHaveBeenCalled(); + } + + expect( + applicationContext.getUseCases().generatePdfFromHtmlInteractor, + ).toHaveBeenCalled(); + expect(applicationContext.getNodeSass).toHaveBeenCalled(); + expect(applicationContext.getPug).toHaveBeenCalled(); + }); + }); + describe('docketRecord', () => { it('Generates a Printable Docket Record document', async () => { const pdf = await docketRecord({ @@ -257,7 +291,7 @@ describe('documentGenerators', () => { }); describe('noticeOfDocketChange', () => { - it('generates a Standing Pre-trial Order document', async () => { + it('generates a Notice of Docket Change document', async () => { const pdf = await noticeOfDocketChange({ applicationContext, data: { @@ -286,6 +320,42 @@ describe('documentGenerators', () => { }); }); + describe('noticeOfReceiptOfPetition', () => { + it('generates a Notice of Receipt of Petition document', async () => { + const pdf = await noticeOfReceiptOfPetition({ + applicationContext, + data: { + address: { + address1: '123 Some St.', + city: 'Somecity', + countryName: '', + name: 'Test Petitioner', + postalCode: '80008', + state: 'ZZ', + }, + caseCaptionExtension: 'Petitioner(s)', + caseTitle: 'Test Petitioner', + docketNumberWithSuffix: '123-45S', + preferredTrialCity: 'Birmingham, AL', + receivedAtFormatted: 'December 1, 2019', + servedDate: 'June 3, 2020', + }, + }); + + // Do not write PDF when running on CircleCI + if (process.env.PDF_OUTPUT) { + writePdfFile('Notice_Receipt_Petition', pdf); + expect(applicationContext.getChromiumBrowser).toHaveBeenCalled(); + } + + expect( + applicationContext.getUseCases().generatePdfFromHtmlInteractor, + ).toHaveBeenCalled(); + expect(applicationContext.getNodeSass).toHaveBeenCalled(); + expect(applicationContext.getPug).toHaveBeenCalled(); + }); + }); + describe('standingPretrialNotice', () => { it('generates a Standing Pre-trial Notice document', async () => { const pdf = await standingPretrialNotice({ diff --git a/shared/src/business/utilities/generateHTMLTemplateForPDF/generateCoverPagePdf.js b/shared/src/business/utilities/generateHTMLTemplateForPDF/generateCoverPagePdf.js deleted file mode 100644 index 3204e0cbc79..00000000000 --- a/shared/src/business/utilities/generateHTMLTemplateForPDF/generateCoverPagePdf.js +++ /dev/null @@ -1,147 +0,0 @@ -const ustcLogoBufferBase64 = require('../../../../static/images/ustc_seal.png_'); - -/** - * generateCoverPagePdf - * - * @param {object} providers the providers object - * @param {object} providers.applicationContext the application context - * @param {string} providers.content the html content for the cover sheet - * @returns {Buffer} the pdf as a binary buffer - */ -exports.generateCoverPagePdf = async ({ applicationContext, content }) => { - let browser = null; - let result = null; - const horizontalMargin = 40; - - try { - browser = await applicationContext.getChromiumBrowser(); - let page = await browser.newPage(); - - const headerTemplate = ''; - const fontSizeDefault = 15; - const fontSizeCaption = 15; - const fontSizeTitle = 18; - - const mainContent = ` -
- -
-
-
-
- Received -
- ${content.dateReceived} -
-
-
-
- ${content.dateFiledLodgedLabel} -
- ${content.dateFiledLodged} -
-
-
- -
-
- ${content.caseTitle} -

-
- ${content.caseCaptionExtension} -

- v. -
-
- Commissioner of Internal Revenue, -

-
- Respondent -
-
-
-
- ${content.electronicallyFiled ? 'Electronically Filed
' : ''} - ${content.mailingDate ? content.mailingDate + '
' : ''} -
- ${content.docketNumber} -
-
-
-
- -
- ${content.documentTitle} -
-
`; - - const footerTemplate = ` - - - - - -
- ${content.certificateOfService} - -
- ${content.dateServed} -
-
-

- - - `; - - await page.setContent(mainContent); - - result = await page.pdf({ - displayHeaderFooter: true, - footerTemplate, - format: 'Letter', - headerTemplate, - margin: { - bottom: '200px', - top: '0px', - }, - printBackground: true, - }); - } catch (error) { - applicationContext.logger.error(error); - throw error; - } finally { - if (browser !== null) { - await browser.close(); - } - } - return result; -}; diff --git a/shared/src/business/utilities/generateHTMLTemplateForPDF/generateHTMLTemplateForPDF.test.js b/shared/src/business/utilities/generateHTMLTemplateForPDF/generateHTMLTemplateForPDF.test.js index d680861424c..09cdc481812 100644 --- a/shared/src/business/utilities/generateHTMLTemplateForPDF/generateHTMLTemplateForPDF.test.js +++ b/shared/src/business/utilities/generateHTMLTemplateForPDF/generateHTMLTemplateForPDF.test.js @@ -1,11 +1,11 @@ const createApplicationContext = require('../../../../../web-api/src/applicationContext'); const { generateHTMLTemplateForPDF } = require('./generateHTMLTemplateForPDF'); const applicationContext = createApplicationContext({}); -const { Case } = require('../../entities/cases/Case'); +const { CASE_CAPTION_POSTFIX } = require('../../entities/EntityConstants'); describe('generateHTMLTemplateForPDF', () => { const content = { - caseCaptionWithPostfix: `Test Case Caption ${Case.CASE_CAPTION_POSTFIX}`, + caseCaptionWithPostfix: `Test Case Caption ${CASE_CAPTION_POSTFIX}`, docketNumberWithSuffix: '123-45S', main: '
Test Main Content
', }; @@ -25,7 +25,7 @@ describe('generateHTMLTemplateForPDF', () => { expect(result.indexOf('')).toBe(0); expect(result.indexOf('U.S. Tax Court')).toBeGreaterThan(-1); expect( - result.indexOf(`Test Case Caption ${Case.CASE_CAPTION_POSTFIX}`), + result.indexOf(`Test Case Caption ${CASE_CAPTION_POSTFIX}`), ).toBeGreaterThan(-1); expect(result.indexOf('123-45S')).toBeGreaterThan(-1); expect(result.indexOf('
Test Main Content
')).toBeGreaterThan(-1); diff --git a/shared/src/business/utilities/generateHTMLTemplateForPDF/generateNoticeOfTrialIssuedTemplate.js b/shared/src/business/utilities/generateHTMLTemplateForPDF/generateNoticeOfTrialIssuedTemplate.js index f2bea1dfd84..c7b36a73463 100644 --- a/shared/src/business/utilities/generateHTMLTemplateForPDF/generateNoticeOfTrialIssuedTemplate.js +++ b/shared/src/business/utilities/generateHTMLTemplateForPDF/generateNoticeOfTrialIssuedTemplate.js @@ -5,6 +5,7 @@ const { formatNow, } = require('../DateHandler'); const { Case } = require('../../entities/cases/Case'); +const { CASE_CAPTION_POSTFIX } = require('../../entities/EntityConstants'); const { generateHTMLTemplateForPDF } = require('./generateHTMLTemplateForPDF'); /** @@ -45,7 +46,7 @@ const generateNoticeOfTrialIssuedTemplate = async ({ }); const templateContent = { - caseCaptionWithPostfix: `${caseCaption} ${Case.CASE_CAPTION_POSTFIX}`, + caseCaptionWithPostfix: `${caseCaption} ${CASE_CAPTION_POSTFIX}`, docketNumberWithSuffix, main, }; diff --git a/shared/src/business/utilities/generateHTMLTemplateForPDF/generatePrintableDocketRecordTemplate.js b/shared/src/business/utilities/generateHTMLTemplateForPDF/generatePrintableDocketRecordTemplate.js index 483a42e5a6b..e239768208d 100644 --- a/shared/src/business/utilities/generateHTMLTemplateForPDF/generatePrintableDocketRecordTemplate.js +++ b/shared/src/business/utilities/generateHTMLTemplateForPDF/generatePrintableDocketRecordTemplate.js @@ -1,4 +1,4 @@ -const { ContactFactory } = require('../../entities/contacts/ContactFactory'); +const { COUNTRY_TYPES } = require('../../entities/EntityConstants'); const { generateHTMLTemplateForPDF } = require('./generateHTMLTemplateForPDF'); const { reactTemplateGenerator } = require('./reactTemplateGenerator'); @@ -26,7 +26,7 @@ const generatePrintableDocketRecordTemplate = async ({ componentName: 'DocketRecord', data: { caseDetail, - countryTypes: ContactFactory.COUNTRY_TYPES, + countryTypes: COUNTRY_TYPES, entries, options: { caseCaptionExtension, diff --git a/shared/src/business/utilities/generateHTMLTemplateForPDF/generatePrintableDocketRecordTemplate.test.js b/shared/src/business/utilities/generateHTMLTemplateForPDF/generatePrintableDocketRecordTemplate.test.js index f7b3998ff88..55b7e0d518e 100644 --- a/shared/src/business/utilities/generateHTMLTemplateForPDF/generatePrintableDocketRecordTemplate.test.js +++ b/shared/src/business/utilities/generateHTMLTemplateForPDF/generatePrintableDocketRecordTemplate.test.js @@ -2,7 +2,7 @@ const createApplicationContext = require('../../../../../web-api/src/application const { generatePrintableDocketRecordTemplate, } = require('./generatePrintableDocketRecordTemplate'); -const { Case } = require('../../entities/cases/Case'); +const { CASE_CAPTION_POSTFIX } = require('../../entities/EntityConstants'); const applicationContext = createApplicationContext({}); @@ -29,7 +29,7 @@ describe('generatePrintableDocketRecordTemplate', () => { expect(result.indexOf('')).toBe(0); expect(result.indexOf(data.caseTitle)).toBeGreaterThan(-1); expect(result.indexOf(data.caseCaptionExtension)).toBeGreaterThan(-1); - expect(result.indexOf(Case.CASE_CAPTION_POSTFIX)).toBeGreaterThan(-1); + expect(result.indexOf(CASE_CAPTION_POSTFIX)).toBeGreaterThan(-1); expect(result.indexOf(data.docketNumberWithSuffix)).toBeGreaterThan(-1); expect(result.indexOf('
')).toBeGreaterThan(-1); diff --git a/shared/src/business/utilities/generateHTMLTemplateForPDF/reactTemplateGenerator.js b/shared/src/business/utilities/generateHTMLTemplateForPDF/reactTemplateGenerator.js index b4ba97240d8..b409a032c06 100644 --- a/shared/src/business/utilities/generateHTMLTemplateForPDF/reactTemplateGenerator.js +++ b/shared/src/business/utilities/generateHTMLTemplateForPDF/reactTemplateGenerator.js @@ -14,15 +14,24 @@ const { const { ChangeOfAddress, } = require('../pdfGenerator/documentTemplates/ChangeOfAddress.jsx'); +const { + CoverSheet, +} = require('../pdfGenerator/documentTemplates/CoverSheet.jsx'); const { DatePrintedFooter, } = require('../pdfGenerator/components/DatePrintedFooter.jsx'); +const { + DateServedFooter, +} = require('../pdfGenerator/components/DateServedFooter.jsx'); const { DocketRecord, } = require('../pdfGenerator/documentTemplates/DocketRecord.jsx'); const { NoticeOfDocketChange, } = require('../pdfGenerator/documentTemplates/NoticeOfDocketChange.jsx'); +const { + NoticeOfReceiptOfPetition, +} = require('../pdfGenerator/documentTemplates/NoticeOfReceiptOfPetition.jsx'); const { PageMetaHeaderDocket, } = require('../pdfGenerator/components/PageMetaHeaderDocket.jsx'); @@ -64,10 +73,13 @@ const components = { AddressLabelCoverSheet, CaseInventoryReport, ChangeOfAddress, + CoverSheet, DatePrintedFooter, + DateServedFooter, DocketRecord, DocumentService, NoticeOfDocketChange, + NoticeOfReceiptOfPetition, Order, PageMetaHeaderDocket, PendingReport, diff --git a/shared/src/business/utilities/getCaseCaptionMeta.js b/shared/src/business/utilities/getCaseCaptionMeta.js index 580b13856dd..2ffcc266e6b 100644 --- a/shared/src/business/utilities/getCaseCaptionMeta.js +++ b/shared/src/business/utilities/getCaseCaptionMeta.js @@ -1,4 +1,5 @@ const { Case } = require('../entities/cases/Case'); +const { CASE_CAPTION_POSTFIX } = require('../entities/EntityConstants'); /** * Gets case caption parts from case data @@ -8,7 +9,6 @@ const { Case } = require('../entities/cases/Case'); */ const getCaseCaptionMeta = caseDetail => { - const { CASE_CAPTION_POSTFIX } = Case; const { caseCaption } = caseDetail; const caseTitle = Case.getCaseTitle(caseDetail.caseCaption); diff --git a/shared/src/business/utilities/getCaseCaptionMeta.test.js b/shared/src/business/utilities/getCaseCaptionMeta.test.js index c87691929d7..382d248c10d 100644 --- a/shared/src/business/utilities/getCaseCaptionMeta.test.js +++ b/shared/src/business/utilities/getCaseCaptionMeta.test.js @@ -1,4 +1,4 @@ -const { Case } = require('../entities/cases/Case'); +const { CASE_CAPTION_POSTFIX } = require('../entities/EntityConstants'); const { getCaseCaptionMeta } = require('./getCaseCaptionMeta'); describe('getCaseCaptionMeta', () => { @@ -7,9 +7,9 @@ describe('getCaseCaptionMeta', () => { caseCaption: 'Eve Brewer, Petitioner', }; expect(getCaseCaptionMeta(caseDetail)).toMatchObject({ - CASE_CAPTION_POSTFIX: Case.CASE_CAPTION_POSTFIX, + CASE_CAPTION_POSTFIX: CASE_CAPTION_POSTFIX, caseCaption: 'Eve Brewer, Petitioner', - caseCaptionWithPostfix: `Eve Brewer, Petitioner ${Case.CASE_CAPTION_POSTFIX}`, + caseCaptionWithPostfix: `Eve Brewer, Petitioner ${CASE_CAPTION_POSTFIX}`, }); }); diff --git a/shared/src/business/utilities/getFormattedCaseDetail.js b/shared/src/business/utilities/getFormattedCaseDetail.js index 823849a10d2..ff102d57077 100644 --- a/shared/src/business/utilities/getFormattedCaseDetail.js +++ b/shared/src/business/utilities/getFormattedCaseDetail.js @@ -3,12 +3,17 @@ const { calendarDatesCompared, createISODateString, } = require('./DateHandler'); +const { + CASE_STATUS_TYPES, + COURT_ISSUED_EVENT_CODES, + PAYMENT_STATUS, + TRANSCRIPT_EVENT_CODE, +} = require('../entities/EntityConstants'); const { Case } = require('../entities/cases/Case'); const { cloneDeep, isEmpty } = require('lodash'); -const { Document } = require('../entities/Document'); -const { User } = require('../entities/User'); +const { ROLES } = require('../entities/EntityConstants'); -const courtIssuedDocumentTypes = Document.COURT_ISSUED_EVENT_CODES.map( +const courtIssuedDocumentTypes = COURT_ISSUED_EVENT_CODES.map( courtIssuedDoc => courtIssuedDoc.documentType, ); @@ -58,7 +63,7 @@ const formatDocument = (applicationContext, document) => { result.isNotServedCourtIssuedDocument = result.isCourtIssuedDocument && !result.servedAt; - result.isTranscript = result.eventCode === Document.TRANSCRIPT_EVENT_CODE; + result.isTranscript = result.eventCode === TRANSCRIPT_EVENT_CODE; result.qcWorkItemsUntouched = !!qcWorkItems.length && @@ -70,7 +75,7 @@ const formatDocument = (applicationContext, document) => { if (result.servedParties && result.servedParties.length > 0) { if ( result.servedParties.length === 1 && - result.servedParties[0].role === User.ROLES.irsSuperuser + result.servedParties[0].role === ROLES.irsSuperuser ) { result.servedPartiesCode = 'R'; } else { @@ -95,7 +100,7 @@ const formatDocketRecord = (applicationContext, docketRecord) => { const TRANSCRIPT_AGE_DAYS_MIN = 90; const documentMeetsAgeRequirements = document => { - const transcriptCodes = [Document.TRANSCRIPT_EVENT_CODE]; + const transcriptCodes = [TRANSCRIPT_EVENT_CODE]; const isTranscript = transcriptCodes.includes(document.eventCode); if (!isTranscript) return true; const availableOnDate = calculateISODate({ @@ -316,8 +321,8 @@ const formatCase = (applicationContext, caseDetail) => { result.formattedPreferredTrialCity = result.preferredTrialCity || 'No location selected'; - if (result.trialSessionId && result.status !== Case.STATUS_TYPES.closed) { - if (result.status === Case.STATUS_TYPES.calendared) { + if (result.trialSessionId && result.status !== CASE_STATUS_TYPES.closed) { + if (result.status === CASE_STATUS_TYPES.calendared) { result.showTrialCalendared = true; } else { result.showScheduled = true; @@ -374,12 +379,12 @@ const formatCase = (applicationContext, caseDetail) => { let paymentDate = ''; let paymentMethod = ''; - if (caseDetail.petitionPaymentStatus === Case.PAYMENT_STATUS.PAID) { + if (caseDetail.petitionPaymentStatus === PAYMENT_STATUS.PAID) { paymentDate = applicationContext .getUtilities() .formatDateString(caseDetail.petitionPaymentDate, 'MM/DD/YY'); paymentMethod = caseDetail.petitionPaymentMethod; - } else if (caseDetail.petitionPaymentStatus === Case.PAYMENT_STATUS.WAIVED) { + } else if (caseDetail.petitionPaymentStatus === PAYMENT_STATUS.WAIVED) { paymentDate = applicationContext .getUtilities() .formatDateString(caseDetail.petitionPaymentWaivedDate, 'MM/DD/YY'); diff --git a/shared/src/business/utilities/getFormattedCaseDetail.test.js b/shared/src/business/utilities/getFormattedCaseDetail.test.js index 5e56c62f0f7..864cd95f06c 100644 --- a/shared/src/business/utilities/getFormattedCaseDetail.test.js +++ b/shared/src/business/utilities/getFormattedCaseDetail.test.js @@ -1,4 +1,3 @@ -import { Case } from '../entities/cases/Case'; import { TRANSCRIPT_AGE_DAYS_MIN, documentMeetsAgeRequirements, @@ -9,9 +8,13 @@ import { getFormattedCaseDetail, sortDocketRecords, } from './getFormattedCaseDetail'; -import { User } from '../entities/User'; import { applicationContext } from '../../../../web-client/src/applicationContext'; import { calculateISODate, createISODateString } from './DateHandler'; +const { + CASE_STATUS_TYPES, + PAYMENT_STATUS, + ROLES, +} = require('../entities/EntityConstants'); const { MOCK_USERS } = require('../../test/mockUsers'); applicationContext.getCurrentUser = () => @@ -429,7 +432,7 @@ describe('formatCase', () => { it('should format trial details if case status is calendared', () => { const result = formatCase(applicationContext, { ...mockCaseDetail, - status: Case.STATUS_TYPES.calendared, + status: CASE_STATUS_TYPES.calendared, trialDate: '2011-11-11', trialLocation: 'Boise, Idaho', trialSessionId: '1f1aa3f7-e2e3-43e6-885d-4ce341588c76', @@ -469,7 +472,7 @@ describe('formatCase', () => { it('should format trial details with incomplete trial information', () => { const result = formatCase(applicationContext, { ...mockCaseDetail, - status: Case.STATUS_TYPES.calendared, + status: CASE_STATUS_TYPES.calendared, trialDate: undefined, trialLocation: undefined, trialSessionId: '1f1aa3f7-e2e3-43e6-885d-4ce341588c76', @@ -494,7 +497,7 @@ describe('formatCase', () => { it('should show not scheduled section if case status is closed', () => { const result = formatCase(applicationContext, { ...mockCaseDetail, - status: Case.STATUS_TYPES.closed, + status: CASE_STATUS_TYPES.closed, }); expect(result).toMatchObject({ @@ -611,7 +614,7 @@ describe('formatDocument', () => { it('should set the servedPartiesCode to `R` if servedAt date exists and servedParties is an array of length 1 with role irsSuperuser', () => { const results = formatDocument(applicationContext, { servedAt: '2019-03-27T21:53:00.297Z', - servedParties: [{ role: User.ROLES.irsSuperuser }], + servedParties: [{ role: ROLES.irsSuperuser }], }); expect(results).toMatchObject({ servedPartiesCode: 'R', @@ -753,7 +756,7 @@ it('should format filing fee string for a paid petition fee', () => { ...mockCaseDetailBase, petitionPaymentDate: '2019-03-01T21:40:46.415Z', petitionPaymentMethod: 'check', - petitionPaymentStatus: Case.PAYMENT_STATUS.PAID, + petitionPaymentStatus: PAYMENT_STATUS.PAID, }, }); @@ -765,7 +768,7 @@ it('should format filing fee string for a waived petition fee', () => { applicationContext, caseDetail: { ...mockCaseDetailBase, - petitionPaymentStatus: Case.PAYMENT_STATUS.WAIVED, + petitionPaymentStatus: PAYMENT_STATUS.WAIVED, petitionPaymentWaivedDate: '2019-03-01T21:40:46.415Z', }, }); @@ -778,7 +781,7 @@ it('should format filing fee string for an unpaid petition fee', () => { applicationContext, caseDetail: { ...mockCaseDetailBase, - petitionPaymentStatus: Case.PAYMENT_STATUS.UNPAID, + petitionPaymentStatus: PAYMENT_STATUS.UNPAID, }, }); diff --git a/shared/src/business/utilities/getFormattedTrialSessionDetails.test.js b/shared/src/business/utilities/getFormattedTrialSessionDetails.test.js index a654802f478..1a2a6e4f7e4 100644 --- a/shared/src/business/utilities/getFormattedTrialSessionDetails.test.js +++ b/shared/src/business/utilities/getFormattedTrialSessionDetails.test.js @@ -1,14 +1,12 @@ import { MOCK_CASE } from '../../../../shared/src/test/mockCase'; -import { TrialSession } from '../entities/trialSessions/TrialSession'; -const { SESSION_STATUS_GROUPS } = TrialSession; +import { SESSION_STATUS_GROUPS } from '../entities/EntityConstants'; +import { applicationContext } from '../../../../web-client/src/applicationContext'; import { formattedTrialSessionDetails, getTrialSessionStatus, } from './getFormattedTrialSessionDetails'; import { omit } from 'lodash'; -import { applicationContext } from '../../../../web-client/src/applicationContext'; - describe('formattedTrialSessionDetails', () => { const TRIAL_SESSION = { caseOrder: [], diff --git a/shared/src/business/utilities/htmlGenerator/index.scss b/shared/src/business/utilities/htmlGenerator/index.scss index c7c47dee155..e4af36c3ad4 100644 --- a/shared/src/business/utilities/htmlGenerator/index.scss +++ b/shared/src/business/utilities/htmlGenerator/index.scss @@ -78,10 +78,18 @@ th { width: 49%; } +.margin-top-40 { + margin-top: 40px; +} + .margin-top-80 { margin-top: 80px; } +.margin-top-200 { + margin-top: 200px; +} + .margin-top-5 { margin-top: 5px; } @@ -140,6 +148,10 @@ th { font-size: 14px; line-height: 18px; + &.border-none { + border: none; + } + #caption-extension, #caption-v, #caption-respondent { @@ -350,6 +362,20 @@ th { text-decoration: none; } } +#document-cover-sheet { + .case-information, + #docket-number, + #document-title, + #certificate-of-service { + font-family: 'nimbus_sans_l', sans-serif !important; + } + + #certificate-of-service { + position: absolute; + bottom: 60px; + left: 60; + } +} #document-docket-record { // TODO: These are basically cards, and could be refactored for more reusability @@ -408,7 +434,7 @@ th { padding-left: 0.6in; } - .address { + .address-label { position: absolute; bottom: 0in; left: 0.5in; diff --git a/shared/src/business/utilities/pdfGenerator/components/AddressLabel.jsx b/shared/src/business/utilities/pdfGenerator/components/AddressLabel.jsx new file mode 100644 index 00000000000..fa5cca7d626 --- /dev/null +++ b/shared/src/business/utilities/pdfGenerator/components/AddressLabel.jsx @@ -0,0 +1,25 @@ +const React = require('react'); + +export const AddressLabel = ({ + address1, + address2, + address3, + city, + countryName, + name, + postalCode, + state, +}) => { + return ( +
+
{name}
+
{address1}
+ {address2 &&
{address2}
} + {address3 &&
{address3}
} +
+ {city}, {state} {postalCode} +
+ {!address3 &&
{countryName}
} +
+ ); +}; diff --git a/shared/src/business/utilities/pdfGenerator/components/AddressLabel.test.js b/shared/src/business/utilities/pdfGenerator/components/AddressLabel.test.js new file mode 100644 index 00000000000..52ed2c38f82 --- /dev/null +++ b/shared/src/business/utilities/pdfGenerator/components/AddressLabel.test.js @@ -0,0 +1,43 @@ +const React = require('react'); +const { AddressLabel } = require('./AddressLabel.jsx'); +const { shallow } = require('enzyme'); + +describe('AddressLabel', () => { + it('renders the name and address', () => { + const wrapper = shallow( + , + ); + + expect(wrapper.text()).toContain('123 Some Street'); + expect(wrapper.text()).toContain('Some City'); + expect(wrapper.text()).toContain('USA'); + expect(wrapper.text()).toContain('Test Person'); + expect(wrapper.text()).toContain('89890'); + expect(wrapper.text()).toContain('ZZ'); + }); + + it('renders optional address information if present', () => { + const wrapper = shallow( + , + ); + + expect(wrapper.text()).toContain('address two'); + expect(wrapper.text()).toContain('address three'); + expect(wrapper.text()).not.toContain('USA'); + }); +}); diff --git a/shared/src/business/utilities/pdfGenerator/components/DatePrintedFooter.test.js b/shared/src/business/utilities/pdfGenerator/components/DatePrintedFooter.test.js new file mode 100644 index 00000000000..d2ed537a5b2 --- /dev/null +++ b/shared/src/business/utilities/pdfGenerator/components/DatePrintedFooter.test.js @@ -0,0 +1,10 @@ +const React = require('react'); +const { DatePrintedFooter } = require('./DatePrintedFooter.jsx'); +const { shallow } = require('enzyme'); + +describe('DatePrintedFooter', () => { + it('renders the given dateServed from props', () => { + let wrapper = shallow(); + expect(wrapper.text()).toContain('Printed 01/01/2020'); + }); +}); diff --git a/shared/src/business/utilities/pdfGenerator/components/DateServedFooter.jsx b/shared/src/business/utilities/pdfGenerator/components/DateServedFooter.jsx new file mode 100644 index 00000000000..aed02ef3e1e --- /dev/null +++ b/shared/src/business/utilities/pdfGenerator/components/DateServedFooter.jsx @@ -0,0 +1,18 @@ +const React = require('react'); + +export const DateServedFooter = ({ dateServed }) => { + return ( +
+ SERVED {dateServed} +
+ ); +}; diff --git a/shared/src/business/utilities/pdfGenerator/components/DateServedFooter.test.js b/shared/src/business/utilities/pdfGenerator/components/DateServedFooter.test.js new file mode 100644 index 00000000000..087b3169643 --- /dev/null +++ b/shared/src/business/utilities/pdfGenerator/components/DateServedFooter.test.js @@ -0,0 +1,10 @@ +const React = require('react'); +const { DateServedFooter } = require('./DateServedFooter.jsx'); +const { shallow } = require('enzyme'); + +describe('DateServedFooter', () => { + it('renders the given dateServed from props', () => { + let wrapper = shallow(); + expect(wrapper.text()).toContain('SERVED 01/01/2020'); + }); +}); diff --git a/shared/src/business/utilities/pdfGenerator/components/PageMetaHeaderDocket.jsx b/shared/src/business/utilities/pdfGenerator/components/PageMetaHeaderDocket.jsx index 10320cb10cf..39b428c99e7 100644 --- a/shared/src/business/utilities/pdfGenerator/components/PageMetaHeaderDocket.jsx +++ b/shared/src/business/utilities/pdfGenerator/components/PageMetaHeaderDocket.jsx @@ -3,10 +3,14 @@ const React = require('react'); export const PageMetaHeaderDocket = ({ docketNumber }) => { return ( <> -
+
Docket Number: {docketNumber}
-
+
Page of{' '}
diff --git a/shared/src/business/utilities/pdfGenerator/components/ReportsMetaHeader.jsx b/shared/src/business/utilities/pdfGenerator/components/ReportsMetaHeader.jsx index 99e4b75bc14..c3350a20c6c 100644 --- a/shared/src/business/utilities/pdfGenerator/components/ReportsMetaHeader.jsx +++ b/shared/src/business/utilities/pdfGenerator/components/ReportsMetaHeader.jsx @@ -3,10 +3,15 @@ const React = require('react'); export const ReportsMetaHeader = ({ headerTitle }) => { return ( <> -
+
{headerTitle}
-
+
Page of{' '}
diff --git a/shared/src/business/utilities/pdfGenerator/documentTemplates/AddressLabelCoverSheet.jsx b/shared/src/business/utilities/pdfGenerator/documentTemplates/AddressLabelCoverSheet.jsx index e374ea08b45..588e6ea9499 100644 --- a/shared/src/business/utilities/pdfGenerator/documentTemplates/AddressLabelCoverSheet.jsx +++ b/shared/src/business/utilities/pdfGenerator/documentTemplates/AddressLabelCoverSheet.jsx @@ -1,4 +1,5 @@ const React = require('react'); +const { AddressLabel } = require('../components/AddressLabel.jsx'); export const AddressLabelCoverSheet = ({ address1, @@ -14,16 +15,16 @@ export const AddressLabelCoverSheet = ({ return (
Docket {docketNumberWithSuffix}
-
-
{name}
-
{address1}
- {address2 &&
{address2}
} - {address3 &&
{address3}
} -
- {city}, {state} {postalCode} -
- {!address3 &&
{countryName}
} -
+
); }; diff --git a/shared/src/business/utilities/pdfGenerator/documentTemplates/AddressLabelCoverSheet.test.js b/shared/src/business/utilities/pdfGenerator/documentTemplates/AddressLabelCoverSheet.test.js index 5f90450f1a6..bd01cb57cd9 100644 --- a/shared/src/business/utilities/pdfGenerator/documentTemplates/AddressLabelCoverSheet.test.js +++ b/shared/src/business/utilities/pdfGenerator/documentTemplates/AddressLabelCoverSheet.test.js @@ -1,10 +1,10 @@ const React = require('react'); const { AddressLabelCoverSheet } = require('./AddressLabelCoverSheet.jsx'); -const { shallow } = require('enzyme'); +const { mount } = require('enzyme'); describe('AddressLabelCoverSheet', () => { it('renders the docket number with suffix', () => { - const wrapper = shallow( + const wrapper = mount( , ); @@ -12,7 +12,7 @@ describe('AddressLabelCoverSheet', () => { }); it('renders the name and address', () => { - const wrapper = shallow( + const wrapper = mount( { expect(wrapper.text()).toContain('89890'); expect(wrapper.text()).toContain('ZZ'); }); - - it('renders optional address information if present', () => { - const wrapper = shallow( - , - ); - - expect(wrapper.text()).toContain('address two'); - expect(wrapper.text()).toContain('address three'); - expect(wrapper.text()).not.toContain('USA'); - }); }); diff --git a/shared/src/business/utilities/pdfGenerator/documentTemplates/CoverSheet.jsx b/shared/src/business/utilities/pdfGenerator/documentTemplates/CoverSheet.jsx new file mode 100644 index 00000000000..e48ef6edced --- /dev/null +++ b/shared/src/business/utilities/pdfGenerator/documentTemplates/CoverSheet.jsx @@ -0,0 +1,66 @@ +const React = require('react'); + +export const CoverSheet = ({ + caseCaptionExtension, + caseTitle, + certificateOfService, + dateFiledLodged, + dateFiledLodgedLabel, + dateReceived, + docketNumberWithSuffix, + documentTitle, + electronicallyFiled, + mailingDate, +}) => { + return ( +
+
+
+
+
+
+
+ Received +
+ {dateReceived} +
+
+
+
+ {dateFiledLodgedLabel} +
+ {dateFiledLodged} +
+
+
+ +
+
+
{caseTitle}
+
{caseCaptionExtension}
+
v.
+
Commissioner of Internal Revenue
+
Respondent
+
+ +
+ {electronicallyFiled &&
Electronically Filed
} + {mailingDate &&
{mailingDate}
} +
Docket Number {docketNumberWithSuffix}
+
+
+
+ +

+ {documentTitle} +

+ + {certificateOfService && ( +
Certificate of Service
+ )} +
+ ); +}; diff --git a/shared/src/business/utilities/pdfGenerator/documentTemplates/CoverSheet.test.js b/shared/src/business/utilities/pdfGenerator/documentTemplates/CoverSheet.test.js new file mode 100644 index 00000000000..3e3e883f676 --- /dev/null +++ b/shared/src/business/utilities/pdfGenerator/documentTemplates/CoverSheet.test.js @@ -0,0 +1,76 @@ +const React = require('react'); +const { CoverSheet } = require('./CoverSheet.jsx'); +const { shallow } = require('enzyme'); + +describe('CoverSheet', () => { + it('renders a document header with case information', () => { + const wrapper = shallow( + , + ); + + expect(wrapper.find('#caption-title').text()).toEqual('Captain Fantastic'); + expect(wrapper.find('#caption-extension').text()).toEqual('Petitioner'); + expect(wrapper.find('#docket-number').text()).toContain( + 'Docket Number 123-45S', + ); + }); + + it('renders the received date', () => { + const wrapper = shallow(); + const text = wrapper.find('#date-received').text(); + + expect(text).toContain('Received'); + expect(text).toContain('01/01/2020'); + }); + + it('renders a filed or lodged label along with the associated date', () => { + const wrapper = shallow( + , + ); + const text = wrapper.find('#filed-or-lodged').text(); + + expect(text).toContain('Some Label'); + expect(text).toContain('02/02/2020'); + }); + + it('renders Electronically Filed if the case was filed electronically', () => { + let wrapper = shallow(); + + expect(wrapper.find('#docket-number').text()).not.toContain( + 'Electronically Filed', + ); + + wrapper = shallow(); + + expect(wrapper.find('#docket-number').text()).toContain( + 'Electronically Filed', + ); + }); + + it('renders the mailingDate if provided', () => { + let wrapper = shallow(); + + expect(wrapper.find('#docket-number').text()).not.toContain('12/1/2019'); + + wrapper = shallow(); + + expect(wrapper.find('#docket-number').text()).toContain('12/1/2019'); + }); + + it('renders Certificate of Service of there is a certificateOfService', () => { + let wrapper = shallow(); + + expect(wrapper.find('#certificate-of-service').length).toEqual(0); + + wrapper = shallow(); + + expect(wrapper.find('#certificate-of-service').length).toEqual(1); + }); +}); diff --git a/shared/src/business/utilities/pdfGenerator/documentTemplates/DocketRecord.test.js b/shared/src/business/utilities/pdfGenerator/documentTemplates/DocketRecord.test.js index 1db0df5652d..2412e390e3d 100644 --- a/shared/src/business/utilities/pdfGenerator/documentTemplates/DocketRecord.test.js +++ b/shared/src/business/utilities/pdfGenerator/documentTemplates/DocketRecord.test.js @@ -1,5 +1,5 @@ const React = require('react'); -const { ContactFactory } = require('../../../entities/contacts/ContactFactory'); +const { COUNTRY_TYPES } = require('../../../entities/EntityConstants'); const { DocketRecord } = require('./DocketRecord.jsx'); const { mount } = require('enzyme'); @@ -107,7 +107,7 @@ describe('DocketRecord', () => { const wrapper = mount( , @@ -138,7 +138,7 @@ describe('DocketRecord', () => { const wrapper = mount( , @@ -158,7 +158,7 @@ describe('DocketRecord', () => { const wrapper = mount( , @@ -181,13 +181,13 @@ describe('DocketRecord', () => { }); it("displays a party's country if international", () => { - contactPrimary.countryType = ContactFactory.COUNTRY_TYPES.INTERNATIONAL; + contactPrimary.countryType = COUNTRY_TYPES.INTERNATIONAL; contactPrimary.country = 'The Republic of Texas'; const wrapper = mount( , @@ -205,7 +205,7 @@ describe('DocketRecord', () => { const wrapper = mount( , @@ -225,7 +225,7 @@ describe('DocketRecord', () => { let wrapper = mount( , @@ -238,7 +238,7 @@ describe('DocketRecord', () => { wrapper = mount( , @@ -279,7 +279,7 @@ describe('DocketRecord', () => { const wrapper = mount( , @@ -308,7 +308,7 @@ describe('DocketRecord', () => { let wrapper = mount( , @@ -321,7 +321,7 @@ describe('DocketRecord', () => { wrapper = mount( , @@ -350,7 +350,7 @@ describe('DocketRecord', () => { const wrapper = mount( , @@ -376,7 +376,7 @@ describe('DocketRecord', () => { const wrapper = mount( , @@ -394,7 +394,7 @@ describe('DocketRecord', () => { const wrapper = mount( , @@ -411,7 +411,7 @@ describe('DocketRecord', () => { const wrapper = mount( , @@ -428,7 +428,7 @@ describe('DocketRecord', () => { const wrapper = mount( , @@ -446,7 +446,7 @@ describe('DocketRecord', () => { const wrapper = mount( , diff --git a/shared/src/business/utilities/pdfGenerator/documentTemplates/NoticeOfReceiptOfPetition.jsx b/shared/src/business/utilities/pdfGenerator/documentTemplates/NoticeOfReceiptOfPetition.jsx new file mode 100644 index 00000000000..518368afa48 --- /dev/null +++ b/shared/src/business/utilities/pdfGenerator/documentTemplates/NoticeOfReceiptOfPetition.jsx @@ -0,0 +1,96 @@ +const React = require('react'); +const { + CompressedDocketHeader, +} = require('../components/CompressedDocketHeader.jsx'); +const { AddressLabel } = require('../components/AddressLabel.jsx'); +const { PrimaryHeader } = require('../components/PrimaryHeader.jsx'); + +export const NoticeOfReceiptOfPetition = ({ + address, + caseCaptionExtension, + caseTitle, + docketNumberWithSuffix, + preferredTrialCity, + receivedAtFormatted, + servedDate, +}) => { + return ( + <> + + +
+ The Court received and filed your petition on {receivedAtFormatted} and + served it on respondent on {servedDate}. +
+ +
+ (X) Request for Place of Trial at {preferredTrialCity}. +
+ +
+
+ Your Docket Number: {docketNumberWithSuffix} +
+
+ Please use this docket number on all papers and correspondence that + you send to the Tax Court. Do not include your Social Security or + Taxpayer Identification numbers on any documents you file with the + Court. +
+
+ +
+
Internet Access:
+
+ To obtain further information about proceeding in the Tax Court, + please visit{' '} + + www.ustaxcourt.gov + {' '} + and select "Taxpayer Identification". +
+
+ +
+
Change of Address:
+
+ You must notify the Clerk of the Court if you change your address. If + you filed your petition in paper, see Tax Court Form 10, Notice of + Change of Address, under “Forms” on the Tax Court’s Website at{' '} + + www.ustaxcourt.gov + + . If you filed your petition electronically, you may update your + address under the “Case Information” tab in your case online. Failure + to notify the Clerk of the Court of a change of your address can mean + you do not receive notices and documents essential to your case and + can lead to dismissal of your case. +
+
+ +

+ Stephanie A. Servoss +
+ Clerk of the Court +

+ +
+ +
+ + ); +}; diff --git a/shared/src/business/utilities/pdfGenerator/documentTemplates/NoticeOfReceiptOfPetition.test.js b/shared/src/business/utilities/pdfGenerator/documentTemplates/NoticeOfReceiptOfPetition.test.js new file mode 100644 index 00000000000..962b368070c --- /dev/null +++ b/shared/src/business/utilities/pdfGenerator/documentTemplates/NoticeOfReceiptOfPetition.test.js @@ -0,0 +1,78 @@ +const React = require('react'); +const { + NoticeOfReceiptOfPetition, +} = require('./NoticeOfReceiptOfPetition.jsx'); +const { mount, shallow } = require('enzyme'); + +describe('NoticeOfReceiptOfPetition', () => { + const caseCaptionExtension = 'Petitioner(s)'; + const caseTitle = 'Test Petitioner'; + const docketNumberWithSuffix = '123-19S'; + const address = { + address1: '123 Some St.', + city: 'Somecity', + countryName: '', + name: 'Test Petitioner', + postalCode: '80008', + state: 'ZZ', + }; + + it('renders a document header with case information', () => { + const wrapper = mount( + , + ); + + expect(wrapper.find('#caption').text()).toContain(caseTitle); + expect(wrapper.find('#caption').text()).toContain(caseCaptionExtension); + expect(wrapper.find('#docket-number').text()).toEqual( + `Docket Number ${docketNumberWithSuffix}`, + ); + expect(wrapper.find('h3').at(0).text()).toEqual( + 'Notice of Receipt of Petition', + ); + }); + + it('renders the case information', () => { + const wrapper = shallow( + , + ); + const textContent = wrapper.text(); + expect(textContent).toContain(docketNumberWithSuffix); + expect(textContent).toContain('Birmingham, AL'); + expect(textContent).toContain('December 1, 2019'); + expect(textContent).toContain('June 3, 2020'); + }); + + it('renders the the petitioner mailing address', () => { + const wrapper = mount( + , + ); + const textContent = wrapper.text(); + expect(textContent).toContain(address.name); + expect(textContent).toContain(address.address1); + expect(textContent).toContain(address.city); + expect(textContent).toContain(address.state); + expect(textContent).toContain(address.postalCode); + }); +}); diff --git a/shared/src/business/utilities/pdfGenerator/documentTemplates/StandingPretrialNotice.jsx b/shared/src/business/utilities/pdfGenerator/documentTemplates/StandingPretrialNotice.jsx index 5df91e10727..887af65fce0 100644 --- a/shared/src/business/utilities/pdfGenerator/documentTemplates/StandingPretrialNotice.jsx +++ b/shared/src/business/utilities/pdfGenerator/documentTemplates/StandingPretrialNotice.jsx @@ -88,7 +88,7 @@ export const StandingPretrialNotice = ({ footerDate, options, trialInfo }) => { -
  • +
  • WHAT TO DO THE DAY OF THE TRIAL SESSION
    • diff --git a/shared/src/business/utilities/setServiceIndicatorsForCase.js b/shared/src/business/utilities/setServiceIndicatorsForCase.js index 87e4e1bff2d..e953e3bc26a 100644 --- a/shared/src/business/utilities/setServiceIndicatorsForCase.js +++ b/shared/src/business/utilities/setServiceIndicatorsForCase.js @@ -1,5 +1,5 @@ const { isEmpty } = require('lodash'); -const { SERVICE_INDICATOR_TYPES } = require('../entities/cases/CaseConstants'); +const { SERVICE_INDICATOR_TYPES } = require('../entities/EntityConstants'); /** * sets the service indicators for parties on the given case diff --git a/shared/src/business/utilities/setServiceIndicatorsForCase.test.js b/shared/src/business/utilities/setServiceIndicatorsForCase.test.js index 8670cc1a9f4..2c41d96551f 100644 --- a/shared/src/business/utilities/setServiceIndicatorsForCase.test.js +++ b/shared/src/business/utilities/setServiceIndicatorsForCase.test.js @@ -1,5 +1,4 @@ -import { SERVICE_INDICATOR_TYPES } from '../entities/cases/CaseConstants'; -import { User } from '../entities/User'; +import { ROLES, SERVICE_INDICATOR_TYPES } from '../entities/EntityConstants'; import { setServiceIndicatorsForCase } from './setServiceIndicatorsForCase'; let baseCaseDetail; @@ -8,7 +7,7 @@ const basePractitioner = { email: 'practitioner1@example.com', name: 'Test Practitioner', representingPrimary: true, - role: User.ROLES.privatePractitioner, + role: ROLES.privatePractitioner, serviceIndicator: 'Paper', }; @@ -16,7 +15,7 @@ const baseRespondent = { email: 'flexionustc+respondent@gmail.com', name: 'Test Respondent', respondentId: '123-abc-123-abc', - role: User.ROLES.irsPractitioner, + role: ROLES.irsPractitioner, serviceIndicator: 'Paper', userId: 'abc-123-abc-123', }; diff --git a/shared/src/errors/errors.js b/shared/src/errors/errors.js index 99b62c3467b..fd39f7e0e10 100644 --- a/shared/src/errors/errors.js +++ b/shared/src/errors/errors.js @@ -99,9 +99,11 @@ module.exports.InvalidEntityError = class InvalidEntityError extends Error { * * @param {string} message the error message */ - constructor(message = 'entity is invalid or invalid for operation') { - super(message); - - this.statusCode = 422; + constructor( + message = 'entity is invalid or invalid for operation', + validationName, + entityIds, + ) { + super(`The ${validationName} entity was invalid. ${message}. ${entityIds}`); } }; diff --git a/shared/src/errors/errors.test.js b/shared/src/errors/errors.test.js index 3475ff01cb1..e21bd3f4580 100644 --- a/shared/src/errors/errors.test.js +++ b/shared/src/errors/errors.test.js @@ -75,15 +75,13 @@ describe('InvalidEntityError', () => { let error; beforeEach(() => { - error = new InvalidEntityError(); + error = new InvalidEntityError('Test message', 'TestEntity', 123); }); - it('should set a status code of 422', () => { - expect(error.statusCode).toEqual(422); - }); - - it('should set the message', () => { - expect(error.message).toEqual('entity is invalid or invalid for operation'); + it('should set the message which includes the entityName and failing ids', () => { + expect(error.message).toEqual( + 'The TestEntity entity was invalid. Test message. 123', + ); }); }); diff --git a/shared/src/persistence/dynamo/cases/getCasesByUser.test.js b/shared/src/persistence/dynamo/cases/getCasesByUser.test.js index 8a8d6ebc06b..24d8ad3f70f 100644 --- a/shared/src/persistence/dynamo/cases/getCasesByUser.test.js +++ b/shared/src/persistence/dynamo/cases/getCasesByUser.test.js @@ -1,6 +1,6 @@ const client = require('../../../../../shared/src/persistence/dynamodbClientService'); const { getCasesByUser } = require('./getCasesByUser'); -const { User } = require('../../../business/entities/User'); +const { ROLES } = require('../../../business/entities/EntityConstants'); const { applicationContext, @@ -18,7 +18,7 @@ applicationContext.getDocumentClient.mockReturnValue({ }); const user = { - role: User.ROLES.petitioner, + role: ROLES.petitioner, userId: '522573b0-dc40-47f7-96fd-64758da315f5', }; diff --git a/shared/src/persistence/dynamo/cases/getClosedCasesByUser.js b/shared/src/persistence/dynamo/cases/getClosedCasesByUser.js new file mode 100644 index 00000000000..fa8a815a955 --- /dev/null +++ b/shared/src/persistence/dynamo/cases/getClosedCasesByUser.js @@ -0,0 +1,22 @@ +const { + CASE_STATUS_TYPES, +} = require('../../../business/entities/EntityConstants'); +const { getUserCases } = require('./getUserCases'); + +/** + * getClosedCasesByUser + * + * @param {object} providers the providers object + * @param {object} providers.applicationContext the application context + * @param {string} providers.userId the user id to get closed cases by + * @returns {object} the closed cases + */ +exports.getClosedCasesByUser = async ({ applicationContext, userId }) => { + const userCases = await getUserCases({ applicationContext, userId }); + + const closedCases = userCases.filter( + x => x.status === CASE_STATUS_TYPES.closed, + ); + + return closedCases; +}; diff --git a/shared/src/persistence/dynamo/cases/getClosedCasesByUser.test.js b/shared/src/persistence/dynamo/cases/getClosedCasesByUser.test.js new file mode 100644 index 00000000000..80016a01566 --- /dev/null +++ b/shared/src/persistence/dynamo/cases/getClosedCasesByUser.test.js @@ -0,0 +1,45 @@ +const { + applicationContext, +} = require('../../../business/test/createTestApplicationContext'); +const { getClosedCasesByUser } = require('./getClosedCasesByUser'); +const { ROLES } = require('../../../business/entities/EntityConstants'); + +jest.mock('./getUserCases', () => ({ + getUserCases: jest.fn().mockReturnValue([ + { + caseId: '123', + pk: 'case|123', + sk: 'case|123', + status: 'New', + }, + { + caseId: '121', + pk: 'case|121', + sk: 'case|121', + status: 'Closed', + }, + ]), +})); + +const user = { + role: ROLES.petitioner, + userId: '522573b0-dc40-47f7-96fd-64758da315f5', +}; + +describe('getClosedCasesByUser', () => { + it('should filter out cases that are not closed', async () => { + const result = await getClosedCasesByUser({ + applicationContext, + user, + }); + + expect(result).toMatchObject([ + { + caseId: '121', + pk: 'case|121', + sk: 'case|121', + status: 'Closed', + }, + ]); + }); +}); diff --git a/shared/src/persistence/dynamo/cases/getOpenCasesByUser.js b/shared/src/persistence/dynamo/cases/getOpenCasesByUser.js index 8515f777392..d597dc11fa6 100644 --- a/shared/src/persistence/dynamo/cases/getOpenCasesByUser.js +++ b/shared/src/persistence/dynamo/cases/getOpenCasesByUser.js @@ -1,5 +1,7 @@ -const { Case } = require('../../../business/entities/cases/Case'); -const { getCasesByUser } = require('./getCasesByUser'); +const { + CASE_STATUS_TYPES, +} = require('../../../business/entities/EntityConstants'); +const { getUserCases } = require('./getUserCases'); /** * getOpenCasesByUserId @@ -10,10 +12,10 @@ const { getCasesByUser } = require('./getCasesByUser'); * @returns {object} the open cases */ exports.getOpenCasesByUser = async ({ applicationContext, userId }) => { - const userCases = await getCasesByUser({ applicationContext, userId }); + const userCases = await getUserCases({ applicationContext, userId }); const openCases = userCases.filter( - x => x.status !== Case.STATUS_TYPES.closed, + x => x.status !== CASE_STATUS_TYPES.closed, ); return openCases; diff --git a/shared/src/persistence/dynamo/cases/getOpenCasesByUser.test.js b/shared/src/persistence/dynamo/cases/getOpenCasesByUser.test.js index 186ab55d862..9320f915597 100644 --- a/shared/src/persistence/dynamo/cases/getOpenCasesByUser.test.js +++ b/shared/src/persistence/dynamo/cases/getOpenCasesByUser.test.js @@ -2,9 +2,10 @@ const { applicationContext, } = require('../../../business/test/createTestApplicationContext'); const { getOpenCasesByUser } = require('./getOpenCasesByUser'); -const { User } = require('../../../business/entities/User'); -jest.mock('./getCasesByUser', () => ({ - getCasesByUser: jest.fn().mockReturnValue([ +const { ROLES } = require('../../../business/entities/EntityConstants'); + +jest.mock('./getUserCases', () => ({ + getUserCases: jest.fn().mockReturnValue([ { caseId: '123', pk: 'case|123', @@ -21,7 +22,7 @@ jest.mock('./getCasesByUser', () => ({ })); const user = { - role: User.ROLES.petitioner, + role: ROLES.petitioner, userId: '522573b0-dc40-47f7-96fd-64758da315f5', }; diff --git a/shared/src/persistence/dynamo/cases/getUserDashboardCases.js b/shared/src/persistence/dynamo/cases/getUserCases.js similarity index 86% rename from shared/src/persistence/dynamo/cases/getUserDashboardCases.js rename to shared/src/persistence/dynamo/cases/getUserCases.js index 94355c88713..33a53e13e1d 100644 --- a/shared/src/persistence/dynamo/cases/getUserDashboardCases.js +++ b/shared/src/persistence/dynamo/cases/getUserCases.js @@ -1,7 +1,7 @@ const client = require('../../dynamodbClientService'); const { stripInternalKeys } = require('../helpers/stripInternalKeys'); -exports.getUserDashboardCases = async ({ applicationContext, userId }) => { +exports.getUserCases = async ({ applicationContext, userId }) => { const userCases = await client.query({ ExpressionAttributeNames: { '#pk': 'pk', diff --git a/shared/src/persistence/dynamo/cases/getUserDashboardCases.test.js b/shared/src/persistence/dynamo/cases/getUserCases.test.js similarity index 71% rename from shared/src/persistence/dynamo/cases/getUserDashboardCases.test.js rename to shared/src/persistence/dynamo/cases/getUserCases.test.js index bf3ffda6b98..f9fe5924a87 100644 --- a/shared/src/persistence/dynamo/cases/getUserDashboardCases.test.js +++ b/shared/src/persistence/dynamo/cases/getUserCases.test.js @@ -1,6 +1,6 @@ -const client = require('../../../../../shared/src/persistence/dynamodbClientService'); -const { getUserDashboardCases } = require('./getUserDashboardCases'); -const { User } = require('../../../business/entities/User'); +const client = require('../../dynamodbClientService'); +const { getUserCases } = require('./getUserCases'); +const { ROLES } = require('../../../business/entities/EntityConstants'); const { applicationContext, @@ -17,11 +17,11 @@ applicationContext.getDocumentClient.mockReturnValue({ }); const user = { - role: User.ROLES.petitioner, + role: ROLES.petitioner, userId: '522573b0-dc40-47f7-96fd-64758da315f5', }; -describe('getUserDashboardCases', () => { +describe('getUserCases', () => { beforeEach(() => { client.query = jest.fn().mockReturnValueOnce([ { @@ -35,7 +35,7 @@ describe('getUserDashboardCases', () => { }); it('should return data with stripped internal keys from persistence', async () => { - const result = await getUserDashboardCases({ + const result = await getUserCases({ applicationContext, user, }); diff --git a/shared/src/persistence/dynamo/cases/updateCase.js b/shared/src/persistence/dynamo/cases/updateCase.js index 309e561b2ba..81e57ade36b 100644 --- a/shared/src/persistence/dynamo/cases/updateCase.js +++ b/shared/src/persistence/dynamo/cases/updateCase.js @@ -261,7 +261,7 @@ exports.updateCase = async ({ applicationContext, caseToUpdate }) => { caseCaption: caseToUpdate.caseCaption, docketNumberSuffix: caseToUpdate.docketNumberSuffix, docketNumberWithSuffix: caseToUpdate.docketNumberWithSuffix, - gsi1pk: caseToUpdate.caseId, + gsi1pk: `user-case|${caseToUpdate.caseId}`, leadCaseId: caseToUpdate.leadCaseId, status: caseToUpdate.status, }, diff --git a/shared/src/persistence/dynamo/cases/updateCase.test.js b/shared/src/persistence/dynamo/cases/updateCase.test.js index 620480cca55..9ed92669ec5 100644 --- a/shared/src/persistence/dynamo/cases/updateCase.test.js +++ b/shared/src/persistence/dynamo/cases/updateCase.test.js @@ -2,7 +2,9 @@ const client = require('../../dynamodbClientService'); const { applicationContext, } = require('../../../business/test/createTestApplicationContext'); -const { Case } = require('../../../business/entities/cases/Case'); +const { + CASE_STATUS_TYPES, +} = require('../../../business/entities/EntityConstants'); const { updateCase } = require('./updateCase'); describe('updateCase', () => { @@ -16,17 +18,17 @@ describe('updateCase', () => { inProgress: false, pk: 'case|123', sk: 'case|123', - status: Case.STATUS_TYPES.generalDocket, + status: CASE_STATUS_TYPES.generalDocket, }, ]; secondQueryStub = [ { gsi1pk: 'user-case|123', - leadCaseId: 'case|123', + leadCaseId: '123', pk: 'user|123', sk: 'case|123', - status: Case.STATUS_TYPES.generalDocket, + status: CASE_STATUS_TYPES.generalDocket, }, ]; @@ -76,7 +78,7 @@ describe('updateCase', () => { caseId: '123', docketNumber: '101-18', docketNumberSuffix: null, - status: Case.STATUS_TYPES.generalDocket, + status: CASE_STATUS_TYPES.generalDocket, userId: 'petitioner', }, }); @@ -99,7 +101,7 @@ describe('updateCase', () => { docketNumber: '101-18', docketNumberSuffix: 'W', inProgress: true, - status: Case.STATUS_TYPES.calendared, + status: CASE_STATUS_TYPES.calendared, trialDate: '2019-03-01T21:40:46.415Z', userId: 'petitioner', }, @@ -115,7 +117,7 @@ describe('updateCase', () => { applicationContext.getDocumentClient().update.mock.calls[0][0], ).toMatchObject({ ExpressionAttributeValues: { - ':caseStatus': Case.STATUS_TYPES.calendared, + ':caseStatus': CASE_STATUS_TYPES.calendared, }, }); expect( @@ -162,7 +164,7 @@ describe('updateCase', () => { associatedJudge: 'Judge Buch', caseId: '123', docketNumberSuffix: null, - status: Case.STATUS_TYPES.generalDocket, + status: CASE_STATUS_TYPES.generalDocket, }, }); @@ -181,7 +183,7 @@ describe('updateCase', () => { caseToUpdate: { caseId: '123', docketNumberSuffix: null, - status: Case.STATUS_TYPES.generalDocket, + status: CASE_STATUS_TYPES.generalDocket, }, }); @@ -204,7 +206,7 @@ describe('updateCase', () => { irsPractitioners: [ { name: 'Guy Fieri', userId: 'user-id-existing-234' }, ], - status: Case.STATUS_TYPES.generalDocket, + status: CASE_STATUS_TYPES.generalDocket, }, }); @@ -235,7 +237,7 @@ describe('updateCase', () => { { name: 'Guy Fieri', userId: 'user-id-existing-123' }, { name: 'Rachel Ray', userId: 'user-id-existing-234' }, ], - status: Case.STATUS_TYPES.generalDocket, + status: CASE_STATUS_TYPES.generalDocket, }, }); @@ -279,7 +281,7 @@ describe('updateCase', () => { }, { name: 'Rachel Ray', userId: 'user-id-existing-234' }, ], - status: Case.STATUS_TYPES.generalDocket, + status: CASE_STATUS_TYPES.generalDocket, }, }); expect( @@ -321,7 +323,7 @@ describe('updateCase', () => { userId: 'user-id-existing-234', }, ], - status: Case.STATUS_TYPES.generalDocket, + status: CASE_STATUS_TYPES.generalDocket, }, }); @@ -348,7 +350,7 @@ describe('updateCase', () => { privatePractitioners: [ { name: 'Guy Fieri', userId: 'user-id-existing-234' }, ], - status: Case.STATUS_TYPES.generalDocket, + status: CASE_STATUS_TYPES.generalDocket, }, }); @@ -381,7 +383,7 @@ describe('updateCase', () => { { name: 'Guy Fieri', userId: 'user-id-existing-123' }, { name: 'Rachel Ray', userId: 'user-id-existing-234' }, ], - status: Case.STATUS_TYPES.generalDocket, + status: CASE_STATUS_TYPES.generalDocket, }, }); @@ -414,7 +416,7 @@ describe('updateCase', () => { }, { name: 'Rachel Ray', userId: 'user-id-existing-234' }, ], - status: Case.STATUS_TYPES.generalDocket, + status: CASE_STATUS_TYPES.generalDocket, }, }); @@ -443,7 +445,7 @@ describe('updateCase', () => { privatePractitioners: [ { name: 'Rachel Ray', userId: 'user-id-existing-234' }, ], - status: Case.STATUS_TYPES.generalDocket, + status: CASE_STATUS_TYPES.generalDocket, }, }); @@ -480,7 +482,7 @@ describe('updateCase', () => { docketNumber: '101-18', docketNumberSuffix: null, inProgress: true, - status: Case.STATUS_TYPES.calendared, + status: CASE_STATUS_TYPES.calendared, trialDate: '2019-03-01T21:40:46.415Z', userId: 'petitioner', }, @@ -489,10 +491,10 @@ describe('updateCase', () => { expect( applicationContext.getDocumentClient().put.mock.calls[0][0].Item, ).toMatchObject({ - gsi1pk: '123', + gsi1pk: 'user-case|123', pk: 'user|123', sk: 'case|123', - status: Case.STATUS_TYPES.calendared, + status: CASE_STATUS_TYPES.calendared, }); }); @@ -505,7 +507,7 @@ describe('updateCase', () => { docketNumber: '101-18', docketNumberSuffix: 'W', inProgress: true, - status: Case.STATUS_TYPES.generalDocket, + status: CASE_STATUS_TYPES.generalDocket, trialDate: '2019-03-01T21:40:46.415Z', userId: 'petitioner', }, @@ -515,7 +517,7 @@ describe('updateCase', () => { applicationContext.getDocumentClient().put.mock.calls[0][0].Item, ).toMatchObject({ docketNumberSuffix: 'W', - gsi1pk: '123', + gsi1pk: 'user-case|123', pk: 'user|123', sk: 'case|123', }); @@ -531,7 +533,7 @@ describe('updateCase', () => { docketNumber: '101-18', docketNumberSuffix: null, inProgress: true, - status: Case.STATUS_TYPES.generalDocket, + status: CASE_STATUS_TYPES.generalDocket, trialDate: '2019-03-01T21:40:46.415Z', userId: 'petitioner', }, @@ -541,7 +543,7 @@ describe('updateCase', () => { applicationContext.getDocumentClient().put.mock.calls[0][0].Item, ).toMatchObject({ caseCaption: 'Guy Fieri, Petitioner', - gsi1pk: '123', + gsi1pk: 'user-case|123', pk: 'user|123', sk: 'case|123', }); @@ -557,7 +559,7 @@ describe('updateCase', () => { docketNumberSuffix: null, inProgress: true, leadCaseId: 'case|321', - status: Case.STATUS_TYPES.generalDocket, + status: CASE_STATUS_TYPES.generalDocket, trialDate: '2019-03-01T21:40:46.415Z', userId: 'petitioner', }, @@ -566,7 +568,7 @@ describe('updateCase', () => { expect( applicationContext.getDocumentClient().put.mock.calls[0][0].Item, ).toMatchObject({ - gsi1pk: '123', + gsi1pk: 'user-case|123', leadCaseId: 'case|321', pk: 'user|123', sk: 'case|123', diff --git a/shared/src/persistence/dynamo/elasticsearch/getElasticsearchReindexRecords.js b/shared/src/persistence/dynamo/elasticsearch/getElasticsearchReindexRecords.js index e90426bad44..a7757e81ccb 100644 --- a/shared/src/persistence/dynamo/elasticsearch/getElasticsearchReindexRecords.js +++ b/shared/src/persistence/dynamo/elasticsearch/getElasticsearchReindexRecords.js @@ -3,8 +3,9 @@ const client = require('../../dynamodbClientService'); /** * getElasticsearchReindexRecords * - * @param {object} providers the providers object - * @param {object} providers.applicationContext the application context + * @param {object} arguments deconstructed arguments + * @param {object} arguments.applicationContext the application context + * @returns {Promise} resolved with query results */ exports.getElasticsearchReindexRecords = async ({ applicationContext }) => { return await client.query({ diff --git a/shared/src/persistence/dynamo/elasticsearch/getRecord.js b/shared/src/persistence/dynamo/elasticsearch/getRecord.js index 672fc4955d6..b0a0e5af152 100644 --- a/shared/src/persistence/dynamo/elasticsearch/getRecord.js +++ b/shared/src/persistence/dynamo/elasticsearch/getRecord.js @@ -3,10 +3,11 @@ const client = require('../../dynamodbClientService'); /** * getRecord - get a generic record from dynamo to index in elasticsearch * - * @param {object} providers the providers object - * @param {object} providers.applicationContext the application context - * @param {object} providers.recordPk the pk of the record to get - * @param {object} providers.recordSk the sk of the record to get + * @param {object} arguments deconstructed arguments + * @param {object} arguments.applicationContext the application context + * @param {string} arguments.recordPk the pk of the record to get + * @param {string} arguments.recordSk the sk of the record to get + * @returns {Promise} resolves with result of query */ exports.getRecord = async ({ applicationContext, recordPk, recordSk }) => { return await client.get({ diff --git a/shared/src/persistence/dynamo/messages/createCaseMessage.js b/shared/src/persistence/dynamo/messages/createCaseMessage.js new file mode 100644 index 00000000000..94f3cea8d47 --- /dev/null +++ b/shared/src/persistence/dynamo/messages/createCaseMessage.js @@ -0,0 +1,21 @@ +const { put } = require('../../dynamodbClientService'); + +/** + * createCaseMessage + * + * @param {object} providers the providers object + * @param {object} providers.applicationContext the application context + * @param {object} providers.caseMessage the case message data + * @returns {object} the created case message + */ +exports.createCaseMessage = async ({ applicationContext, caseMessage }) => { + await put({ + Item: { + gsi1pk: `message|${caseMessage.messageId}`, + pk: `case|${caseMessage.caseId}`, + sk: `message|${caseMessage.messageId}`, + ...caseMessage, + }, + applicationContext, + }); +}; diff --git a/shared/src/persistence/dynamo/messages/createCaseMessage.test.js b/shared/src/persistence/dynamo/messages/createCaseMessage.test.js new file mode 100644 index 00000000000..a5845b9c066 --- /dev/null +++ b/shared/src/persistence/dynamo/messages/createCaseMessage.test.js @@ -0,0 +1,46 @@ +const { + applicationContext, +} = require('../../../business/test/createTestApplicationContext'); +const { createCaseMessage } = require('./createCaseMessage'); + +const mockCaseMessage = { + caseId: 'b3f09a45-b27c-4383-acc1-2ab1f99e6725', + createdAt: '2019-03-01T21:40:46.415Z', + from: 'Test Petitionsclerk', + fromSection: 'petitions', + fromUserId: '4791e892-14ee-4ab1-8468-0c942ec379d2', + message: 'hey there', + messageId: 'a10d6855-f3ee-4c11-861c-c7f11cba4dff', + subject: 'hello', + to: 'Test Petitionsclerk2', + toSection: 'petitions', + toUserId: '449b916e-3362-4a5d-bf56-b2b94ba29c12', +}; + +describe('createCaseMessage', () => { + beforeAll(() => { + applicationContext.environment.stage = 'dev'; + applicationContext.getDocumentClient().put.mockReturnValue({ + promise: () => Promise.resolve(null), + }); + }); + + it('attempts to persist the case message record', async () => { + await createCaseMessage({ + applicationContext, + caseMessage: mockCaseMessage, + }); + + expect( + applicationContext.getDocumentClient().put.mock.calls.length, + ).toEqual(1); + expect( + applicationContext.getDocumentClient().put.mock.calls[0][0].Item, + ).toMatchObject({ + gsi1pk: `message|${mockCaseMessage.messageId}`, + pk: `case|${mockCaseMessage.caseId}`, + sk: `message|${mockCaseMessage.messageId}`, + ...mockCaseMessage, + }); + }); +}); diff --git a/shared/src/persistence/dynamo/messages/getCaseMessageById.js b/shared/src/persistence/dynamo/messages/getCaseMessageById.js new file mode 100644 index 00000000000..2fd2f0aa99d --- /dev/null +++ b/shared/src/persistence/dynamo/messages/getCaseMessageById.js @@ -0,0 +1,25 @@ +const { query } = require('../../dynamodbClientService'); + +/** + * getCaseMessageById + * + * @param {object} providers the providers object + * @param {object} providers.applicationContext the application context + * @param {string} providers.messageId the message id + * @returns {object} the created case message + */ +exports.getCaseMessageById = async ({ applicationContext, messageId }) => { + const messages = await query({ + ExpressionAttributeNames: { + '#gsi1pk': 'gsi1pk', + }, + ExpressionAttributeValues: { + ':gsi1pk': `message|${messageId}`, + }, + IndexName: 'gsi1', + KeyConditionExpression: '#gsi1pk = :gsi1pk', + applicationContext, + }); + + return messages[0]; +}; diff --git a/shared/src/persistence/dynamo/messages/getCaseMessageById.test.js b/shared/src/persistence/dynamo/messages/getCaseMessageById.test.js new file mode 100644 index 00000000000..2976dd980f0 --- /dev/null +++ b/shared/src/persistence/dynamo/messages/getCaseMessageById.test.js @@ -0,0 +1,36 @@ +const { + applicationContext, +} = require('../../../business/test/createTestApplicationContext'); +const { getCaseMessageById } = require('./getCaseMessageById'); + +const mockCaseMessage = { + caseId: 'b3f09a45-b27c-4383-acc1-2ab1f99e6725', + createdAt: '2019-03-01T21:40:46.415Z', + from: 'Test Petitionsclerk', + fromSection: 'petitions', + fromUserId: '4791e892-14ee-4ab1-8468-0c942ec379d2', + message: 'hey there', + messageId: 'a10d6855-f3ee-4c11-861c-c7f11cba4dff', + subject: 'hello', + to: 'Test Petitionsclerk2', + toSection: 'petitions', + toUserId: '449b916e-3362-4a5d-bf56-b2b94ba29c12', +}; + +describe('getCaseMessageById', () => { + beforeAll(() => { + applicationContext.environment.stage = 'dev'; + applicationContext.getDocumentClient().query.mockReturnValue({ + promise: () => Promise.resolve({ Items: [mockCaseMessage] }), + }); + }); + + it('retrieves the case message from persistence', async () => { + const retrievedMessage = await getCaseMessageById({ + applicationContext, + messageId: mockCaseMessage.messageId, + }); + + expect(retrievedMessage).toEqual(mockCaseMessage); + }); +}); diff --git a/shared/src/persistence/dynamo/users/createPractitionerUser.js b/shared/src/persistence/dynamo/users/createPractitionerUser.js index 236f3a824f4..86a721d8902 100644 --- a/shared/src/persistence/dynamo/users/createPractitionerUser.js +++ b/shared/src/persistence/dynamo/users/createPractitionerUser.js @@ -1,5 +1,5 @@ const client = require('../../dynamodbClientService'); -const { User } = require('../../../business/entities/User'); +const { ROLES } = require('../../../business/entities/EntityConstants'); exports.createUserRecords = async ({ applicationContext, user, userId }) => { delete user.password; @@ -53,11 +53,7 @@ exports.createUserRecords = async ({ applicationContext, user, userId }) => { exports.createPractitionerUser = async ({ applicationContext, user }) => { let userId = applicationContext.getUniqueId(); - if ( - ![User.ROLES.privatePractitioner, User.ROLES.irsPractitioner].includes( - user.role, - ) - ) { + if (![ROLES.privatePractitioner, ROLES.irsPractitioner].includes(user.role)) { throw new Error( 'Practitioner users must have either private or IRS practitioner role', ); diff --git a/shared/src/persistence/dynamo/users/createPractitionerUser.test.js b/shared/src/persistence/dynamo/users/createPractitionerUser.test.js index 163f6842e07..ca9d0ac619e 100644 --- a/shared/src/persistence/dynamo/users/createPractitionerUser.test.js +++ b/shared/src/persistence/dynamo/users/createPractitionerUser.test.js @@ -5,14 +5,14 @@ const { createPractitionerUser, createUserRecords, } = require('./createPractitionerUser'); -const { User } = require('../../../business/entities/User'); +const { ROLES } = require('../../../business/entities/EntityConstants'); const userId = '9b52c605-edba-41d7-b045-d5f992a499d3'; const privatePractitionerUser = { barNumber: 'pt1234', //intentionally lower case - should be converted to upper case when persisted name: 'Test Private Practitioner', - role: User.ROLES.privatePractitioner, + role: ROLES.privatePractitioner, section: 'privatePractitioner', }; @@ -20,14 +20,14 @@ const privatePractitionerUserWithSection = { barNumber: 'pt1234', email: 'test@example.com', name: 'Test Private Practitioner', - role: User.ROLES.privatePractitioner, + role: ROLES.privatePractitioner, section: 'privatePractitioner', }; const privatePractitionerUserWithoutBarNumber = { barNumber: '', name: 'Test Private Practitioner', - role: User.ROLES.privatePractitioner, + role: ROLES.privatePractitioner, section: 'privatePractitioner', }; @@ -35,7 +35,7 @@ const otherUser = { barNumber: 'pt1234', email: 'test@example.com', name: 'Test Other', - role: User.ROLES.other, + role: ROLES.other, section: 'other', }; diff --git a/shared/src/persistence/dynamo/users/createUser.js b/shared/src/persistence/dynamo/users/createUser.js index 610bd5778a7..5225b0901be 100644 --- a/shared/src/persistence/dynamo/users/createUser.js +++ b/shared/src/persistence/dynamo/users/createUser.js @@ -1,5 +1,5 @@ const client = require('../../dynamodbClientService'); -const { User } = require('../../../business/entities/User'); +const { ROLES } = require('../../../business/entities/EntityConstants'); exports.createUserRecords = async ({ applicationContext, user, userId }) => { delete user.password; @@ -17,7 +17,7 @@ exports.createUserRecords = async ({ applicationContext, user, userId }) => { applicationContext, }); - if (user.role === User.ROLES.judge) { + if (user.role === ROLES.judge) { await client.put({ Item: { pk: 'section|judge', @@ -39,8 +39,8 @@ exports.createUserRecords = async ({ applicationContext, user, userId }) => { }); if ( - (user.role === User.ROLES.privatePractitioner || - user.role === User.ROLES.irsPractitioner) && + (user.role === ROLES.privatePractitioner || + user.role === ROLES.irsPractitioner) && user.name && user.barNumber ) { @@ -70,7 +70,7 @@ exports.createUserRecords = async ({ applicationContext, user, userId }) => { exports.createUser = async ({ applicationContext, user }) => { let userId; let userPoolId = - user.role === User.ROLES.irsSuperuser + user.role === ROLES.irsSuperuser ? process.env.USER_POOL_IRS_ID : process.env.USER_POOL_ID; diff --git a/shared/src/persistence/dynamo/users/createUser.test.js b/shared/src/persistence/dynamo/users/createUser.test.js index d771b928d3f..87fff5f0345 100644 --- a/shared/src/persistence/dynamo/users/createUser.test.js +++ b/shared/src/persistence/dynamo/users/createUser.test.js @@ -2,27 +2,27 @@ const { applicationContext, } = require('../../../business/test/createTestApplicationContext'); const { createUser, createUserRecords } = require('./createUser'); -const { User } = require('../../../business/entities/User'); +const { ROLES } = require('../../../business/entities/EntityConstants'); const userId = '9b52c605-edba-41d7-b045-d5f992a499d3'; const petitionsClerkUser = { name: 'Test Petitionsclerk', - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, section: 'petitions', }; const privatePractitionerUser = { barNumber: 'pt1234', //intentionally lower case - should be converted to upper case when persisted name: 'Test Private Practitioner', - role: User.ROLES.privatePractitioner, + role: ROLES.privatePractitioner, section: 'privatePractitioner', }; const privatePractitionerUserWithoutBarNumber = { barNumber: '', name: 'Test Private Practitioner', - role: User.ROLES.privatePractitioner, + role: ROLES.privatePractitioner, section: 'privatePractitioner', }; @@ -56,7 +56,7 @@ describe('createUser', () => { it('should call adminCreateUser', async () => { const petitionsclerkUser = { name: 'Test Petitionsclerk', - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, section: 'petitions', }; @@ -166,7 +166,7 @@ describe('createUser', () => { it('attempts to persist a judge user with a section mapping record for the chambers and the judge', async () => { const judgeUser = { name: 'Judge Adam', - role: User.ROLES.judge, + role: ROLES.judge, section: 'adamsChambers', }; @@ -319,7 +319,7 @@ describe('createUser', () => { it('does not persist section mapping record if user does not have a section', async () => { const privatePractitionerUserWithoutSection = { name: 'Test Private Practitioner', - role: User.ROLES.privatePractitioner, + role: ROLES.privatePractitioner, }; await createUserRecords({ diff --git a/shared/src/persistence/dynamo/users/getInternalUsers.js b/shared/src/persistence/dynamo/users/getInternalUsers.js index 09333c80766..8768c31689c 100644 --- a/shared/src/persistence/dynamo/users/getInternalUsers.js +++ b/shared/src/persistence/dynamo/users/getInternalUsers.js @@ -2,7 +2,7 @@ const { ADC_SECTION, DOCKET_SECTION, PETITIONS_SECTION, -} = require('../../../business/entities/WorkQueue'); +} = require('../../../business/entities/EntityConstants'); const { getUsersInSection } = require('./getUsersInSection'); exports.getInternalUsers = async ({ applicationContext }) => { diff --git a/shared/src/persistence/dynamo/users/getPractitionerByBarNumber.test.js b/shared/src/persistence/dynamo/users/getPractitionerByBarNumber.test.js index b58cbb5cb7e..9076e2fc009 100644 --- a/shared/src/persistence/dynamo/users/getPractitionerByBarNumber.test.js +++ b/shared/src/persistence/dynamo/users/getPractitionerByBarNumber.test.js @@ -2,7 +2,7 @@ const client = require('../../../../../shared/src/persistence/dynamodbClientServ const { applicationContext, } = require('../../../business/test/createTestApplicationContext'); -const { User } = require('../../../business/entities/User'); +const { ROLES } = require('../../../business/entities/EntityConstants'); const { getPractitionerByBarNumber } = require('./getPractitionerByBarNumber'); @@ -11,7 +11,7 @@ describe('getPractitionerByBarNumber', () => { barNumber: 'PT1234', name: 'Test Practitioner', pk: 'user|9805d1ab-18d0-43ec-bafb-654e83405416', - role: User.ROLES.privatePractitioner, + role: ROLES.privatePractitioner, section: 'privatePractitioner', sk: '9805d1ab-18d0-43ec-bafb-654e83405416', userId: '9805d1ab-18d0-43ec-bafb-654e83405416', @@ -21,7 +21,7 @@ describe('getPractitionerByBarNumber', () => { barNumber: 'PI5678', name: 'IRS Practitioner', pk: 'user|0105d1ab-18d0-43ec-bafb-654e83405416', - role: User.ROLES.irsPractitioner, + role: ROLES.irsPractitioner, section: 'irsPractitioner', sk: '0105d1ab-18d0-43ec-bafb-654e83405416', userId: '0105d1ab-18d0-43ec-bafb-654e83405416', @@ -31,7 +31,7 @@ describe('getPractitionerByBarNumber', () => { barNumber: 'PI9999', name: 'Inactive Practitioner', pk: 'user|be4274f0-c525-45bc-8378-9f30fd841571', - role: User.ROLES.inactivePractitioner, + role: ROLES.inactivePractitioner, section: 'inactivePractitioner', sk: 'be4274f0-c525-45bc-8378-9f30fd841571', userId: 'be4274f0-c525-45bc-8378-9f30fd841571', diff --git a/shared/src/persistence/dynamo/users/getUsersBySearchKey.test.js b/shared/src/persistence/dynamo/users/getUsersBySearchKey.test.js index c6981b49798..27826381892 100644 --- a/shared/src/persistence/dynamo/users/getUsersBySearchKey.test.js +++ b/shared/src/persistence/dynamo/users/getUsersBySearchKey.test.js @@ -1,6 +1,6 @@ const client = require('../../../../../shared/src/persistence/dynamodbClientService'); const { getUsersBySearchKey } = require('./getUsersBySearchKey'); -const { User } = require('../../../business/entities/User'); +const { ROLES } = require('../../../business/entities/EntityConstants'); const { applicationContext, @@ -13,7 +13,7 @@ describe('getUsersBySearchKey', () => { barNumber: 'PT1234', name: 'Test Practitioner', pk: 'user|9805d1ab-18d0-43ec-bafb-654e83405416', - role: User.ROLES.privatePractitioner, + role: ROLES.privatePractitioner, section: 'privatePractitioner', sk: '9805d1ab-18d0-43ec-bafb-654e83405416', userId: '9805d1ab-18d0-43ec-bafb-654e83405416', @@ -38,7 +38,7 @@ describe('getUsersBySearchKey', () => { barNumber: 'PT1234', name: 'Test Practitioner', pk: 'user|9805d1ab-18d0-43ec-bafb-654e83405416', - role: User.ROLES.privatePractitioner, + role: ROLES.privatePractitioner, section: 'privatePractitioner', sk: '9805d1ab-18d0-43ec-bafb-654e83405416', userId: '9805d1ab-18d0-43ec-bafb-654e83405416', diff --git a/shared/src/persistence/dynamo/users/updatePractitionerUser.test.js b/shared/src/persistence/dynamo/users/updatePractitionerUser.test.js index 7fe57521bd0..422692375cc 100644 --- a/shared/src/persistence/dynamo/users/updatePractitionerUser.test.js +++ b/shared/src/persistence/dynamo/users/updatePractitionerUser.test.js @@ -5,7 +5,7 @@ const { updatePractitionerUser, updateUserRecords, } = require('./updatePractitionerUser'); -const { User } = require('../../../business/entities/User'); +const { ROLES } = require('../../../business/entities/EntityConstants'); const userId = '9b52c605-edba-41d7-b045-d5f992a499d3'; @@ -14,13 +14,13 @@ describe('updatePractitionerUser', () => { const oldUser = { barNumber: 'PT1234', name: 'Test Private Practitioner', - role: User.ROLES.privatePractitioner, + role: ROLES.privatePractitioner, section: 'privatePractitioner', }; const updatedUser = { barNumber: 'PT1234', name: 'Test Private Practitioner', - role: User.ROLES.inactivePractitioner, + role: ROLES.inactivePractitioner, section: 'inactivePractitioner', }; @@ -99,7 +99,7 @@ describe('updatePractitionerUser', () => { Item: { barNumber: 'PT1234', name: 'Test Practitioner', - role: User.ROLES.inactivePractitioner, + role: ROLES.inactivePractitioner, section: 'inactivePractitioner', }, }), @@ -107,7 +107,7 @@ describe('updatePractitionerUser', () => { const updatedUser = { barNumber: 'PT1234', name: 'Test Practitioner', - role: User.ROLES.inactivePractitioner, + role: ROLES.inactivePractitioner, section: 'inactivePractitioner', }; @@ -130,7 +130,7 @@ describe('updatePractitionerUser', () => { Item: { barNumber: 'PT1234', name: 'Test Practitioner', - role: User.ROLES.inactivePractitioner, + role: ROLES.inactivePractitioner, section: 'inactivePractitioner', }, }), @@ -138,7 +138,7 @@ describe('updatePractitionerUser', () => { const updatedUser = { barNumber: 'PT1234', name: 'Test Practitioner', - role: User.ROLES.inactivePractitioner, + role: ROLES.inactivePractitioner, section: 'inactivePractitioner', }; @@ -156,7 +156,7 @@ describe('updatePractitionerUser - with a cognito response', () => { const updatedUser = { barNumber: 'PT1234', name: 'Test Practitioner', - role: User.ROLES.inactivePractitioner, + role: ROLES.inactivePractitioner, section: 'inactivePractitioner', }; diff --git a/shared/src/persistence/dynamo/users/updateUser.test.js b/shared/src/persistence/dynamo/users/updateUser.test.js index 43e3c3e2b90..69e4b0f11f8 100644 --- a/shared/src/persistence/dynamo/users/updateUser.test.js +++ b/shared/src/persistence/dynamo/users/updateUser.test.js @@ -1,14 +1,14 @@ const { applicationContext, } = require('../../../business/test/createTestApplicationContext'); +const { ROLES } = require('../../../business/entities/EntityConstants'); const { updateUser } = require('./updateUser'); -const { User } = require('../../../business/entities/User'); const mockUserId = '9b52c605-edba-41d7-b045-d5f992a499d3'; const mockUser = { name: 'Test User', - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, section: 'petitions', userId: mockUserId, }; diff --git a/shared/src/persistence/dynamsoft/getScannerInterface.test.js b/shared/src/persistence/dynamsoft/getScannerInterface.test.js index 80853557b09..54508bff2e0 100644 --- a/shared/src/persistence/dynamsoft/getScannerInterface.test.js +++ b/shared/src/persistence/dynamsoft/getScannerInterface.test.js @@ -3,7 +3,7 @@ const { } = require('../../business/test/createTestApplicationContext'); const { getScannerInterface } = require('./getScannerInterface'); const { JSDOM } = require('jsdom'); -import { Scan } from '../../business/entities/Scan'; +import { SCAN_MODES } from '../../business/entities/EntityConstants'; describe('getScannerInterface', () => { const jsdom = new JSDOM(''); @@ -22,8 +22,6 @@ describe('getScannerInterface', () => { const mockOpenSource = jest.fn(); const mockRemoveAllImages = jest.fn(); - const { SCAN_MODES } = Scan; - applicationContext.getScannerResourceUri.mockReturnValue('abc'); const DWObject = { diff --git a/shared/src/persistence/elasticsearch/bulkIndexRecords.js b/shared/src/persistence/elasticsearch/bulkIndexRecords.js index 2ba55c32bb5..75cf3bef5b8 100644 --- a/shared/src/persistence/elasticsearch/bulkIndexRecords.js +++ b/shared/src/persistence/elasticsearch/bulkIndexRecords.js @@ -25,8 +25,8 @@ exports.bulkIndexRecords = async ({ applicationContext, records }) => { }); const failedRecords = []; - if (response.body.errors) { - response.body.items.forEach((action, i) => { + if (response.errors) { + response.items.forEach((action, i) => { const operation = Object.keys(action)[0]; if (action[operation].error) { let record = body[i * 2 + 1]; diff --git a/shared/src/persistence/elasticsearch/bulkIndexRecords.test.js b/shared/src/persistence/elasticsearch/bulkIndexRecords.test.js new file mode 100644 index 00000000000..a4136455545 --- /dev/null +++ b/shared/src/persistence/elasticsearch/bulkIndexRecords.test.js @@ -0,0 +1,77 @@ +const { + applicationContext, +} = require('../../business/test/createTestApplicationContext'); +const { bulkIndexRecords } = require('./bulkIndexRecords'); + +describe('bulkIndexRecords', () => { + const newImageRecord = { + caseId: { S: '6f3d97f8-1bdd-4779-a150-c076d08ad8fd' }, + caseStatus: { S: 'New' }, + createdAt: { S: '2020-06-10T15:10:23.553Z' }, + docketNumber: { S: '105-19' }, + docketNumberWithSuffix: { S: '105-19' }, + entityName: { S: 'CaseMessage' }, + from: { S: 'Test Docketclerk' }, + fromSection: { S: 'docket' }, + fromUserId: { S: '1805d1ab-18d0-43ec-bafb-654e83405416' }, + gsi1pk: { S: 'message|2e30ecc2-3818-4855-ad3f-4a3ce8d29767' }, + message: { S: 'D' }, + messageId: { S: '2e30ecc2-3818-4855-ad3f-4a3ce8d29767' }, + pk: { S: 'case|6f3d97f8-1bdd-4779-a150-c076d08ad8fd' }, + sk: { S: 'message|2e30ecc2-3818-4855-ad3f-4a3ce8d29767' }, + subject: { S: 'S' }, + to: { S: 'Test Docketclerk' }, + toSection: { S: 'docket' }, + toUserId: { S: '1805d1ab-18d0-43ec-bafb-654e83405416' }, + }; + + const records = [ + { + dynamodb: { + NewImage: newImageRecord, + }, + }, + ]; + + it('returns no failed records if the bulk call is successful', async () => { + applicationContext.getSearchClient().bulk.mockReturnValue({ + errors: false, + items: [{}], + took: 100, + }); + + const result = await bulkIndexRecords({ + applicationContext, + records: records, + }); + expect(result.failedRecords).toEqual([]); + }); + + it('returns failed records if the bulk call is unsuccessful', async () => { + applicationContext.getSearchClient().bulk.mockReturnValue({ + errors: true, + items: [ + { + index: { + _index: 'efcms-message', + error: { + index: 'efcms-message', + index_uuid: 'aAsFqTI0Tc2W0LCWgPNrOA', + reason: 'document missing', + shard: '0', + type: 'document_missing_exception', + }, + status: 404, + }, + }, + ], + took: 100, + }); + + const result = await bulkIndexRecords({ + applicationContext, + records: records, + }); + expect(result.failedRecords).toEqual([newImageRecord]); + }); +}); diff --git a/shared/src/persistence/elasticsearch/getIndexMappingFields.js b/shared/src/persistence/elasticsearch/getIndexMappingFields.js index b7262bc646c..9cf34f11585 100644 --- a/shared/src/persistence/elasticsearch/getIndexMappingFields.js +++ b/shared/src/persistence/elasticsearch/getIndexMappingFields.js @@ -1,8 +1,8 @@ /** - * @param {object} args deconstructed arguments - * @param {object} args.applicationContext the application context - * @param {string} args.index the index we're querying - * @return {object} the mapping properties of the specified index + * @param {object} arguments deconstructed arguments + * @param {object} arguments.applicationContext the application context + * @param {string} arguments.index the index we're querying + * @returns {object} the mapping properties of the specified index */ exports.getIndexMappingFields = async ({ applicationContext, index }) => { const searchClient = applicationContext.getSearchClient(); diff --git a/shared/src/persistence/elasticsearch/getIndexMappingLimit.js b/shared/src/persistence/elasticsearch/getIndexMappingLimit.js index 79c2ec94869..7ae4e558bc8 100644 --- a/shared/src/persistence/elasticsearch/getIndexMappingLimit.js +++ b/shared/src/persistence/elasticsearch/getIndexMappingLimit.js @@ -2,7 +2,7 @@ * @param {object} params deconstructed arguments * @param {object} params.applicationContext the application context * @param {string} params.index the index we're querying - * @return {string} the limit for the specified index + * @returns {Promise} the limit for the specified index */ exports.getIndexMappingLimit = async ({ applicationContext, index }) => { const searchClient = applicationContext.getSearchClient(); diff --git a/shared/src/persistence/elasticsearch/getIndexNameForRecord.js b/shared/src/persistence/elasticsearch/getIndexNameForRecord.js index 616acfa8a28..bbf533757be 100644 --- a/shared/src/persistence/elasticsearch/getIndexNameForRecord.js +++ b/shared/src/persistence/elasticsearch/getIndexNameForRecord.js @@ -26,6 +26,10 @@ exports.getIndexNameForRecord = record => { index = 'efcms-document'; } else if (isRecordOfType(record, 'User')) { index = 'efcms-user'; + } else if (isRecordOfType(record, 'CaseMessage')) { + index = 'efcms-message'; + } else if (isRecordOfType(record, 'UserCase')) { + index = 'efcms-user-case'; } return index; diff --git a/shared/src/persistence/elasticsearch/getIndexNameForRecord.test.js b/shared/src/persistence/elasticsearch/getIndexNameForRecord.test.js index 8a69246ee06..a70a6e83735 100644 --- a/shared/src/persistence/elasticsearch/getIndexNameForRecord.test.js +++ b/shared/src/persistence/elasticsearch/getIndexNameForRecord.test.js @@ -5,6 +5,7 @@ describe('getIndexNameForRecord', () => { const record = {}; const result = getIndexNameForRecord(record); + expect(result).toEqual(null); }); @@ -16,6 +17,7 @@ describe('getIndexNameForRecord', () => { }; const result = getIndexNameForRecord(record); + expect(result).toEqual('efcms-case'); }); @@ -27,6 +29,7 @@ describe('getIndexNameForRecord', () => { }; const result = getIndexNameForRecord(record); + expect(result).toEqual('efcms-document'); }); @@ -38,6 +41,7 @@ describe('getIndexNameForRecord', () => { }; const result = getIndexNameForRecord(record); + expect(result).toEqual('efcms-user'); }); @@ -49,6 +53,7 @@ describe('getIndexNameForRecord', () => { }; const result = getIndexNameForRecord(record); + expect(result).toEqual('efcms-user'); }); @@ -60,6 +65,7 @@ describe('getIndexNameForRecord', () => { }; const result = getIndexNameForRecord(record); + expect(result).toEqual('efcms-user'); }); @@ -71,6 +77,31 @@ describe('getIndexNameForRecord', () => { }; const result = getIndexNameForRecord(record); + expect(result).toEqual('efcms-user'); }); + + it('returns efcms-message for CaseMessage records', () => { + const record = { + entityName: { + S: 'CaseMessage', + }, + }; + + const result = getIndexNameForRecord(record); + + expect(result).toEqual('efcms-message'); + }); + + it('returns efcms-user-case for UserCase records', () => { + const record = { + entityName: { + S: 'UserCase', + }, + }; + + const result = getIndexNameForRecord(record); + + expect(result).toEqual('efcms-user-case'); + }); }); diff --git a/shared/src/persistence/elasticsearch/getIndexedCasesForUser.js b/shared/src/persistence/elasticsearch/getIndexedCasesForUser.js new file mode 100644 index 00000000000..d0e235ec27a --- /dev/null +++ b/shared/src/persistence/elasticsearch/getIndexedCasesForUser.js @@ -0,0 +1,59 @@ +const { search } = require('./searchClient'); + +/** + * getIndexedCasesForUser + * + * @param {object} providers the providers object + * @param {object} providers.applicationContext the application context + * @param {string} providers.statuses case status to filter by + * @param {string} providers.userId the userId to filter cases by + * @returns {object} the case data + */ +exports.getIndexedCasesForUser = async ({ + applicationContext, + statuses, + userId, +}) => { + const { results } = await search({ + applicationContext, + searchParameters: { + body: { + _source: [ + 'docketNumber', + 'docketNumberWithSuffix', + 'caseCaption', + 'leadCaseId', + 'caseId', + 'createdAt', + 'status', + ], + query: { + bool: { + must: [ + { + match: { + 'pk.S': { operator: 'and', query: `user|${userId}` }, + }, + }, + { match: { 'sk.S': 'case|' } }, + { match: { 'gsi1pk.S': 'user-case|' } }, + { + bool: { + should: statuses.map(status => ({ + match: { + 'status.S': status, + }, + })), + }, + }, + ], + }, + }, + size: 5000, + }, + index: 'efcms-user-case', + }, + }); + + return results; +}; diff --git a/shared/src/persistence/elasticsearch/getIndexedCasesForUser.test.js b/shared/src/persistence/elasticsearch/getIndexedCasesForUser.test.js new file mode 100644 index 00000000000..86c2f88299e --- /dev/null +++ b/shared/src/persistence/elasticsearch/getIndexedCasesForUser.test.js @@ -0,0 +1,70 @@ +const { + applicationContext, +} = require('../../business/test/createTestApplicationContext'); +const { + CASE_STATUS_TYPES, +} = require('../../business/entities/EntityConstants'); +const { getIndexedCasesForUser } = require('./getIndexedCasesForUser'); + +describe('getIndexedCasesForUser', () => { + beforeEach(() => {}); + + it('should search for cases by the userId and statuses provided', async () => { + const mockUserId = '123'; + + await getIndexedCasesForUser({ + applicationContext, + statuses: [ + CASE_STATUS_TYPES.new, + CASE_STATUS_TYPES.jurisdictionRetained, + CASE_STATUS_TYPES.calendared, + ], + userId: mockUserId, + }); + + expect( + applicationContext.getSearchClient().search.mock.calls[0][0].body.query + .bool.must, + ).toMatchObject([ + { + match: { + 'pk.S': { + operator: 'and', + query: `user|${mockUserId}`, + }, + }, + }, + { + match: { + 'sk.S': 'case|', + }, + }, + { + match: { + 'gsi1pk.S': 'user-case|', + }, + }, + { + bool: { + should: [ + { + match: { + 'status.S': CASE_STATUS_TYPES.new, + }, + }, + { + match: { + 'status.S': 'Jurisdiction Retained', + }, + }, + { + match: { + 'status.S': 'Calendared', + }, + }, + ], + }, + }, + ]); + }); +}); diff --git a/shared/src/persistence/elasticsearch/messages/getSectionInboxMessages.js b/shared/src/persistence/elasticsearch/messages/getSectionInboxMessages.js new file mode 100644 index 00000000000..6fe8c0770d2 --- /dev/null +++ b/shared/src/persistence/elasticsearch/messages/getSectionInboxMessages.js @@ -0,0 +1,26 @@ +const { search } = require('../searchClient'); + +exports.getSectionInboxMessages = async ({ applicationContext, section }) => { + const query = { + body: { + query: { + bool: { + must: { + match: { + 'toSection.S': { operator: 'and', query: section }, + }, + }, + }, + }, + size: 5000, + }, + index: 'efcms-message', + }; + + const { results } = await search({ + applicationContext, + searchParameters: query, + }); + + return results; +}; diff --git a/shared/src/persistence/elasticsearch/messages/getSectionInboxMessages.test.js b/shared/src/persistence/elasticsearch/messages/getSectionInboxMessages.test.js new file mode 100644 index 00000000000..b6f8bca6067 --- /dev/null +++ b/shared/src/persistence/elasticsearch/messages/getSectionInboxMessages.test.js @@ -0,0 +1,20 @@ +const { + applicationContext, +} = require('../../../business/test/createTestApplicationContext'); +const { getSectionInboxMessages } = require('./getSectionInboxMessages'); +jest.mock('../searchClient'); +const { search } = require('../searchClient'); + +describe('getSectionInboxMessages', () => { + it('returns results from the search client', async () => { + search.mockReturnValue({ results: ['some', 'matches'], total: 0 }); + + const results = await getSectionInboxMessages({ + applicationContext, + section: 'petitions', + }); + + expect(search).toHaveBeenCalledTimes(1); + expect(results).toMatchObject(['some', 'matches']); + }); +}); diff --git a/shared/src/persistence/elasticsearch/messages/getSectionOutboxMessages.js b/shared/src/persistence/elasticsearch/messages/getSectionOutboxMessages.js new file mode 100644 index 00000000000..6655fb2212e --- /dev/null +++ b/shared/src/persistence/elasticsearch/messages/getSectionOutboxMessages.js @@ -0,0 +1,26 @@ +const { search } = require('../searchClient'); + +exports.getSectionOutboxMessages = async ({ applicationContext, section }) => { + const query = { + body: { + query: { + bool: { + must: { + match: { + 'fromSection.S': { operator: 'and', query: section }, + }, + }, + }, + }, + size: 5000, + }, + index: 'efcms-message', + }; + + const { results } = await search({ + applicationContext, + searchParameters: query, + }); + + return results; +}; diff --git a/shared/src/persistence/elasticsearch/messages/getSectionOutboxMessages.test.js b/shared/src/persistence/elasticsearch/messages/getSectionOutboxMessages.test.js new file mode 100644 index 00000000000..3204b439b8d --- /dev/null +++ b/shared/src/persistence/elasticsearch/messages/getSectionOutboxMessages.test.js @@ -0,0 +1,20 @@ +const { + applicationContext, +} = require('../../../business/test/createTestApplicationContext'); +const { getSectionOutboxMessages } = require('./getSectionOutboxMessages'); +jest.mock('../searchClient'); +const { search } = require('../searchClient'); + +describe('getSectionOutboxMessages', () => { + it('returns results from the search client', async () => { + search.mockReturnValue({ results: ['some', 'matches'], total: 0 }); + + const results = await getSectionOutboxMessages({ + applicationContext, + section: 'petitions', + }); + + expect(search).toHaveBeenCalledTimes(1); + expect(results).toMatchObject(['some', 'matches']); + }); +}); diff --git a/shared/src/persistence/elasticsearch/messages/getUserInboxMessages.js b/shared/src/persistence/elasticsearch/messages/getUserInboxMessages.js new file mode 100644 index 00000000000..1d9e0d925de --- /dev/null +++ b/shared/src/persistence/elasticsearch/messages/getUserInboxMessages.js @@ -0,0 +1,26 @@ +const { search } = require('../searchClient'); + +exports.getUserInboxMessages = async ({ applicationContext, userId }) => { + const query = { + body: { + query: { + bool: { + must: { + match: { + 'toUserId.S': { operator: 'and', query: userId }, + }, + }, + }, + }, + size: 5000, + }, + index: 'efcms-message', + }; + + const { results } = await search({ + applicationContext, + searchParameters: query, + }); + + return results; +}; diff --git a/shared/src/persistence/elasticsearch/messages/getUserInboxMessages.test.js b/shared/src/persistence/elasticsearch/messages/getUserInboxMessages.test.js new file mode 100644 index 00000000000..ef8656addc1 --- /dev/null +++ b/shared/src/persistence/elasticsearch/messages/getUserInboxMessages.test.js @@ -0,0 +1,20 @@ +const { + applicationContext, +} = require('../../../business/test/createTestApplicationContext'); +const { getUserInboxMessages } = require('./getUserInboxMessages'); +jest.mock('../searchClient'); +const { search } = require('../searchClient'); + +describe('getUserInboxMessages', () => { + it('returns results from the search client', async () => { + search.mockReturnValue({ results: ['some', 'matches'], total: 0 }); + + const results = await getUserInboxMessages({ + applicationContext, + userId: 'f5d68c53-af31-484d-803b-da22c4d03357', + }); + + expect(search).toHaveBeenCalledTimes(1); + expect(results).toMatchObject(['some', 'matches']); + }); +}); diff --git a/shared/src/persistence/elasticsearch/messages/getUserOutboxMessages.js b/shared/src/persistence/elasticsearch/messages/getUserOutboxMessages.js new file mode 100644 index 00000000000..d11d9b7bdd4 --- /dev/null +++ b/shared/src/persistence/elasticsearch/messages/getUserOutboxMessages.js @@ -0,0 +1,26 @@ +const { search } = require('../searchClient'); + +exports.getUserOutboxMessages = async ({ applicationContext, userId }) => { + const query = { + body: { + query: { + bool: { + must: { + match: { + 'fromUserId.S': { operator: 'and', query: userId }, + }, + }, + }, + }, + size: 5000, + }, + index: 'efcms-message', + }; + + const { results } = await search({ + applicationContext, + searchParameters: query, + }); + + return results; +}; diff --git a/shared/src/persistence/elasticsearch/messages/getUserOutboxMessages.test.js b/shared/src/persistence/elasticsearch/messages/getUserOutboxMessages.test.js new file mode 100644 index 00000000000..34d004f6280 --- /dev/null +++ b/shared/src/persistence/elasticsearch/messages/getUserOutboxMessages.test.js @@ -0,0 +1,20 @@ +const { + applicationContext, +} = require('../../../business/test/createTestApplicationContext'); +const { getUserOutboxMessages } = require('./getUserOutboxMessages'); +jest.mock('../searchClient'); +const { search } = require('../searchClient'); + +describe('getUserOutboxMessages', () => { + it('returns results from the search client', async () => { + search.mockReturnValue({ results: ['some', 'matches'], total: 0 }); + + const results = await getUserOutboxMessages({ + applicationContext, + userId: '318de3b3-1625-4638-98a3-c67ab1b17be7', + }); + + expect(search).toHaveBeenCalledTimes(1); + expect(results).toMatchObject(['some', 'matches']); + }); +}); diff --git a/shared/src/persistence/s3/getUploadPolicy.js b/shared/src/persistence/s3/getUploadPolicy.js index ed8cc569390..6f1a06a2206 100644 --- a/shared/src/persistence/s3/getUploadPolicy.js +++ b/shared/src/persistence/s3/getUploadPolicy.js @@ -1,5 +1,6 @@ -exports.MAX_FILE_SIZE_MB = 250; // megabytes -exports.MAX_FILE_SIZE_BYTES = exports.MAX_FILE_SIZE_MB * 1024 * 1024; // bytes -> megabytes +const { + MAX_FILE_SIZE_BYTES, +} = require('../../business/entities/EntityConstants'); /** * getUploadPolicy @@ -16,7 +17,7 @@ exports.getUploadPolicy = ({ applicationContext, documentId }) => Conditions: [ ['starts-with', '$key', documentId], ['starts-with', '$Content-Type', ''], - ['content-length-range', 0, exports.MAX_FILE_SIZE_BYTES], + ['content-length-range', 0, MAX_FILE_SIZE_BYTES], ], }, (err, data) => { diff --git a/shared/src/proxies/getOpenCasesProxy.js b/shared/src/proxies/getClosedCasesProxy.js similarity index 68% rename from shared/src/proxies/getOpenCasesProxy.js rename to shared/src/proxies/getClosedCasesProxy.js index d8afe7cfb48..54021128a57 100644 --- a/shared/src/proxies/getOpenCasesProxy.js +++ b/shared/src/proxies/getClosedCasesProxy.js @@ -1,15 +1,15 @@ const { get } = require('./requests'); /** - * getOpenCasesInteractor + * getClosedCasesInteractor * * @param {object} providers the providers object * @param {object} providers.applicationContext the application context * @returns {Promise<*>} the promise of the api call */ -exports.getOpenCasesInteractor = ({ applicationContext }) => { +exports.getClosedCasesInteractor = ({ applicationContext }) => { return get({ applicationContext, - endpoint: '/cases/open-cases', + endpoint: '/cases/closed', }); }; diff --git a/shared/src/proxies/getConsolidatedCasesByUserProxy.js b/shared/src/proxies/getOpenConsolidatedCasesProxy.js similarity index 58% rename from shared/src/proxies/getConsolidatedCasesByUserProxy.js rename to shared/src/proxies/getOpenConsolidatedCasesProxy.js index 475d8f63f37..6e99dd27178 100644 --- a/shared/src/proxies/getConsolidatedCasesByUserProxy.js +++ b/shared/src/proxies/getOpenConsolidatedCasesProxy.js @@ -1,15 +1,15 @@ const { get } = require('./requests'); /** + * getOpenConsolidatedCasesInteractor * * @param {object} providers the providers object * @param {object} providers.applicationContext the application context * @returns {Promise<*>} the promise of the api call */ -exports.getConsolidatedCasesByUserInteractor = ({ applicationContext }) => { - const user = applicationContext.getCurrentUser(); +exports.getOpenConsolidatedCasesInteractor = ({ applicationContext }) => { return get({ applicationContext, - endpoint: `/users/${user.userId}/cases-with-consolidation`, + endpoint: '/cases/open', }); }; diff --git a/shared/src/proxies/messages/createCaseMessageProxy.js b/shared/src/proxies/messages/createCaseMessageProxy.js new file mode 100644 index 00000000000..507ba6c1465 --- /dev/null +++ b/shared/src/proxies/messages/createCaseMessageProxy.js @@ -0,0 +1,36 @@ +const { post } = require('../requests'); + +/** + * createCaseMessageInteractor + * + * @param {object} providers the providers object + * @param {object} providers.applicationContext the application context + * @param {string} providers.caseId the id of the case + * @param {string} providers.message the message text + * @param {string} providers.subject the message subject + * @param {string} providers.toSection the section of the user receiving the message + * @param {string} providers.toUserId the user id of the user receiving the message + * @returns {Promise<*>} the promise of the api call + */ +exports.createCaseMessageInteractor = ({ + applicationContext, + attachments, + caseId, + message, + subject, + toSection, + toUserId, +}) => { + return post({ + applicationContext, + body: { + attachments, + caseId, + message, + subject, + toSection, + toUserId, + }, + endpoint: '/messages/', + }); +}; diff --git a/shared/src/proxies/messages/getCaseMessageProxy.js b/shared/src/proxies/messages/getCaseMessageProxy.js new file mode 100644 index 00000000000..ecc64beff70 --- /dev/null +++ b/shared/src/proxies/messages/getCaseMessageProxy.js @@ -0,0 +1,16 @@ +const { get } = require('../requests'); + +/** + * getCaseMessageInteractor + * + * @param {object} providers the providers object + * @param {object} providers.applicationContext the application context + * @param {string} providers.messageId the message id + * @returns {Promise<*>} the promise of the api call + */ +exports.getCaseMessageInteractor = ({ applicationContext, messageId }) => { + return get({ + applicationContext, + endpoint: `/messages/${messageId}`, + }); +}; diff --git a/shared/src/proxies/messages/getInboxCaseMessagesForSectionProxy.js b/shared/src/proxies/messages/getInboxCaseMessagesForSectionProxy.js new file mode 100644 index 00000000000..04489ee0876 --- /dev/null +++ b/shared/src/proxies/messages/getInboxCaseMessagesForSectionProxy.js @@ -0,0 +1,19 @@ +const { get } = require('../requests'); + +/** + * getInboxCaseMessagesForSectionInteractor + * + * @param {object} providers the providers object + * @param {object} providers.applicationContext the application context + * @param {string} providers.section the section + * @returns {Promise<*>} the promise of the api call + */ +exports.getInboxCaseMessagesForSectionInteractor = ({ + applicationContext, + section, +}) => { + return get({ + applicationContext, + endpoint: `/messages/inbox/section/${section}`, + }); +}; diff --git a/shared/src/proxies/messages/getInboxCaseMessagesForUserProxy.js b/shared/src/proxies/messages/getInboxCaseMessagesForUserProxy.js new file mode 100644 index 00000000000..4f0fcf02708 --- /dev/null +++ b/shared/src/proxies/messages/getInboxCaseMessagesForUserProxy.js @@ -0,0 +1,19 @@ +const { get } = require('../requests'); + +/** + * getInboxCaseMessagesForUserInteractor + * + * @param {object} providers the providers object + * @param {object} providers.applicationContext the application context + * @param {string} providers.userId the user id + * @returns {Promise<*>} the promise of the api call + */ +exports.getInboxCaseMessagesForUserInteractor = ({ + applicationContext, + userId, +}) => { + return get({ + applicationContext, + endpoint: `/messages/inbox/${userId}`, + }); +}; diff --git a/shared/src/proxies/messages/getOutboxCaseMessagesForSectionProxy.js b/shared/src/proxies/messages/getOutboxCaseMessagesForSectionProxy.js new file mode 100644 index 00000000000..7573f7a4a9d --- /dev/null +++ b/shared/src/proxies/messages/getOutboxCaseMessagesForSectionProxy.js @@ -0,0 +1,19 @@ +const { get } = require('../requests'); + +/** + * getOutboxCaseMessagesForSectionInteractor + * + * @param {object} providers the providers object + * @param {object} providers.applicationContext the application context + * @param {string} providers.section the section + * @returns {Promise<*>} the promise of the api call + */ +exports.getOutboxCaseMessagesForSectionInteractor = ({ + applicationContext, + section, +}) => { + return get({ + applicationContext, + endpoint: `/messages/outbox/section/${section}`, + }); +}; diff --git a/shared/src/proxies/messages/getOutboxCaseMessagesForUserProxy.js b/shared/src/proxies/messages/getOutboxCaseMessagesForUserProxy.js new file mode 100644 index 00000000000..e75d75c47c3 --- /dev/null +++ b/shared/src/proxies/messages/getOutboxCaseMessagesForUserProxy.js @@ -0,0 +1,19 @@ +const { get } = require('../requests'); + +/** + * getOutboxCaseMessagesForUserInteractor + * + * @param {object} providers the providers object + * @param {object} providers.applicationContext the application context + * @param {string} providers.userId the user id + * @returns {Promise<*>} the promise of the api call + */ +exports.getOutboxCaseMessagesForUserInteractor = ({ + applicationContext, + userId, +}) => { + return get({ + applicationContext, + endpoint: `/messages/outbox/${userId}`, + }); +}; diff --git a/shared/src/proxies/public/getTodaysOpinionsProxy.js b/shared/src/proxies/public/getTodaysOpinionsProxy.js new file mode 100644 index 00000000000..a7e769f5438 --- /dev/null +++ b/shared/src/proxies/public/getTodaysOpinionsProxy.js @@ -0,0 +1,15 @@ +const { get } = require('../requests'); + +/** + * getTodaysOpinionsProxy + * + * @param {object} providers the providers object + * @param {object} providers.applicationContext the application context + * @returns {Promise<*>} the promise of the api call + */ +exports.getTodaysOpinionsInteractor = ({ applicationContext }) => { + return get({ + applicationContext, + endpoint: '/public-api/todays-opinions', + }); +}; diff --git a/shared/src/test/mockCase.js b/shared/src/test/mockCase.js index 9b089642b36..ad9a59e9f2c 100644 --- a/shared/src/test/mockCase.js +++ b/shared/src/test/mockCase.js @@ -16,6 +16,7 @@ exports.MOCK_CASE = { title: 'Executor', }, correspondence: [], + createdAt: '2018-03-01T21:40:46.415Z', docketNumber: '101-18', docketNumberWithSuffix: '101-18', docketRecord: [ diff --git a/shared/src/tools/court-issued-event-codes.csv b/shared/src/tools/court-issued-event-codes.csv index 6d121e572bf..83de0170276 100644 --- a/shared/src/tools/court-issued-event-codes.csv +++ b/shared/src/tools/court-issued-event-codes.csv @@ -1,17 +1,17 @@ -CODE,DOCKET ENTRY LANGUAGE,Display in Dropdown ,Nonstandard type ,What is this order for? ,Judge's name ,Date,Docket number(s),Trial location (dropdown) ,Concatenated Docket Entry ,Served Stamp -O,ORDER *ANYTHING*,O - Order ,Type A ,[Anything],,,,,[Anything],Served OR Entered and Served -OAJ,ORDER that case is assigned to *JUDGE* . *ANYTHING*,OAJ - Order that case is assigned ,Type B,[Anything],[Judge Name],,,,Order [Judge name] [Anything],Served -OAL,"ORDER that the letter ""L"" is added to the Dkt. No. *ANYTHING*","OAL - Order that the letter ""L"" is added to Docket number ",Type C,,,,[Docket number],,"Order that the letter ""L"" is added to Docket number [Anything]",Served -OAP,ORDER for Amended Petition on *DATE*. *ANY*,OAP - Order for Amended Petition ,Type D,[Anything],,[Date],,,Order for Amended Petition on [Date] [Anything],Served -OAPF,ORDER for Amended Petition and Filing Fee on *DATE*. *ANY*,OAPF - Order for Amended Petition and Filing Fee ,Type D,[Anything],,[Date],,,Order for Amended Petition and Filing Fee on [Date] [Anything],Served -OAR,"ORDER that the letter ""R"" is added to the Dkt. No. *ANYTHING*","OAR - Order that the letter ""R"" is added to the Docket number ",Type C,,,,[Docket number],,"Order that the letter ""R"" is added to the Docket number [Docket number]",Served -OAS,"ORDER that the letter ""S"" is added to the Dkt. No. *ANYTHING*","OAS - Order that the letter ""S"" is added to the Docket number ",Type C,,,,[Docket number],,"Order that the letter ""S"" is added to the Docket number [Docket number]",Served -OASL,"ORDER that the letters ""SL"" are added to the Dkt. No. *ANY*","OASL - Order that the letters ""SL"" are added to the Docket number ",Type C,,,,[Docket number],,"Order that the letters ""SL"" are added to the Docket number [Docket number]",Served -OAW,"ORDER that the letter ""W"" is added to the Dkt. No. *ANYTHING*","OAW - Order that the letter ""W"" is added to the Docket number ",Type C,,,,[Docket number],,"Order that the letter ""W"" is added to the Docket number [Docket number]",Served -OAX,"ORDER that the letter ""X"" is added to the Dkt. No. *ANYTHING*","OAX - Order that the letter ""X"" is added to the Docket number ",Type C,,,,[Docket number],,"Order that the letter ""X"" is added to the Docket number [Docket number]",Served +CODE,DOCKET ENTRY LANGUAGE,Display in Dropdown ,Nonstandard type ,What is this order for? ,Judge's name ,Date,Docket number(s),Trial location (dropdown) ,Concatenated Docket Entry ,Served Stamp +O,ORDER *ANYTHING*,O - Order ,Type A ,[Anything],,,,,[Anything],Served OR Entered and Served +OAJ,ORDER that case is assigned to *JUDGE* . *ANYTHING*,OAJ - Order that case is assigned ,Type B,[Anything],[Judge Name],,,,Order [Judge name] [Anything],Served +OAL,"ORDER that the letter ""L"" is added to the Dkt. No. *ANYTHING*","OAL - Order that the letter ""L"" is added to Docket number ",Type C,,,,[Docket number],,"Order that the letter ""L"" is added to Docket number [Anything]",Served +OAP,ORDER for Amended Petition on *DATE*. *ANY*,OAP - Order for Amended Petition ,Type D,[Anything],,[Date],,,Order for Amended Petition on [Date] [Anything],Served +OAPF,ORDER for Amended Petition and Filing Fee on *DATE*. *ANY*,OAPF - Order for Amended Petition and Filing Fee ,Type D,[Anything],,[Date],,,Order for Amended Petition and Filing Fee on [Date] [Anything],Served +OAR,"ORDER that the letter ""R"" is added to the Dkt. No. *ANYTHING*","OAR - Order that the letter ""R"" is added to the Docket number ",Type C,,,,[Docket number],,"Order that the letter ""R"" is added to the Docket number [Docket number]",Served +OAS,"ORDER that the letter ""S"" is added to the Dkt. No. *ANYTHING*","OAS - Order that the letter ""S"" is added to the Docket number ",Type C,,,,[Docket number],,"Order that the letter ""S"" is added to the Docket number [Docket number]",Served +OASL,"ORDER that the letters ""SL"" are added to the Dkt. No. *ANY*","OASL - Order that the letters ""SL"" are added to the Docket number ",Type C,,,,[Docket number],,"Order that the letters ""SL"" are added to the Docket number [Docket number]",Served +OAW,"ORDER that the letter ""W"" is added to the Dkt. No. *ANYTHING*","OAW - Order that the letter ""W"" is added to the Docket number ",Type C,,,,[Docket number],,"Order that the letter ""W"" is added to the Docket number [Docket number]",Served +OAX,"ORDER that the letter ""X"" is added to the Dkt. No. *ANYTHING*","OAX - Order that the letter ""X"" is added to the Docket number ",Type C,,,,[Docket number],,"Order that the letter ""X"" is added to the Docket number [Docket number]",Served OCA,ORDER that caption of case is amended. *ANYTHING*,OCA - Order that caption of case is amended ,Type A ,[Anything],,,,,Order that caption of case is amended [Anything],Served -OD,"ORDER OF DISMISSAL Entered,, *JUDGE*. *ANYTHING*","OD - Order of Dismissal Entered, ",Type B,[Anything],[Judge name],,,,"Order of Dismissal Entered, [Judge Name] [Anything]",Entered and Served -ODD,"ORDER OF DISMISSAL AND DECISION Entered,, *JUDGE*. *ANYTHING*","ODD - Order of Dismissal and Decision Entered, ",Type B,[Anything],[Judge name],,,,"Order of Dismissal and Decision Entered, [Judge Name] [Anything]",Entered and Served +OD,"ORDER OF DISMISSAL Entered,, *JUDGE*. *ANYTHING*","OD - Order of Dismissal Entered",Type B,[Anything],[Judge name],,,,"Order of Dismissal Entered, [Judge Name] [Anything]",Entered and Served +ODD,"ORDER OF DISMISSAL AND DECISION Entered,, *JUDGE*. *ANYTHING*","ODD - Order of Dismissal and Decision Entered, ",Type B,[Anything],[Judge name],,,,"Order of Dismissal and Decision Entered, [Judge Name] [Anything]",Entered and Served ODL,"ORDER that the letter ""L"" is deleted from the Dkt. No. *ANY*","ODL - Order that the letter ""L"" is deleted from the Docket number ",Type C,,,,[Docket number],,"Order that the letter ""L"" is deleted from the Docket number [Docket number]",Served ODP,"ORDER that the letter ""P"" is deleted from the Dkt. No. *ANYTHING*","ODP - Order that the letter ""P"" is deleted from the Docket number ",Type C,,,,[Docket number],,"Order that the letter ""P"" is deleted from the Docket number [Docket number]",Served ODR,"ORDER that the letter ""R"" is deleted from the Dkt. No. *ANY*","ODR - Order that the letter ""R"" is deleted from the Docket number ",Type C,,,,[Docket number],,"Order that the letter ""R"" is deleted from the Docket number [Docket number]",Served @@ -35,10 +35,10 @@ OSC,ORDER *ANYTHING*,OSC - Order ,Type A ,[Anything],,,,,Order [Anything],Served OSCP,"ORDER petr(s) by *DATE* show cause why ""S"" should not be removed *ANYTHING*","OSCP - Order petr(s) to show cause why ""S"" should not be removed ",Type D,[Anything],,[Date],,,"OSCP - Order petr(s) by [Date] to show cause why ""S"" should not be removed [Anything]",Served OST,ORDER of Service of Transcript (Bench Opinion) *ANYTHING*,OST - Order of Service of Transcript (Bench Opinion),Type A ,[Anything],,,,,Order of Service of Transcript (Bench Opinion) [Anything],Served OSUB,ORDER that case is submitted to *JUDGE*. *ANYTHING*,OSUB - Order that case is submitted,Type B,[Anything],[Judge name],,,,Order that case is submitted to [Judge Name] [Anything],Served -DEC,"DECISION Entered,, *JUDGE* *ANYTHING*","DEC - Decision Entered, ",Type B,[Anything],[Judge name],,,,"Decision Entered, [Judge Name] [Anything]",Entered and Served -OAD,"ORDER AND DECISION Entered,, *ANY* *JUDGE*. *ANYTHING*","OAD - Order and Decision Entered,",Type B,[Anything],[Judge name],,,,"Order and Decision Entered, [Judge Name] [Anything]",Entered and Served -ODJ,"ORDER OF DISMISSAL FOR LACK OF JURISDICTION Entered,, *JUDGE*. *ANYTHING*","ODJ - Order of Dismissal for Lack of Jurisdiction Entered,",Type B,[Anything],[Judge name],,,,"Order of Dismissal for Lack of Jurisdiction Entered, [Judge Name] [Anything]",Entered and Served -SDEC,"STIPULATED DECISION Entered, *JUDGE*. *ANYTHING*","SDEC - Stipulated Decision Entered,",Type B,[Anything],[Judge name],,,,"Stipulated Decision Entered, [Judge Name] [Anything]",Entered and Served +DEC,"DECISION Entered,, *JUDGE* *ANYTHING*","DEC - Decision Entered, ",Type B,[Anything],[Judge name],,,,"Decision Entered, [Judge Name] [Anything]",Entered and Served +OAD,"ORDER AND DECISION Entered,, *ANY* *JUDGE*. *ANYTHING*","OAD - Order and Decision Entered,",Type B,[Anything],[Judge name],,,,"Order and Decision Entered, [Judge Name] [Anything]",Entered and Served +ODJ,"ORDER OF DISMISSAL FOR LACK OF JURISDICTION Entered,, *JUDGE*. *ANYTHING*","ODJ - Order of Dismissal for Lack of Jurisdiction Entered,",Type B,[Anything],[Judge name],,,,"Order of Dismissal for Lack of Jurisdiction Entered, [Judge Name] [Anything]",Entered and Served +SDEC,"STIPULATED DECISION Entered, *JUDGE*. *ANYTHING*","SDEC - Stipulated Decision Entered,",Type B,[Anything],[Judge name],,,,"Stipulated Decision Entered, [Judge Name] [Anything]",Entered and Served MOP ,Memorandum Opinion [judge],MOP - Memorandum Opinion ,Type B,[Anything],[Judge name],,,,Memorandum Opinion [judge], NOT ,Notice [Anything],NOT - Notice ,Type A ,[Anything],,,,,[Anything], SOP ,Summary Opinion [judge],Summary Opinion ,Type B,[Anything],[Judge name],,,,Summary Opinion [judge], @@ -54,4 +54,4 @@ TCOP ,T.C. Opinion [judge] [anything],TCOP - T.C. Opinion,Type B,[Anything],[Jud RTRA ,Revised Transcript of [anything],RTRA - Revised Transcript ,Type A,[Anything],,,,,Revised Transcript of [anything], TRAN,Transcript of [anything],TRAN - Transcript ,Type H,[Anything],,[Date],,,Transcript of [anything] on [date], SPTO,Standing Pre-Trial Order ,SPTO - Standing Pre-Trial Order ,HOLD hold (dependent on if we get to automated logic) ,,,,,,Standing Pre-Trial Order , -MISC,,MISC - Miscellaneous ,Type A,[Anything],,,,,, \ No newline at end of file +MISC,,MISC - Miscellaneous ,Type A,[Anything],,,,,, diff --git a/shared/src/tools/courtIssuedEventCodes.json b/shared/src/tools/courtIssuedEventCodes.json index dd734654ffa..6d0f9f6f919 100644 --- a/shared/src/tools/courtIssuedEventCodes.json +++ b/shared/src/tools/courtIssuedEventCodes.json @@ -67,13 +67,13 @@ }, { "eventCode": "OD", - "documentType": "OD - Order of Dismissal Entered,", + "documentType": "OD - Order of Dismissal Entered", "documentTitle": "Order of Dismissal Entered, [Judge Name] [Anything]", "scenario": "Type B" }, { "eventCode": "ODD", - "documentType": "ODD - Order of Dismissal and Decision Entered,", + "documentType": "ODD - Order of Dismissal and Decision Entered", "documentTitle": "Order of Dismissal and Decision Entered, [Judge Name] [Anything]", "scenario": "Type B" }, diff --git a/shared/src/tools/generateMarkdownSchema.js b/shared/src/tools/generateMarkdownSchema.js index 0591cf922a0..cbfb0ba69ff 100644 --- a/shared/src/tools/generateMarkdownSchema.js +++ b/shared/src/tools/generateMarkdownSchema.js @@ -48,20 +48,36 @@ const { const { getSurvivingSpouseContact, } = require('../business/entities/contacts/SurvivingSpouseContact'); +const { + InitialWorkItemMessage, +} = require('../business/entities/InitialWorkItemMessage'); +const { + OrderWithoutBody, +} = require('../business/entities/orders/OrderWithoutBody'); const { PrivatePractitioner, } = require('../business/entities/PrivatePractitioner'); const { Batch } = require('../business/entities/Batch'); const { Case } = require('../business/entities/cases/Case'); const { CaseDeadline } = require('../business/entities/CaseDeadline'); +const { CaseMessage } = require('../business/entities/CaseMessage'); const { Correspondence } = require('../business/entities/Correspondence'); const { DocketRecord } = require('../business/entities/DocketRecord'); const { Document } = require('../business/entities/Document'); const { ForwardMessage } = require('../business/entities/ForwardMessage'); +const { IrsPractitioner } = require('../business/entities/IrsPractitioner'); +const { Message } = require('../business/entities/Message'); +const { NewCaseMessage } = require('../business/entities/NewCaseMessage'); +const { NewPractitioner } = require('../business/entities/NewPractitioner'); +const { Note } = require('../business/entities/notes/Note'); +const { Order } = require('../business/entities/orders/Order'); const { Practitioner } = require('../business/entities/Practitioner'); const { PublicUser } = require('../business/entities/PublicUser'); +const { Scan } = require('../business/entities/Scan'); const { Statistic } = require('../business/entities/Statistic'); const { User } = require('../business/entities/User'); +const { UserCase } = require('../business/entities/UserCase'); +const { UserCaseNote } = require('../business/entities/notes/UserCaseNote'); const { WorkItem } = require('../business/entities/WorkItem'); const generateMarkdownSchema = (entity, entityName) => { @@ -204,13 +220,25 @@ generateMarkdownSchema( generateMarkdownSchema(Batch, 'Batch'); generateMarkdownSchema(Case, 'Case'); generateMarkdownSchema(CaseDeadline, 'CaseDeadline'); +generateMarkdownSchema(CaseMessage, 'CaseMessage'); generateMarkdownSchema(Correspondence, 'Correspondence'); generateMarkdownSchema(DocketRecord, 'DocketRecord'); generateMarkdownSchema(Document, 'Document'); generateMarkdownSchema(ForwardMessage, 'ForwardMessage'); +generateMarkdownSchema(InitialWorkItemMessage, 'InitialWorkItemMessage'); +generateMarkdownSchema(IrsPractitioner, 'IrsPractitioner'); +generateMarkdownSchema(Message, 'Message'); +generateMarkdownSchema(NewCaseMessage, 'NewCaseMessage'); +generateMarkdownSchema(NewPractitioner, 'NewPractitioner'); +generateMarkdownSchema(Note, 'Note'); +generateMarkdownSchema(Order, 'Order'); +generateMarkdownSchema(OrderWithoutBody, 'OrderWithoutBody'); generateMarkdownSchema(Practitioner, 'Practitioner'); generateMarkdownSchema(PrivatePractitioner, 'PrivatePractitioner'); generateMarkdownSchema(PublicUser, 'PublicUser'); +generateMarkdownSchema(Scan, 'Scan'); generateMarkdownSchema(Statistic, 'Statistic'); generateMarkdownSchema(User, 'User'); +generateMarkdownSchema(UserCase, 'UserCase'); +generateMarkdownSchema(UserCaseNote, 'UserCaseNote'); generateMarkdownSchema(WorkItem, 'WorkItem'); diff --git a/shared/src/tools/validateUser.js b/shared/src/tools/validateUser.js new file mode 100644 index 00000000000..cfaf84d1961 --- /dev/null +++ b/shared/src/tools/validateUser.js @@ -0,0 +1,30 @@ +const { getUniqueId } = require('../sharedAppContext'); +const { User } = require('../business/entities/User'); + +const [ + email, + role, + section, + name, + judgeFullName, + judgeTitle, +] = process.argv.slice(2); + +const user = new User({ + email, + judgeFullName, + judgeTitle, + name, + role, + section, + userId: getUniqueId(), +}); + +if (!user.isValid()) { + console.error( + 'Validation errors: ', + user.getValidationErrors(), + JSON.stringify(user.toRawObject(), null, 2), + ); + process.exit(1); +} diff --git a/shared/src/utilities/JoiValidationDecorator.js b/shared/src/utilities/JoiValidationDecorator.js index 72e567494a3..4af129ffb1b 100644 --- a/shared/src/utilities/JoiValidationDecorator.js +++ b/shared/src/utilities/JoiValidationDecorator.js @@ -1,4 +1,5 @@ const joi = require('@hapi/joi'); +const { InvalidEntityError } = require('../errors/errors'); const { isEmpty } = require('lodash'); /** @@ -67,7 +68,7 @@ function getFormattedValidationErrors(entity) { const keys = Object.keys(entity); const obj = {}; let errors = null; - if (entity && entity.getFormattedValidationErrors) { + if (entity.getFormattedValidationErrors) { errors = getFormattedValidationErrorsHelper(entity); } if (errors) { @@ -133,12 +134,14 @@ exports.joiValidationDecorator = function ( entityConstructor.prototype.validate = function validate() { if (!this.isValid()) { - throw new Error( - `The ${ - entityConstructor.validationName || '' - } entity was invalid ${JSON.stringify( - this.getFormattedValidationErrors(), - )}`, + const ids = Object.entries(this) + .filter(([key, value]) => value && key.endsWith('Id')) + .map(([key, value]) => `${key}: "${value}"`) + .join('; '); + throw new InvalidEntityError( + JSON.stringify(this.getFormattedValidationErrors()), + entityConstructor.validationName, + ids, ); } return this; diff --git a/shared/src/utilities/getAllEventCodes.js b/shared/src/utilities/getAllEventCodes.js index f47fa701080..3f203a21e67 100644 --- a/shared/src/utilities/getAllEventCodes.js +++ b/shared/src/utilities/getAllEventCodes.js @@ -1,7 +1,7 @@ const courtIssuedEventCodes = require('../tools/courtIssuedEventCodes.json'); const documentMapExternal = require('../tools/externalFilingEvents.json'); const documentMapInternal = require('../tools/internalFilingEvents.json'); -const { Document } = require('../business/entities/Document'); +const { EVENT_CODES } = require('../business/entities/EntityConstants'); const eventCodes = []; for (const category in documentMapExternal) { @@ -18,9 +18,7 @@ for (const document of courtIssuedEventCodes) { eventCodes.push(document.eventCode); } -const results = Array.from( - new Set(eventCodes.concat(Document.eventCodes)), -).sort(); +const results = Array.from(new Set(eventCodes.concat(EVENT_CODES))).sort(); exports.getAllEventCodes = () => { return results; diff --git a/web-api/config/custom.yml b/web-api/config/custom.yml index 0fb984433e6..56562260fc5 100644 --- a/web-api/config/custom.yml +++ b/web-api/config/custom.yml @@ -225,6 +225,15 @@ practitioners: <<: *customDomainDefault basePath: 'practitioners' +messages: + <<: *customDefault + serverless-offline: + <<: *serverless-offline-default + port: 3018 + customDomain: + <<: *customDomainDefault + basePath: 'messages' + migrate: <<: *customDefault serverless-offline: diff --git a/web-api/config/environment-variables.yml b/web-api/config/environment-variables.yml index e210eba55d1..f1d72ac40ea 100644 --- a/web-api/config/environment-variables.yml +++ b/web-api/config/environment-variables.yml @@ -7,6 +7,7 @@ ELASTICSEARCH_ENDPOINT: ${self:custom.vars.elasticsearchEndpoint, self:provider. MASTER_REGION: ${self:provider.masterRegion} STAGE: ${self:custom.stage} USER_POOL_ID: ${opt:userPoolId, self:provider.userPoolId} +USER_POOL_IRS_ID: ${opt:userPoolIrsId, self.provider.userPoolIrsId} NODE_ENV: ${self:custom.vars.nodeEnv} EMAIL_SOURCE: noreply@mail.efcms-${opt:stage}.${opt:domain} EMAIL_DOCUMENT_SERVED_TEMPLATE: document_served_${opt:stage} diff --git a/web-api/elasticsearch/elasticsearch-indexes.js b/web-api/elasticsearch/elasticsearch-indexes.js index fc089f05dd5..b2e92767bc2 100644 --- a/web-api/elasticsearch/elasticsearch-indexes.js +++ b/web-api/elasticsearch/elasticsearch-indexes.js @@ -1 +1,7 @@ -exports.elasticsearchIndexes = ['efcms-case', 'efcms-document', 'efcms-user']; +exports.elasticsearchIndexes = [ + 'efcms-case', + 'efcms-document', + 'efcms-user', + 'efcms-message', + 'efcms-user-case', +]; diff --git a/web-api/migrations/00001-statistics.js b/web-api/migrations/00001-statistics.js index 2f4c27624e3..fbabf8014c5 100644 --- a/web-api/migrations/00001-statistics.js +++ b/web-api/migrations/00001-statistics.js @@ -1,4 +1,7 @@ const createApplicationContext = require('../src/applicationContext'); +const { + CASE_TYPES_MAP, +} = require('../../shared/src/business/entities/EntityConstants'); const { Case } = require('../../shared/src/business/entities/cases/Case'); const { isCaseRecord, upGenerator } = require('./utilities'); const { Statistic } = require('../../shared/src/business/entities/Statistic'); @@ -7,7 +10,7 @@ const applicationContext = createApplicationContext({}); const mutateRecord = item => { if ( isCaseRecord(item) && - item.caseType === Case.CASE_TYPES_MAP.deficiency && + item.caseType === CASE_TYPES_MAP.deficiency && item.hasVerifiedIrsNotice === true ) { let { statistics } = item; diff --git a/web-api/migrations/00001-statistics.test.js b/web-api/migrations/00001-statistics.test.js index e1627da106b..22580394ff0 100644 --- a/web-api/migrations/00001-statistics.test.js +++ b/web-api/migrations/00001-statistics.test.js @@ -1,4 +1,6 @@ -const { Case } = require('../../shared/src/business/entities/cases/Case'); +const { + CASE_TYPES_MAP, +} = require('../../shared/src/business/entities/EntityConstants'); const { forAllRecords } = require('./utilities'); const { MOCK_CASE } = require('../../shared/src/test/mockCase'); const { up } = require('./00001-statistics'); @@ -54,7 +56,7 @@ describe('case statistics migration', () => { Items: [ { ...mockCaseWithKeys, - caseType: Case.CASE_TYPES_MAP.cdp, + caseType: CASE_TYPES_MAP.cdp, }, ], }), @@ -71,7 +73,7 @@ describe('case statistics migration', () => { Items: [ { ...mockCaseWithKeys, - caseType: Case.CASE_TYPES_MAP.deficiency, + caseType: CASE_TYPES_MAP.deficiency, hasVerifiedIrsNotice: false, }, ], @@ -89,7 +91,7 @@ describe('case statistics migration', () => { Items: [ { ...mockCaseWithKeys, - caseType: Case.CASE_TYPES_MAP.deficiency, + caseType: CASE_TYPES_MAP.deficiency, hasVerifiedIrsNotice: true, }, ], @@ -117,7 +119,7 @@ describe('case statistics migration', () => { Items: [ { ...mockCaseWithKeys, - caseType: Case.CASE_TYPES_MAP.deficiency, + caseType: CASE_TYPES_MAP.deficiency, hasVerifiedIrsNotice: true, statistics: [], }, @@ -146,7 +148,7 @@ describe('case statistics migration', () => { Items: [ { ...mockCaseWithKeys, - caseType: Case.CASE_TYPES_MAP.deficiency, + caseType: CASE_TYPES_MAP.deficiency, hasVerifiedIrsNotice: true, statistics: [ { @@ -182,7 +184,7 @@ describe('case statistics migration', () => { Items: [ { ...mockCaseWithKeys, - caseType: Case.CASE_TYPES_MAP.deficiency, + caseType: CASE_TYPES_MAP.deficiency, hasVerifiedIrsNotice: true, statistics: [ { diff --git a/web-api/migrations/00002-invalid-statistics.js b/web-api/migrations/00002-invalid-statistics.js new file mode 100644 index 00000000000..8bd6d1165fb --- /dev/null +++ b/web-api/migrations/00002-invalid-statistics.js @@ -0,0 +1,33 @@ +const createApplicationContext = require('../src/applicationContext'); +const { + CASE_TYPES_MAP, +} = require('../../shared/src/business/entities/EntityConstants'); +const { Case } = require('../../shared/src/business/entities/cases/Case'); +const { isCaseRecord, upGenerator } = require('./utilities'); +const applicationContext = createApplicationContext({}); + +const mutateRecord = item => { + let { statistics } = item; + + if ( + isCaseRecord(item) && + (item.caseType !== CASE_TYPES_MAP.deficiency || + item.hasVerifiedIrsNotice !== true) && + statistics && + statistics.length + ) { + const caseEntity = new Case( + { + ...item, + statistics: [], + }, + { applicationContext }, + ) + .validate() + .toRawObject(); + + return { ...item, ...caseEntity }; + } +}; + +module.exports = { mutateRecord, up: upGenerator(mutateRecord) }; diff --git a/web-api/migrations/00002-invalid-statistics.test.js b/web-api/migrations/00002-invalid-statistics.test.js new file mode 100644 index 00000000000..d38aeae35a2 --- /dev/null +++ b/web-api/migrations/00002-invalid-statistics.test.js @@ -0,0 +1,158 @@ +const { + CASE_TYPES_MAP, +} = require('../../shared/src/business/entities/EntityConstants'); +const { forAllRecords } = require('./utilities'); +const { MOCK_CASE } = require('../../shared/src/test/mockCase'); +const { up } = require('./00002-invalid-statistics'); + +describe('invalid statistics migration', () => { + let applicationContext; + let scanStub; + let putStub; + + const mockCaseWithKeys = { + ...MOCK_CASE, + pk: `case|${MOCK_CASE.caseId}`, + sk: `case|${MOCK_CASE.caseId}`, + }; + + beforeEach(() => { + scanStub = jest.fn().mockReturnValue({ + promise: async () => ({ + Items: [mockCaseWithKeys], + }), + }); + + putStub = jest.fn().mockReturnValue({ + promise: async () => ({}), + }); + + applicationContext = { + environment: { + stage: 'dev', + }, + getDocumentClient: () => ({ + put: putStub, + scan: scanStub, + }), + }; + }); + + it('should wipe out any existing statistics if hasVerifiedIrsNotice is false', async () => { + scanStub = jest.fn().mockReturnValue({ + promise: async () => ({ + Items: [ + { + ...mockCaseWithKeys, + caseType: CASE_TYPES_MAP.deficiency, + hasVerifiedIrsNotice: false, + statistics: [ + { + irsDeficiencyAmount: 1, + irsTotalPenalties: 1, + year: '2012', + yearOrPeriod: 'Year', + }, + ], + }, + ], + }), + }); + + await up(applicationContext.getDocumentClient(), '', forAllRecords); + + expect(putStub.mock.calls.length).toBe(1); + expect(putStub.mock.calls[0][0].Item).toMatchObject({ + statistics: [], + }); + }); + + it('should wipe out any existing statistics if case is not a deficiency', async () => { + scanStub = jest.fn().mockReturnValue({ + promise: async () => ({ + Items: [ + { + ...mockCaseWithKeys, + caseType: CASE_TYPES_MAP.cdp, + hasVerifiedIrsNotice: true, + statistics: [ + { + irsDeficiencyAmount: 1, + irsTotalPenalties: 1, + year: '2012', + yearOrPeriod: 'Year', + }, + ], + }, + ], + }), + }); + + await up(applicationContext.getDocumentClient(), '', forAllRecords); + + expect(putStub.mock.calls.length).toBe(1); + expect(putStub.mock.calls[0][0].Item).toMatchObject({ + statistics: [], + }); + }); + + it('should not wipe out any existing statistics if case is not a deficiency and has no statistics', async () => { + scanStub = jest.fn().mockReturnValue({ + promise: async () => ({ + Items: [ + { + ...mockCaseWithKeys, + caseType: CASE_TYPES_MAP.cdp, + hasVerifiedIrsNotice: true, + statistics: [], + }, + ], + }), + }); + + await up(applicationContext.getDocumentClient(), '', forAllRecords); + + expect(putStub.mock.calls.length).toBe(0); + }); + + it('should wipe out any existing statistics if case is not a deficiency, has no verified irs notice, and has no statistics', async () => { + scanStub = jest.fn().mockReturnValue({ + promise: async () => ({ + Items: [ + { + ...mockCaseWithKeys, + caseType: CASE_TYPES_MAP.cdp, + hasVerifiedIrsNotice: false, + statistics: [{ yearOrPeriod: 'Year' }], + }, + ], + }), + }); + + await up(applicationContext.getDocumentClient(), '', forAllRecords); + + expect(putStub.mock.calls.length).toBe(1); + expect(putStub.mock.calls[0][0].Item).toMatchObject({ + statistics: [], + }); + }); + + it('should not wipe out any existing statistics if deficiency case hasVerifiedIrsNotice is false and has no statistics', async () => { + scanStub = jest.fn().mockReturnValue({ + promise: async () => ({ + Items: [ + { + ...mockCaseWithKeys, + caseType: CASE_TYPES_MAP.deficiency, + hasVerifiedIrsNotice: false, + statistics: [], + }, + ], + }), + }); + + await up(applicationContext.getDocumentClient(), '', forAllRecords); + + expect(putStub.mock.calls.length).toBe(0); + }); +}); diff --git a/web-api/migrations/00003-user-case-mapping.js b/web-api/migrations/00003-user-case-mapping.js new file mode 100644 index 00000000000..bde3f73cbb8 --- /dev/null +++ b/web-api/migrations/00003-user-case-mapping.js @@ -0,0 +1,43 @@ +const createApplicationContext = require('../src/applicationContext'); +const { + isNewUserCaseMappingRecord, + isUserCaseMappingRecord, + upGenerator, +} = require('./utilities'); +const { Case } = require('../../shared/src/business/entities/cases/Case'); +const { UserCase } = require('../../shared/src/business/entities/UserCase'); +const applicationContext = createApplicationContext({}); + +const mutateRecord = async (item, documentClient, tableName) => { + const caseId = item.sk.split('|')[1]; + + if (isUserCaseMappingRecord(item) && !isNewUserCaseMappingRecord(item)) { + const mappedCase = await documentClient + .get({ + Key: { + pk: `case|${caseId}`, + sk: `case|${caseId}`, + }, + TableName: tableName, + }) + .promise(); + + if (mappedCase.Item) { + const caseEntity = new Case(mappedCase.Item, { applicationContext }); + const userCaseEntity = new UserCase(caseEntity.validate().toRawObject(), { + applicationContext, + }) + .validate() + .toRawObject(); + + return { + ...item, + ...userCaseEntity, + entityName: 'UserCase', + gsi1pk: `user-case|${caseId}`, + }; + } + } +}; + +module.exports = { mutateRecord, up: upGenerator(mutateRecord) }; diff --git a/web-api/migrations/00003-user-case-mapping.test.js b/web-api/migrations/00003-user-case-mapping.test.js new file mode 100644 index 00000000000..8ba137565df --- /dev/null +++ b/web-api/migrations/00003-user-case-mapping.test.js @@ -0,0 +1,85 @@ +const { forAllRecords } = require('./utilities'); +const { MOCK_CASE } = require('../../shared/src/test/mockCase'); +const { up } = require('./00003-user-case-mapping'); +const { UserCase } = require('../../shared/src/business/entities/UserCase'); + +describe('user case mapping migration', () => { + let documentClient; + let scanStub; + let putStub; + let getStub; + + const mockUserCaseItem = { + pk: 'user|6805d1ab-18d0-43ec-bafb-654e83405416', + sk: `case|${MOCK_CASE.caseId}`, + }; + + const mockUserCaseEntity = new UserCase(MOCK_CASE).validate().toRawObject(); + + const mockNewUserCaseItem = { + gsi1pk: `user-case|${MOCK_CASE.caseId}`, + pk: 'user|6805d1ab-18d0-43ec-bafb-654e83405416', + sk: `case|${MOCK_CASE.caseId}`, + ...mockUserCaseEntity, + }; + + const mockCaseWithKeys = { + ...MOCK_CASE, + pk: `case|${MOCK_CASE.caseId}`, + sk: `case|${MOCK_CASE.caseId}`, + }; + + beforeEach(() => { + scanStub = jest.fn().mockReturnValue({ + promise: async () => ({ + Items: [mockUserCaseItem], + }), + }); + + putStub = jest.fn().mockReturnValue({ + promise: async () => ({}), + }); + + getStub = jest.fn().mockReturnValue({ + promise: async () => ({ + Item: mockCaseWithKeys, + }), + }); + + documentClient = { + get: getStub, + put: putStub, + scan: scanStub, + }; + }); + + it('should not update the item when it is not a user-case record', async () => { + documentClient.scan = jest.fn().mockReturnValue({ + promise: async () => ({ + Items: [mockCaseWithKeys], + }), + }); + + await up(documentClient, '', forAllRecords); + + expect(putStub).not.toHaveBeenCalled(); + }); + + it('should not update the item when its a new user-case record', async () => { + documentClient.scan = jest.fn().mockReturnValue({ + promise: async () => ({ + Items: [mockNewUserCaseItem], + }), + }); + + await up(documentClient, '', forAllRecords); + + expect(putStub).not.toHaveBeenCalled(); + }); + + it('should update the item', async () => { + await up(documentClient, '', forAllRecords); + + expect(putStub.mock.calls.length).toBe(1); + }); +}); diff --git a/web-api/migrations/00004-user-case-status.js b/web-api/migrations/00004-user-case-status.js new file mode 100644 index 00000000000..896130d7c5d --- /dev/null +++ b/web-api/migrations/00004-user-case-status.js @@ -0,0 +1,36 @@ +const createApplicationContext = require('../src/applicationContext'); +const { Case } = require('../../shared/src/business/entities/cases/Case'); +const { isUserCaseMappingRecord, upGenerator } = require('./utilities'); +const { UserCase } = require('../../shared/src/business/entities/UserCase'); +const applicationContext = createApplicationContext({}); + +const mutateRecord = async (item, documentClient, tableName) => { + if (isUserCaseMappingRecord(item) && !item.status) { + const caseId = item.sk.split('|')[1]; + const mappedCase = await documentClient + .get({ + Key: { + pk: `case|${caseId}`, + sk: `case|${caseId}`, + }, + TableName: tableName, + }) + .promise(); + + if (mappedCase.Item) { + const caseEntity = new Case(mappedCase.Item, { applicationContext }); + const userCaseEntity = new UserCase(caseEntity.validate().toRawObject(), { + applicationContext, + }) + .validate() + .toRawObject(); + + return { + ...item, + ...userCaseEntity, + }; + } + } +}; + +module.exports = { mutateRecord, up: upGenerator(mutateRecord) }; diff --git a/web-api/migrations/00004-user-case-status.test.js b/web-api/migrations/00004-user-case-status.test.js new file mode 100644 index 00000000000..62c0151de70 --- /dev/null +++ b/web-api/migrations/00004-user-case-status.test.js @@ -0,0 +1,93 @@ +const { + CASE_STATUS_TYPES, +} = require('../../shared/src/business/entities/EntityConstants'); +const { forAllRecords } = require('./utilities'); +const { MOCK_CASE } = require('../../shared/src/test/mockCase'); +const { up } = require('./00004-user-case-status'); +const { UserCase } = require('../../shared/src/business/entities/UserCase'); + +describe('user case mapping migration', () => { + let documentClient; + let scanStub; + let putStub; + let getStub; + + const mockUserCaseItem = { + pk: 'user|6805d1ab-18d0-43ec-bafb-654e83405416', + sk: `case|${MOCK_CASE.caseId}`, + }; + + const mockUserCaseEntity = new UserCase(MOCK_CASE).validate().toRawObject(); + + const mockNewUserCaseItem = { + gsi1pk: `user-case|${MOCK_CASE.caseId}`, + pk: 'user|6805d1ab-18d0-43ec-bafb-654e83405416', + sk: `case|${MOCK_CASE.caseId}`, + ...mockUserCaseEntity, + }; + + const mockCaseWithKeys = { + ...MOCK_CASE, + pk: `case|${MOCK_CASE.caseId}`, + sk: `case|${MOCK_CASE.caseId}`, + }; + + beforeEach(() => { + scanStub = jest.fn().mockReturnValue({ + promise: async () => ({ + Items: [mockUserCaseItem], + }), + }); + + putStub = jest.fn().mockReturnValue({ + promise: async () => ({}), + }); + + getStub = jest.fn().mockReturnValue({ + promise: async () => ({ + Item: mockCaseWithKeys, + }), + }); + + documentClient = { + get: getStub, + put: putStub, + scan: scanStub, + }; + }); + + it('should not update the item when it is not a user-case record', async () => { + documentClient.scan = jest.fn().mockReturnValue({ + promise: async () => ({ + Items: [mockCaseWithKeys], + }), + }); + + await up(documentClient, '', forAllRecords); + + expect(putStub).not.toHaveBeenCalled(); + }); + + it('should not update the item when it has a status', async () => { + documentClient.scan = jest.fn().mockReturnValue({ + promise: async () => ({ + Items: [ + { + ...mockNewUserCaseItem, + status: CASE_STATUS_TYPES.closed, + }, + ], + }), + }); + + await up(documentClient, '', forAllRecords); + + expect(putStub).not.toHaveBeenCalled(); + }); + + it('should update the item', async () => { + await up(documentClient, '', forAllRecords); + + expect(putStub.mock.calls.length).toBe(1); + }); +}); diff --git a/web-api/migrations/utilities.js b/web-api/migrations/utilities.js index deb8588d25b..f05d05210f0 100644 --- a/web-api/migrations/utilities.js +++ b/web-api/migrations/utilities.js @@ -1,6 +1,10 @@ const isCaseRecord = item => !!item.caseType; const isTrialSessionRecord = item => !!item.caseOrder && !!item.trialSessionId && !!item.maxCases; +const isUserCaseMappingRecord = item => + item.pk.startsWith('user|') && item.sk.startsWith('case|'); +const isNewUserCaseMappingRecord = item => + !!item.gsi1pk && item.gsi1pk.startsWith('user-case|'); const forAllRecords = async (documentClient, tableName, cb) => { let hasMoreResults = true; @@ -48,6 +52,8 @@ const upGenerator = mutateFunction => async ( module.exports = { forAllRecords, isCaseRecord, + isNewUserCaseMappingRecord, isTrialSessionRecord, + isUserCaseMappingRecord, upGenerator, }; diff --git a/web-api/migrations/utilities.test.js b/web-api/migrations/utilities.test.js index f1988aab729..6bac7f70c9e 100644 --- a/web-api/migrations/utilities.test.js +++ b/web-api/migrations/utilities.test.js @@ -1,16 +1,20 @@ +const { + CASE_TYPES_MAP, +} = require('../../shared/src/business/entities/EntityConstants'); const { forAllRecords, isCaseRecord, + isNewUserCaseMappingRecord, isTrialSessionRecord, + isUserCaseMappingRecord, upGenerator, } = require('./utilities'); -const { Case } = require('../../shared/src/business/entities/cases/Case'); describe('utilities', () => { describe('isCaseRecord', () => { it('should return true if the item is a case record', () => { const result = isCaseRecord({ - caseType: Case.CASE_TYPES_MAP.cdp, + caseType: CASE_TYPES_MAP.cdp, }); expect(result).toEqual(true); @@ -38,11 +42,63 @@ describe('utilities', () => { it('should return false if the item is not a trial session record', () => { const result = isTrialSessionRecord({ - caseType: Case.CASE_TYPES_MAP.cdp, + caseType: CASE_TYPES_MAP.cdp, + }); + + expect(result).toEqual(false); + }); + }); + + describe('isUserCaseMappingRecord', () => { + it('should return true if the item is a user case mapping record', () => { + const result = isUserCaseMappingRecord({ + pk: 'user|', + sk: 'case|', + }); + + expect(result).toEqual(true); + }); + + it('should return false if the item is not a user case mapping record (pk,sk = case|)', () => { + const result = isUserCaseMappingRecord({ + pk: 'case|', + sk: 'case|', }); expect(result).toEqual(false); }); + + it('should return false if the item is not a user case mapping record (pk,sk = user|)', () => { + const result = isUserCaseMappingRecord({ + pk: 'user|', + sk: 'user|', + }); + expect(result).toEqual(false); + }); + }); + + describe('isNewUserCaseMappingRecord', () => { + it('should return true if the record is a new user-case mapping record', () => { + const result = isNewUserCaseMappingRecord({ + gsi1pk: 'user-case|', + }); + + expect(result).toEqual(true); + }); + + it('should return false if the record is not a new user-case mapping record', () => { + const result = isNewUserCaseMappingRecord({ + gsi1pk: 'case|', + }); + + expect(result).toEqual(false); + }); + + it('should return false if the record is not a new user-case mapping record (no gsi1pk)', () => { + const result = isNewUserCaseMappingRecord({}); + + expect(result).toEqual(false); + }); }); describe('forAllRecords', () => { @@ -54,11 +110,11 @@ describe('utilities', () => { scannedItems = [ { caseId: 'case-123', - caseType: Case.CASE_TYPES_MAP.cdp, + caseType: CASE_TYPES_MAP.cdp, }, { caseId: 'case-321', - caseType: Case.CASE_TYPES_MAP.deficiency, + caseType: CASE_TYPES_MAP.deficiency, }, ]; @@ -94,11 +150,11 @@ describe('utilities', () => { scannedItems = [ { caseId: 'case-123', - caseType: Case.CASE_TYPES_MAP.cdp, + caseType: CASE_TYPES_MAP.cdp, }, { caseId: 'case-321', - caseType: Case.CASE_TYPES_MAP.deficiency, + caseType: CASE_TYPES_MAP.deficiency, }, ]; diff --git a/web-api/proxy.js b/web-api/proxy.js index 68f18ca6c27..3e32a60293d 100644 --- a/web-api/proxy.js +++ b/web-api/proxy.js @@ -20,6 +20,7 @@ const PROXY_DESTINATIONS = { '/case-parties': `http://${PROXY_HOST}:3014`, '/cases': `http://${PROXY_HOST}:3002`, '/documents': `http://${PROXY_HOST}:3004`, + '/messages': `http://${PROXY_HOST}:3018`, '/migrate': `http://${PROXY_HOST}:3030`, '/notifications': `http://${PROXY_HOST}:3011`, '/practitioners': `http://${PROXY_HOST}:3017`, diff --git a/web-api/run-serverless-messages.sh b/web-api/run-serverless-messages.sh new file mode 100755 index 00000000000..013aac73d54 --- /dev/null +++ b/web-api/run-serverless-messages.sh @@ -0,0 +1,3 @@ +#!/bin/bash -e + +./web-api/run-serverless.sh "${1}" "${2}" "messagesHandlers.js" "serverless-messages.yml" "build:api:messages" diff --git a/web-api/seed-elasticsearch.sh b/web-api/seed-elasticsearch.sh index 5ba100d01ac..b7eaa5796f3 100755 --- a/web-api/seed-elasticsearch.sh +++ b/web-api/seed-elasticsearch.sh @@ -3,4 +3,6 @@ curl -X DELETE "localhost:9200/efcms-case" curl -X DELETE "localhost:9200/efcms-document" curl -X DELETE "localhost:9200/efcms-user" +curl -X DELETE "localhost:9200/efcms-message" +curl -X DELETE "localhost:9200/efcms-user-case" ELASTICSEARCH_PORT=9200 ELASTICSEARCH_PROTOCOL="http" node ./web-api/elasticsearch/elasticsearch-index-settings.js diff --git a/web-api/serverless-cases.yml b/web-api/serverless-cases.yml index 78200ae4d97..564c939e108 100644 --- a/web-api/serverless-cases.yml +++ b/web-api/serverless-cases.yml @@ -111,11 +111,22 @@ functions: arn: arn:aws:lambda:${opt:region}:${opt:accountId}:function:cognito_authorizer_lambda_${opt:stage} managedExternally: true - getOpenCases: - handler: web-api/${self:provider.dir}/casesHandlers.getOpenCasesLambda + getOpenConsolidatedCases: + handler: web-api/${self:provider.dir}/casesHandlers.getOpenConsolidatedCasesLambda events: - http: - path: /open-cases + path: /open + method: get + cors: ui-${self:provider.stage}.ef-cms.${opt:domain} + authorizer: + arn: arn:aws:lambda:${opt:region}:${opt:accountId}:function:cognito_authorizer_lambda_${opt:stage} + managedExternally: true + + getClosedCases: + handler: web-api/${self:provider.dir}/casesHandlers.getClosedCasesLambda + events: + - http: + path: /closed method: get cors: ui-${self:provider.stage}.ef-cms.${opt:domain} authorizer: diff --git a/web-api/serverless-messages.yml b/web-api/serverless-messages.yml new file mode 100644 index 00000000000..69d4d746610 --- /dev/null +++ b/web-api/serverless-messages.yml @@ -0,0 +1,121 @@ +service: ef-cms-messages-${opt:stageColor} +plugins: + - serverless-domain-manager + - serverless-offline + - serverless-prune-plugin + - serverless-plugin-tracing + - serverless-latest-layer-version + - serverless-jetpack + - serverless-log-forwarding + +custom: ${file(./web-api/config/custom.yml):messages} + +provider: + name: aws + endpointType: REGIONAL + tracing: true + stage: ${self:custom.stage} + region: ${self:custom.region} + runtime: nodejs12.x + memorySize: 768 + timeout: 30 + logRetentionInDays: 7 + role: arn:aws:iam::${opt:accountId}:role/lambda_role_${opt:stage} + dir: ${opt:run_dir, 'src'} + s3Endpoint: s3.us-east-1.amazonaws.com + dynamodbEndpoint: dynamodb.${opt:region}.amazonaws.com + elasticsearchEndpoint: ${opt:elasticsearch_endpoint} + masterRegion: us-east-1 + userPoolId: us-east-1_7uRkF0Axn + masterDynamodbEndpoint: dynamodb.us-east-1.amazonaws.com + deploymentBucket: + name: ${env:SLS_DEPLOYMENT_BUCKET} + serverSideEncryption: AES256 + apiGateway: + binaryMediaTypes: + - 'application/pdf' + clamavDefDir: /opt/var/lib/clamav + + environment: ${file(./web-api/config/environment-variables.yml)} + +package: + exclude: + - ./** + include: + - web-api/${self:provider.dir}/messagesHandlers.js + excludeDevDependencies: true + +resources: ${file(./web-api/config/resources.yml)} + +functions: + createCaseMessage: + handler: web-api/${self:provider.dir}/messagesHandlers.createCaseMessageLambda + events: + - http: + path: / + method: post + cors: ui-${self:provider.stage}.ef-cms.${opt:domain} + authorizer: + type: COGNITO_USER_POOLS + authorizerId: + Ref: ApiGatewayAuthorizer + + getCaseMessage: + handler: web-api/${self:provider.dir}/messagesHandlers.getCaseMessageLambda + events: + - http: + path: /{messageId} + method: get + cors: ui-${self:provider.stage}.ef-cms.${opt:domain} + authorizer: + type: COGNITO_USER_POOLS + authorizerId: + Ref: ApiGatewayAuthorizer + + getInboxCaseMessagesForUser: + handler: web-api/${self:provider.dir}/messagesHandlers.getInboxCaseMessagesForUserLambda + events: + - http: + path: /inbox/{userId} + method: get + cors: ui-${self:provider.stage}.ef-cms.${opt:domain} + authorizer: + type: COGNITO_USER_POOLS + authorizerId: + Ref: ApiGatewayAuthorizer + + getInboxCaseMessagesForSection: + handler: web-api/${self:provider.dir}/messagesHandlers.getInboxCaseMessagesForSectionLambda + events: + - http: + path: /inbox/section/{section} + method: get + cors: ui-${self:provider.stage}.ef-cms.${opt:domain} + authorizer: + type: COGNITO_USER_POOLS + authorizerId: + Ref: ApiGatewayAuthorizer + + getOutboxCaseMessagesForUser: + handler: web-api/${self:provider.dir}/messagesHandlers.getOutboxCaseMessagesForUserLambda + events: + - http: + path: /outbox/{userId} + method: get + cors: ui-${self:provider.stage}.ef-cms.${opt:domain} + authorizer: + type: COGNITO_USER_POOLS + authorizerId: + Ref: ApiGatewayAuthorizer + + getOutboxCaseMessagesForSection: + handler: web-api/${self:provider.dir}/messagesHandlers.getOutboxCaseMessagesForSectionLambda + events: + - http: + path: /outbox/section/{section} + method: get + cors: ui-${self:provider.stage}.ef-cms.${opt:domain} + authorizer: + type: COGNITO_USER_POOLS + authorizerId: + Ref: ApiGatewayAuthorizer diff --git a/web-api/serverless-public-api.yml b/web-api/serverless-public-api.yml index b381b4055a4..47f457b3dfa 100644 --- a/web-api/serverless-public-api.yml +++ b/web-api/serverless-public-api.yml @@ -116,3 +116,11 @@ functions: path: /opinion-search method: get cors: ui-public-${self:provider.stage}.ef-cms.${opt:domain} + + todaysOpinions: + handler: web-api/${self:provider.dir}/publicApiHandlers.todaysOpinionsLambda + events: + - http: + path: /todays-opinions + method: get + cors: ui-${self:provider.stage}.ef-cms.${opt:domain} diff --git a/web-api/serverless-users.yml b/web-api/serverless-users.yml index fc24452440a..d05ac2789ae 100644 --- a/web-api/serverless-users.yml +++ b/web-api/serverless-users.yml @@ -107,18 +107,6 @@ functions: authorizerId: Ref: ApiGatewayAuthorizer - getConsolidatedCasesByUser: - handler: web-api/${self:provider.dir}/usersHandlers.getConsolidatedCasesByUserLambda - events: - - http: - path: /{userId}/cases-with-consolidation - method: get - cors: ui-${self:provider.stage}.ef-cms.${opt:domain} - authorizer: - type: COGNITO_USER_POOLS - authorizerId: - Ref: ApiGatewayAuthorizer - verifyPendingCaseForUser: handler: web-api/${self:provider.dir}/usersHandlers.verifyPendingCaseForUserLambda events: diff --git a/web-api/setup-court-users.sh b/web-api/setup-court-users.sh index 027974d2672..331a692dd87 100755 --- a/web-api/setup-court-users.sh +++ b/web-api/setup-court-users.sh @@ -42,6 +42,8 @@ createAccount() { judgeFullName=$5 judgeTitle=$6 + node ../shared/src/tools/validateUser.js "${email}" "${role}" "${section}" "${name}" "${judgeFullName}" "${judgeTitle}" + curl --header "Content-Type: application/json" \ --header "Authorization: Bearer ${adminToken}" \ --request POST \ diff --git a/web-api/src/applicationContext.js b/web-api/src/applicationContext.js index 96f5a3d211d..5b211bf5b25 100644 --- a/web-api/src/applicationContext.js +++ b/web-api/src/applicationContext.js @@ -7,13 +7,11 @@ const AWS = ? AWSXRay.captureAWS(require('aws-sdk')) : require('aws-sdk'); -const { getUniqueId } = require('../../shared/src/sharedAppContext.js'); - const barNumberGenerator = require('../../shared/src/persistence/dynamo/users/barNumberGenerator'); const connectionClass = require('http-aws-es'); const docketNumberGenerator = require('../../shared/src/persistence/dynamo/cases/docketNumberGenerator'); const elasticsearch = require('elasticsearch'); -const elasticsearchIndexes = require('../elasticsearch/elasticsearch-indexes'); +const pdfLib = require('pdf-lib'); const util = require('util'); const { addCaseToTrialSessionInteractor, @@ -31,8 +29,10 @@ const { addressLabelCoverSheet, caseInventoryReport, changeOfAddress, + coverSheet, docketRecord, noticeOfDocketChange, + noticeOfReceiptOfPetition, order, pendingReport, receiptOfFiling, @@ -77,6 +77,10 @@ const { const { bulkIndexRecords, } = require('../../shared/src/persistence/elasticsearch/bulkIndexRecords'); +const { + CASE_STATUS_TYPES, + SESSION_STATUS_GROUPS, +} = require('../../shared/src/business/entities/EntityConstants'); const { caseAdvancedSearch, } = require('../../shared/src/persistence/elasticsearch/caseAdvancedSearch'); @@ -128,6 +132,12 @@ const { const { createCaseInteractor, } = require('../../shared/src/business/useCases/createCaseInteractor'); +const { + createCaseMessage, +} = require('../../shared/src/persistence/dynamo/messages/createCaseMessage'); +const { + createCaseMessageInteractor, +} = require('../../shared/src/business/useCases/messages/createCaseMessageInteractor'); const { createCaseTrialSortMappingRecords, } = require('../../shared/src/persistence/dynamo/cases/createCaseTrialSortMappingRecords'); @@ -239,6 +249,9 @@ const { const { deleteWorkItemFromSection, } = require('../../shared/src/persistence/dynamo/workitems/deleteWorkItemFromSection'); +const { + elasticsearchIndexes, +} = require('../elasticsearch/elasticsearch-indexes'); const { fetchPendingItems, } = require('../../shared/src/business/useCaseHelper/pendingItems/fetchPendingItems'); @@ -269,15 +282,15 @@ const { const { fileExternalDocumentInteractor, } = require('../../shared/src/business/useCases/externalDocument/fileExternalDocumentInteractor'); +const { + formatAndSortConsolidatedCases, +} = require('../../shared/src/business/useCaseHelper/consolidatedCases/formatAndSortConsolidatedCases'); const { formatJudgeName, } = require('../../shared/src/business/utilities/getFormattedJudgeName'); const { forwardWorkItemInteractor, } = require('../../shared/src/business/useCases/workitems/forwardWorkItemInteractor'); -const { - generateCaseConfirmationPdf, -} = require('../../shared/src/business/useCaseHelper/caseConfirmation/generateCaseConfirmationPdf'); const { generateCaseInventoryReportPdf, } = require('../../shared/src/business/useCaseHelper/caseInventoryReport/generateCaseInventoryReportPdf'); @@ -361,6 +374,12 @@ const { const { getCaseInventoryReportInteractor, } = require('../../shared/src/business/useCases/caseInventoryReport/getCaseInventoryReportInteractor'); +const { + getCaseMessageById, +} = require('../../shared/src/persistence/dynamo/messages/getCaseMessageById'); +const { + getCaseMessageInteractor, +} = require('../../shared/src/business/useCases/messages/getCaseMessageInteractor'); const { getCasesByCaseIds, } = require('../../shared/src/persistence/dynamo/cases/getCasesByCaseIds'); @@ -376,12 +395,18 @@ const { const { getChromiumBrowser, } = require('../../shared/src/business/utilities/getChromiumBrowser'); +const { + getClosedCasesByUser, +} = require('../../shared/src/persistence/dynamo/cases/getClosedCasesByUser'); +const { + getClosedCasesInteractor, +} = require('../../shared/src/business/useCases/getClosedCasesInteractor'); const { getConsolidatedCasesByCaseInteractor, } = require('../../shared/src/business/useCases/getConsolidatedCasesByCaseInteractor'); const { - getConsolidatedCasesByUserInteractor, -} = require('../../shared/src/business/useCases/getConsolidatedCasesByUserInteractor'); + getConsolidatedCasesForLeadCase, +} = require('../../shared/src/business/useCaseHelper/consolidatedCases/getConsolidatedCasesForLeadCase'); const { getDocumentQCInboxForSection, } = require('../../shared/src/persistence/dynamo/workitems/getDocumentQCInboxForSection'); @@ -430,6 +455,12 @@ const { const { getFormattedCaseDetail, } = require('../../shared/src/business/utilities/getFormattedCaseDetail'); +const { + getInboxCaseMessagesForSectionInteractor, +} = require('../../shared/src/business/useCases/messages/getInboxCaseMessagesForSectionInteractor'); +const { + getInboxCaseMessagesForUserInteractor, +} = require('../../shared/src/business/useCases/messages/getInboxCaseMessagesForUserInteractor'); const { getInboxMessagesForSection, } = require('../../shared/src/persistence/dynamo/workitems/getInboxMessagesForSection'); @@ -442,6 +473,9 @@ const { const { getInboxMessagesForUserInteractor, } = require('../../shared/src/business/useCases/workitems/getInboxMessagesForUserInteractor'); +const { + getIndexedCasesForUser, +} = require('../../shared/src/persistence/elasticsearch/getIndexedCasesForUser'); const { getIndexMappingFields, } = require('../../shared/src/persistence/elasticsearch/getIndexMappingFields'); @@ -470,8 +504,14 @@ const { getOpenCasesByUser, } = require('../../shared/src/persistence/dynamo/cases/getOpenCasesByUser'); const { - getOpenCasesInteractor, -} = require('../../shared/src/business/useCases/getOpenCasesInteractor'); + getOpenConsolidatedCasesInteractor, +} = require('../../shared/src/business/useCases/getOpenConsolidatedCasesInteractor'); +const { + getOutboxCaseMessagesForSectionInteractor, +} = require('../../shared/src/business/useCases/messages/getOutboxCaseMessagesForSectionInteractor'); +const { + getOutboxCaseMessagesForUserInteractor, +} = require('../../shared/src/business/useCases/messages/getOutboxCaseMessagesForUserInteractor'); const { getPractitionerByBarNumber, } = require('../../shared/src/persistence/dynamo/users/getPractitionerByBarNumber'); @@ -499,6 +539,12 @@ const { const { getRecord, } = require('../../shared/src/persistence/dynamo/elasticsearch/getRecord'); +const { + getSectionInboxMessages, +} = require('../../shared/src/persistence/elasticsearch/messages/getSectionInboxMessages'); +const { + getSectionOutboxMessages, +} = require('../../shared/src/persistence/elasticsearch/messages/getSectionOutboxMessages'); const { getSentMessagesForSection, } = require('../../shared/src/persistence/dynamo/workitems/getSentMessagesForSection'); @@ -511,6 +557,9 @@ const { const { getSentMessagesForUserInteractor, } = require('../../shared/src/business/useCases/workitems/getSentMessagesForUserInteractor'); +const { + getTodaysOpinionsInteractor, +} = require('../../shared/src/business/useCases/public/getTodaysOpinionsInteractor'); const { getTrialSessionById, } = require('../../shared/src/persistence/dynamo/trialSessions/getTrialSessionById'); @@ -529,6 +578,9 @@ const { const { getTrialSessionWorkingCopyInteractor, } = require('../../shared/src/business/useCases/trialSessions/getTrialSessionWorkingCopyInteractor'); +const { + getUnassociatedLeadCase, +} = require('../../shared/src/business/useCaseHelper/consolidatedCases/getUnassociatedLeadCase'); const { getUploadPolicy, } = require('../../shared/src/persistence/s3/getUploadPolicy'); @@ -554,11 +606,17 @@ const { getUserCaseNoteInteractor, } = require('../../shared/src/business/useCases/caseNote/getUserCaseNoteInteractor'); const { - getUserDashboardCases, -} = require('../../shared/src/persistence/dynamo/cases/getUserDashboardCases'); + getUserCases, +} = require('../../shared/src/persistence/dynamo/cases/getUserCases'); +const { + getUserInboxMessages, +} = require('../../shared/src/persistence/elasticsearch/messages/getUserInboxMessages'); const { getUserInteractor, } = require('../../shared/src/business/useCases/getUserInteractor'); +const { + getUserOutboxMessages, +} = require('../../shared/src/persistence/elasticsearch/messages/getUserOutboxMessages'); const { getUsersBySearchKey, } = require('../../shared/src/persistence/dynamo/users/getUsersBySearchKey'); @@ -611,6 +669,9 @@ const { const { opinionPublicSearchInteractor, } = require('../../shared/src/business/useCases/public/opinionPublicSearchInteractor'); +const { + ORDER_TYPES, +} = require('../../shared/src/business/entities/EntityConstants'); const { orderAdvancedSearchInteractor, } = require('../../shared/src/business/useCases/orderAdvancedSearchInteractor'); @@ -629,6 +690,9 @@ const { const { processStreamRecordsInteractor, } = require('../../shared/src/business/useCases/processStreamRecordsInteractor'); +const { + processUserAssociatedCases, +} = require('../../shared/src/business/useCaseHelper/consolidatedCases/processUserAssociatedCases'); const { putWorkItemInOutbox, } = require('../../shared/src/persistence/dynamo/workitems/putWorkItemInOutbox'); @@ -731,9 +795,6 @@ const { const { submitPendingCaseAssociationRequestInteractor, } = require('../../shared/src/business/useCases/caseAssociationRequest/submitPendingCaseAssociationRequestInteractor'); -const { - TrialSession, -} = require('../../shared/src/business/entities/trialSessions/TrialSession'); const { unblockCaseFromTrialInteractor, } = require('../../shared/src/business/useCases/unblockCaseFromTrialInteractor'); @@ -873,11 +934,8 @@ const { Case } = require('../../shared/src/business/entities/cases/Case'); const { Document } = require('../../shared/src/business/entities/Document'); const { exec } = require('child_process'); const { getDocument } = require('../../shared/src/persistence/s3/getDocument'); -const { Order } = require('../../shared/src/business/entities/orders/Order'); +const { getUniqueId } = require('../../shared/src/sharedAppContext.js'); const { User } = require('../../shared/src/business/entities/User'); - -const pdfLib = require('pdf-lib'); - const { v4: uuidv4 } = require('uuid'); // increase the timeout for zip uploads to S3 @@ -993,8 +1051,11 @@ module.exports = (appContextUser = {}) => { }, getConstants: () => ({ CASE_INVENTORY_MAX_PAGE_SIZE: 5000, - ORDER_TYPES_MAP: Order.ORDER_TYPES, - SESSION_STATUS_GROUPS: TrialSession.SESSION_STATUS_GROUPS, + OPEN_CASE_STATUSES: Object.values(CASE_STATUS_TYPES).filter( + status => status !== CASE_STATUS_TYPES.closed, + ), + ORDER_TYPES_MAP: ORDER_TYPES, + SESSION_STATUS_GROUPS, }), getCurrentUser, getDispatchers: () => ({ @@ -1005,8 +1066,10 @@ module.exports = (appContextUser = {}) => { addressLabelCoverSheet, caseInventoryReport, changeOfAddress, + coverSheet, docketRecord, noticeOfDocketChange, + noticeOfReceiptOfPetition, order, pendingReport, receiptOfFiling, @@ -1102,6 +1165,7 @@ module.exports = (appContextUser = {}) => { createCase, createCaseCatalogRecord, createCaseDeadline, + createCaseMessage, createCaseTrialSortMappingRecords, createElasticsearchReindexRecord, createPractitionerUser, @@ -1135,9 +1199,11 @@ module.exports = (appContextUser = {}) => { getCaseByDocketNumber, getCaseDeadlinesByCaseId, getCaseInventoryReport, + getCaseMessageById, getCasesByCaseIds, getCasesByLeadCaseId, getCasesByUser, + getClosedCasesByUser, getDocument, getDocumentQCInboxForSection, getDocumentQCInboxForUser, @@ -1151,12 +1217,15 @@ module.exports = (appContextUser = {}) => { getInboxMessagesForUser, getIndexMappingFields, getIndexMappingLimit, + getIndexedCasesForUser, getInternalUsers, getOpenCasesByUser, getPractitionerByBarNumber, getPractitionersByName, getPublicDownloadPolicyUrl, getRecord, + getSectionInboxMessages, + getSectionOutboxMessages, getSentMessagesForSection, getSentMessagesForUser, getTrialSessionById, @@ -1166,7 +1235,9 @@ module.exports = (appContextUser = {}) => { getUserById, getUserCaseNote, getUserCaseNoteForCases, - getUserDashboardCases, + getUserCases, + getUserInboxMessages, + getUserOutboxMessages, getUsersBySearchKey, getUsersInSection, getWebSocketConnectionByConnectionId, @@ -1267,9 +1338,12 @@ module.exports = (appContextUser = {}) => { appendPaperServiceAddressPageToPdf, countPagesInDocument, fetchPendingItems, - generateCaseConfirmationPdf, + formatAndSortConsolidatedCases, generateCaseInventoryReportPdf, getCaseInventoryReport, + getConsolidatedCasesForLeadCase, + getUnassociatedLeadCase, + processUserAssociatedCases, saveFileAndGenerateUrl, sendIrsSuperuserPetitionEmail, sendServedPartiesEmails, @@ -1296,6 +1370,7 @@ module.exports = (appContextUser = {}) => { createCaseDeadlineInteractor, createCaseFromPaperInteractor, createCaseInteractor, + createCaseMessageInteractor, createCourtIssuedOrderPdfFromHtmlInteractor, createPractitionerUserInteractor, createTrialSessionInteractor, @@ -1333,15 +1408,18 @@ module.exports = (appContextUser = {}) => { getCaseForPublicDocketSearchInteractor, getCaseInteractor, getCaseInventoryReportInteractor, + getCaseMessageInteractor, getCasesByUserInteractor, + getClosedCasesInteractor, getConsolidatedCasesByCaseInteractor, - getConsolidatedCasesByUserInteractor, getDocumentQCInboxForSectionInteractor, getDocumentQCInboxForUserInteractor, getDocumentQCServedForSectionInteractor, getDocumentQCServedForUserInteractor, getDownloadPolicyUrlInteractor, getEligibleCasesForTrialSessionInteractor, + getInboxCaseMessagesForSectionInteractor, + getInboxCaseMessagesForUserInteractor, getInboxMessagesForSectionInteractor, getInboxMessagesForUserInteractor, getInternalUsersInteractor, @@ -1349,7 +1427,9 @@ module.exports = (appContextUser = {}) => { getJudgeForUserChambersInteractor, getJudgesForPublicSearchInteractor, getNotificationsInteractor, - getOpenCasesInteractor, + getOpenConsolidatedCasesInteractor, + getOutboxCaseMessagesForSectionInteractor, + getOutboxCaseMessagesForUserInteractor, getPractitionerByBarNumberInteractor, getPractitionersByNameInteractor, getPrivatePractitionersBySearchKeyInteractor, @@ -1357,6 +1437,7 @@ module.exports = (appContextUser = {}) => { getPublicDownloadPolicyUrlInteractor, getSentMessagesForSectionInteractor, getSentMessagesForUserInteractor, + getTodaysOpinionsInteractor, getTrialSessionDetailsInteractor, getTrialSessionWorkingCopyInteractor, getTrialSessionsInteractor, @@ -1447,7 +1528,7 @@ module.exports = (appContextUser = {}) => { logger: { error: value => { // eslint-disable-next-line no-console - console.error(JSON.stringify(value)); + console.error(value); }, info: (key, value) => { // eslint-disable-next-line no-console diff --git a/web-api/src/cases/getOpenCasesLambda.js b/web-api/src/cases/getClosedCasesLambda.js similarity index 67% rename from web-api/src/cases/getOpenCasesLambda.js rename to web-api/src/cases/getClosedCasesLambda.js index 02b657a3b3b..d9d8fa10733 100644 --- a/web-api/src/cases/getOpenCasesLambda.js +++ b/web-api/src/cases/getClosedCasesLambda.js @@ -1,14 +1,14 @@ const { genericHandler } = require('../genericHandler'); /** - * used for fetching all open cases + * used for fetching all closed cases * * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -exports.getOpenCasesLambda = event => +exports.getClosedCasesLambda = event => genericHandler(event, async ({ applicationContext }) => { - return await applicationContext.getUseCases().getOpenCasesInteractor({ + return await applicationContext.getUseCases().getClosedCasesInteractor({ applicationContext, }); }); diff --git a/web-api/src/cases/getOpenConsolidatedCasesLambda.js b/web-api/src/cases/getOpenConsolidatedCasesLambda.js new file mode 100644 index 00000000000..719e0e4ab36 --- /dev/null +++ b/web-api/src/cases/getOpenConsolidatedCasesLambda.js @@ -0,0 +1,16 @@ +const { genericHandler } = require('../genericHandler'); + +/** + * used for fetching all open cases + * + * @param {object} event the AWS event object + * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers + */ +exports.getOpenConsolidatedCasesLambda = event => + genericHandler(event, async ({ applicationContext }) => { + return await applicationContext + .getUseCases() + .getOpenConsolidatedCasesInteractor({ + applicationContext, + }); + }); diff --git a/web-api/src/casesHandlers.js b/web-api/src/casesHandlers.js index 7e53011cbaa..f8454a9b029 100644 --- a/web-api/src/casesHandlers.js +++ b/web-api/src/casesHandlers.js @@ -5,9 +5,12 @@ module.exports = { .createCaseFromPaperLambda, createCaseLambda: require('./cases/createCaseLambda').createCaseLambda, getCaseLambda: require('./cases/getCaseLambda').getCaseLambda, + getClosedCasesLambda: require('./cases/getClosedCasesLambda') + .getClosedCasesLambda, getConsolidatedCasesByCaseLambda: require('./cases/getConsolidatedCasesByCaseLambda') .getConsolidatedCasesByCaseLambda, - getOpenCasesLambda: require('./cases/getOpenCasesLambda').getOpenCasesLambda, + getOpenConsolidatedCasesLambda: require('./cases/getOpenConsolidatedCasesLambda') + .getOpenConsolidatedCasesLambda, removeCasePendingItemLambda: require('./cases/removeCasePendingItemLambda') .removeCasePendingItemLambda, saveCaseDetailInternalEditLambda: require('./cases/saveCaseDetailInternalEditLambda') diff --git a/web-api/src/messages/createCaseMessageLambda.js b/web-api/src/messages/createCaseMessageLambda.js new file mode 100644 index 00000000000..66ef3b0c933 --- /dev/null +++ b/web-api/src/messages/createCaseMessageLambda.js @@ -0,0 +1,15 @@ +const { genericHandler } = require('../genericHandler'); + +/** + * lambda which is used for creating a new case message + * + * @param {object} event the AWS event object + * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers + */ +exports.createCaseMessageLambda = event => + genericHandler(event, async ({ applicationContext }) => { + return await applicationContext.getUseCases().createCaseMessageInteractor({ + ...JSON.parse(event.body), + applicationContext, + }); + }); diff --git a/web-api/src/messages/getCaseMessageLambda.js b/web-api/src/messages/getCaseMessageLambda.js new file mode 100644 index 00000000000..60f0f3ef43e --- /dev/null +++ b/web-api/src/messages/getCaseMessageLambda.js @@ -0,0 +1,15 @@ +const { genericHandler } = require('../genericHandler'); + +/** + * lambda which is used for creating a new case message + * + * @param {object} event the AWS event object + * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers + */ +exports.getCaseMessageLambda = event => + genericHandler(event, async ({ applicationContext }) => { + return await applicationContext.getUseCases().getCaseMessageInteractor({ + applicationContext, + messageId: event.pathParameters.messageId, + }); + }); diff --git a/web-api/src/messages/getInboxCaseMessagesForSectionLambda.js b/web-api/src/messages/getInboxCaseMessagesForSectionLambda.js new file mode 100644 index 00000000000..eedd1e8cc8d --- /dev/null +++ b/web-api/src/messages/getInboxCaseMessagesForSectionLambda.js @@ -0,0 +1,17 @@ +const { genericHandler } = require('../genericHandler'); + +/** + * gets the inbox case messages for the section + * + * @param {object} event the AWS event object + * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers + */ +exports.getInboxCaseMessagesForSectionLambda = event => + genericHandler(event, async ({ applicationContext }) => { + return await applicationContext + .getUseCases() + .getInboxCaseMessagesForSectionInteractor({ + applicationContext, + section: event.pathParameters.section, + }); + }); diff --git a/web-api/src/messages/getInboxCaseMessagesForUserLambda.js b/web-api/src/messages/getInboxCaseMessagesForUserLambda.js new file mode 100644 index 00000000000..9e4623c3568 --- /dev/null +++ b/web-api/src/messages/getInboxCaseMessagesForUserLambda.js @@ -0,0 +1,17 @@ +const { genericHandler } = require('../genericHandler'); + +/** + * gets the inbox case messages for the user + * + * @param {object} event the AWS event object + * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers + */ +exports.getInboxCaseMessagesForUserLambda = event => + genericHandler(event, async ({ applicationContext }) => { + return await applicationContext + .getUseCases() + .getInboxCaseMessagesForUserInteractor({ + applicationContext, + userId: event.pathParameters.userId, + }); + }); diff --git a/web-api/src/messages/getOutboxCaseMessagesForSectionLambda.js b/web-api/src/messages/getOutboxCaseMessagesForSectionLambda.js new file mode 100644 index 00000000000..d1ecfd66aef --- /dev/null +++ b/web-api/src/messages/getOutboxCaseMessagesForSectionLambda.js @@ -0,0 +1,17 @@ +const { genericHandler } = require('../genericHandler'); + +/** + * gets the outbox case messages for the section + * + * @param {object} event the AWS event object + * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers + */ +exports.getOutboxCaseMessagesForSectionLambda = event => + genericHandler(event, async ({ applicationContext }) => { + return await applicationContext + .getUseCases() + .getOutboxCaseMessagesForSectionInteractor({ + applicationContext, + section: event.pathParameters.section, + }); + }); diff --git a/web-api/src/messages/getOutboxCaseMessagesForUserLambda.js b/web-api/src/messages/getOutboxCaseMessagesForUserLambda.js new file mode 100644 index 00000000000..cc9d5493829 --- /dev/null +++ b/web-api/src/messages/getOutboxCaseMessagesForUserLambda.js @@ -0,0 +1,17 @@ +const { genericHandler } = require('../genericHandler'); + +/** + * gets the outbox case messages for the user + * + * @param {object} event the AWS event object + * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers + */ +exports.getOutboxCaseMessagesForUserLambda = event => + genericHandler(event, async ({ applicationContext }) => { + return await applicationContext + .getUseCases() + .getOutboxCaseMessagesForUserInteractor({ + applicationContext, + userId: event.pathParameters.userId, + }); + }); diff --git a/web-api/src/messagesHandlers.js b/web-api/src/messagesHandlers.js new file mode 100644 index 00000000000..1925d327f21 --- /dev/null +++ b/web-api/src/messagesHandlers.js @@ -0,0 +1,14 @@ +module.exports = { + createCaseMessageLambda: require('./messages/createCaseMessageLambda') + .createCaseMessageLambda, + getCaseMessageLambda: require('./messages/getCaseMessageLambda') + .getCaseMessageLambda, + getInboxCaseMessagesForSectionLambda: require('./messages/getInboxCaseMessagesForSectionLambda') + .getInboxCaseMessagesForSectionLambda, + getInboxCaseMessagesForUserLambda: require('./messages/getInboxCaseMessagesForUserLambda') + .getInboxCaseMessagesForUserLambda, + getOutboxCaseMessagesForSectionLambda: require('./messages/getOutboxCaseMessagesForSectionLambda') + .getOutboxCaseMessagesForSectionLambda, + getOutboxCaseMessagesForUserLambda: require('./messages/getOutboxCaseMessagesForUserLambda') + .getOutboxCaseMessagesForUserLambda, +}; diff --git a/web-api/src/cases/getConsolidatedCasesByUserLambda.js b/web-api/src/public-api/todaysOpinionsLambda.js similarity index 56% rename from web-api/src/cases/getConsolidatedCasesByUserLambda.js rename to web-api/src/public-api/todaysOpinionsLambda.js index 907435f4cce..895cc519bb2 100644 --- a/web-api/src/cases/getConsolidatedCasesByUserLambda.js +++ b/web-api/src/public-api/todaysOpinionsLambda.js @@ -1,23 +1,23 @@ const { genericHandler } = require('../genericHandler'); /** - * used for fetching all cases (including consolidated) of a particular status, user role, etc + * used for fetching opinions created for the current date * * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -exports.getConsolidatedCasesByUserLambda = event => +exports.todaysOpinionsLambda = event => genericHandler( event, async ({ applicationContext }) => { - const { userId } = event.pathParameters || {}; - return await applicationContext .getUseCases() - .getConsolidatedCasesByUserInteractor({ + .getTodaysOpinionsInteractor({ applicationContext, - userId, }); }, - { logResults: false, skipFiltering: true }, + { + isPublicUser: true, + user: {}, + }, ); diff --git a/web-api/src/publicApiHandlers.js b/web-api/src/publicApiHandlers.js index ce466c97033..e0e5a01e887 100644 --- a/web-api/src/publicApiHandlers.js +++ b/web-api/src/publicApiHandlers.js @@ -15,4 +15,6 @@ module.exports = { .opinionPublicSearchLambda, orderPublicSearchLambda: require('./public-api/orderPublicSearchLambda') .orderPublicSearchLambda, + todaysOpinionsLambda: require('./public-api/todaysOpinionsLambda') + .todaysOpinionsLambda, }; diff --git a/web-api/src/streamsHandlers.js b/web-api/src/streamsHandlers.js index a25f36fbeca..6d71546f2c6 100644 --- a/web-api/src/streamsHandlers.js +++ b/web-api/src/streamsHandlers.js @@ -2,5 +2,5 @@ module.exports = { processStreamRecordsLambda: require('./streams/processStreamRecordsLambda') .processStreamRecordsLambda, reprocessFailedRecordsLambda: require('./streams/reprocessFailedRecordsLambda') - .handler, + .reprocessFailedRecordsLambda, }; diff --git a/web-api/src/usersHandlers.js b/web-api/src/usersHandlers.js index b09294bb4f3..791e0cf4708 100644 --- a/web-api/src/usersHandlers.js +++ b/web-api/src/usersHandlers.js @@ -2,8 +2,6 @@ module.exports = { createUserLambda: require('./users/createUserLambda').createUserLambda, getCasesByUserLambda: require('./cases/getCasesByUserLambda') .getCasesByUserLambda, - getConsolidatedCasesByUserLambda: require('./cases/getConsolidatedCasesByUserLambda') - .getConsolidatedCasesByUserLambda, getDocumentQCInboxForUserLambda: require('./workitems/getDocumentQCInboxForUserLambda') .getDocumentQCInboxForUserLambda, getDocumentQCServedForUserLambda: require('./workitems/getDocumentQCServedForUserLambda') diff --git a/web-api/storage/fixtures/create-random-cases.js b/web-api/storage/fixtures/create-random-cases.js index 21e51d93133..8475a00b48b 100755 --- a/web-api/storage/fixtures/create-random-cases.js +++ b/web-api/storage/fixtures/create-random-cases.js @@ -2,12 +2,11 @@ const axios = require('axios'); const faker = require('faker'); const jwt = require('jsonwebtoken'); const { - ContactFactory, -} = require('../../../shared/src/business/entities/contacts/ContactFactory'); -const { - TrialSession, -} = require('../../../shared/src/business/entities/trialSessions/TrialSession'); -const { Case } = require('../../../shared/src/business/entities/cases/Case'); + CASE_TYPES, + PARTY_TYPES, + PROCEDURE_TYPES, + TRIAL_CITIES, +} = require('../../../shared/src/business/entities/EntityConstants'); const { userMap } = require('../../../shared/src/test/mockUserTokenMap'); const USAGE = ` @@ -42,7 +41,7 @@ const main = () => { for (let i = 0; i < numToCreate; i++) { const preferredTrialCityObject = - TrialSession.TRIAL_CITIES.ALL[faker.random.number() % 74]; + TRIAL_CITIES.ALL[faker.random.number() % 74]; const preferredTrialCity = preferredTrialCityObject.city + ', ' + preferredTrialCityObject.state; @@ -51,7 +50,7 @@ const main = () => { const randomlyGeneratedData = { petitionFileId, petitionMetadata: { - caseType: Case.CASE_TYPES[faker.random.number() % 13], + caseType: CASE_TYPES[faker.random.number() % 13], contactPrimary: { address1: faker.address.streetAddress(), city: faker.address.city(), @@ -73,10 +72,10 @@ const main = () => { countryType: 'domestic', filingType: 'Myself and my spouse', hasIrsNotice: faker.random.boolean(), - partyType: ContactFactory.PARTY_TYPES.petitionerSpouse, + partyType: PARTY_TYPES.petitionerSpouse, preferredTrialCity, privatePractitioners: [], - procedureType: Case.PROCEDURE_TYPES[faker.random.number() % 2], + procedureType: PROCEDURE_TYPES[faker.random.number() % 2], }, stinFileId, }; diff --git a/web-api/storage/fixtures/get-diffs.js b/web-api/storage/fixtures/get-diffs.js index 0b699c7a227..46b330f24da 100755 --- a/web-api/storage/fixtures/get-diffs.js +++ b/web-api/storage/fixtures/get-diffs.js @@ -26,6 +26,11 @@ process.argv.forEach((val, index) => { } }); +/** + * @arg obj1 {object} + * @arg obj2 {object} + * @returns {boolean} if objects are deep-equal + */ function deepEqual(obj1, obj2) { //Loop through properties in object 1 for (let p in obj1) { @@ -36,23 +41,23 @@ function deepEqual(obj1, obj2) { if (obj2[p] === null && obj1[p] !== null) return false; switch (typeof obj1[p]) { - //Deep compare objects - case 'object': - if (!deepEqual(obj1[p], obj2[p])) return false; - break; + //Deep compare objects + case 'object': + if (!deepEqual(obj1[p], obj2[p])) return false; + break; //Compare function code - case 'function': - if ( - typeof obj2[p] == 'undefined' || + case 'function': + if ( + typeof obj2[p] == 'undefined' || (p != 'compare' && obj1[p].toString() != obj2[p].toString()) - ) - return false; - break; + ) + return false; + break; //Compare values - default: - if (obj1[p] === '' && obj2[p] !== '') return false; - if (obj2[p] === '' && obj1[p] !== '') return false; - if (obj1[p] != obj2[p]) return false; + default: + if (obj1[p] === '' && obj2[p] !== '') return false; + if (obj2[p] === '' && obj1[p] !== '') return false; + if (obj1[p] != obj2[p]) return false; } } @@ -91,4 +96,4 @@ const main = () => { console.log(JSON.stringify(differences, null, 2)); }; -main(arguments); +main(); diff --git a/web-api/storage/fixtures/seed/101-19.json b/web-api/storage/fixtures/seed/101-19.json index bbb1d84b43f..dc6b7d118da 100755 --- a/web-api/storage/fixtures/seed/101-19.json +++ b/web-api/storage/fixtures/seed/101-19.json @@ -73,7 +73,8 @@ "caseCaption": "Brett Osborne, Petitioner", "docketNumber": "101-19", "docketNumberWithSuffix": "101-19W", - "status": "New" + "status": "New", + "entityName": "UserCase" }, { "sk": "case|2fa6da8d-4328-4a20-a5d7-b76637e1dc02", diff --git a/web-api/storage/fixtures/seed/102-19.json b/web-api/storage/fixtures/seed/102-19.json index 7cdc3c60554..1e3780dfd83 100755 --- a/web-api/storage/fixtures/seed/102-19.json +++ b/web-api/storage/fixtures/seed/102-19.json @@ -92,7 +92,8 @@ "docketNumber": "102-19", "status": "New", "createdAt": "2019-03-01T21:40:46.415Z", - "caseCaption": "Selma Horn & Cairo Harris, Petitioners" + "caseCaption": "Selma Horn & Cairo Harris, Petitioners", + "entityName": "UserCase" }, { "docketNumberWithSuffix": "102-19P", diff --git a/web-api/storage/fixtures/seed/102-20.json b/web-api/storage/fixtures/seed/102-20.json index c063ca4b36c..f11c13f29d0 100644 --- a/web-api/storage/fixtures/seed/102-20.json +++ b/web-api/storage/fixtures/seed/102-20.json @@ -54,7 +54,8 @@ "caseCaption": "Eve Brewer, Petitioner", "docketNumber": "102-20", "docketNumberWithSuffix": "102-20S", - "status": "New" + "status": "New", + "entityName": "UserCase" }, { "sk": "case|c862926c-119f-49d5-8cc3-6e93ab703fa3", @@ -74,7 +75,8 @@ "caseCaption": "Eve Brewer, Petitioner", "docketNumber": "102-20", "docketNumberWithSuffix": "102-20S", - "status": "New" + "status": "New", + "entityName": "UserCase" }, { "docketNumberWithSuffix": "102-20S", @@ -205,7 +207,8 @@ "caseCaption": "Eve Brewer, Petitioner", "docketNumber": "102-20", "docketNumberWithSuffix": "102-20S", - "status": "New" + "status": "New", + "entityName": "UserCase" }, { "role": "irsPractitioner", diff --git a/web-api/storage/fixtures/seed/103-19.json b/web-api/storage/fixtures/seed/103-19.json index 98946a90399..9aa29b8cfce 100755 --- a/web-api/storage/fixtures/seed/103-19.json +++ b/web-api/storage/fixtures/seed/103-19.json @@ -91,9 +91,10 @@ "caseId": "491b05b4-483f-4b85-8dd7-2dd4c069eb50", "createdAt": "2019-03-01T22:53:50.097Z", "caseCaption": "Samson Workman, Petitioner", - "docketNumber": "102-20", + "docketNumber": "103-19", "docketNumberWithSuffix": "103-19S", - "status": "New" + "status": "New", + "entityName": "UserCase" }, { "sk": "case|491b05b4-483f-4b85-8dd7-2dd4c069eb50", @@ -106,9 +107,10 @@ "caseId": "491b05b4-483f-4b85-8dd7-2dd4c069eb50", "createdAt": "2019-03-01T22:53:50.097Z", "caseCaption": "Samson Workman, Petitioner", - "docketNumber": "102-20", + "docketNumber": "103-19", "docketNumberWithSuffix": "103-19S", - "status": "New" + "status": "New", + "entityName": "UserCase" }, { "sk": "work-item|9055257a-0a95-4b80-a728-5bb754c60e59", diff --git a/web-api/storage/fixtures/seed/103-20.json b/web-api/storage/fixtures/seed/103-20.json index fa2dc351d68..542bb405517 100644 --- a/web-api/storage/fixtures/seed/103-20.json +++ b/web-api/storage/fixtures/seed/103-20.json @@ -235,7 +235,8 @@ "createdAt": "2020-01-23T21:45:34.520Z", "docketNumber": "103-20", "docketNumberWithSuffix": "103-20L", - "status": "Calendared" + "status": "Calendared", + "entityName": "UserCase" }, { "associatedJudge": "Judge Armen", diff --git a/web-api/storage/fixtures/seed/104-19.json b/web-api/storage/fixtures/seed/104-19.json index 9445b2ea0a0..7060664cc82 100755 --- a/web-api/storage/fixtures/seed/104-19.json +++ b/web-api/storage/fixtures/seed/104-19.json @@ -97,7 +97,8 @@ "createdAt": "2019-03-05T17:34:13.490Z", "docketNumber": "104-19", "docketNumberWithSuffix": "104-19L", - "status": "New" + "status": "New", + "entityName": "UserCase" }, { "sk": "case|5f6e8b8e-4fac-4fd7-bf3c-42f0d7c3ca05", diff --git a/web-api/storage/fixtures/seed/104-20.json b/web-api/storage/fixtures/seed/104-20.json index f943fbfd780..bec659be234 100644 --- a/web-api/storage/fixtures/seed/104-20.json +++ b/web-api/storage/fixtures/seed/104-20.json @@ -26,7 +26,7 @@ } ], "attachments": false, - "documentType": "ODD - Order of Dismissal and Decision Entered,", + "documentType": "ODD - Order of Dismissal and Decision Entered", "entityName": "Document", "filingDate": "2020-04-14T03:01:15.215Z", "pending": false, @@ -54,7 +54,7 @@ "docketNumber": "104-20" }, "attachments": false, - "documentType": "ODD - Order of Dismissal and Decision Entered,", + "documentType": "ODD - Order of Dismissal and Decision Entered", "filingDate": "2020-04-14T03:01:15.215Z", "pending": false, "documentContents": "Déjà vu, this is a seed order in case 104-20 filed on Apr 13 at 11:01pm ET\n", @@ -245,7 +245,7 @@ } ], "attachments": false, - "documentType": "ODD - Order of Dismissal and Decision Entered,", + "documentType": "ODD - Order of Dismissal and Decision Entered", "entityName": "Document", "filingDate": "2020-04-14T03:01:15.215Z", "pending": false, @@ -278,7 +278,7 @@ } ], "attachments": false, - "documentType": "ODD - Order of Dismissal and Decision Entered,", + "documentType": "ODD - Order of Dismissal and Decision Entered", "filingDate": "2020-04-14T03:01:15.215Z", "pending": false, "receivedAt": "2020-04-14T03:01:15.215Z", @@ -305,7 +305,7 @@ "docketNumber": "104-20" }, "attachments": false, - "documentType": "ODD - Order of Dismissal and Decision Entered,", + "documentType": "ODD - Order of Dismissal and Decision Entered", "filingDate": "2020-04-14T03:01:15.215Z", "pending": false, "documentContents": "Déjà vu, this is a seed order in case 104-20 filed on Apr 13 at 11:01pm ET\n", diff --git a/web-api/storage/fixtures/seed/105-19.json b/web-api/storage/fixtures/seed/105-19.json index 63309c14ca3..7e502d2384e 100755 --- a/web-api/storage/fixtures/seed/105-19.json +++ b/web-api/storage/fixtures/seed/105-19.json @@ -75,7 +75,8 @@ "createdAt": "2019-03-27T21:53:00.297Z", "docketNumber": "105-19", "docketNumberWithSuffix": "105-19", - "status": "New" + "status": "New", + "entityName": "UserCase" }, { "sk": "case|6f3d97f8-1bdd-4779-a150-c076d08ad8fd", diff --git a/web-api/storage/fixtures/seed/105-20.json b/web-api/storage/fixtures/seed/105-20.json index e720cfda7b5..84969f6031b 100644 --- a/web-api/storage/fixtures/seed/105-20.json +++ b/web-api/storage/fixtures/seed/105-20.json @@ -579,8 +579,9 @@ "caseCaption": "Astra Santiago, Petitioner", "createdAt": "2020-04-29T15:50:41.686Z", "docketNumber": "105-20", - "docketNumberWithSuffix": "105-19L", - "status": "General Docket - Not at Issue" + "docketNumberWithSuffix": "105-20L", + "status": "General Docket - Not at Issue", + "entityName": "UserCase" }, { "sk": "case|28caad58-df69-4a4d-af15-6554aee7fbd6", @@ -594,8 +595,9 @@ "caseCaption": "Astra Santiago, Petitioner", "createdAt": "2020-04-29T15:50:41.686Z", "docketNumber": "105-20", - "docketNumberWithSuffix": "105-19L", - "status": "General Docket - Not at Issue" + "docketNumberWithSuffix": "105-20L", + "status": "General Docket - Not at Issue", + "entityName": "UserCase" }, { "associatedJudge": "Chief Judge", diff --git a/web-api/storage/fixtures/seed/106-19.json b/web-api/storage/fixtures/seed/106-19.json index 45b49735353..fe3ce4670da 100755 --- a/web-api/storage/fixtures/seed/106-19.json +++ b/web-api/storage/fixtures/seed/106-19.json @@ -589,7 +589,8 @@ "caseId": "d3d92ca6-d9b3-4bd6-8328-e94a9fc36f88", "status": "New", "docketNumber": "106-19", - "docketNumberWithSuffix": "106-19" + "docketNumberWithSuffix": "106-19", + "entityName": "UserCase" }, { "docketNumberSuffix": null, diff --git a/web-api/storage/fixtures/seed/107-19.json b/web-api/storage/fixtures/seed/107-19.json index c2553495261..765a79100a8 100644 --- a/web-api/storage/fixtures/seed/107-19.json +++ b/web-api/storage/fixtures/seed/107-19.json @@ -29,7 +29,8 @@ "caseId": "58c1f7a3-8062-42f0-a73e-8bd69b419878", "docketNumber": "107-19", "docketNumberWithSuffix": "107-19L", - "status": "General Docket - At Issue (Ready for Trial)" + "status": "General Docket - At Issue (Ready for Trial)", + "entityName": "UserCase" }, { "sk": "case|58c1f7a3-8062-42f0-a73e-8bd69b419878", @@ -40,7 +41,8 @@ "caseId": "58c1f7a3-8062-42f0-a73e-8bd69b419878", "docketNumber": "107-19", "docketNumberWithSuffix": "107-19L", - "status": "General Docket - At Issue (Ready for Trial)" + "status": "General Docket - At Issue (Ready for Trial)", + "entityName": "UserCase" }, { "completedAt": "2019-08-16T17:30:10.526Z", @@ -272,7 +274,8 @@ "caseId": "58c1f7a3-8062-42f0-a73e-8bd69b419878", "docketNumber": "107-19", "docketNumberWithSuffix": "107-19L", - "status": "General Docket - At Issue (Ready for Trial)" + "status": "General Docket - At Issue (Ready for Trial)", + "entityName": "UserCase" }, { "sk": "case|58c1f7a3-8062-42f0-a73e-8bd69b419878", diff --git a/web-api/storage/fixtures/seed/108-19.json b/web-api/storage/fixtures/seed/108-19.json index 04fe4ca9652..c2166ee71ba 100644 --- a/web-api/storage/fixtures/seed/108-19.json +++ b/web-api/storage/fixtures/seed/108-19.json @@ -229,7 +229,8 @@ "caseId": "46c4064f-b44a-4ac3-9dfb-9ce9f00e43f5", "docketNumber": "108-19", "docketNumberWithSuffix": "108-19", - "status": "Calendared" + "status": "Calendared", + "entityName": "UserCase" }, { "sk": "work-item|ba1c4ce7-6def-4eb8-9ac7-be844ba3a380", diff --git a/web-api/storage/fixtures/seed/111-19.json b/web-api/storage/fixtures/seed/111-19.json index 91e4fb8f54f..0d7a3c8df1d 100644 --- a/web-api/storage/fixtures/seed/111-19.json +++ b/web-api/storage/fixtures/seed/111-19.json @@ -81,7 +81,8 @@ "leadCaseId": "fd8d1139-5e54-4117-9b94-7a69359423c2", "docketNumber": "111-19", "docketNumberWithSuffix": "111-19L", - "status": "Submitted" + "status": "Submitted", + "entityName": "UserCase" }, { "documentType": "Statement of Taxpayer Identification", diff --git a/web-api/storage/fixtures/seed/112-19.json b/web-api/storage/fixtures/seed/112-19.json index 1d454fffe95..ffdf7355462 100644 --- a/web-api/storage/fixtures/seed/112-19.json +++ b/web-api/storage/fixtures/seed/112-19.json @@ -82,7 +82,8 @@ "leadCaseId": "fd8d1139-5e54-4117-9b94-7a69359423c2", "docketNumber": "112-19", "docketNumberWithSuffix": "112-19L", - "status": "Submitted" + "status": "Submitted", + "entityName": "UserCase" }, { "documentType": "Statement of Taxpayer Identification", diff --git a/web-api/storage/fixtures/seed/113-19.json b/web-api/storage/fixtures/seed/113-19.json index d2d8d55a656..42471da76ee 100644 --- a/web-api/storage/fixtures/seed/113-19.json +++ b/web-api/storage/fixtures/seed/113-19.json @@ -82,7 +82,8 @@ "leadCaseId": "fd8d1139-5e54-4117-9b94-7a69359423c2", "docketNumber": "113-19", "docketNumberWithSuffix": "113-19L", - "status": "Submitted" + "status": "Submitted", + "entityName": "UserCase" }, { "documentType": "Statement of Taxpayer Identification", diff --git a/web-api/storage/fixtures/seed/case-messages.json b/web-api/storage/fixtures/seed/case-messages.json new file mode 100644 index 00000000000..97a43c68ed9 --- /dev/null +++ b/web-api/storage/fixtures/seed/case-messages.json @@ -0,0 +1,23 @@ +[ + { + "attachments": [], + "caseId": "0bc59d5b-c2b9-41f7-92a7-03b8cadffcc0", + "caseStatus": "General Docket - Not at Issue", + "createdAt": "2020-06-05T18:02:25.280Z", + "docketNumber": "105-20", + "docketNumberWithSuffix": "105-20L", + "entityName": "CaseMessage", + "from": "Test Petitionsclerk", + "fromSection": "petitions", + "fromUserId": "3805d1ab-18d0-43ec-bafb-654e83405416", + "gsi1pk": "message|eb0a139a-8951-4de1-8b83-f02a27504105", + "message": "hello!", + "messageId": "eb0a139a-8951-4de1-8b83-f02a27504105", + "pk": "case|0bc59d5b-c2b9-41f7-92a7-03b8cadffcc0", + "sk": "message|eb0a139a-8951-4de1-8b83-f02a27504105", + "subject": "message to myself", + "to": "Test Petitionsclerk", + "toSection": "petitions", + "toUserId": "3805d1ab-18d0-43ec-bafb-654e83405416" + } +] diff --git a/web-api/storage/fixtures/seed/fix.js b/web-api/storage/fixtures/seed/fix.js index b8045d985a2..47b49e9b373 100644 --- a/web-api/storage/fixtures/seed/fix.js +++ b/web-api/storage/fixtures/seed/fix.js @@ -20,6 +20,7 @@ const files = [ ]; for (const file of files) { + // eslint-disable-next-line security/detect-non-literal-require let json = require(file); const items = []; for (const item of json) { diff --git a/web-api/storage/fixtures/seed/index.js b/web-api/storage/fixtures/seed/index.js index ae4c648ba9c..1e703409d9d 100755 --- a/web-api/storage/fixtures/seed/index.js +++ b/web-api/storage/fixtures/seed/index.js @@ -17,6 +17,7 @@ module.exports = [ ...require('./103-20.json'), ...require('./104-20.json'), ...require('./105-20.json'), + ...require('./case-messages.json'), ...require('./trial-sessions.json'), ...require('./trial-sessions-past.json'), ...require('./misc.json'), diff --git a/web-api/storage/fixtures/validate-seed.js b/web-api/storage/fixtures/validate-seed.js index 4b312eaeeea..1755c569c81 100755 --- a/web-api/storage/fixtures/validate-seed.js +++ b/web-api/storage/fixtures/validate-seed.js @@ -25,10 +25,9 @@ stdin.on('end', () => { /** * @param {Array} entry to the seedFile which ought to exist - * @param {string} entry.seedFile the seed file that referenced the documentId * @param {string} entry.uuid the documentId's UUID */ -function checkFilesExist([uuid, seedFile]) { +function checkFilesExist([uuid]) { const createFiles = { [`${__dirname}/s3/noop-documents-local-us-east-1/${uuid}._S3rver_metadata.json`]: `${__dirname}/s3/noop-documents-local-us-east-1/${EXISTING_UUID}._S3rver_metadata.json`, [`${__dirname}/s3/noop-documents-local-us-east-1/${uuid}._S3rver_object`]: `${__dirname}/s3/noop-documents-local-us-east-1/${EXISTING_UUID}._S3rver_object`, diff --git a/web-api/storage/scripts/createUsers.js b/web-api/storage/scripts/createUsers.js index 1c4d58f1411..8e1c5dfb83e 100644 --- a/web-api/storage/scripts/createUsers.js +++ b/web-api/storage/scripts/createUsers.js @@ -6,8 +6,10 @@ const { const { createUserRecords: createPractitionerUserRecords, } = require('../../../shared/src/persistence/dynamo/users/createPractitionerUser.js'); +const { + ROLES, +} = require('../../../shared/src/business/entities/EntityConstants'); const { omit } = require('lodash'); -const { User } = require('../../../shared/src/business/entities/User'); let usersByEmail = {}; @@ -32,9 +34,9 @@ module.exports.createUsers = async () => { if ( [ - User.ROLES.irsPractitioner, - User.ROLES.privatePractitioner, - User.ROLES.inactivePractitioner, + ROLES.irsPractitioner, + ROLES.privatePractitioner, + ROLES.inactivePractitioner, ].includes(userRecord.role) ) { return createPractitionerUserRecords({ diff --git a/web-api/storage/scripts/loadTest/loadTestHelpers.js b/web-api/storage/scripts/loadTest/loadTestHelpers.js index 20699532fc3..5a40a9a8440 100644 --- a/web-api/storage/scripts/loadTest/loadTestHelpers.js +++ b/web-api/storage/scripts/loadTest/loadTestHelpers.js @@ -1,9 +1,10 @@ const faker = require('faker'); const { - TrialSession, -} = require('../../../../shared/src/business/entities/trialSessions/TrialSession'); -const { Case } = require('../../../../shared/src/business/entities/cases/Case'); -const { User } = require('../../../../shared/src/business/entities/User'); + FILING_TYPES, + PROCEDURE_TYPES, + ROLES, + TRIAL_CITY_STRINGS, +} = require('../../../../shared/src/business/entities/EntityConstants'); const createTrialSession = async ({ applicationContext }) => { let startDate = faker.date.future(1); @@ -35,9 +36,7 @@ const createTrialSession = async ({ applicationContext }) => { term = 'Fall'; } - let trialLocation = faker.random.arrayElement( - TrialSession.TRIAL_CITY_STRINGS, - ); + let trialLocation = faker.random.arrayElement(TRIAL_CITY_STRINGS); return await applicationContext.getUseCases().createTrialSessionInteractor({ applicationContext, @@ -129,15 +128,11 @@ const createCase = async ({ postalCode: faker.address.zipCode(), state: faker.address.stateAbbr(), }, - filingType: faker.random.arrayElement( - Case.FILING_TYPES[User.ROLES.petitioner], - ), + filingType: faker.random.arrayElement(FILING_TYPES[ROLES.petitioner]), hasIrsNotice: false, partyType: 'Petitioner', - preferredTrialCity: faker.random.arrayElement( - TrialSession.TRIAL_CITY_STRINGS, - ), - procedureType: faker.random.arrayElement(Case.PROCEDURE_TYPES), + preferredTrialCity: faker.random.arrayElement(TRIAL_CITY_STRINGS), + procedureType: faker.random.arrayElement(PROCEDURE_TYPES), }, stinFileId, }); diff --git a/web-api/storage/scripts/loadTest/loadTestPractitioners.js b/web-api/storage/scripts/loadTest/loadTestPractitioners.js index 05f4ba4199a..1afbc9fac2a 100644 --- a/web-api/storage/scripts/loadTest/loadTestPractitioners.js +++ b/web-api/storage/scripts/loadTest/loadTestPractitioners.js @@ -12,7 +12,7 @@ const cognito = new AWS.CognitoIdentityServiceProvider({ (async () => { let practitionerUser; - var apigateway = new AWS.APIGateway({ + const apigateway = new AWS.APIGateway({ region: process.env.REGION, }); const { items: apis } = await apigateway @@ -28,14 +28,14 @@ const cognito = new AWS.CognitoIdentityServiceProvider({ return obj; }, {}); - let token = await getUserToken({ + const token = await getUserToken({ cognito, env: process.env.ENV, password: 'Testing1234$', username: 'practitioner1@example.com', }); - let response = await axios.get(`${services['ef-cms-users-green']}`, { + const response = await axios.get(`${services['ef-cms-users-green']}`, { headers: { Authorization: `Bearer ${token}`, }, diff --git a/web-api/storage/scripts/loadTest/loadTestTrialSession.js b/web-api/storage/scripts/loadTest/loadTestTrialSession.js index 5996e7c2646..67a77d8d42b 100644 --- a/web-api/storage/scripts/loadTest/loadTestTrialSession.js +++ b/web-api/storage/scripts/loadTest/loadTestTrialSession.js @@ -18,7 +18,7 @@ const cognito = new AWS.CognitoIdentityServiceProvider({ let petitionerUser; let docketClerkUser; - var apigateway = new AWS.APIGateway({ + const apigateway = new AWS.APIGateway({ region: process.env.REGION, }); const { items: apis } = await apigateway diff --git a/web-api/swagger.json b/web-api/swagger.json index 95fe05c0c7b..ddb632fd79f 100644 --- a/web-api/swagger.json +++ b/web-api/swagger.json @@ -1065,7 +1065,7 @@ } } }, - "/cases/open-cases": { + "/cases/open": { "get": { "tags": ["cases"], "summary": "Retrieve open cases", @@ -1109,6 +1109,50 @@ } } }, + "/cases/closed": { + "get": { + "tags": ["cases"], + "summary": "Retrieve closed cases", + "description": "Retrieve closed cases.\n", + "produces": ["application/json"], + "responses": { + "200": { + "description": "200 response", + "schema": { + "$ref": "#/definitions/case" + } + } + }, + "security": [ + { + "CognitoUserPool": [] + } + ] + }, + "options": { + "consumes": ["application/json"], + "produces": ["application/json"], + "responses": { + "200": { + "description": "200 response", + "headers": { + "Access-Control-Allow-Origin": { + "type": "string" + }, + "Access-Control-Allow-Methods": { + "type": "string" + }, + "Access-Control-Allow-Credentials": { + "type": "string" + }, + "Access-Control-Allow-Headers": { + "type": "string" + } + } + } + } + } + }, "/public-api/cases/{caseId}": { "parameters": [ { @@ -5453,6 +5497,354 @@ } } } + }, + "/messages": { + "post": { + "tags": ["messages"], + "summary": "create a case message", + "description": "Create a message.\n", + "produces": ["application/json"], + "responses": { + "200": { + "description": "200 response", + "schema": { + "$ref": "#/definitions/caseMessage" + } + } + }, + "security": [ + { + "CognitoUserPool": [] + } + ] + }, + "options": { + "consumes": ["application/json"], + "produces": ["application/json"], + "responses": { + "200": { + "description": "200 response", + "headers": { + "Access-Control-Allow-Origin": { + "type": "string" + }, + "Access-Control-Allow-Methods": { + "type": "string" + }, + "Access-Control-Allow-Credentials": { + "type": "string" + }, + "Access-Control-Allow-Headers": { + "type": "string" + } + } + } + } + } + }, + "/messages/{messageId}": { + "parameters": [ + { + "name": "messageId", + "in": "path", + "required": true, + "type": "string" + } + ], + "get": { + "tags": ["messages"], + "summary": "gets the message for the specific id", + "description": "Gets the message for the specific id.\n", + "produces": ["application/json"], + "responses": { + "200": { + "description": "200 response", + "schema": { + "$ref": "#/definitions/caseMessage" + } + } + }, + "security": [ + { + "CognitoUserPool": [] + } + ] + }, + "options": { + "consumes": ["application/json"], + "produces": ["application/json"], + "responses": { + "200": { + "description": "200 response", + "headers": { + "Access-Control-Allow-Origin": { + "type": "string" + }, + "Access-Control-Allow-Methods": { + "type": "string" + }, + "Access-Control-Allow-Credentials": { + "type": "string" + }, + "Access-Control-Allow-Headers": { + "type": "string" + } + } + } + } + } + }, + "/messages/inbox/{userId}": { + "parameters": [ + { + "name": "userId", + "in": "path", + "required": true, + "type": "string" + } + ], + "get": { + "tags": ["messages"], + "summary": "gets the inbox messages for the specific user id", + "description": "Gets the inbox messages for the specific user id.\n", + "produces": ["application/json"], + "responses": { + "200": { + "description": "200 response", + "schema": { + "$ref": "#/definitions/caseMessage" + } + } + }, + "security": [ + { + "CognitoUserPool": [] + } + ] + }, + "options": { + "consumes": ["application/json"], + "produces": ["application/json"], + "responses": { + "200": { + "description": "200 response", + "headers": { + "Access-Control-Allow-Origin": { + "type": "string" + }, + "Access-Control-Allow-Methods": { + "type": "string" + }, + "Access-Control-Allow-Credentials": { + "type": "string" + }, + "Access-Control-Allow-Headers": { + "type": "string" + } + } + } + } + } + }, + "/messages/inbox/section/{section}": { + "parameters": [ + { + "name": "section", + "in": "path", + "required": true, + "type": "string" + } + ], + "get": { + "tags": ["messages"], + "summary": "gets the inbox messages for the specific section", + "description": "Gets the inbox messages for the specific user section.\n", + "produces": ["application/json"], + "responses": { + "200": { + "description": "200 response", + "schema": { + "$ref": "#/definitions/caseMessage" + } + } + }, + "security": [ + { + "CognitoUserPool": [] + } + ] + }, + "options": { + "consumes": ["application/json"], + "produces": ["application/json"], + "responses": { + "200": { + "description": "200 response", + "headers": { + "Access-Control-Allow-Origin": { + "type": "string" + }, + "Access-Control-Allow-Methods": { + "type": "string" + }, + "Access-Control-Allow-Credentials": { + "type": "string" + }, + "Access-Control-Allow-Headers": { + "type": "string" + } + } + } + } + } + }, + "/messages/outbox/{userId}": { + "parameters": [ + { + "name": "userId", + "in": "path", + "required": true, + "type": "string" + } + ], + "get": { + "tags": ["messages"], + "summary": "gets the outbox messages for the specific user id", + "description": "Gets the outbox messages for the specific user id.\n", + "produces": ["application/json"], + "responses": { + "200": { + "description": "200 response", + "schema": { + "$ref": "#/definitions/caseMessage" + } + } + }, + "security": [ + { + "CognitoUserPool": [] + } + ] + }, + "options": { + "consumes": ["application/json"], + "produces": ["application/json"], + "responses": { + "200": { + "description": "200 response", + "headers": { + "Access-Control-Allow-Origin": { + "type": "string" + }, + "Access-Control-Allow-Methods": { + "type": "string" + }, + "Access-Control-Allow-Credentials": { + "type": "string" + }, + "Access-Control-Allow-Headers": { + "type": "string" + } + } + } + } + } + }, + "/messages/outbox/section/{section}": { + "parameters": [ + { + "name": "section", + "in": "path", + "required": true, + "type": "string" + } + ], + "get": { + "tags": ["messages"], + "summary": "gets the outbox messages for the specific section", + "description": "Gets the outbox messages for the specific user section.\n", + "produces": ["application/json"], + "responses": { + "200": { + "description": "200 response", + "schema": { + "$ref": "#/definitions/caseMessage" + } + } + }, + "security": [ + { + "CognitoUserPool": [] + } + ] + }, + "options": { + "consumes": ["application/json"], + "produces": ["application/json"], + "responses": { + "200": { + "description": "200 response", + "headers": { + "Access-Control-Allow-Origin": { + "type": "string" + }, + "Access-Control-Allow-Methods": { + "type": "string" + }, + "Access-Control-Allow-Credentials": { + "type": "string" + }, + "Access-Control-Allow-Headers": { + "type": "string" + } + } + } + } + } + }, + "/public-api/todays-opinions": { + "get": { + "tags": ["case-documents"], + "summary": "returns the opinions created for the current date", + "description": "Returns the opinions created for the current date.\n", + "produces": ["application/json"], + "responses": { + "200": { + "description": "200 response", + "schema": { + "$ref": "#/definitions/document" + } + } + }, + "security": [ + { + "CognitoUserPool": [] + } + ] + }, + "options": { + "consumes": ["application/json"], + "produces": ["application/json"], + "responses": { + "200": { + "description": "200 response", + "headers": { + "Access-Control-Allow-Origin": { + "type": "string" + }, + "Access-Control-Allow-Methods": { + "type": "string" + }, + "Access-Control-Allow-Credentials": { + "type": "string" + }, + "Access-Control-Allow-Headers": { + "type": "string" + } + } + } + } + } } }, "securityDefinitions": { @@ -5818,6 +6210,72 @@ } }, "description": "a case procedural note" + }, + "caseMessage": { + "type": "object", + "properties": { + "caseId": { + "type": "string", + "description": "id of the associated case" + }, + "caseStatus": { + "type": "string", + "description": "status of the associated case" + }, + "createdAt": { + "type": "string", + "description": "message created time" + }, + "docketNumber": { + "type": "string", + "description": "docket number of the associated case" + }, + "docketNumberWithSuffix": { + "type": "string", + "description": "docket number of the associated case with its suffix" + }, + "entityName": { + "type": "string", + "description": "the name of the entity - CaseMessage" + }, + "from": { + "type": "string", + "description": "the name of the user who sent the message" + }, + "fromSection": { + "type": "string", + "description": "the section of the user who sent the message" + }, + "fromUserId": { + "type": "string", + "description": "the ID of the user who sent the message" + }, + "message": { + "type": "string", + "description": "the message text" + }, + "messageId": { + "type": "string", + "description": "the unique ID generated by the system to represent the message" + }, + "subject": { + "type": "string", + "description": "the subject line of the message" + }, + "to": { + "type": "string", + "description": "the name of the user who is the recipient of the message" + }, + "toSection": { + "type": "string", + "description": "the section of the user who is the recipient of the message" + }, + "toUserId": { + "type": "string", + "description": "the ID of the user who is the recipient of the message" + } + }, + "description": "a case deadline" } } } diff --git a/web-api/terraform/template/cognito.tf b/web-api/terraform/template/cognito.tf index 787ec26d9d7..feb694918ac 100644 --- a/web-api/terraform/template/cognito.tf +++ b/web-api/terraform/template/cognito.tf @@ -106,11 +106,6 @@ resource "aws_cognito_user_pool" "irs_pool" { enabled = true } - device_configuration { - challenge_required_on_new_device = true - device_only_remembered_on_user_prompt = false - } - auto_verified_attributes = ["email"] username_attributes = ["email"] diff --git a/web-client/integration-tests-public/journey/unauthedUserViewsCaseDetail.js b/web-client/integration-tests-public/journey/unauthedUserViewsCaseDetail.js index cd831e309ec..23cb7268966 100644 --- a/web-client/integration-tests-public/journey/unauthedUserViewsCaseDetail.js +++ b/web-client/integration-tests-public/journey/unauthedUserViewsCaseDetail.js @@ -77,7 +77,7 @@ export const unauthedUserViewsCaseDetail = test => { documentType: 'Statement of Taxpayer Identification', }), expect.objectContaining({ - documentType: 'OD - Order of Dismissal Entered,', + documentType: 'OD - Order of Dismissal Entered', }), expect.objectContaining({ documentType: 'TRAN - Transcript' }), ]), diff --git a/web-client/integration-tests-public/journey/unauthedUserViewsTodaysOpinions.js b/web-client/integration-tests-public/journey/unauthedUserViewsTodaysOpinions.js new file mode 100644 index 00000000000..9c73d30a400 --- /dev/null +++ b/web-client/integration-tests-public/journey/unauthedUserViewsTodaysOpinions.js @@ -0,0 +1,18 @@ +import { refreshElasticsearchIndex } from '../../integration-tests/helpers'; + +export const unauthedUserViewsTodaysOpinions = test => { + return it('should view todays opinions', async () => { + await refreshElasticsearchIndex(); + + await test.runSequence('gotoTodaysOpinionsSequence', {}); + + expect(test.getState('todaysOpinions')).toEqual( + expect.arrayContaining([ + expect.objectContaining({ + documentType: 'TCOP - T.C. Opinion', + numberOfPages: 1, + }), + ]), + ); + }); +}; diff --git a/web-client/integration-tests-public/unauthedUserSearchesForCase.test.js b/web-client/integration-tests-public/unauthedUserSearchesForCase.test.js index e1e937ddb12..5a23172d4b7 100644 --- a/web-client/integration-tests-public/unauthedUserSearchesForCase.test.js +++ b/web-client/integration-tests-public/unauthedUserSearchesForCase.test.js @@ -15,7 +15,7 @@ import { petitionerCreatesNewCase } from '../integration-tests/journey/petitione import { docketClerkAddsDocketEntryFromOrderOfDismissal } from '../integration-tests/journey/docketClerkAddsDocketEntryFromOrderOfDismissal'; import { docketClerkAddsTranscriptDocketEntryFromOrder } from '../integration-tests/journey/docketClerkAddsTranscriptDocketEntryFromOrder'; import { docketClerkCreatesAnOrder } from '../integration-tests/journey/docketClerkCreatesAnOrder'; -import { docketClerkServesOrder } from '../integration-tests/journey/docketClerkServesOrder'; +import { docketClerkServesDocument } from '../integration-tests/journey/docketClerkServesDocument'; // Public User import { unauthedUserNavigatesToPublicSite } from './journey/unauthedUserNavigatesToPublicSite'; @@ -63,7 +63,7 @@ describe('Docket clerk creates and serves an order (should be viewable to the pu expectedDocumentType: 'Order of Dismissal', }); docketClerkAddsDocketEntryFromOrderOfDismissal(testClient, 1); - docketClerkServesOrder(testClient, 1); + docketClerkServesDocument(testClient, 1); }); describe('Docket clerk creates and serves a transcript (should not be viewable to the public)', () => { @@ -78,7 +78,7 @@ describe('Docket clerk creates and serves a transcript (should not be viewable t month: '01', year: '2019', }); - docketClerkServesOrder(testClient, 2); + docketClerkServesDocument(testClient, 2); }); describe('Unauthed user searches for a case and views a case detail page', () => { diff --git a/web-client/integration-tests-public/unauthedUserSearchesForOrder.test.js b/web-client/integration-tests-public/unauthedUserSearchesForOrder.test.js index 64b9bd6e261..6d3fde04268 100644 --- a/web-client/integration-tests-public/unauthedUserSearchesForOrder.test.js +++ b/web-client/integration-tests-public/unauthedUserSearchesForOrder.test.js @@ -1,9 +1,9 @@ -import { ContactFactory } from '../../shared/src/business/entities/contacts/ContactFactory'; +import { PARTY_TYPES } from '../../shared/src/business/entities/EntityConstants'; import { docketClerkAddsDocketEntryFromOrder } from '../integration-tests/journey/docketClerkAddsDocketEntryFromOrder'; import { docketClerkAddsDocketEntryFromOrderOfDismissal } from '../integration-tests/journey/docketClerkAddsDocketEntryFromOrderOfDismissal'; import { docketClerkCreatesAnOrder } from '../integration-tests/journey/docketClerkCreatesAnOrder'; import { docketClerkSealsCase } from '../integration-tests/journey/docketClerkSealsCase'; -import { docketClerkServesOrder } from '../integration-tests/journey/docketClerkServesOrder'; +import { docketClerkServesDocument } from '../integration-tests/journey/docketClerkServesDocument'; import { loginAs, setupTest as setupTestClient, @@ -41,7 +41,7 @@ describe('Petitioner creates case', () => { postalCode: '77546', state: 'CT', }, - partyType: ContactFactory.PARTY_TYPES.petitionerSpouse, + partyType: PARTY_TYPES.petitionerSpouse, }); expect(caseDetail.docketNumber).toBeDefined(); test.docketNumber = caseDetail.docketNumber; @@ -58,7 +58,7 @@ describe('Docket clerk creates orders to search for', () => { signedAtFormatted: '01/02/2020', }); docketClerkAddsDocketEntryFromOrder(testClient, 0); - docketClerkServesOrder(testClient, 0); + docketClerkServesDocument(testClient, 0); docketClerkCreatesAnOrder(testClient, { documentTitle: 'Order of Dismissal', @@ -66,7 +66,7 @@ describe('Docket clerk creates orders to search for', () => { expectedDocumentType: 'Order of Dismissal', }); docketClerkAddsDocketEntryFromOrderOfDismissal(testClient, 1); - docketClerkServesOrder(testClient, 1); + docketClerkServesDocument(testClient, 1); docketClerkCreatesAnOrder(testClient, { documentTitle: 'Order of Dismissal', diff --git a/web-client/integration-tests-public/unauthedUserSearchesForSealedCase.test.js b/web-client/integration-tests-public/unauthedUserSearchesForSealedCase.test.js index 69d2c4ba8f3..486117d7334 100644 --- a/web-client/integration-tests-public/unauthedUserSearchesForSealedCase.test.js +++ b/web-client/integration-tests-public/unauthedUserSearchesForSealedCase.test.js @@ -1,15 +1,11 @@ -import { setupTest } from './helpers'; - +import { PARTY_TYPES } from '../../shared/src/business/entities/EntityConstants'; +import { docketClerkSealsCase } from '../integration-tests/journey/docketClerkSealsCase'; import { loginAs, setupTest as setupTestClient, uploadPetition, } from '../integration-tests/helpers'; - -import { ContactFactory } from '../../shared/src/business/entities/contacts/ContactFactory'; - -// Public User -import { docketClerkSealsCase } from '../integration-tests/journey/docketClerkSealsCase'; +import { setupTest } from './helpers'; import { unauthedUserNavigatesToPublicSite } from './journey/unauthedUserNavigatesToPublicSite'; import { unauthedUserSearchesForSealedCaseByName } from './journey/unauthedUserSearchesForSealedCaseByName'; import { unauthedUserSearchesForSealedCasesByDocketNumber } from './journey/unauthedUserSearchesForSealedCasesByDocketNumber'; @@ -37,7 +33,7 @@ describe('Petitioner creates cases to search for', () => { postalCode: '77546', state: 'CT', }, - partyType: ContactFactory.PARTY_TYPES.petitionerSpouse, + partyType: PARTY_TYPES.petitionerSpouse, }); expect(caseDetail.docketNumber).toBeDefined(); test.docketNumber = caseDetail.docketNumber; diff --git a/web-client/integration-tests-public/unauthedUserViewsTodaysOpinions.test.js b/web-client/integration-tests-public/unauthedUserViewsTodaysOpinions.test.js new file mode 100644 index 00000000000..1f56f402d10 --- /dev/null +++ b/web-client/integration-tests-public/unauthedUserViewsTodaysOpinions.test.js @@ -0,0 +1,46 @@ +import { docketClerkAddsDocketEntryFromOrder } from '../integration-tests/journey/docketClerkAddsDocketEntryFromOrder'; +import { docketClerkConvertsAnOrderToAnOpinion } from '../integration-tests/journey/docketClerkConvertsAnOrderToAnOpinion'; +import { docketClerkCreatesAnOrder } from '../integration-tests/journey/docketClerkCreatesAnOrder'; +import { docketClerkServesDocument } from '../integration-tests/journey/docketClerkServesDocument'; +import { docketClerkViewsDraftOrder } from '../integration-tests/journey/docketClerkViewsDraftOrder'; + +import { + loginAs, + setupTest as setupTestClient, + uploadPetition, +} from '../integration-tests/helpers'; +import { setupTest } from './helpers'; +import { unauthedUserViewsTodaysOpinions } from './journey/unauthedUserViewsTodaysOpinions'; + +const test = setupTest(); +const testClient = setupTestClient({ + useCases: { + loadPDFForSigningInteractor: () => Promise.resolve(null), + }, +}); + +testClient.draftOrders = []; + +describe('Unauthed user views todays opinions', () => { + loginAs(testClient, 'petitioner'); + it('Create test case to add an opinion to', async () => { + const caseDetail = await uploadPetition(testClient); + expect(caseDetail.docketNumber).toBeDefined(); + testClient.docketNumber = caseDetail.docketNumber; + }); + + // the next few tests create an order document, then edit it to convert + // it to an opinion type document, and then serve that opinion in order for it to show up in todays opinions + loginAs(testClient, 'docketclerk'); + docketClerkCreatesAnOrder(testClient, { + documentTitle: 'Order to do something', + eventCode: 'O', + expectedDocumentType: 'Order', + }); + docketClerkViewsDraftOrder(testClient, 0); + docketClerkAddsDocketEntryFromOrder(testClient, 0); + docketClerkConvertsAnOrderToAnOpinion(testClient, 0); + docketClerkServesDocument(testClient, 0); + + unauthedUserViewsTodaysOpinions(test); +}); diff --git a/web-client/integration-tests/admissionsClerkPractitionerJourney.test.js b/web-client/integration-tests/admissionsClerkPractitionerJourney.test.js index d0abfb701f2..9da92ae4bd2 100644 --- a/web-client/integration-tests/admissionsClerkPractitionerJourney.test.js +++ b/web-client/integration-tests/admissionsClerkPractitionerJourney.test.js @@ -1,4 +1,4 @@ -import { ContactFactory } from '../../shared/src/business/entities/contacts/ContactFactory'; +import { PARTY_TYPES } from '../../shared/src/business/entities/EntityConstants'; import { admissionsClerkAddsNewPractitioner } from './journey/admissionsClerkAddsNewPractitioner'; import { admissionsClerkEditsPractitionerInfo } from './journey/admissionsClerkEditsPractitionerInfo'; import { admissionsClerkSearchesForPractitionerByBarNumber } from './journey/admissionsClerkSearchesForPractitionerByBarNumber'; @@ -32,7 +32,7 @@ describe('admissions clerk practitioner journey', () => { postalCode: '77546', state: 'AZ', }, - partyType: ContactFactory.PARTY_TYPES.petitionerSpouse, + partyType: PARTY_TYPES.petitionerSpouse, }); expect(caseDetail.docketNumber).toBeDefined(); test.docketNumber = caseDetail.docketNumber; diff --git a/web-client/integration-tests/docketClerkAddsCourtIssuedOrderToDocketRecord.test.js b/web-client/integration-tests/docketClerkAddsCourtIssuedOrderToDocketRecord.test.js index ec13b48e9c1..442d1462555 100644 --- a/web-client/integration-tests/docketClerkAddsCourtIssuedOrderToDocketRecord.test.js +++ b/web-client/integration-tests/docketClerkAddsCourtIssuedOrderToDocketRecord.test.js @@ -5,9 +5,9 @@ import { docketClerkAddsDocketEntryFromOrder } from './journey/docketClerkAddsDo import { docketClerkAddsDocketEntryFromOrderOfDismissal } from './journey/docketClerkAddsDocketEntryFromOrderOfDismissal'; import { docketClerkAddsDocketEntryFromOrderWithDate } from './journey/docketClerkAddsDocketEntryFromOrderWithDate'; import { docketClerkCancelsAddDocketEntryFromOrder } from './journey/docketClerkCancelsAddDocketEntryFromOrder'; +import { docketClerkConvertsAnOrderToAnOpinion } from './journey/docketClerkConvertsAnOrderToAnOpinion'; import { docketClerkCreatesAnOrder } from './journey/docketClerkCreatesAnOrder'; import { docketClerkEditsDocketEntryFromOrderTypeA } from './journey/docketClerkEditsDocketEntryFromOrderTypeA'; -import { docketClerkEditsDocketEntryFromOrderTypeB } from './journey/docketClerkEditsDocketEntryFromOrderTypeB'; import { docketClerkEditsDocketEntryFromOrderTypeC } from './journey/docketClerkEditsDocketEntryFromOrderTypeC'; import { docketClerkEditsDocketEntryFromOrderTypeD } from './journey/docketClerkEditsDocketEntryFromOrderTypeD'; import { docketClerkEditsDocketEntryFromOrderTypeE } from './journey/docketClerkEditsDocketEntryFromOrderTypeE'; @@ -64,7 +64,7 @@ describe('Docket Clerk Adds Court-Issued Order to Docket Record', () => { docketClerkViewsDraftOrder(test, 0); docketClerkAddsDocketEntryFromOrder(test, 0); docketClerkEditsDocketEntryFromOrderTypeA(test, 0); - docketClerkEditsDocketEntryFromOrderTypeB(test, 0); + docketClerkConvertsAnOrderToAnOpinion(test, 0); docketClerkEditsDocketEntryFromOrderTypeC(test, 0); docketClerkEditsDocketEntryFromOrderTypeD(test, 0); docketClerkEditsDocketEntryFromOrderTypeE(test, 0); diff --git a/web-client/integration-tests/docketClerkAddsTranscriptToDocketRecord.test.js b/web-client/integration-tests/docketClerkAddsTranscriptToDocketRecord.test.js index 5f9b13bfa43..a98c673d8df 100644 --- a/web-client/integration-tests/docketClerkAddsTranscriptToDocketRecord.test.js +++ b/web-client/integration-tests/docketClerkAddsTranscriptToDocketRecord.test.js @@ -1,6 +1,6 @@ import { docketClerkAddsTranscriptDocketEntryFromOrder } from './journey/docketClerkAddsTranscriptDocketEntryFromOrder'; import { docketClerkCreatesAnOrder } from './journey/docketClerkCreatesAnOrder'; -import { docketClerkServesOrder } from './journey/docketClerkServesOrder'; +import { docketClerkServesDocument } from './journey/docketClerkServesDocument'; import { docketClerkViewsDraftOrder } from './journey/docketClerkViewsDraftOrder'; import { fakeFile, loginAs, setupTest } from './helpers'; import { formattedCaseDetail as formattedCaseDetailComputed } from '../src/presenter/computeds/formattedCaseDetail'; @@ -44,7 +44,7 @@ describe('Docket Clerk Adds Transcript to Docket Record', () => { month: '01', year: '2019', }); - docketClerkServesOrder(test, 0); + docketClerkServesDocument(test, 0); docketClerkCreatesAnOrder(test, { documentTitle: 'Order to do something', eventCode: 'O', @@ -58,7 +58,7 @@ describe('Docket Clerk Adds Transcript to Docket Record', () => { month: today.getMonth() + 1, year: today.getFullYear(), }); - docketClerkServesOrder(test, 1); + docketClerkServesDocument(test, 1); loginAs(test, 'petitioner'); it('petitioner views transcript on docket record', async () => { diff --git a/web-client/integration-tests/docketClerkCaseInventoryReport.test.js b/web-client/integration-tests/docketClerkCaseInventoryReport.test.js index bb9a427c530..d2af90d805e 100644 --- a/web-client/integration-tests/docketClerkCaseInventoryReport.test.js +++ b/web-client/integration-tests/docketClerkCaseInventoryReport.test.js @@ -1,4 +1,4 @@ -import { Case } from '../../shared/src/business/entities/cases/Case'; +import { CASE_STATUS_TYPES } from '../../shared/src/business/entities/EntityConstants'; import { docketClerkCreatesATrialSession } from './journey/docketClerkCreatesATrialSession'; import { docketClerkViewsTrialSessionList } from './journey/docketClerkViewsTrialSessionList'; import { @@ -30,7 +30,7 @@ describe('case inventory report journey', () => { //New await test.runSequence('updateScreenMetadataSequence', { key: 'status', - value: Case.STATUS_TYPES.new, + value: CASE_STATUS_TYPES.new, }); await test.runSequence('submitCaseInventoryReportModalSequence'); initialCaseInventoryCounts.new = test.getState( @@ -48,7 +48,7 @@ describe('case inventory report journey', () => { //Calendared, Judge Armen await test.runSequence('updateScreenMetadataSequence', { key: 'status', - value: Case.STATUS_TYPES.calendared, + value: CASE_STATUS_TYPES.calendared, }); await test.runSequence('submitCaseInventoryReportModalSequence'); initialCaseInventoryCounts.calendaredArmen = test.getState( @@ -120,7 +120,7 @@ describe('case inventory report journey', () => { await test.runSequence('openCaseInventoryReportModalSequence'); await test.runSequence('updateScreenMetadataSequence', { key: 'status', - value: Case.STATUS_TYPES.new, + value: CASE_STATUS_TYPES.new, }); await test.runSequence('submitCaseInventoryReportModalSequence'); let updatedCaseInventoryCount = test.getState( @@ -144,7 +144,7 @@ describe('case inventory report journey', () => { //Calendared, Judge Armen (+1 from initial) await test.runSequence('updateScreenMetadataSequence', { key: 'status', - value: Case.STATUS_TYPES.calendared, + value: CASE_STATUS_TYPES.calendared, }); await test.runSequence('submitCaseInventoryReportModalSequence'); updatedCaseInventoryCount = test.getState( diff --git a/web-client/integration-tests/docketClerkCreatesDocketEntryFromScans.test.js b/web-client/integration-tests/docketClerkCreatesDocketEntryFromScans.test.js index 41cb152849a..46d7fd7b247 100644 --- a/web-client/integration-tests/docketClerkCreatesDocketEntryFromScans.test.js +++ b/web-client/integration-tests/docketClerkCreatesDocketEntryFromScans.test.js @@ -1,80 +1,20 @@ -import { Case } from '../../shared/src/business/entities/cases/Case'; -import { CerebralTest } from 'cerebral/test'; -import { ContactFactory } from '../../shared/src/business/entities/contacts/ContactFactory'; -import { JSDOM } from 'jsdom'; -import { MAX_FILE_SIZE_MB } from '../../shared/src/persistence/s3/getUploadPolicy'; -import { TrialSession } from '../../shared/src/business/entities/trialSessions/TrialSession'; -import { User } from '../../shared/src/business/entities/User'; import { addBatchesForScanning, createPDFFromScannedBatches, selectScannerSource, -} from './scanHelpers.js'; -import { applicationContext } from '../src/applicationContext'; +} from './scanHelpers'; import { docketClerkAddsDocketEntryFile } from './journey/docketClerkAddsDocketEntryFile'; import { docketClerkAddsDocketEntryWithoutFile } from './journey/docketClerkAddsDocketEntryWithoutFile'; import { docketClerkSavesDocketEntry } from './journey/docketClerkSavesDocketEntry'; import { docketClerkViewsEditDocketRecord } from './journey/docketClerkViewsEditDocketRecord'; import { docketClerkViewsQCInProgress } from './journey/docketClerkViewsQCInProgress'; import { docketClerkViewsSectionQCInProgress } from './journey/docketClerkViewsSectionQCInProgress'; -import { getScannerInterface } from '../../shared/src/persistence/dynamsoft/getScannerMockInterface'; -import { isFunction, mapValues } from 'lodash'; -import { loginAs } from './helpers'; +import { fakeFile, loginAs, setupTest } from './helpers'; import { petitionerChoosesCaseType } from './journey/petitionerChoosesCaseType'; import { petitionerChoosesProcedureType } from './journey/petitionerChoosesProcedureType'; import { petitionerCreatesNewCase } from './journey/petitionerCreatesNewCase'; -import { presenter } from '../src/presenter/presenter'; -import { withAppContextDecorator } from '../src/withAppContext'; -import FormData from 'form-data'; -let test; -global.FormData = FormData; -presenter.providers.applicationContext = Object.assign(applicationContext, { - getScanner: getScannerInterface, -}); -presenter.providers.router = { - createObjectURL: () => {}, - externalRoute: () => {}, - revokeObjectURL: () => {}, - route: async url => { - if (url === `/case-detail/${test.docketNumber}`) { - await test.runSequence('gotoCaseDetailSequence', { - docketNumber: test.docketNumber, - }); - } - - if (url === '/') { - await test.runSequence('gotoDashboardSequence'); - } - - if (url === '/file-a-petition/success') { - await test.runSequence('gotoFilePetitionSuccessSequence'); - } - }, -}; - -presenter.state = mapValues(presenter.state, value => { - if (isFunction(value)) { - return withAppContextDecorator(value, applicationContext); - } - return value; -}); - -const fakeData = - 'JVBERi0xLjEKJcKlwrHDqwoKMSAwIG9iagogIDw8IC9UeXBlIC9DYXRhbG9nCiAgICAgL1BhZ2VzIDIgMCBSCiAgPj4KZW5kb2JqCgoyIDAgb2JqCiAgPDwgL1R5cGUgL1BhZ2VzCiAgICAgL0tpZHMgWzMgMCBSXQogICAgIC9Db3VudCAxCiAgICAgL01lZGlhQm94IFswIDAgMzAwIDE0NF0KICA+PgplbmRvYmoKCjMgMCBvYmoKICA8PCAgL1R5cGUgL1BhZ2UKICAgICAgL1BhcmVudCAyIDAgUgogICAgICAvUmVzb3VyY2VzCiAgICAgICA8PCAvRm9udAogICAgICAgICAgIDw8IC9GMQogICAgICAgICAgICAgICA8PCAvVHlwZSAvRm9udAogICAgICAgICAgICAgICAgICAvU3VidHlwZSAvVHlwZTEKICAgICAgICAgICAgICAgICAgL0Jhc2VGb250IC9UaW1lcy1Sb21hbgogICAgICAgICAgICAgICA+PgogICAgICAgICAgID4+CiAgICAgICA+PgogICAgICAvQ29udGVudHMgNCAwIFIKICA+PgplbmRvYmoKCjQgMCBvYmoKICA8PCAvTGVuZ3RoIDg0ID4+CnN0cmVhbQogIEJUCiAgICAvRjEgMTggVGYKICAgIDUgODAgVGQKICAgIChDb25ncmF0aW9ucywgeW91IGZvdW5kIHRoZSBFYXN0ZXIgRWdnLikgVGoKICBFVAplbmRzdHJlYW0KZW5kb2JqCgp4cmVmCjAgNQowMDAwMDAwMDAwIDY1NTM1IGYgCjAwMDAwMDAwMTggMDAwMDAgbiAKMDAwMDAwMDA3NyAwMDAwMCBuIAowMDAwMDAwMTc4IDAwMDAwIG4gCjAwMDAwMDA0NTcgMDAwMDAgbiAKdHJhaWxlcgogIDw8ICAvUm9vdCAxIDAgUgogICAgICAvU2l6ZSA1CiAgPj4Kc3RhcnR4cmVmCjU2NQolJUVPRgo='; - -const fakeFile = Buffer.from(fakeData, 'base64'); -fakeFile.name = 'fakeFile.pdf'; - -const dom = new JSDOM(` - - -`); - -const { window } = dom; -const { Blob, File } = window; - -test = CerebralTest(presenter); +const test = setupTest(); describe('Create Docket Entry From Scans', () => { let scannerSourceIndex = 0; @@ -82,44 +22,18 @@ describe('Create Docket Entry From Scans', () => { beforeEach(() => { jest.setTimeout(30000); - global.alert = () => null; - global.URL = { - createObjectURL: () => { - return fakeData; - }, - revokeObjectURL: () => null, - }; - global.window = { - URL: global.URL, - document: {}, - localStorage: { - getItem: key => { - if (key === 'scannerSourceIndex') { - return `"${scannerSourceIndex}"`; - } - if (key === 'scannerSourceName') { - return `"${scannerSourceName}"`; - } + global.window.localStorage.getItem = key => { + if (key === 'scannerSourceIndex') { + return `"${scannerSourceIndex}"`; + } - return null; - }, - removeItem: () => null, - setItem: () => null, - }, - }; - - global.File = File; - global.Blob = Blob; + if (key === 'scannerSourceName') { + return `"${scannerSourceName}"`; + } - test.setState('constants', { - CASE_CAPTION_POSTFIX: Case.CASE_CAPTION_POSTFIX, - COUNTRY_TYPES: ContactFactory.COUNTRY_TYPES, - MAX_FILE_SIZE_MB, - PARTY_TYPES: ContactFactory.PARTY_TYPES, - TRIAL_CITIES: TrialSession.TRIAL_CITIES, - USER_ROLES: User.ROLES, - }); + return null; + }; }); loginAs(test, 'petitioner'); diff --git a/web-client/integration-tests/docketClerkEditsDocketEntryMeta.test.js b/web-client/integration-tests/docketClerkEditsDocketEntryMeta.test.js index 9d511e954ee..2b33b7793fc 100644 --- a/web-client/integration-tests/docketClerkEditsDocketEntryMeta.test.js +++ b/web-client/integration-tests/docketClerkEditsDocketEntryMeta.test.js @@ -7,7 +7,7 @@ import { docketClerkEditsDocketEntryMeta } from './journey/docketClerkEditsDocke import { docketClerkNavigatesToEditDocketEntryMeta } from './journey/docketClerkNavigatesToEditDocketEntryMeta'; import { docketClerkNavigatesToEditDocketEntryMetaCourtIssued } from './journey/docketClerkNavigatesToEditDocketEntryMetaCourtIssued'; import { docketClerkQCsDocketEntry } from './journey/docketClerkQCsDocketEntry'; -import { docketClerkServesOrder } from './journey/docketClerkServesOrder'; +import { docketClerkServesDocument } from './journey/docketClerkServesDocument'; import { docketClerkVerifiesDocketEntryMetaUpdates } from './journey/docketClerkVerifiesDocketEntryMetaUpdates'; import { docketClerkVerifiesEditCourtIssuedNonstandardFields } from './journey/docketClerkVerifiesEditCourtIssuedNonstandardFields'; @@ -54,7 +54,7 @@ describe("Docket Clerk Edits a Docket Entry's Meta", () => { expectedDocumentType: 'Order', }); docketClerkAddsDocketEntryFromOrder(test, 0); - docketClerkServesOrder(test, 0); + docketClerkServesDocument(test, 0); docketClerkNavigatesToEditDocketEntryMetaCourtIssued(test, 4); docketClerkEditsDocketEntryMetaCourtIssued(test); docketClerkVerifiesDocketEntryMetaCourtIssuedUpdates(test, 4); @@ -67,7 +67,7 @@ describe("Docket Clerk Edits a Docket Entry's Meta", () => { expectedDocumentType: 'Order of Dismissal', }); docketClerkAddsDocketEntryFromOrderOfDismissal(test, 1); - docketClerkServesOrder(test, 1); + docketClerkServesDocument(test, 1); docketClerkNavigatesToEditDocketEntryMetaCourtIssued(test, 5); docketClerkVerifiesEditCourtIssuedNonstandardFieldsWithJudge(test); }); diff --git a/web-client/integration-tests/docketClerkEditsPetitionPaymentFee.test.js b/web-client/integration-tests/docketClerkEditsPetitionPaymentFee.test.js index 623002fa1a3..d262c346f8b 100644 --- a/web-client/integration-tests/docketClerkEditsPetitionPaymentFee.test.js +++ b/web-client/integration-tests/docketClerkEditsPetitionPaymentFee.test.js @@ -1,4 +1,5 @@ import { Case } from '../../shared/src/business/entities/cases/Case'; +import { PAYMENT_STATUS } from '../../shared/src/business/entities/EntityConstants'; import { loginAs, setupTest, uploadPetition } from './helpers'; const test = setupTest(); @@ -26,7 +27,7 @@ describe('docket clerk edits a petition payment fee', () => { expect(test.getState('caseDetail.petitionPaymentDate')).toBeUndefined(); expect(test.getState('caseDetail.petitionPaymentStatus')).toEqual( - Case.PAYMENT_STATUS.UNPAID, + PAYMENT_STATUS.UNPAID, ); expect(test.getState('caseDetail.docketRecord')).not.toContainEqual({ description: 'Filing Fee Paid', @@ -37,7 +38,7 @@ describe('docket clerk edits a petition payment fee', () => { await test.runSequence('updateFormValueSequence', { key: 'petitionPaymentStatus', - value: Case.PAYMENT_STATUS.PAID, + value: PAYMENT_STATUS.PAID, }); await test.runSequence('updatePetitionDetailsSequence'); @@ -71,7 +72,7 @@ describe('docket clerk edits a petition payment fee', () => { expect(test.getState('validationErrors')).toEqual({}); expect(test.getState('caseDetail.petitionPaymentStatus')).toEqual( - Case.PAYMENT_STATUS.PAID, + PAYMENT_STATUS.PAID, ); expect(test.getState('caseDetail.petitionPaymentDate')).toEqual( '2001-01-01T05:00:00.000Z', diff --git a/web-client/integration-tests/docketClerkEditsPetitionerInformation.test.js b/web-client/integration-tests/docketClerkEditsPetitionerInformation.test.js index 8042886a567..798fbe837b4 100644 --- a/web-client/integration-tests/docketClerkEditsPetitionerInformation.test.js +++ b/web-client/integration-tests/docketClerkEditsPetitionerInformation.test.js @@ -1,4 +1,4 @@ -import { ContactFactory } from '../../shared/src/business/entities/contacts/ContactFactory'; +import { PARTY_TYPES } from '../../shared/src/business/entities/EntityConstants'; import { loginAs, setupTest, uploadPetition } from './helpers'; const test = setupTest(); @@ -23,7 +23,7 @@ describe('docket clerk edits the petitioner information', () => { postalCode: '77546', state: 'CT', }, - partyType: ContactFactory.PARTY_TYPES.petitionerSpouse, + partyType: PARTY_TYPES.petitionerSpouse, }); expect(caseDetail.docketNumber).toBeDefined(); test.docketNumber = caseDetail.docketNumber; diff --git a/web-client/integration-tests/docketClerkExternalDocumentQCWorkflow.test.js b/web-client/integration-tests/docketClerkExternalDocumentQCWorkflow.test.js index d73fab3b8a9..b1d11403d66 100644 --- a/web-client/integration-tests/docketClerkExternalDocumentQCWorkflow.test.js +++ b/web-client/integration-tests/docketClerkExternalDocumentQCWorkflow.test.js @@ -1,4 +1,4 @@ -import { ContactFactory } from '../../shared/src/business/entities/contacts/ContactFactory'; +import { PARTY_TYPES } from '../../shared/src/business/entities/EntityConstants'; import { assignWorkItems, findWorkItemByCaseId, @@ -50,7 +50,7 @@ describe('Create a work item', () => { postalCode: '77546', state: 'CT', }, - partyType: ContactFactory.PARTY_TYPES.petitionerSpouse, + partyType: PARTY_TYPES.petitionerSpouse, }); expect(caseDetail.docketNumber).toBeDefined(); }); diff --git a/web-client/integration-tests/docketClerkOrderAdvancedSearch.test.js b/web-client/integration-tests/docketClerkOrderAdvancedSearch.test.js index ef897eba8d2..243ebf9afac 100644 --- a/web-client/integration-tests/docketClerkOrderAdvancedSearch.test.js +++ b/web-client/integration-tests/docketClerkOrderAdvancedSearch.test.js @@ -3,7 +3,7 @@ import { docketClerkAddsDocketEntryFromOrder } from './journey/docketClerkAddsDo import { docketClerkAddsDocketEntryFromOrderOfDismissal } from './journey/docketClerkAddsDocketEntryFromOrderOfDismissal'; import { docketClerkCreatesAnOrder } from './journey/docketClerkCreatesAnOrder'; import { docketClerkSealsCase } from './journey/docketClerkSealsCase'; -import { docketClerkServesOrder } from './journey/docketClerkServesOrder'; +import { docketClerkServesDocument } from './journey/docketClerkServesDocument'; import { loginAs, refreshElasticsearchIndex, @@ -65,7 +65,7 @@ describe('docket clerk order advanced search', () => { signedAtFormatted: '01/02/2020', }); docketClerkAddsDocketEntryFromOrder(test, 0); - docketClerkServesOrder(test, 0); + docketClerkServesDocument(test, 0); docketClerkCreatesAnOrder(test, { documentTitle: 'Order of Dismissal', @@ -80,7 +80,7 @@ describe('docket clerk order advanced search', () => { expectedDocumentType: 'Order of Dismissal', }); docketClerkAddsDocketEntryFromOrderOfDismissal(test, 2); - docketClerkServesOrder(test, 2); + docketClerkServesDocument(test, 2); docketClerkCreatesAnOrder(test, { documentTitle: 'Order of something', @@ -88,7 +88,7 @@ describe('docket clerk order advanced search', () => { expectedDocumentType: 'Order', }); docketClerkAddsDocketEntryFromOrder(test, 3); - docketClerkServesOrder(test, 3); + docketClerkServesDocument(test, 3); docketClerkSealsCase(test); }); @@ -318,7 +318,7 @@ describe('docket clerk order advanced search', () => { await test.runSequence('submitOrderAdvancedSearchSequence'); - await wait(1000); + await wait(2000); expect(test.getState('searchResults')).toEqual( expect.arrayContaining([ diff --git a/web-client/integration-tests/docketClerkSealsCase.test.js b/web-client/integration-tests/docketClerkSealsCase.test.js index 2ee567200c1..c71e3555d73 100644 --- a/web-client/integration-tests/docketClerkSealsCase.test.js +++ b/web-client/integration-tests/docketClerkSealsCase.test.js @@ -1,9 +1,8 @@ -import { loginAs, setupTest, uploadPetition } from './helpers'; - -import { ContactFactory } from '../../shared/src/business/entities/contacts/ContactFactory'; +import { PARTY_TYPES } from '../../shared/src/business/entities/EntityConstants'; import { associatedUserAdvancedSearchForSealedCase } from './journey/associatedUserAdvancedSearchForSealedCase'; import { associatedUserViewsCaseDetailForSealedCase } from './journey/associatedUserViewsCaseDetailForSealedCase'; import { docketClerkSealsCase } from './journey/docketClerkSealsCase'; +import { loginAs, setupTest, uploadPetition } from './helpers'; import { petitionsClerkAddsPractitionersToCase } from './journey/petitionsClerkAddsPractitionersToCase'; import { petitionsClerkAddsRespondentsToCase } from './journey/petitionsClerkAddsRespondentsToCase'; import { petitionsClerkViewsCaseDetail } from './journey/petitionsClerkViewsCaseDetail'; @@ -30,7 +29,7 @@ describe('Docket Clerk seals a case', () => { postalCode: '77546', state: 'CT', }, - partyType: ContactFactory.PARTY_TYPES.petitionerSpouse, + partyType: PARTY_TYPES.petitionerSpouse, }); expect(caseDetail.docketNumber).toBeDefined(); test.docketNumber = caseDetail.docketNumber; diff --git a/web-client/integration-tests/docketClerkServesCourtIssuedDocument.test.js b/web-client/integration-tests/docketClerkServesCourtIssuedDocument.test.js index 14fd3bb9b88..ef5250968f4 100644 --- a/web-client/integration-tests/docketClerkServesCourtIssuedDocument.test.js +++ b/web-client/integration-tests/docketClerkServesCourtIssuedDocument.test.js @@ -5,7 +5,7 @@ import { docketClerkAddsDocketEntryFromOrder } from './journey/docketClerkAddsDo import { docketClerkAddsDocketEntryFromOrderOfDismissal } from './journey/docketClerkAddsDocketEntryFromOrderOfDismissal'; import { docketClerkCancelsAddDocketEntryFromOrder } from './journey/docketClerkCancelsAddDocketEntryFromOrder'; import { docketClerkCreatesAnOrder } from './journey/docketClerkCreatesAnOrder'; -import { docketClerkServesOrder } from './journey/docketClerkServesOrder'; +import { docketClerkServesDocument } from './journey/docketClerkServesDocument'; import { docketClerkViewsCaseDetailAfterServingCourtIssuedDocument } from './journey/docketClerkViewsCaseDetailAfterServingCourtIssuedDocument'; import { docketClerkViewsCaseDetailForCourtIssuedDocketEntry } from './journey/docketClerkViewsCaseDetailForCourtIssuedDocketEntry'; import { docketClerkViewsDraftOrder } from './journey/docketClerkViewsDraftOrder'; @@ -61,8 +61,8 @@ describe('Docket Clerk Adds Court-Issued Order to Docket Record', () => { docketClerkViewsCaseDetailForCourtIssuedDocketEntry(test); docketClerkViewsSavedCourtIssuedDocketEntryInProgress(test, 1); docketClerkViewsCaseDetailForCourtIssuedDocketEntry(test); - docketClerkServesOrder(test, 0); + docketClerkServesDocument(test, 0); docketClerkViewsCaseDetailAfterServingCourtIssuedDocument(test, 0); - docketClerkServesOrder(test, 1); + docketClerkServesDocument(test, 1); docketClerkViewsCaseDetailAfterServingCourtIssuedDocument(test, 1); }); diff --git a/web-client/integration-tests/docketClerkServesCourtIssuedDocumentForPaperCase.test.js b/web-client/integration-tests/docketClerkServesCourtIssuedDocumentForPaperCase.test.js index 1811eb75a9c..c09375c9465 100644 --- a/web-client/integration-tests/docketClerkServesCourtIssuedDocumentForPaperCase.test.js +++ b/web-client/integration-tests/docketClerkServesCourtIssuedDocumentForPaperCase.test.js @@ -1,4 +1,4 @@ -import { Case } from '../../shared/src/business/entities/cases/Case'; +import { CASE_STATUS_TYPES } from '../../shared/src/business/entities/EntityConstants'; import { fakeFile, loginAs, setupTest } from './helpers'; // docketClerk @@ -42,6 +42,6 @@ describe('Docket Clerk Adds Court-Issued Order to Docket Record', () => { docketClerkViewsCaseDetailAfterServingCourtIssuedDocument( test, 0, - Case.STATUS_TYPES.generalDocket, + CASE_STATUS_TYPES.generalDocket, ); }); diff --git a/web-client/integration-tests/docketClerkUpdatesDocketEntries.test.js b/web-client/integration-tests/docketClerkUpdatesDocketEntries.test.js index 1de7bba48f9..bdc48d3813c 100644 --- a/web-client/integration-tests/docketClerkUpdatesDocketEntries.test.js +++ b/web-client/integration-tests/docketClerkUpdatesDocketEntries.test.js @@ -1,4 +1,4 @@ -import { ContactFactory } from '../../shared/src/business/entities/contacts/ContactFactory'; +import { PARTY_TYPES } from '../../shared/src/business/entities/EntityConstants'; import { docketClerkAddsDocketEntryWithoutFile } from './journey/docketClerkAddsDocketEntryWithoutFile'; import { docketClerkEditsDocketEntryNonstandardA } from './journey/docketClerkEditsDocketEntryNonstandardA'; import { docketClerkEditsDocketEntryNonstandardB } from './journey/docketClerkEditsDocketEntryNonstandardB'; @@ -32,7 +32,7 @@ describe('docket clerk updates docket entries', () => { postalCode: '77546', state: 'AZ', }, - partyType: ContactFactory.PARTY_TYPES.petitionerSpouse, + partyType: PARTY_TYPES.petitionerSpouse, }); expect(caseDetail.docketNumber).toBeDefined(); test.docketNumber = caseDetail.docketNumber; diff --git a/web-client/integration-tests/documentServiceEmailSentOnServe.test.js b/web-client/integration-tests/documentServiceEmailSentOnServe.test.js index 3ee6091ea07..449571e44a8 100644 --- a/web-client/integration-tests/documentServiceEmailSentOnServe.test.js +++ b/web-client/integration-tests/documentServiceEmailSentOnServe.test.js @@ -7,7 +7,7 @@ import { import { docketClerkAddsDocketEntryFromOrder } from './journey/docketClerkAddsDocketEntryFromOrder'; import { docketClerkCreatesAnOrder } from './journey/docketClerkCreatesAnOrder'; -import { docketClerkServesOrder } from './journey/docketClerkServesOrder'; +import { docketClerkServesDocument } from './journey/docketClerkServesDocument'; import { docketClerkViewsCaseDetailForCourtIssuedDocketEntry } from './journey/docketClerkViewsCaseDetailForCourtIssuedDocketEntry'; import { docketClerkViewsDraftOrder } from './journey/docketClerkViewsDraftOrder'; @@ -38,7 +38,7 @@ describe.skip('Document Service Email Sent on Serve', () => { docketClerkViewsCaseDetailForCourtIssuedDocketEntry(test); docketClerkViewsDraftOrder(test, 0); docketClerkAddsDocketEntryFromOrder(test, 0); - docketClerkServesOrder(test, 0); + docketClerkServesDocument(test, 0); it('should send the expected emails for parties', async () => { const emails = await getEmailsForAddress('petitioner'); diff --git a/web-client/integration-tests/externalUserOrderAdvancedSearch.test.js b/web-client/integration-tests/externalUserOrderAdvancedSearch.test.js index 923f866bd78..351106a3b3f 100644 --- a/web-client/integration-tests/externalUserOrderAdvancedSearch.test.js +++ b/web-client/integration-tests/externalUserOrderAdvancedSearch.test.js @@ -2,7 +2,7 @@ import { associatedUserSearchesForServedOrder } from './journey/associatedUserSe import { docketClerkAddsDocketEntryFromOrder } from './journey/docketClerkAddsDocketEntryFromOrder'; import { docketClerkCreatesAnOrder } from './journey/docketClerkCreatesAnOrder'; import { docketClerkSealsCase } from './journey/docketClerkSealsCase'; -import { docketClerkServesOrder } from './journey/docketClerkServesOrder'; +import { docketClerkServesDocument } from './journey/docketClerkServesDocument'; import { loginAs, refreshElasticsearchIndex, @@ -47,7 +47,7 @@ describe('external users perform an advanced search for orders', () => { expectedDocumentType: 'Order', }); docketClerkAddsDocketEntryFromOrder(test, 0); - docketClerkServesOrder(test, 0); + docketClerkServesDocument(test, 0); it('refresh elasticsearch index', async () => { await refreshElasticsearchIndex(); }); diff --git a/web-client/integration-tests/externalUserViewsOpenAndClosedCases.test.js b/web-client/integration-tests/externalUserViewsOpenAndClosedCases.test.js new file mode 100644 index 00000000000..8dacba4c4f2 --- /dev/null +++ b/web-client/integration-tests/externalUserViewsOpenAndClosedCases.test.js @@ -0,0 +1,33 @@ +import { docketClerkUpdatesCaseStatusToClosed } from './journey/docketClerkUpdatesCaseStatusToClosed'; +import { irsPractitionerViewsOpenAndClosedCases } from './journey/irsPractitionerViewsOpenAndClosedCases'; +import { loginAs, setupTest, uploadPetition } from './helpers'; +import { petitionerViewsOpenAndClosedCases } from './journey/petitionerViewsOpenAndClosedCases'; +import { privatePractitionerViewsOpenAndClosedCases } from './journey/privatePractitionerViewsOpenClosedCases'; + +const test = setupTest(); + +describe('external user views open and closed cases', () => { + beforeAll(() => { + jest.setTimeout(30000); + loginAs(test, 'docketclerk'); + }); + + loginAs(test, 'petitioner'); + it('login as a petitioner and create the case to close', async () => { + const caseDetail = await uploadPetition(test); + expect(caseDetail.docketNumber).toBeDefined(); + test.docketNumber = caseDetail.docketNumber; + }); + + loginAs(test, 'docketclerk'); + docketClerkUpdatesCaseStatusToClosed(test); + + loginAs(test, 'petitioner'); + petitionerViewsOpenAndClosedCases(test); + + loginAs(test, 'privatePractitioner'); + privatePractitionerViewsOpenAndClosedCases(test); + + loginAs(test, 'irsPractitioner'); + irsPractitionerViewsOpenAndClosedCases(test); +}); diff --git a/web-client/integration-tests/helpers.js b/web-client/integration-tests/helpers.js index dbf5ab39427..f5cf2473bec 100644 --- a/web-client/integration-tests/helpers.js +++ b/web-client/integration-tests/helpers.js @@ -1,6 +1,8 @@ /* eslint-disable jest/no-export */ -import { CerebralTest } from 'cerebral/test'; +import { CerebralTest, runCompute } from 'cerebral/test'; +import { DynamoDB } from 'aws-sdk'; import { JSDOM } from 'jsdom'; +import { PARTY_TYPES } from '../../shared/src/business/entities/EntityConstants'; import { applicationContext } from '../src/applicationContext'; import { back, @@ -10,8 +12,6 @@ import { revokeObjectURL, router, } from '../src/router'; - -import { DynamoDB } from 'aws-sdk'; import { formattedWorkQueue as formattedWorkQueueComputed } from '../src/presenter/computeds/formattedWorkQueue'; import { getScannerInterface } from '../../shared/src/persistence/dynamsoft/getScannerMockInterface'; import { @@ -20,7 +20,6 @@ import { } from '../../shared/src/business/useCases/scannerMockFiles'; import { isFunction, mapValues } from 'lodash'; import { presenter } from '../src/presenter/presenter'; -import { runCompute } from 'cerebral/test'; import { socketProvider } from '../src/providers/socket'; import { socketRouter } from '../src/providers/socketRouter'; import { userMap } from '../../shared/src/test/mockUserTokenMap'; @@ -31,9 +30,6 @@ import axios from 'axios'; import { workQueueHelper as workQueueHelperComputed } from '../src/presenter/computeds/workQueueHelper'; import FormData from 'form-data'; -const { - ContactFactory, -} = require('../../shared/src/business/entities/contacts/ContactFactory'); const formattedWorkQueue = withAppContextDecorator(formattedWorkQueueComputed); const workQueueHelper = withAppContextDecorator(workQueueHelperComputed); @@ -384,7 +380,7 @@ export const uploadPetition = async ( contactSecondary: overrides.contactSecondary || {}, filingType: 'Myself', hasIrsNotice: false, - partyType: overrides.partyType || ContactFactory.PARTY_TYPES.petitioner, + partyType: overrides.partyType || PARTY_TYPES.petitioner, preferredTrialCity: overrides.preferredTrialCity || 'Seattle, Washington', procedureType: overrides.procedureType || 'Regular', }; @@ -562,6 +558,7 @@ export const setupTest = ({ useCases = {} } = {}) => { export const gotoRoute = (routes, routeToGoTo) => { for (let route of routes) { + // eslint-disable-next-line security/detect-non-literal-regexp const regex = new RegExp( route.route.replace(/\*/g, '([a-z\\-A-Z0-9]+)').replace(/\.\./g, '(.*)') + '$', diff --git a/web-client/integration-tests/journey/captureCreatedCase.js b/web-client/integration-tests/journey/captureCreatedCase.js index 3d8a2bd21e2..0374a5bd230 100644 --- a/web-client/integration-tests/journey/captureCreatedCase.js +++ b/web-client/integration-tests/journey/captureCreatedCase.js @@ -5,7 +5,7 @@ export const captureCreatedCase = ( ) => { return it('Capture Created Case', async () => { await test.runSequence('gotoDashboardSequence'); - createdCases.push(`${test.getState('cases.0.caseId')}`); - createdDocketNumbers.push(`${test.getState('cases.0.docketNumber')}`); + createdCases.push(`${test.getState('openCases.0.caseId')}`); + createdDocketNumbers.push(`${test.getState('openCases.0.docketNumber')}`); }); }; diff --git a/web-client/integration-tests/journey/chambersUserViewsCaseDetail.js b/web-client/integration-tests/journey/chambersUserViewsCaseDetail.js index e851aae20f7..676d90a3248 100644 --- a/web-client/integration-tests/journey/chambersUserViewsCaseDetail.js +++ b/web-client/integration-tests/journey/chambersUserViewsCaseDetail.js @@ -1,4 +1,7 @@ -import { Case } from '../../../shared/src/business/entities/cases/Case'; +import { + CASE_STATUS_TYPES, + CHIEF_JUDGE, +} from '../../../shared/src/business/entities/EntityConstants'; export const chambersUserViewsCaseDetail = ( test, @@ -13,12 +16,10 @@ export const chambersUserViewsCaseDetail = ( expect(test.getState('currentPage')).toEqual('CaseDetailInternal'); expect(test.getState('caseDetail.docketNumber')).toEqual(test.docketNumber); - expect(test.getState('caseDetail.status')).toEqual(Case.STATUS_TYPES.new); + expect(test.getState('caseDetail.status')).toEqual(CASE_STATUS_TYPES.new); expect(test.getState('caseDetail.documents').length).toEqual( expectedDocumentCount, ); - expect(test.getState('caseDetail.associatedJudge')).toEqual( - Case.CHIEF_JUDGE, - ); + expect(test.getState('caseDetail.associatedJudge')).toEqual(CHIEF_JUDGE); }); }; diff --git a/web-client/integration-tests/journey/chambersUserViewsCaseDetailAfterAddingOrder.js b/web-client/integration-tests/journey/chambersUserViewsCaseDetailAfterAddingOrder.js index 9c4e9dc8829..f65e6c19220 100644 --- a/web-client/integration-tests/journey/chambersUserViewsCaseDetailAfterAddingOrder.js +++ b/web-client/integration-tests/journey/chambersUserViewsCaseDetailAfterAddingOrder.js @@ -1,4 +1,4 @@ -import { Case } from '../../../shared/src/business/entities/cases/Case'; +import { CASE_STATUS_TYPES } from '../../../shared/src/business/entities/EntityConstants'; export const chambersUserViewsCaseDetailAfterAddingOrder = test => { return it('Chambers user views case detail after adding order', async () => { @@ -10,7 +10,7 @@ export const chambersUserViewsCaseDetailAfterAddingOrder = test => { expect(test.getState('currentPage')).toEqual('CaseDetailInternal'); expect(test.getState('caseDetail.docketNumber')).toEqual(test.docketNumber); - expect(test.getState('caseDetail.status')).toEqual(Case.STATUS_TYPES.new); + expect(test.getState('caseDetail.status')).toEqual(CASE_STATUS_TYPES.new); expect(test.getState('caseDetail.documents').length).toEqual(3); expect( test diff --git a/web-client/integration-tests/journey/docketClerkAddsDocketEntryFromOrderOfDismissal.js b/web-client/integration-tests/journey/docketClerkAddsDocketEntryFromOrderOfDismissal.js index 7071da58c0f..99932332636 100644 --- a/web-client/integration-tests/journey/docketClerkAddsDocketEntryFromOrderOfDismissal.js +++ b/web-client/integration-tests/journey/docketClerkAddsDocketEntryFromOrderOfDismissal.js @@ -40,7 +40,7 @@ export const docketClerkAddsDocketEntryFromOrderOfDismissal = ( expect(test.getState('form.eventCode')).toEqual('OD'); expect(test.getState('form.documentType')).toEqual( - 'OD - Order of Dismissal Entered,', + 'OD - Order of Dismissal Entered', ); expect(helperComputed.showJudge).toBeTruthy(); expect(test.getState('form.judge')).toBeFalsy(); diff --git a/web-client/integration-tests/journey/docketClerkEditsDocketEntryFromOrderTypeB.js b/web-client/integration-tests/journey/docketClerkConvertsAnOrderToAnOpinion.js similarity index 98% rename from web-client/integration-tests/journey/docketClerkEditsDocketEntryFromOrderTypeB.js rename to web-client/integration-tests/journey/docketClerkConvertsAnOrderToAnOpinion.js index 20a5a4ea3b7..9b75a7ed2b1 100644 --- a/web-client/integration-tests/journey/docketClerkEditsDocketEntryFromOrderTypeB.js +++ b/web-client/integration-tests/journey/docketClerkConvertsAnOrderToAnOpinion.js @@ -3,7 +3,7 @@ import { formattedCaseDetail } from '../../src/presenter/computeds/formattedCase import { runCompute } from 'cerebral/test'; import { withAppContextDecorator } from '../../src/withAppContext'; -export const docketClerkEditsDocketEntryFromOrderTypeB = ( +export const docketClerkConvertsAnOrderToAnOpinion = ( test, draftOrderIndex, ) => { diff --git a/web-client/integration-tests/journey/docketClerkEditsServiceIndicatorForPetitioner.js b/web-client/integration-tests/journey/docketClerkEditsServiceIndicatorForPetitioner.js index b90c3d16205..fa6c6f550aa 100644 --- a/web-client/integration-tests/journey/docketClerkEditsServiceIndicatorForPetitioner.js +++ b/web-client/integration-tests/journey/docketClerkEditsServiceIndicatorForPetitioner.js @@ -1,4 +1,4 @@ -import { SERVICE_INDICATOR_TYPES } from '../../../shared/src/business/entities/cases/CaseConstants'; +import { SERVICE_INDICATOR_TYPES } from '../../../shared/src/business/entities/EntityConstants'; export const docketClerkEditsServiceIndicatorForPetitioner = test => { return it('docket clerk edits service indicator for a petitioner', async () => { diff --git a/web-client/integration-tests/journey/docketClerkEditsServiceIndicatorForPractitioner.js b/web-client/integration-tests/journey/docketClerkEditsServiceIndicatorForPractitioner.js index 26dae8ab341..c5d9d2d0926 100644 --- a/web-client/integration-tests/journey/docketClerkEditsServiceIndicatorForPractitioner.js +++ b/web-client/integration-tests/journey/docketClerkEditsServiceIndicatorForPractitioner.js @@ -1,4 +1,4 @@ -import { SERVICE_INDICATOR_TYPES } from '../../../shared/src/business/entities/cases/CaseConstants'; +import { SERVICE_INDICATOR_TYPES } from '../../../shared/src/business/entities/EntityConstants'; export const docketClerkEditsServiceIndicatorForPractitioner = test => { return it('docket clerk edits service indicator for a practitioner', async () => { diff --git a/web-client/integration-tests/journey/docketClerkEditsServiceIndicatorForRespondent.js b/web-client/integration-tests/journey/docketClerkEditsServiceIndicatorForRespondent.js index b1d4942d664..310f19ad0ae 100644 --- a/web-client/integration-tests/journey/docketClerkEditsServiceIndicatorForRespondent.js +++ b/web-client/integration-tests/journey/docketClerkEditsServiceIndicatorForRespondent.js @@ -1,4 +1,4 @@ -import { SERVICE_INDICATOR_TYPES } from '../../../shared/src/business/entities/cases/CaseConstants'; +import { SERVICE_INDICATOR_TYPES } from '../../../shared/src/business/entities/EntityConstants'; export const docketClerkEditsServiceIndicatorForRespondent = test => { return it('docket clerk edits service indicator for a respondent', async () => { diff --git a/web-client/integration-tests/journey/docketClerkServesOrder.js b/web-client/integration-tests/journey/docketClerkServesDocument.js similarity index 93% rename from web-client/integration-tests/journey/docketClerkServesOrder.js rename to web-client/integration-tests/journey/docketClerkServesDocument.js index dae03a377a9..edbc00ec9b3 100644 --- a/web-client/integration-tests/journey/docketClerkServesOrder.js +++ b/web-client/integration-tests/journey/docketClerkServesDocument.js @@ -2,7 +2,7 @@ import { formattedCaseDetail } from '../../src/presenter/computeds/formattedCase import { runCompute } from 'cerebral/test'; import { withAppContextDecorator } from '../../src/withAppContext'; -export const docketClerkServesOrder = (test, draftOrderIndex) => { +export const docketClerkServesDocument = (test, draftOrderIndex) => { return it(`Docket Clerk serves the order after the docket entry has been created ${draftOrderIndex}`, async () => { let caseDetailFormatted; diff --git a/web-client/integration-tests/journey/docketClerkSetsCaseReadyForTrial.js b/web-client/integration-tests/journey/docketClerkSetsCaseReadyForTrial.js index 8777425cadd..13e27d0878b 100644 --- a/web-client/integration-tests/journey/docketClerkSetsCaseReadyForTrial.js +++ b/web-client/integration-tests/journey/docketClerkSetsCaseReadyForTrial.js @@ -1,4 +1,6 @@ -const { Case } = require('../../../shared/src/business/entities/cases/Case'); +const { + CASE_STATUS_TYPES, +} = require('../../../shared/src/business/entities/EntityConstants'); export const docketClerkSetsCaseReadyForTrial = test => { return it('Docket clerk sets a case ready for trial', async () => { @@ -8,21 +10,21 @@ export const docketClerkSetsCaseReadyForTrial = test => { }); expect(test.getState('caseDetail.docketNumber')).toEqual(test.docketNumber); expect(test.getState('caseDetail.status')).toEqual( - Case.STATUS_TYPES.generalDocket, + CASE_STATUS_TYPES.generalDocket, ); await test.runSequence('openUpdateCaseModalSequence'); await test.runSequence('updateModalValueSequence', { key: 'caseStatus', - value: Case.STATUS_TYPES.generalDocketReadyForTrial, + value: CASE_STATUS_TYPES.generalDocketReadyForTrial, }); await test.runSequence('submitUpdateCaseModalSequence'); expect(test.getState('caseDetail.docketNumber')).toEqual(test.docketNumber); expect(test.getState('caseDetail.status')).toEqual( - Case.STATUS_TYPES.generalDocketReadyForTrial, + CASE_STATUS_TYPES.generalDocketReadyForTrial, ); if (test.casesReadyForTrial) { diff --git a/web-client/integration-tests/journey/docketClerkUpdatesCaseStatusFromCalendaredToSubmitted.js b/web-client/integration-tests/journey/docketClerkUpdatesCaseStatusFromCalendaredToSubmitted.js index 4c7a3a95c6a..407cbad0ced 100644 --- a/web-client/integration-tests/journey/docketClerkUpdatesCaseStatusFromCalendaredToSubmitted.js +++ b/web-client/integration-tests/journey/docketClerkUpdatesCaseStatusFromCalendaredToSubmitted.js @@ -1,4 +1,4 @@ -import { Case } from '../../../shared/src/business/entities/cases/Case'; +import { CASE_STATUS_TYPES } from '../../../shared/src/business/entities/EntityConstants'; export const docketClerkUpdatesCaseStatusFromCalendaredToSubmitted = test => { return it('Docket clerk updates case status from Calendared to Submitted with an associated judge', async () => { @@ -9,7 +9,7 @@ export const docketClerkUpdatesCaseStatusFromCalendaredToSubmitted = test => { }); expect(test.getState('caseDetail.status')).toEqual( - Case.STATUS_TYPES.calendared, + CASE_STATUS_TYPES.calendared, ); await test.runSequence('openUpdateCaseModalSequence'); @@ -17,16 +17,16 @@ export const docketClerkUpdatesCaseStatusFromCalendaredToSubmitted = test => { expect(test.getState('modal.showModal')).toEqual('UpdateCaseModalDialog'); expect(test.getState('modal.caseStatus')).toEqual( - Case.STATUS_TYPES.calendared, + CASE_STATUS_TYPES.calendared, ); await test.runSequence('updateModalValueSequence', { key: 'caseStatus', - value: Case.STATUS_TYPES.submitted, + value: CASE_STATUS_TYPES.submitted, }); expect(test.getState('modal.caseStatus')).toEqual( - Case.STATUS_TYPES.submitted, + CASE_STATUS_TYPES.submitted, ); // the current judge on the case is selected by default. @@ -53,7 +53,7 @@ export const docketClerkUpdatesCaseStatusFromCalendaredToSubmitted = test => { expect(test.getState('validationErrors')).toEqual({}); expect(test.getState('caseDetail.status')).toEqual( - Case.STATUS_TYPES.submitted, + CASE_STATUS_TYPES.submitted, ); expect(test.getState('caseDetail.associatedJudge')).toEqual('Judge Buch'); expect(test.getState('modal')).toEqual({}); diff --git a/web-client/integration-tests/journey/docketClerkUpdatesCaseStatusToClosed.js b/web-client/integration-tests/journey/docketClerkUpdatesCaseStatusToClosed.js new file mode 100644 index 00000000000..11a1e277d65 --- /dev/null +++ b/web-client/integration-tests/journey/docketClerkUpdatesCaseStatusToClosed.js @@ -0,0 +1,35 @@ +import { CASE_STATUS_TYPES } from '../../../shared/src/business/entities/EntityConstants'; +import { refreshElasticsearchIndex } from '../helpers'; + +export const docketClerkUpdatesCaseStatusToClosed = test => { + return it('Docket clerk updates case status to closed', async () => { + test.setState('caseDetail', {}); + + await test.runSequence('gotoCaseDetailSequence', { + docketNumber: test.docketNumber, + }); + + const currentStatus = test.getState('caseDetail.status'); + + await test.runSequence('openUpdateCaseModalSequence'); + + expect(test.getState('modal.showModal')).toEqual('UpdateCaseModalDialog'); + + expect(test.getState('modal.caseStatus')).toEqual(currentStatus); + + await test.runSequence('updateModalValueSequence', { + key: 'caseStatus', + value: CASE_STATUS_TYPES.closed, + }); + + await test.runSequence('submitUpdateCaseModalSequence'); + + await refreshElasticsearchIndex(); + + expect(test.getState('caseDetail.status')).toEqual( + CASE_STATUS_TYPES.closed, + ); + + expect(test.getState('modal')).toEqual({}); + }); +}; diff --git a/web-client/integration-tests/journey/docketClerkUpdatesCaseStatusToReadyForTrial.js b/web-client/integration-tests/journey/docketClerkUpdatesCaseStatusToReadyForTrial.js index 41b5c5fbd3e..40ca168a127 100644 --- a/web-client/integration-tests/journey/docketClerkUpdatesCaseStatusToReadyForTrial.js +++ b/web-client/integration-tests/journey/docketClerkUpdatesCaseStatusToReadyForTrial.js @@ -1,4 +1,7 @@ -import { Case } from '../../../shared/src/business/entities/cases/Case'; +import { + CASE_STATUS_TYPES, + CHIEF_JUDGE, +} from '../../../shared/src/business/entities/EntityConstants'; export const docketClerkUpdatesCaseStatusToReadyForTrial = test => { return it('Docket clerk updates case status to General Docket - At Issue (Ready for Trial)', async () => { @@ -18,7 +21,7 @@ export const docketClerkUpdatesCaseStatusToReadyForTrial = test => { await test.runSequence('updateModalValueSequence', { key: 'caseStatus', - value: Case.STATUS_TYPES.generalDocket, + value: CASE_STATUS_TYPES.generalDocket, }); await test.runSequence('clearModalSequence'); @@ -33,17 +36,15 @@ export const docketClerkUpdatesCaseStatusToReadyForTrial = test => { await test.runSequence('updateModalValueSequence', { key: 'caseStatus', - value: Case.STATUS_TYPES.generalDocketReadyForTrial, + value: CASE_STATUS_TYPES.generalDocketReadyForTrial, }); await test.runSequence('submitUpdateCaseModalSequence'); expect(test.getState('caseDetail.status')).toEqual( - Case.STATUS_TYPES.generalDocketReadyForTrial, - ); - expect(test.getState('caseDetail.associatedJudge')).toEqual( - Case.CHIEF_JUDGE, + CASE_STATUS_TYPES.generalDocketReadyForTrial, ); + expect(test.getState('caseDetail.associatedJudge')).toEqual(CHIEF_JUDGE); expect(test.getState('modal')).toEqual({}); }); }; diff --git a/web-client/integration-tests/journey/docketClerkViewsCaseDetailAfterServingCourtIssuedDocument.js b/web-client/integration-tests/journey/docketClerkViewsCaseDetailAfterServingCourtIssuedDocument.js index ef86757fc78..cc4ed74bba5 100644 --- a/web-client/integration-tests/journey/docketClerkViewsCaseDetailAfterServingCourtIssuedDocument.js +++ b/web-client/integration-tests/journey/docketClerkViewsCaseDetailAfterServingCourtIssuedDocument.js @@ -1,4 +1,4 @@ -import { Case } from '../../../shared/src/business/entities/cases/Case'; +import { CASE_STATUS_TYPES } from '../../../shared/src/business/entities/EntityConstants'; export const docketClerkViewsCaseDetailAfterServingCourtIssuedDocument = ( test, @@ -20,10 +20,10 @@ export const docketClerkViewsCaseDetailAfterServingCourtIssuedDocument = ( if (expectedCaseStatus) { expect(test.getState('caseDetail.status')).toEqual(expectedCaseStatus); } else if (orderDocument.eventCode === 'O') { - expect(test.getState('caseDetail.status')).toEqual(Case.STATUS_TYPES.new); + expect(test.getState('caseDetail.status')).toEqual(CASE_STATUS_TYPES.new); } else { expect(test.getState('caseDetail.status')).toEqual( - Case.STATUS_TYPES.closed, + CASE_STATUS_TYPES.closed, ); expect(test.getState('caseDetail.highPriority')).toEqual(false); } diff --git a/web-client/integration-tests/journey/docketClerkViewsInactiveCasesForTrialSession.js b/web-client/integration-tests/journey/docketClerkViewsInactiveCasesForTrialSession.js index 74a7dbf72af..f311e3f6235 100644 --- a/web-client/integration-tests/journey/docketClerkViewsInactiveCasesForTrialSession.js +++ b/web-client/integration-tests/journey/docketClerkViewsInactiveCasesForTrialSession.js @@ -1,4 +1,4 @@ -import { Case } from '../../../shared/src/business/entities/cases/Case'; +import { CASE_STATUS_TYPES } from '../../../shared/src/business/entities/EntityConstants'; import { formattedTrialSessionDetails as formattedTrialSessionDetailsComputed } from '../../src/presenter/computeds/formattedTrialSessionDetails'; import { runCompute } from 'cerebral/test'; import { withAppContextDecorator } from '../../src/withAppContext'; @@ -25,7 +25,7 @@ export const docketClerkViewsInactiveCasesForTrialSession = test => { test.caseId, ); expect(trialSessionDetailsFormatted.inactiveCases[0].disposition).toEqual( - `Status was changed to ${Case.STATUS_TYPES.submitted}`, + `Status was changed to ${CASE_STATUS_TYPES.submitted}`, ); }); }; diff --git a/web-client/integration-tests/journey/irsPractitionerViewsOpenAndClosedCases.js b/web-client/integration-tests/journey/irsPractitionerViewsOpenAndClosedCases.js new file mode 100644 index 00000000000..4099c6ced3c --- /dev/null +++ b/web-client/integration-tests/journey/irsPractitionerViewsOpenAndClosedCases.js @@ -0,0 +1,13 @@ +import { refreshElasticsearchIndex } from '../helpers'; + +export const irsPractitionerViewsOpenAndClosedCases = test => { + return it('irs practitoner views open and closed cases', async () => { + await refreshElasticsearchIndex(); + + await test.runSequence('gotoDashboardSequence'); + + expect(test.getState('currentPage')).toEqual('DashboardRespondent'); + expect(test.getState('openCases').length).toBeGreaterThan(0); + expect(test.getState('closedCases').length).toBeGreaterThan(0); + }); +}; diff --git a/web-client/integration-tests/journey/irsSuperuserAdvancedSearchForCase.js b/web-client/integration-tests/journey/irsSuperuserAdvancedSearchForCase.js index baa8850828b..1d1c780b008 100644 --- a/web-client/integration-tests/journey/irsSuperuserAdvancedSearchForCase.js +++ b/web-client/integration-tests/journey/irsSuperuserAdvancedSearchForCase.js @@ -1,5 +1,5 @@ +import { COUNTRY_TYPES } from '../../../shared/src/business/entities/EntityConstants'; import { CaseSearch } from '../../../shared/src/business/entities/cases/CaseSearch'; -import { ContactFactory } from '../../../shared/src/business/entities/contacts/ContactFactory'; import { refreshElasticsearchIndex } from '../helpers'; export const irsSuperuserAdvancedSearchForCase = test => { @@ -50,7 +50,7 @@ export const irsSuperuserAdvancedSearchForCase = test => { await test.runSequence('updateAdvancedSearchFormValueSequence', { formType: 'caseSearchByName', key: 'countryType', - value: ContactFactory.COUNTRY_TYPES.INTERNATIONAL, + value: COUNTRY_TYPES.INTERNATIONAL, }); await test.runSequence('submitCaseAdvancedSearchSequence'); diff --git a/web-client/integration-tests/journey/petitionerCreatesNewCase.js b/web-client/integration-tests/journey/petitionerCreatesNewCase.js index 0978f0ac21a..ac90069b4bd 100644 --- a/web-client/integration-tests/journey/petitionerCreatesNewCase.js +++ b/web-client/integration-tests/journey/petitionerCreatesNewCase.js @@ -122,6 +122,6 @@ export const petitionerCreatesNewCase = (test, fakeFile, overrides = {}) => { expect(test.getState('currentPage')).toBe('DashboardPetitioner'); - test.docketNumber = test.getState('cases.0.docketNumber'); + test.docketNumber = test.getState('openCases.0.docketNumber'); }); }; diff --git a/web-client/integration-tests/journey/petitionerCreatesNewCaseTestAllOptions.js b/web-client/integration-tests/journey/petitionerCreatesNewCaseTestAllOptions.js index df3f9b5d321..6a3787b5488 100644 --- a/web-client/integration-tests/journey/petitionerCreatesNewCaseTestAllOptions.js +++ b/web-client/integration-tests/journey/petitionerCreatesNewCaseTestAllOptions.js @@ -1,5 +1,5 @@ import { Case } from '../../../shared/src/business/entities/cases/Case'; -import { ContactFactory } from '../../../shared/src/business/entities/contacts/ContactFactory'; +import { PARTY_TYPES } from '../../../shared/src/business/entities/EntityConstants'; import { runCompute } from 'cerebral/test'; import { startCaseHelper as startCaseHelperComputed } from '../../src/presenter/computeds/startCaseHelper'; import { withAppContextDecorator } from '../../src/withAppContext'; @@ -282,7 +282,7 @@ export const petitionerCreatesNewCaseTestAllOptions = ( await test.runSequence('updateStartCaseFormValueSequence', { key: 'businessType', - value: ContactFactory.PARTY_TYPES.partnershipOtherThanTaxMatters, + value: PARTY_TYPES.partnershipOtherThanTaxMatters, }); result = runCompute(startCaseHelper, { @@ -304,7 +304,7 @@ export const petitionerCreatesNewCaseTestAllOptions = ( await test.runSequence('updateStartCaseFormValueSequence', { key: 'businessType', - value: ContactFactory.PARTY_TYPES.partnershipBBA, + value: PARTY_TYPES.partnershipBBA, }); result = runCompute(startCaseHelper, { @@ -338,7 +338,7 @@ export const petitionerCreatesNewCaseTestAllOptions = ( await test.runSequence('updateStartCaseFormValueSequence', { key: 'estateType', - value: ContactFactory.PARTY_TYPES.estate, + value: PARTY_TYPES.estate, }); result = runCompute(startCaseHelper, { @@ -370,7 +370,7 @@ export const petitionerCreatesNewCaseTestAllOptions = ( await test.runSequence('updateStartCaseFormValueSequence', { key: 'estateType', - value: ContactFactory.PARTY_TYPES.estateWithoutExecutor, + value: PARTY_TYPES.estateWithoutExecutor, }); result = runCompute(startCaseHelper, { @@ -529,7 +529,7 @@ export const petitionerCreatesNewCaseTestAllOptions = ( await test.runSequence('updateStartCaseFormValueSequence', { key: 'minorIncompetentType', - value: ContactFactory.PARTY_TYPES.nextFriendForMinor, + value: PARTY_TYPES.nextFriendForMinor, }); result = runCompute(startCaseHelper, { @@ -561,7 +561,7 @@ export const petitionerCreatesNewCaseTestAllOptions = ( await test.runSequence('updateStartCaseFormValueSequence', { key: 'minorIncompetentType', - value: ContactFactory.PARTY_TYPES.nextFriendForIncompetentPerson, + value: PARTY_TYPES.nextFriendForIncompetentPerson, }); result = runCompute(startCaseHelper, { diff --git a/web-client/integration-tests/journey/petitionerVerifiesConsolidatedCases.js b/web-client/integration-tests/journey/petitionerVerifiesConsolidatedCases.js index 20f37983281..51ef97fb080 100644 --- a/web-client/integration-tests/journey/petitionerVerifiesConsolidatedCases.js +++ b/web-client/integration-tests/journey/petitionerVerifiesConsolidatedCases.js @@ -1,6 +1,6 @@ export const petitionerVerifiesConsolidatedCases = test => { return it('Petitioner verifies there are consolidated cases', async () => { - const cases = test.getState('cases'); + const cases = test.getState('openCases'); const casesWithConsolidation = cases.filter( caseDetail => !!caseDetail.leadCaseId, diff --git a/web-client/integration-tests/journey/petitionerVerifiesUnconsolidatedCases.js b/web-client/integration-tests/journey/petitionerVerifiesUnconsolidatedCases.js index 71a4ee9f5f7..040d815dcef 100644 --- a/web-client/integration-tests/journey/petitionerVerifiesUnconsolidatedCases.js +++ b/web-client/integration-tests/journey/petitionerVerifiesUnconsolidatedCases.js @@ -1,6 +1,6 @@ export const petitionerVerifiesUnconsolidatedCases = test => { return it('Petitioner verifies the cases were unconsolidated', async () => { - const cases = test.getState('cases'); + const cases = test.getState('openCases'); const casesWithConsolidation = cases.filter( caseDetail => caseDetail.leadCaseId === test.leadCaseId, diff --git a/web-client/integration-tests/journey/petitionerViewsDashboard.js b/web-client/integration-tests/journey/petitionerViewsDashboard.js index 53869020d1d..c12cc577645 100644 --- a/web-client/integration-tests/journey/petitionerViewsDashboard.js +++ b/web-client/integration-tests/journey/petitionerViewsDashboard.js @@ -1,8 +1,13 @@ +import { refreshElasticsearchIndex } from '../helpers'; + export const petitionerViewsDashboard = test => { return it('petitioner views dashboard', async () => { + await refreshElasticsearchIndex(); + await test.runSequence('gotoDashboardSequence'); + expect(test.getState('currentPage')).toEqual('DashboardPetitioner'); - expect(test.getState('cases').length).toBeGreaterThan(0); - test.docketNumber = test.getState('cases.0.docketNumber'); + expect(test.getState('openCases').length).toBeGreaterThan(0); + test.docketNumber = test.getState('openCases.0.docketNumber'); }); }; diff --git a/web-client/integration-tests/journey/petitionerViewsOpenAndClosedCases.js b/web-client/integration-tests/journey/petitionerViewsOpenAndClosedCases.js new file mode 100644 index 00000000000..b0251f8e9fe --- /dev/null +++ b/web-client/integration-tests/journey/petitionerViewsOpenAndClosedCases.js @@ -0,0 +1,15 @@ +import { refreshElasticsearchIndex } from '../helpers'; + +export const petitionerViewsOpenAndClosedCases = test => { + return it('petitioner views open and closed cases', async () => { + await refreshElasticsearchIndex(); + + await test.runSequence('gotoDashboardSequence'); + + expect(test.getState('currentPage')).toEqual('DashboardPetitioner'); + expect(test.getState('openCases').length).toBeGreaterThan(0); + expect(test.getState('closedCases')[0]).toMatchObject({ + docketNumber: test.docketNumber, + }); + }); +}; diff --git a/web-client/integration-tests/journey/petitionsClerk1ViewsMessageDetail.js b/web-client/integration-tests/journey/petitionsClerk1ViewsMessageDetail.js new file mode 100644 index 00000000000..079715a68c4 --- /dev/null +++ b/web-client/integration-tests/journey/petitionsClerk1ViewsMessageDetail.js @@ -0,0 +1,12 @@ +export const petitionsClerk1ViewsMessageDetail = test => { + return it('petitions clerk 1 views the message detail for the message they received', async () => { + await test.runSequence('gotoMessageDetailSequence', { + docketNumber: test.docketNumber, + messageId: test.messageId, + }); + + expect(test.getState('messageDetail')).toMatchObject({ + messageId: test.messageId, + }); + }); +}; diff --git a/web-client/integration-tests/journey/petitionsClerk1ViewsMessageInbox.js b/web-client/integration-tests/journey/petitionsClerk1ViewsMessageInbox.js new file mode 100644 index 00000000000..3ba7e957e2d --- /dev/null +++ b/web-client/integration-tests/journey/petitionsClerk1ViewsMessageInbox.js @@ -0,0 +1,18 @@ +export const petitionsClerk1ViewsMessageInbox = test => { + return it('petitions clerk 1 views their messages inbox', async () => { + await test.runSequence('gotoCaseMessagesSequence', { + box: 'inbox', + queue: 'my', + }); + + const messages = test.getState('messages'); + + const foundMessage = messages.find( + message => message.subject === test.testMessageSubject, + ); + + expect(foundMessage).toBeDefined(); + + test.messageId = foundMessage.messageId; + }); +}; diff --git a/web-client/integration-tests/journey/petitionsClerkAddsDeficiencyStatisticToCase.js b/web-client/integration-tests/journey/petitionsClerkAddsDeficiencyStatisticToCase.js index cbf59e1027e..fbbb97947e8 100644 --- a/web-client/integration-tests/journey/petitionsClerkAddsDeficiencyStatisticToCase.js +++ b/web-client/integration-tests/journey/petitionsClerkAddsDeficiencyStatisticToCase.js @@ -1,4 +1,4 @@ -import { Case } from '../../../shared/src/business/entities/cases/Case'; +import { CASE_TYPES_MAP } from '../../../shared/src/business/entities/EntityConstants'; import { Statistic } from '../../../shared/src/business/entities/Statistic'; export const petitionsClerkAddsDeficiencyStatisticToCase = test => { @@ -14,7 +14,7 @@ export const petitionsClerkAddsDeficiencyStatisticToCase = test => { }); await test.runSequence('updateFormValueSequence', { key: 'caseType', - value: Case.CASE_TYPES_MAP.deficiency, + value: CASE_TYPES_MAP.deficiency, }); await test.runSequence('refreshStatisticsSequence'); await test.runSequence('updateFormValueSequence', { diff --git a/web-client/integration-tests/journey/petitionsClerkAdvancedSearchForCase.js b/web-client/integration-tests/journey/petitionsClerkAdvancedSearchForCase.js index ffe9cf23ab6..c806ec7261c 100644 --- a/web-client/integration-tests/journey/petitionsClerkAdvancedSearchForCase.js +++ b/web-client/integration-tests/journey/petitionsClerkAdvancedSearchForCase.js @@ -1,5 +1,5 @@ +import { COUNTRY_TYPES } from '../../../shared/src/business/entities/EntityConstants'; import { CaseSearch } from '../../../shared/src/business/entities/cases/CaseSearch'; -import { ContactFactory } from '../../../shared/src/business/entities/contacts/ContactFactory'; import { refreshElasticsearchIndex } from '../helpers'; export const petitionsClerkAdvancedSearchForCase = test => { @@ -50,7 +50,7 @@ export const petitionsClerkAdvancedSearchForCase = test => { await test.runSequence('updateAdvancedSearchFormValueSequence', { formType: 'caseSearchByName', key: 'countryType', - value: ContactFactory.COUNTRY_TYPES.INTERNATIONAL, + value: COUNTRY_TYPES.INTERNATIONAL, }); await test.runSequence('submitCaseAdvancedSearchSequence'); diff --git a/web-client/integration-tests/journey/petitionsClerkBlocksCase.js b/web-client/integration-tests/journey/petitionsClerkBlocksCase.js index 8c1eb1bbb89..08a49bfdb78 100644 --- a/web-client/integration-tests/journey/petitionsClerkBlocksCase.js +++ b/web-client/integration-tests/journey/petitionsClerkBlocksCase.js @@ -1,4 +1,4 @@ -import { Case } from '../../../shared/src/business/entities/cases/Case'; +import { CASE_STATUS_TYPES } from '../../../shared/src/business/entities/EntityConstants'; import { refreshElasticsearchIndex } from '../helpers'; export const petitionsClerkBlocksCase = (test, trialLocation) => { @@ -45,7 +45,7 @@ export const petitionsClerkBlocksCase = (test, trialLocation) => { 'Daenerys Stormborn of the House Targaryen, First of Her Name, the Unburnt, Queen of the Andals and the First Men, Khaleesi of the Great Grass Sea, Breaker of Chains, and Mother of Dragons, Deceased, Daenerys Stormborn of the House Targaryen, First of Her Name, the Unburnt, Queen of the Andals and the First Men, Khaleesi of the Great Grass Sea, Breaker of Chains, and Mother of Dragons, Surviving Spouse, Petitioner', docketNumber: test.docketNumber, docketNumberSuffix: 'S', - status: Case.STATUS_TYPES.generalDocketReadyForTrial, + status: CASE_STATUS_TYPES.generalDocketReadyForTrial, }), ]), ); diff --git a/web-client/integration-tests/journey/petitionsClerkCreatesNewCase.js b/web-client/integration-tests/journey/petitionsClerkCreatesNewCase.js index 9283f88aa01..2462ca7417b 100644 --- a/web-client/integration-tests/journey/petitionsClerkCreatesNewCase.js +++ b/web-client/integration-tests/journey/petitionsClerkCreatesNewCase.js @@ -1,5 +1,5 @@ -import { Case } from '../../../shared/src/business/entities/cases/Case'; import { CaseInternal } from '../../../shared/src/business/entities/cases/CaseInternal'; +import { PAYMENT_STATUS } from '../../../shared/src/business/entities/EntityConstants'; const { VALIDATION_ERROR_MESSAGES } = CaseInternal; @@ -183,7 +183,7 @@ export const petitionsClerkCreatesNewCase = ( await test.runSequence('updatePetitionPaymentFormValueSequence', { key: 'petitionPaymentStatus', - value: Case.PAYMENT_STATUS.UNPAID, + value: PAYMENT_STATUS.UNPAID, }); await test.runSequence('validatePetitionFromPaperSequence'); diff --git a/web-client/integration-tests/journey/petitionsClerkCreatesNewCaseFromPaper.js b/web-client/integration-tests/journey/petitionsClerkCreatesNewCaseFromPaper.js index 8870d363adb..2eb8c1b2964 100644 --- a/web-client/integration-tests/journey/petitionsClerkCreatesNewCaseFromPaper.js +++ b/web-client/integration-tests/journey/petitionsClerkCreatesNewCaseFromPaper.js @@ -1,6 +1,8 @@ -import { Case } from '../../../shared/src/business/entities/cases/Case'; import { CaseInternal } from '../../../shared/src/business/entities/cases/CaseInternal'; -import { ContactFactory } from '../../../shared/src/business/entities/contacts/ContactFactory'; +import { + PARTY_TYPES, + PAYMENT_STATUS, +} from '../../../shared/src/business/entities/EntityConstants'; import { reviewSavedPetitionHelper as reviewSavedPetitionHelperComputed } from '../../src/presenter/computeds/reviewSavedPetitionHelper'; import { runCompute } from 'cerebral/test'; import { withAppContextDecorator } from '../../src/withAppContext'; @@ -90,7 +92,7 @@ export const petitionsClerkCreatesNewCaseFromPaper = ( }, { key: 'partyType', - value: ContactFactory.PARTY_TYPES.petitionerDeceasedSpouse, + value: PARTY_TYPES.petitionerDeceasedSpouse, }, { key: 'contactPrimary.countryType', @@ -131,7 +133,7 @@ export const petitionsClerkCreatesNewCaseFromPaper = ( }, { key: 'petitionPaymentStatus', - value: Case.PAYMENT_STATUS.WAIVED, + value: PAYMENT_STATUS.WAIVED, }, { key: 'paymentDateWaivedDay', diff --git a/web-client/integration-tests/journey/petitionsClerkCreatesNewMessageOnCase.js b/web-client/integration-tests/journey/petitionsClerkCreatesNewMessageOnCase.js new file mode 100644 index 00000000000..6d86fb858ed --- /dev/null +++ b/web-client/integration-tests/journey/petitionsClerkCreatesNewMessageOnCase.js @@ -0,0 +1,46 @@ +import { NewCaseMessage } from '../../../shared/src/business/entities/NewCaseMessage'; +import { refreshElasticsearchIndex } from '../helpers'; + +export const petitionsClerkCreatesNewMessageOnCase = test => { + return it('petitions clerk creates new message on a case', async () => { + await test.runSequence('gotoCaseDetailSequence', { + docketNumber: test.docketNumber, + }); + + await test.runSequence('openCreateCaseMessageModalSequence'); + + await test.runSequence('updateCreateCaseMessageValueInModalSequence', { + key: 'toSection', + value: 'petitions', + }); + + await test.runSequence('updateCreateCaseMessageValueInModalSequence', { + key: 'toUserId', + value: '4805d1ab-18d0-43ec-bafb-654e83405416', //petitionsclerk1 + }); + + test.testMessageSubject = `what kind of bear is best? ${Date.now()}`; + + await test.runSequence('updateCreateCaseMessageValueInModalSequence', { + key: 'subject', + value: test.testMessageSubject, + }); + + await test.runSequence('createCaseMessageSequence'); + + expect(test.getState('validationErrors')).toEqual({ + message: NewCaseMessage.VALIDATION_ERROR_MESSAGES.message, + }); + + await test.runSequence('updateCreateCaseMessageValueInModalSequence', { + key: 'message', + value: 'bears, beets, battlestar galactica', + }); + + await test.runSequence('createCaseMessageSequence'); + + expect(test.getState('validationErrors')).toEqual({}); + + await refreshElasticsearchIndex(); + }); +}; diff --git a/web-client/integration-tests/journey/petitionsClerkSubmitsCaseToIrs.js b/web-client/integration-tests/journey/petitionsClerkSubmitsCaseToIrs.js index b722e9bc95b..66866854aa0 100644 --- a/web-client/integration-tests/journey/petitionsClerkSubmitsCaseToIrs.js +++ b/web-client/integration-tests/journey/petitionsClerkSubmitsCaseToIrs.js @@ -1,3 +1,4 @@ +import { CASE_STATUS_TYPES } from '../../../shared/src/business/entities/EntityConstants'; import { Case } from '../../../shared/src/business/entities/cases/Case'; const { VALIDATION_ERROR_MESSAGES } = Case; @@ -61,7 +62,7 @@ export const petitionsClerkSubmitsCaseToIrs = test => { '2017-12-24T05:00:00.000Z', ); expect(test.getState('caseDetail.status')).toEqual( - Case.STATUS_TYPES.generalDocket, + CASE_STATUS_TYPES.generalDocket, ); //check that documents were served const documents = test.getState('caseDetail.documents'); diff --git a/web-client/integration-tests/journey/petitionsClerkSubmitsPaperCaseToIrs.js b/web-client/integration-tests/journey/petitionsClerkSubmitsPaperCaseToIrs.js index c19d9fed6f9..c2a3cc3f3d8 100644 --- a/web-client/integration-tests/journey/petitionsClerkSubmitsPaperCaseToIrs.js +++ b/web-client/integration-tests/journey/petitionsClerkSubmitsPaperCaseToIrs.js @@ -1,5 +1,8 @@ +import { + CASE_STATUS_TYPES, + ROLES, +} from '../../../shared/src/business/entities/EntityConstants'; import { Case } from '../../../shared/src/business/entities/cases/Case'; -import { User } from '../../../shared/src/business/entities/User'; const { VALIDATION_ERROR_MESSAGES } = Case; @@ -64,14 +67,14 @@ export const petitionsClerkSubmitsPaperCaseToIrs = test => { '2017-12-24T05:00:00.000Z', ); expect(test.getState('caseDetail.status')).toEqual( - Case.STATUS_TYPES.generalDocket, + CASE_STATUS_TYPES.generalDocket, ); //check that documents were served const documents = test.getState('caseDetail.documents'); for (const document of documents) { expect(document.servedAt).toBeDefined(); expect(document.servedParties.length).toEqual(1); - expect(document.servedParties[0].role).toEqual(User.ROLES.irsSuperuser); + expect(document.servedParties[0].role).toEqual(ROLES.irsSuperuser); } }); }; diff --git a/web-client/integration-tests/journey/petitionsClerkUpdatesCaseDetail.js b/web-client/integration-tests/journey/petitionsClerkUpdatesCaseDetail.js index 7e2aca793b5..b8720a24db0 100644 --- a/web-client/integration-tests/journey/petitionsClerkUpdatesCaseDetail.js +++ b/web-client/integration-tests/journey/petitionsClerkUpdatesCaseDetail.js @@ -1,4 +1,5 @@ import { Case } from '../../../shared/src/business/entities/cases/Case'; +import { PAYMENT_STATUS } from '../../../shared/src/business/entities/EntityConstants'; const { VALIDATION_ERROR_MESSAGES } = Case; @@ -125,7 +126,7 @@ export const petitionsClerkUpdatesCaseDetail = test => { // petitionPaymentDate await test.runSequence('updateFormValueSequence', { key: 'petitionPaymentStatus', - value: Case.PAYMENT_STATUS.PAID, + value: PAYMENT_STATUS.PAID, }); await test.runSequence('saveSavedCaseForLaterSequence'); diff --git a/web-client/integration-tests/journey/petitionsClerkVerifiesOrderForOdsCheckbox.js b/web-client/integration-tests/journey/petitionsClerkVerifiesOrderForOdsCheckbox.js index b54cbea1276..e68096be014 100644 --- a/web-client/integration-tests/journey/petitionsClerkVerifiesOrderForOdsCheckbox.js +++ b/web-client/integration-tests/journey/petitionsClerkVerifiesOrderForOdsCheckbox.js @@ -1,5 +1,5 @@ import { CaseInternal } from '../../../shared/src/business/entities/cases/CaseInternal'; -import { ContactFactory } from '../../../shared/src/business/entities/contacts/ContactFactory'; +import { PARTY_TYPES } from '../../../shared/src/business/entities/EntityConstants'; export const petitionsClerkVerifiesOrderForOdsCheckbox = (test, fakeFile) => { return it('Petitions clerk verifies that the Order for ODS checkbox is correctly checked and unchecked', async () => { @@ -9,14 +9,14 @@ export const petitionsClerkVerifiesOrderForOdsCheckbox = (test, fakeFile) => { await test.runSequence('updateStartCaseInternalPartyTypeSequence', { key: 'partyType', - value: ContactFactory.PARTY_TYPES.petitioner, + value: PARTY_TYPES.petitioner, }); expect(test.getState('form.orderForOds')).toBeFalsy(); await test.runSequence('updateStartCaseInternalPartyTypeSequence', { key: 'partyType', - value: ContactFactory.PARTY_TYPES.corporation, + value: PARTY_TYPES.corporation, }); expect(test.getState('form.orderForOds')).toBeTruthy(); diff --git a/web-client/integration-tests/journey/petitionsClerkVerifiesPetitionPaymentFeeOptions.js b/web-client/integration-tests/journey/petitionsClerkVerifiesPetitionPaymentFeeOptions.js index d033003fb2d..c2a6943b42b 100644 --- a/web-client/integration-tests/journey/petitionsClerkVerifiesPetitionPaymentFeeOptions.js +++ b/web-client/integration-tests/journey/petitionsClerkVerifiesPetitionPaymentFeeOptions.js @@ -1,5 +1,6 @@ import { Case } from '../../../shared/src/business/entities/cases/Case'; import { CaseInternal } from '../../../shared/src/business/entities/cases/CaseInternal'; +import { PAYMENT_STATUS } from '../../../shared/src/business/entities/EntityConstants'; export const petitionsClerkVerifiesPetitionPaymentFeeOptions = ( test, @@ -14,7 +15,7 @@ export const petitionsClerkVerifiesPetitionPaymentFeeOptions = ( await test.runSequence('updatePetitionPaymentFormValueSequence', { key: 'petitionPaymentStatus', - value: Case.PAYMENT_STATUS.PAID, + value: PAYMENT_STATUS.PAID, }); expect(test.getState('form.orderForFilingFee')).toEqual(false); @@ -55,7 +56,7 @@ export const petitionsClerkVerifiesPetitionPaymentFeeOptions = ( await test.runSequence('updatePetitionPaymentFormValueSequence', { key: 'petitionPaymentStatus', - value: Case.PAYMENT_STATUS.UNPAID, + value: PAYMENT_STATUS.UNPAID, }); expect(test.getState('form.orderForFilingFee')).toEqual(true); @@ -71,7 +72,7 @@ export const petitionsClerkVerifiesPetitionPaymentFeeOptions = ( await test.runSequence('updatePetitionPaymentFormValueSequence', { key: 'petitionPaymentStatus', - value: Case.PAYMENT_STATUS.WAIVED, + value: PAYMENT_STATUS.WAIVED, }); expect(test.getState('form.orderForFilingFee')).toEqual(false); diff --git a/web-client/integration-tests/journey/petitionsClerkViewsCaseDetail.js b/web-client/integration-tests/journey/petitionsClerkViewsCaseDetail.js index bd2700209eb..3c15675417b 100644 --- a/web-client/integration-tests/journey/petitionsClerkViewsCaseDetail.js +++ b/web-client/integration-tests/journey/petitionsClerkViewsCaseDetail.js @@ -1,4 +1,7 @@ -import { Case } from '../../../shared/src/business/entities/cases/Case'; +import { + CASE_STATUS_TYPES, + CHIEF_JUDGE, +} from '../../../shared/src/business/entities/EntityConstants'; export const petitionsClerkViewsCaseDetail = ( test, @@ -13,13 +16,11 @@ export const petitionsClerkViewsCaseDetail = ( expect(test.getState('currentPage')).toEqual('CaseDetailInternal'); expect(test.getState('caseDetail.docketNumber')).toEqual(test.docketNumber); - expect(test.getState('caseDetail.status')).toEqual(Case.STATUS_TYPES.new); + expect(test.getState('caseDetail.status')).toEqual(CASE_STATUS_TYPES.new); expect(test.getState('caseDetail.documents').length).toEqual( expectedDocumentCount, ); - expect(test.getState('caseDetail.associatedJudge')).toEqual( - Case.CHIEF_JUDGE, - ); + expect(test.getState('caseDetail.associatedJudge')).toEqual(CHIEF_JUDGE); const caseDetail = test.getState('caseDetail'); diff --git a/web-client/integration-tests/journey/petitionsClerkViewsCaseDetailAfterAddingNotice.js b/web-client/integration-tests/journey/petitionsClerkViewsCaseDetailAfterAddingNotice.js index e7e917f039e..5b97bc60267 100644 --- a/web-client/integration-tests/journey/petitionsClerkViewsCaseDetailAfterAddingNotice.js +++ b/web-client/integration-tests/journey/petitionsClerkViewsCaseDetailAfterAddingNotice.js @@ -1,4 +1,4 @@ -import { Case } from '../../../shared/src/business/entities/cases/Case'; +import { CASE_STATUS_TYPES } from '../../../shared/src/business/entities/EntityConstants'; export const petitionsClerkViewsCaseDetailAfterAddingNotice = test => { return it('Petitions clerk views case detail after adding notice', async () => { @@ -8,7 +8,7 @@ export const petitionsClerkViewsCaseDetailAfterAddingNotice = test => { }); expect(test.getState('currentPage')).toEqual('CaseDetailInternal'); expect(test.getState('caseDetail.docketNumber')).toEqual(test.docketNumber); - expect(test.getState('caseDetail.status')).toEqual(Case.STATUS_TYPES.new); + expect(test.getState('caseDetail.status')).toEqual(CASE_STATUS_TYPES.new); expect(test.getState('caseDetail.documents').length).toEqual(3); expect( test diff --git a/web-client/integration-tests/journey/petitionsClerkViewsCaseDetailAfterAddingOrder.js b/web-client/integration-tests/journey/petitionsClerkViewsCaseDetailAfterAddingOrder.js index ec1c9ede1a9..cbe84ac2986 100644 --- a/web-client/integration-tests/journey/petitionsClerkViewsCaseDetailAfterAddingOrder.js +++ b/web-client/integration-tests/journey/petitionsClerkViewsCaseDetailAfterAddingOrder.js @@ -1,4 +1,4 @@ -import { Case } from '../../../shared/src/business/entities/cases/Case'; +import { CASE_STATUS_TYPES } from '../../../shared/src/business/entities/EntityConstants'; export const petitionsClerkViewsCaseDetailAfterAddingOrder = test => { return it('Petitions clerk views case detail after adding order', async () => { @@ -8,7 +8,7 @@ export const petitionsClerkViewsCaseDetailAfterAddingOrder = test => { }); expect(test.getState('currentPage')).toEqual('CaseDetailInternal'); expect(test.getState('caseDetail.docketNumber')).toEqual(test.docketNumber); - expect(test.getState('caseDetail.status')).toEqual(Case.STATUS_TYPES.new); + expect(test.getState('caseDetail.status')).toEqual(CASE_STATUS_TYPES.new); expect(test.getState('caseDetail.documents').length).toEqual(3); expect( test diff --git a/web-client/integration-tests/journey/petitionsClerkViewsMessages.js b/web-client/integration-tests/journey/petitionsClerkViewsMessages.js index dc5c563826f..95c7cfa6529 100644 --- a/web-client/integration-tests/journey/petitionsClerkViewsMessages.js +++ b/web-client/integration-tests/journey/petitionsClerkViewsMessages.js @@ -1,4 +1,4 @@ -import { Case } from '../../../shared/src/business/entities/cases/Case'; +import { CASE_STATUS_TYPES } from '../../../shared/src/business/entities/EntityConstants'; export const petitionsClerkViewsMessages = test => { return it('Petitions clerk views messages', async () => { @@ -19,7 +19,7 @@ export const petitionsClerkViewsMessages = test => { workItem.document.documentType === 'Petition', ); expect(workItem).toBeDefined(); - expect(workItem.caseStatus).toEqual(Case.STATUS_TYPES.new); + expect(workItem.caseStatus).toEqual(CASE_STATUS_TYPES.new); expect(workItem.messages[0].message).toEqual( 'Petition filed by Daenerys Stormborn of the House Targaryen, First of Her Name, the Unburnt, Queen of the Andals and the First Men, Khaleesi of the Great Grass Sea, Breaker of Chains, and Mother of Dragons, Deceased, Daenerys Stormborn of the House Targaryen, First of Her Name, the Unburnt, Queen of the Andals and the First Men, Khaleesi of the Great Grass Sea, Breaker of Chains, and Mother of Dragons 2, Surviving Spouse is ready for review.', ); diff --git a/web-client/integration-tests/journey/petitionsClerkViewsSentMessagesBox.js b/web-client/integration-tests/journey/petitionsClerkViewsSentMessagesBox.js new file mode 100644 index 00000000000..a42ba012c8f --- /dev/null +++ b/web-client/integration-tests/journey/petitionsClerkViewsSentMessagesBox.js @@ -0,0 +1,16 @@ +export const petitionsClerkViewsSentMessagesBox = test => { + return it('petitions clerk views their sent messages box', async () => { + await test.runSequence('gotoCaseMessagesSequence', { + box: 'outbox', + queue: 'my', + }); + + const messages = test.getState('messages'); + + const foundMessage = messages.find( + message => message.subject === test.testMessageSubject, + ); + + expect(foundMessage).toBeDefined(); + }); +}; diff --git a/web-client/integration-tests/journey/practitionerCreatesNewCase.js b/web-client/integration-tests/journey/practitionerCreatesNewCase.js index 1fdfa29eb77..ec1a13e866a 100644 --- a/web-client/integration-tests/journey/practitionerCreatesNewCase.js +++ b/web-client/integration-tests/journey/practitionerCreatesNewCase.js @@ -200,6 +200,6 @@ export const practitionerCreatesNewCase = (test, fakeFile) => { expect(test.getState('currentPage')).toBe('DashboardPractitioner'); - test.docketNumber = test.getState('cases.0.docketNumber'); + test.docketNumber = test.getState('openCases.0.docketNumber'); }); }; diff --git a/web-client/integration-tests/journey/practitionerRequestsPendingAccessToCase.js b/web-client/integration-tests/journey/practitionerRequestsPendingAccessToCase.js index 148196e7b9e..5de962a0f05 100644 --- a/web-client/integration-tests/journey/practitionerRequestsPendingAccessToCase.js +++ b/web-client/integration-tests/journey/practitionerRequestsPendingAccessToCase.js @@ -83,6 +83,10 @@ export const practitionerRequestsPendingAccessToCase = (test, fakeFile) => { ); expect(test.getState('validationErrors')).toEqual({}); + expect(test.getState('wizardStep')).toBe('RequestAccessReview'); + await test.runSequence('submitCaseAssociationRequestSequence'); + + expect(test.getState('wizardStep')).toBeUndefined(); }); }; diff --git a/web-client/integration-tests/journey/practitionerViewsDashboard.js b/web-client/integration-tests/journey/practitionerViewsDashboard.js index cb3d2c53860..97f4fc2db11 100644 --- a/web-client/integration-tests/journey/practitionerViewsDashboard.js +++ b/web-client/integration-tests/journey/practitionerViewsDashboard.js @@ -2,8 +2,8 @@ export const practitionerViewsDashboard = test => { return it('Practitioner views dashboard', async () => { await test.runSequence('gotoDashboardSequence'); expect(test.getState('currentPage')).toEqual('DashboardPractitioner'); - expect(test.getState('cases').length).toBeGreaterThan(0); - const latestDocketNumber = test.getState('cases.0.docketNumber'); + expect(test.getState('openCases').length).toBeGreaterThan(0); + const latestDocketNumber = test.getState('openCases.0.docketNumber'); expect(test.docketNumber).toEqual(latestDocketNumber); }); }; diff --git a/web-client/integration-tests/journey/privatePractitionerViewsOpenClosedCases.js b/web-client/integration-tests/journey/privatePractitionerViewsOpenClosedCases.js new file mode 100644 index 00000000000..1ee4532c513 --- /dev/null +++ b/web-client/integration-tests/journey/privatePractitionerViewsOpenClosedCases.js @@ -0,0 +1,9 @@ +export const privatePractitionerViewsOpenAndClosedCases = test => { + return it('private practitioner views open and closed cases', async () => { + await test.runSequence('gotoDashboardSequence'); + + expect(test.getState('currentPage')).toEqual('DashboardPractitioner'); + expect(test.getState('openCases').length).toBeGreaterThan(0); + expect(test.getState('closedCases').length).toBe(0); + }); +}; diff --git a/web-client/integration-tests/journey/respondentViewsCaseDetailOfBatchedCase.js b/web-client/integration-tests/journey/respondentViewsCaseDetailOfBatchedCase.js index 618121b76b6..9b27acbc14c 100644 --- a/web-client/integration-tests/journey/respondentViewsCaseDetailOfBatchedCase.js +++ b/web-client/integration-tests/journey/respondentViewsCaseDetailOfBatchedCase.js @@ -1,4 +1,4 @@ -import { Case } from '../../../shared/src/business/entities/cases/Case'; +import { CASE_STATUS_TYPES } from '../../../shared/src/business/entities/EntityConstants'; export const respondentViewsCaseDetailOfBatchedCase = test => { return it('Respondent views case detail', async () => { @@ -9,7 +9,7 @@ export const respondentViewsCaseDetailOfBatchedCase = test => { expect(test.getState('currentPage')).toEqual('CaseDetail'); expect(test.getState('caseDetail.docketNumber')).toEqual(test.docketNumber); expect(test.getState('caseDetail.status')).toEqual( - Case.STATUS_TYPES.generalDocket, + CASE_STATUS_TYPES.generalDocket, ); expect(test.getState('caseDetail.documents').length).toEqual(2); }); diff --git a/web-client/integration-tests/journey/respondentViewsDashboard.js b/web-client/integration-tests/journey/respondentViewsDashboard.js index 42a1955df97..db2b0d53b7e 100644 --- a/web-client/integration-tests/journey/respondentViewsDashboard.js +++ b/web-client/integration-tests/journey/respondentViewsDashboard.js @@ -2,6 +2,6 @@ export const respondentViewsDashboard = test => { return it('Respondent views dashboard', async () => { await test.runSequence('gotoDashboardSequence'); expect(test.getState('currentPage')).toEqual('DashboardRespondent'); - expect(test.getState('cases').length).toBeGreaterThanOrEqual(0); + expect(test.getState('openCases').length).toBeGreaterThanOrEqual(0); }); }; diff --git a/web-client/integration-tests/messagesJourney.test.js b/web-client/integration-tests/messagesJourney.test.js new file mode 100644 index 00000000000..8b8c57882e1 --- /dev/null +++ b/web-client/integration-tests/messagesJourney.test.js @@ -0,0 +1,30 @@ +import { loginAs, setupTest, uploadPetition } from './helpers'; +import { petitionsClerk1ViewsMessageDetail } from './journey/petitionsClerk1ViewsMessageDetail'; +import { petitionsClerk1ViewsMessageInbox } from './journey/petitionsClerk1ViewsMessageInbox'; +import { petitionsClerkCreatesNewMessageOnCase } from './journey/petitionsClerkCreatesNewMessageOnCase'; +import { petitionsClerkViewsSentMessagesBox } from './journey/petitionsClerkViewsSentMessagesBox'; + +const test = setupTest(); + +describe('messages journey', () => { + beforeAll(() => { + jest.setTimeout(40000); + }); + + loginAs(test, 'petitioner'); + it('Create test case to send messages', async () => { + const caseDetail = await uploadPetition(test); + expect(caseDetail.docketNumber).toBeDefined(); + test.docketNumber = caseDetail.docketNumber; + test.documentId = caseDetail.documents[0].documentId; + test.caseId = caseDetail.caseId; + }); + + loginAs(test, 'petitionsclerk'); + petitionsClerkCreatesNewMessageOnCase(test); + petitionsClerkViewsSentMessagesBox(test); + + loginAs(test, 'petitionsclerk1'); + petitionsClerk1ViewsMessageInbox(test); + petitionsClerk1ViewsMessageDetail(test); +}); diff --git a/web-client/integration-tests/modifyContactInfo.test.js b/web-client/integration-tests/modifyContactInfo.test.js index ddae5e200a0..28cff241f47 100644 --- a/web-client/integration-tests/modifyContactInfo.test.js +++ b/web-client/integration-tests/modifyContactInfo.test.js @@ -1,4 +1,4 @@ -import { ContactFactory } from '../../shared/src/business/entities/contacts/ContactFactory'; +import { PARTY_TYPES } from '../../shared/src/business/entities/EntityConstants'; import { docketClerkViewsNoticeOfChangeOfAddress } from './journey/docketClerkViewsNoticeOfChangeOfAddress'; import { loginAs, setupTest, uploadPetition } from './helpers'; import { petitionerEditsCasePrimaryContactAddress } from './journey/petitionerEditsCasePrimaryContactAddress'; @@ -33,7 +33,7 @@ describe('Modify Petitioner Contact Information', () => { postalCode: '77546', state: 'CT', }, - partyType: ContactFactory.PARTY_TYPES.petitionerSpouse, + partyType: PARTY_TYPES.petitionerSpouse, }); expect(caseDetail.docketNumber).toBeDefined(); test.docketNumber = caseDetail.docketNumber; diff --git a/web-client/integration-tests/noticeOfTrialSessionWithPaperService.test.js b/web-client/integration-tests/noticeOfTrialSessionWithPaperService.test.js index 94cff3752a4..83068f008a3 100644 --- a/web-client/integration-tests/noticeOfTrialSessionWithPaperService.test.js +++ b/web-client/integration-tests/noticeOfTrialSessionWithPaperService.test.js @@ -1,12 +1,12 @@ -import { ContactFactory } from '../../shared/src/business/entities/contacts/ContactFactory'; - -import { loginAs, setupTest, uploadPetition } from './helpers'; -import { markAllCasesAsQCed } from './journey/markAllCasesAsQCed'; - +import { + COUNTRY_TYPES, + PARTY_TYPES, +} from '../../shared/src/business/entities/EntityConstants'; import { docketClerkCreatesAnIncompleteTrialSessionBeforeCalendaring } from './journey/docketClerkCreatesAnIncompleteTrialSessionBeforeCalendaring'; import { docketClerkSetsCaseReadyForTrial } from './journey/docketClerkSetsCaseReadyForTrial'; import { docketClerkViewsTrialSessionList } from './journey/docketClerkViewsTrialSessionList'; - +import { loginAs, setupTest, uploadPetition } from './helpers'; +import { markAllCasesAsQCed } from './journey/markAllCasesAsQCed'; import { petitionsClerkCompletesAndSetsTrialSession } from './journey/petitionsClerkCompletesAndSetsTrialSession'; import { petitionsClerkSubmitsCaseToIrs } from './journey/petitionsClerkSubmitsCaseToIrs'; import { petitionsClerkViewsDocketRecordAfterSettingTrial } from './journey/petitionsClerkViewsDocketRecordAfterSettingTrial'; @@ -28,14 +28,14 @@ describe('Generate Notices of Trial Session with Paper Service', () => { contactSecondary: { address1: '123 Paper St.', city: 'Paper City', - countryType: ContactFactory.COUNTRY_TYPES.DOMESTIC, + countryType: COUNTRY_TYPES.DOMESTIC, name: 'Richard Papers', phone: '1231231234', postalCode: '12345', state: 'IA', }, hasPaper: true, - partyType: ContactFactory.PARTY_TYPES.petitionerSpouse, + partyType: PARTY_TYPES.petitionerSpouse, preferredTrialCity: trialLocation, procedureType: 'Small', // should generate a Standing Pretrial Notice trialLocation, diff --git a/web-client/integration-tests/petitionsClerkBlockCase.test.js b/web-client/integration-tests/petitionsClerkBlockCase.test.js index 1327a004862..378aff31052 100644 --- a/web-client/integration-tests/petitionsClerkBlockCase.test.js +++ b/web-client/integration-tests/petitionsClerkBlockCase.test.js @@ -1,4 +1,4 @@ -import { Case } from '../../shared/src/business/entities/cases/Case'; +import { AUTOMATIC_BLOCKED_REASONS } from '../../shared/src/business/entities/EntityConstants'; import { docketClerkCreatesATrialSession } from './journey/docketClerkCreatesATrialSession'; import { docketClerkSetsCaseReadyForTrial } from './journey/docketClerkSetsCaseReadyForTrial'; import { docketClerkViewsTrialSessionList } from './journey/docketClerkViewsTrialSessionList'; @@ -68,7 +68,7 @@ describe('Blocking a Case', () => { expect(test.getState('blockedCases')).toMatchObject([ { automaticBlocked: true, - automaticBlockedReason: Case.AUTOMATIC_BLOCKED_REASONS.dueDate, + automaticBlockedReason: AUTOMATIC_BLOCKED_REASONS.dueDate, blocked: false, docketNumber: test.docketNumber, }, @@ -103,7 +103,7 @@ describe('Blocking a Case', () => { expect(test.getState('blockedCases')).toMatchObject([ { automaticBlocked: true, - automaticBlockedReason: Case.AUTOMATIC_BLOCKED_REASONS.pending, + automaticBlockedReason: AUTOMATIC_BLOCKED_REASONS.pending, blocked: false, docketNumber: test.docketNumber, }, @@ -129,7 +129,7 @@ describe('Blocking a Case', () => { expect(test.getState('blockedCases')).toMatchObject([ { automaticBlocked: true, - automaticBlockedReason: Case.AUTOMATIC_BLOCKED_REASONS.dueDate, + automaticBlockedReason: AUTOMATIC_BLOCKED_REASONS.dueDate, blocked: true, blockedReason: 'just because', docketNumber: test.docketNumber, diff --git a/web-client/integration-tests/petitionsClerkCounselAssociationJourney.test.js b/web-client/integration-tests/petitionsClerkCounselAssociationJourney.test.js index 19f40c34710..f69e42f9cfd 100644 --- a/web-client/integration-tests/petitionsClerkCounselAssociationJourney.test.js +++ b/web-client/integration-tests/petitionsClerkCounselAssociationJourney.test.js @@ -1,4 +1,4 @@ -import { ContactFactory } from '../../shared/src/business/entities/contacts/ContactFactory'; +import { PARTY_TYPES } from '../../shared/src/business/entities/EntityConstants'; import { loginAs, setupTest, uploadPetition } from './helpers'; import { petitionsClerkAddsPractitionersToCase } from './journey/petitionsClerkAddsPractitionersToCase'; import { petitionsClerkAddsRespondentsToCase } from './journey/petitionsClerkAddsRespondentsToCase'; @@ -26,7 +26,7 @@ describe('Petitions Clerk Counsel Association Journey', () => { postalCode: '77546', state: 'AZ', }, - partyType: ContactFactory.PARTY_TYPES.petitionerSpouse, + partyType: PARTY_TYPES.petitionerSpouse, }); expect(caseDetail.docketNumber).toBeDefined(); test.docketNumber = caseDetail.docketNumber; diff --git a/web-client/integration-tests/practitionerCaseJourney.test.js b/web-client/integration-tests/practitionerCaseJourney.test.js index 1fcb67f8b88..a963bb63db2 100644 --- a/web-client/integration-tests/practitionerCaseJourney.test.js +++ b/web-client/integration-tests/practitionerCaseJourney.test.js @@ -1,4 +1,4 @@ -import { ContactFactory } from '../../shared/src/business/entities/contacts/ContactFactory'; +import { PARTY_TYPES } from '../../shared/src/business/entities/EntityConstants'; import { fakeFile, loginAs, setupTest, uploadPetition } from './helpers'; import { practitionerCreatesNewCase } from './journey/practitionerCreatesNewCase'; import { practitionerFilesDocumentForOwnedCase } from './journey/practitionerFilesDocumentForOwnedCase'; @@ -38,7 +38,7 @@ describe('Practitioner requests access to case', () => { postalCode: '77546', state: 'AZ', }, - partyType: ContactFactory.PARTY_TYPES.petitionerSpouse, + partyType: PARTY_TYPES.petitionerSpouse, }); expect(caseDetail.docketNumber).toBeDefined(); test.docketNumber = caseDetail.docketNumber; @@ -68,7 +68,7 @@ describe('Practitioner requests access to case', () => { postalCode: '77546', state: 'AZ', }, - partyType: ContactFactory.PARTY_TYPES.petitionerSpouse, + partyType: PARTY_TYPES.petitionerSpouse, }); expect(caseDetail.docketNumber).toBeDefined(); test.docketNumber = caseDetail.docketNumber; diff --git a/web-client/integration-tests/scanHelpers.js b/web-client/integration-tests/scanHelpers.js index 2ea23b17c9a..dbb27f42789 100644 --- a/web-client/integration-tests/scanHelpers.js +++ b/web-client/integration-tests/scanHelpers.js @@ -1,6 +1,6 @@ import { setBatchPages } from './helpers'; -exports.addBatchesForScanning = ( +export const addBatchesForScanning = ( test, { scannerSourceIndex, scannerSourceName }, ) => { @@ -22,8 +22,7 @@ exports.addBatchesForScanning = ( ]); }); }; - -exports.createPDFFromScannedBatches = test => { +export const createPDFFromScannedBatches = test => { return it('Creates a PDF from added batches', async () => { const selectedDocumentType = test.getState( 'currentViewMetadata.documentSelectedForScan', @@ -43,7 +42,7 @@ exports.createPDFFromScannedBatches = test => { }); }; -exports.selectScannerSource = ( +export const selectScannerSource = ( test, { scannerSourceIndex, scannerSourceName }, ) => { diff --git a/web-client/integration-tests/sentWorkItemsExpireAfter7Days.test.js b/web-client/integration-tests/sentWorkItemsExpireAfter7Days.test.js index 180f4c4af83..2dc7efd7d8a 100644 --- a/web-client/integration-tests/sentWorkItemsExpireAfter7Days.test.js +++ b/web-client/integration-tests/sentWorkItemsExpireAfter7Days.test.js @@ -1,5 +1,7 @@ -import { Case } from '../../shared/src/business/entities/cases/Case'; -import { User } from '../../shared/src/business/entities/User'; +import { + CASE_STATUS_TYPES, + ROLES, +} from '../../shared/src/business/entities/EntityConstants'; import { getFormattedMyOutbox, getFormattedSectionOutbox, @@ -32,7 +34,7 @@ describe('verify old sent work items do not show up in the outbox', () => { expect(caseDetail.docketNumber).toBeDefined(); const applicationContext = applicationContextFactory({ - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, section: 'petitions', userId: '3805d1ab-18d0-43ec-bafb-654e83405416', }); @@ -52,7 +54,7 @@ describe('verify old sent work items do not show up in the outbox', () => { assigneeId: '3805d1ab-18d0-43ec-bafb-654e83405416', assigneeName: 'Test petitionsclerk1', caseId: 'd481929a-fb22-4800-900e-50b15ac55934', - caseStatus: Case.STATUS_TYPES.new, + caseStatus: CASE_STATUS_TYPES.new, createdAt: CREATED_8_DAYS_AGO.toISOString(), docketNumber: caseDetail.docketNumber, docketNumberSuffix: null, diff --git a/web-client/integration-tests/servedWorkItemsExpireAfter7Days.test.js b/web-client/integration-tests/servedWorkItemsExpireAfter7Days.test.js index 7b9f9384eba..7434e7ed4e1 100644 --- a/web-client/integration-tests/servedWorkItemsExpireAfter7Days.test.js +++ b/web-client/integration-tests/servedWorkItemsExpireAfter7Days.test.js @@ -1,5 +1,7 @@ -import { Case } from '../../shared/src/business/entities/cases/Case'; -import { User } from '../../shared/src/business/entities/User'; +import { + CASE_STATUS_TYPES, + ROLES, +} from '../../shared/src/business/entities/EntityConstants'; import { getFormattedDocumentQCMyOutbox, getFormattedDocumentQCSectionOutbox, @@ -33,7 +35,7 @@ describe('verify old served work items do not show up in the outbox', () => { expect(caseDetail.docketNumber).toBeDefined(); const applicationContext = applicationContextFactory({ - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, section: 'petitions', userId: '3805d1ab-18d0-43ec-bafb-654e83405416', }); @@ -53,7 +55,7 @@ describe('verify old served work items do not show up in the outbox', () => { assigneeId: '3805d1ab-18d0-43ec-bafb-654e83405416', assigneeName: 'Test petitionsclerk1', caseId: 'd481929a-fb22-4800-900e-50b15ac55934', - caseStatus: Case.STATUS_TYPES.new, + caseStatus: CASE_STATUS_TYPES.new, completedAt: '2019-06-26T16:31:17.643Z', completedByUserId: '3805d1ab-18d0-43ec-bafb-654e83405416', createdAt: CREATED_8_DAYS_AGO.toISOString(), @@ -77,7 +79,7 @@ describe('verify old served work items do not show up in the outbox', () => { toUserId: '3805d1ab-18d0-43ec-bafb-654e83405416', }, ], - section: 'irsBatchSection', + section: 'irsSystem', sentBy: 'Test petitionsclerk1', sentBySection: 'petitions', sentByUserId: '3805d1ab-18d0-43ec-bafb-654e83405416', diff --git a/web-client/integration-tests/signAndServeStipulatedDecision.test.js b/web-client/integration-tests/signAndServeStipulatedDecision.test.js index 20a29d7d167..99234f3bb69 100644 --- a/web-client/integration-tests/signAndServeStipulatedDecision.test.js +++ b/web-client/integration-tests/signAndServeStipulatedDecision.test.js @@ -1,4 +1,4 @@ -import { Case } from '../../shared/src/business/entities/cases/Case'; +import { CASE_STATUS_TYPES } from '../../shared/src/business/entities/EntityConstants'; import { createCourtIssuedDocketEntry, @@ -134,6 +134,6 @@ describe('a user signs and serves a stipulated decision', () => { d => d.documentId === signedDocumentId, ); expect(signedDocument.servedAt).toBeDefined(); - expect(caseDetail.status).toEqual(Case.STATUS_TYPES.closed); + expect(caseDetail.status).toEqual(CASE_STATUS_TYPES.closed); }); }); diff --git a/web-client/integration-tests/trialSessionEligibleCasesJourney.test.js b/web-client/integration-tests/trialSessionEligibleCasesJourney.test.js index 649a8bdbfde..b7ebcc6ea4d 100644 --- a/web-client/integration-tests/trialSessionEligibleCasesJourney.test.js +++ b/web-client/integration-tests/trialSessionEligibleCasesJourney.test.js @@ -1,4 +1,4 @@ -import { Case } from '../../shared/src/business/entities/cases/Case'; +import { CHIEF_JUDGE } from '../../shared/src/business/entities/EntityConstants'; import { docketClerkCreatesATrialSession } from './journey/docketClerkCreatesATrialSession'; import { docketClerkSetsCaseReadyForTrial } from './journey/docketClerkSetsCaseReadyForTrial'; import { docketClerkViewsNewTrialSession } from './journey/docketClerkViewsNewTrialSession'; @@ -294,9 +294,7 @@ describe('Trial Session Eligible Cases Journey', () => { expect(test.getState('caseDetail.status')).not.toEqual('Calendared'); expect(test.getState('caseDetail.trialLocation')).toBeUndefined(); expect(test.getState('caseDetail.trialDate')).toBeUndefined(); - expect(test.getState('caseDetail.associatedJudge')).toEqual( - Case.CHIEF_JUDGE, - ); + expect(test.getState('caseDetail.associatedJudge')).toEqual(CHIEF_JUDGE); //Case #3 - not assigned await test.runSequence('gotoCaseDetailSequence', { diff --git a/web-client/pa11y/pa11y-docketclerk.js b/web-client/pa11y/pa11y-docketclerk.js index 96ff7cc603f..8481318c26c 100644 --- a/web-client/pa11y/pa11y-docketclerk.js +++ b/web-client/pa11y/pa11y-docketclerk.js @@ -21,7 +21,7 @@ module.exports = [ notes: 'checks a11y of form when petition fee payment status paid is selected', url: - 'http://localhost:1234/mock-login?token=docketclerk&path=/case-detail/105-19/edit-details&info=paid', + 'http://localhost:1234/mock-login?token=docketclerk&path=/case-detail/101-19/edit-details&info=paid', }, { actions: [ @@ -32,7 +32,7 @@ module.exports = [ notes: 'checks a11y of form when petition fee payment status unpaid is selected', url: - 'http://localhost:1234/mock-login?token=docketclerk&path=/case-detail/105-19/edit-details&info=unpaid', + 'http://localhost:1234/mock-login?token=docketclerk&path=/case-detail/101-19/edit-details&info=unpaid', }, { actions: [ @@ -43,7 +43,7 @@ module.exports = [ notes: 'checks a11y of form when petition fee payment status waived is selected', url: - 'http://localhost:1234/mock-login?token=docketclerk&path=/case-detail/105-19/edit-details&info=waived', + 'http://localhost:1234/mock-login?token=docketclerk&path=/case-detail/101-19/edit-details&info=waived', }, 'http://localhost:1234/mock-login?token=docketclerk&path=/case-detail/101-19/documents/1f1aa3f7-e2e3-43e6-885d-4ce341588c76', { diff --git a/web-client/pa11y/pa11y-petitionsclerk.js b/web-client/pa11y/pa11y-petitionsclerk.js index c3791590c98..92e37516d44 100644 --- a/web-client/pa11y/pa11y-petitionsclerk.js +++ b/web-client/pa11y/pa11y-petitionsclerk.js @@ -152,6 +152,20 @@ module.exports = [ url: 'http://localhost:1234/mock-login?token=petitionsclerk&path=/case-detail/101-19&info=edit-signed-order-confirm-modal', }, + { + actions: [ + 'wait for #case-detail-menu-button to be visible', + 'wait for .progress-indicator to be hidden', + 'click element #case-detail-menu-button', + 'wait for #menu-button-add-new-message to be visible', + 'wait for .progress-indicator to be hidden', + 'click element #menu-button-add-new-message', + 'wait for .ustc-create-message-modal to be visible', + ], + notes: 'checks a11y of create message modal', + url: + 'http://localhost:1234/mock-login?token=petitionsclerk&path=/case-detail/105-19&info=create-message-modal', + }, { actions: [ 'wait for #case-detail-menu-button to be visible', @@ -468,4 +482,10 @@ module.exports = [ 'http://localhost:1234/mock-login?token=petitionsclerk&path=/search&info=practitioner-search-results', }, 'http://localhost:1234/mock-login?token=petitionsclerk&path=/practitioner-detail/PT1234', + /* case messages */ + 'http://localhost:1234/mock-login?token=petitionsclerk&path=/case-messages/my/inbox&info=case-messages-inbox', + 'http://localhost:1234/mock-login?token=petitionsclerk&path=/case-messages/my/outbox&info=case-messages-outbox', + 'http://localhost:1234/mock-login?token=petitionsclerk&path=/case-messages/section/inbox&info=case-messages-section-inbox', + 'http://localhost:1234/mock-login?token=petitionsclerk&path=/case-messages/section/outbox&info=case-messages-section-outbox', + 'http://localhost:1234/mock-login?token=petitionsclerk&path=/case-messages/105-20/message-detail/eb0a139a-8951-4de1-8b83-f02a27504105&info=case-message-detail', ]; diff --git a/web-client/pa11y/pa11y-private-practitioner.js b/web-client/pa11y/pa11y-private-practitioner.js index d7e3a89d487..30ec024adb0 100644 --- a/web-client/pa11y/pa11y-private-practitioner.js +++ b/web-client/pa11y/pa11y-private-practitioner.js @@ -5,4 +5,13 @@ module.exports = [ 'http://localhost:1234/mock-login?token=privatePractitioner&path=/file-a-petition/step-1', 'http://localhost:1234/mock-login?token=privatePractitioner&path=/case-detail/102-19/request-access', 'http://localhost:1234/mock-login?token=privatePractitioner&path=/search/no-matches', + { + actions: [ + 'wait for #tab-closed to be visible', + 'click element #tab-closed', + 'wait for element #tabContent-closed to be visible', + ], + notes: 'check the a11y of the Closed Cases tab', + url: 'http://localhost:1234/mock-login?token=privatePractitioner&path=/', + }, ]; diff --git a/web-client/pa11y/pa11y-public-user.js b/web-client/pa11y/pa11y-public-user.js index 3af6b6bd187..9fb8e4990db 100644 --- a/web-client/pa11y/pa11y-public-user.js +++ b/web-client/pa11y/pa11y-public-user.js @@ -45,4 +45,5 @@ module.exports = [ notes: 'checks a11y of advanced opinion search with results', url: 'http://localhost:5678/', }, + 'http://localhost:5678/todays-opinions', ]; diff --git a/web-client/src/applicationContext.js b/web-client/src/applicationContext.js index b869091b4f3..315ad0c05af 100644 --- a/web-client/src/applicationContext.js +++ b/web-client/src/applicationContext.js @@ -37,6 +37,18 @@ import { associatePrivatePractitionerWithCaseInteractor } from '../../shared/src import { authorizeCodeInteractor } from '../../shared/src/business/useCases/authorizeCodeInteractor'; import { batchDownloadTrialSessionInteractor } from '../../shared/src/proxies/trialSessions/batchDownloadTrialSessionProxy'; import { blockCaseFromTrialInteractor } from '../../shared/src/proxies/blockCaseFromTrialProxy'; +import { + calculateISODate, + createISODateString, + createISODateStringFromObject, + dateStringsCompared, + deconstructDate, + formatDateString, + formatNow, + isStringISOFormatted, + isValidDateString, + prepareDateFromString, +} from '../../shared/src/business/utilities/DateHandler'; import { canConsolidateInteractor } from '../../shared/src/business/useCases/caseConsolidation/canConsolidateInteractor'; import { canSetTrialSessionAsCalendaredInteractor } from '../../shared/src/business/useCases/trialSessions/canSetTrialSessionAsCalendaredInteractor'; import { caseAdvancedSearchInteractor } from '../../shared/src/proxies/caseAdvancedSearchProxy'; @@ -51,18 +63,8 @@ import { completeWorkItemInteractor } from '../../shared/src/proxies/workitems/c import { createCaseDeadlineInteractor } from '../../shared/src/proxies/caseDeadline/createCaseDeadlineProxy'; import { createCaseFromPaperInteractor } from '../../shared/src/proxies/createCaseFromPaperProxy'; import { createCaseInteractor } from '../../shared/src/proxies/createCaseProxy'; +import { createCaseMessageInteractor } from '../../shared/src/proxies/messages/createCaseMessageProxy'; import { createCourtIssuedOrderPdfFromHtmlInteractor } from '../../shared/src/proxies/courtIssuedOrder/createCourtIssuedOrderPdfFromHtmlProxy'; -import { - createISODateString, - createISODateStringFromObject, - dateStringsCompared, - deconstructDate, - formatDateString, - formatNow, - isStringISOFormatted, - isValidDateString, - prepareDateFromString, -} from '../../shared/src/business/utilities/DateHandler'; import { createPractitionerUserInteractor } from '../../shared/src/proxies/practitioners/createPractitionerUserProxy'; import { createTrialSessionInteractor } from '../../shared/src/proxies/trialSessions/createTrialSessionProxy'; import { createWorkItemInteractor } from '../../shared/src/proxies/workitems/createWorkItemProxy'; @@ -105,15 +107,18 @@ import { getCalendaredCasesForTrialSessionInteractor } from '../../shared/src/pr import { getCaseDeadlinesForCaseInteractor } from '../../shared/src/proxies/caseDeadline/getCaseDeadlinesForCaseProxy'; import { getCaseInteractor } from '../../shared/src/proxies/getCaseProxy'; import { getCaseInventoryReportInteractor } from '../../shared/src/proxies/reports/getCaseInventoryReportProxy'; +import { getCaseMessageInteractor } from '../../shared/src/proxies/messages/getCaseMessageProxy'; import { getCasesByUserInteractor } from '../../shared/src/proxies/getCasesByUserProxy'; +import { getClosedCasesInteractor } from '../../shared/src/proxies/getClosedCasesProxy'; import { getConsolidatedCasesByCaseInteractor } from '../../shared/src/proxies/getConsolidatedCasesByCaseProxy'; -import { getConsolidatedCasesByUserInteractor } from '../../shared/src/proxies/getConsolidatedCasesByUserProxy'; import { getDocument } from '../../shared/src/persistence/s3/getDocument'; import { getDocumentQCInboxForSectionInteractor } from '../../shared/src/proxies/workitems/getDocumentQCInboxForSectionProxy'; import { getDocumentQCInboxForUserInteractor } from '../../shared/src/proxies/workitems/getDocumentQCInboxForUserProxy'; import { getDocumentQCServedForSectionInteractor } from '../../shared/src/proxies/workitems/getDocumentQCServedForSectionProxy'; import { getDocumentQCServedForUserInteractor } from '../../shared/src/proxies/workitems/getDocumentQCServedForUserProxy'; import { getEligibleCasesForTrialSessionInteractor } from '../../shared/src/proxies/trialSessions/getEligibleCasesForTrialSessionProxy'; +import { getInboxCaseMessagesForSectionInteractor } from '../../shared/src/proxies/messages/getInboxCaseMessagesForSectionProxy'; +import { getInboxCaseMessagesForUserInteractor } from '../../shared/src/proxies/messages/getInboxCaseMessagesForUserProxy'; import { getInboxMessagesForSectionInteractor } from '../../shared/src/proxies/workitems/getInboxMessagesForSectionProxy'; import { getInboxMessagesForUserInteractor } from '../../shared/src/proxies/workitems/getInboxMessagesForUserProxy'; import { getInternalUsersInteractor } from '../../shared/src/proxies/users/getInternalUsersProxy'; @@ -121,7 +126,9 @@ import { getIrsPractitionersBySearchKeyInteractor } from '../../shared/src/proxi import { getItem } from '../../shared/src/persistence/localStorage/getItem'; import { getItemInteractor } from '../../shared/src/business/useCases/getItemInteractor'; import { getNotificationsInteractor } from '../../shared/src/proxies/users/getNotificationsProxy'; -import { getOpenCasesInteractor } from '../../shared/src/proxies/getOpenCasesProxy'; +import { getOpenConsolidatedCasesInteractor } from '../../shared/src/proxies/getOpenConsolidatedCasesProxy'; +import { getOutboxCaseMessagesForSectionInteractor } from '../../shared/src/proxies/messages/getOutboxCaseMessagesForSectionProxy'; +import { getOutboxCaseMessagesForUserInteractor } from '../../shared/src/proxies/messages/getOutboxCaseMessagesForUserProxy'; import { getPdfFromUrl } from '../../shared/src/persistence/s3/getPdfFromUrl'; import { getPdfFromUrlInteractor } from '../../shared/src/business/useCases/document/getPdfFromUrlInteractor'; import { getPractitionerByBarNumberInteractor } from '../../shared/src/proxies/users/getPractitionerByBarNumberProxy'; @@ -204,6 +211,7 @@ import { validateCaseAssociationRequestInteractor } from '../../shared/src/busin import { validateCaseDeadlineInteractor } from '../../shared/src/business/useCases/caseDeadline/validateCaseDeadlineInteractor'; import { validateCaseDetailInteractor } from '../../shared/src/business/useCases/validateCaseDetailInteractor'; import { validateCourtIssuedDocketEntryInteractor } from '../../shared/src/business/useCases/courtIssuedDocument/validateCourtIssuedDocketEntryInteractor'; +import { validateCreateCaseMessageInteractor } from '../../shared/src/business/useCases/messages/validateCreateCaseMessageInteractor'; import { validateDocketEntryInteractor } from '../../shared/src/business/useCases/docketEntry/validateDocketEntryInteractor'; import { validateEditPrivatePractitionerInteractor } from '../../shared/src/business/useCases/caseAssociation/validateEditPrivatePractitionerInteractor'; import { validateExternalDocumentInformationInteractor } from '../../shared/src/business/useCases/externalDocument/validateExternalDocumentInformationInteractor'; @@ -267,6 +275,7 @@ const allUseCases = { createCaseDeadlineInteractor, createCaseFromPaperInteractor, createCaseInteractor, + createCaseMessageInteractor, createCourtIssuedOrderPdfFromHtmlInteractor, createPractitionerUserInteractor, createTrialSessionInteractor, @@ -304,14 +313,17 @@ const allUseCases = { getCaseDeadlinesForCaseInteractor, getCaseInteractor, getCaseInventoryReportInteractor, + getCaseMessageInteractor, getCasesByUserInteractor, + getClosedCasesInteractor, getConsolidatedCasesByCaseInteractor, - getConsolidatedCasesByUserInteractor, getDocumentQCInboxForSectionInteractor, getDocumentQCInboxForUserInteractor, getDocumentQCServedForSectionInteractor, getDocumentQCServedForUserInteractor, getEligibleCasesForTrialSessionInteractor, + getInboxCaseMessagesForSectionInteractor, + getInboxCaseMessagesForUserInteractor, getInboxMessagesForSectionInteractor, getInboxMessagesForUserInteractor, getInternalUsersInteractor, @@ -319,7 +331,9 @@ const allUseCases = { getItemInteractor, getJudgeForUserChambersInteractor, getNotificationsInteractor, - getOpenCasesInteractor, + getOpenConsolidatedCasesInteractor, + getOutboxCaseMessagesForSectionInteractor, + getOutboxCaseMessagesForUserInteractor, getPdfFromUrlInteractor, getPractitionerByBarNumberInteractor, getPractitionersByNameInteractor, @@ -395,6 +409,7 @@ const allUseCases = { validateCaseDeadlineInteractor, validateCaseDetailInteractor, validateCourtIssuedDocketEntryInteractor, + validateCreateCaseMessageInteractor, validateDocketEntryInteractor, validateDocketRecordInteractor, validateEditPrivatePractitionerInteractor, @@ -500,6 +515,7 @@ const applicationContext = { getUserPermissions, getUtilities: () => { return { + calculateISODate, compareCasesByDocketNumber, compareISODateStrings, compareStrings, diff --git a/web-client/src/applicationContextPublic.js b/web-client/src/applicationContextPublic.js index 3ad6cb15947..37ec3be2629 100644 --- a/web-client/src/applicationContextPublic.js +++ b/web-client/src/applicationContextPublic.js @@ -1,9 +1,16 @@ +import { + CASE_CAPTION_POSTFIX, + CASE_SEARCH_PAGE_SIZE, + COUNTRY_TYPES, + US_STATES, +} from '../../shared/src/business/entities/EntityConstants'; import { Case } from '../../shared/src/business/entities/cases/Case'; -import { CaseSearch } from '../../shared/src/business/entities/cases/CaseSearch'; -import { ContactFactory } from '../../shared/src/business/entities/contacts/ContactFactory'; import { casePublicSearchInteractor } from '../../shared/src/proxies/casePublicSearchProxy'; import { compareCasesByDocketNumber } from '../../shared/src/business/utilities/getFormattedTrialSessionDetails'; -import { formatDateString } from '../../shared/src/business/utilities/DateHandler'; +import { + createISODateString, + formatDateString, +} from '../../shared/src/business/utilities/DateHandler'; import { formatDocketRecord, formatDocketRecordWithDocument, @@ -18,6 +25,7 @@ import { import { getJudgeLastName } from '../../shared/src/business/utilities/getFormattedJudgeName'; import { getPublicCaseInteractor } from '../../shared/src/proxies/getPublicCaseProxy'; import { getPublicJudgesInteractor } from '../../shared/src/proxies/public/getPublicJudgesProxy'; +import { getTodaysOpinionsInteractor } from '../../shared/src/proxies/public/getTodaysOpinionsProxy'; import { opinionPublicSearchInteractor } from '../../shared/src/proxies/opinionPublicSearchProxy'; import { orderPublicSearchInteractor } from '../../shared/src/proxies/orderPublicSearchProxy'; import { validateCaseAdvancedSearchInteractor } from '../../shared/src/business/useCases/validateCaseAdvancedSearchInteractor'; @@ -41,10 +49,10 @@ const applicationContextPublic = { getConstants: () => deepFreeze({ ADVANCED_SEARCH_TABS, - CASE_CAPTION_POSTFIX: Case.CASE_CAPTION_POSTFIX, - CASE_SEARCH_PAGE_SIZE: CaseSearch.CASE_SEARCH_PAGE_SIZE, - COUNTRY_TYPES: ContactFactory.COUNTRY_TYPES, - US_STATES: ContactFactory.US_STATES, + CASE_CAPTION_POSTFIX: CASE_CAPTION_POSTFIX, + CASE_SEARCH_PAGE_SIZE: CASE_SEARCH_PAGE_SIZE, + COUNTRY_TYPES: COUNTRY_TYPES, + US_STATES: US_STATES, }), getCurrentUserToken: () => null, getHttpClient: () => axios, @@ -55,6 +63,7 @@ const applicationContextPublic = { getCaseForPublicDocketSearchInteractor, getCaseInteractor: getPublicCaseInteractor, getPublicJudgesInteractor, + getTodaysOpinionsInteractor, opinionPublicSearchInteractor, orderPublicSearchInteractor, validateCaseAdvancedSearchInteractor, @@ -64,6 +73,7 @@ const applicationContextPublic = { getUtilities: () => { return { compareCasesByDocketNumber, + createISODateString, formatDateString, formatDocketRecord, formatDocketRecordWithDocument, diff --git a/web-client/src/getConstants.js b/web-client/src/getConstants.js index 8ae6943d403..e57f1e327a3 100644 --- a/web-client/src/getConstants.js +++ b/web-client/src/getConstants.js @@ -1,27 +1,52 @@ import { + ADMISSIONS_STATUS_OPTIONS, + BUSINESS_TYPES, + CASE_CAPTION_POSTFIX, + CASE_SEARCH_PAGE_SIZE, + CASE_STATUS_TYPES, + CASE_TYPES, + CASE_TYPES_MAP, CHAMBERS_SECTION, CHAMBERS_SECTIONS, - SECTIONS, -} from '../../shared/src/business/entities/WorkQueue'; -import { Case } from '../../shared/src/business/entities/cases/Case'; -import { CaseInternal } from '../../shared/src/business/entities/cases/CaseInternal'; -import { CaseSearch } from '../../shared/src/business/entities/cases/CaseSearch'; -import { ContactFactory } from '../../shared/src/business/entities/contacts/ContactFactory'; -import { Document } from '../../shared/src/business/entities/Document'; -import { FORMATS } from '../../shared/src/business/utilities/DateHandler'; -import { + CHIEF_JUDGE, + CONTACT_CHANGE_DOCUMENT_TYPES, + COUNTRY_TYPES, + COURT_ISSUED_EVENT_CODES, + DEFAULT_PROCEDURE_TYPE, + DOCUMENT_CATEGORIES, + DOCUMENT_CATEGORY_MAP, + DOCUMENT_INTERNAL_CATEGORY_MAP, + DOCUMENT_NOTICE_EVENT_CODES, + EMPLOYER_OPTIONS, + ESTATE_TYPES, + FILING_TYPES, + INITIAL_DOCUMENT_TYPES, MAX_FILE_SIZE_BYTES, MAX_FILE_SIZE_MB, -} from '../../shared/src/persistence/s3/getUploadPolicy'; -import { Order } from '../../shared/src/business/entities/orders/Order'; -import { Practitioner } from '../../shared/src/business/entities/Practitioner'; + ORDER_TYPES, + OTHER_TYPES, + PARTY_TYPES, + PAYMENT_STATUS, + PRACTITIONER_TYPE_OPTIONS, + PROCEDURE_TYPES, + ROLES, + SCAN_MODES, + SECTIONS, + SERVICE_INDICATOR_TYPES, + SESSION_STATUS_GROUPS, + SESSION_TYPES, + SIGNED_DOCUMENT_TYPES, + STATUS_TYPES_MANUAL_UPDATE, + STATUS_TYPES_WITH_ASSOCIATED_JUDGE, + SYSTEM_GENERATED_DOCUMENT_TYPES, + TRANSCRIPT_EVENT_CODE, + TRIAL_CITIES, + TRIAL_STATUS_TYPES, + US_STATES, +} from '../../shared/src/business/entities/EntityConstants'; +import { FORMATS } from '../../shared/src/business/utilities/DateHandler'; import { ROLE_PERMISSIONS } from '../../shared/src/authorization/authorizationClientService'; -import { SERVICE_INDICATOR_TYPES } from '../../shared/src/business/entities/cases/CaseConstants'; import { SERVICE_STAMP_OPTIONS } from '../../shared/src/business/entities/courtIssuedDocument/CourtIssuedDocumentConstants'; -import { Scan } from '../../shared/src/business/entities/Scan'; -import { TrialSession } from '../../shared/src/business/entities/trialSessions/TrialSession'; -import { TrialSessionWorkingCopy } from '../../shared/src/business/entities/trialSessions/TrialSessionWorkingCopy'; -import { User } from '../../shared/src/business/entities/User'; const MINUTES = 60 * 1000; @@ -32,60 +57,67 @@ const ADVANCED_SEARCH_TABS = { PRACTITIONER: 'practitioner', }; +const EXTERNAL_USER_DASHBOARD_TABS = { + CLOSED: 'Closed', + OPEN: 'Open', +}; + export const getConstants = () => ({ - ADMISSIONS_STATUS_OPTIONS: Practitioner.ADMISSIONS_STATUS_OPTIONS, + ADMISSIONS_STATUS_OPTIONS, ADVANCED_SEARCH_TABS, - BUSINESS_TYPES: ContactFactory.BUSINESS_TYPES, - CASE_CAPTION_POSTFIX: Case.CASE_CAPTION_POSTFIX, + BUSINESS_TYPES: BUSINESS_TYPES, + CASE_CAPTION_POSTFIX, CASE_INVENTORY_PAGE_SIZE: 2, - CASE_SEARCH_PAGE_SIZE: CaseSearch.CASE_SEARCH_PAGE_SIZE, - CASE_TYPES: Case.CASE_TYPES, - CASE_TYPES_MAP: Case.CASE_TYPES_MAP, - CATEGORIES: Document.CATEGORIES, - CATEGORY_MAP: Document.CATEGORY_MAP, + CASE_LIST_PAGE_SIZE: 20, + CASE_SEARCH_PAGE_SIZE, + CASE_TYPES, + CASE_TYPES_MAP, + CATEGORIES: DOCUMENT_CATEGORIES, + CATEGORY_MAP: DOCUMENT_CATEGORY_MAP, CHAMBERS_SECTION, CHAMBERS_SECTIONS, - CHIEF_JUDGE: Case.CHIEF_JUDGE, - CONTACT_CHANGE_DOCUMENT_TYPES: Document.CONTACT_CHANGE_DOCUMENT_TYPES, - COUNTRY_TYPES: ContactFactory.COUNTRY_TYPES, - COURT_ISSUED_EVENT_CODES: Document.COURT_ISSUED_EVENT_CODES, + CHIEF_JUDGE, + CONTACT_CHANGE_DOCUMENT_TYPES: CONTACT_CHANGE_DOCUMENT_TYPES, + COUNTRY_TYPES, + COURT_ISSUED_EVENT_CODES: COURT_ISSUED_EVENT_CODES, DATE_FORMATS: FORMATS, - DEFAULT_PROCEDURE_TYPE: CaseInternal.DEFAULT_PROCEDURE_TYPE, - EMPLOYER_OPTIONS: Practitioner.EMPLOYER_OPTIONS, - ESTATE_TYPES: ContactFactory.ESTATE_TYPES, - FILING_TYPES: Case.FILING_TYPES, - INITIAL_DOCUMENT_TYPES: Document.INITIAL_DOCUMENT_TYPES, - INTERNAL_CATEGORY_MAP: Document.INTERNAL_CATEGORY_MAP, + DEFAULT_PROCEDURE_TYPE, + EMPLOYER_OPTIONS, + ESTATE_TYPES, + EXTERNAL_USER_DASHBOARD_TABS, + FILING_TYPES, + INITIAL_DOCUMENT_TYPES, + INTERNAL_CATEGORY_MAP: DOCUMENT_INTERNAL_CATEGORY_MAP, MAX_FILE_SIZE_BYTES, MAX_FILE_SIZE_MB, - NOTICE_EVENT_CODES: Document.NOTICE_EVENT_CODES, - ORDER_TYPES_MAP: Order.ORDER_TYPES, - OTHER_TYPES: ContactFactory.OTHER_TYPES, - PARTY_TYPES: ContactFactory.PARTY_TYPES, - PAYMENT_STATUS: Case.PAYMENT_STATUS, - PRACTITIONER_TYPE_OPTIONS: Practitioner.PRACTITIONER_TYPE_OPTIONS, - PROCEDURE_TYPES: Case.PROCEDURE_TYPES, + NOTICE_EVENT_CODES: DOCUMENT_NOTICE_EVENT_CODES, + ORDER_TYPES_MAP: ORDER_TYPES, + OTHER_TYPES, + PARTY_TYPES, + PAYMENT_STATUS, + PRACTITIONER_TYPE_OPTIONS, + PROCEDURE_TYPES, REFRESH_INTERVAL: 20 * MINUTES, ROLE_PERMISSIONS, - SCAN_MODES: Scan.SCAN_MODES, + SCAN_MODES, SECTIONS, SERVICE_INDICATOR_TYPES, SERVICE_STAMP_OPTIONS, SESSION_DEBOUNCE: 250, SESSION_MODAL_TIMEOUT: 5 * MINUTES, - SESSION_STATUS_GROUPS: TrialSession.SESSION_STATUS_GROUPS, + SESSION_STATUS_GROUPS, SESSION_TIMEOUT: (process.env.SESSION_TIMEOUT && parseInt(process.env.SESSION_TIMEOUT)) || 55 * MINUTES, - SIGNED_DOCUMENT_TYPES: Document.SIGNED_DOCUMENT_TYPES, - STATUS_TYPES: Case.STATUS_TYPES, - STATUS_TYPES_MANUAL_UPDATE: Case.STATUS_TYPES_MANUAL_UPDATE, - STATUS_TYPES_WITH_ASSOCIATED_JUDGE: Case.STATUS_TYPES_WITH_ASSOCIATED_JUDGE, - SYSTEM_GENERATED_DOCUMENT_TYPES: Document.SYSTEM_GENERATED_DOCUMENT_TYPES, - TRANSCRIPT_EVENT_CODE: Document.TRANSCRIPT_EVENT_CODE, - TRIAL_CITIES: TrialSession.TRIAL_CITIES, - TRIAL_SESSION_TYPES: TrialSession.SESSION_TYPES, - TRIAL_STATUS_TYPES: TrialSessionWorkingCopy.TRIAL_STATUS_TYPES, - US_STATES: ContactFactory.US_STATES, - USER_ROLES: User.ROLES, + SIGNED_DOCUMENT_TYPES: SIGNED_DOCUMENT_TYPES, + STATUS_TYPES: CASE_STATUS_TYPES, + STATUS_TYPES_MANUAL_UPDATE, + STATUS_TYPES_WITH_ASSOCIATED_JUDGE: STATUS_TYPES_WITH_ASSOCIATED_JUDGE, + SYSTEM_GENERATED_DOCUMENT_TYPES: SYSTEM_GENERATED_DOCUMENT_TYPES, + TRANSCRIPT_EVENT_CODE: TRANSCRIPT_EVENT_CODE, + TRIAL_CITIES: TRIAL_CITIES, + TRIAL_SESSION_TYPES: SESSION_TYPES, + TRIAL_STATUS_TYPES, + US_STATES, + USER_ROLES: ROLES, }); diff --git a/web-client/src/index.pug b/web-client/src/index.pug index d32f3fb05e6..daad13f706a 100644 --- a/web-client/src/index.pug +++ b/web-client/src/index.pug @@ -2,7 +2,6 @@ doctype html html(lang="en") head meta(charset="utf-8") - meta(built="" + (new Date()).toLocaleString('en-US', {weekday: 'short', year: 'numeric', month: 'short', day: 'numeric', hour: 'numeric', minute: 'numeric', timeZone: 'America/New_York'}) + " EST") meta(revision="" + (process.env.CIRCLE_SHA1 || '').substr(0,7)) meta(name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no") title U.S. Tax Court Electronic Filing and Case Management System @@ -18,4 +17,6 @@ html(lang="en") #app #modal-root #dwtcontrolContainer + footer.grid-container.position-fixed.bottom-0.right-0 + p Deployed #{(new Date()).toLocaleString('en-US', {weekday: 'short', year: 'numeric', month: 'short', day: 'numeric', hour: 'numeric', minute: 'numeric', timeZone: 'America/New_York'})} EST script(src="index." + process.env.USTC_ENV + ".js") diff --git a/web-client/src/presenter/actions/AdvancedSearch/defaultAdvancedSearchFormAction.test.js b/web-client/src/presenter/actions/AdvancedSearch/defaultAdvancedSearchFormAction.test.js index 53b1c29a7fa..8f055f5cd3e 100644 --- a/web-client/src/presenter/actions/AdvancedSearch/defaultAdvancedSearchFormAction.test.js +++ b/web-client/src/presenter/actions/AdvancedSearch/defaultAdvancedSearchFormAction.test.js @@ -1,4 +1,4 @@ -import { ContactFactory } from '../../../../../shared/src/business/entities/contacts/ContactFactory'; +import { COUNTRY_TYPES } from '../../../../../shared/src/business/entities/EntityConstants'; import { applicationContextForClient } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { defaultAdvancedSearchFormAction } from './defaultAdvancedSearchFormAction'; import { presenter } from '../../presenter-mock'; @@ -18,7 +18,7 @@ describe('defaultAdvancedSearchFormAction', () => { expect(result.state.advancedSearchForm).toEqual({ caseSearchByDocketNumber: {}, caseSearchByName: { - countryType: ContactFactory.COUNTRY_TYPES.DOMESTIC, + countryType: COUNTRY_TYPES.DOMESTIC, }, opinionSearch: {}, orderSearch: {}, @@ -46,7 +46,7 @@ describe('defaultAdvancedSearchFormAction', () => { advancedSearchForm: { caseSearchByDocketNumber: { yes: true }, caseSearchByName: { - countryType: ContactFactory.COUNTRY_TYPES.INTERNATIONAL, + countryType: COUNTRY_TYPES.INTERNATIONAL, no: false, }, opinionSearch: {}, @@ -61,7 +61,7 @@ describe('defaultAdvancedSearchFormAction', () => { expect(result.state.advancedSearchForm).toEqual({ caseSearchByDocketNumber: { yes: true }, caseSearchByName: { - countryType: ContactFactory.COUNTRY_TYPES.INTERNATIONAL, + countryType: COUNTRY_TYPES.INTERNATIONAL, no: false, }, opinionSearch: {}, diff --git a/web-client/src/presenter/actions/CaseDetail/createCaseMessageAction.js b/web-client/src/presenter/actions/CaseDetail/createCaseMessageAction.js new file mode 100644 index 00000000000..6334d6a75f3 --- /dev/null +++ b/web-client/src/presenter/actions/CaseDetail/createCaseMessageAction.js @@ -0,0 +1,19 @@ +import { state } from 'cerebral'; + +export const createCaseMessageAction = async ({ applicationContext, get }) => { + const form = get(state.modal.form); + + const { caseId } = get(state.caseDetail); + + await applicationContext.getUseCases().createCaseMessageInteractor({ + applicationContext, + caseId, + ...form, + }); + + return { + alertSuccess: { + message: 'Your message has been sent.', + }, + }; +}; diff --git a/web-client/src/presenter/actions/CaseDetail/createCaseMessageAction.test.js b/web-client/src/presenter/actions/CaseDetail/createCaseMessageAction.test.js new file mode 100644 index 00000000000..7391d264753 --- /dev/null +++ b/web-client/src/presenter/actions/CaseDetail/createCaseMessageAction.test.js @@ -0,0 +1,54 @@ +import { applicationContextForClient as applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; +import { createCaseMessageAction } from './createCaseMessageAction'; +import { presenter } from '../../presenter-mock'; +import { runAction } from 'cerebral/test'; + +describe('createCaseMessageAction', () => { + beforeAll(() => { + presenter.providers.applicationContext = applicationContext; + }); + + it('should call createCaseMessageInteractor with the expected parameters and return the alertSuccess', async () => { + const result = await runAction(createCaseMessageAction, { + modules: { + presenter, + }, + state: { + caseDetail: { + caseId: 'a7806fa0-ce6a-41ca-b66e-59438953f8bb', + }, + modal: { + form: { + attachments: [ + { + documentId: 'b1130321-0a76-43bc-b3eb-64a18f079873', + documentTitle: 'Petition', + }, + ], + message: 'You there!', + subject: 'Hey!', + }, + }, + }, + }); + + expect( + applicationContext.getUseCases().createCaseMessageInteractor, + ).toBeCalled(); + expect( + applicationContext.getUseCases().createCaseMessageInteractor.mock + .calls[0][0], + ).toMatchObject({ + attachments: [ + { + documentId: 'b1130321-0a76-43bc-b3eb-64a18f079873', + documentTitle: 'Petition', + }, + ], + caseId: 'a7806fa0-ce6a-41ca-b66e-59438953f8bb', + message: 'You there!', + subject: 'Hey!', + }); + expect(result.output).toHaveProperty('alertSuccess'); + }); +}); diff --git a/web-client/src/presenter/actions/CaseDetail/validateUpdateCaseModalAction.test.js b/web-client/src/presenter/actions/CaseDetail/validateUpdateCaseModalAction.test.js index 8c4a854e3c5..36f2a09a5fa 100644 --- a/web-client/src/presenter/actions/CaseDetail/validateUpdateCaseModalAction.test.js +++ b/web-client/src/presenter/actions/CaseDetail/validateUpdateCaseModalAction.test.js @@ -1,4 +1,4 @@ -import { Case } from '../../../../../shared/src/business/entities/cases/Case'; +import { CASE_STATUS_TYPES } from '../../../../../shared/src/business/entities/EntityConstants'; import { applicationContextForClient } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { presenter } from '../../presenter-mock'; import { runAction } from 'cerebral/test'; @@ -28,7 +28,7 @@ describe('validateUpdateCaseModalAction', () => { state: { modal: { caseCaption: 'A case caption', - caseStatus: Case.STATUS_TYPES.closed, + caseStatus: CASE_STATUS_TYPES.closed, }, }, }); @@ -46,7 +46,7 @@ describe('validateUpdateCaseModalAction', () => { modal: { associatedJudge: 'Judge Armen', caseCaption: 'A case caption', - caseStatus: Case.STATUS_TYPES.submitted, + caseStatus: CASE_STATUS_TYPES.submitted, }, }, }); @@ -63,7 +63,7 @@ describe('validateUpdateCaseModalAction', () => { state: { modal: { associatedJudge: 'Judge Armen', - caseStatus: Case.STATUS_TYPES.submitted, + caseStatus: CASE_STATUS_TYPES.submitted, }, }, }); @@ -97,7 +97,7 @@ describe('validateUpdateCaseModalAction', () => { state: { modal: { caseCaption: 'A case caption', - caseStatus: Case.STATUS_TYPES.submitted, + caseStatus: CASE_STATUS_TYPES.submitted, }, }, }); diff --git a/web-client/src/presenter/actions/CaseInventoryReport/generatePrintableCaseInventoryReportAction.js b/web-client/src/presenter/actions/CaseInventoryReport/generatePrintableCaseInventoryReportAction.js index 9d5626f0fef..ebeccdc8798 100644 --- a/web-client/src/presenter/actions/CaseInventoryReport/generatePrintableCaseInventoryReportAction.js +++ b/web-client/src/presenter/actions/CaseInventoryReport/generatePrintableCaseInventoryReportAction.js @@ -6,6 +6,7 @@ import { state } from 'cerebral'; * @param {object} providers the providers object * @param {object} providers.applicationContext the application context * @param {Function} providers.get the cerebral get function + * @returns {Promise} the url of the printable pdf */ export const generatePrintableCaseInventoryReportAction = async ({ applicationContext, diff --git a/web-client/src/presenter/actions/CourtIssuedDocketEntry/setDefaultServiceStampAction.test.js b/web-client/src/presenter/actions/CourtIssuedDocketEntry/setDefaultServiceStampAction.test.js index f588bbac325..02dcf5ff4cf 100644 --- a/web-client/src/presenter/actions/CourtIssuedDocketEntry/setDefaultServiceStampAction.test.js +++ b/web-client/src/presenter/actions/CourtIssuedDocketEntry/setDefaultServiceStampAction.test.js @@ -1,4 +1,4 @@ -import { User } from '../../../../../shared/src/business/entities/User'; +import { ROLES } from '../../../../../shared/src/business/entities/EntityConstants'; import { applicationContextForClient as applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { presenter } from '../../presenter-mock'; import { runAction } from 'cerebral/test'; @@ -9,7 +9,7 @@ presenter.providers.applicationContext = applicationContext; describe('setDefaultServiceStampAction', () => { it('should set default serviceStamp on form if user is a petitions clerk', async () => { applicationContext.getCurrentUser = () => ({ - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, }); const result = await runAction(setDefaultServiceStampAction, { @@ -28,7 +28,7 @@ describe('setDefaultServiceStampAction', () => { it('should not set default serviceStamp on form if user is a docket clerk', async () => { applicationContext.getCurrentUser = () => ({ - role: User.ROLES.docketClerk, + role: ROLES.docketClerk, }); const result = await runAction(setDefaultServiceStampAction, { diff --git a/web-client/src/presenter/actions/Dashboard/incrementCurrentPageClosedCasesAction.js b/web-client/src/presenter/actions/Dashboard/incrementCurrentPageClosedCasesAction.js new file mode 100644 index 00000000000..a4d0ffb2300 --- /dev/null +++ b/web-client/src/presenter/actions/Dashboard/incrementCurrentPageClosedCasesAction.js @@ -0,0 +1,14 @@ +import { state } from 'cerebral'; + +/** + * increments state.closedCasesCurrentPage by 1 + * + * @param {object} providers the providers object + * @param {Function} providers.get the cerebral get function + * @param {Function} providers.store the cerebral store function + */ +export const incrementCurrentPageClosedCasesAction = ({ get, store }) => { + const currentPage = get(state.closedCasesCurrentPage) || 1; + + store.set(state.closedCasesCurrentPage, currentPage + 1); +}; diff --git a/web-client/src/presenter/actions/Dashboard/incrementCurrentPageClosedCasesAction.test.js b/web-client/src/presenter/actions/Dashboard/incrementCurrentPageClosedCasesAction.test.js new file mode 100644 index 00000000000..dd4d1057846 --- /dev/null +++ b/web-client/src/presenter/actions/Dashboard/incrementCurrentPageClosedCasesAction.test.js @@ -0,0 +1,14 @@ +import { incrementCurrentPageClosedCasesAction } from './incrementCurrentPageClosedCasesAction'; +import { presenter } from '../../presenter-mock'; +import { runAction } from 'cerebral/test'; + +describe('incrementCurrentPageClosedCasesAction', () => { + it('increments state.closedCasesCurrentPage by 1', async () => { + const result = await runAction(incrementCurrentPageClosedCasesAction, { + modules: { presenter }, + state: { closedCasesCurrentPage: 2 }, + }); + + expect(result.state.closedCasesCurrentPage).toEqual(3); + }); +}); diff --git a/web-client/src/presenter/actions/Dashboard/incrementCurrentPageOpenCasesAction.js b/web-client/src/presenter/actions/Dashboard/incrementCurrentPageOpenCasesAction.js new file mode 100644 index 00000000000..26196811c22 --- /dev/null +++ b/web-client/src/presenter/actions/Dashboard/incrementCurrentPageOpenCasesAction.js @@ -0,0 +1,14 @@ +import { state } from 'cerebral'; + +/** + * increments state.openCasesCurrentPage by 1 + * + * @param {object} providers the providers object + * @param {Function} providers.get the cerebral get function + * @param {Function} providers.store the cerebral store function + */ +export const incrementCurrentPageOpenCasesAction = ({ get, store }) => { + const currentPage = get(state.openCasesCurrentPage) || 1; + + store.set(state.openCasesCurrentPage, currentPage + 1); +}; diff --git a/web-client/src/presenter/actions/Dashboard/incrementCurrentPageOpenCasesAction.test.js b/web-client/src/presenter/actions/Dashboard/incrementCurrentPageOpenCasesAction.test.js new file mode 100644 index 00000000000..c9697c07c7f --- /dev/null +++ b/web-client/src/presenter/actions/Dashboard/incrementCurrentPageOpenCasesAction.test.js @@ -0,0 +1,14 @@ +import { incrementCurrentPageOpenCasesAction } from './incrementCurrentPageOpenCasesAction'; +import { presenter } from '../../presenter-mock'; +import { runAction } from 'cerebral/test'; + +describe('incrementCurrentPageOpenCasesAction', () => { + it('increments state.openCasesCurrentPage by 1', async () => { + const result = await runAction(incrementCurrentPageOpenCasesAction, { + modules: { presenter }, + state: { openCasesCurrentPage: 2 }, + }); + + expect(result.state.openCasesCurrentPage).toEqual(3); + }); +}); diff --git a/web-client/src/presenter/actions/EditDocketRecordEntry/setDocketEntryMetaTypeAction.test.js b/web-client/src/presenter/actions/EditDocketRecordEntry/setDocketEntryMetaTypeAction.test.js index 89c9fdc471f..c1f8e7d218d 100644 --- a/web-client/src/presenter/actions/EditDocketRecordEntry/setDocketEntryMetaTypeAction.test.js +++ b/web-client/src/presenter/actions/EditDocketRecordEntry/setDocketEntryMetaTypeAction.test.js @@ -1,4 +1,4 @@ -import { Document } from '../../../../../shared/src/business/entities/Document'; +import { COURT_ISSUED_EVENT_CODES } from '../../../../../shared/src/business/entities/EntityConstants'; import { applicationContextForClient } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { presenter } from '../../presenter-mock'; import { runAction } from 'cerebral/test'; @@ -13,7 +13,7 @@ describe('setDocketEntryMetaTypeAction', () => { state: { form: { documentId: '123', - eventCode: Document.COURT_ISSUED_EVENT_CODES[0].eventCode, + eventCode: COURT_ISSUED_EVENT_CODES[0].eventCode, }, }, }); diff --git a/web-client/src/presenter/actions/FileDocument/setDefaultFileDocumentFormValuesAction.test.js b/web-client/src/presenter/actions/FileDocument/setDefaultFileDocumentFormValuesAction.test.js index ebbe411c2e1..2a8eb1054e8 100644 --- a/web-client/src/presenter/actions/FileDocument/setDefaultFileDocumentFormValuesAction.test.js +++ b/web-client/src/presenter/actions/FileDocument/setDefaultFileDocumentFormValuesAction.test.js @@ -1,4 +1,4 @@ -import { User } from '../../../../../shared/src/business/entities/User'; +import { ROLES } from '../../../../../shared/src/business/entities/EntityConstants'; import { applicationContextForClient as applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { presenter } from '../../presenter-mock'; import { runAction } from 'cerebral/test'; @@ -9,7 +9,7 @@ describe('setDefaultFileDocumentFormValuesAction', () => { it('sets form.partyPrimary to true if the user is a petitioner', async () => { applicationContext.getCurrentUser = () => ({ - role: User.ROLES.petitioner, + role: ROLES.petitioner, }); const result = await runAction(setDefaultFileDocumentFormValuesAction, { modules: { presenter }, @@ -24,7 +24,7 @@ describe('setDefaultFileDocumentFormValuesAction', () => { }); it('does not set form.partyPrimary if the user is not a petitioner', async () => { applicationContext.getCurrentUser = () => ({ - role: User.ROLES.privatePractitioner, + role: ROLES.privatePractitioner, }); const result = await runAction(setDefaultFileDocumentFormValuesAction, { modules: { presenter }, diff --git a/web-client/src/presenter/actions/FileDocument/submitCaseAssociationRequestAction.test.js b/web-client/src/presenter/actions/FileDocument/submitCaseAssociationRequestAction.test.js index 6813a699231..5793d8b3ea0 100644 --- a/web-client/src/presenter/actions/FileDocument/submitCaseAssociationRequestAction.test.js +++ b/web-client/src/presenter/actions/FileDocument/submitCaseAssociationRequestAction.test.js @@ -1,3 +1,4 @@ +import { ROLES } from '../../../../../shared/src/business/entities/EntityConstants'; import { User } from '../../../../../shared/src/business/entities/User'; import { applicationContextForClient as applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { presenter } from '../../presenter-mock'; @@ -18,7 +19,7 @@ describe('submitCaseAssociationRequestAction', () => { new User({ email: 'practitioner1@example.com', name: 'richard', - role: User.ROLES.privatePractitioner, + role: ROLES.privatePractitioner, userId: 'a805d1ab-18d0-43ec-bafb-654e83405416', }), ); diff --git a/web-client/src/presenter/actions/ManualAssociation/associateIrsPractitionerWithCaseAction.test.js b/web-client/src/presenter/actions/ManualAssociation/associateIrsPractitionerWithCaseAction.test.js index 42ffe56ae36..ba5579908a9 100644 --- a/web-client/src/presenter/actions/ManualAssociation/associateIrsPractitionerWithCaseAction.test.js +++ b/web-client/src/presenter/actions/ManualAssociation/associateIrsPractitionerWithCaseAction.test.js @@ -1,4 +1,4 @@ -import { SERVICE_INDICATOR_TYPES } from '../../../../../shared/src/business/entities/cases/CaseConstants'; +import { SERVICE_INDICATOR_TYPES } from '../../../../../shared/src/business/entities/EntityConstants'; import { applicationContextForClient } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { associateIrsPractitionerWithCaseAction } from './associateIrsPractitionerWithCaseAction'; import { presenter } from '../../presenter-mock'; diff --git a/web-client/src/presenter/actions/Public/getPublicJudgesAction.test.js b/web-client/src/presenter/actions/Public/getPublicJudgesAction.test.js index d02786d1fc3..c3deac65a61 100644 --- a/web-client/src/presenter/actions/Public/getPublicJudgesAction.test.js +++ b/web-client/src/presenter/actions/Public/getPublicJudgesAction.test.js @@ -1,4 +1,4 @@ -import { User } from '../../../../../shared/src/business/entities/User'; +import { ROLES } from '../../../../../shared/src/business/entities/EntityConstants'; import { applicationContextForClient as applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { getPublicJudgesAction } from './getPublicJudgesAction'; import { presenter } from '../../presenter-public'; @@ -13,11 +13,11 @@ describe('getPublicJudgesAction', () => { const mockJudges = [ { name: 'Test Judge', - role: User.ROLES.judge, + role: ROLES.judge, }, { name: 'Test Judge2', - role: User.ROLES.judge, + role: ROLES.judge, }, ]; applicationContext diff --git a/web-client/src/presenter/actions/Public/getTodaysOpinionsAction.js b/web-client/src/presenter/actions/Public/getTodaysOpinionsAction.js new file mode 100644 index 00000000000..26f1a56ac1e --- /dev/null +++ b/web-client/src/presenter/actions/Public/getTodaysOpinionsAction.js @@ -0,0 +1,14 @@ +/** + * gets today's opinions + * + * @param {object} providers the providers object + * @param {object} providers.applicationContext the applicationContext + * @returns {Promise} a list of today's opinion documents + */ +export const getTodaysOpinionsAction = async ({ applicationContext }) => { + const todaysOpinions = await applicationContext + .getUseCases() + .getTodaysOpinionsInteractor({ applicationContext }); + + return { todaysOpinions }; +}; diff --git a/web-client/src/presenter/actions/Public/getTodaysOpinionsAction.test.js b/web-client/src/presenter/actions/Public/getTodaysOpinionsAction.test.js new file mode 100644 index 00000000000..47996ade8a9 --- /dev/null +++ b/web-client/src/presenter/actions/Public/getTodaysOpinionsAction.test.js @@ -0,0 +1,34 @@ +import { applicationContextForClient as applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; +import { getTodaysOpinionsAction } from './getTodaysOpinionsAction'; +import { presenter } from '../../presenter-public'; +import { runAction } from 'cerebral/test'; + +describe('getTodaysOpinionsAction', () => { + beforeAll(() => { + presenter.providers.applicationContext = applicationContext; + }); + + it('gets the list of todays opinion', async () => { + const mockTodaysOpinions = [ + { + documentId: '1234', + documentTitle: 'An opinion', + }, + { + documentId: '5678', + documentTitle: 'Another opinion', + }, + ]; + applicationContext + .getUseCases() + .getTodaysOpinionsInteractor.mockReturnValue(mockTodaysOpinions); + + const result = await runAction(getTodaysOpinionsAction, { + modules: { + presenter, + }, + }); + + expect(result.output.todaysOpinions).toMatchObject(mockTodaysOpinions); + }); +}); diff --git a/web-client/src/presenter/actions/Public/setTodaysOpinionsAction.js b/web-client/src/presenter/actions/Public/setTodaysOpinionsAction.js new file mode 100644 index 00000000000..4cbf435f544 --- /dev/null +++ b/web-client/src/presenter/actions/Public/setTodaysOpinionsAction.js @@ -0,0 +1,10 @@ +import { state } from 'cerebral'; +/** + * sets the state.todaysOpinions based on props.todaysOpinions + * + * @param {object} props the props object + * @param {object} store the store object + */ +export const setTodaysOpinionsAction = async ({ props, store }) => { + store.set(state.todaysOpinions, props.todaysOpinions); +}; diff --git a/web-client/src/presenter/actions/Public/setTodaysOpinionsAction.test.js b/web-client/src/presenter/actions/Public/setTodaysOpinionsAction.test.js new file mode 100644 index 00000000000..7d7b4227704 --- /dev/null +++ b/web-client/src/presenter/actions/Public/setTodaysOpinionsAction.test.js @@ -0,0 +1,28 @@ +import { runAction } from 'cerebral/test'; +import { setTodaysOpinionsAction } from './setTodaysOpinionsAction'; + +describe('setTodaysOpinionsAction', () => { + it('sets state.todaysOpions from props.todaysOpinions', async () => { + const mockTodaysOpinions = [ + { + documentId: '1234', + documentTitle: 'An opinion', + }, + { + documentId: '5678', + documentTitle: 'Another opinion', + }, + ]; + + const { state } = await runAction(setTodaysOpinionsAction, { + props: { + todaysOpinions: mockTodaysOpinions, + }, + state: { + todaysOpinions: [], + }, + }); + + expect(state.todaysOpinions).toMatchObject(mockTodaysOpinions); + }); +}); diff --git a/web-client/src/presenter/actions/StartCase/updatePartyTypeAction.test.js b/web-client/src/presenter/actions/StartCase/updatePartyTypeAction.test.js index 1caffda0455..d359219f7d6 100644 --- a/web-client/src/presenter/actions/StartCase/updatePartyTypeAction.test.js +++ b/web-client/src/presenter/actions/StartCase/updatePartyTypeAction.test.js @@ -1,5 +1,8 @@ -import { ContactFactory } from '../../../../../shared/src/business/entities/contacts/ContactFactory'; -import { User } from '../../../../../shared/src/business/entities/User'; +import { + COUNTRY_TYPES, + PARTY_TYPES, + ROLES, +} from '../../../../../shared/src/business/entities/EntityConstants'; import { applicationContextForClient as applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { presenter } from '../../presenter-mock'; import { runAction } from 'cerebral/test'; @@ -17,7 +20,7 @@ const getFixtures = (props, state = {}) => ({ state: { ...state, user: { - role: User.ROLES.petitioner, + role: ROLES.petitioner, }, }, }); @@ -31,7 +34,7 @@ describe('updatePartyTypeAction', () => { value: 'Myself', }), ); - expect(state.form.partyType).toEqual(ContactFactory.PARTY_TYPES.petitioner); + expect(state.form.partyType).toEqual(PARTY_TYPES.petitioner); }); it('sets the partyType to "Petitioner & Deceased Spouse" when "isSpouseDeceased" is updated to "Yes"', async () => { @@ -42,9 +45,7 @@ describe('updatePartyTypeAction', () => { value: 'Yes', }), ); - expect(state.form.partyType).toEqual( - ContactFactory.PARTY_TYPES.petitionerDeceasedSpouse, - ); + expect(state.form.partyType).toEqual(PARTY_TYPES.petitionerDeceasedSpouse); }); it('sets the partyType to "Petitioner & Spouse" when "isSpouseDeceased" is updated to "No"', async () => { @@ -55,9 +56,7 @@ describe('updatePartyTypeAction', () => { value: 'No', }), ); - expect(state.form.partyType).toEqual( - ContactFactory.PARTY_TYPES.petitionerSpouse, - ); + expect(state.form.partyType).toEqual(PARTY_TYPES.petitionerSpouse); }); it('sets the partyType to "Donor" when "otherType" is updated to "Donor"', async () => { @@ -68,7 +67,7 @@ describe('updatePartyTypeAction', () => { value: 'Donor', }), ); - expect(state.form.partyType).toEqual(ContactFactory.PARTY_TYPES.donor); + expect(state.form.partyType).toEqual(PARTY_TYPES.donor); }); it('sets the partyType to "Transferee" when "otherType" is updated to "Transferee"', async () => { @@ -79,7 +78,7 @@ describe('updatePartyTypeAction', () => { value: 'Transferee', }), ); - expect(state.form.partyType).toEqual(ContactFactory.PARTY_TYPES.transferee); + expect(state.form.partyType).toEqual(PARTY_TYPES.transferee); }); it('sets the partyType to "Surviving Spouse" when "otherType" is updated to "Deceased Spouse"', async () => { @@ -90,9 +89,7 @@ describe('updatePartyTypeAction', () => { value: 'Deceased Spouse', }), ); - expect(state.form.partyType).toEqual( - ContactFactory.PARTY_TYPES.survivingSpouse, - ); + expect(state.form.partyType).toEqual(PARTY_TYPES.survivingSpouse); }); it('sets the partyType to the props.value passed in when key is "businessType"', async () => { @@ -158,7 +155,7 @@ describe('updatePartyTypeAction', () => { }, { constants: { - COUNTRY_TYPES: ContactFactory.COUNTRY_TYPES, + COUNTRY_TYPES: COUNTRY_TYPES, PARTY_TYPES: [], }, form: { @@ -183,7 +180,7 @@ describe('updatePartyTypeAction', () => { }, { constants: { - COUNTRY_TYPES: ContactFactory.COUNTRY_TYPES, + COUNTRY_TYPES: COUNTRY_TYPES, PARTY_TYPES: [], }, form: { @@ -208,7 +205,7 @@ describe('updatePartyTypeAction', () => { }, { constants: { - COUNTRY_TYPES: ContactFactory.COUNTRY_TYPES, + COUNTRY_TYPES: COUNTRY_TYPES, PARTY_TYPES: [], }, form: { diff --git a/web-client/src/presenter/actions/StartCaseInternal/updateOrderForFilingFeeAction.test.js b/web-client/src/presenter/actions/StartCaseInternal/updateOrderForFilingFeeAction.test.js index 6e50e0312d7..d8058fb7a9e 100644 --- a/web-client/src/presenter/actions/StartCaseInternal/updateOrderForFilingFeeAction.test.js +++ b/web-client/src/presenter/actions/StartCaseInternal/updateOrderForFilingFeeAction.test.js @@ -1,4 +1,4 @@ -import { Case } from '../../../../../shared/src/business/entities/cases/Case'; +import { PAYMENT_STATUS } from '../../../../../shared/src/business/entities/EntityConstants'; import { applicationContextForClient as applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { presenter } from '../../presenter-mock'; import { runAction } from 'cerebral/test'; @@ -16,7 +16,7 @@ describe('updateOrderForFilingFeeAction', () => { }, props: { key: 'petitionPaymentStatus', - value: Case.PAYMENT_STATUS.UNPAID, + value: PAYMENT_STATUS.UNPAID, }, state: { form: {}, @@ -33,7 +33,7 @@ describe('updateOrderForFilingFeeAction', () => { }, props: { key: 'anotherField', - value: Case.PAYMENT_STATUS.UNPAID, + value: PAYMENT_STATUS.UNPAID, }, state: { form: { @@ -52,7 +52,7 @@ describe('updateOrderForFilingFeeAction', () => { }, props: { key: 'petitionPaymentStatus', - value: Case.PAYMENT_STATUS.PAID, + value: PAYMENT_STATUS.PAID, }, state: { form: {}, diff --git a/web-client/src/presenter/actions/StartCaseInternal/updateOrderForOdsAction.test.js b/web-client/src/presenter/actions/StartCaseInternal/updateOrderForOdsAction.test.js index e4840bb8a61..fecf958f9e5 100644 --- a/web-client/src/presenter/actions/StartCaseInternal/updateOrderForOdsAction.test.js +++ b/web-client/src/presenter/actions/StartCaseInternal/updateOrderForOdsAction.test.js @@ -1,4 +1,4 @@ -import { ContactFactory } from '../../../../../shared/src/business/entities/contacts/ContactFactory'; +import { PARTY_TYPES } from '../../../../../shared/src/business/entities/EntityConstants'; import { applicationContextForClient as applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { presenter } from '../../presenter-mock'; import { runAction } from 'cerebral/test'; @@ -17,7 +17,7 @@ describe('updateOrderForOdsAction', () => { props: { key: 'partyType' }, state: { form: { - partyType: ContactFactory.PARTY_TYPES.corporation, + partyType: PARTY_TYPES.corporation, }, }, }); @@ -33,7 +33,7 @@ describe('updateOrderForOdsAction', () => { props: { key: 'partyType' }, state: { form: { - partyType: ContactFactory.PARTY_TYPES.petitioner, + partyType: PARTY_TYPES.petitioner, }, }, }); @@ -50,7 +50,7 @@ describe('updateOrderForOdsAction', () => { state: { form: { ownershipDisclosureFile: 'the file!', - partyType: ContactFactory.PARTY_TYPES.corporation, + partyType: PARTY_TYPES.corporation, }, }, }); @@ -67,7 +67,7 @@ describe('updateOrderForOdsAction', () => { state: { form: { orderForOds: false, - partyType: ContactFactory.PARTY_TYPES.corporation, + partyType: PARTY_TYPES.corporation, }, }, }); diff --git a/web-client/src/presenter/actions/WorkItem/setCreateMessageModalDialogModalStateAction.js b/web-client/src/presenter/actions/WorkItem/setCreateMessageModalDialogModalStateAction.js index 8d3f4b6ca44..89edc461847 100644 --- a/web-client/src/presenter/actions/WorkItem/setCreateMessageModalDialogModalStateAction.js +++ b/web-client/src/presenter/actions/WorkItem/setCreateMessageModalDialogModalStateAction.js @@ -8,5 +8,7 @@ import { state } from 'cerebral'; */ export const setCreateMessageModalDialogModalStateAction = ({ store }) => { store.set(state.modal.validationErrors, {}); - store.set(state.modal.form, {}); + store.set(state.modal.form, { + attachments: [], + }); }; diff --git a/web-client/src/presenter/actions/WorkItem/setCreateMessageModalDialogModalStateAction.test.js b/web-client/src/presenter/actions/WorkItem/setCreateMessageModalDialogModalStateAction.test.js index 28634cd9549..fa7c9c08ff6 100644 --- a/web-client/src/presenter/actions/WorkItem/setCreateMessageModalDialogModalStateAction.test.js +++ b/web-client/src/presenter/actions/WorkItem/setCreateMessageModalDialogModalStateAction.test.js @@ -16,7 +16,9 @@ describe('setCreateMessageModalDialogModalStateAction', () => { ); expect(result.state.modal).toEqual({ - form: {}, + form: { + attachments: [], + }, validationErrors: {}, }); }); diff --git a/web-client/src/presenter/actions/caseAssociation/validateEditIrsPractitionersAction.test.js b/web-client/src/presenter/actions/caseAssociation/validateEditIrsPractitionersAction.test.js index 9870efdcb20..f04d36d80c7 100644 --- a/web-client/src/presenter/actions/caseAssociation/validateEditIrsPractitionersAction.test.js +++ b/web-client/src/presenter/actions/caseAssociation/validateEditIrsPractitionersAction.test.js @@ -1,4 +1,4 @@ -import { SERVICE_INDICATOR_TYPES } from '../../../../../shared/src/business/entities/cases/CaseConstants'; +import { SERVICE_INDICATOR_TYPES } from '../../../../../shared/src/business/entities/EntityConstants'; import { presenter } from '../../presenter-mock'; import { runAction } from 'cerebral/test'; import { validateEditIrsPractitionersAction } from './validateEditIrsPractitionersAction'; diff --git a/web-client/src/presenter/actions/caseConsolidation/getConsolidatedCasesByUserAction.js b/web-client/src/presenter/actions/caseConsolidation/getConsolidatedCasesByUserAction.js index 48c6a6f4ffc..90425914bb4 100644 --- a/web-client/src/presenter/actions/caseConsolidation/getConsolidatedCasesByUserAction.js +++ b/web-client/src/presenter/actions/caseConsolidation/getConsolidatedCasesByUserAction.js @@ -1,4 +1,4 @@ -import { Case } from '../../../../../shared/src/business/entities/cases/Case'; +import { CASE_STATUS_TYPES } from '../../../../../shared/src/business/entities/EntityConstants'; import { orderBy } from 'lodash'; import { state } from 'cerebral'; @@ -17,18 +17,16 @@ export const getConsolidatedCasesByUserAction = async ({ const status = get(state.currentViewMetadata.caseList.tab); let caseList; - if (status !== Case.STATUS_TYPES.closed) { - caseList = await applicationContext.getUseCases().getOpenCasesInteractor({ + if (status !== CASE_STATUS_TYPES.closed) { + caseList = await applicationContext + .getUseCases() + .getOpenConsolidatedCasesInteractor({ + applicationContext, + }); + } else { + caseList = await applicationContext.getUseCases().getClosedCasesInteractor({ applicationContext, }); - } else { - //TODO implement this when working on displaying closed cases - // caseList = await applicationContext - // .getUseCases() - // .getClosedConsolidatedCasesByUserInteractor({ - // applicationContext, - // userId, - // }); } caseList = orderBy(caseList, 'createdAt', 'desc'); return { caseList }; diff --git a/web-client/src/presenter/actions/caseConsolidation/getOpenAndClosedCasesByUserAction.js b/web-client/src/presenter/actions/caseConsolidation/getOpenAndClosedCasesByUserAction.js new file mode 100644 index 00000000000..8fb781b4228 --- /dev/null +++ b/web-client/src/presenter/actions/caseConsolidation/getOpenAndClosedCasesByUserAction.js @@ -0,0 +1,30 @@ +import { orderBy } from 'lodash'; + +/** + * Fetches the cases (including consolidated) associated with the petitioner who + * created them or the respondent who is associated with them. + * + * @param {object} providers the providers object + * @param {object} providers.applicationContext needed for getting the getCasesByUser use case + * @returns {object} contains the caseList returned from the + * getOpenConsolidatedCasesInteractor and getClosedCasesInteractor use cases + */ +export const getOpenAndClosedCasesByUserAction = async ({ + applicationContext, +}) => { + let openCaseList = await applicationContext + .getUseCases() + .getOpenConsolidatedCasesInteractor({ + applicationContext, + }); + let closedCaseList = await applicationContext + .getUseCases() + .getClosedCasesInteractor({ + applicationContext, + }); + + openCaseList = orderBy(openCaseList, 'createdAt', 'desc'); + closedCaseList = orderBy(closedCaseList, 'createdAt', 'desc'); + + return { closedCaseList, openCaseList }; +}; diff --git a/web-client/src/presenter/actions/caseConsolidation/getConsolidatedCasesByUserAction.test.js b/web-client/src/presenter/actions/caseConsolidation/getOpenAndClosedCasesByUserAction.test.js similarity index 55% rename from web-client/src/presenter/actions/caseConsolidation/getConsolidatedCasesByUserAction.test.js rename to web-client/src/presenter/actions/caseConsolidation/getOpenAndClosedCasesByUserAction.test.js index 456566a77ea..e3d3ee991a6 100644 --- a/web-client/src/presenter/actions/caseConsolidation/getConsolidatedCasesByUserAction.test.js +++ b/web-client/src/presenter/actions/caseConsolidation/getOpenAndClosedCasesByUserAction.test.js @@ -1,11 +1,27 @@ import { applicationContextForClient as applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; -import { getConsolidatedCasesByUserAction } from './getConsolidatedCasesByUserAction'; +import { getOpenAndClosedCasesByUserAction } from './getOpenAndClosedCasesByUserAction'; import { presenter } from '../../presenter-mock'; import { runAction } from 'cerebral/test'; -describe('getConsolidatedCasesByUserAction', () => { +describe('getOpenAndClosedCasesByUserAction', () => { beforeAll(() => { - applicationContext.getUseCases().getOpenCasesInteractor.mockReturnValue([ + applicationContext + .getUseCases() + .getOpenConsolidatedCasesInteractor.mockReturnValue([ + { + caseId: 'case-id-234', + createdAt: '2019-07-20T20:20:15.680Z', + }, + { + caseId: 'case-id-123', + createdAt: '2019-07-19T20:20:15.680Z', + }, + { + caseId: 'case-id-345', + createdAt: '2019-07-21T20:20:15.680Z', + }, + ]); + applicationContext.getUseCases().getClosedCasesInteractor.mockReturnValue([ { caseId: 'case-id-234', createdAt: '2019-07-20T20:20:15.680Z', @@ -27,7 +43,7 @@ describe('getConsolidatedCasesByUserAction', () => { }); it('gets the consolidated cases by userId', async () => { - const { output } = await runAction(getConsolidatedCasesByUserAction, { + const { output } = await runAction(getOpenAndClosedCasesByUserAction, { modules: { presenter }, state: { currentViewMetadata: { @@ -39,28 +55,16 @@ describe('getConsolidatedCasesByUserAction', () => { }); expect(output).toMatchObject({ - caseList: [ + closedCaseList: [ + { caseId: 'case-id-345', createdAt: '2019-07-21T20:20:15.680Z' }, + { caseId: 'case-id-234', createdAt: '2019-07-20T20:20:15.680Z' }, + { caseId: 'case-id-123', createdAt: '2019-07-19T20:20:15.680Z' }, + ], + openCaseList: [ { caseId: 'case-id-345', createdAt: '2019-07-21T20:20:15.680Z' }, { caseId: 'case-id-234', createdAt: '2019-07-20T20:20:15.680Z' }, { caseId: 'case-id-123', createdAt: '2019-07-19T20:20:15.680Z' }, ], }); }); - - it('should retrieve all open cases when props.currentViewMetadata.caseList.tab is not Closed', async () => { - await runAction(getConsolidatedCasesByUserAction, { - modules: { presenter }, - state: { - currentViewMetadata: { - caseList: { - tab: 'Open', - }, - }, - }, - }); - - expect( - applicationContext.getUseCases().getOpenCasesInteractor, - ).toHaveBeenCalled(); - }); }); diff --git a/web-client/src/presenter/actions/chooseMessageBoxAction.js b/web-client/src/presenter/actions/chooseMessageBoxAction.js new file mode 100644 index 00000000000..9f4afa6a295 --- /dev/null +++ b/web-client/src/presenter/actions/chooseMessageBoxAction.js @@ -0,0 +1,19 @@ +import { state } from 'cerebral'; + +/** + * Used for changing the message queue (my, section) and box (inbox, outbox, completed) from props + * + * @param {object} providers the providers object + * @param {object} providers.path the next object in the path (this is defined in the sequence right after this action is invoked) + * @param {object} providers.props the cerebral props object + * @param {object} providers.store the cerebral store object + * @returns {*} returns the next action in the sequence's path + */ +export const chooseMessageBoxAction = ({ path, props, store }) => { + store.set(state.messageBoxToDisplay.queue, props.queue); + store.set(state.messageBoxToDisplay.box, props.box); + + const messageBoxPath = `${props.queue}${props.box}`; + + return path[messageBoxPath](); +}; diff --git a/web-client/src/presenter/actions/chooseMessageBoxAction.test.js b/web-client/src/presenter/actions/chooseMessageBoxAction.test.js new file mode 100644 index 00000000000..cf344065763 --- /dev/null +++ b/web-client/src/presenter/actions/chooseMessageBoxAction.test.js @@ -0,0 +1,29 @@ +import { chooseMessageBoxAction } from './chooseMessageBoxAction'; +import { presenter } from '../presenter-mock'; +import { runAction } from 'cerebral/test'; + +describe('chooseMessageBoxAction', () => { + const myinboxMock = jest.fn(); + + beforeAll(() => { + presenter.providers.path = { + myinbox: myinboxMock, + }; + }); + + it('sets state.messageBoxToDisplay from props and calls the path to the correct box', async () => { + const { state } = await runAction(chooseMessageBoxAction, { + modules: { presenter }, + props: { + box: 'inbox', + queue: 'my', + }, + }); + + expect(state.messageBoxToDisplay).toEqual({ + box: 'inbox', + queue: 'my', + }); + expect(myinboxMock).toBeCalled(); + }); +}); diff --git a/web-client/src/presenter/actions/createPractitionerUserAction.js b/web-client/src/presenter/actions/createPractitionerUserAction.js index 7103ad32501..27e85653f33 100644 --- a/web-client/src/presenter/actions/createPractitionerUserAction.js +++ b/web-client/src/presenter/actions/createPractitionerUserAction.js @@ -8,6 +8,7 @@ import { state } from 'cerebral'; * @param {Function} providers.get the cerebral get function * @param {object} providers.path the next object in the path * @param {object} providers.props the props passed in to the action + * @returns {object} path execution results */ export const createPractitionerUserAction = async ({ applicationContext, diff --git a/web-client/src/presenter/actions/defaultUpdateCaseModalValuesAction.test.js b/web-client/src/presenter/actions/defaultUpdateCaseModalValuesAction.test.js index 96258c32535..c796aa50d0d 100644 --- a/web-client/src/presenter/actions/defaultUpdateCaseModalValuesAction.test.js +++ b/web-client/src/presenter/actions/defaultUpdateCaseModalValuesAction.test.js @@ -1,4 +1,4 @@ -import { Case } from '../../../../shared/src/business/entities/cases/Case'; +import { CASE_STATUS_TYPES } from '../../../../shared/src/business/entities/EntityConstants'; import { defaultUpdateCaseModalValuesAction } from './defaultUpdateCaseModalValuesAction'; import { runAction } from 'cerebral/test'; @@ -9,7 +9,7 @@ describe('defaultUpdateCaseModalValuesAction', () => { caseDetail: { associatedJudge: 'Chief Judge', caseCaption: 'A case caption', - status: Case.STATUS_TYPES.new, + status: CASE_STATUS_TYPES.new, }, modal: {}, }, @@ -18,7 +18,7 @@ describe('defaultUpdateCaseModalValuesAction', () => { expect(result.state.modal).toMatchObject({ associatedJudge: 'Chief Judge', caseCaption: 'A case caption', - caseStatus: Case.STATUS_TYPES.new, + caseStatus: CASE_STATUS_TYPES.new, }); }); }); diff --git a/web-client/src/presenter/actions/getCaseAssociationAction.test.js b/web-client/src/presenter/actions/getCaseAssociationAction.test.js index 8ea952e7c36..df9bdeee83a 100644 --- a/web-client/src/presenter/actions/getCaseAssociationAction.test.js +++ b/web-client/src/presenter/actions/getCaseAssociationAction.test.js @@ -1,4 +1,4 @@ -import { User } from '../../../../shared/src/business/entities/User'; +import { ROLES } from '../../../../shared/src/business/entities/EntityConstants'; import { applicationContextForClient as applicationContext } from '../../../../shared/src/business/test/createTestApplicationContext'; import { getCaseAssociationAction } from './getCaseAssociationAction'; import { presenter } from '../presenter-mock'; @@ -13,7 +13,7 @@ describe('getCaseAssociation', () => { .verifyPendingCaseForUserInteractor.mockReturnValue(false); applicationContext.getCurrentUser.mockReturnValue({ - role: User.ROLES.privatePractitioner, + role: ROLES.privatePractitioner, userId: '123', }); }); @@ -41,7 +41,7 @@ describe('getCaseAssociation', () => { .getUseCases() .verifyPendingCaseForUserInteractor.mockReturnValue(true); applicationContext.getCurrentUser.mockReturnValue({ - role: User.ROLES.privatePractitioner, + role: ROLES.privatePractitioner, userId: '1234', }); @@ -67,7 +67,7 @@ describe('getCaseAssociation', () => { .getUseCases() .verifyPendingCaseForUserInteractor.mockReturnValue(false); applicationContext.getCurrentUser.mockReturnValue({ - role: User.ROLES.privatePractitioner, + role: ROLES.privatePractitioner, userId: '1234', }); @@ -93,7 +93,7 @@ describe('getCaseAssociation', () => { .getUseCases() .verifyPendingCaseForUserInteractor.mockReturnValue(false); applicationContext.getCurrentUser.mockReturnValue({ - role: User.ROLES.irsPractitioner, + role: ROLES.irsPractitioner, userId: '789', }); @@ -119,7 +119,7 @@ describe('getCaseAssociation', () => { .getUseCases() .verifyPendingCaseForUserInteractor.mockReturnValue(true); applicationContext.getCurrentUser.mockReturnValue({ - role: User.ROLES.irsPractitioner, + role: ROLES.irsPractitioner, userId: '789', }); @@ -145,7 +145,7 @@ describe('getCaseAssociation', () => { .getUseCases() .verifyPendingCaseForUserInteractor.mockReturnValue(false); applicationContext.getCurrentUser.mockReturnValue({ - role: User.ROLES.petitioner, + role: ROLES.petitioner, userId: '123', }); const results = await runAction(getCaseAssociationAction, { @@ -170,7 +170,7 @@ describe('getCaseAssociation', () => { .getUseCases() .verifyPendingCaseForUserInteractor.mockReturnValue(true); applicationContext.getCurrentUser.mockReturnValue({ - role: User.ROLES.petitioner, + role: ROLES.petitioner, userId: '789', }); @@ -196,7 +196,7 @@ describe('getCaseAssociation', () => { .getUseCases() .verifyPendingCaseForUserInteractor.mockReturnValue(false); applicationContext.getCurrentUser.mockReturnValue({ - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: '123', }); @@ -219,7 +219,7 @@ describe('getCaseAssociation', () => { it('should return false for isAssociated and pendingAssociation if the user is an irsSuperuser and the petition document is not served', async () => { applicationContext.getCurrentUser.mockReturnValue({ - role: User.ROLES.irsSuperuser, + role: ROLES.irsSuperuser, userId: '123', }); @@ -242,7 +242,7 @@ describe('getCaseAssociation', () => { it('should return true for isAssociated and false for pendingAssociation if the user is an irsSuperuser and the petition document is served', async () => { applicationContext.getCurrentUser.mockReturnValue({ - role: User.ROLES.irsSuperuser, + role: ROLES.irsSuperuser, userId: '123', }); diff --git a/web-client/src/presenter/actions/getFormDocumentUrlForPreviewAction.test.js b/web-client/src/presenter/actions/getFormDocumentUrlForPreviewAction.test.js index d74bea62e4d..1e194d54a21 100644 --- a/web-client/src/presenter/actions/getFormDocumentUrlForPreviewAction.test.js +++ b/web-client/src/presenter/actions/getFormDocumentUrlForPreviewAction.test.js @@ -1,11 +1,9 @@ -import { Document } from '../../../../shared/src/business/entities/Document'; +import { INITIAL_DOCUMENT_TYPES } from '../../../../shared/src/business/entities/EntityConstants'; import { applicationContextForClient as applicationContext } from '../../../../shared/src/business/test/createTestApplicationContext'; import { getFormDocumentUrlForPreviewAction } from './getFormDocumentUrlForPreviewAction'; import { presenter } from '../presenter-mock'; import { runAction } from 'cerebral/test'; -const { INITIAL_DOCUMENT_TYPES } = Document; - describe('getFormDocumentUrlForPreviewAction', () => { let form; diff --git a/web-client/src/presenter/actions/getInboxCaseMessagesForSectionAction.js b/web-client/src/presenter/actions/getInboxCaseMessagesForSectionAction.js new file mode 100644 index 00000000000..2d240120b60 --- /dev/null +++ b/web-client/src/presenter/actions/getInboxCaseMessagesForSectionAction.js @@ -0,0 +1,18 @@ +/** + * fetches the inbox case messages for the section + * + * @param {object} applicationContext object that contains all the context specific methods + * @returns {Promise<{CaseMessage: Array}>} a list of messages + */ +export const getInboxCaseMessagesForSectionAction = async ({ + applicationContext, +}) => { + const messages = await applicationContext + .getUseCases() + .getInboxCaseMessagesForSectionInteractor({ + applicationContext, + section: applicationContext.getCurrentUser().section, + }); + + return { messages }; +}; diff --git a/web-client/src/presenter/actions/getInboxCaseMessagesForSectionAction.test.js b/web-client/src/presenter/actions/getInboxCaseMessagesForSectionAction.test.js new file mode 100644 index 00000000000..8c729e46f6e --- /dev/null +++ b/web-client/src/presenter/actions/getInboxCaseMessagesForSectionAction.test.js @@ -0,0 +1,27 @@ +import { applicationContextForClient as applicationContext } from '../../../../shared/src/business/test/createTestApplicationContext'; +import { getInboxCaseMessagesForSectionAction } from './getInboxCaseMessagesForSectionAction'; +import { presenter } from '../presenter-mock'; +import { runAction } from 'cerebral/test'; + +describe('getInboxCaseMessagesForSectionAction', () => { + const message = { + messageId: '180bfc0c-4e8e-448a-802a-8fe027be85ef', + }; + + beforeAll(() => { + presenter.providers.applicationContext = applicationContext; + applicationContext + .getUseCases() + .getInboxCaseMessagesForSectionInteractor.mockReturnValue([message]); + }); + + it('returns the messages retrieved from the use case', async () => { + const results = await runAction(getInboxCaseMessagesForSectionAction, { + modules: { + presenter, + }, + state: {}, + }); + expect(results.output.messages).toEqual([message]); + }); +}); diff --git a/web-client/src/presenter/actions/getInboxCaseMessagesForUserAction.js b/web-client/src/presenter/actions/getInboxCaseMessagesForUserAction.js new file mode 100644 index 00000000000..00bf3404842 --- /dev/null +++ b/web-client/src/presenter/actions/getInboxCaseMessagesForUserAction.js @@ -0,0 +1,18 @@ +/** + * fetches the inbox case messages for the user + * + * @param {object} applicationContext object that contains all the context specific methods + * @returns {Promise<{CaseMessage: Array}>} a list of messages + */ +export const getInboxCaseMessagesForUserAction = async ({ + applicationContext, +}) => { + const messages = await applicationContext + .getUseCases() + .getInboxCaseMessagesForUserInteractor({ + applicationContext, + userId: applicationContext.getCurrentUser().userId, + }); + + return { messages }; +}; diff --git a/web-client/src/presenter/actions/getInboxCaseMessagesForUserAction.test.js b/web-client/src/presenter/actions/getInboxCaseMessagesForUserAction.test.js new file mode 100644 index 00000000000..3b92fef61f7 --- /dev/null +++ b/web-client/src/presenter/actions/getInboxCaseMessagesForUserAction.test.js @@ -0,0 +1,27 @@ +import { applicationContextForClient as applicationContext } from '../../../../shared/src/business/test/createTestApplicationContext'; +import { getInboxCaseMessagesForUserAction } from './getInboxCaseMessagesForUserAction'; +import { presenter } from '../presenter-mock'; +import { runAction } from 'cerebral/test'; + +describe('getInboxCaseMessagesForUserAction', () => { + const message = { + messageId: '180bfc0c-4e8e-448a-802a-8fe027be85ef', + }; + + beforeAll(() => { + presenter.providers.applicationContext = applicationContext; + applicationContext + .getUseCases() + .getInboxCaseMessagesForUserInteractor.mockReturnValue([message]); + }); + + it('returns the messages retrieved from the use case', async () => { + const results = await runAction(getInboxCaseMessagesForUserAction, { + modules: { + presenter, + }, + state: {}, + }); + expect(results.output.messages).toEqual([message]); + }); +}); diff --git a/web-client/src/presenter/actions/getMessageAction.js b/web-client/src/presenter/actions/getMessageAction.js new file mode 100644 index 00000000000..c5c5f5854a6 --- /dev/null +++ b/web-client/src/presenter/actions/getMessageAction.js @@ -0,0 +1,18 @@ +/** + * Fetches the message using the getMessage use case using the props.messageId + * + * @param {object} providers the providers object + * @param {object} providers.applicationContext needed for getting the getCase use case + * @param {object} providers.props the cerebral props object containing props.docketNumber + * @returns {object} contains the message returned from the use case + */ +export const getMessageAction = async ({ applicationContext, props }) => { + const { messageId } = props; + const messageDetail = await applicationContext + .getUseCases() + .getCaseMessageInteractor({ + applicationContext, + messageId, + }); + return { messageDetail }; +}; diff --git a/web-client/src/presenter/actions/getMessageAction.test.js b/web-client/src/presenter/actions/getMessageAction.test.js new file mode 100644 index 00000000000..68d9e4d1a26 --- /dev/null +++ b/web-client/src/presenter/actions/getMessageAction.test.js @@ -0,0 +1,31 @@ +import { applicationContextForClient } from '../../../../shared/src/business/test/createTestApplicationContext'; +import { getMessageAction } from './getMessageAction'; +import { presenter } from '../presenter-mock'; +import { runAction } from 'cerebral/test'; + +describe('getMessageAction', () => { + beforeAll(() => { + presenter.providers.applicationContext = applicationContextForClient; + }); + + it('calls the use case with props.messageId', async () => { + await runAction(getMessageAction, { + modules: { + presenter, + }, + props: { + messageId: '0fbd6b64-6e13-4984-b46b-fd74906fd2c7', + }, + }); + + expect( + applicationContextForClient.getUseCases().getCaseMessageInteractor, + ).toBeCalled(); + expect( + applicationContextForClient.getUseCases().getCaseMessageInteractor.mock + .calls[0][0], + ).toMatchObject({ + messageId: '0fbd6b64-6e13-4984-b46b-fd74906fd2c7', + }); + }); +}); diff --git a/web-client/src/presenter/actions/getOpinionTypesAction.js b/web-client/src/presenter/actions/getOpinionTypesAction.js index 47e4eed892b..40898a008fb 100644 --- a/web-client/src/presenter/actions/getOpinionTypesAction.js +++ b/web-client/src/presenter/actions/getOpinionTypesAction.js @@ -1,4 +1,4 @@ -import { Document } from '../../../../shared/src/business/entities/Document'; +import { OPINION_DOCUMENT_TYPES } from '../../../../shared/src/business/entities/EntityConstants'; const courtIssuedEventCodes = require('../../../../shared/src/tools/courtIssuedEventCodes.json'); /** @@ -9,9 +9,7 @@ const courtIssuedEventCodes = require('../../../../shared/src/tools/courtIssuedE */ export const getOpinionTypesAction = () => { const opinionDocuments = courtIssuedEventCodes.filter(courtIssuedDocument => { - if ( - Document.OPINION_DOCUMENT_TYPES.includes(courtIssuedDocument.eventCode) - ) { + if (OPINION_DOCUMENT_TYPES.includes(courtIssuedDocument.eventCode)) { return courtIssuedDocument; } }); diff --git a/web-client/src/presenter/actions/getOutboxCaseMessagesForSectionAction.js b/web-client/src/presenter/actions/getOutboxCaseMessagesForSectionAction.js new file mode 100644 index 00000000000..ed78d72cf9b --- /dev/null +++ b/web-client/src/presenter/actions/getOutboxCaseMessagesForSectionAction.js @@ -0,0 +1,18 @@ +/** + * fetches the outbox case messages for the section + * + * @param {object} applicationContext object that contains all the context specific methods + * @returns {Promise<{CaseMessage: Array}>} a list of messages + */ +export const getOutboxCaseMessagesForSectionAction = async ({ + applicationContext, +}) => { + const messages = await applicationContext + .getUseCases() + .getOutboxCaseMessagesForSectionInteractor({ + applicationContext, + section: applicationContext.getCurrentUser().section, + }); + + return { messages }; +}; diff --git a/web-client/src/presenter/actions/getOutboxCaseMessagesForSectionAction.test.js b/web-client/src/presenter/actions/getOutboxCaseMessagesForSectionAction.test.js new file mode 100644 index 00000000000..0caa4550158 --- /dev/null +++ b/web-client/src/presenter/actions/getOutboxCaseMessagesForSectionAction.test.js @@ -0,0 +1,27 @@ +import { applicationContextForClient as applicationContext } from '../../../../shared/src/business/test/createTestApplicationContext'; +import { getOutboxCaseMessagesForSectionAction } from './getOutboxCaseMessagesForSectionAction'; +import { presenter } from '../presenter-mock'; +import { runAction } from 'cerebral/test'; + +describe('getOutboxCaseMessagesForSectionAction', () => { + const message = { + messageId: '180bfc0c-4e8e-448a-802a-8fe027be85ef', + }; + + beforeAll(() => { + presenter.providers.applicationContext = applicationContext; + applicationContext + .getUseCases() + .getOutboxCaseMessagesForSectionInteractor.mockReturnValue([message]); + }); + + it('returns the messages retrieved from the use case', async () => { + const results = await runAction(getOutboxCaseMessagesForSectionAction, { + modules: { + presenter, + }, + state: {}, + }); + expect(results.output.messages).toEqual([message]); + }); +}); diff --git a/web-client/src/presenter/actions/getOutboxCaseMessagesForUserAction.js b/web-client/src/presenter/actions/getOutboxCaseMessagesForUserAction.js new file mode 100644 index 00000000000..9a7abad8273 --- /dev/null +++ b/web-client/src/presenter/actions/getOutboxCaseMessagesForUserAction.js @@ -0,0 +1,18 @@ +/** + * fetches the outbox case messages for the user + * + * @param {object} applicationContext object that contains all the context specific methods + * @returns {Promise<{CaseMessage: Array}>} a list of messages + */ +export const getOutboxCaseMessagesForUserAction = async ({ + applicationContext, +}) => { + const messages = await applicationContext + .getUseCases() + .getOutboxCaseMessagesForUserInteractor({ + applicationContext, + userId: applicationContext.getCurrentUser().userId, + }); + + return { messages }; +}; diff --git a/web-client/src/presenter/actions/getOutboxCaseMessagesForUserAction.test.js b/web-client/src/presenter/actions/getOutboxCaseMessagesForUserAction.test.js new file mode 100644 index 00000000000..31d97d504d5 --- /dev/null +++ b/web-client/src/presenter/actions/getOutboxCaseMessagesForUserAction.test.js @@ -0,0 +1,27 @@ +import { applicationContextForClient as applicationContext } from '../../../../shared/src/business/test/createTestApplicationContext'; +import { getOutboxCaseMessagesForUserAction } from './getOutboxCaseMessagesForUserAction'; +import { presenter } from '../presenter-mock'; +import { runAction } from 'cerebral/test'; + +describe('getOutboxCaseMessagesForUserAction', () => { + const message = { + messageId: '180bfc0c-4e8e-448a-802a-8fe027be85ef', + }; + + beforeAll(() => { + presenter.providers.applicationContext = applicationContext; + applicationContext + .getUseCases() + .getOutboxCaseMessagesForUserInteractor.mockReturnValue([message]); + }); + + it('returns the messages retrieved from the use case', async () => { + const results = await runAction(getOutboxCaseMessagesForUserAction, { + modules: { + presenter, + }, + state: {}, + }); + expect(results.output.messages).toEqual([message]); + }); +}); diff --git a/web-client/src/presenter/actions/getPDFForPreviewAction.js b/web-client/src/presenter/actions/getPDFForPreviewAction.js index 80eae726da5..470526894d4 100644 --- a/web-client/src/presenter/actions/getPDFForPreviewAction.js +++ b/web-client/src/presenter/actions/getPDFForPreviewAction.js @@ -5,6 +5,7 @@ import { state } from 'cerebral'; * @param {object} providers the providers object * @param {object} providers.applicationContext the application context * @param {Function} providers.props used for getting caseId and documentId + * @returns {Promise} pdf file object for preview */ export const getPDFForPreviewAction = async ({ applicationContext, diff --git a/web-client/src/presenter/actions/rescanBatchAction.test.js b/web-client/src/presenter/actions/rescanBatchAction.test.js index b39fb4c390f..e8450ca5c38 100644 --- a/web-client/src/presenter/actions/rescanBatchAction.test.js +++ b/web-client/src/presenter/actions/rescanBatchAction.test.js @@ -1,12 +1,10 @@ -import { Scan } from '../../../../shared/src/business/entities/Scan'; +import { SCAN_MODES } from '../../../../shared/src/business/entities/EntityConstants'; import { applicationContextForClient as applicationContext } from '../../../../shared/src/business/test/createTestApplicationContext'; import { presenter } from '../presenter-mock'; import { rescanBatchAction } from './rescanBatchAction'; import { runAction } from 'cerebral/test'; describe('rescanBatchAction', () => { - const { SCAN_MODES } = Scan; - const successStub = jest.fn(); const errorStub = jest.fn(); diff --git a/web-client/src/presenter/actions/resetContactsAction.test.js b/web-client/src/presenter/actions/resetContactsAction.test.js index 072f12f13c5..b57d9d48c14 100644 --- a/web-client/src/presenter/actions/resetContactsAction.test.js +++ b/web-client/src/presenter/actions/resetContactsAction.test.js @@ -1,4 +1,4 @@ -import { ContactFactory } from '../../../../shared/src/business/entities/contacts/ContactFactory'; +import { PARTY_TYPES } from '../../../../shared/src/business/entities/EntityConstants'; import { applicationContextForClient as applicationContext } from '../../../../shared/src/business/test/createTestApplicationContext'; import { presenter } from '../presenter-mock'; import { resetContactsAction } from './resetContactsAction'; @@ -24,7 +24,7 @@ describe('resetContactsAction', () => { state: 'AL', zip: '12345', }, - partyType: ContactFactory.PARTY_TYPES.petitioner, + partyType: PARTY_TYPES.petitioner, }, }, }); @@ -33,7 +33,7 @@ describe('resetContactsAction', () => { countryType: 'domestic', email: 'test@example.com', }, - partyType: ContactFactory.PARTY_TYPES.petitioner, + partyType: PARTY_TYPES.petitioner, }); }); @@ -52,7 +52,7 @@ describe('resetContactsAction', () => { phone: '1234567890', zip: '12345', }, - partyType: ContactFactory.PARTY_TYPES.petitioner, + partyType: PARTY_TYPES.petitioner, }, }, }); @@ -61,7 +61,7 @@ describe('resetContactsAction', () => { countryType: 'domestic', email: 'test@example.com', }, - partyType: ContactFactory.PARTY_TYPES.petitioner, + partyType: PARTY_TYPES.petitioner, }); }); @@ -88,7 +88,7 @@ describe('resetContactsAction', () => { state: 'AL', zip: '12345', }, - partyType: ContactFactory.PARTY_TYPES.petitionerSpouse, + partyType: PARTY_TYPES.petitionerSpouse, }, }, }); @@ -98,7 +98,7 @@ describe('resetContactsAction', () => { email: 'test@example.com', }, contactSecondary: { countryType: 'domestic' }, - partyType: ContactFactory.PARTY_TYPES.petitionerSpouse, + partyType: PARTY_TYPES.petitionerSpouse, }); }); }); diff --git a/web-client/src/presenter/actions/runPathForUserRoleAction.test.js b/web-client/src/presenter/actions/runPathForUserRoleAction.test.js index 9f70d17319f..52e9462832c 100644 --- a/web-client/src/presenter/actions/runPathForUserRoleAction.test.js +++ b/web-client/src/presenter/actions/runPathForUserRoleAction.test.js @@ -1,4 +1,4 @@ -import { User } from '../../../../shared/src/business/entities/User'; +import { ROLES } from '../../../../shared/src/business/entities/EntityConstants'; import { applicationContextForClient as applicationContext } from '../../../../shared/src/business/test/createTestApplicationContext'; import { presenter } from '../presenter-mock'; import { runAction } from 'cerebral/test'; @@ -37,7 +37,7 @@ describe('runPathForUserRoleAction', () => { it('should return the petitioner path for user role petitioner', async () => { presenter.providers.applicationContext.getCurrentUser = () => ({ - role: User.ROLES.petitioner, + role: ROLES.petitioner, }); await runAction(runPathForUserRoleAction, { modules: { @@ -50,7 +50,7 @@ describe('runPathForUserRoleAction', () => { it('should return the privatePractitioner path for user role privatePractitioner', async () => { presenter.providers.applicationContext.getCurrentUser = () => ({ - role: User.ROLES.privatePractitioner, + role: ROLES.privatePractitioner, }); await runAction(runPathForUserRoleAction, { modules: { @@ -63,7 +63,7 @@ describe('runPathForUserRoleAction', () => { it('should return the irsPractitioner path for user role irsPractitioner', async () => { presenter.providers.applicationContext.getCurrentUser = () => ({ - role: User.ROLES.irsPractitioner, + role: ROLES.irsPractitioner, }); await runAction(runPathForUserRoleAction, { modules: { @@ -76,7 +76,7 @@ describe('runPathForUserRoleAction', () => { it('should return the petitionsclerk path for user role petitionsclerk', async () => { presenter.providers.applicationContext.getCurrentUser = () => ({ - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, }); await runAction(runPathForUserRoleAction, { modules: { @@ -89,7 +89,7 @@ describe('runPathForUserRoleAction', () => { it('should return the docketclerk path for user role docketclerk', async () => { presenter.providers.applicationContext.getCurrentUser = () => ({ - role: User.ROLES.docketClerk, + role: ROLES.docketClerk, }); await runAction(runPathForUserRoleAction, { modules: { @@ -102,7 +102,7 @@ describe('runPathForUserRoleAction', () => { it('should return the judge path for user role judge', async () => { presenter.providers.applicationContext.getCurrentUser = () => ({ - role: User.ROLES.judge, + role: ROLES.judge, }); await runAction(runPathForUserRoleAction, { modules: { diff --git a/web-client/src/presenter/actions/saveCaseDetailInternalEditAction.test.js b/web-client/src/presenter/actions/saveCaseDetailInternalEditAction.test.js index d82d4bf204f..5ec0b09bac8 100644 --- a/web-client/src/presenter/actions/saveCaseDetailInternalEditAction.test.js +++ b/web-client/src/presenter/actions/saveCaseDetailInternalEditAction.test.js @@ -1,4 +1,4 @@ -import { Case } from '../../../../shared/src/business/entities/cases/Case'; +import { CASE_STATUS_TYPES } from '../../../../shared/src/business/entities/EntityConstants'; import { MOCK_CASE } from '../../../../shared/src/test/mockCase'; import { applicationContextForClient as applicationContext } from '../../../../shared/src/business/test/createTestApplicationContext'; import { presenter } from '../presenter-mock'; @@ -14,7 +14,7 @@ describe('saveCaseDetailInternalEditAction', () => { const caseDetail = { ...MOCK_CASE, createdAt: '2019-03-01T21:40:46.415Z', - status: Case.STATUS_TYPES.generalDocketReadyForTrial, + status: CASE_STATUS_TYPES.generalDocketReadyForTrial, }; applicationContext .getUseCases() @@ -38,7 +38,7 @@ describe('saveCaseDetailInternalEditAction', () => { it('should not call the updateCaseTrialSortTags use case if case status is not ready for trial', async () => { const caseDetail = { ...MOCK_CASE, - status: Case.STATUS_TYPES.new, + status: CASE_STATUS_TYPES.new, }; applicationContext .getUseCases() diff --git a/web-client/src/presenter/actions/setCaseMessagesAction.js b/web-client/src/presenter/actions/setCaseMessagesAction.js new file mode 100644 index 00000000000..5cec449b883 --- /dev/null +++ b/web-client/src/presenter/actions/setCaseMessagesAction.js @@ -0,0 +1,13 @@ +import { state } from 'cerebral'; + +/** + * sets the state.messages based on the props.messages passed in. + * + * @param {object} providers the providers object + * @param {object} providers.store the cerebral store + * @param {object} providers.props the cerebral props object + * @returns {undefined} + */ +export const setCaseMessagesAction = ({ props, store }) => { + store.set(state.messages, props.messages); +}; diff --git a/web-client/src/presenter/actions/setCaseMessagesAction.test.js b/web-client/src/presenter/actions/setCaseMessagesAction.test.js new file mode 100644 index 00000000000..6ae6d51914d --- /dev/null +++ b/web-client/src/presenter/actions/setCaseMessagesAction.test.js @@ -0,0 +1,16 @@ +import { runAction } from 'cerebral/test'; +import { setCaseMessagesAction } from './setCaseMessagesAction'; + +describe('setCaseMessagesAction', () => { + const message = { + messageId: '180bfc0c-4e8e-448a-802a-8fe027be85ef', + }; + + it('sets props.messages on state.messages', async () => { + const results = await runAction(setCaseMessagesAction, { + props: { messages: [message] }, + state: {}, + }); + expect(results.state.messages).toEqual([message]); + }); +}); diff --git a/web-client/src/presenter/actions/setCaseOnFormUsingStateAction.js b/web-client/src/presenter/actions/setCaseOnFormUsingStateAction.js index 679cba89018..bacd0faebb3 100644 --- a/web-client/src/presenter/actions/setCaseOnFormUsingStateAction.js +++ b/web-client/src/presenter/actions/setCaseOnFormUsingStateAction.js @@ -6,6 +6,7 @@ import { state } from 'cerebral'; * @param {object} providers the providers object * @param {Function} providers.get the cerebral get function * @param {object} providers.store the cerebral store + * @returns {object} caseDetail onto the props stream */ export const setCaseOnFormUsingStateAction = async ({ get, store }) => { const caseDetail = get(state.caseDetail); diff --git a/web-client/src/presenter/actions/setCaseTypeToDisplayAction.js b/web-client/src/presenter/actions/setCaseTypeToDisplayAction.js new file mode 100644 index 00000000000..70e9b63e3c8 --- /dev/null +++ b/web-client/src/presenter/actions/setCaseTypeToDisplayAction.js @@ -0,0 +1,13 @@ +import { state } from 'cerebral'; + +/** + * sets the case type to display to open or closed + * + * @param {object} providers the providers object + * @param {object} providers.get the cerebral get function + * @param {object} providers.store the cerebral store object + * @returns {void} + */ +export const setCaseTypeToDisplayAction = ({ props, store }) => { + store.set(state.openClosedCases.caseType, props.tabName); +}; diff --git a/web-client/src/presenter/actions/setCaseTypeToDisplayAction.test.js b/web-client/src/presenter/actions/setCaseTypeToDisplayAction.test.js new file mode 100644 index 00000000000..fc96ab66c21 --- /dev/null +++ b/web-client/src/presenter/actions/setCaseTypeToDisplayAction.test.js @@ -0,0 +1,18 @@ +import { runAction } from 'cerebral/test'; +import { setCaseTypeToDisplayAction } from './setCaseTypeToDisplayAction'; + +describe('setCaseTypeToDisplayAction', () => { + it('sets state.openClosedCases.caseType to the value of props.tabName', async () => { + const result = await runAction(setCaseTypeToDisplayAction, { + props: { + tabName: 'Open', + }, + }); + + expect(result.state).toMatchObject({ + openClosedCases: { + caseType: 'Open', + }, + }); + }); +}); diff --git a/web-client/src/presenter/actions/setCasesAction.js b/web-client/src/presenter/actions/setCasesAction.js index a91bd58b4c4..2303fc4ce85 100644 --- a/web-client/src/presenter/actions/setCasesAction.js +++ b/web-client/src/presenter/actions/setCasesAction.js @@ -1,12 +1,13 @@ import { state } from 'cerebral'; /** - * sets the state.cases based on the props.caseList passed in + * sets the state.openCases and state.closedCases based on the props.openCaseList and props.closedCaseList passed in * * @param {object} providers the providers object - * @param {object} providers.store the cerebral store used for setting the state.cases - * @param {object} providers.props the cerebral props object used for passing the props.caseList + * @param {object} providers.store the cerebral store used for setting the state.openCases and state.closedCases + * @param {object} providers.props the cerebral props object used for passing the props.closedCaseList and props.openCaseList */ export const setCasesAction = ({ props, store }) => { - store.set(state.cases, props.caseList); + store.set(state.openCases, props.openCaseList); + store.set(state.closedCases, props.closedCaseList); }; diff --git a/web-client/src/presenter/actions/setCasesAction.test.js b/web-client/src/presenter/actions/setCasesAction.test.js index 44be4444991..1fdb312a835 100644 --- a/web-client/src/presenter/actions/setCasesAction.test.js +++ b/web-client/src/presenter/actions/setCasesAction.test.js @@ -2,10 +2,18 @@ import { runAction } from 'cerebral/test'; import { setCasesAction } from './setCasesAction'; describe('setCasesAction', () => { - it('sets state.cases from props.caseList', async () => { + it('sets state.openCases from props.openCaseList and state.closedCases from props.closedCaseList', async () => { const { state } = await runAction(setCasesAction, { props: { - caseList: [ + closedCaseList: [ + { + caseId: '1234', + }, + { + caseId: '2345', + }, + ], + openCaseList: [ { caseId: '1234', }, @@ -15,11 +23,18 @@ describe('setCasesAction', () => { ], }, state: { - cases: [], + closedCases: [], + openCases: [], }, }); - expect(state.cases).toEqual([ + expect(state.openCases).toEqual([ + { + caseId: '1234', + }, + { caseId: '2345' }, + ]); + expect(state.closedCases).toEqual([ { caseId: '1234', }, diff --git a/web-client/src/presenter/actions/setDefaultCaseTypeToDisplayAction.js b/web-client/src/presenter/actions/setDefaultCaseTypeToDisplayAction.js new file mode 100644 index 00000000000..e39eceeb955 --- /dev/null +++ b/web-client/src/presenter/actions/setDefaultCaseTypeToDisplayAction.js @@ -0,0 +1,17 @@ +import { state } from 'cerebral'; + +/** + * sets the default case type to display to open + * + * @param {object} providers the providers object + * @param {object} providers.applicationContext the applicationContext + * @param {object} providers.store the cerebral store object + * @returns {void} + */ +export const setDefaultCaseTypeToDisplayAction = ({ + applicationContext, + store, +}) => { + const { EXTERNAL_USER_DASHBOARD_TABS } = applicationContext.getConstants(); + store.set(state.openClosedCases.caseType, EXTERNAL_USER_DASHBOARD_TABS.OPEN); +}; diff --git a/web-client/src/presenter/actions/setDefaultCaseTypeToDisplayAction.test.js b/web-client/src/presenter/actions/setDefaultCaseTypeToDisplayAction.test.js new file mode 100644 index 00000000000..b6a706211c9 --- /dev/null +++ b/web-client/src/presenter/actions/setDefaultCaseTypeToDisplayAction.test.js @@ -0,0 +1,23 @@ +import { applicationContextForClient as applicationContext } from '../../../../shared/src/business/test/createTestApplicationContext'; +import { presenter } from '../presenter-mock'; +import { runAction } from 'cerebral/test'; +import { setDefaultCaseTypeToDisplayAction } from './setDefaultCaseTypeToDisplayAction'; + +describe('setDefaultCaseTypeToDisplayAction', () => { + const { EXTERNAL_USER_DASHBOARD_TABS } = applicationContext.getConstants(); + beforeAll(() => { + presenter.providers.applicationContext = applicationContext; + }); + + it('sets the default value for state.openClosedCases.caseType to "Open"', async () => { + const result = await runAction(setDefaultCaseTypeToDisplayAction, { + modules: { + presenter, + }, + }); + + expect(result.state.openClosedCases.caseType).toEqual( + EXTERNAL_USER_DASHBOARD_TABS.OPEN, + ); + }); +}); diff --git a/web-client/src/presenter/actions/setEditOtherStatisticsFromAction.test.js b/web-client/src/presenter/actions/setEditOtherStatisticsFormAction.test.js similarity index 100% rename from web-client/src/presenter/actions/setEditOtherStatisticsFromAction.test.js rename to web-client/src/presenter/actions/setEditOtherStatisticsFormAction.test.js diff --git a/web-client/src/presenter/actions/setMessageAction.js b/web-client/src/presenter/actions/setMessageAction.js new file mode 100644 index 00000000000..75fd48afff4 --- /dev/null +++ b/web-client/src/presenter/actions/setMessageAction.js @@ -0,0 +1,12 @@ +import { state } from 'cerebral'; + +/** + * sets the state.messageDetail from props.messageDetail + * + * @param {object} providers the providers object + * @param {object} providers.props the cerebral props object containing the props.messageDetail + * @param {object} providers.store the cerebral store used for setting the state.messageDetail + */ +export const setMessageAction = ({ props, store }) => { + store.set(state.messageDetail, props.messageDetail); +}; diff --git a/web-client/src/presenter/actions/setMessageAction.test.js b/web-client/src/presenter/actions/setMessageAction.test.js new file mode 100644 index 00000000000..0b9de0ae953 --- /dev/null +++ b/web-client/src/presenter/actions/setMessageAction.test.js @@ -0,0 +1,18 @@ +import { runAction } from 'cerebral/test'; +import { setMessageAction } from './setMessageAction'; + +describe('setMessageAction', () => { + it('sets state.caseDetail from props', async () => { + const { state } = await runAction(setMessageAction, { + props: { + messageDetail: { + messageId: '4b194c7b-6305-4d46-b8dd-6962066574f7', + }, + }, + }); + + expect(state.messageDetail).toEqual({ + messageId: '4b194c7b-6305-4d46-b8dd-6962066574f7', + }); + }); +}); diff --git a/web-client/src/presenter/actions/setRequestAccessWizardStepActionGenerator.js b/web-client/src/presenter/actions/setRequestAccessWizardStepActionGenerator.js new file mode 100644 index 00000000000..d7cc4ffb0ab --- /dev/null +++ b/web-client/src/presenter/actions/setRequestAccessWizardStepActionGenerator.js @@ -0,0 +1,13 @@ +import { state } from 'cerebral'; + +/** + * Sets the state.wizardStep to the value passed in. + * + * @param {string} wizardStep the wizardStep + * @returns {Function} a function that sets the wizardStep + */ +export const setRequestAccessWizardStepActionGenerator = wizardStep => { + return ({ store }) => { + store.set(state.wizardStep, wizardStep); + }; +}; diff --git a/web-client/src/presenter/actions/setRequestAccessWizardStepActionGenerator.test.js b/web-client/src/presenter/actions/setRequestAccessWizardStepActionGenerator.test.js new file mode 100644 index 00000000000..6496dc0a285 --- /dev/null +++ b/web-client/src/presenter/actions/setRequestAccessWizardStepActionGenerator.test.js @@ -0,0 +1,13 @@ +import { runAction } from 'cerebral/test'; +import { setRequestAccessWizardStepActionGenerator } from './setRequestAccessWizardStepActionGenerator'; + +describe('setRequestAccessWizardStepActionGenerator', () => { + it('should set state.wizardStep to the value passed in', async () => { + const mockWizardStep = 'TestWizardStep'; + const { state } = await runAction( + setRequestAccessWizardStepActionGenerator(mockWizardStep), + ); + + expect(state.wizardStep).toBe(mockWizardStep); + }); +}); diff --git a/web-client/src/presenter/actions/setSectionInboxCountAction.test.js b/web-client/src/presenter/actions/setSectionInboxCountAction.test.js index 71cdbfc734c..5393ad7ec93 100644 --- a/web-client/src/presenter/actions/setSectionInboxCountAction.test.js +++ b/web-client/src/presenter/actions/setSectionInboxCountAction.test.js @@ -1,4 +1,4 @@ -import { User } from '../../../../shared/src/business/entities/User'; +import { ROLES } from '../../../../shared/src/business/entities/EntityConstants'; import { applicationContextForClient as applicationContext } from '../../../../shared/src/business/test/createTestApplicationContext'; import { presenter } from '../presenter-mock'; import { runAction } from 'cerebral/test'; @@ -51,7 +51,7 @@ describe('setSectionInboxCountAction', () => { it('sets sectionInboxCount for a docketClerk user', async () => { applicationContext.getCurrentUser.mockReturnValue({ - role: User.ROLES.docketClerk, + role: ROLES.docketClerk, }); const result = await runAction(setSectionInboxCountAction, { @@ -74,7 +74,7 @@ describe('setSectionInboxCountAction', () => { it('sets sectionInboxCount for a judge user', async () => { applicationContext.getCurrentUser.mockReturnValue({ name: 'Judge Barker', - role: User.ROLES.judge, + role: ROLES.judge, }); const result = await runAction(setSectionInboxCountAction, { @@ -99,7 +99,7 @@ describe('setSectionInboxCountAction', () => { it('sets sectionInboxCount for a chambers user', async () => { applicationContext.getCurrentUser.mockReturnValue({ name: 'ADC', - role: User.ROLES.adc, + role: ROLES.adc, }); const result = await runAction(setSectionInboxCountAction, { diff --git a/web-client/src/presenter/actions/setUserPermissionsAction.test.js b/web-client/src/presenter/actions/setUserPermissionsAction.test.js index 7dde70c21ff..4829fcce800 100644 --- a/web-client/src/presenter/actions/setUserPermissionsAction.test.js +++ b/web-client/src/presenter/actions/setUserPermissionsAction.test.js @@ -1,4 +1,4 @@ -import { User } from '../../../../shared/src/business/entities/User'; +import { ROLES } from '../../../../shared/src/business/entities/EntityConstants'; import { applicationContextForClient as applicationContext } from '../../../../shared/src/business/test/createTestApplicationContext'; import { getUserPermissions } from '../../../../shared/src/authorization/getUserPermissions'; @@ -7,7 +7,7 @@ import { runAction } from 'cerebral/test'; import { setUserPermissionsAction } from './setUserPermissionsAction'; describe('setUserPermissionsAction', () => { - const mockUser = { role: User.ROLES.docketClerk }; + const mockUser = { role: ROLES.docketClerk }; beforeAll(() => { presenter.providers.applicationContext = applicationContext; diff --git a/web-client/src/presenter/actions/setupEditPetitionDetailFormAction.test.js b/web-client/src/presenter/actions/setupEditPetitionDetailFormAction.test.js index ef1e540f544..481861b9cb8 100644 --- a/web-client/src/presenter/actions/setupEditPetitionDetailFormAction.test.js +++ b/web-client/src/presenter/actions/setupEditPetitionDetailFormAction.test.js @@ -1,4 +1,4 @@ -import { Case } from '../../../../shared/src/business/entities/cases/Case'; +import { PAYMENT_STATUS } from '../../../../shared/src/business/entities/EntityConstants'; import { applicationContextForClient as applicationContext } from '../../../../shared/src/business/test/createTestApplicationContext'; import { presenter } from '../presenter-mock'; import { runAction } from 'cerebral/test'; @@ -17,7 +17,7 @@ describe('setupEditPetitionDetailFormAction', () => { state: { caseDetail: { caseType: 'some case type', - petitionPaymentStatus: Case.PAYMENT_STATUS.WAIVED, + petitionPaymentStatus: PAYMENT_STATUS.WAIVED, petitionPaymentWaivedDate: '2019-03-01T21:40:46.415Z', preferredTrialCity: 'Fresno, California', procedureType: 'Small', @@ -31,7 +31,7 @@ describe('setupEditPetitionDetailFormAction', () => { paymentDateWaivedDay: '01', paymentDateWaivedMonth: '03', paymentDateWaivedYear: '2019', - petitionPaymentStatus: Case.PAYMENT_STATUS.WAIVED, + petitionPaymentStatus: PAYMENT_STATUS.WAIVED, preferredTrialCity: 'Fresno, California', procedureType: 'Small', }); @@ -45,7 +45,7 @@ describe('setupEditPetitionDetailFormAction', () => { state: { caseDetail: { petitionPaymentDate: '2019-03-01T21:40:46.415Z', - petitionPaymentStatus: Case.PAYMENT_STATUS.PAID, + petitionPaymentStatus: PAYMENT_STATUS.PAID, }, form: {}, }, @@ -55,7 +55,7 @@ describe('setupEditPetitionDetailFormAction', () => { paymentDateDay: '01', paymentDateMonth: '03', paymentDateYear: '2019', - petitionPaymentStatus: Case.PAYMENT_STATUS.PAID, + petitionPaymentStatus: PAYMENT_STATUS.PAID, }); }); @@ -66,14 +66,14 @@ describe('setupEditPetitionDetailFormAction', () => { }, state: { caseDetail: { - petitionPaymentStatus: Case.PAYMENT_STATUS.UNPAID, + petitionPaymentStatus: PAYMENT_STATUS.UNPAID, }, form: {}, }, }); expect(result.state.form).toEqual({ - petitionPaymentStatus: Case.PAYMENT_STATUS.UNPAID, + petitionPaymentStatus: PAYMENT_STATUS.UNPAID, }); }); diff --git a/web-client/src/presenter/actions/startScanAction.test.js b/web-client/src/presenter/actions/startScanAction.test.js index 8f904c7f747..133c1d21850 100644 --- a/web-client/src/presenter/actions/startScanAction.test.js +++ b/web-client/src/presenter/actions/startScanAction.test.js @@ -1,4 +1,4 @@ -import { Scan } from '../../../../shared/src/business/entities/Scan'; +import { SCAN_MODES } from '../../../../shared/src/business/entities/EntityConstants'; import { applicationContextForClient as applicationContext } from '../../../../shared/src/business/test/createTestApplicationContext'; import { presenter } from '../presenter-mock'; import { runAction } from 'cerebral/test'; @@ -22,7 +22,7 @@ describe('startScanAction', () => { presenter, }, props: { - scanMode: Scan.SCAN_MODES.FEEDER, + scanMode: SCAN_MODES.FEEDER, scannerSourceIndex: 0, scannerSourceName: 'scanner', }, @@ -46,7 +46,7 @@ describe('startScanAction', () => { presenter, }, props: { - scanMode: Scan.SCAN_MODES.FEEDER, + scanMode: SCAN_MODES.FEEDER, scannerSourceIndex: 0, scannerSourceName: 'scanner', }, @@ -99,7 +99,7 @@ describe('startScanAction', () => { presenter, }, props: { - scanMode: Scan.SCAN_MODES.FEEDER, + scanMode: SCAN_MODES.FEEDER, scannerSourceIndex: 0, scannerSourceName: 'scanner', }, diff --git a/web-client/src/presenter/actions/unsetRequestAccessWizardStepAction.js b/web-client/src/presenter/actions/unsetRequestAccessWizardStepAction.js new file mode 100644 index 00000000000..dda47ad13a2 --- /dev/null +++ b/web-client/src/presenter/actions/unsetRequestAccessWizardStepAction.js @@ -0,0 +1,11 @@ +import { state } from 'cerebral'; + +/** + * Clears the state.wizardStep. + * + * @param {object} providers the providers object + * @param {object} providers.store the cerebral store + */ +export const unsetRequestAccessWizardStepAction = ({ store }) => { + store.unset(state.wizardStep); +}; diff --git a/web-client/src/presenter/actions/unsetRequestAccessWizardStepAction.test.js b/web-client/src/presenter/actions/unsetRequestAccessWizardStepAction.test.js new file mode 100644 index 00000000000..a4562f9e521 --- /dev/null +++ b/web-client/src/presenter/actions/unsetRequestAccessWizardStepAction.test.js @@ -0,0 +1,14 @@ +import { runAction } from 'cerebral/test'; +import { unsetRequestAccessWizardStepAction } from './unsetRequestAccessWizardStepAction'; + +describe('unsetRequestAccessWizardStepAction', () => { + it('should clear wizardStep from state', async () => { + const { state } = await runAction(unsetRequestAccessWizardStepAction, { + state: { + wizardStep: 'TestWizardStep', + }, + }); + + expect(state.wizardStep).toBeUndefined(); + }); +}); diff --git a/web-client/src/presenter/actions/updateCreateCaseMessageAttachmentsAction.js b/web-client/src/presenter/actions/updateCreateCaseMessageAttachmentsAction.js new file mode 100644 index 00000000000..c294d6494d3 --- /dev/null +++ b/web-client/src/presenter/actions/updateCreateCaseMessageAttachmentsAction.js @@ -0,0 +1,35 @@ +import { state } from 'cerebral'; + +/** + * updates the current case message form data's attachments field + * + * @param {object} providers the providers object + * @param {object} providers.get the get function to retrieve values from state + * @param {object} providers.props the cerebral props object + * @param {object} providers.store the cerebral store object + */ +export const updateCreateCaseMessageAttachmentsAction = ({ + get, + props, + store, +}) => { + const { attachments } = get(state.modal.form); + const { documents } = get(state.caseDetail); + const { documentId } = props; + + // TODO: Should we evaluate the length of the array and conditionally push? + if (documentId) { + const document = documents.find( + document => document.documentId === documentId, + ); + + const documentTitle = document.documentTitle || document.documentType; + + attachments.push({ + documentId, + documentTitle, + }); + + store.set(state.modal.form.attachments, attachments); + } +}; diff --git a/web-client/src/presenter/actions/updateCreateCaseMessageAttachmentsAction.test.js b/web-client/src/presenter/actions/updateCreateCaseMessageAttachmentsAction.test.js new file mode 100644 index 00000000000..dbe07e0ecfc --- /dev/null +++ b/web-client/src/presenter/actions/updateCreateCaseMessageAttachmentsAction.test.js @@ -0,0 +1,52 @@ +import { runAction } from 'cerebral/test'; +import { updateCreateCaseMessageAttachmentsAction } from './updateCreateCaseMessageAttachmentsAction'; + +describe('updateCreateCaseMessageAttachmentsAction', () => { + const caseDetail = { + documents: [ + { + documentId: '123', + documentType: 'Petition', + }, + ], + }; + + it('appends the given document meta from props to the form.modal.attachments array', async () => { + const result = await runAction(updateCreateCaseMessageAttachmentsAction, { + props: { + documentId: '123', + }, + state: { + caseDetail, + modal: { + form: { + attachments: [], + }, + }, + }, + }); + + expect(result.state.modal.form.attachments).toEqual([ + { documentId: '123', documentTitle: 'Petition' }, + ]); + }); + + it('does not modify the array if no documentId is given', async () => { + const result = await runAction(updateCreateCaseMessageAttachmentsAction, { + props: { + documentId: '', + documentTitle: '', + }, + state: { + caseDetail, + modal: { + form: { + attachments: [], + }, + }, + }, + }); + + expect(result.state.modal.form.attachments).toEqual([]); + }); +}); diff --git a/web-client/src/presenter/actions/updatePractitionerUserAction.js b/web-client/src/presenter/actions/updatePractitionerUserAction.js index a62a066a35c..c6cd6b359b1 100644 --- a/web-client/src/presenter/actions/updatePractitionerUserAction.js +++ b/web-client/src/presenter/actions/updatePractitionerUserAction.js @@ -7,6 +7,7 @@ import { state } from 'cerebral'; * @param {object} providers.applicationContext the applicationContext * @param {Function} providers.get the cerebral get function * @param {object} providers.path the next object in the path + * @returns {object} path execution results */ export const updatePractitionerUserAction = async ({ applicationContext, diff --git a/web-client/src/presenter/actions/validateCreateCaseMessageAction.js b/web-client/src/presenter/actions/validateCreateCaseMessageAction.js new file mode 100644 index 00000000000..9aa05ae4815 --- /dev/null +++ b/web-client/src/presenter/actions/validateCreateCaseMessageAction.js @@ -0,0 +1,31 @@ +import { state } from 'cerebral'; + +/** + * validates the create case message modal + * + * @param {object} providers the providers object + * @param {object} providers.get the cerebral get function + * @param {object} providers.path the path to take if validation fails or not + * @param {object} providers.applicationContext the application context needed for getting the validateForwardMessage use case + * @returns {object} path.success or path.error + */ +export const validateCreateCaseMessageAction = ({ + applicationContext, + get, + path, +}) => { + const message = get(state.modal.form); + + const errors = applicationContext + .getUseCases() + .validateCreateCaseMessageInteractor({ + applicationContext, + message, + }); + + if (!errors) { + return path.success(); + } else { + return path.error({ errors }); + } +}; diff --git a/web-client/src/presenter/actions/validateCreateCaseMessageAction.test.js b/web-client/src/presenter/actions/validateCreateCaseMessageAction.test.js new file mode 100644 index 00000000000..8f7b517ef4b --- /dev/null +++ b/web-client/src/presenter/actions/validateCreateCaseMessageAction.test.js @@ -0,0 +1,90 @@ +import { applicationContextForClient as applicationContext } from '../../../../shared/src/business/test/createTestApplicationContext'; +import { presenter } from '../presenter-mock'; +import { runAction } from 'cerebral/test'; +import { validateCreateCaseMessageAction } from './validateCreateCaseMessageAction'; + +describe('validateCreateCaseMessageAction', () => { + let successStub; + let errorStub; + + beforeAll(() => { + successStub = jest.fn(); + errorStub = jest.fn(); + + presenter.providers.applicationContext = applicationContext; + presenter.providers.path = { + error: errorStub, + success: successStub, + }; + + applicationContext + .getUseCases() + .validateCreateCaseMessageInteractor.mockReturnValue(null); + }); + + it('should call the success path when no errors are found', async () => { + await runAction(validateCreateCaseMessageAction, { + modules: { + presenter, + }, + props: {}, + state: { + modal: { + form: { + caseId: 'fa1179bd-04f5-4934-a716-964d8d7babc6', + from: 'yup', + fromSection: 'yup', + fromUserId: 'fa1179bd-04f5-4934-a716-964d8d7babc6', + message: 'yup', + subject: 'hi', + to: 'yup', + toSection: 'yup', + toUserId: 'fa1179bd-04f5-4934-a716-964d8d7babc6', + }, + }, + }, + }); + expect( + applicationContext.getUseCases().validateCreateCaseMessageInteractor.mock + .calls[0][0].message, + ).toMatchObject({ + caseId: 'fa1179bd-04f5-4934-a716-964d8d7babc6', + from: 'yup', + fromSection: 'yup', + fromUserId: 'fa1179bd-04f5-4934-a716-964d8d7babc6', + message: 'yup', + subject: 'hi', + to: 'yup', + toSection: 'yup', + toUserId: 'fa1179bd-04f5-4934-a716-964d8d7babc6', + }); + expect(successStub.mock.calls.length).toEqual(1); + }); + + it('should call the error path when any errors are found', async () => { + applicationContext + .getUseCases() + .validateCreateCaseMessageInteractor.mockReturnValue('error'); + + await runAction(validateCreateCaseMessageAction, { + modules: { + presenter, + }, + state: { + modal: { + form: { + caseId: 'fa1179bd-04f5-4934-a716-964d8d7babc6', + from: 'yup', + fromSection: 'yup', + fromUserId: 'fa1179bd-04f5-4934-a716-964d8d7babc6', + message: 'yup', + to: 'yup', + toSection: 'yup', + toUserId: 'fa1179bd-04f5-4934-a716-964d8d7babc6', + }, + }, + }, + }); + expect(errorStub.mock.calls.length).toEqual(1); + }); +}); diff --git a/web-client/src/presenter/computeds/AdvancedSearch/advancedDocumentSearchHelper.js b/web-client/src/presenter/computeds/AdvancedSearch/advancedDocumentSearchHelper.js index 0c7753f294d..cd2f84ddb15 100644 --- a/web-client/src/presenter/computeds/AdvancedSearch/advancedDocumentSearchHelper.js +++ b/web-client/src/presenter/computeds/AdvancedSearch/advancedDocumentSearchHelper.js @@ -1,4 +1,9 @@ import { Document } from '../../../../../shared/src/business/entities/Document'; +import { + OPINION_DOCUMENT_TYPES, + ORDER_DOCUMENT_TYPES, +} from '../../../../../shared/src/business/entities/EntityConstants'; + import { capitalize } from 'lodash'; import { paginationHelper } from './advancedSearchHelper'; import { state } from 'cerebral'; @@ -59,11 +64,11 @@ export const formatDocumentSearchResultRecord = ( result.documentTitle = result.formattedDocumentType; } - if (Document.OPINION_DOCUMENT_TYPES.includes(result.eventCode)) { + if (OPINION_DOCUMENT_TYPES.includes(result.eventCode)) { result.formattedJudgeName = result.judge ? applicationContext.getUtilities().getJudgeLastName(result.judge) : ''; - } else if (Document.ORDER_DOCUMENT_TYPES.includes(result.eventCode)) { + } else if (ORDER_DOCUMENT_TYPES.includes(result.eventCode)) { result.formattedSignedJudgeName = result.signedJudgeName ? applicationContext .getUtilities() diff --git a/web-client/src/presenter/computeds/AdvancedSearch/advancedSearchHelper.test.js b/web-client/src/presenter/computeds/AdvancedSearch/advancedSearchHelper.test.js index 817deecd83d..0e6f935493d 100644 --- a/web-client/src/presenter/computeds/AdvancedSearch/advancedSearchHelper.test.js +++ b/web-client/src/presenter/computeds/AdvancedSearch/advancedSearchHelper.test.js @@ -1,5 +1,7 @@ -import { ContactFactory } from '../../../../../shared/src/business/entities/contacts/ContactFactory'; -import { User } from '../../../../../shared/src/business/entities/User'; +import { + COUNTRY_TYPES, + ROLES, +} from '../../../../../shared/src/business/entities/EntityConstants'; import { advancedSearchHelper as advancedSearchHelperComputed } from './advancedSearchHelper'; import { applicationContext } from '../../../applicationContext'; import { getUserPermissions } from '../../../../../shared/src/authorization/getUserPermissions'; @@ -32,7 +34,7 @@ describe('advancedSearchHelper', () => { beforeEach(() => { globalUser = { - role: User.ROLES.docketClerk, + role: ROLES.docketClerk, userId: 'docketClerk', }; }); @@ -64,7 +66,7 @@ describe('advancedSearchHelper', () => { it('returns showPractitionerSearch false when user is an external user', () => { globalUser = { - role: User.ROLES.privatePractitioner, + role: ROLES.privatePractitioner, userId: 'practitioner', }; @@ -85,7 +87,7 @@ describe('advancedSearchHelper', () => { ...getBaseState(globalUser), advancedSearchForm: { caseSearchByName: { - countryType: ContactFactory.COUNTRY_TYPES.DOMESTIC, + countryType: COUNTRY_TYPES.DOMESTIC, }, }, }, @@ -102,7 +104,7 @@ describe('advancedSearchHelper', () => { ...getBaseState(globalUser), advancedSearchForm: { caseSearchByName: { - countryType: ContactFactory.COUNTRY_TYPES.INTERNATIONAL, + countryType: COUNTRY_TYPES.INTERNATIONAL, }, }, }, diff --git a/web-client/src/presenter/computeds/Dashboard/externalUserCasesHelper.js b/web-client/src/presenter/computeds/Dashboard/externalUserCasesHelper.js new file mode 100644 index 00000000000..6bbcf7b7ede --- /dev/null +++ b/web-client/src/presenter/computeds/Dashboard/externalUserCasesHelper.js @@ -0,0 +1,33 @@ +import { state } from 'cerebral'; + +export const externalUserCasesHelper = (get, applicationContext) => { + const { formatCase } = applicationContext.getUtilities(); + + const openCases = get(state.openCases); + const closedCases = get(state.closedCases); + + const formattedOpenCases = openCases.map(openCase => + formatCase(applicationContext, openCase), + ); + const formattedClosedCases = closedCases.map(closedCase => + formatCase(applicationContext, closedCase), + ); + + const openCurrentPage = get(state.openCasesCurrentPage) || 1; + const closedCurrentPage = get(state.closedCasesCurrentPage) || 1; + const pageSize = get(state.constants.CASE_LIST_PAGE_SIZE); + + return { + closedCaseResults: formattedClosedCases.slice( + 0, + closedCurrentPage * pageSize, + ), + closedCasesCount: formattedClosedCases.length, + openCaseResults: formattedOpenCases.slice(0, openCurrentPage * pageSize), + openCasesCount: formattedOpenCases.length, + showLoadMoreClosedCases: + formattedClosedCases.length > closedCurrentPage * pageSize, + showLoadMoreOpenCases: + formattedOpenCases.length > openCurrentPage * pageSize, + }; +}; diff --git a/web-client/src/presenter/computeds/Dashboard/externalUserCasesHelper.test.js b/web-client/src/presenter/computeds/Dashboard/externalUserCasesHelper.test.js new file mode 100644 index 00000000000..43d7517d501 --- /dev/null +++ b/web-client/src/presenter/computeds/Dashboard/externalUserCasesHelper.test.js @@ -0,0 +1,97 @@ +import { applicationContext } from '../../../applicationContext'; +import { externalUserCasesHelper as externalUserCasesHelperComputed } from './externalUserCasesHelper'; +import { runCompute } from 'cerebral/test'; +import { withAppContextDecorator } from '../../../withAppContext'; + +const externalUserCasesHelper = withAppContextDecorator( + externalUserCasesHelperComputed, + { + ...applicationContext, + getUtilities: () => ({ + formatCase: () => ({ + caseId: 'case-id-123', + }), + }), + }, +); + +const baseState = { + closedCases: [...Array(10).keys()], + constants: { + CASE_LIST_PAGE_SIZE: 5, + }, + openCases: [...Array(10).keys()], +}; + +describe('externalUserCasesHelper', () => { + it('returns more than 10 open and closed cases, shows load more button for both', () => { + const result = runCompute(externalUserCasesHelper, { + state: { + ...baseState, + }, + }); + + expect(result).toMatchObject({ + showLoadMoreClosedCases: true, + showLoadMoreOpenCases: true, + }); + }); + + it("doesn't show load more button for closed cases", () => { + const result = runCompute(externalUserCasesHelper, { + state: { + ...baseState, + closedCases: [0], + }, + }); + + expect(result).toMatchObject({ + showLoadMoreClosedCases: false, + showLoadMoreOpenCases: true, + }); + }); + + it("doesn't show load more button for open cases", () => { + const result = runCompute(externalUserCasesHelper, { + state: { + ...baseState, + openCases: [0], + }, + }); + + expect(result).toMatchObject({ + showLoadMoreClosedCases: true, + showLoadMoreOpenCases: false, + }); + }); + + it('sets the total count of both open and closed cases', () => { + const result = runCompute(externalUserCasesHelper, { + state: { + ...baseState, + closedCases: [{ caseId: 'hey' }], + openCases: [{ caseId: 'hey' }, { caseId: 'bye' }], + }, + }); + + expect(result).toMatchObject({ + closedCasesCount: 1, + openCasesCount: 2, + }); + }); + + it('uses current pages in state', () => { + const result = runCompute(externalUserCasesHelper, { + state: { + ...baseState, + closedCasesCurrentPage: 2, + openCasesCurrentPage: 2, + }, + }); + + expect(result).toMatchObject({ + showLoadMoreClosedCases: false, + showLoadMoreOpenCases: false, + }); + }); +}); diff --git a/web-client/src/presenter/computeds/addDocketEntryHelper.test.js b/web-client/src/presenter/computeds/addDocketEntryHelper.test.js index 0a1efe38e84..fc6b8c49479 100644 --- a/web-client/src/presenter/computeds/addDocketEntryHelper.test.js +++ b/web-client/src/presenter/computeds/addDocketEntryHelper.test.js @@ -1,5 +1,5 @@ -import { ContactFactory } from '../../../../shared/src/business/entities/contacts/ContactFactory'; import { MOCK_CASE } from '../../../../shared/src/test/mockCase'; +import { PARTY_TYPES } from '../../../../shared/src/business/entities/EntityConstants'; import { addDocketEntryHelper as addDocketEntryHelperComputed } from './addDocketEntryHelper'; import { applicationContext } from '../../applicationContext'; import { runCompute } from 'cerebral/test'; @@ -71,7 +71,7 @@ describe('addDocketEntryHelper', () => { }); it('shows secondary party for petitionerSpouse or petitionerDeceasedSpouse', () => { - state.caseDetail.partyType = ContactFactory.PARTY_TYPES.petitionerSpouse; + state.caseDetail.partyType = PARTY_TYPES.petitionerSpouse; const result = runCompute(addDocketEntryHelper, { state }); expect(result.showSecondaryParty).toBeTruthy(); }); diff --git a/web-client/src/presenter/computeds/addEditUserCaseNoteModalHelper.test.js b/web-client/src/presenter/computeds/addEditUserCaseNoteModalHelper.test.js index 4deb6b1bb54..cc0b9760da1 100644 --- a/web-client/src/presenter/computeds/addEditUserCaseNoteModalHelper.test.js +++ b/web-client/src/presenter/computeds/addEditUserCaseNoteModalHelper.test.js @@ -1,4 +1,4 @@ -import { User } from '../../../../shared/src/business/entities/User'; +import { ROLES } from '../../../../shared/src/business/entities/EntityConstants'; import { runCompute } from 'cerebral/test'; import { withAppContextDecorator } from '../../withAppContext'; @@ -10,7 +10,7 @@ const addEditUserCaseNoteModalHelper = withAppContextDecorator( addEditUserCaseNoteModalHelperComputed, { getConstants: () => ({ - USER_ROLES: User.ROLES, + USER_ROLES: ROLES, }), getCurrentUser: () => currentUser, }, @@ -19,7 +19,7 @@ const addEditUserCaseNoteModalHelper = withAppContextDecorator( describe('addEditUserCaseNoteModalHelper', () => { it("should return Judge's notes as notesLabel if current user is not a trial clerk", () => { currentUser = { - role: User.ROLES.judge, + role: ROLES.judge, }; const result = runCompute(addEditUserCaseNoteModalHelper, {}); @@ -29,7 +29,7 @@ describe('addEditUserCaseNoteModalHelper', () => { it('should return Notes as notesLabel if current user is a trial clerk', () => { currentUser = { - role: User.ROLES.trialClerk, + role: ROLES.trialClerk, }; const result = runCompute(addEditUserCaseNoteModalHelper, {}); diff --git a/web-client/src/presenter/computeds/caseDetailEditContactsHelper.test.js b/web-client/src/presenter/computeds/caseDetailEditContactsHelper.test.js index 3cab15aa76e..562c7756ad9 100644 --- a/web-client/src/presenter/computeds/caseDetailEditContactsHelper.test.js +++ b/web-client/src/presenter/computeds/caseDetailEditContactsHelper.test.js @@ -1,4 +1,4 @@ -import { ContactFactory } from '../../../../shared/src/business/entities/contacts/ContactFactory'; +import { PARTY_TYPES } from '../../../../shared/src/business/entities/EntityConstants'; import { applicationContext } from '../../applicationContext'; import { caseDetailEditContactsHelper as caseDetailEditContactsHelperComputed } from './caseDetailEditContactsHelper'; import { runCompute } from 'cerebral/test'; @@ -13,7 +13,7 @@ describe('caseDetailEditContactsHelper', () => { it('should validate form view information for party type Conservator', () => { const result = runCompute(caseDetailEditContactsHelper, { state: { - form: { partyType: ContactFactory.PARTY_TYPES.conservator }, + form: { partyType: PARTY_TYPES.conservator }, }, }); expect(result).toMatchObject({ @@ -29,7 +29,7 @@ describe('caseDetailEditContactsHelper', () => { it('should validate form view information for party type Corporation', () => { const result = runCompute(caseDetailEditContactsHelper, { state: { - form: { partyType: ContactFactory.PARTY_TYPES.corporation }, + form: { partyType: PARTY_TYPES.corporation }, }, }); expect(result).toMatchObject({ @@ -44,7 +44,7 @@ describe('caseDetailEditContactsHelper', () => { it('should validate form view information for party type Custodian', () => { const result = runCompute(caseDetailEditContactsHelper, { state: { - form: { partyType: ContactFactory.PARTY_TYPES.custodian }, + form: { partyType: PARTY_TYPES.custodian }, }, }); expect(result).toMatchObject({ @@ -60,7 +60,7 @@ describe('caseDetailEditContactsHelper', () => { it('should validate form view information for party type Donor', () => { const result = runCompute(caseDetailEditContactsHelper, { state: { - form: { partyType: ContactFactory.PARTY_TYPES.donor }, + form: { partyType: PARTY_TYPES.donor }, }, }); expect(result).toMatchObject({ @@ -75,7 +75,7 @@ describe('caseDetailEditContactsHelper', () => { const result = runCompute(caseDetailEditContactsHelper, { state: { form: { - partyType: ContactFactory.PARTY_TYPES.estate, + partyType: PARTY_TYPES.estate, }, }, }); @@ -94,7 +94,7 @@ describe('caseDetailEditContactsHelper', () => { const result = runCompute(caseDetailEditContactsHelper, { state: { form: { - partyType: ContactFactory.PARTY_TYPES.estateWithoutExecutor, + partyType: PARTY_TYPES.estateWithoutExecutor, }, }, }); @@ -111,7 +111,7 @@ describe('caseDetailEditContactsHelper', () => { const result = runCompute(caseDetailEditContactsHelper, { state: { form: { - partyType: ContactFactory.PARTY_TYPES.guardian, + partyType: PARTY_TYPES.guardian, }, }, }); @@ -129,7 +129,7 @@ describe('caseDetailEditContactsHelper', () => { const result = runCompute(caseDetailEditContactsHelper, { state: { form: { - partyType: ContactFactory.PARTY_TYPES.nextFriendForIncompetentPerson, + partyType: PARTY_TYPES.nextFriendForIncompetentPerson, }, }, }); @@ -147,7 +147,7 @@ describe('caseDetailEditContactsHelper', () => { const result = runCompute(caseDetailEditContactsHelper, { state: { form: { - partyType: ContactFactory.PARTY_TYPES.nextFriendForMinor, + partyType: PARTY_TYPES.nextFriendForMinor, }, }, }); @@ -165,7 +165,7 @@ describe('caseDetailEditContactsHelper', () => { const result = runCompute(caseDetailEditContactsHelper, { state: { form: { - partyType: ContactFactory.PARTY_TYPES.partnershipBBA, + partyType: PARTY_TYPES.partnershipBBA, }, }, }); @@ -183,7 +183,7 @@ describe('caseDetailEditContactsHelper', () => { const result = runCompute(caseDetailEditContactsHelper, { state: { form: { - partyType: ContactFactory.PARTY_TYPES.partnershipOtherThanTaxMatters, + partyType: PARTY_TYPES.partnershipOtherThanTaxMatters, }, }, }); @@ -201,7 +201,7 @@ describe('caseDetailEditContactsHelper', () => { const result = runCompute(caseDetailEditContactsHelper, { state: { form: { - partyType: ContactFactory.PARTY_TYPES.partnershipAsTaxMattersPartner, + partyType: PARTY_TYPES.partnershipAsTaxMattersPartner, }, }, }); @@ -219,7 +219,7 @@ describe('caseDetailEditContactsHelper', () => { const result = runCompute(caseDetailEditContactsHelper, { state: { form: { - partyType: ContactFactory.PARTY_TYPES.petitioner, + partyType: PARTY_TYPES.petitioner, }, }, }); @@ -235,7 +235,7 @@ describe('caseDetailEditContactsHelper', () => { const result = runCompute(caseDetailEditContactsHelper, { state: { form: { - partyType: ContactFactory.PARTY_TYPES.petitionerSpouse, + partyType: PARTY_TYPES.petitionerSpouse, }, }, }); @@ -259,7 +259,7 @@ describe('caseDetailEditContactsHelper', () => { const result = runCompute(caseDetailEditContactsHelper, { state: { form: { - partyType: ContactFactory.PARTY_TYPES.petitionerDeceasedSpouse, + partyType: PARTY_TYPES.petitionerDeceasedSpouse, }, }, }); @@ -279,7 +279,7 @@ describe('caseDetailEditContactsHelper', () => { const result = runCompute(caseDetailEditContactsHelper, { state: { form: { - partyType: ContactFactory.PARTY_TYPES.survivingSpouse, + partyType: PARTY_TYPES.survivingSpouse, }, }, }); @@ -297,7 +297,7 @@ describe('caseDetailEditContactsHelper', () => { const result = runCompute(caseDetailEditContactsHelper, { state: { form: { - partyType: ContactFactory.PARTY_TYPES.transferee, + partyType: PARTY_TYPES.transferee, }, }, }); @@ -313,7 +313,7 @@ describe('caseDetailEditContactsHelper', () => { const result = runCompute(caseDetailEditContactsHelper, { state: { form: { - partyType: ContactFactory.PARTY_TYPES.trust, + partyType: PARTY_TYPES.trust, }, }, }); diff --git a/web-client/src/presenter/computeds/caseDetailEditHelper.test.js b/web-client/src/presenter/computeds/caseDetailEditHelper.test.js index 664b04a4c8a..35a665da235 100644 --- a/web-client/src/presenter/computeds/caseDetailEditHelper.test.js +++ b/web-client/src/presenter/computeds/caseDetailEditHelper.test.js @@ -1,5 +1,7 @@ -import { Case } from '../../../../shared/src/business/entities/cases/Case'; -import { ContactFactory } from '../../../../shared/src/business/entities/contacts/ContactFactory'; +import { + PARTY_TYPES, + PAYMENT_STATUS, +} from '../../../../shared/src/business/entities/EntityConstants'; import { applicationContext } from '../../applicationContext'; import { caseDetailEditHelper as caseDetailEditHelperComputed } from './caseDetailEditHelper'; import { runCompute } from 'cerebral/test'; @@ -15,7 +17,7 @@ describe('case detail edit computed', () => { const result = runCompute(caseDetailEditHelper, { state: { form: { - partyType: ContactFactory.PARTY_TYPES.conservator, + partyType: PARTY_TYPES.conservator, }, }, }); @@ -26,7 +28,7 @@ describe('case detail edit computed', () => { const result = runCompute(caseDetailEditHelper, { state: { form: { - partyType: ContactFactory.PARTY_TYPES.conservator, + partyType: PARTY_TYPES.conservator, }, }, }); @@ -38,7 +40,7 @@ describe('case detail edit computed', () => { const result = runCompute(caseDetailEditHelper, { state: { form: { - partyType: ContactFactory.PARTY_TYPES.corporation, + partyType: PARTY_TYPES.corporation, }, }, }); @@ -50,7 +52,7 @@ describe('case detail edit computed', () => { const result = runCompute(caseDetailEditHelper, { state: { form: { - partyType: ContactFactory.PARTY_TYPES.custodian, + partyType: PARTY_TYPES.custodian, }, }, }); @@ -62,7 +64,7 @@ describe('case detail edit computed', () => { const result = runCompute(caseDetailEditHelper, { state: { form: { - partyType: ContactFactory.PARTY_TYPES.donor, + partyType: PARTY_TYPES.donor, }, }, }); @@ -74,7 +76,7 @@ describe('case detail edit computed', () => { const result = runCompute(caseDetailEditHelper, { state: { form: { - partyType: ContactFactory.PARTY_TYPES.estate, + partyType: PARTY_TYPES.estate, }, }, }); @@ -86,7 +88,7 @@ describe('case detail edit computed', () => { const result = runCompute(caseDetailEditHelper, { state: { form: { - partyType: ContactFactory.PARTY_TYPES.estateWithoutExecutor, + partyType: PARTY_TYPES.estateWithoutExecutor, }, }, }); @@ -98,7 +100,7 @@ describe('case detail edit computed', () => { const result = runCompute(caseDetailEditHelper, { state: { form: { - partyType: ContactFactory.PARTY_TYPES.guardian, + partyType: PARTY_TYPES.guardian, }, }, }); @@ -110,7 +112,7 @@ describe('case detail edit computed', () => { const result = runCompute(caseDetailEditHelper, { state: { form: { - partyType: ContactFactory.PARTY_TYPES.nextFriendForIncompetentPerson, + partyType: PARTY_TYPES.nextFriendForIncompetentPerson, }, }, }); @@ -122,7 +124,7 @@ describe('case detail edit computed', () => { const result = runCompute(caseDetailEditHelper, { state: { form: { - partyType: ContactFactory.PARTY_TYPES.nextFriendForMinor, + partyType: PARTY_TYPES.nextFriendForMinor, }, }, }); @@ -134,7 +136,7 @@ describe('case detail edit computed', () => { const result = runCompute(caseDetailEditHelper, { state: { form: { - partyType: ContactFactory.PARTY_TYPES.partnershipAsTaxMattersPartner, + partyType: PARTY_TYPES.partnershipAsTaxMattersPartner, }, }, }); @@ -146,7 +148,7 @@ describe('case detail edit computed', () => { const result = runCompute(caseDetailEditHelper, { state: { form: { - partyType: ContactFactory.PARTY_TYPES.partnershipBBA, + partyType: PARTY_TYPES.partnershipBBA, }, }, }); @@ -158,7 +160,7 @@ describe('case detail edit computed', () => { const result = runCompute(caseDetailEditHelper, { state: { form: { - partyType: ContactFactory.PARTY_TYPES.partnershipOtherThanTaxMatters, + partyType: PARTY_TYPES.partnershipOtherThanTaxMatters, }, }, }); @@ -170,7 +172,7 @@ describe('case detail edit computed', () => { const result = runCompute(caseDetailEditHelper, { state: { form: { - partyType: ContactFactory.PARTY_TYPES.petitioner, + partyType: PARTY_TYPES.petitioner, }, }, }); @@ -182,7 +184,7 @@ describe('case detail edit computed', () => { const result = runCompute(caseDetailEditHelper, { state: { form: { - partyType: ContactFactory.PARTY_TYPES.petitionerDeceasedSpouse, + partyType: PARTY_TYPES.petitionerDeceasedSpouse, }, }, }); @@ -194,7 +196,7 @@ describe('case detail edit computed', () => { const result = runCompute(caseDetailEditHelper, { state: { form: { - partyType: ContactFactory.PARTY_TYPES.petitionerSpouse, + partyType: PARTY_TYPES.petitionerSpouse, }, }, }); @@ -206,7 +208,7 @@ describe('case detail edit computed', () => { const result = runCompute(caseDetailEditHelper, { state: { form: { - partyType: ContactFactory.PARTY_TYPES.survivingSpouse, + partyType: PARTY_TYPES.survivingSpouse, }, }, }); @@ -218,7 +220,7 @@ describe('case detail edit computed', () => { const result = runCompute(caseDetailEditHelper, { state: { form: { - partyType: ContactFactory.PARTY_TYPES.transferee, + partyType: PARTY_TYPES.transferee, }, }, }); @@ -230,7 +232,7 @@ describe('case detail edit computed', () => { const result = runCompute(caseDetailEditHelper, { state: { form: { - partyType: ContactFactory.PARTY_TYPES.trust, + partyType: PARTY_TYPES.trust, }, }, }); @@ -248,7 +250,7 @@ describe('case detail edit computed', () => { documentType: 'Ownership Disclosure Statement', }, ], - partyType: ContactFactory.PARTY_TYPES.corporation, + partyType: PARTY_TYPES.corporation, }, }, }); @@ -268,7 +270,7 @@ describe('case detail edit computed', () => { documentType: 'Petition', }, ], - partyType: ContactFactory.PARTY_TYPES.corporation, + partyType: PARTY_TYPES.corporation, }, }, }); @@ -279,7 +281,7 @@ describe('case detail edit computed', () => { const result = runCompute(caseDetailEditHelper, { state: { form: { - partyType: ContactFactory.PARTY_TYPES.petitioner, + partyType: PARTY_TYPES.petitioner, }, }, }); @@ -290,7 +292,7 @@ describe('case detail edit computed', () => { const result = runCompute(caseDetailEditHelper, { state: { form: { - partyType: ContactFactory.PARTY_TYPES.petitioner, + partyType: PARTY_TYPES.petitioner, preferredTrialCity: 'Fresno, California', }, }, @@ -312,7 +314,7 @@ describe('case detail edit computed', () => { }, ], isPaper: true, - partyType: ContactFactory.PARTY_TYPES.petitioner, + partyType: PARTY_TYPES.petitioner, }, }, }); @@ -329,7 +331,7 @@ describe('case detail edit computed', () => { const result = runCompute(caseDetailEditHelper, { state: { form: { - petitionPaymentStatus: Case.PAYMENT_STATUS.UNPAID, + petitionPaymentStatus: PAYMENT_STATUS.UNPAID, }, }, }); @@ -340,7 +342,7 @@ describe('case detail edit computed', () => { const result = runCompute(caseDetailEditHelper, { state: { form: { - petitionPaymentStatus: Case.PAYMENT_STATUS.PAID, + petitionPaymentStatus: PAYMENT_STATUS.PAID, }, }, }); @@ -351,7 +353,7 @@ describe('case detail edit computed', () => { const result = runCompute(caseDetailEditHelper, { state: { form: { - petitionPaymentStatus: Case.PAYMENT_STATUS.WAIVED, + petitionPaymentStatus: PAYMENT_STATUS.WAIVED, }, }, }); diff --git a/web-client/src/presenter/computeds/caseDetailHeaderHelper.test.js b/web-client/src/presenter/computeds/caseDetailHeaderHelper.test.js index 7ea40b60a53..7f8e2ca0732 100644 --- a/web-client/src/presenter/computeds/caseDetailHeaderHelper.test.js +++ b/web-client/src/presenter/computeds/caseDetailHeaderHelper.test.js @@ -1,5 +1,7 @@ -import { Case } from '../../../../shared/src/business/entities/cases/Case'; -import { User } from '../../../../shared/src/business/entities/User'; +import { + CASE_STATUS_TYPES, + ROLES, +} from '../../../../shared/src/business/entities/EntityConstants'; import { applicationContext } from '../../applicationContext'; import { caseDetailHeaderHelper as caseDetailHeaderHelperComputed } from './caseDetailHeaderHelper'; import { getUserPermissions } from '../../../../shared/src/authorization/getUserPermissions'; @@ -28,13 +30,13 @@ const getBaseState = user => { describe('caseDetailHeaderHelper', () => { it('should set showEditCaseButton to true if the user has UPDATE_CASE_CONTENT permission', () => { const user = { - role: User.ROLES.docketClerk, + role: ROLES.docketClerk, userId: 'docketClerk', }; const result = runCompute(caseDetailHeaderHelper, { state: { ...getBaseState(user), - caseDetail: { status: Case.STATUS_TYPES.new }, + caseDetail: { status: CASE_STATUS_TYPES.new }, }, }); expect(result.showEditCaseButton).toEqual(true); @@ -42,13 +44,13 @@ describe('caseDetailHeaderHelper', () => { it('should set showEditCaseButton to false if the user does not have UPDATE_CASE_CONTENT permission', () => { const user = { - role: User.ROLES.privatePractitioner, + role: ROLES.privatePractitioner, userId: '123', }; const result = runCompute(caseDetailHeaderHelper, { state: { ...getBaseState(user), - caseDetail: { status: Case.STATUS_TYPES.new }, + caseDetail: { status: CASE_STATUS_TYPES.new }, }, }); expect(result.showEditCaseButton).toEqual(false); @@ -56,7 +58,7 @@ describe('caseDetailHeaderHelper', () => { it('should set showFileFirstDocumentButton and showRequestAccessToCaseButton to false if user role is respondent and the respondent is associated with the case', () => { const user = { - role: User.ROLES.irsPractitioner, + role: ROLES.irsPractitioner, userId: '789', }; const result = runCompute(caseDetailHeaderHelper, { @@ -76,7 +78,7 @@ describe('caseDetailHeaderHelper', () => { it('should set showFileFirstDocumentButton and showRequestAccessToCaseButton to false if user role is respondent and the respondent is not associated with the case but the case is sealed', () => { const user = { - role: User.ROLES.irsPractitioner, + role: ROLES.irsPractitioner, userId: '789', }; const result = runCompute(caseDetailHeaderHelper, { @@ -99,7 +101,7 @@ describe('caseDetailHeaderHelper', () => { it('should set showRequestAccessToCaseButton to true if user role is respondent and the respondent is not associated with the case', () => { const user = { - role: User.ROLES.irsPractitioner, + role: ROLES.irsPractitioner, userId: '789', }; const result = runCompute(caseDetailHeaderHelper, { @@ -119,7 +121,7 @@ describe('caseDetailHeaderHelper', () => { it('should set showFileFirstDocumentButton to true if user role is respondent and there is no respondent associated with the case', () => { const user = { - role: User.ROLES.irsPractitioner, + role: ROLES.irsPractitioner, userId: '789', }; const result = runCompute(caseDetailHeaderHelper, { @@ -139,7 +141,7 @@ describe('caseDetailHeaderHelper', () => { it('should set showPendingAccessToCaseButton to true if user role is practitioner and case is not owned by user but has pending request', () => { const user = { - role: User.ROLES.privatePractitioner, + role: ROLES.privatePractitioner, userId: '123', }; const result = runCompute(caseDetailHeaderHelper, { @@ -159,7 +161,7 @@ describe('caseDetailHeaderHelper', () => { it('should set showRequestAccessToCaseButton to true if user role is practitioner and case is not owned by user', () => { const user = { - role: User.ROLES.privatePractitioner, + role: ROLES.privatePractitioner, userId: '123', }; const result = runCompute(caseDetailHeaderHelper, { @@ -178,7 +180,7 @@ describe('caseDetailHeaderHelper', () => { it('should set showRequestAccessToCaseButton to false when the current page is FilePetitionSuccess', () => { const user = { - role: User.ROLES.privatePractitioner, + role: ROLES.privatePractitioner, userId: '123', }; const result = runCompute(caseDetailHeaderHelper, { @@ -197,7 +199,7 @@ describe('caseDetailHeaderHelper', () => { it('should set showRequestAccessToCaseButton to false if user role is practitioner and case is not owned by user and the case is sealed', () => { const user = { - role: User.ROLES.privatePractitioner, + role: ROLES.privatePractitioner, userId: '123', }; const result = runCompute(caseDetailHeaderHelper, { @@ -216,7 +218,7 @@ describe('caseDetailHeaderHelper', () => { it('should set showRequestAccessToCaseButton to false if user role is practitioner and case is owned by user', () => { const user = { - role: User.ROLES.privatePractitioner, + role: ROLES.privatePractitioner, userId: '123', }; const result = runCompute(caseDetailHeaderHelper, { @@ -235,7 +237,7 @@ describe('caseDetailHeaderHelper', () => { it('should set showRequestAccessToCaseButton to false if user role is petitioner and user is not associated with the case', () => { const user = { - role: User.ROLES.petitioner, + role: ROLES.petitioner, userId: '123', }; const result = runCompute(caseDetailHeaderHelper, { @@ -254,7 +256,7 @@ describe('caseDetailHeaderHelper', () => { it('should show the consolidated case icon if the case is associated with a lead case', async () => { const user = { - role: User.ROLES.docketClerk, + role: ROLES.docketClerk, userId: '123', }; const result = runCompute(caseDetailHeaderHelper, { @@ -276,7 +278,7 @@ describe('caseDetailHeaderHelper', () => { it('should NOT show the consolidated case icon if the case is NOT associated with a lead case', async () => { const user = { - role: User.ROLES.docketClerk, + role: ROLES.docketClerk, userId: '123', }; const result = runCompute(caseDetailHeaderHelper, { @@ -298,7 +300,7 @@ describe('caseDetailHeaderHelper', () => { it('should show the case detail header menu and add docket entry and create order buttons if current page is CaseDetailInternal and user role is docketclerk', () => { const user = { - role: User.ROLES.docketClerk, + role: ROLES.docketClerk, userId: '789', }; const result = runCompute(caseDetailHeaderHelper, { @@ -373,7 +375,7 @@ describe('caseDetailHeaderHelper', () => { it('should show the Upload PDF button in the action menu if the user is a court user', () => { const user = { - role: User.ROLES.docketClerk, + role: ROLES.docketClerk, userId: '123', }; const result = runCompute(caseDetailHeaderHelper, { @@ -394,7 +396,7 @@ describe('caseDetailHeaderHelper', () => { it('should NOT show the Upload PDF button in the action menu if the user is not a court user', () => { const user = { - role: User.ROLES.petitioner, + role: ROLES.petitioner, userId: '123', }; const result = runCompute(caseDetailHeaderHelper, { diff --git a/web-client/src/presenter/computeds/caseDetailHelper.test.js b/web-client/src/presenter/computeds/caseDetailHelper.test.js index 55e8631489e..f9949c32992 100644 --- a/web-client/src/presenter/computeds/caseDetailHelper.test.js +++ b/web-client/src/presenter/computeds/caseDetailHelper.test.js @@ -1,4 +1,4 @@ -import { User } from '../../../../shared/src/business/entities/User'; +import { ROLES } from '../../../../shared/src/business/entities/EntityConstants'; import { applicationContext } from '../../applicationContext'; import { caseDetailHelper as caseDetailHelperComputed } from './caseDetailHelper'; import { getUserPermissions } from '../../../../shared/src/authorization/getUserPermissions'; @@ -24,7 +24,7 @@ const getBaseState = user => { describe('case detail computed', () => { it('should set showAddCorrespondenceButton to false when the current user is not a petitions clerk or a docket clerk', () => { const user = { - role: User.ROLES.privatePractitioner, + role: ROLES.privatePractitioner, userId: '123', }; @@ -45,7 +45,7 @@ describe('case detail computed', () => { it('should set showAddCorrespondenceButton to true when the current user is a petitions clerk', () => { const user = { - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: '123', }; @@ -66,7 +66,7 @@ describe('case detail computed', () => { it('should set showFileDocumentButton to true if current page is CaseDetail, user role is practitioner, and case is owned by user', () => { const user = { - role: User.ROLES.privatePractitioner, + role: ROLES.privatePractitioner, userId: '123', }; const result = runCompute(caseDetailHelper, { @@ -85,7 +85,7 @@ describe('case detail computed', () => { it('should set showFileDocumentButton to false if current page is CaseDetail, user role is practitioner, and case is not owned by user', () => { const user = { - role: User.ROLES.privatePractitioner, + role: ROLES.privatePractitioner, userId: '123', }; const result = runCompute(caseDetailHelper, { @@ -104,7 +104,7 @@ describe('case detail computed', () => { it('should set showFileDocumentButton to true if current page is CaseDetail, user role is petitioner, and the user is associated with the case', () => { const user = { - role: User.ROLES.petitioner, + role: ROLES.petitioner, }; const result = runCompute(caseDetailHelper, { state: { @@ -122,7 +122,7 @@ describe('case detail computed', () => { it('should set userHasAccessToCase to true if user role is petitioner and user is associated with case', () => { const user = { - role: User.ROLES.petitioner, + role: ROLES.petitioner, userId: '123', }; const result = runCompute(caseDetailHelper, { @@ -141,7 +141,7 @@ describe('case detail computed', () => { it('should set userHasAccessToCase to true if user role is practitioner and the practitioner is associated with the case', () => { const user = { - role: User.ROLES.privatePractitioner, + role: ROLES.privatePractitioner, userId: '123', }; const result = runCompute(caseDetailHelper, { @@ -158,7 +158,7 @@ describe('case detail computed', () => { it('should set userHasAccessToCase to false if user role is practitioner and the practitioner is not associated with the case', () => { const user = { - role: User.ROLES.privatePractitioner, + role: ROLES.privatePractitioner, userId: '123', }; const result = runCompute(caseDetailHelper, { @@ -175,7 +175,7 @@ describe('case detail computed', () => { it('should set userHasAccessToCase and showFileDocumentButton to true if user role is respondent and the respondent is associated with the case', () => { const user = { - role: User.ROLES.irsPractitioner, + role: ROLES.irsPractitioner, userId: '789', }; const result = runCompute(caseDetailHelper, { @@ -195,7 +195,7 @@ describe('case detail computed', () => { it('should set userHasAccessToCase and showFileDocumentButton to false if user role is respondent and the respondent is not associated with the case', () => { const user = { - role: User.ROLES.irsPractitioner, + role: ROLES.irsPractitioner, userId: '789', }; const result = runCompute(caseDetailHelper, { @@ -215,7 +215,7 @@ describe('case detail computed', () => { it('should set userHasAccessToCase and showFileDocumentButton to false if user role is respondent and there is no respondent associated with the case', () => { const user = { - role: User.ROLES.irsPractitioner, + role: ROLES.irsPractitioner, userId: '789', }; const result = runCompute(caseDetailHelper, { @@ -235,7 +235,7 @@ describe('case detail computed', () => { it('should show case deadlines external view for external user who is associated with the case if there are deadlines on the case', () => { const user = { - role: User.ROLES.petitioner, + role: ROLES.petitioner, userId: '789', }; const result = runCompute(caseDetailHelper, { @@ -257,7 +257,7 @@ describe('case detail computed', () => { it('should not show case deadlines external view for external user who is associated with the case if there are not deadlines on the case', () => { const user = { - role: User.ROLES.petitioner, + role: ROLES.petitioner, userId: '789', }; const result = runCompute(caseDetailHelper, { @@ -279,7 +279,7 @@ describe('case detail computed', () => { it('should not show case deadlines external view for external user who is not associated with the case and there are deadlines on the case', () => { const user = { - role: User.ROLES.irsPractitioner, + role: ROLES.irsPractitioner, userId: '789', }; const result = runCompute(caseDetailHelper, { @@ -301,7 +301,7 @@ describe('case detail computed', () => { it('should show case deadlines internal view and not show case deadlines external view for internal user', () => { const user = { - role: User.ROLES.docketClerk, + role: ROLES.docketClerk, userId: '789', }; const result = runCompute(caseDetailHelper, { @@ -320,7 +320,7 @@ describe('case detail computed', () => { it('should show case deadlines internal view as empty and not show case deadlines external view for internal user if case deadlines is empty', () => { const user = { - role: User.ROLES.docketClerk, + role: ROLES.docketClerk, userId: '789', }; const result = runCompute(caseDetailHelper, { @@ -339,7 +339,7 @@ describe('case detail computed', () => { it('should show practitioner section if user is an internal user', () => { const user = { - role: User.ROLES.docketClerk, + role: ROLES.docketClerk, userId: '789', }; const result = runCompute(caseDetailHelper, { @@ -354,7 +354,7 @@ describe('case detail computed', () => { it('should show practitioner section if user is an external user and there are privatePractitioners on the case', () => { const user = { - role: User.ROLES.privatePractitioner, + role: ROLES.privatePractitioner, userId: '123', }; const result = runCompute(caseDetailHelper, { @@ -369,7 +369,7 @@ describe('case detail computed', () => { it('should not show practitioner section if user is an external user and there are no privatePractitioners on the case', () => { const user = { - role: User.ROLES.privatePractitioner, + role: ROLES.privatePractitioner, userId: '123', }; const result = runCompute(caseDetailHelper, { @@ -384,7 +384,7 @@ describe('case detail computed', () => { it('should show respondent section if user is an internal user', () => { const user = { - role: User.ROLES.docketClerk, + role: ROLES.docketClerk, userId: '789', }; const result = runCompute(caseDetailHelper, { @@ -399,7 +399,7 @@ describe('case detail computed', () => { it('should show respondent section if user is an external user and there are irsPractitioners on the case', () => { const user = { - role: User.ROLES.privatePractitioner, + role: ROLES.privatePractitioner, userId: '123', }; const result = runCompute(caseDetailHelper, { @@ -414,7 +414,7 @@ describe('case detail computed', () => { it('should not show respondent section if user is an external user and there are no irsPractitioners on the case', () => { const user = { - role: User.ROLES.privatePractitioner, + role: ROLES.privatePractitioner, userId: '123', }; const result = runCompute(caseDetailHelper, { @@ -429,7 +429,7 @@ describe('case detail computed', () => { it('should format practitioner matches with cityStateZip string and isAlreadyInCase boolean', () => { const user = { - role: User.ROLES.privatePractitioner, + role: ROLES.privatePractitioner, userId: '123', }; const result = runCompute(caseDetailHelper, { @@ -473,7 +473,7 @@ describe('case detail computed', () => { it('should set practitionerSearchResultsCount to the length of the state.modal.practitionerMatches', () => { const user = { - role: User.ROLES.privatePractitioner, + role: ROLES.privatePractitioner, userId: '123', }; const result = runCompute(caseDetailHelper, { @@ -489,7 +489,7 @@ describe('case detail computed', () => { it('should set practitionerSearchResultsCount to 0 if the state.modal.practitionerMatches is an empty array', () => { const user = { - role: User.ROLES.privatePractitioner, + role: ROLES.privatePractitioner, userId: '123', }; const result = runCompute(caseDetailHelper, { @@ -505,7 +505,7 @@ describe('case detail computed', () => { it('should not set practitionerSearchResultsCount if state.modal is an empty object', () => { const user = { - role: User.ROLES.privatePractitioner, + role: ROLES.privatePractitioner, userId: '123', }; const result = runCompute(caseDetailHelper, { @@ -521,7 +521,7 @@ describe('case detail computed', () => { it('should format respondent matches with cityStateZip string and isAlreadyInCase boolean', () => { const user = { - role: User.ROLES.privatePractitioner, + role: ROLES.privatePractitioner, userId: '123', }; const result = runCompute(caseDetailHelper, { @@ -565,7 +565,7 @@ describe('case detail computed', () => { it('should set respondentSearchResultsCount to the length of the state.modal.respondentMatches', () => { const user = { - role: User.ROLES.privatePractitioner, + role: ROLES.privatePractitioner, userId: '123', }; const result = runCompute(caseDetailHelper, { @@ -581,7 +581,7 @@ describe('case detail computed', () => { it('should set respondentSearchResultsCount to 0 if the state.modal.respondentMatches is an empty array', () => { const user = { - role: User.ROLES.privatePractitioner, + role: ROLES.privatePractitioner, userId: '123', }; const result = runCompute(caseDetailHelper, { @@ -597,7 +597,7 @@ describe('case detail computed', () => { it('should not set respondentSearchResultsCount if state.modal is an empty object', () => { const user = { - role: User.ROLES.privatePractitioner, + role: ROLES.privatePractitioner, userId: '123', }; const result = runCompute(caseDetailHelper, { @@ -613,7 +613,7 @@ describe('case detail computed', () => { it('should show empty state for consolidated cases', () => { const user = { - role: User.ROLES.privatePractitioner, + role: ROLES.privatePractitioner, userId: '123', }; const result = runCompute(caseDetailHelper, { @@ -640,7 +640,7 @@ describe('case detail computed', () => { it('should show edit petition details button if user has EDIT_PETITION_DETAILS permission', () => { const user = { - role: User.ROLES.docketClerk, + role: ROLES.docketClerk, userId: '789', }; const result = runCompute(caseDetailHelper, { @@ -657,7 +657,7 @@ describe('case detail computed', () => { it('should not show edit petition details button if user does not have EDIT_PETITION_DETAILS permission', () => { const user = { - role: User.ROLES.docketClerk, + role: ROLES.docketClerk, userId: '789', }; const result = runCompute(caseDetailHelper, { @@ -674,7 +674,7 @@ describe('case detail computed', () => { it('should show the filing fee section for a petitioner user', () => { const user = { - role: User.ROLES.petitioner, + role: ROLES.petitioner, userId: '789', }; const result = runCompute(caseDetailHelper, { @@ -690,7 +690,7 @@ describe('case detail computed', () => { it('should show the filing fee section for a practitioner user', () => { const user = { - role: User.ROLES.privatePractitioner, + role: ROLES.privatePractitioner, userId: '789', }; const result = runCompute(caseDetailHelper, { @@ -706,7 +706,7 @@ describe('case detail computed', () => { it('should not show the filing fee section for a respondent user', () => { const user = { - role: User.ROLES.irsPractitioner, + role: ROLES.irsPractitioner, userId: '789', }; const result = runCompute(caseDetailHelper, { diff --git a/web-client/src/presenter/computeds/caseDetailSubnavHelper.test.js b/web-client/src/presenter/computeds/caseDetailSubnavHelper.test.js index a95cbef40a1..f3e6aaaa7db 100644 --- a/web-client/src/presenter/computeds/caseDetailSubnavHelper.test.js +++ b/web-client/src/presenter/computeds/caseDetailSubnavHelper.test.js @@ -1,4 +1,4 @@ -import { User } from '../../../../shared/src/business/entities/User'; +import { ROLES } from '../../../../shared/src/business/entities/EntityConstants'; import { applicationContext } from '../../applicationContext'; import { caseDetailSubnavHelper as caseDetailSubnavHelperComputed } from './caseDetailSubnavHelper'; import { getUserPermissions } from '../../../../shared/src/authorization/getUserPermissions'; @@ -27,7 +27,7 @@ const getBaseState = user => { describe('caseDetailSubnavHelper', () => { it('should show internal-only tabs if user is internal', () => { const user = { - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: '123', }; const result = runCompute(caseDetailSubnavHelper, { @@ -44,7 +44,7 @@ describe('caseDetailSubnavHelper', () => { it('should not show internal-only tabs if user is external', () => { const user = { - role: User.ROLES.petitioner, + role: ROLES.petitioner, userId: '123', }; const result = runCompute(caseDetailSubnavHelper, { @@ -60,7 +60,7 @@ describe('caseDetailSubnavHelper', () => { it('should show case information tab if user is external and associated with the case', () => { const user = { - role: User.ROLES.petitioner, + role: ROLES.petitioner, userId: '123', }; const result = runCompute(caseDetailSubnavHelper, { @@ -76,7 +76,7 @@ describe('caseDetailSubnavHelper', () => { it('should not show case information tab if user is external and not associated with the case', () => { const user = { - role: User.ROLES.irsPractitioner, + role: ROLES.irsPractitioner, userId: '123', }; const result = runCompute(caseDetailSubnavHelper, { diff --git a/web-client/src/presenter/computeds/caseInformationHelper.test.js b/web-client/src/presenter/computeds/caseInformationHelper.test.js index ef6a4446f80..c495a42a0a8 100644 --- a/web-client/src/presenter/computeds/caseInformationHelper.test.js +++ b/web-client/src/presenter/computeds/caseInformationHelper.test.js @@ -1,4 +1,4 @@ -import { User } from '../../../../shared/src/business/entities/User'; +import { ROLES } from '../../../../shared/src/business/entities/EntityConstants'; import { caseInformationHelper } from './caseInformationHelper'; import { getUserPermissions } from '../../../../shared/src/authorization/getUserPermissions'; import { runCompute } from 'cerebral/test'; @@ -12,7 +12,7 @@ const getBaseState = user => { describe('case information helper', () => { it('should show add counsel section if user is an internal user', () => { const user = { - role: User.ROLES.docketClerk, + role: ROLES.docketClerk, userId: '789', }; const result = runCompute(caseInformationHelper, { @@ -27,7 +27,7 @@ describe('case information helper', () => { it('should not show add counsel section if user is an external user', () => { const user = { - role: User.ROLES.privatePractitioner, + role: ROLES.privatePractitioner, userId: '123', }; const result = runCompute(caseInformationHelper, { @@ -42,7 +42,7 @@ describe('case information helper', () => { it('should show edit privatePractitioners and irsPractitioners buttons if user is an internal user and there are privatePractitioners and irsPractitioners on the case', () => { const user = { - role: User.ROLES.docketClerk, + role: ROLES.docketClerk, userId: '789', }; const result = runCompute(caseInformationHelper, { @@ -61,7 +61,7 @@ describe('case information helper', () => { it('should not show edit privatePractitioners or irsPractitioners buttons if user is an internal user and there are not privatePractitioners and irsPractitioners on the case', () => { const user = { - role: User.ROLES.docketClerk, + role: ROLES.docketClerk, userId: '789', }; const result = runCompute(caseInformationHelper, { @@ -77,7 +77,7 @@ describe('case information helper', () => { it('should not show edit privatePractitioners or irsPractitioners buttons if user is not an internal user', () => { const user = { - role: User.ROLES.petitioner, + role: ROLES.petitioner, userId: '789', }; const result = runCompute(caseInformationHelper, { @@ -96,7 +96,7 @@ describe('case information helper', () => { it('should not show Seal Case button if user does not have SEAL_CASE permission', () => { const user = { - role: User.ROLES.petitionsClerk, // does not have SEAL_CASE permission + role: ROLES.petitionsClerk, // does not have SEAL_CASE permission userId: '789', }; const result = runCompute(caseInformationHelper, { @@ -111,7 +111,7 @@ describe('case information helper', () => { it('should show Seal Case button if user has SEAL_CASE permission and case is not already sealed', () => { const user = { - role: User.ROLES.docketClerk, // has SEAL_CASE permission + role: ROLES.docketClerk, // has SEAL_CASE permission userId: '789', }; const result = runCompute(caseInformationHelper, { @@ -126,7 +126,7 @@ describe('case information helper', () => { it('should not show Seal Case button if user has SEAL_CASE permission and case is already sealed', () => { const user = { - role: User.ROLES.docketClerk, // has SEAL_CASE permission + role: ROLES.docketClerk, // has SEAL_CASE permission userId: '789', }; const result = runCompute(caseInformationHelper, { diff --git a/web-client/src/presenter/computeds/caseInventoryReportHelper.test.js b/web-client/src/presenter/computeds/caseInventoryReportHelper.test.js index 219bb232758..b439e521d23 100644 --- a/web-client/src/presenter/computeds/caseInventoryReportHelper.test.js +++ b/web-client/src/presenter/computeds/caseInventoryReportHelper.test.js @@ -1,12 +1,15 @@ -import { Case } from '../../../../shared/src/business/entities/cases/Case'; -import { User } from '../../../../shared/src/business/entities/User'; +import { + CASE_STATUS_TYPES, + ROLES, +} from '../../../../shared/src/business/entities/EntityConstants'; + import { applicationContext } from '../../applicationContext'; import { caseInventoryReportHelper as caseInventoryReportHelperComputed } from './caseInventoryReportHelper'; import { runCompute } from 'cerebral/test'; import { withAppContextDecorator } from '../../withAppContext'; applicationContext.getCurrentUser = () => ({ - role: User.ROLES.docketClerk, + role: ROLES.docketClerk, userId: '5d66d122-8417-427b-9048-c1ba8ab1ea68', }); @@ -32,7 +35,7 @@ describe('caseInventoryReportHelper', () => { }, }); - expect(result.caseStatuses).toEqual(Object.values(Case.STATUS_TYPES)); + expect(result.caseStatuses).toEqual(Object.values(CASE_STATUS_TYPES)); }); it('should return all judges from state along with Chief Judge sorted alphabetically', () => { diff --git a/web-client/src/presenter/computeds/caseSearchBoxHelper.test.js b/web-client/src/presenter/computeds/caseSearchBoxHelper.test.js index 0a0334d9418..7ca8135cfb1 100644 --- a/web-client/src/presenter/computeds/caseSearchBoxHelper.test.js +++ b/web-client/src/presenter/computeds/caseSearchBoxHelper.test.js @@ -1,4 +1,4 @@ -import { User } from '../../../../shared/src/business/entities/User'; +import { ROLES } from '../../../../shared/src/business/entities/EntityConstants'; import { applicationContext } from '../../applicationContext'; import { caseSearchBoxHelper as caseSearchBoxHelperComputed } from './caseSearchBoxHelper'; import { runCompute } from 'cerebral/test'; @@ -12,7 +12,7 @@ const caseSearchBoxHelper = withAppContextDecorator( describe('caseSearchBoxHelper', () => { it('should return showSearchDescription true if the user role is not irsSuperuser', () => { applicationContext.getCurrentUser = () => ({ - role: User.ROLES.irsPractitioner, + role: ROLES.irsPractitioner, userId: '5d66d122-8417-427b-9048-c1ba8ab1ea68', }); @@ -25,7 +25,7 @@ describe('caseSearchBoxHelper', () => { it('should return showSearchDescription false if the user role is irsSuperuser', () => { applicationContext.getCurrentUser = () => ({ - role: User.ROLES.irsSuperuser, + role: ROLES.irsSuperuser, userId: '5d66d122-8417-427b-9048-c1ba8ab1ea68', }); diff --git a/web-client/src/presenter/computeds/completeDocumentTypeSectionHelper.test.js b/web-client/src/presenter/computeds/completeDocumentTypeSectionHelper.test.js index f2006c93f55..74854a0b6a6 100644 --- a/web-client/src/presenter/computeds/completeDocumentTypeSectionHelper.test.js +++ b/web-client/src/presenter/computeds/completeDocumentTypeSectionHelper.test.js @@ -1,4 +1,4 @@ -import { Document } from '../../../../shared/src/business/entities/Document'; +import { DOCUMENT_CATEGORY_MAP } from '../../../../shared/src/business/entities/EntityConstants'; import { applicationContext } from '../../applicationContext'; import { completeDocumentTypeSectionHelper as completeDocumentTypeSectionHelperComputed } from './completeDocumentTypeSectionHelper'; import { runCompute } from 'cerebral/test'; @@ -25,7 +25,7 @@ describe('completeDocumentTypeSectionHelper', () => { const categoryKey = 'Application'; const categoryIdx = 0; - const { category, documentType } = Document.CATEGORY_MAP[categoryKey][ + const { category, documentType } = DOCUMENT_CATEGORY_MAP[categoryKey][ categoryIdx ]; @@ -49,7 +49,7 @@ describe('completeDocumentTypeSectionHelper', () => { const categoryKey = 'Motion'; const categoryIdx = 22; - const { category, documentType } = Document.CATEGORY_MAP[categoryKey][ + const { category, documentType } = DOCUMENT_CATEGORY_MAP[categoryKey][ categoryIdx ]; diff --git a/web-client/src/presenter/computeds/contactEditHelper.test.js b/web-client/src/presenter/computeds/contactEditHelper.test.js index 2dc9bfe23fa..8fa02475c08 100644 --- a/web-client/src/presenter/computeds/contactEditHelper.test.js +++ b/web-client/src/presenter/computeds/contactEditHelper.test.js @@ -1,5 +1,5 @@ -import { ContactFactory } from '../../../../shared/src/business/entities/contacts/ContactFactory'; import { MOCK_CASE } from '../../../../shared/src/test/mockCase'; +import { PARTY_TYPES } from '../../../../shared/src/business/entities/EntityConstants'; import { applicationContext } from '../../applicationContext'; import { contactEditHelper as contactEditHelperComputed } from './contactEditHelper'; import { runCompute } from 'cerebral/test'; @@ -22,7 +22,7 @@ describe('contactEditHelper', () => { ...state, caseDetail: { ...MOCK_CASE, - partyType: ContactFactory.PARTY_TYPES.corporation, + partyType: PARTY_TYPES.corporation, }, }; @@ -37,7 +37,7 @@ describe('contactEditHelper', () => { ...state, caseDetail: { ...MOCK_CASE, - partyType: ContactFactory.PARTY_TYPES.estateWithoutExecutor, + partyType: PARTY_TYPES.estateWithoutExecutor, }, }; @@ -52,7 +52,7 @@ describe('contactEditHelper', () => { ...state, caseDetail: { ...MOCK_CASE, - partyType: ContactFactory.PARTY_TYPES.petitionerDeceasedSpouse, + partyType: PARTY_TYPES.petitionerDeceasedSpouse, }, }; @@ -67,7 +67,7 @@ describe('contactEditHelper', () => { ...state, caseDetail: { ...MOCK_CASE, - partyType: ContactFactory.PARTY_TYPES.guardian, + partyType: PARTY_TYPES.guardian, }, }; diff --git a/web-client/src/presenter/computeds/contactsHelper.test.js b/web-client/src/presenter/computeds/contactsHelper.test.js index fc6c41c6dc8..4a9b7153620 100644 --- a/web-client/src/presenter/computeds/contactsHelper.test.js +++ b/web-client/src/presenter/computeds/contactsHelper.test.js @@ -1,5 +1,7 @@ -import { ContactFactory } from '../../../../shared/src/business/entities/contacts/ContactFactory'; -import { User } from '../../../../shared/src/business/entities/User'; +import { + PARTY_TYPES, + ROLES, +} from '../../../../shared/src/business/entities/EntityConstants'; import { applicationContext } from '../../applicationContext'; import { contactsHelper as contactsHelperComputed } from './contactsHelper'; import { runCompute } from 'cerebral/test'; @@ -11,10 +13,10 @@ const contactsHelper = withAppContextDecorator( ); const petitionerUser = { - role: User.ROLES.petitioner, + role: ROLES.petitioner, }; const practitionerUser = { - role: User.ROLES.privatePractitioner, + role: ROLES.privatePractitioner, }; describe('contactsHelper', () => { @@ -22,7 +24,7 @@ describe('contactsHelper', () => { applicationContext.getCurrentUser = () => petitionerUser; const result = runCompute(contactsHelper, { state: { - form: { partyType: ContactFactory.PARTY_TYPES.conservator }, + form: { partyType: PARTY_TYPES.conservator }, }, }); expect(result).toMatchObject({ @@ -39,7 +41,7 @@ describe('contactsHelper', () => { applicationContext.getCurrentUser = () => petitionerUser; const result = runCompute(contactsHelper, { state: { - form: { partyType: ContactFactory.PARTY_TYPES.corporation }, + form: { partyType: PARTY_TYPES.corporation }, }, }); expect(result).toMatchObject({ @@ -55,7 +57,7 @@ describe('contactsHelper', () => { applicationContext.getCurrentUser = () => petitionerUser; const result = runCompute(contactsHelper, { state: { - form: { partyType: ContactFactory.PARTY_TYPES.custodian }, + form: { partyType: PARTY_TYPES.custodian }, }, }); expect(result).toMatchObject({ @@ -72,7 +74,7 @@ describe('contactsHelper', () => { applicationContext.getCurrentUser = () => petitionerUser; const result = runCompute(contactsHelper, { state: { - form: { partyType: ContactFactory.PARTY_TYPES.donor }, + form: { partyType: PARTY_TYPES.donor }, }, }); expect(result).toMatchObject({ @@ -88,7 +90,7 @@ describe('contactsHelper', () => { const result = runCompute(contactsHelper, { state: { form: { - partyType: ContactFactory.PARTY_TYPES.estate, + partyType: PARTY_TYPES.estate, }, }, }); @@ -109,7 +111,7 @@ describe('contactsHelper', () => { const result = runCompute(contactsHelper, { state: { form: { - partyType: ContactFactory.PARTY_TYPES.estateWithoutExecutor, + partyType: PARTY_TYPES.estateWithoutExecutor, }, }, }); @@ -127,7 +129,7 @@ describe('contactsHelper', () => { const result = runCompute(contactsHelper, { state: { form: { - partyType: ContactFactory.PARTY_TYPES.guardian, + partyType: PARTY_TYPES.guardian, }, }, }); @@ -146,7 +148,7 @@ describe('contactsHelper', () => { const result = runCompute(contactsHelper, { state: { form: { - partyType: ContactFactory.PARTY_TYPES.nextFriendForIncompetentPerson, + partyType: PARTY_TYPES.nextFriendForIncompetentPerson, }, }, }); @@ -166,7 +168,7 @@ describe('contactsHelper', () => { const result = runCompute(contactsHelper, { state: { form: { - partyType: ContactFactory.PARTY_TYPES.nextFriendForMinor, + partyType: PARTY_TYPES.nextFriendForMinor, }, }, }); @@ -185,7 +187,7 @@ describe('contactsHelper', () => { const result = runCompute(contactsHelper, { state: { form: { - partyType: ContactFactory.PARTY_TYPES.partnershipBBA, + partyType: PARTY_TYPES.partnershipBBA, }, }, }); @@ -204,7 +206,7 @@ describe('contactsHelper', () => { const result = runCompute(contactsHelper, { state: { form: { - partyType: ContactFactory.PARTY_TYPES.partnershipOtherThanTaxMatters, + partyType: PARTY_TYPES.partnershipOtherThanTaxMatters, }, }, }); @@ -224,7 +226,7 @@ describe('contactsHelper', () => { const result = runCompute(contactsHelper, { state: { form: { - partyType: ContactFactory.PARTY_TYPES.partnershipAsTaxMattersPartner, + partyType: PARTY_TYPES.partnershipAsTaxMattersPartner, }, }, }); @@ -243,7 +245,7 @@ describe('contactsHelper', () => { const result = runCompute(contactsHelper, { state: { form: { - partyType: ContactFactory.PARTY_TYPES.petitioner, + partyType: PARTY_TYPES.petitioner, }, }, }); @@ -260,7 +262,7 @@ describe('contactsHelper', () => { const result = runCompute(contactsHelper, { state: { form: { - partyType: ContactFactory.PARTY_TYPES.petitionerSpouse, + partyType: PARTY_TYPES.petitionerSpouse, }, }, }); @@ -283,7 +285,7 @@ describe('contactsHelper', () => { const result = runCompute(contactsHelper, { state: { form: { - partyType: ContactFactory.PARTY_TYPES.petitionerDeceasedSpouse, + partyType: PARTY_TYPES.petitionerDeceasedSpouse, }, }, }); @@ -304,7 +306,7 @@ describe('contactsHelper', () => { const result = runCompute(contactsHelper, { state: { form: { - partyType: ContactFactory.PARTY_TYPES.survivingSpouse, + partyType: PARTY_TYPES.survivingSpouse, }, }, }); @@ -323,7 +325,7 @@ describe('contactsHelper', () => { const result = runCompute(contactsHelper, { state: { form: { - partyType: ContactFactory.PARTY_TYPES.transferee, + partyType: PARTY_TYPES.transferee, }, }, }); @@ -340,7 +342,7 @@ describe('contactsHelper', () => { const result = runCompute(contactsHelper, { state: { form: { - partyType: ContactFactory.PARTY_TYPES.trust, + partyType: PARTY_TYPES.trust, }, }, }); @@ -358,7 +360,7 @@ describe('contactsHelper', () => { applicationContext.getCurrentUser = () => practitionerUser; const result = runCompute(contactsHelper, { state: { - form: { partyType: ContactFactory.PARTY_TYPES.conservator }, + form: { partyType: PARTY_TYPES.conservator }, }, }); expect(result).toMatchObject({ @@ -375,7 +377,7 @@ describe('contactsHelper', () => { applicationContext.getCurrentUser = () => practitionerUser; const result = runCompute(contactsHelper, { state: { - form: { partyType: ContactFactory.PARTY_TYPES.corporation }, + form: { partyType: PARTY_TYPES.corporation }, }, }); expect(result).toMatchObject({ @@ -391,7 +393,7 @@ describe('contactsHelper', () => { applicationContext.getCurrentUser = () => practitionerUser; const result = runCompute(contactsHelper, { state: { - form: { partyType: ContactFactory.PARTY_TYPES.custodian }, + form: { partyType: PARTY_TYPES.custodian }, }, }); expect(result).toMatchObject({ @@ -408,7 +410,7 @@ describe('contactsHelper', () => { applicationContext.getCurrentUser = () => practitionerUser; const result = runCompute(contactsHelper, { state: { - form: { partyType: ContactFactory.PARTY_TYPES.donor }, + form: { partyType: PARTY_TYPES.donor }, }, }); expect(result).toMatchObject({ @@ -424,7 +426,7 @@ describe('contactsHelper', () => { const result = runCompute(contactsHelper, { state: { form: { - partyType: ContactFactory.PARTY_TYPES.estate, + partyType: PARTY_TYPES.estate, }, }, }); @@ -445,7 +447,7 @@ describe('contactsHelper', () => { const result = runCompute(contactsHelper, { state: { form: { - partyType: ContactFactory.PARTY_TYPES.estateWithoutExecutor, + partyType: PARTY_TYPES.estateWithoutExecutor, }, }, }); @@ -463,7 +465,7 @@ describe('contactsHelper', () => { const result = runCompute(contactsHelper, { state: { form: { - partyType: ContactFactory.PARTY_TYPES.guardian, + partyType: PARTY_TYPES.guardian, }, }, }); @@ -482,7 +484,7 @@ describe('contactsHelper', () => { const result = runCompute(contactsHelper, { state: { form: { - partyType: ContactFactory.PARTY_TYPES.nextFriendForIncompetentPerson, + partyType: PARTY_TYPES.nextFriendForIncompetentPerson, }, }, }); @@ -502,7 +504,7 @@ describe('contactsHelper', () => { const result = runCompute(contactsHelper, { state: { form: { - partyType: ContactFactory.PARTY_TYPES.nextFriendForMinor, + partyType: PARTY_TYPES.nextFriendForMinor, }, }, }); @@ -521,7 +523,7 @@ describe('contactsHelper', () => { const result = runCompute(contactsHelper, { state: { form: { - partyType: ContactFactory.PARTY_TYPES.partnershipBBA, + partyType: PARTY_TYPES.partnershipBBA, }, }, }); @@ -540,7 +542,7 @@ describe('contactsHelper', () => { const result = runCompute(contactsHelper, { state: { form: { - partyType: ContactFactory.PARTY_TYPES.partnershipOtherThanTaxMatters, + partyType: PARTY_TYPES.partnershipOtherThanTaxMatters, }, }, }); @@ -559,7 +561,7 @@ describe('contactsHelper', () => { const result = runCompute(contactsHelper, { state: { form: { - partyType: ContactFactory.PARTY_TYPES.partnershipAsTaxMattersPartner, + partyType: PARTY_TYPES.partnershipAsTaxMattersPartner, }, }, }); @@ -578,7 +580,7 @@ describe('contactsHelper', () => { const result = runCompute(contactsHelper, { state: { form: { - partyType: ContactFactory.PARTY_TYPES.petitioner, + partyType: PARTY_TYPES.petitioner, }, }, }); @@ -595,7 +597,7 @@ describe('contactsHelper', () => { const result = runCompute(contactsHelper, { state: { form: { - partyType: ContactFactory.PARTY_TYPES.petitionerSpouse, + partyType: PARTY_TYPES.petitionerSpouse, }, }, }); @@ -618,7 +620,7 @@ describe('contactsHelper', () => { const result = runCompute(contactsHelper, { state: { form: { - partyType: ContactFactory.PARTY_TYPES.petitionerDeceasedSpouse, + partyType: PARTY_TYPES.petitionerDeceasedSpouse, }, }, }); @@ -639,7 +641,7 @@ describe('contactsHelper', () => { const result = runCompute(contactsHelper, { state: { form: { - partyType: ContactFactory.PARTY_TYPES.survivingSpouse, + partyType: PARTY_TYPES.survivingSpouse, }, }, }); @@ -658,7 +660,7 @@ describe('contactsHelper', () => { const result = runCompute(contactsHelper, { state: { form: { - partyType: ContactFactory.PARTY_TYPES.transferee, + partyType: PARTY_TYPES.transferee, }, }, }); @@ -675,7 +677,7 @@ describe('contactsHelper', () => { const result = runCompute(contactsHelper, { state: { form: { - partyType: ContactFactory.PARTY_TYPES.trust, + partyType: PARTY_TYPES.trust, }, }, }); diff --git a/web-client/src/presenter/computeds/createCaseMessageModalHelper.js b/web-client/src/presenter/computeds/createCaseMessageModalHelper.js new file mode 100644 index 00000000000..f4c70841b92 --- /dev/null +++ b/web-client/src/presenter/computeds/createCaseMessageModalHelper.js @@ -0,0 +1,34 @@ +import { state } from 'cerebral'; + +export const createCaseMessageModalHelper = (get, applicationContext) => { + const caseDetail = get(state.caseDetail); + const { + docketRecordWithDocument, + draftDocuments, + } = applicationContext + .getUtilities() + .getFormattedCaseDetail({ applicationContext, caseDetail }); + + const form = get(state.modal.form); + const screenMetadata = get(state.screenMetadata); + const documentAttachmentLimit = 5; // TODO: Do something better with this + + const currentAttachmentCount = (form.attachments || []).length; + const canAddDocument = currentAttachmentCount < documentAttachmentLimit; + const shouldShowAddDocumentForm = + currentAttachmentCount === 0 || screenMetadata.showAddDocumentForm; + + const documents = []; + docketRecordWithDocument.forEach(entry => { + if (entry.document) { + documents.push(entry.document); + } + }); + + return { + documents, + draftDocuments, + showAddDocumentForm: canAddDocument && shouldShowAddDocumentForm, + showAddMoreDocumentsButton: canAddDocument && !shouldShowAddDocumentForm, + }; +}; diff --git a/web-client/src/presenter/computeds/createCaseMessageModalHelper.test.js b/web-client/src/presenter/computeds/createCaseMessageModalHelper.test.js new file mode 100644 index 00000000000..9f4a6c4cf96 --- /dev/null +++ b/web-client/src/presenter/computeds/createCaseMessageModalHelper.test.js @@ -0,0 +1,176 @@ +import { MOCK_CASE } from '../../../../shared/src/test/mockCase'; +import { applicationContext } from '../../applicationContext'; +import { createCaseMessageModalHelper as createCaseMessageModalHelperComputed } from './createCaseMessageModalHelper'; +import { runCompute } from 'cerebral/test'; +import { withAppContextDecorator } from '../../withAppContext'; + +const createCaseMessageModalHelper = withAppContextDecorator( + createCaseMessageModalHelperComputed, + applicationContext, +); + +describe('createCaseMessageModalHelper', () => { + let caseDetail; + + beforeAll(() => { + applicationContext.getCurrentUser = () => ({ + userId: MOCK_CASE.userId, + }); + + caseDetail = { + ...MOCK_CASE, + docketRecord: [ + { documentId: '123', index: 1 }, + { documentId: '234', index: 2 }, + { index: 3 }, // note: no document + ], + documents: [ + { documentId: '123', documentType: 'Petition' }, + { documentId: '234', documentTitle: 'Some Document' }, + { documentId: '345', documentType: 'Order' }, + ], + }; + }); + + it('returns documents on the docket record', () => { + const result = runCompute(createCaseMessageModalHelper, { + state: { + caseDetail, + modal: { + form: {}, + }, + screenMetadata: { + showAddDocumentForm: true, + }, + }, + }); + + expect(result.documents).toMatchObject([ + { documentId: '123' }, + { documentId: '234' }, + ]); + expect(result.documents.length).toEqual(2); + }); + + it('returns draftDocuments from formattedCaseDetail', () => { + const result = runCompute(createCaseMessageModalHelper, { + state: { + caseDetail, + modal: { + form: {}, + }, + screenMetadata: { + showAddDocumentForm: true, + }, + }, + }); + + expect(result.draftDocuments).toMatchObject([{ documentId: '345' }]); + }); + + it('returns showAddDocumentForm true when the current attachment count is zero', () => { + const result = runCompute(createCaseMessageModalHelper, { + state: { + caseDetail, + modal: { + form: {}, + }, + screenMetadata: { + showAddDocumentForm: true, + }, + }, + }); + + expect(result.showAddDocumentForm).toEqual(true); + }); + + it('returns showAddDocumentForm true when screenMetadata.showAddDocumentForm is true and the maximum number of attachments has not been met', () => { + const result = runCompute(createCaseMessageModalHelper, { + state: { + caseDetail, + modal: { + form: { + attachments: [{}, {}, {}, {}], // 4/5 documents attached + }, + }, + screenMetadata: { + showAddDocumentForm: true, + }, + }, + }); + + expect(result.showAddDocumentForm).toEqual(true); + }); + + it('returns showAddDocumentForm false when screenMetadata.showAddDocumentForm is false and the maximum number of attachments has not been met', () => { + const result = runCompute(createCaseMessageModalHelper, { + state: { + caseDetail, + modal: { + form: { + attachments: [{}, {}, {}, {}], // 4/5 documents attached + }, + }, + screenMetadata: { + showAddDocumentForm: false, + }, + }, + }); + + expect(result.showAddDocumentForm).toEqual(false); + }); + + it('returns showAddDocumentForm false when maximum number of attachments have been reached', () => { + const result = runCompute(createCaseMessageModalHelper, { + state: { + caseDetail, + modal: { + form: { + attachments: [{}, {}, {}, {}, {}], // 5/5 documents attached + }, + }, + screenMetadata: { + showAddDocumentForm: true, + }, + }, + }); + + expect(result.showAddDocumentForm).toEqual(false); + }); + + it('returns showAddMoreDocumentsButton true when showAddDocumentForm is false and the current attachment count is greater than zero but less than the maximum', () => { + const result = runCompute(createCaseMessageModalHelper, { + state: { + caseDetail, + modal: { + form: { + attachments: [{}, {}, {}, {}], // 4/5 documents attached + }, + }, + screenMetadata: { + showAddDocumentForm: false, + }, + }, + }); + + expect(result.showAddMoreDocumentsButton).toEqual(true); + }); + + it('returns showAddMoreDocumentsButton false when maximum number of attachments have been reached', () => { + const result = runCompute(createCaseMessageModalHelper, { + state: { + caseDetail, + modal: { + form: { + attachments: [{}, {}, {}, {}, {}], // 5/5 documents attached + }, + }, + screenMetadata: { + showAddDocumentForm: false, + }, + }, + }); + + expect(result.showAddMoreDocumentsButton).toEqual(false); + }); +}); diff --git a/web-client/src/presenter/computeds/dashboardExternalHelper.js b/web-client/src/presenter/computeds/dashboardExternalHelper.js index 27fcfc426ac..e0091b44235 100644 --- a/web-client/src/presenter/computeds/dashboardExternalHelper.js +++ b/web-client/src/presenter/computeds/dashboardExternalHelper.js @@ -1,7 +1,9 @@ import { state } from 'cerebral'; export const dashboardExternalHelper = (get, applicationContext) => { - const cases = get(state.cases); + const openCases = get(state.openCases) || []; + const closedCases = get(state.closedCases) || []; + const cases = [...openCases, ...closedCases]; const user = applicationContext.getCurrentUser() || {}; return { diff --git a/web-client/src/presenter/computeds/dashboardExternalHelper.test.js b/web-client/src/presenter/computeds/dashboardExternalHelper.test.js index 8a2456d9565..77b59d1fc17 100644 --- a/web-client/src/presenter/computeds/dashboardExternalHelper.test.js +++ b/web-client/src/presenter/computeds/dashboardExternalHelper.test.js @@ -1,4 +1,4 @@ -import { User } from '../../../../shared/src/business/entities/User'; +import { ROLES } from '../../../../shared/src/business/entities/EntityConstants'; import { applicationContext } from '../../applicationContext'; import { dashboardExternalHelper as dashboardExternalHelperComputed } from './dashboardExternalHelper'; import { runCompute } from 'cerebral/test'; @@ -10,26 +10,28 @@ const dashboardExternalHelper = withAppContextDecorator( ); describe('petitioner dashboard helper', () => { - it('shows "what to expect" but not case list when there are no cases', () => { + it('shows "what to expect" but not case list when there are no open or closed cases', () => { applicationContext.getCurrentUser = () => ({ - role: User.ROLES.petitioner, + role: ROLES.petitioner, }); const result = runCompute(dashboardExternalHelper, { state: { - cases: [], + closedCases: [], + openCases: [], }, }); expect(result.showCaseList).toEqual(false); expect(result.showWhatToExpect).toEqual(true); expect(result.showCaseSearch).toEqual(false); }); - it('shows case list but not "what to expect" when there is a case', () => { + it('shows case list but not "what to expect" when there is an open or closed case case', () => { applicationContext.getCurrentUser = () => ({ - role: User.ROLES.petitioner, + role: ROLES.petitioner, }); const result = runCompute(dashboardExternalHelper, { state: { - cases: [{ something: true }], + closedCases: [{ something: true }], + openCases: [{ something: true }], }, }); expect(result.showCaseList).toEqual(true); @@ -38,11 +40,12 @@ describe('petitioner dashboard helper', () => { }); it('shows case search if defined user has privatePractitioner role', () => { applicationContext.getCurrentUser = () => ({ - role: User.ROLES.privatePractitioner, + role: ROLES.privatePractitioner, }); const result = runCompute(dashboardExternalHelper, { state: { - cases: [{ something: true }], + closedCases: [{ something: true }], + openCases: [{ something: true }], }, }); expect(result.showCaseList).toEqual(true); @@ -52,11 +55,12 @@ describe('petitioner dashboard helper', () => { it('shows case search if defined user has irsPractitioner role', () => { applicationContext.getCurrentUser = () => ({ - role: User.ROLES.irsPractitioner, + role: ROLES.irsPractitioner, }); const result = runCompute(dashboardExternalHelper, { state: { - cases: [{ something: true }], + closedCases: [{ something: true }], + openCases: [{ something: true }], }, }); expect(result.showCaseList).toEqual(true); @@ -66,11 +70,12 @@ describe('petitioner dashboard helper', () => { it('hides case search if defined user does not have privatePractitioner or irsPractitioner role', () => { applicationContext.getCurrentUser = () => ({ - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, }); const result = runCompute(dashboardExternalHelper, { state: { - cases: [{ something: true }], + closedCases: [{ something: true }], + openCases: [{ something: true }], }, }); expect(result.showCaseList).toEqual(true); diff --git a/web-client/src/presenter/computeds/documentDetailHelper.test.js b/web-client/src/presenter/computeds/documentDetailHelper.test.js index 9a1fddb5e71..548426cdca2 100644 --- a/web-client/src/presenter/computeds/documentDetailHelper.test.js +++ b/web-client/src/presenter/computeds/documentDetailHelper.test.js @@ -1,6 +1,8 @@ -import { Case } from '../../../../shared/src/business/entities/cases/Case'; +import { + CASE_STATUS_TYPES, + ROLES, +} from '../../../../shared/src/business/entities/EntityConstants'; import { Correspondence } from '../../../../shared/src/business/entities/Correspondence'; -import { User } from '../../../../shared/src/business/entities/User'; import { applicationContextForClient as applicationContext } from '../../../../shared/src/business/test/createTestApplicationContext'; import { documentDetailHelper as documentDetailHelperComputed, @@ -27,7 +29,7 @@ const documentDetailHelper = withAppContextDecorator( const getBaseState = user => { globalUser = user; return { - constants: { STATUS_TYPES: Case.STATUS_TYPES, USER_ROLES: User.ROLES }, + constants: { STATUS_TYPES: CASE_STATUS_TYPES, USER_ROLES: ROLES }, permissions: getUserPermissions(user), }; }; @@ -36,13 +38,13 @@ describe('document detail helper', () => { describe('formatDocumentWorkItems', () => { it('should return filtered and formatted completedWorkItems, incompleteWorkItems, and qcWorkItem', () => { const user = { - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: '123', }; const workItems = [ { assigneeId: user.userId, - caseStatus: Case.STATUS_TYPES.new, + caseStatus: CASE_STATUS_TYPES.new, completedAt: '2018-12-21T20:49:28.192Z', createdAt: '2018-11-21T20:49:28.192Z', document: { @@ -60,7 +62,7 @@ describe('document detail helper', () => { }, { assigneeId: user.userId, - caseStatus: Case.STATUS_TYPES.new, + caseStatus: CASE_STATUS_TYPES.new, createdAt: '2018-11-22T20:49:28.192Z', document: { documentId: 'abc', @@ -77,7 +79,7 @@ describe('document detail helper', () => { }, { assigneeId: user.userId, - caseStatus: Case.STATUS_TYPES.new, + caseStatus: CASE_STATUS_TYPES.new, createdAt: '2018-11-23T20:49:28.192Z', document: { documentId: 'abc', @@ -117,7 +119,7 @@ describe('document detail helper', () => { it('showAction function should return true for complete for document Id abc', () => { const user = { - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: '123', }; const result = runCompute(documentDetailHelper, { @@ -126,7 +128,7 @@ describe('document detail helper', () => { caseDetail: { docketRecord: [], documents: [{ documentId: 'abc' }], - status: Case.STATUS_TYPES.generalDocket, + status: CASE_STATUS_TYPES.generalDocket, }, documentId: 'abc', workItemActions: { @@ -139,7 +141,7 @@ describe('document detail helper', () => { it('should set showSignDocumentButton to true when user has COURT_ISSUED_DOCUMENT permission and there is a valid document to sign that is not already signed', () => { const user = { - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: '123', }; const result = runCompute(documentDetailHelper, { @@ -154,7 +156,7 @@ describe('document detail helper', () => { workItems: [ { assigneeId: user.userId, - caseStatus: Case.STATUS_TYPES.new, + caseStatus: CASE_STATUS_TYPES.new, document: { documentId: 'abc', documentType: 'Proposed Stipulated Decision', @@ -170,7 +172,7 @@ describe('document detail helper', () => { ], }, ], - status: Case.STATUS_TYPES.new, + status: CASE_STATUS_TYPES.new, }, documentId: 'abc', permissions: { @@ -184,7 +186,7 @@ describe('document detail helper', () => { describe('createdFiledLabel', () => { it('should set createFiledLabel to `Created` for a court-issued document', async () => { const user = { - role: User.ROLES.docketClerk, + role: ROLES.docketClerk, userId: '123', }; @@ -199,7 +201,7 @@ describe('document detail helper', () => { documentType: 'Order of Dismissal', }, ], - status: Case.STATUS_TYPES.new, + status: CASE_STATUS_TYPES.new, }, documentId: 'abc', workItemActions: { @@ -212,7 +214,7 @@ describe('document detail helper', () => { it('should set createFiledLabel to `Filed` for a non court-issued document', async () => { const user = { - role: User.ROLES.docketClerk, + role: ROLES.docketClerk, userId: '123', }; @@ -227,7 +229,7 @@ describe('document detail helper', () => { documentType: 'Petition', }, ], - status: Case.STATUS_TYPES.new, + status: CASE_STATUS_TYPES.new, }, documentId: 'abc', workItemActions: { @@ -242,7 +244,7 @@ describe('document detail helper', () => { describe('showCreatedFiled', () => { it('should set showCreatedFiled to true if the document is not an order or court-issued document', async () => { const user = { - role: User.ROLES.docketClerk, + role: ROLES.docketClerk, userId: '123', }; @@ -257,7 +259,7 @@ describe('document detail helper', () => { documentType: 'Answer', }, ], - status: Case.STATUS_TYPES.new, + status: CASE_STATUS_TYPES.new, }, documentId: 'abc', workItemActions: { @@ -270,7 +272,7 @@ describe('document detail helper', () => { it('should set showCreatedFiled to true if the document is an order and is in draft state (not on the docket record)', async () => { const user = { - role: User.ROLES.docketClerk, + role: ROLES.docketClerk, userId: '123', }; @@ -285,7 +287,7 @@ describe('document detail helper', () => { documentType: 'Order', }, ], - status: Case.STATUS_TYPES.new, + status: CASE_STATUS_TYPES.new, }, documentId: 'abc', workItemActions: { @@ -298,7 +300,7 @@ describe('document detail helper', () => { it('should set showCreatedFiled to false if the document is an order and is in not draft state (on the docket record)', async () => { const user = { - role: User.ROLES.docketClerk, + role: ROLES.docketClerk, userId: '123', }; @@ -313,7 +315,7 @@ describe('document detail helper', () => { documentType: 'Order', }, ], - status: Case.STATUS_TYPES.new, + status: CASE_STATUS_TYPES.new, }, documentId: 'abc', workItemActions: { @@ -328,7 +330,7 @@ describe('document detail helper', () => { describe('showAddCourtIssuedDocketEntryButton', () => { it('should set showAddCourtIssuedDocketEntryButton true when the user has the DOCKET_ENTRY permission and the document is an unsigned stipulated decision', async () => { const user = { - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: '123', }; @@ -343,7 +345,7 @@ describe('document detail helper', () => { documentType: 'Stipulated Decision', }, ], - status: Case.STATUS_TYPES.new, + status: CASE_STATUS_TYPES.new, }, documentId: 'abc', permissions: { DOCKET_ENTRY: true }, @@ -357,7 +359,7 @@ describe('document detail helper', () => { it('should set showAddCourtIssuedDocketEntryButton true when the user has the DOCKET_ENTRY permission and the document is a signed stipulated decision', async () => { const user = { - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: '123', }; @@ -373,7 +375,7 @@ describe('document detail helper', () => { signedAt: getDateISO(), }, ], - status: Case.STATUS_TYPES.new, + status: CASE_STATUS_TYPES.new, }, documentId: 'abc', permissions: { DOCKET_ENTRY: true }, @@ -387,7 +389,7 @@ describe('document detail helper', () => { it('should set showAddCourtIssuedDocketEntryButton true when the user has the DOCKET_ENTRY permission and the document is an unsigned order', async () => { const user = { - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: '123', }; @@ -402,7 +404,7 @@ describe('document detail helper', () => { documentType: 'Order of Dismissal', }, ], - status: Case.STATUS_TYPES.new, + status: CASE_STATUS_TYPES.new, }, documentId: 'abc', permissions: { DOCKET_ENTRY: true }, @@ -416,7 +418,7 @@ describe('document detail helper', () => { it('should set showAddCourtIssuedDocketEntryButton false when the user has the DOCKET_ENTRY permission and the document is a served order', async () => { const user = { - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: '123', }; @@ -432,7 +434,7 @@ describe('document detail helper', () => { servedAt: getDateISO(), }, ], - status: Case.STATUS_TYPES.new, + status: CASE_STATUS_TYPES.new, }, documentId: 'abc', permissions: { DOCKET_ENTRY: true }, @@ -446,7 +448,7 @@ describe('document detail helper', () => { it('should set showAddCourtIssuedDocketEntryButton false when the user does not have the DOCKET_ENTRY permission', async () => { const user = { - role: User.ROLES.petitioner, + role: ROLES.petitioner, userId: '123', }; @@ -461,7 +463,7 @@ describe('document detail helper', () => { documentType: 'Stipulated Decision', }, ], - status: Case.STATUS_TYPES.new, + status: CASE_STATUS_TYPES.new, }, documentId: 'abc', permissions: { DOCKET_ENTRY: false }, @@ -475,7 +477,7 @@ describe('document detail helper', () => { it('should set showAddCourtIssuedDocketEntryButton false when the document type is not an order or stipulated decision', async () => { const user = { - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: '123', }; @@ -490,7 +492,7 @@ describe('document detail helper', () => { documentType: 'Petition', }, ], - status: Case.STATUS_TYPES.new, + status: CASE_STATUS_TYPES.new, }, documentId: 'abc', permissions: { DOCKET_ENTRY: true }, @@ -506,7 +508,7 @@ describe('document detail helper', () => { describe('showEditDocketEntry and showEditCourtIssuedDocketEntry', () => { it('should set showEditDocketEntry false and showEditCourtIssuedDocketEntry true when the document is a signed stipulated decision with a docket entry and the user has the DOCKET_ENTRY permission', async () => { const user = { - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: '123', }; @@ -526,7 +528,7 @@ describe('document detail helper', () => { signedAt: getDateISO(), }, ], - status: Case.STATUS_TYPES.new, + status: CASE_STATUS_TYPES.new, }, documentId: 'abc', permissions: { DOCKET_ENTRY: true }, @@ -541,7 +543,7 @@ describe('document detail helper', () => { it('should set showEditDocketEntry false when the document is an unsigned stipulated decision and the user has the DOCKET_ENTRY permission', async () => { const user = { - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: '123', }; @@ -556,7 +558,7 @@ describe('document detail helper', () => { documentType: 'Stipulated Decision', }, ], - status: Case.STATUS_TYPES.new, + status: CASE_STATUS_TYPES.new, }, documentId: 'abc', permissions: { DOCKET_ENTRY: true }, @@ -570,7 +572,7 @@ describe('document detail helper', () => { it('should set showEditDocketEntry true when the non QCed document is a served order and the user has the DOCKET_ENTRY permission', async () => { const user = { - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: '123', }; @@ -586,7 +588,7 @@ describe('document detail helper', () => { servedAt: getDateISO(), workItems: [ { - caseStatus: Case.STATUS_TYPES.new, + caseStatus: CASE_STATUS_TYPES.new, document: { receivedAt: '2018-11-21T20:49:28.192Z', }, @@ -605,7 +607,7 @@ describe('document detail helper', () => { ], }, ], - status: Case.STATUS_TYPES.new, + status: CASE_STATUS_TYPES.new, }, documentId: 'abc', permissions: { DOCKET_ENTRY: true }, @@ -619,7 +621,7 @@ describe('document detail helper', () => { it('should set showEditDocketEntry false on a QCed document even when it is a served order and the user has the DOCKET_ENTRY permission', async () => { const user = { - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: '123', }; @@ -635,7 +637,7 @@ describe('document detail helper', () => { servedAt: getDateISO(), workItems: [ { - caseStatus: Case.STATUS_TYPES.new, + caseStatus: CASE_STATUS_TYPES.new, completedAt: '2018-11-21T20:49:28.192Z', document: { receivedAt: '2018-11-21T20:49:28.192Z', @@ -655,7 +657,7 @@ describe('document detail helper', () => { ], }, ], - status: Case.STATUS_TYPES.new, + status: CASE_STATUS_TYPES.new, }, documentId: 'abc', permissions: { DOCKET_ENTRY: true }, @@ -669,7 +671,7 @@ describe('document detail helper', () => { it('should set showEditDocketEntry false when the document is an unserved order and the user has the DOCKET_ENTRY permission', async () => { const user = { - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: '123', }; @@ -684,7 +686,7 @@ describe('document detail helper', () => { documentType: 'Order of Dismissal', }, ], - status: Case.STATUS_TYPES.new, + status: CASE_STATUS_TYPES.new, }, documentId: 'abc', permissions: { DOCKET_ENTRY: true }, @@ -698,7 +700,7 @@ describe('document detail helper', () => { it('should set showEditDocketEntry false when the document is petition and the user has the DOCKET_ENTRY permission', async () => { const user = { - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: '123', }; @@ -713,7 +715,7 @@ describe('document detail helper', () => { documentType: 'Petition', }, ], - status: Case.STATUS_TYPES.new, + status: CASE_STATUS_TYPES.new, }, documentId: 'abc', permissions: { DOCKET_ENTRY: true }, @@ -729,7 +731,7 @@ describe('document detail helper', () => { describe('formattedDocument', () => { it('should search for the specified document in the case correspondence list', () => { const user = { - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: '123', }; const mockCorrespondence = new Correspondence({ @@ -753,7 +755,7 @@ describe('document detail helper', () => { userId: 'petitioner', workItems: [ { - caseStatus: Case.STATUS_TYPES.new, + caseStatus: CASE_STATUS_TYPES.new, completedAt: '2018-11-21T20:49:28.192Z', completedBy: 'William T. Riker', document: { @@ -773,7 +775,7 @@ describe('document detail helper', () => { }, { assigneeId: 'abc', - caseStatus: Case.STATUS_TYPES.new, + caseStatus: CASE_STATUS_TYPES.new, document: { documentType: 'Proposed Stipulated Decision', receivedAt: '2018-11-21T20:49:28.192Z', @@ -806,7 +808,7 @@ describe('document detail helper', () => { it('should search for the specified document in the case documents list', () => { const user = { - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: '123', }; const mockCorrespondence = new Correspondence({ @@ -823,7 +825,7 @@ describe('document detail helper', () => { userId: 'petitioner', workItems: [ { - caseStatus: Case.STATUS_TYPES.new, + caseStatus: CASE_STATUS_TYPES.new, completedAt: '2018-11-21T20:49:28.192Z', completedBy: 'William T. Riker', document: { @@ -843,7 +845,7 @@ describe('document detail helper', () => { }, { assigneeId: 'abc', - caseStatus: Case.STATUS_TYPES.new, + caseStatus: CASE_STATUS_TYPES.new, document: { documentType: 'Proposed Stipulated Decision', receivedAt: '2018-11-21T20:49:28.192Z', @@ -883,7 +885,7 @@ describe('document detail helper', () => { it('should indicate QC completed by workItem "completedBy" if not indicated on Document', () => { const user = { - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: '123', }; const result = runCompute(documentDetailHelper, { @@ -901,7 +903,7 @@ describe('document detail helper', () => { userId: 'petitioner', workItems: [ { - caseStatus: Case.STATUS_TYPES.new, + caseStatus: CASE_STATUS_TYPES.new, completedAt: '2018-11-21T20:49:28.192Z', completedBy: 'William T. Riker', document: { @@ -921,7 +923,7 @@ describe('document detail helper', () => { }, { assigneeId: 'abc', - caseStatus: Case.STATUS_TYPES.new, + caseStatus: CASE_STATUS_TYPES.new, document: { documentType: 'Proposed Stipulated Decision', receivedAt: '2018-11-21T20:49:28.192Z', @@ -955,7 +957,7 @@ describe('document detail helper', () => { it('should indicate QC completed by "qcByUser" on Document if present', () => { const user = { - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: '123', }; const result = runCompute(documentDetailHelper, { @@ -978,7 +980,7 @@ describe('document detail helper', () => { userId: 'petitioner', workItems: [ { - caseStatus: Case.STATUS_TYPES.new, + caseStatus: CASE_STATUS_TYPES.new, completedAt: '2018-11-21T20:49:28.192Z', completedBy: 'William T. Riker', document: { @@ -998,7 +1000,7 @@ describe('document detail helper', () => { }, { assigneeId: 'abc', - caseStatus: Case.STATUS_TYPES.new, + caseStatus: CASE_STATUS_TYPES.new, document: { documentType: 'Proposed Stipulated Decision', receivedAt: '2018-11-21T20:49:28.192Z', @@ -1032,7 +1034,7 @@ describe('document detail helper', () => { it('should filter out completed work items with Served on IRS messages', () => { const user = { - role: User.ROLES.adc, + role: ROLES.adc, userId: '123', }; const result = runCompute(documentDetailHelper, { @@ -1050,7 +1052,7 @@ describe('document detail helper', () => { userId: 'petitioner', workItems: [ { - caseStatus: Case.STATUS_TYPES.new, + caseStatus: CASE_STATUS_TYPES.new, completedAt: '2018-11-21T20:49:28.192Z', document: { receivedAt: '2018-11-21T20:49:28.192Z', @@ -1069,7 +1071,7 @@ describe('document detail helper', () => { }, { assigneeId: 'abc', - caseStatus: Case.STATUS_TYPES.new, + caseStatus: CASE_STATUS_TYPES.new, document: { documentType: 'Proposed Stipulated Decision', receivedAt: '2018-11-21T20:49:28.192Z', @@ -1100,7 +1102,7 @@ describe('document detail helper', () => { it("default to empty array when a document's workItems are non-existent", () => { const user = { - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: '123', }; const result = runCompute(documentDetailHelper, { @@ -1128,7 +1130,7 @@ describe('document detail helper', () => { describe('showConfirmEditOrder, showSignedAt, and showRemoveSignature', () => { it('should show confirm edit order, signed at, and remove signature for a signed order', () => { const user = { - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: '123', }; const result = runCompute(documentDetailHelper, { @@ -1146,7 +1148,7 @@ describe('document detail helper', () => { }, documentId: '123-abc', user: { - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, }, }, }); @@ -1158,7 +1160,7 @@ describe('document detail helper', () => { it('should show confirm edit order, signed at, but NOT remove signature for a signed notice', () => { const user = { - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: '123', }; const result = runCompute(documentDetailHelper, { @@ -1177,7 +1179,7 @@ describe('document detail helper', () => { }, documentId: '123-abc', user: { - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, }, }, }); @@ -1189,7 +1191,7 @@ describe('document detail helper', () => { it('should NOT show confirm edit order OR remove signature when the documentType is not an order', () => { const user = { - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: '123', }; const result = runCompute(documentDetailHelper, { @@ -1207,7 +1209,7 @@ describe('document detail helper', () => { }, documentId: '123-abc', user: { - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, }, }, }); @@ -1219,7 +1221,7 @@ describe('document detail helper', () => { it('should NOT show confirm edit order OR remove signature when the document has not been signed', () => { const user = { - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: '123', }; const result = runCompute(documentDetailHelper, { @@ -1237,7 +1239,7 @@ describe('document detail helper', () => { }, documentId: '123-abc', user: { - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, }, }, }); @@ -1251,7 +1253,7 @@ describe('document detail helper', () => { describe('showPrintCaseConfirmationButton', () => { it("should show the 'Print Confirmation' button if a document has been served and the document is a petition ", () => { const user = { - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: '123', }; const result = runCompute(documentDetailHelper, { @@ -1277,7 +1279,7 @@ describe('document detail helper', () => { it("should not show the 'Print Confirmation' button if a document has not been served", () => { const user = { - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: '123', }; const result = runCompute(documentDetailHelper, { @@ -1303,7 +1305,7 @@ describe('document detail helper', () => { it("should not show the 'Print Confirmation' button if the document is not a petition ", () => { const user = { - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: '123', }; const result = runCompute(documentDetailHelper, { @@ -1331,7 +1333,7 @@ describe('document detail helper', () => { describe('isDraftDocument', () => { it('should return isDraftDocument false if the document is served', () => { const user = { - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: '123', }; const result = runCompute(documentDetailHelper, { @@ -1357,7 +1359,7 @@ describe('document detail helper', () => { it('should return isDraftDocument true if the document is an unserved Stipulated Decision', () => { const user = { - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: '123', }; const result = runCompute(documentDetailHelper, { @@ -1382,7 +1384,7 @@ describe('document detail helper', () => { it('should return isDraftDocument true if the document is an order that is NOT on the docket record', () => { const user = { - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: '123', }; const result = runCompute(documentDetailHelper, { @@ -1407,7 +1409,7 @@ describe('document detail helper', () => { it('should return isDraftDocument false if the document is an order that is on the docket record', () => { const user = { - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: '123', }; const result = runCompute(documentDetailHelper, { @@ -1436,7 +1438,7 @@ describe('document detail helper', () => { it('should return isDraftDocument true if the document is a court-issued document that is NOT on the docket record', () => { const user = { - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: '123', }; const result = runCompute(documentDetailHelper, { @@ -1461,7 +1463,7 @@ describe('document detail helper', () => { it('should return isDraftDocument false if the document is a court-issued document that is on the docket record', () => { const user = { - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: '123', }; const result = runCompute(documentDetailHelper, { @@ -1486,7 +1488,7 @@ describe('document detail helper', () => { it('should return isDraftDocument false if the document is unserved but is not an internal document type', () => { const user = { - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: '123', }; const result = runCompute(documentDetailHelper, { @@ -1512,7 +1514,7 @@ describe('document detail helper', () => { describe('editUrl', () => { it('should go to the sign url when the document is a stip decision', () => { const user = { - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: '123', }; const result = runCompute(documentDetailHelper, { @@ -1540,7 +1542,7 @@ describe('document detail helper', () => { it('should go to the edit upload pdf url when the document is a Miscellaneous document', () => { const user = { - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: '123', }; const result = runCompute(documentDetailHelper, { @@ -1568,7 +1570,7 @@ describe('document detail helper', () => { it('should go to the edit order url when the document is a Order document', () => { const user = { - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: '123', }; const result = runCompute(documentDetailHelper, { diff --git a/web-client/src/presenter/computeds/editStatisticFormHelper.test.js b/web-client/src/presenter/computeds/editStatisticFormHelper.test.js index d36786b5435..8634c4688ef 100644 --- a/web-client/src/presenter/computeds/editStatisticFormHelper.test.js +++ b/web-client/src/presenter/computeds/editStatisticFormHelper.test.js @@ -1,4 +1,4 @@ -import { Case } from '../../../../shared/src/business/entities/cases/Case'; +import { CASE_TYPES_MAP } from '../../../../shared/src/business/entities/EntityConstants'; import { applicationContextForClient as applicationContext } from '../../../../shared/src/business/test/createTestApplicationContext'; import { editStatisticFormHelper as editStatisticFormHelperComputed } from './editStatisticFormHelper'; import { runCompute } from 'cerebral/test'; @@ -38,7 +38,7 @@ describe('editStatisticFormHelper', () => { const result = runCompute(editStatisticFormHelper, { state: { caseDetail: { - caseType: Case.CASE_TYPES_MAP.cdp, + caseType: CASE_TYPES_MAP.cdp, }, form: {}, }, @@ -50,7 +50,7 @@ describe('editStatisticFormHelper', () => { const result = runCompute(editStatisticFormHelper, { state: { caseDetail: { - caseType: Case.CASE_TYPES_MAP.deficiency, + caseType: CASE_TYPES_MAP.deficiency, hasVerifiedIrsNotice: false, }, form: {}, @@ -63,7 +63,7 @@ describe('editStatisticFormHelper', () => { const result = runCompute(editStatisticFormHelper, { state: { caseDetail: { - caseType: Case.CASE_TYPES_MAP.deficiency, + caseType: CASE_TYPES_MAP.deficiency, hasVerifiedIrsNotice: true, statistics: [{ irsTotalPenalties: 1 }, { irsTotalPenalties: 2 }], }, @@ -77,7 +77,7 @@ describe('editStatisticFormHelper', () => { const result = runCompute(editStatisticFormHelper, { state: { caseDetail: { - caseType: Case.CASE_TYPES_MAP.deficiency, + caseType: CASE_TYPES_MAP.deficiency, hasVerifiedIrsNotice: true, statistics: [{ irsTotalPenalties: 1 }], }, diff --git a/web-client/src/presenter/computeds/extractPendingMessagesFromCaseDetail.test.js b/web-client/src/presenter/computeds/extractPendingMessagesFromCaseDetail.test.js index c2395ade77e..02a7766d191 100644 --- a/web-client/src/presenter/computeds/extractPendingMessagesFromCaseDetail.test.js +++ b/web-client/src/presenter/computeds/extractPendingMessagesFromCaseDetail.test.js @@ -1,4 +1,4 @@ -import { User } from '../../../../shared/src/business/entities/User'; +import { ROLES } from '../../../../shared/src/business/entities/EntityConstants'; import { applicationContext } from '../../applicationContext'; import { extractedPendingMessagesFromCaseDetail as extractPendingMessagesFromCaseDetailComputed } from './extractPendingMessagesFromCaseDetail'; import { getUserPermissions } from '../../../../shared/src/authorization/getUserPermissions'; @@ -23,7 +23,7 @@ const getBaseState = user => { }; const petitionsClerkUser = { - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: '123', }; diff --git a/web-client/src/presenter/computeds/fileDocumentHelper.test.js b/web-client/src/presenter/computeds/fileDocumentHelper.test.js index cd2e9a53dad..9d20e8d9f1a 100644 --- a/web-client/src/presenter/computeds/fileDocumentHelper.test.js +++ b/web-client/src/presenter/computeds/fileDocumentHelper.test.js @@ -1,6 +1,6 @@ -import { ContactFactory } from '../../../../shared/src/business/entities/contacts/ContactFactory'; import { MOCK_CASE } from '../../../../shared/src/test/mockCase'; import { MOCK_USERS } from '../../../../shared/src/test/mockUsers'; +import { PARTY_TYPES } from '../../../../shared/src/business/entities/EntityConstants'; import { applicationContext } from '../../applicationContext'; import { fileDocumentHelper as fileDocumentHelperComputed } from './fileDocumentHelper'; import { runCompute } from 'cerebral/test'; @@ -149,7 +149,7 @@ describe('fileDocumentHelper', () => { }); it('shows secondary party for petitionerSpouse or petitionerDeceasedSpouse', () => { - state.caseDetail.partyType = ContactFactory.PARTY_TYPES.petitionerSpouse; + state.caseDetail.partyType = PARTY_TYPES.petitionerSpouse; const result = runCompute(fileDocumentHelper, { state }); expect(result.showSecondaryParty).toBeTruthy(); }); diff --git a/web-client/src/presenter/computeds/filterWorkItems.test.js b/web-client/src/presenter/computeds/filterWorkItems.test.js index 507354a0bb1..24313bfe608 100644 --- a/web-client/src/presenter/computeds/filterWorkItems.test.js +++ b/web-client/src/presenter/computeds/filterWorkItems.test.js @@ -1,6 +1,11 @@ -import * as CONSTANTS from '../../../../shared/src/business/entities/WorkQueue'; -import { Case } from '../../../../shared/src/business/entities/cases/Case'; -import { User } from '../../../../shared/src/business/entities/User'; +import { + CASE_STATUS_TYPES, + DOCKET_SECTION, + IRS_SYSTEM_SECTION, + PETITIONS_SECTION, + ROLES, +} from '../../../../shared/src/business/entities/EntityConstants'; + import { applicationContext } from '../../applicationContext'; import { filterWorkItems } from './formattedWorkQueue'; @@ -72,31 +77,31 @@ const SECTION_DOCUMENT_QC_OUTBOX = { }; const petitionsClerk1 = { - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, section: 'petitions', userId: 'p1', }; const petitionsClerk2 = { - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, section: 'petitions', userId: 'p2', }; const docketClerk1 = { - role: User.ROLES.docketClerk, + role: ROLES.docketClerk, section: 'docket', userId: 'd1', }; const docketClerk2 = { - role: User.ROLES.docketClerk, + role: ROLES.docketClerk, section: 'docket', userId: 'd2', }; const adc = { - role: User.ROLES.adc, + role: ROLES.adc, section: 'adc', userId: 'd3', }; @@ -106,7 +111,7 @@ const generateWorkItem = (data, document) => { assigneeId: null, assigneeName: null, caseId: '123', - caseStatus: Case.STATUS_TYPES.new, + caseStatus: CASE_STATUS_TYPES.new, createdAt: '2018-12-27T18:05:54.166Z', docketNumber: '100-01', document: { @@ -224,7 +229,7 @@ describe('filterWorkItems', () => { beforeAll(() => { applicationContext.getCurrentUser = () => ({ - role: User.ROLES.docketClerk, + role: ROLES.docketClerk, userId: '7f87f5d1-dfce-4515-a1e4-5231ceac61bb', }); @@ -233,15 +238,15 @@ describe('filterWorkItems', () => { completedAt: null, docketNumber: '100-01', isQC: false, - section: CONSTANTS.PETITIONS_SECTION, + section: PETITIONS_SECTION, }); workItemPetitionsMyMessagesSent = generateWorkItem({ assigneeId: petitionsClerk2.userId, docketNumber: '100-02', isQC: false, - section: CONSTANTS.PETITIONS_SECTION, - sentBySection: CONSTANTS.PETITIONS_SECTION, + section: PETITIONS_SECTION, + sentBySection: PETITIONS_SECTION, sentByUserId: petitionsClerk1.userId, }); @@ -249,13 +254,13 @@ describe('filterWorkItems', () => { completedAt: null, docketNumber: '100-03', isQC: false, - section: CONSTANTS.PETITIONS_SECTION, + section: PETITIONS_SECTION, }); workItemPetitionsSectionMessagesSent = generateWorkItem({ docketNumber: '100-04', isQC: false, - sentBySection: CONSTANTS.PETITIONS_SECTION, + sentBySection: PETITIONS_SECTION, sentByUserId: petitionsClerk2.userId, }); @@ -263,17 +268,17 @@ describe('filterWorkItems', () => { assigneeId: petitionsClerk1.userId, docketNumber: '100-05', isQC: true, - section: CONSTANTS.PETITIONS_SECTION, + section: PETITIONS_SECTION, }); workItemPetitionsMyDocumentQCServed = generateWorkItem({ assigneeId: petitionsClerk1.userId, - caseStatus: Case.STATUS_TYPES.calendared, + caseStatus: CASE_STATUS_TYPES.calendared, completedAt: '2019-07-18T18:05:54.166Z', completedByUserId: petitionsClerk1.userId, docketNumber: '100-07', isQC: true, - section: CONSTANTS.IRS_SYSTEM_SECTION, + section: IRS_SYSTEM_SECTION, sentByUserId: petitionsClerk1.userId, }); @@ -281,17 +286,17 @@ describe('filterWorkItems', () => { completedAt: null, docketNumber: '100-08', isQC: true, - section: CONSTANTS.PETITIONS_SECTION, + section: PETITIONS_SECTION, }); workItemPetitionsSectionDocumentQCServed = generateWorkItem({ assigneeId: petitionsClerk2.userId, - caseStatus: Case.STATUS_TYPES.calendared, + caseStatus: CASE_STATUS_TYPES.calendared, completedAt: '2019-07-18T18:05:54.166Z', completedByUserId: petitionsClerk2.userId, docketNumber: '100-10', isQC: true, - section: CONSTANTS.IRS_SYSTEM_SECTION, + section: IRS_SYSTEM_SECTION, sentByUserId: petitionsClerk2.userId, }); @@ -300,14 +305,14 @@ describe('filterWorkItems', () => { completedAt: null, docketNumber: '100-11', isQC: false, - section: CONSTANTS.DOCKET_SECTION, + section: DOCKET_SECTION, }); workItemDocketMyMessagesSent = generateWorkItem({ assigneeId: docketClerk2.userId, docketNumber: '100-12', isQC: false, - sentBySection: CONSTANTS.DOCKET_SECTION, + sentBySection: DOCKET_SECTION, sentByUserId: docketClerk1.userId, }); @@ -315,13 +320,13 @@ describe('filterWorkItems', () => { completedAt: null, docketNumber: '100-13', isQC: false, - section: CONSTANTS.DOCKET_SECTION, + section: DOCKET_SECTION, }); workItemDocketSectionMessagesSent = generateWorkItem({ docketNumber: '100-14', isQC: false, - sentBySection: CONSTANTS.DOCKET_SECTION, + sentBySection: DOCKET_SECTION, sentByUserId: docketClerk2.userId, }); @@ -330,14 +335,14 @@ describe('filterWorkItems', () => { completedAt: null, docketNumber: '100-15', isQC: true, - section: CONSTANTS.DOCKET_SECTION, + section: DOCKET_SECTION, }); workItemDocketSectionDocumentQCInbox = generateWorkItem({ completedAt: null, docketNumber: '100-17', isQC: true, - section: CONSTANTS.DOCKET_SECTION, + section: DOCKET_SECTION, }); workItemDocketMyDocumentQCInProgress = generateWorkItem( @@ -346,7 +351,7 @@ describe('filterWorkItems', () => { completedAt: null, docketNumber: '100-18', isQC: true, - section: CONSTANTS.DOCKET_SECTION, + section: DOCKET_SECTION, }, { isFileAttached: false, @@ -359,7 +364,7 @@ describe('filterWorkItems', () => { completedAt: null, docketNumber: '100-19', isQC: true, - section: CONSTANTS.DOCKET_SECTION, + section: DOCKET_SECTION, }, { isFileAttached: false, @@ -498,7 +503,7 @@ describe('filterWorkItems', () => { it('Returns sent messages for a Petitions Clerk in My Document QC Outbox', () => { const filtered = workQueueOutbox.filter( filterWorkItems({ - USER_ROLES: User.ROLES, + USER_ROLES: ROLES, applicationContext, ...MY_DOCUMENT_QC_OUTBOX, user: petitionsClerk1, @@ -544,7 +549,7 @@ describe('filterWorkItems', () => { const user = petitionsClerk1; const filtered = workQueueOutbox.filter( filterWorkItems({ - USER_ROLES: User.ROLES, + USER_ROLES: ROLES, applicationContext, ...SECTION_DOCUMENT_QC_OUTBOX, user, diff --git a/web-client/src/presenter/computeds/formattedCaseDetail.js b/web-client/src/presenter/computeds/formattedCaseDetail.js index 89e009d14aa..9bce183d2ed 100644 --- a/web-client/src/presenter/computeds/formattedCaseDetail.js +++ b/web-client/src/presenter/computeds/formattedCaseDetail.js @@ -1,10 +1,17 @@ /* eslint-disable complexity */ import { state } from 'cerebral'; -export const formattedCases = (get, applicationContext) => { +export const formattedOpenCases = (get, applicationContext) => { const { formatCase } = applicationContext.getUtilities(); - const cases = get(state.cases); + const cases = get(state.openCases); + return cases.map(myCase => formatCase(applicationContext, myCase)); +}; + +export const formattedClosedCases = (get, applicationContext) => { + const { formatCase } = applicationContext.getUtilities(); + + const cases = get(state.closedCases); return cases.map(myCase => formatCase(applicationContext, myCase)); }; diff --git a/web-client/src/presenter/computeds/formattedCaseDetail.test.js b/web-client/src/presenter/computeds/formattedCaseDetail.test.js index e4c668a9d25..abb6965c9e1 100644 --- a/web-client/src/presenter/computeds/formattedCaseDetail.test.js +++ b/web-client/src/presenter/computeds/formattedCaseDetail.test.js @@ -1,5 +1,7 @@ -import { Case } from '../../../../shared/src/business/entities/cases/Case'; -import { User } from '../../../../shared/src/business/entities/User'; +import { + CASE_STATUS_TYPES, + ROLES, +} from '../../../../shared/src/business/entities/EntityConstants'; import { applicationContext } from '../../applicationContext'; import { formattedCaseDetail as formattedCaseDetailComputed } from './formattedCaseDetail'; import { getUserPermissions } from '../../../../shared/src/authorization/getUserPermissions'; @@ -26,15 +28,15 @@ const getBaseState = user => { }; const petitionsClerkUser = { - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: '123', }; const docketClerkUser = { - role: User.ROLES.docketClerk, + role: ROLES.docketClerk, userId: '234', }; const judgeUser = { - role: User.ROLES.judge, + role: ROLES.judge, userId: '345', }; @@ -473,7 +475,7 @@ describe('formattedCaseDetail', () => { workItems: [{ isQC: true }], }, ], - status: Case.STATUS_TYPES.new, + status: CASE_STATUS_TYPES.new, }; const result = runCompute(formattedCaseDetail, { state: { @@ -543,7 +545,7 @@ describe('formattedCaseDetail', () => { }, ], isPaper: true, - status: Case.STATUS_TYPES.new, + status: CASE_STATUS_TYPES.new, }; const result = runCompute(formattedCaseDetail, { state: { @@ -873,7 +875,7 @@ describe('formattedCaseDetail', () => { associatedJudge: 'Judge Judy', correspondence: [], petitioners: [{ name: 'bob' }], - status: Case.STATUS_TYPES.calendared, + status: CASE_STATUS_TYPES.calendared, trialDate: '2018-12-11T05:00:00Z', trialLocation: 'England is my City', trialSessionId: '123', @@ -896,7 +898,7 @@ describe('formattedCaseDetail', () => { associatedJudge: 'Judge Judy', correspondence: [], petitioners: [{ name: 'bob' }], - status: Case.STATUS_TYPES.calendared, + status: CASE_STATUS_TYPES.calendared, trialDate: '2018-12-11T05:00:00Z', trialLocation: 'England is my City', trialSessionId: '123', @@ -1136,7 +1138,7 @@ describe('formattedCaseDetail', () => { associatedJudge: 'Guy Fieri', correspondence: [], petitioners: [{ name: 'Bobby Flay' }], - status: Case.STATUS_TYPES.calendared, + status: CASE_STATUS_TYPES.calendared, trialDate: '2018-12-11T05:00:00Z', trialLocation: 'Flavortown', trialSessionId: '123', @@ -1144,7 +1146,7 @@ describe('formattedCaseDetail', () => { ], correspondence: [], petitioners: [{ name: 'bob' }], - status: Case.STATUS_TYPES.calendared, + status: CASE_STATUS_TYPES.calendared, trialDate: '2018-12-11T05:00:00Z', trialLocation: 'England is my City', trialSessionId: '123', @@ -1167,7 +1169,7 @@ describe('formattedCaseDetail', () => { associatedJudge: 'Judge Judy', correspondence: [], petitioners: [{ name: 'bob' }], - status: Case.STATUS_TYPES.calendared, + status: CASE_STATUS_TYPES.calendared, trialDate: '2018-12-11T05:00:00Z', trialLocation: 'England is my City', trialSessionId: '123', diff --git a/web-client/src/presenter/computeds/formattedDashboardTrialSessions.test.js b/web-client/src/presenter/computeds/formattedDashboardTrialSessions.test.js index 0c3e5300646..9b210fe1fc0 100644 --- a/web-client/src/presenter/computeds/formattedDashboardTrialSessions.test.js +++ b/web-client/src/presenter/computeds/formattedDashboardTrialSessions.test.js @@ -1,4 +1,4 @@ -import { User } from '../../../../shared/src/business/entities/User'; +import { ROLES } from '../../../../shared/src/business/entities/EntityConstants'; import { applicationContext } from '../../applicationContext'; import { formatNow } from '../../../../shared/src/business/utilities/DateHandler'; import { @@ -223,7 +223,7 @@ describe('formattedDashboardTrialSessions', () => { it('returns results for an associated chambers judge if the user role is chambers', () => { applicationContext.getCurrentUser = () => ({ - role: User.ROLES.chambers, + role: ROLES.chambers, userId: '6', }); const result = runCompute(formattedDashboardTrialSessions, { diff --git a/web-client/src/presenter/computeds/formattedMessageDetail.js b/web-client/src/presenter/computeds/formattedMessageDetail.js new file mode 100644 index 00000000000..b9dc91f6890 --- /dev/null +++ b/web-client/src/presenter/computeds/formattedMessageDetail.js @@ -0,0 +1,16 @@ +import { formatDateIfToday } from './formattedWorkQueue'; +import { state } from 'cerebral'; + +export const formattedMessageDetail = (get, applicationContext) => { + const messageDetail = get(state.messageDetail); + + const result = { + ...messageDetail, + createdAtFormatted: formatDateIfToday( + messageDetail.createdAt, + applicationContext, + ), + }; + + return result; +}; diff --git a/web-client/src/presenter/computeds/formattedMessageDetail.test.js b/web-client/src/presenter/computeds/formattedMessageDetail.test.js new file mode 100644 index 00000000000..b7116b30f27 --- /dev/null +++ b/web-client/src/presenter/computeds/formattedMessageDetail.test.js @@ -0,0 +1,29 @@ +import { applicationContext } from '../../applicationContext'; +import { formattedMessageDetail as formattedMessageDetailComputed } from './formattedMessageDetail'; +import { runCompute } from 'cerebral/test'; +import { withAppContextDecorator } from '../../withAppContext'; + +const formattedMessageDetail = withAppContextDecorator( + formattedMessageDetailComputed, + { + ...applicationContext, + }, +); + +describe('formattedMessageDetail', () => { + it('formats the message detail with createdAtFormatted', () => { + const result = runCompute(formattedMessageDetail, { + state: { + messageDetail: { + caseId: '78fb798f-66c3-42fa-bb5a-c14fac735b61', + createdAt: '2019-03-01T21:40:46.415Z', + messageId: '60e129bf-b8ec-4e0c-93c7-9633ab69f5df', + }, + }, + }); + + expect(result).toMatchObject({ + createdAtFormatted: '03/01/19', + }); + }); +}); diff --git a/web-client/src/presenter/computeds/formattedMessages.js b/web-client/src/presenter/computeds/formattedMessages.js new file mode 100644 index 00000000000..fa36b38c32d --- /dev/null +++ b/web-client/src/presenter/computeds/formattedMessages.js @@ -0,0 +1,17 @@ +import { state } from 'cerebral'; + +import { formatDateIfToday } from './formattedWorkQueue'; + +export const formattedMessages = (get, applicationContext) => { + const messages = get(state.messages) || []; + + const result = messages.map(message => ({ + ...message, + createdAtFormatted: formatDateIfToday( + message.createdAt, + applicationContext, + ), + })); + + return result; +}; diff --git a/web-client/src/presenter/computeds/formattedMessages.test.js b/web-client/src/presenter/computeds/formattedMessages.test.js new file mode 100644 index 00000000000..0e42780fff1 --- /dev/null +++ b/web-client/src/presenter/computeds/formattedMessages.test.js @@ -0,0 +1,34 @@ +import { formattedMessages as formattedMessagesComputed } from './formattedMessages'; +import { runCompute } from 'cerebral/test'; +import { withAppContextDecorator } from '../../withAppContext'; + +const formattedMessages = withAppContextDecorator(formattedMessagesComputed); + +describe('formattedMessages', () => { + it('returns a createdAtFormatted', () => { + const result = runCompute(formattedMessages, { + state: { + messages: [ + { + caseId: 'c6b81f4d-1e47-423a-8caf-6d2fdc3d3859', + caseStatus: 'Ready for trial', + createdAt: '2019-01-01T17:29:13.122Z', + docketNumber: '123-45', + docketNumberSuffix: '', + from: 'Test Sender', + fromSection: 'docket', + fromUserId: '11181f4d-1e47-423a-8caf-6d2fdc3d3859', + message: 'This is a test message', + messageId: '22281f4d-1e47-423a-8caf-6d2fdc3d3859', + subject: 'Test subject...', + to: 'Test Recipient', + toSection: 'petitions', + toUserId: '33331f4d-1e47-423a-8caf-6d2fdc3d3859', + }, + ], + }, + }); + + expect(result[0].createdAtFormatted).toEqual('01/01/19'); + }); +}); diff --git a/web-client/src/presenter/computeds/formattedTrialSessions.test.js b/web-client/src/presenter/computeds/formattedTrialSessions.test.js index a7668e75aa9..8442f4d09a5 100644 --- a/web-client/src/presenter/computeds/formattedTrialSessions.test.js +++ b/web-client/src/presenter/computeds/formattedTrialSessions.test.js @@ -1,4 +1,4 @@ -import { User } from '../../../../shared/src/business/entities/User'; +import { ROLES } from '../../../../shared/src/business/entities/EntityConstants'; import { applicationContext } from '../../applicationContext'; import { filterFormattedSessionsByStatus, @@ -28,17 +28,17 @@ let nextYear; let currentUser = {}; const testJudgeUser = { - role: User.ROLES.judge, + role: ROLES.judge, userId: '1', }; const testTrialClerkUser = { - role: User.ROLES.trialClerk, + role: ROLES.trialClerk, userId: '10', }; const baseState = { - constants: { USER_ROLES: User.ROLES }, + constants: { USER_ROLES: ROLES }, judgeUser: testJudgeUser, }; @@ -456,7 +456,7 @@ describe('formattedTrialSessions', () => { ...baseState, judgeUser: undefined, trialSessions: TRIAL_SESSIONS_LIST, - user: { role: User.ROLES.petitionsClerk, userId: '1' }, + user: { role: ROLES.petitionsClerk, userId: '1' }, }, }); expect(result.formattedSessions).toMatchObject([ @@ -612,7 +612,7 @@ describe('formattedTrialSessions', () => { trialLocation: 'Jacksonville, FL', }, ], - user: { role: User.ROLES.petitionsClerk, userId: '1' }, + user: { role: ROLES.petitionsClerk, userId: '1' }, }, }); expect(result.formattedSessions).toMatchObject([ diff --git a/web-client/src/presenter/computeds/formattedWorkQueue.js b/web-client/src/presenter/computeds/formattedWorkQueue.js index 96c0c4efb28..94d02b3f001 100644 --- a/web-client/src/presenter/computeds/formattedWorkQueue.js +++ b/web-client/src/presenter/computeds/formattedWorkQueue.js @@ -1,7 +1,7 @@ import { DOCKET_SECTION, PETITIONS_SECTION, -} from '../../../../shared/src/business/entities/WorkQueue'; +} from '../../../../shared/src/business/entities/EntityConstants'; import { capitalize, cloneDeep, orderBy } from 'lodash'; import { filterQcItemsByAssociatedJudge } from '../utilities/filterQcItemsByAssociatedJudge'; import { state } from 'cerebral'; @@ -14,7 +14,7 @@ const isDateToday = (date, applicationContext) => { return now === then; }; -const formatDateIfToday = (date, applicationContext) => { +export const formatDateIfToday = (date, applicationContext) => { const now = applicationContext.getUtilities().formatNow('MMDDYY'); const then = applicationContext .getUtilities() diff --git a/web-client/src/presenter/computeds/formattedWorkQueue.test.js b/web-client/src/presenter/computeds/formattedWorkQueue.test.js index c3912e07f30..94579b53c94 100644 --- a/web-client/src/presenter/computeds/formattedWorkQueue.test.js +++ b/web-client/src/presenter/computeds/formattedWorkQueue.test.js @@ -1,8 +1,12 @@ -import { Case } from '../../../../shared/src/business/entities/cases/Case'; -import { User } from '../../../../shared/src/business/entities/User'; +import { + CASE_STATUS_TYPES, + CHIEF_JUDGE, + ROLES, +} from '../../../../shared/src/business/entities/EntityConstants'; import { applicationContext } from '../../applicationContext'; import { cloneDeep } from 'lodash'; import { + formatDateIfToday, formatWorkItem, formattedWorkQueue as formattedWorkQueueComputed, getWorkItemDocumentLink, @@ -29,13 +33,13 @@ const WORK_ITEM_ID_4 = '4bd51fb7-fc46-4d4d-a506-08d48afcf46d'; const JUDGE_USER_ID_1 = '89c956aa-65c6-4632-a6c8-7f0c6162d615'; const petitionsClerkUser = { - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, section: 'petitions', userId: 'abc', }; const docketClerkUser = { - role: User.ROLES.docketClerk, + role: ROLES.docketClerk, section: 'docket', userId: 'abc', }; @@ -51,7 +55,7 @@ const FORMATTED_WORK_ITEM = { assigneeId: 'abc', assigneeName: 'Unassigned', caseId: 'e631d81f-a579-4de5-b8a8-b3f10ef619fd', - caseStatus: Case.STATUS_TYPES.generalDocket, + caseStatus: CASE_STATUS_TYPES.generalDocket, createdAtFormatted: '12/27/18', currentMessage: { createdAtFormatted: '12/27/18', @@ -111,7 +115,7 @@ describe('formatted work queue computed', () => { assigneeId: 'abc', assigneeName: null, caseId: 'e631d81f-a579-4de5-b8a8-b3f10ef619fd', - caseStatus: Case.STATUS_TYPES.generalDocket, + caseStatus: CASE_STATUS_TYPES.generalDocket, createdAt: '2018-12-27T18:05:54.166Z', docketNumber: '101-18', docketNumberSuffix: 'S', @@ -435,7 +439,7 @@ describe('formatted work queue computed', () => { it('filters items based on associatedJudge for a given judge or chambers user', () => { const judgeUser = { name: 'Test Judge', - role: User.ROLES.judge, + role: ROLES.judge, userId: JUDGE_USER_ID_1, }; @@ -460,7 +464,7 @@ describe('formatted work queue computed', () => { }, { ...qcWorkItem, - associatedJudge: Case.CHIEF_JUDGE, + associatedJudge: CHIEF_JUDGE, workItemId: WORK_ITEM_ID_4, }, ], @@ -479,7 +483,7 @@ describe('formatted work queue computed', () => { it('filters items based on associatedJudge for an adc user', () => { const adcUser = { name: 'Test ADC', - role: User.ROLES.adc, + role: ROLES.adc, userId: 'd4d25c47-bb50-4575-9c31-d00bb682a215', }; @@ -503,7 +507,7 @@ describe('formatted work queue computed', () => { }, { ...qcWorkItem, - associatedJudge: Case.CHIEF_JUDGE, + associatedJudge: CHIEF_JUDGE, workItemId: WORK_ITEM_ID_4, }, ], @@ -523,7 +527,7 @@ describe('formatted work queue computed', () => { it('filters items based on in progress cases for a petitionsclerk', () => { const petitionsClerkUser = { name: 'Test PetitionsClerk', - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: 'd4d25c47-bb50-4575-9c31-d00bb682a215', }; @@ -547,9 +551,9 @@ describe('formatted work queue computed', () => { }, { ...qcWorkItem, - associatedJudge: Case.CHIEF_JUDGE, + associatedJudge: CHIEF_JUDGE, caseIsInProgress: true, - caseStatus: Case.STATUS_TYPES.new, + caseStatus: CASE_STATUS_TYPES.new, document: { ...qcWorkItem.document, status: 'processing', @@ -1457,4 +1461,42 @@ describe('formatted work queue computed', () => { ); }); }); + + describe('formatDateIfToday', () => { + it('returns a time if the date is today', () => { + const currentTime = applicationContext + .getUtilities() + .createISODateString(); + + const result = formatDateIfToday(currentTime, applicationContext); + + expect(result).toContain(':'); + expect(result).toContain('ET'); + expect(result).not.toContain('/'); + }); + + it('returns "Yesterday" if the date is yesterday', () => { + const currentTime = applicationContext + .getUtilities() + .createISODateString(); + + const yesterday = applicationContext + .getUtilities() + .calculateISODate({ dateString: currentTime, howMuch: -1 }); + + const result = formatDateIfToday(yesterday, applicationContext); + + expect(result).toEqual('Yesterday'); + }); + + it('returns the formatted date if older than one day', () => { + const date = applicationContext + .getUtilities() + .formatDateString('2019-01-01T17:29:13.122Z'); + + const result = formatDateIfToday(date, applicationContext); + + expect(result).toContain('01/01/19'); + }); + }); }); diff --git a/web-client/src/presenter/computeds/headerHelper.js b/web-client/src/presenter/computeds/headerHelper.js index 35871fb1bab..a6bae5e8e49 100644 --- a/web-client/src/presenter/computeds/headerHelper.js +++ b/web-client/src/presenter/computeds/headerHelper.js @@ -18,6 +18,7 @@ export const headerHelper = (get, applicationContext) => { const isTrialSessions = currentPage.includes('TrialSession'); const isDashboard = currentPage.startsWith('Dashboard'); const isMessages = currentPage.startsWith('Messages'); + const isCaseMessages = currentPage.startsWith('CaseMessages'); const pageIsHome = isDashboard || @@ -34,6 +35,7 @@ export const headerHelper = (get, applicationContext) => { defaultQCBoxPath: isOtherUser(userRole) ? '/document-qc/section/inbox' : '/document-qc/my/inbox', + pageIsCaseMessages: isCaseMessages && workQueueIsInternal, pageIsDashboard: isDashboard && applicationContext.getUtilities().isExternalUser(userRole), pageIsDocumentQC: isMessages && !workQueueIsInternal, diff --git a/web-client/src/presenter/computeds/headerHelper.test.js b/web-client/src/presenter/computeds/headerHelper.test.js index 2dff2f95869..25f122b680d 100644 --- a/web-client/src/presenter/computeds/headerHelper.test.js +++ b/web-client/src/presenter/computeds/headerHelper.test.js @@ -1,4 +1,4 @@ -import { User } from '../../../../shared/src/business/entities/User'; +import { ROLES } from '../../../../shared/src/business/entities/EntityConstants'; import { applicationContext } from '../../applicationContext'; import { getUserPermissions } from '../../../../shared/src/authorization/getUserPermissions'; import { headerHelper as headerHelperComputed } from './headerHelper'; @@ -20,31 +20,27 @@ const getBaseState = user => { }; }; -const internal = [ - User.ROLES.petitionsClerk, - User.ROLES.adc, - User.ROLES.docketClerk, -]; +const internal = [ROLES.petitionsClerk, ROLES.adc, ROLES.docketClerk]; const external = [ - User.ROLES.petitioner, - User.ROLES.privatePractitioner, - User.ROLES.irsPractitioner, + ROLES.petitioner, + ROLES.privatePractitioner, + ROLES.irsPractitioner, ]; describe('headerHelper', () => { it('should show search in header for users other than petitioner, privatePractitioners and irsPractitioners', () => { let result = runCompute(headerHelper, { - state: getBaseState({ role: User.ROLES.petitioner }), + state: getBaseState({ role: ROLES.petitioner }), }); expect(result.showSearchInHeader).toBeFalsy(); result = runCompute(headerHelper, { - state: getBaseState({ role: User.ROLES.petitionsClerk }), + state: getBaseState({ role: ROLES.petitionsClerk }), }); expect(result.showSearchInHeader).toBeTruthy(); result = runCompute(headerHelper, { - state: getBaseState({ role: User.ROLES.docketClerk }), + state: getBaseState({ role: ROLES.docketClerk }), }); expect(result.showSearchInHeader).toBeTruthy(); }); @@ -83,35 +79,35 @@ describe('headerHelper', () => { }); it('should not show cases for irsSuperuser', () => { const result = runCompute(headerHelper, { - state: getBaseState({ role: User.ROLES.irsSuperuser }), + state: getBaseState({ role: ROLES.irsSuperuser }), }); expect(result.showMyCases).toBeFalsy(); }); it('should show search nav item for irsSuperuser', () => { const result = runCompute(headerHelper, { - state: getBaseState({ role: User.ROLES.irsSuperuser }), + state: getBaseState({ role: ROLES.irsSuperuser }), }); expect(result.showSearchNavItem).toBeTruthy(); }); it('should NOT show search nav item for privatePractitioner', () => { const result = runCompute(headerHelper, { - state: getBaseState({ role: User.ROLES.privatePractitioner }), + state: getBaseState({ role: ROLES.privatePractitioner }), }); expect(result.showSearchNavItem).toBeFalsy(); }); it('should NOT show search in header for privatePractitioners, irsPractitioners, or irsSuperuser', () => { let result = runCompute(headerHelper, { - state: getBaseState({ role: User.ROLES.privatePractitioner }), + state: getBaseState({ role: ROLES.privatePractitioner }), }); expect(result.showSearchInHeader).toBeFalsy(); result = runCompute(headerHelper, { - state: getBaseState({ role: User.ROLES.irsPractitioner }), + state: getBaseState({ role: ROLES.irsPractitioner }), }); expect(result.showSearchInHeader).toBeFalsy(); result = runCompute(headerHelper, { - state: getBaseState({ role: User.ROLES.irsSuperuser }), + state: getBaseState({ role: ROLES.irsSuperuser }), }); expect(result.showSearchInHeader).toBeFalsy(); }); @@ -150,7 +146,7 @@ describe('headerHelper', () => { it('should know when the page is Messages', () => { const result = runCompute(headerHelper, { state: { - ...getBaseState({ role: User.ROLES.petitionsClerk }), + ...getBaseState({ role: ROLES.petitionsClerk }), currentPage: 'Messages', workQueueToDisplay: { workQueueIsInternal: true, @@ -159,10 +155,22 @@ describe('headerHelper', () => { }); expect(result.pageIsMessages).toBeTruthy(); }); + it('should know when the page is Case Messages', () => { + const result = runCompute(headerHelper, { + state: { + ...getBaseState({ role: ROLES.petitionsClerk }), + currentPage: 'CaseMessages', + workQueueToDisplay: { + workQueueIsInternal: true, + }, + }, + }); + expect(result.pageIsCaseMessages).toBeTruthy(); + }); it('should know when the page is My Cases', () => { const result = runCompute(headerHelper, { state: { - ...getBaseState({ role: User.ROLES.petitioner }), + ...getBaseState({ role: ROLES.petitioner }), currentPage: 'DashboardPetitioner', }, }); @@ -171,7 +179,7 @@ describe('headerHelper', () => { it('should know when the page is Dashboard', () => { const result = runCompute(headerHelper, { state: { - ...getBaseState({ role: User.ROLES.irsSuperuser }), + ...getBaseState({ role: ROLES.irsSuperuser }), currentPage: 'DashboardIrsSuperuser', }, }); @@ -180,7 +188,7 @@ describe('headerHelper', () => { it('should not set pageIsMessages or pageIsDocumentQC to true if currentPage is TrialSessions', () => { const result = runCompute(headerHelper, { state: { - ...getBaseState({ role: User.ROLES.petitionsClerk }), + ...getBaseState({ role: ROLES.petitionsClerk }), currentPage: 'TrialSessions', }, }); @@ -190,7 +198,7 @@ describe('headerHelper', () => { it('should know when the page is TrialSessions', () => { const result = runCompute(headerHelper, { state: { - ...getBaseState({ role: User.ROLES.petitionsClerk }), + ...getBaseState({ role: ROLES.petitionsClerk }), currentPage: 'TrialSessions', }, }); @@ -199,7 +207,7 @@ describe('headerHelper', () => { it('should know when the page is TrialSessionDetails', () => { const result = runCompute(headerHelper, { state: { - ...getBaseState({ role: User.ROLES.petitionsClerk }), + ...getBaseState({ role: ROLES.petitionsClerk }), currentPage: 'TrialSessionDetails', }, }); @@ -209,7 +217,7 @@ describe('headerHelper', () => { it('should show border under Reports tab when page is CaseDeadlines', () => { const result = runCompute(headerHelper, { state: { - ...getBaseState({ role: User.ROLES.petitionsClerk }), + ...getBaseState({ role: ROLES.petitionsClerk }), currentPage: 'CaseDeadlines', }, }); @@ -219,7 +227,7 @@ describe('headerHelper', () => { it('should show border under Reports tab when page is BlockedCasesReport', () => { const result = runCompute(headerHelper, { state: { - ...getBaseState({ role: User.ROLES.petitionsClerk }), + ...getBaseState({ role: ROLES.petitionsClerk }), currentPage: 'BlockedCasesReport', }, }); diff --git a/web-client/src/presenter/computeds/messagesHelper.js b/web-client/src/presenter/computeds/messagesHelper.js new file mode 100644 index 00000000000..ea213e4a1cb --- /dev/null +++ b/web-client/src/presenter/computeds/messagesHelper.js @@ -0,0 +1,13 @@ +import { state } from 'cerebral'; + +export const messagesHelper = get => { + const messageBoxToDisplay = get(state.messageBoxToDisplay); + const showIndividualMessages = messageBoxToDisplay.queue === 'my'; + const showSectionMessages = messageBoxToDisplay.queue === 'section'; + + const messagesTitle = showIndividualMessages + ? 'My Messages' + : 'Section Messages'; + + return { messagesTitle, showIndividualMessages, showSectionMessages }; +}; diff --git a/web-client/src/presenter/computeds/messagesHelper.test.js b/web-client/src/presenter/computeds/messagesHelper.test.js new file mode 100644 index 00000000000..6973339df47 --- /dev/null +++ b/web-client/src/presenter/computeds/messagesHelper.test.js @@ -0,0 +1,50 @@ +import { messagesHelper } from './messagesHelper'; +import { runCompute } from 'cerebral/test'; + +describe('messagesHelper', () => { + it('should set showIndividualMessages true and showSectionMessages false if messageBoxToDisplay.queue is my', () => { + const result = runCompute(messagesHelper, { + state: { + messageBoxToDisplay: { + queue: 'my', + }, + }, + }); + expect(result.showIndividualMessages).toBeTruthy(); + expect(result.showSectionMessages).toBeFalsy(); + }); + + it('should set showIndividualMessages false and showSectionMessages true if messageBoxToDisplay.queue is section', () => { + const result = runCompute(messagesHelper, { + state: { + messageBoxToDisplay: { + queue: 'section', + }, + }, + }); + expect(result.showIndividualMessages).toBeFalsy(); + expect(result.showSectionMessages).toBeTruthy(); + }); + + it('should set messagesTitle to the current message box being displayed', () => { + let result = runCompute(messagesHelper, { + state: { + messageBoxToDisplay: { + queue: 'my', + }, + }, + }); + + expect(result.messagesTitle).toEqual('My Messages'); + + result = runCompute(messagesHelper, { + state: { + messageBoxToDisplay: { + queue: 'section', + }, + }, + }); + + expect(result.messagesTitle).toEqual('Section Messages'); + }); +}); diff --git a/web-client/src/presenter/computeds/public/todaysOpinionsHelper.js b/web-client/src/presenter/computeds/public/todaysOpinionsHelper.js new file mode 100644 index 00000000000..abbb67d6c01 --- /dev/null +++ b/web-client/src/presenter/computeds/public/todaysOpinionsHelper.js @@ -0,0 +1,26 @@ +import { Document } from '../../../../../shared/src/business/entities/Document'; +import { state } from 'cerebral'; + +export const todaysOpinionsHelper = (get, applicationContext) => { + const todaysOpinions = get(state.todaysOpinions); + const baseUrl = get(state.baseUrl); + + const currentDate = applicationContext.getUtilities().createISODateString(); + const formattedCurrentDate = applicationContext + .getUtilities() + .formatDateString(currentDate, 'MMMM D, YYYY'); + + const formattedOpinions = todaysOpinions.map(opinion => ({ + ...opinion, + documentLink: `${baseUrl}/public-api/${opinion.caseId}/${opinion.documentId}/public-document-download-url`, + formattedDocumentType: Document.getFormattedType(opinion.documentType), + formattedFilingDate: applicationContext + .getUtilities() + .formatDateString(opinion.filingDate, 'MMDDYY'), + formattedJudgeName: applicationContext + .getUtilities() + .getJudgeLastName(opinion.judge), + })); + + return { formattedCurrentDate, formattedOpinions }; +}; diff --git a/web-client/src/presenter/computeds/public/todaysOpinionsHelper.test.js b/web-client/src/presenter/computeds/public/todaysOpinionsHelper.test.js new file mode 100644 index 00000000000..1eac031f4a6 --- /dev/null +++ b/web-client/src/presenter/computeds/public/todaysOpinionsHelper.test.js @@ -0,0 +1,56 @@ +import { applicationContextPublic } from '../../../applicationContextPublic'; +import { runCompute } from 'cerebral/test'; +import { todaysOpinionsHelper as todaysOpinionsHelperComputed } from './todaysOpinionsHelper'; +import { withAppContextDecorator } from '../../../withAppContext'; + +const todaysOpinionsHelper = withAppContextDecorator( + todaysOpinionsHelperComputed, + applicationContextPublic, +); + +let state; +describe('todaysOpinionsHelper', () => { + beforeEach(() => { + state = { + baseUrl: 'https://www.example.com', + todaysOpinions: [ + { + caseCaption: 'Sauceboss, Petitioner', + caseId: 'case-id-123', + documentId: 'document-id-123', + documentType: 'MOP - Memorandum Opinion', + filingDate: '2020-06-11T20:17:10.646Z', + judge: 'Guy Fieri', + }, + ], + }; + }); + + it('should return the formattedOpinions as an array', () => { + const result = runCompute(todaysOpinionsHelper, { state }); + expect(Array.isArray(result.formattedOpinions)).toBeTruthy(); + expect(result.formattedOpinions).toMatchObject([ + { + caseCaption: 'Sauceboss, Petitioner', + documentLink: + 'https://www.example.com/public-api/case-id-123/document-id-123/public-document-download-url', + formattedDocumentType: 'Memorandum Opinion', + formattedFilingDate: '06/11/20', + formattedJudgeName: 'Fieri', + }, + ]); + }); + + it('should return formattedCurrentDate', () => { + const result = runCompute(todaysOpinionsHelper, { state }); + + const currentDate = applicationContextPublic + .getUtilities() + .createISODateString(); + const formattedCurrentDate = applicationContextPublic + .getUtilities() + .formatDateString(currentDate, 'MMMM D, YYYY'); + + expect(result.formattedCurrentDate).toEqual(formattedCurrentDate); + }); +}); diff --git a/web-client/src/presenter/computeds/requestAccessHelper.test.js b/web-client/src/presenter/computeds/requestAccessHelper.test.js index d4cf386c718..01d7e97992d 100644 --- a/web-client/src/presenter/computeds/requestAccessHelper.test.js +++ b/web-client/src/presenter/computeds/requestAccessHelper.test.js @@ -1,5 +1,5 @@ import { MOCK_CASE } from '../../../../shared/src/test/mockCase'; -import { User } from '../../../../shared/src/business/entities/User'; +import { ROLES } from '../../../../shared/src/business/entities/EntityConstants'; import { applicationContext } from '../../applicationContext'; import { requestAccessHelper as requestAccessHelperComputed } from './requestAccessHelper'; import { runCompute } from 'cerebral/test'; @@ -17,7 +17,7 @@ const requestAccessHelper = withAppContextDecorator( ); applicationContext.getCurrentUser = () => ({ - role: User.ROLES.privatePractitioner, + role: ROLES.privatePractitioner, }); describe('requestAccessHelper', () => { @@ -90,7 +90,7 @@ describe('requestAccessHelper', () => { it('returns correct number of document options for user role respondent', () => { applicationContext.getCurrentUser = () => ({ - role: User.ROLES.irsPractitioner, + role: ROLES.irsPractitioner, }); const result = runCompute(requestAccessHelper, { state }); expect(result.documents.length).toEqual(2); diff --git a/web-client/src/presenter/computeds/scanBatchPreviewerHelper.test.js b/web-client/src/presenter/computeds/scanBatchPreviewerHelper.test.js index 77b59fdd3a0..b4d9e4cb8d2 100644 --- a/web-client/src/presenter/computeds/scanBatchPreviewerHelper.test.js +++ b/web-client/src/presenter/computeds/scanBatchPreviewerHelper.test.js @@ -1,5 +1,7 @@ -import { Scan } from '../../../../shared/src/business/entities/Scan'; -import { User } from '../../../../shared/src/business/entities/User'; +import { + ROLES, + SCAN_MODES, +} from '../../../../shared/src/business/entities/EntityConstants'; import { applicationContext } from '../../applicationContext'; import { runCompute } from 'cerebral/test'; import { scanBatchPreviewerHelper as scanBatchPreviewerHelperComputed } from './scanBatchPreviewerHelper'; @@ -11,15 +13,13 @@ const state = { }, }; -const { SCAN_MODES } = Scan; - const scanBatchPreviewerHelper = withAppContextDecorator( scanBatchPreviewerHelperComputed, applicationContext, ); applicationContext.getCurrentUser = () => ({ - role: User.ROLES.privatePractitioner, + role: ROLES.privatePractitioner, }); applicationContext.getConstants = () => ({ SCAN_MODES }); diff --git a/web-client/src/presenter/computeds/scanHelper.test.js b/web-client/src/presenter/computeds/scanHelper.test.js index 2e69ca840ed..0cbf3833fae 100644 --- a/web-client/src/presenter/computeds/scanHelper.test.js +++ b/web-client/src/presenter/computeds/scanHelper.test.js @@ -1,4 +1,4 @@ -import { User } from '../../../../shared/src/business/entities/User'; +import { ROLES } from '../../../../shared/src/business/entities/EntityConstants'; import { applicationContext } from '../../applicationContext'; import { runCompute } from 'cerebral/test'; import { scanHelper as scanHelperComputed } from './scanHelper'; @@ -12,7 +12,7 @@ const scanHelper = withAppContextDecorator( describe('scanHelper', () => { it('sets hasScanFeature to `true` for `petitionsclerk` user roles', () => { applicationContext.getCurrentUser = () => ({ - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, }); const result = runCompute(scanHelper, { state: {}, @@ -22,7 +22,7 @@ describe('scanHelper', () => { it('sets hasScanFeature to `true` for `docketclerk` user roles', () => { applicationContext.getCurrentUser = () => ({ - role: User.ROLES.docketClerk, + role: ROLES.docketClerk, }); const result = runCompute(scanHelper, { state: {}, @@ -32,7 +32,7 @@ describe('scanHelper', () => { it('sets hasScanFeature to `true` for `adc` user roles', () => { applicationContext.getCurrentUser = () => ({ - role: User.ROLES.adc, + role: ROLES.adc, }); const result = runCompute(scanHelper, { state: {}, @@ -42,7 +42,7 @@ describe('scanHelper', () => { it('sets hasScanFeature to `false` for `petitioner` user roles', () => { applicationContext.getCurrentUser = () => ({ - role: User.ROLES.petitioner, + role: ROLES.petitioner, }); const result = runCompute(scanHelper, { state: {}, @@ -52,7 +52,7 @@ describe('scanHelper', () => { it('sets hasScanFeature to `false` for `practitioner` user roles', () => { applicationContext.getCurrentUser = () => ({ - role: User.ROLES.privatePractitioner, + role: ROLES.privatePractitioner, }); const result = runCompute(scanHelper, { state: {}, @@ -62,7 +62,7 @@ describe('scanHelper', () => { it('sets hasScanFeature to `false` for `respondent` user roles', () => { applicationContext.getCurrentUser = () => ({ - role: User.ROLES.irsPractitioner, + role: ROLES.irsPractitioner, }); const result = runCompute(scanHelper, { state: {}, diff --git a/web-client/src/presenter/computeds/selectDocumentTypeHelper.test.js b/web-client/src/presenter/computeds/selectDocumentTypeHelper.test.js index 4c65c8468da..e1fbbfa3bd4 100644 --- a/web-client/src/presenter/computeds/selectDocumentTypeHelper.test.js +++ b/web-client/src/presenter/computeds/selectDocumentTypeHelper.test.js @@ -1,4 +1,4 @@ -import { Document } from '../../../../shared/src/business/entities/Document'; +import { DOCUMENT_CATEGORY_MAP } from '../../../../shared/src/business/entities/EntityConstants'; import { MOCK_CASE } from '../../../../shared/src/test/mockCase'; import { applicationContext } from '../../applicationContext'; import { runCompute } from 'cerebral/test'; @@ -6,7 +6,7 @@ import { selectDocumentTypeHelper as selectDocumentTypeHelperComputed } from './ import { withAppContextDecorator } from '../../withAppContext'; // external filing events don't currently contain Nonstandard I, Nonstandard J -- but if they did ... -Document.CATEGORY_MAP['Miscellaneous'].push({ +DOCUMENT_CATEGORY_MAP['Miscellaneous'].push({ category: 'Miscellaneous', documentTitle: '[First, Second, etc.] Something to [anything]', documentType: 'Something [anything]', @@ -18,7 +18,7 @@ Document.CATEGORY_MAP['Miscellaneous'].push({ scenario: 'Nonstandard I', }); -Document.CATEGORY_MAP['Decision'].push({ +DOCUMENT_CATEGORY_MAP['Decision'].push({ category: 'Decision', documentTitle: 'Stipulated Decision Entered [judge] [anything]', documentType: 'Stipulated Decision Entered', @@ -37,7 +37,7 @@ const selectDocumentTypeHelper = withAppContextDecorator( getConstants: () => { return { ...applicationContext.getConstants(), - CATEGORY_MAP: Document.CATEGORY_MAP, + CATEGORY_MAP: DOCUMENT_CATEGORY_MAP, }; }, }, diff --git a/web-client/src/presenter/computeds/startCaseHelper.test.js b/web-client/src/presenter/computeds/startCaseHelper.test.js index db7a4b67c72..4ed847e1257 100644 --- a/web-client/src/presenter/computeds/startCaseHelper.test.js +++ b/web-client/src/presenter/computeds/startCaseHelper.test.js @@ -1,5 +1,7 @@ -import { Case } from '../../../../shared/src/business/entities/cases/Case'; -import { User } from '../../../../shared/src/business/entities/User'; +import { + FILING_TYPES, + ROLES, +} from '../../../../shared/src/business/entities/EntityConstants'; import { applicationContext } from '../../applicationContext'; import { getTrialCityName } from '../computeds/formattedTrialCity'; import { runCompute } from 'cerebral/test'; @@ -14,7 +16,7 @@ const startCaseHelper = withAppContextDecorator( describe('start a case computed', () => { beforeAll(() => { applicationContext.getCurrentUser = () => ({ - role: User.ROLES.petitioner, + role: ROLES.petitioner, }); }); @@ -101,12 +103,12 @@ describe('start a case computed', () => { getTrialCityName, }, }); - expect(result.filingTypes).toEqual(Case.FILING_TYPES.petitioner); + expect(result.filingTypes).toEqual(FILING_TYPES.petitioner); }); it('returns privatePractitioner filing types if user is privatePractitioner role', () => { applicationContext.getCurrentUser = () => ({ - role: User.ROLES.privatePractitioner, + role: ROLES.privatePractitioner, }); const result = runCompute(startCaseHelper, { @@ -117,12 +119,12 @@ describe('start a case computed', () => { getTrialCityName, }, }); - expect(result.filingTypes).toEqual(Case.FILING_TYPES.privatePractitioner); + expect(result.filingTypes).toEqual(FILING_TYPES.privatePractitioner); }); it('returns petitioner filing types by default if user is not petitioner or privatePractitioner role', () => { applicationContext.getCurrentUser = () => ({ - role: User.ROLES.irsPractitioner, + role: ROLES.irsPractitioner, }); const result = runCompute(startCaseHelper, { @@ -133,6 +135,6 @@ describe('start a case computed', () => { getTrialCityName, }, }); - expect(result.filingTypes).toEqual(Case.FILING_TYPES.petitioner); + expect(result.filingTypes).toEqual(FILING_TYPES.petitioner); }); }); diff --git a/web-client/src/presenter/computeds/startCaseInternalContactsHelper.test.js b/web-client/src/presenter/computeds/startCaseInternalContactsHelper.test.js index bc4402219fc..e205ab92816 100644 --- a/web-client/src/presenter/computeds/startCaseInternalContactsHelper.test.js +++ b/web-client/src/presenter/computeds/startCaseInternalContactsHelper.test.js @@ -1,4 +1,4 @@ -import { ContactFactory } from '../../../../shared/src/business/entities/contacts/ContactFactory'; +import { PARTY_TYPES } from '../../../../shared/src/business/entities/EntityConstants'; import { applicationContext } from '../../applicationContext'; import { runCompute } from 'cerebral/test'; import { startCaseInternalContactsHelper as startCaseInternalContactsHelperComputed } from './startCaseInternalContactsHelper'; @@ -14,9 +14,9 @@ describe('startCaseInternalContactsHelper', () => { const result = runCompute(startCaseInternalContactsHelper, { state: { constants: { - PARTY_TYPES: ContactFactory.PARTY_TYPES, + PARTY_TYPES: PARTY_TYPES, }, - form: { partyType: ContactFactory.PARTY_TYPES.conservator }, + form: { partyType: PARTY_TYPES.conservator }, }, }); expect(result).toMatchObject({ @@ -33,9 +33,9 @@ describe('startCaseInternalContactsHelper', () => { const result = runCompute(startCaseInternalContactsHelper, { state: { constants: { - PARTY_TYPES: ContactFactory.PARTY_TYPES, + PARTY_TYPES: PARTY_TYPES, }, - form: { partyType: ContactFactory.PARTY_TYPES.corporation }, + form: { partyType: PARTY_TYPES.corporation }, }, }); expect(result).toMatchObject({ @@ -51,9 +51,9 @@ describe('startCaseInternalContactsHelper', () => { const result = runCompute(startCaseInternalContactsHelper, { state: { constants: { - PARTY_TYPES: ContactFactory.PARTY_TYPES, + PARTY_TYPES: PARTY_TYPES, }, - form: { partyType: ContactFactory.PARTY_TYPES.custodian }, + form: { partyType: PARTY_TYPES.custodian }, }, }); expect(result).toMatchObject({ @@ -70,9 +70,9 @@ describe('startCaseInternalContactsHelper', () => { const result = runCompute(startCaseInternalContactsHelper, { state: { constants: { - PARTY_TYPES: ContactFactory.PARTY_TYPES, + PARTY_TYPES: PARTY_TYPES, }, - form: { partyType: ContactFactory.PARTY_TYPES.donor }, + form: { partyType: PARTY_TYPES.donor }, }, }); expect(result).toMatchObject({ @@ -87,10 +87,10 @@ describe('startCaseInternalContactsHelper', () => { const result = runCompute(startCaseInternalContactsHelper, { state: { constants: { - PARTY_TYPES: ContactFactory.PARTY_TYPES, + PARTY_TYPES: PARTY_TYPES, }, form: { - partyType: ContactFactory.PARTY_TYPES.estate, + partyType: PARTY_TYPES.estate, }, }, }); @@ -109,10 +109,10 @@ describe('startCaseInternalContactsHelper', () => { const result = runCompute(startCaseInternalContactsHelper, { state: { constants: { - PARTY_TYPES: ContactFactory.PARTY_TYPES, + PARTY_TYPES: PARTY_TYPES, }, form: { - partyType: ContactFactory.PARTY_TYPES.estateWithoutExecutor, + partyType: PARTY_TYPES.estateWithoutExecutor, }, }, }); @@ -129,10 +129,10 @@ describe('startCaseInternalContactsHelper', () => { const result = runCompute(startCaseInternalContactsHelper, { state: { constants: { - PARTY_TYPES: ContactFactory.PARTY_TYPES, + PARTY_TYPES: PARTY_TYPES, }, form: { - partyType: ContactFactory.PARTY_TYPES.guardian, + partyType: PARTY_TYPES.guardian, }, }, }); @@ -150,10 +150,10 @@ describe('startCaseInternalContactsHelper', () => { const result = runCompute(startCaseInternalContactsHelper, { state: { constants: { - PARTY_TYPES: ContactFactory.PARTY_TYPES, + PARTY_TYPES: PARTY_TYPES, }, form: { - partyType: ContactFactory.PARTY_TYPES.nextFriendForIncompetentPerson, + partyType: PARTY_TYPES.nextFriendForIncompetentPerson, }, }, }); @@ -171,10 +171,10 @@ describe('startCaseInternalContactsHelper', () => { const result = runCompute(startCaseInternalContactsHelper, { state: { constants: { - PARTY_TYPES: ContactFactory.PARTY_TYPES, + PARTY_TYPES: PARTY_TYPES, }, form: { - partyType: ContactFactory.PARTY_TYPES.nextFriendForMinor, + partyType: PARTY_TYPES.nextFriendForMinor, }, }, }); @@ -192,10 +192,10 @@ describe('startCaseInternalContactsHelper', () => { const result = runCompute(startCaseInternalContactsHelper, { state: { constants: { - PARTY_TYPES: ContactFactory.PARTY_TYPES, + PARTY_TYPES: PARTY_TYPES, }, form: { - partyType: ContactFactory.PARTY_TYPES.partnershipBBA, + partyType: PARTY_TYPES.partnershipBBA, }, }, }); @@ -213,10 +213,10 @@ describe('startCaseInternalContactsHelper', () => { const result = runCompute(startCaseInternalContactsHelper, { state: { constants: { - PARTY_TYPES: ContactFactory.PARTY_TYPES, + PARTY_TYPES: PARTY_TYPES, }, form: { - partyType: ContactFactory.PARTY_TYPES.partnershipOtherThanTaxMatters, + partyType: PARTY_TYPES.partnershipOtherThanTaxMatters, }, }, }); @@ -234,10 +234,10 @@ describe('startCaseInternalContactsHelper', () => { const result = runCompute(startCaseInternalContactsHelper, { state: { constants: { - PARTY_TYPES: ContactFactory.PARTY_TYPES, + PARTY_TYPES: PARTY_TYPES, }, form: { - partyType: ContactFactory.PARTY_TYPES.partnershipAsTaxMattersPartner, + partyType: PARTY_TYPES.partnershipAsTaxMattersPartner, }, }, }); @@ -255,10 +255,10 @@ describe('startCaseInternalContactsHelper', () => { const result = runCompute(startCaseInternalContactsHelper, { state: { constants: { - PARTY_TYPES: ContactFactory.PARTY_TYPES, + PARTY_TYPES: PARTY_TYPES, }, form: { - partyType: ContactFactory.PARTY_TYPES.petitioner, + partyType: PARTY_TYPES.petitioner, }, }, }); @@ -274,10 +274,10 @@ describe('startCaseInternalContactsHelper', () => { const result = runCompute(startCaseInternalContactsHelper, { state: { constants: { - PARTY_TYPES: ContactFactory.PARTY_TYPES, + PARTY_TYPES: PARTY_TYPES, }, form: { - partyType: ContactFactory.PARTY_TYPES.petitionerSpouse, + partyType: PARTY_TYPES.petitionerSpouse, }, }, }); @@ -299,10 +299,10 @@ describe('startCaseInternalContactsHelper', () => { const result = runCompute(startCaseInternalContactsHelper, { state: { constants: { - PARTY_TYPES: ContactFactory.PARTY_TYPES, + PARTY_TYPES: PARTY_TYPES, }, form: { - partyType: ContactFactory.PARTY_TYPES.petitionerDeceasedSpouse, + partyType: PARTY_TYPES.petitionerDeceasedSpouse, }, }, }); @@ -322,10 +322,10 @@ describe('startCaseInternalContactsHelper', () => { const result = runCompute(startCaseInternalContactsHelper, { state: { constants: { - PARTY_TYPES: ContactFactory.PARTY_TYPES, + PARTY_TYPES: PARTY_TYPES, }, form: { - partyType: ContactFactory.PARTY_TYPES.survivingSpouse, + partyType: PARTY_TYPES.survivingSpouse, }, }, }); @@ -343,10 +343,10 @@ describe('startCaseInternalContactsHelper', () => { const result = runCompute(startCaseInternalContactsHelper, { state: { constants: { - PARTY_TYPES: ContactFactory.PARTY_TYPES, + PARTY_TYPES: PARTY_TYPES, }, form: { - partyType: ContactFactory.PARTY_TYPES.transferee, + partyType: PARTY_TYPES.transferee, }, }, }); @@ -362,10 +362,10 @@ describe('startCaseInternalContactsHelper', () => { const result = runCompute(startCaseInternalContactsHelper, { state: { constants: { - PARTY_TYPES: ContactFactory.PARTY_TYPES, + PARTY_TYPES: PARTY_TYPES, }, form: { - partyType: ContactFactory.PARTY_TYPES.trust, + partyType: PARTY_TYPES.trust, }, }, }); diff --git a/web-client/src/presenter/computeds/startCaseInternalHelper.test.js b/web-client/src/presenter/computeds/startCaseInternalHelper.test.js index d0667fa84b8..d1b80c6bb8c 100644 --- a/web-client/src/presenter/computeds/startCaseInternalHelper.test.js +++ b/web-client/src/presenter/computeds/startCaseInternalHelper.test.js @@ -1,4 +1,4 @@ -import { ContactFactory } from '../../../../shared/src/business/entities/contacts/ContactFactory'; +import { PARTY_TYPES } from '../../../../shared/src/business/entities/EntityConstants'; import { applicationContext } from '../../applicationContext'; import { runCompute } from 'cerebral/test'; import { startCaseInternalHelper as startCaseInternalHelperComputed } from './startCaseInternalHelper'; @@ -21,7 +21,7 @@ describe('case detail edit computed', () => { const result = runCompute(startCaseInternalHelper, { state: { form: { - partyType: ContactFactory.PARTY_TYPES.conservator, + partyType: PARTY_TYPES.conservator, }, }, }); @@ -33,7 +33,7 @@ describe('case detail edit computed', () => { const result = runCompute(startCaseInternalHelper, { state: { form: { - partyType: ContactFactory.PARTY_TYPES.corporation, + partyType: PARTY_TYPES.corporation, }, }, }); @@ -45,7 +45,7 @@ describe('case detail edit computed', () => { const result = runCompute(startCaseInternalHelper, { state: { form: { - partyType: ContactFactory.PARTY_TYPES.custodian, + partyType: PARTY_TYPES.custodian, }, }, }); @@ -57,7 +57,7 @@ describe('case detail edit computed', () => { const result = runCompute(startCaseInternalHelper, { state: { form: { - partyType: ContactFactory.PARTY_TYPES.donor, + partyType: PARTY_TYPES.donor, }, }, }); @@ -69,7 +69,7 @@ describe('case detail edit computed', () => { const result = runCompute(startCaseInternalHelper, { state: { form: { - partyType: ContactFactory.PARTY_TYPES.estate, + partyType: PARTY_TYPES.estate, }, }, }); @@ -81,7 +81,7 @@ describe('case detail edit computed', () => { const result = runCompute(startCaseInternalHelper, { state: { form: { - partyType: ContactFactory.PARTY_TYPES.estateWithoutExecutor, + partyType: PARTY_TYPES.estateWithoutExecutor, }, }, }); @@ -93,7 +93,7 @@ describe('case detail edit computed', () => { const result = runCompute(startCaseInternalHelper, { state: { form: { - partyType: ContactFactory.PARTY_TYPES.guardian, + partyType: PARTY_TYPES.guardian, }, }, }); @@ -105,7 +105,7 @@ describe('case detail edit computed', () => { const result = runCompute(startCaseInternalHelper, { state: { form: { - partyType: ContactFactory.PARTY_TYPES.nextFriendForIncompetentPerson, + partyType: PARTY_TYPES.nextFriendForIncompetentPerson, }, }, }); @@ -117,7 +117,7 @@ describe('case detail edit computed', () => { const result = runCompute(startCaseInternalHelper, { state: { form: { - partyType: ContactFactory.PARTY_TYPES.nextFriendForMinor, + partyType: PARTY_TYPES.nextFriendForMinor, }, }, }); @@ -129,7 +129,7 @@ describe('case detail edit computed', () => { const result = runCompute(startCaseInternalHelper, { state: { form: { - partyType: ContactFactory.PARTY_TYPES.partnershipAsTaxMattersPartner, + partyType: PARTY_TYPES.partnershipAsTaxMattersPartner, }, }, }); @@ -141,7 +141,7 @@ describe('case detail edit computed', () => { const result = runCompute(startCaseInternalHelper, { state: { form: { - partyType: ContactFactory.PARTY_TYPES.partnershipBBA, + partyType: PARTY_TYPES.partnershipBBA, }, }, }); @@ -153,7 +153,7 @@ describe('case detail edit computed', () => { const result = runCompute(startCaseInternalHelper, { state: { form: { - partyType: ContactFactory.PARTY_TYPES.partnershipOtherThanTaxMatters, + partyType: PARTY_TYPES.partnershipOtherThanTaxMatters, }, }, }); @@ -165,7 +165,7 @@ describe('case detail edit computed', () => { const result = runCompute(startCaseInternalHelper, { state: { form: { - partyType: ContactFactory.PARTY_TYPES.petitioner, + partyType: PARTY_TYPES.petitioner, }, }, }); @@ -177,7 +177,7 @@ describe('case detail edit computed', () => { const result = runCompute(startCaseInternalHelper, { state: { form: { - partyType: ContactFactory.PARTY_TYPES.petitionerDeceasedSpouse, + partyType: PARTY_TYPES.petitionerDeceasedSpouse, }, }, }); @@ -189,7 +189,7 @@ describe('case detail edit computed', () => { const result = runCompute(startCaseInternalHelper, { state: { form: { - partyType: ContactFactory.PARTY_TYPES.petitionerSpouse, + partyType: PARTY_TYPES.petitionerSpouse, }, }, }); @@ -201,7 +201,7 @@ describe('case detail edit computed', () => { const result = runCompute(startCaseInternalHelper, { state: { form: { - partyType: ContactFactory.PARTY_TYPES.survivingSpouse, + partyType: PARTY_TYPES.survivingSpouse, }, }, }); @@ -213,7 +213,7 @@ describe('case detail edit computed', () => { const result = runCompute(startCaseInternalHelper, { state: { form: { - partyType: ContactFactory.PARTY_TYPES.transferee, + partyType: PARTY_TYPES.transferee, }, }, }); @@ -225,7 +225,7 @@ describe('case detail edit computed', () => { const result = runCompute(startCaseInternalHelper, { state: { form: { - partyType: ContactFactory.PARTY_TYPES.trust, + partyType: PARTY_TYPES.trust, }, }, }); @@ -237,7 +237,7 @@ describe('case detail edit computed', () => { const result = runCompute(startCaseInternalHelper, { state: { form: { - partyType: ContactFactory.PARTY_TYPES.corporation, + partyType: PARTY_TYPES.corporation, }, }, }); @@ -248,7 +248,7 @@ describe('case detail edit computed', () => { const result = runCompute(startCaseInternalHelper, { state: { form: { - partyType: ContactFactory.PARTY_TYPES.petitioner, + partyType: PARTY_TYPES.petitioner, }, }, }); diff --git a/web-client/src/presenter/computeds/statisticsFormHelper.test.js b/web-client/src/presenter/computeds/statisticsFormHelper.test.js index 36554539f80..3065c6f37ff 100644 --- a/web-client/src/presenter/computeds/statisticsFormHelper.test.js +++ b/web-client/src/presenter/computeds/statisticsFormHelper.test.js @@ -1,4 +1,4 @@ -import { Case } from '../../../../shared/src/business/entities/cases/Case'; +import { CASE_TYPES_MAP } from '../../../../shared/src/business/entities/EntityConstants'; import { applicationContextForClient as applicationContext } from '../../../../shared/src/business/test/createTestApplicationContext'; import { runCompute } from 'cerebral/test'; import { statisticsFormHelper as statisticsFormHelperComputed } from './statisticsFormHelper'; @@ -14,7 +14,7 @@ describe('case detail edit computed', () => { const result = runCompute(statisticsFormHelper, { state: { form: { - caseType: Case.CASE_TYPES_MAP.deficiency, + caseType: CASE_TYPES_MAP.deficiency, hasVerifiedIrsNotice: true, }, }, @@ -26,7 +26,7 @@ describe('case detail edit computed', () => { const result = runCompute(statisticsFormHelper, { state: { form: { - caseType: Case.CASE_TYPES_MAP.deficiency, + caseType: CASE_TYPES_MAP.deficiency, hasVerifiedIrsNotice: false, }, }, @@ -38,7 +38,7 @@ describe('case detail edit computed', () => { const result = runCompute(statisticsFormHelper, { state: { form: { - caseType: Case.CASE_TYPES_MAP.cdp, + caseType: CASE_TYPES_MAP.cdp, hasVerifiedIrsNotice: true, }, }, diff --git a/web-client/src/presenter/computeds/statisticsHelper.test.js b/web-client/src/presenter/computeds/statisticsHelper.test.js index 6f26eb6d8fe..aea8c7e47ba 100644 --- a/web-client/src/presenter/computeds/statisticsHelper.test.js +++ b/web-client/src/presenter/computeds/statisticsHelper.test.js @@ -1,4 +1,4 @@ -import { Case } from '../../../../shared/src/business/entities/cases/Case'; +import { CASE_TYPES_MAP } from '../../../../shared/src/business/entities/EntityConstants'; import { applicationContextForClient as applicationContext } from '../../../../shared/src/business/test/createTestApplicationContext'; import { runCompute } from 'cerebral/test'; import { statisticsHelper as statisticsHelperComputed } from './statisticsHelper'; @@ -124,7 +124,7 @@ describe('statisticsHelper', () => { const result = runCompute(statisticsHelper, { state: { caseDetail: { - caseType: Case.CASE_TYPES_MAP.deficiency, + caseType: CASE_TYPES_MAP.deficiency, }, permissions: { ADD_EDIT_STATISTICS: true, @@ -142,7 +142,7 @@ describe('statisticsHelper', () => { const result = runCompute(statisticsHelper, { state: { caseDetail: { - caseType: Case.CASE_TYPES_MAP.deficiency, + caseType: CASE_TYPES_MAP.deficiency, }, permissions: { ADD_EDIT_STATISTICS: false, @@ -160,7 +160,7 @@ describe('statisticsHelper', () => { const result = runCompute(statisticsHelper, { state: { caseDetail: { - caseType: Case.CASE_TYPES_MAP.cdp, + caseType: CASE_TYPES_MAP.cdp, }, permissions: { ADD_EDIT_STATISTICS: true, @@ -180,7 +180,7 @@ describe('statisticsHelper', () => { const result = runCompute(statisticsHelper, { state: { caseDetail: { - caseType: Case.CASE_TYPES_MAP.deficiency, + caseType: CASE_TYPES_MAP.deficiency, statistics: statisticsWithMaxLength, }, permissions: { diff --git a/web-client/src/presenter/computeds/trialSessionHeaderHelper.test.js b/web-client/src/presenter/computeds/trialSessionHeaderHelper.test.js index 89e14f7f11e..bef10694fdf 100644 --- a/web-client/src/presenter/computeds/trialSessionHeaderHelper.test.js +++ b/web-client/src/presenter/computeds/trialSessionHeaderHelper.test.js @@ -1,6 +1,6 @@ +import { ROLES } from '../../../../shared/src/business/entities/EntityConstants'; import { User } from '../../../../shared/src/business/entities/User'; import { runCompute } from 'cerebral/test'; - import { trialSessionHeaderHelper as trialSessionHeaderHelperComputed } from './trialSessionHeaderHelper'; import { withAppContextDecorator } from '../../withAppContext'; @@ -14,7 +14,7 @@ const trialSessionHeaderHelper = withAppContextDecorator( trialSessionHeaderHelperComputed, { getConstants: () => ({ - USER_ROLES: User.ROLES, + USER_ROLES: ROLES, }), getCurrentUser: () => currentUser, getUtilities: () => ({ @@ -29,25 +29,25 @@ const trialSessionHeaderHelper = withAppContextDecorator( const chambersUser = new User({ name: 'Trial Judge Chambers', - role: User.ROLES.chambers, + role: ROLES.chambers, userId: CHAMBERS_USER_ID, }); const judgeUser = new User({ name: 'Trial Judge', - role: User.ROLES.judge, + role: ROLES.judge, userId: JUDGE_USER_ID, }); const trialClerkUser = new User({ name: 'Trial Clerk', - role: User.ROLES.trialClerk, + role: ROLES.trialClerk, userId: TRIAL_CLERK_USER_ID, }); const baseState = { - constants: { USER_ROLES: User.ROLES }, - judgeUser: { role: User.ROLES.judge, userId: JUDGE_USER_ID }, + constants: { USER_ROLES: ROLES }, + judgeUser: { role: ROLES.judge, userId: JUDGE_USER_ID }, }; describe('trial session helper computed', () => { diff --git a/web-client/src/presenter/computeds/trialSessionWorkingCopyHelper.test.js b/web-client/src/presenter/computeds/trialSessionWorkingCopyHelper.test.js index 9ed2a4d6d21..fb7008e6baa 100644 --- a/web-client/src/presenter/computeds/trialSessionWorkingCopyHelper.test.js +++ b/web-client/src/presenter/computeds/trialSessionWorkingCopyHelper.test.js @@ -1,6 +1,9 @@ -import { Case } from '../../../../shared/src/business/entities/cases/Case'; +import { + CASE_STATUS_TYPES, + STATUS_TYPES, + TRIAL_STATUS_TYPES, +} from '../../../../shared/src/business/entities/EntityConstants'; import { MOCK_CASE } from '../../../../shared/src/test/mockCase'; -import { TrialSessionWorkingCopy } from '../../../../shared/src/business/entities/trialSessions/TrialSessionWorkingCopy'; import { applicationContext } from '../../applicationContext'; import { runCompute } from 'cerebral/test'; import { trialSessionWorkingCopyHelper as trialSessionWorkingCopyHelperComputed } from './trialSessionWorkingCopyHelper'; @@ -363,22 +366,22 @@ describe('trial session working copy computed', () => { { ...MOCK_CASE, docketNumber: '102-19', - status: Case.STATUS_TYPES.closed, + status: CASE_STATUS_TYPES.closed, }, { ...MOCK_CASE, docketNumber: '5000-17', - status: Case.STATUS_TYPES.closed, + status: CASE_STATUS_TYPES.closed, }, { ...MOCK_CASE, docketNumber: '500-17', - status: Case.STATUS_TYPES.closed, + status: CASE_STATUS_TYPES.closed, }, { ...MOCK_CASE, docketNumber: '90-07', - status: Case.STATUS_TYPES.closed, + status: CASE_STATUS_TYPES.closed, }, ], }, @@ -399,8 +402,8 @@ describe('trial session working copy computed', () => { let result = runCompute(trialSessionWorkingCopyHelper, { state: { constants: { - STATUS_TYPES: Case.STATUS_TYPES, - TRIAL_STATUS_TYPES: TrialSessionWorkingCopy.TRIAL_STATUS_TYPES, + STATUS_TYPES, + TRIAL_STATUS_TYPES, }, trialSession: { ...TRIAL_SESSION, diff --git a/web-client/src/presenter/computeds/trialSessionsHelper.test.js b/web-client/src/presenter/computeds/trialSessionsHelper.test.js index ab4e77e2cee..8c155bbe759 100644 --- a/web-client/src/presenter/computeds/trialSessionsHelper.test.js +++ b/web-client/src/presenter/computeds/trialSessionsHelper.test.js @@ -1,10 +1,10 @@ -import { User } from '../../../../shared/src/business/entities/User'; +import { ROLES } from '../../../../shared/src/business/entities/EntityConstants'; import { runCompute } from 'cerebral/test'; import { trialSessionsHelper as trialSessionsHelperComputed } from './trialSessionsHelper'; import { withAppContextDecorator } from '../../withAppContext'; let currentUser = { - role: User.ROLES.judge, + role: ROLES.judge, userId: '9d7fd667-42a4-4bd0-9ec7-89d2673cf8b1', }; diff --git a/web-client/src/presenter/computeds/trialSessionsSummaryHelper.test.js b/web-client/src/presenter/computeds/trialSessionsSummaryHelper.test.js index 198561513b1..af830d58cf1 100644 --- a/web-client/src/presenter/computeds/trialSessionsSummaryHelper.test.js +++ b/web-client/src/presenter/computeds/trialSessionsSummaryHelper.test.js @@ -1,4 +1,4 @@ -import { User } from '../../../../shared/src/business/entities/User'; +import { ROLES } from '../../../../shared/src/business/entities/EntityConstants'; import { runCompute } from 'cerebral/test'; import { trialSessionsSummaryHelper as trialSessionsSummaryHelperComputed } from './trialSessionsSummaryHelper'; import { withAppContextDecorator } from '../../withAppContext'; @@ -12,7 +12,7 @@ const trialSessionsSummaryHelper = withAppContextDecorator( trialSessionsSummaryHelperComputed, { getConstants: () => ({ - USER_ROLES: User.ROLES, + USER_ROLES: ROLES, }), getCurrentUser: () => currentUser, }, @@ -21,7 +21,7 @@ const trialSessionsSummaryHelper = withAppContextDecorator( describe('trialSessionsSummaryHelper', () => { beforeEach(() => { currentUser = { - role: User.ROLES.judge, + role: ROLES.judge, userId: judgeId, }; }); @@ -36,14 +36,14 @@ describe('trialSessionsSummaryHelper', () => { it('should return the judeUserId as the chambers judge associated with the logged in user', () => { currentUser = { - role: User.ROLES.chambers, + role: ROLES.chambers, userId: chambersId, }; const result = runCompute(trialSessionsSummaryHelper, { state: { judgeUser: { - role: User.ROLES.judge, + role: ROLES.judge, userId: judgeId, }, }, diff --git a/web-client/src/presenter/computeds/updateCaseModalHelper.test.js b/web-client/src/presenter/computeds/updateCaseModalHelper.test.js index 10cbcf1ecef..a8ed5fa8102 100644 --- a/web-client/src/presenter/computeds/updateCaseModalHelper.test.js +++ b/web-client/src/presenter/computeds/updateCaseModalHelper.test.js @@ -1,4 +1,7 @@ -import { Case } from '../../../../shared/src/business/entities/cases/Case'; +import { + CASE_STATUS_TYPES, + STATUS_TYPES_MANUAL_UPDATE, +} from '../../../../shared/src/business/entities/EntityConstants'; import { applicationContext } from '../../applicationContext'; import { runCompute } from 'cerebral/test'; import { updateCaseModalHelper as updateCaseModalHelperComputed } from './updateCaseModalHelper'; @@ -15,7 +18,7 @@ describe('updateCaseModalHelper', () => { beforeEach(() => { mockCase = { caseId: '123', - status: Case.STATUS_TYPES.new, + status: CASE_STATUS_TYPES.new, }; }); @@ -24,7 +27,7 @@ describe('updateCaseModalHelper', () => { state: { caseDetail: mockCase, modal: { - caseStatus: Case.STATUS_TYPES.submitted, + caseStatus: CASE_STATUS_TYPES.submitted, }, }, }); @@ -36,7 +39,7 @@ describe('updateCaseModalHelper', () => { state: { caseDetail: mockCase, modal: { - caseStatus: Case.STATUS_TYPES.new, + caseStatus: CASE_STATUS_TYPES.new, }, }, }); @@ -46,7 +49,7 @@ describe('updateCaseModalHelper', () => { it('returns showCalendaredAlert true if the case is currently calendared', () => { const result = runCompute(updateCaseModalHelper, { state: { - caseDetail: { ...mockCase, status: Case.STATUS_TYPES.calendared }, + caseDetail: { ...mockCase, status: CASE_STATUS_TYPES.calendared }, }, }); expect(result.showCalendaredAlert).toBeTruthy(); @@ -58,6 +61,6 @@ describe('updateCaseModalHelper', () => { caseDetail: mockCase, }, }); - expect(result.caseStatusOptions).toEqual(Case.STATUS_TYPES_MANUAL_UPDATE); + expect(result.caseStatusOptions).toEqual(STATUS_TYPES_MANUAL_UPDATE); }); }); diff --git a/web-client/src/presenter/computeds/workQueueHelper.test.js b/web-client/src/presenter/computeds/workQueueHelper.test.js index cf773424b16..ea56b6a618a 100644 --- a/web-client/src/presenter/computeds/workQueueHelper.test.js +++ b/web-client/src/presenter/computeds/workQueueHelper.test.js @@ -1,4 +1,4 @@ -import { User } from '../../../../shared/src/business/entities/User'; +import { ROLES } from '../../../../shared/src/business/entities/EntityConstants'; import { applicationContext } from '../../applicationContext'; import { getUserPermissions } from '../../../../shared/src/authorization/getUserPermissions'; import { runCompute } from 'cerebral/test'; @@ -24,7 +24,7 @@ const getBaseState = user => { describe('workQueueHelper', () => { it('returns the expected state when selected work items are set', () => { const user = { - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: '9d7fd667-42a4-4bd0-9ec7-89d2673cf8b1', }; const result = runCompute(workQueueHelper, { @@ -50,7 +50,7 @@ describe('workQueueHelper', () => { it('returns the expected state when selected work items are not set', () => { const user = { - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: '9d7fd667-42a4-4bd0-9ec7-89d2673cf8b1', }; const result = runCompute(workQueueHelper, { @@ -76,7 +76,7 @@ describe('workQueueHelper', () => { it('returns My Messages for workQueueTitle if showing individual internal work queue', () => { const user = { - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: '9d7fd667-42a4-4bd0-9ec7-89d2673cf8b1', }; const result = runCompute(workQueueHelper, { @@ -100,7 +100,7 @@ describe('workQueueHelper', () => { it('returns Section Messages for workQueueTitle if showing section internal work queue', () => { const user = { - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: '9d7fd667-42a4-4bd0-9ec7-89d2673cf8b1', }; const result = runCompute(workQueueHelper, { @@ -124,7 +124,7 @@ describe('workQueueHelper', () => { it('returns My Document QC for workQueueTitle if showing individual non-internal work queue', () => { const user = { - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: '9d7fd667-42a4-4bd0-9ec7-89d2673cf8b1', }; const result = runCompute(workQueueHelper, { @@ -148,7 +148,7 @@ describe('workQueueHelper', () => { it('returns Document QC for workQueueTitle if showing section non-internal work queue and current user is not a docket or petitions clerk', () => { const user = { - role: User.ROLES.adc, + role: ROLES.adc, userId: '9d7fd667-42a4-4bd0-9ec7-89d2673cf8b1', }; const result = runCompute(workQueueHelper, { @@ -172,7 +172,7 @@ describe('workQueueHelper', () => { it('returns Section Document QC for workQueueTitle if showing section non-internal work queue and current user is a docket clerk', () => { const user = { - role: User.ROLES.docketClerk, + role: ROLES.docketClerk, userId: '9d7fd667-42a4-4bd0-9ec7-89d2673cf8b1', }; const result = runCompute(workQueueHelper, { @@ -196,7 +196,7 @@ describe('workQueueHelper', () => { it('shows the start a case button when role is petitions clerk', () => { const user = { - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: '9d7fd667-42a4-4bd0-9ec7-89d2673cf8b1', }; const result = runCompute(workQueueHelper, { @@ -217,7 +217,7 @@ describe('workQueueHelper', () => { it('does not show the start a case button when role is docket clerk', () => { const user = { - role: User.ROLES.docketClerk, + role: ROLES.docketClerk, userId: '9d7fd667-42a4-4bd0-9ec7-89d2673cf8b1', }; const result = runCompute(workQueueHelper, { @@ -238,7 +238,7 @@ describe('workQueueHelper', () => { it('shows the case status column when role is judge', () => { const user = { - role: User.ROLES.judge, + role: ROLES.judge, userId: '9d7fd667-42a4-4bd0-9ec7-89d2673cf8b1', }; const result = runCompute(workQueueHelper, { @@ -257,7 +257,7 @@ describe('workQueueHelper', () => { it('shows the case status column when role is chambers', () => { const user = { - role: User.ROLES.chambers, + role: ROLES.chambers, userId: '9d7fd667-42a4-4bd0-9ec7-89d2673cf8b1', }; const result = runCompute(workQueueHelper, { @@ -276,7 +276,7 @@ describe('workQueueHelper', () => { it('shows the from column when role is judge', () => { const user = { - role: User.ROLES.judge, + role: ROLES.judge, userId: '9d7fd667-42a4-4bd0-9ec7-89d2673cf8b1', }; const result = runCompute(workQueueHelper, { @@ -295,7 +295,7 @@ describe('workQueueHelper', () => { it('shows the from column when role is chambers', () => { const user = { - role: User.ROLES.chambers, + role: ROLES.chambers, userId: '9d7fd667-42a4-4bd0-9ec7-89d2673cf8b1', }; const result = runCompute(workQueueHelper, { @@ -314,7 +314,7 @@ describe('workQueueHelper', () => { it('shows "Received" as filed label on messages inbox', () => { const user = { - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: '9d7fd667-42a4-4bd0-9ec7-89d2673cf8b1', }; const result = runCompute(workQueueHelper, { @@ -337,7 +337,7 @@ describe('workQueueHelper', () => { it('shows in progress petitions for a petitionsclerk', () => { const user = { - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, userId: '9d7fd667-42a4-4bd0-9ec7-89d2673cf8b1', }; const result = runCompute(workQueueHelper, { diff --git a/web-client/src/presenter/errors/ErrorFactory.js b/web-client/src/presenter/errors/ErrorFactory.js index 62322197e9a..6908d5aeb86 100644 --- a/web-client/src/presenter/errors/ErrorFactory.js +++ b/web-client/src/presenter/errors/ErrorFactory.js @@ -22,7 +22,6 @@ export const ErrorFactory = { newError = new ServerInvalidResponseError(e); } else if (!e.response) { // this should only happen if cognito throws a cors exception due to expired tokens or invalid tokens - console.log('e', e); newError = new UnidentifiedUserError(e); } newError.originalError = e; diff --git a/web-client/src/presenter/presenter-public.js b/web-client/src/presenter/presenter-public.js index b55a34f7991..cc29279a380 100644 --- a/web-client/src/presenter/presenter-public.js +++ b/web-client/src/presenter/presenter-public.js @@ -7,6 +7,7 @@ import { clearPdfPreviewUrlSequence } from './sequences/clearPdfPreviewUrlSequen import { gotoPublicCaseDetailSequence } from './sequences/public/gotoPublicCaseDetailSequence'; import { gotoPublicPrintableDocketRecordSequence } from './sequences/public/gotoPublicPrintableDocketRecordSequence'; import { gotoPublicSearchSequence } from './sequences/public/gotoPublicSearchSequence'; +import { gotoTodaysOpinionsSequence } from './sequences/public/gotoTodaysOpinionsSequence'; import { navigateBackSequence } from './sequences/navigateBackSequence'; import { navigateToCognitoSequence } from './sequences/navigateToCognitoSequence'; import { navigateToPublicSiteSequence } from './sequences/public/navigateToPublicSiteSequence'; @@ -37,6 +38,7 @@ export const presenter = { gotoPublicCaseDetailSequence, gotoPublicPrintableDocketRecordSequence, gotoPublicSearchSequence, + gotoTodaysOpinionsSequence, navigateBackSequence, navigateToCognitoSequence, navigateToPublicSiteSequence, diff --git a/web-client/src/presenter/presenter.js b/web-client/src/presenter/presenter.js index 192658069ef..7492323a7b2 100644 --- a/web-client/src/presenter/presenter.js +++ b/web-client/src/presenter/presenter.js @@ -54,6 +54,7 @@ import { convertHtml2PdfSequence } from './sequences/convertHtml2PdfSequence'; import { copyPrimaryContactSequence } from './sequences/copyPrimaryContactSequence'; import { countryTypeUserContactChangeSequence } from './sequences/countryTypeUserContactChangeSequence'; import { createCaseDeadlineSequence } from './sequences/createCaseDeadlineSequence'; +import { createCaseMessageSequence } from './sequences/createCaseMessageSequence'; import { createWorkItemSequence } from './sequences/createWorkItemSequence'; import { deleteCaseDeadlineSequence } from './sequences/deleteCaseDeadlineSequence'; import { deleteCaseNoteSequence } from './sequences/deleteCaseNoteSequence'; @@ -91,6 +92,7 @@ import { gotoBeforeYouFileDocumentSequence } from './sequences/gotoBeforeYouFile import { gotoBlockedCasesReportSequence } from './sequences/gotoBlockedCasesReportSequence'; import { gotoCaseDetailSequence } from './sequences/gotoCaseDetailSequence'; import { gotoCaseInventoryReportSequence } from './sequences/gotoCaseInventoryReportSequence'; +import { gotoCaseMessagesSequence } from './sequences/gotoCaseMessagesSequence'; import { gotoCaseSearchNoMatchesSequence } from './sequences/gotoCaseSearchNoMatchesSequence'; import { gotoCompleteDocketEntrySequence } from './sequences/gotoCompleteDocketEntrySequence'; import { gotoCreateOrderSequence } from './sequences/gotoCreateOrderSequence'; @@ -113,6 +115,7 @@ import { gotoFileDocumentSequence } from './sequences/gotoFileDocumentSequence'; import { gotoFilePetitionSuccessSequence } from './sequences/gotoFilePetitionSuccessSequence'; import { gotoIdleLogoutSequence } from './sequences/gotoIdleLogoutSequence'; import { gotoLoginSequence } from './sequences/gotoLoginSequence'; +import { gotoMessageDetailSequence } from './sequences/gotoMessageDetailSequence'; import { gotoMessagesSequence } from './sequences/gotoMessagesSequence'; import { gotoPdfPreviewSequence } from './sequences/gotoPdfPreviewSequence'; import { gotoPendingReportSequence } from './sequences/gotoPendingReportSequence'; @@ -182,6 +185,7 @@ import { openConfirmRemoveCaseDetailPendingItemModalSequence } from './sequences import { openConfirmRescanBatchModalSequence } from './sequences/openConfirmRescanBatchModalSequence'; import { openConfirmServeToIrsModalSequence } from './sequences/openConfirmServeToIrsModalSequence'; import { openCreateCaseDeadlineModalSequence } from './sequences/openCreateCaseDeadlineModalSequence'; +import { openCreateCaseMessageModalSequence } from './sequences/openCreateCaseMessageModalSequence'; import { openCreateMessageAlongsideDocketRecordQCModalSequence } from './sequences/openCreateMessageAlongsideDocketRecordQCModalSequence'; import { openCreateMessageModalSequence } from './sequences/openCreateMessageModalSequence'; import { openCreateOrderChooseTypeModalSequence } from './sequences/openCreateOrderChooseTypeModalSequence'; @@ -236,6 +240,7 @@ import { serveCaseToIrsSequence } from './sequences/serveCaseToIrsSequence'; import { serveCourtIssuedDocumentSequence } from './sequences/serveCourtIssuedDocumentSequence'; import { setCaseDetailPageTabSequence } from './sequences/setCaseDetailPageTabSequence'; import { setCaseDetailPrimaryTabSequence } from './sequences/setCaseDetailPrimaryTabSequence'; +import { setCaseTypeToDisplaySequence } from './sequences/setCaseTypeToDisplaySequence'; import { setCurrentPageErrorSequence } from './sequences/setCurrentPageErrorSequence'; import { setCurrentPageIndexSequence } from './sequences/setCurrentPageIndexSequence'; import { setDocumentForUploadSequence } from './sequences/setDocumentForUploadSequence'; @@ -255,6 +260,8 @@ import { setWorkItemActionSequence } from './sequences/setWorkItemActionSequence import { setWorkQueueIsInternalSequence } from './sequences/setWorkQueueIsInternalSequence'; import { showCalculatePenaltiesModalSequence } from './sequences/showCalculatePenaltiesModalSequence'; import { showDocketRecordDetailModalSequence } from './sequences/showDocketRecordDetailModalSequence'; +import { showMoreClosedCasesSequence } from './sequences/showMoreClosedCasesSequence'; +import { showMoreOpenCasesSequence } from './sequences/showMoreOpenCasesSequence'; import { showMoreResultsSequence } from './sequences/showMoreResultsSequence'; import { signOutSequence } from './sequences/signOutSequence'; import { startScanSequence } from './sequences/startScanSequence'; @@ -318,6 +325,8 @@ import { updateCaseNoteSequence } from './sequences/updateCaseNoteSequence'; import { updateCasePartyTypeSequence } from './sequences/updateCasePartyTypeSequence'; import { updateCompleteFormValueSequence } from './sequences/updateCompleteFormValueSequence'; import { updateCourtIssuedDocketEntryFormValueSequence } from './sequences/updateCourtIssuedDocketEntryFormValueSequence'; +import { updateCreateCaseMessageAttachmentsSequence } from './sequences/updateCreateCaseMessageAttachmentsSequence'; +import { updateCreateCaseMessageValueInModalSequence } from './sequences/updateCreateCaseMessageValueInModalSequence'; import { updateCreateOrderModalFormValueSequence } from './sequences/updateCreateOrderModalFormValueSequence'; import { updateDocketEntryFormValueSequence } from './sequences/updateDocketEntryFormValueSequence'; import { updateDocketEntryMetaDocumentFormValueSequence } from './sequences/updateDocketEntryMetaDocumentFormValueSequence'; @@ -363,6 +372,7 @@ import { validateCaseDetailSequence } from './sequences/validateCaseDetailSequen import { validateCaseDocketNumberSearchFormSequence } from './sequences/validateCaseDocketNumberSearchFormSequence'; import { validateCaseInventoryReportModalSequence } from './sequences/validateCaseInventoryReportModalSequence'; import { validateCourtIssuedDocketEntrySequence } from './sequences/validateCourtIssuedDocketEntrySequence'; +import { validateCreateCaseMessageInModalSequence } from './sequences/validateCreateCaseMessageInModalSequence'; import { validateDocketEntrySequence } from './sequences/validateDocketEntrySequence'; import { validateDocketRecordSequence } from './sequences/validateDocketRecordSequence'; import { validateEditIrsPractitionersSequence } from './sequences/caseAssociation/validateEditIrsPractitionersSequence'; @@ -458,6 +468,7 @@ export const presenter = { copyPrimaryContactSequence, countryTypeUserContactChangeSequence, createCaseDeadlineSequence, + createCaseMessageSequence, createWorkItemSequence, deleteCaseDeadlineSequence, deleteCaseNoteSequence, @@ -495,6 +506,7 @@ export const presenter = { gotoBlockedCasesReportSequence, gotoCaseDetailSequence, gotoCaseInventoryReportSequence, + gotoCaseMessagesSequence, gotoCaseSearchNoMatchesSequence, gotoCompleteDocketEntrySequence, gotoCreateOrderSequence, @@ -517,6 +529,7 @@ export const presenter = { gotoFilePetitionSuccessSequence, gotoIdleLogoutSequence, gotoLoginSequence, + gotoMessageDetailSequence, gotoMessagesSequence, gotoPdfPreviewSequence, gotoPendingReportSequence, @@ -586,6 +599,7 @@ export const presenter = { openConfirmRescanBatchModalSequence, openConfirmServeToIrsModalSequence, openCreateCaseDeadlineModalSequence, + openCreateCaseMessageModalSequence, openCreateMessageAlongsideDocketRecordQCModalSequence, openCreateMessageModalSequence, openCreateOrderChooseTypeModalSequence, @@ -640,6 +654,7 @@ export const presenter = { serveCourtIssuedDocumentSequence, setCaseDetailPageTabSequence, setCaseDetailPrimaryTabSequence, + setCaseTypeToDisplaySequence, setCurrentPageIndexSequence, setDocumentForUploadSequence, setDocumentUploadModeSequence, @@ -658,6 +673,8 @@ export const presenter = { setWorkQueueIsInternalSequence, showCalculatePenaltiesModalSequence, showDocketRecordDetailModalSequence, + showMoreClosedCasesSequence, + showMoreOpenCasesSequence, showMoreResultsSequence, signOutSequence, startScanSequence, @@ -720,6 +737,8 @@ export const presenter = { updateCasePartyTypeSequence, updateCompleteFormValueSequence, updateCourtIssuedDocketEntryFormValueSequence, + updateCreateCaseMessageAttachmentsSequence, + updateCreateCaseMessageValueInModalSequence, updateCreateOrderModalFormValueSequence, updateDocketEntryFormValueSequence, updateDocketEntryMetaDocumentFormValueSequence, @@ -765,6 +784,7 @@ export const presenter = { validateCaseDocketNumberSearchFormSequence, validateCaseInventoryReportModalSequence, validateCourtIssuedDocketEntrySequence, + validateCreateCaseMessageInModalSequence, validateDocketEntrySequence, validateDocketRecordSequence, validateEditIrsPractitionersSequence, diff --git a/web-client/src/presenter/sequences/createCaseMessageSequence.js b/web-client/src/presenter/sequences/createCaseMessageSequence.js new file mode 100644 index 00000000000..132b79ffefb --- /dev/null +++ b/web-client/src/presenter/sequences/createCaseMessageSequence.js @@ -0,0 +1,30 @@ +import { clearAlertsAction } from '../actions/clearAlertsAction'; +import { clearModalAction } from '../actions/clearModalAction'; +import { clearModalStateAction } from '../actions/clearModalStateAction'; +import { clearScreenMetadataAction } from '../actions/clearScreenMetadataAction'; +import { clearUsersAction } from '../actions/clearUsersAction'; +import { createCaseMessageAction } from '../actions/CaseDetail/createCaseMessageAction'; +import { setAlertSuccessAction } from '../actions/setAlertSuccessAction'; +import { setValidationErrorsAction } from '../actions/setValidationErrorsAction'; +import { showProgressSequenceDecorator } from '../utilities/sequenceHelpers'; +import { startShowValidationAction } from '../actions/startShowValidationAction'; +import { stopShowValidationAction } from '../actions/stopShowValidationAction'; +import { validateCreateCaseMessageAction } from '../actions/validateCreateCaseMessageAction'; + +export const createCaseMessageSequence = [ + clearAlertsAction, + startShowValidationAction, + validateCreateCaseMessageAction, + { + error: [setValidationErrorsAction], + success: showProgressSequenceDecorator([ + createCaseMessageAction, + stopShowValidationAction, + setAlertSuccessAction, + clearScreenMetadataAction, + clearUsersAction, + clearModalAction, + clearModalStateAction, + ]), + }, +]; diff --git a/web-client/src/presenter/sequences/getCasesByStatusForUserSequence.js b/web-client/src/presenter/sequences/getCasesByStatusForUserSequence.js index cab4a751a4e..a77a2ac0b5a 100644 --- a/web-client/src/presenter/sequences/getCasesByStatusForUserSequence.js +++ b/web-client/src/presenter/sequences/getCasesByStatusForUserSequence.js @@ -1,8 +1,8 @@ -import { getConsolidatedCasesByUserAction } from '../actions/caseConsolidation/getConsolidatedCasesByUserAction'; +import { getOpenAndClosedCasesByUserAction } from '../actions/caseConsolidation/getOpenAndClosedCasesByUserAction'; import { setCasesAction } from '../actions/setCasesAction'; import { showProgressSequenceDecorator } from '../utilities/sequenceHelpers'; export const getCasesByStatusForUserSequence = showProgressSequenceDecorator([ - getConsolidatedCasesByUserAction, + getOpenAndClosedCasesByUserAction, setCasesAction, ]); diff --git a/web-client/src/presenter/sequences/gotoCaseMessagesSequence.js b/web-client/src/presenter/sequences/gotoCaseMessagesSequence.js new file mode 100644 index 00000000000..6490d81fa2f --- /dev/null +++ b/web-client/src/presenter/sequences/gotoCaseMessagesSequence.js @@ -0,0 +1,34 @@ +import { chooseMessageBoxAction } from '../actions/chooseMessageBoxAction'; +import { clearErrorAlertsAction } from '../actions/clearErrorAlertsAction'; +import { closeMobileMenuAction } from '../actions/closeMobileMenuAction'; +import { getInboxCaseMessagesForSectionAction } from '../actions/getInboxCaseMessagesForSectionAction'; +import { getInboxCaseMessagesForUserAction } from '../actions/getInboxCaseMessagesForUserAction'; +import { getOutboxCaseMessagesForSectionAction } from '../actions/getOutboxCaseMessagesForSectionAction'; +import { getOutboxCaseMessagesForUserAction } from '../actions/getOutboxCaseMessagesForUserAction'; +import { isLoggedInAction } from '../actions/isLoggedInAction'; +import { redirectToCognitoAction } from '../actions/redirectToCognitoAction'; +import { setCaseMessagesAction } from '../actions/setCaseMessagesAction'; +import { setCurrentPageAction } from '../actions/setCurrentPageAction'; + +const goToCaseMessages = [ + setCurrentPageAction('Interstitial'), + closeMobileMenuAction, + clearErrorAlertsAction, + chooseMessageBoxAction, + { + myinbox: [getInboxCaseMessagesForUserAction], + myoutbox: [getOutboxCaseMessagesForUserAction], + sectioninbox: [getInboxCaseMessagesForSectionAction], + sectionoutbox: [getOutboxCaseMessagesForSectionAction], + }, + setCaseMessagesAction, + setCurrentPageAction('CaseMessages'), +]; + +export const gotoCaseMessagesSequence = [ + isLoggedInAction, + { + isLoggedIn: goToCaseMessages, + unauthorized: [redirectToCognitoAction], + }, +]; diff --git a/web-client/src/presenter/sequences/gotoDashboardSequence.js b/web-client/src/presenter/sequences/gotoDashboardSequence.js index 23e32b3cfa7..989aa22db4b 100644 --- a/web-client/src/presenter/sequences/gotoDashboardSequence.js +++ b/web-client/src/presenter/sequences/gotoDashboardSequence.js @@ -1,9 +1,9 @@ import { chooseWorkQueueSequence } from './chooseWorkQueueSequence'; import { clearErrorAlertsAction } from '../actions/clearErrorAlertsAction'; import { closeMobileMenuAction } from '../actions/closeMobileMenuAction'; -import { getConsolidatedCasesByUserAction } from '../actions/caseConsolidation/getConsolidatedCasesByUserAction'; import { getConstants } from '../../getConstants'; import { getJudgeForCurrentUserAction } from '../actions/getJudgeForCurrentUserAction'; +import { getOpenAndClosedCasesByUserAction } from '../actions/caseConsolidation/getOpenAndClosedCasesByUserAction'; import { getTrialSessionsAction } from '../actions/TrialSession/getTrialSessionsAction'; import { getUserAction } from '../actions/getUserAction'; import { isLoggedInAction } from '../actions/isLoggedInAction'; @@ -13,6 +13,7 @@ import { runPathForUserRoleAction } from '../actions/runPathForUserRoleAction'; import { set } from 'cerebral/factories'; import { setCasesAction } from '../actions/setCasesAction'; import { setCurrentPageAction } from '../actions/setCurrentPageAction'; +import { setDefaultCaseTypeToDisplayAction } from '../actions/setDefaultCaseTypeToDisplayAction'; import { setJudgeUserAction } from '../actions/setJudgeUserAction'; import { setMessageInboxPropsAction } from '../actions/setMessageInboxPropsAction'; import { setTrialSessionsAction } from '../actions/TrialSession/setTrialSessionsAction'; @@ -56,7 +57,8 @@ const goToDashboard = [ ], inactivePractitioner: [setCurrentPageAction('DashboardInactive')], irsPractitioner: [ - getConsolidatedCasesByUserAction, + setDefaultCaseTypeToDisplayAction, + getOpenAndClosedCasesByUserAction, setCasesAction, setCurrentPageAction('DashboardRespondent'), ], @@ -69,12 +71,14 @@ const goToDashboard = [ setCurrentPageAction('DashboardJudge'), ], petitioner: [ - getConsolidatedCasesByUserAction, + setDefaultCaseTypeToDisplayAction, + getOpenAndClosedCasesByUserAction, setCasesAction, setCurrentPageAction('DashboardPetitioner'), ], privatePractitioner: [ - getConsolidatedCasesByUserAction, + setDefaultCaseTypeToDisplayAction, + getOpenAndClosedCasesByUserAction, setCasesAction, setCurrentPageAction('DashboardPractitioner'), ], diff --git a/web-client/src/presenter/sequences/gotoMessageDetailSequence.js b/web-client/src/presenter/sequences/gotoMessageDetailSequence.js new file mode 100644 index 00000000000..64eec11e1fd --- /dev/null +++ b/web-client/src/presenter/sequences/gotoMessageDetailSequence.js @@ -0,0 +1,29 @@ +import { clearErrorAlertsAction } from '../actions/clearErrorAlertsAction'; +import { closeMobileMenuAction } from '../actions/closeMobileMenuAction'; +import { getCaseAction } from '../actions/getCaseAction'; +import { getMessageAction } from '../actions/getMessageAction'; +import { isLoggedInAction } from '../actions/isLoggedInAction'; +import { redirectToCognitoAction } from '../actions/redirectToCognitoAction'; +import { setCaseAction } from '../actions/setCaseAction'; +import { setCurrentPageAction } from '../actions/setCurrentPageAction'; +import { setMessageAction } from '../actions/setMessageAction'; +import { showProgressSequenceDecorator } from '../utilities/sequenceHelpers'; + +const gotoMessageDetail = showProgressSequenceDecorator([ + setCurrentPageAction('Interstitial'), + closeMobileMenuAction, + clearErrorAlertsAction, + getCaseAction, + setCaseAction, + getMessageAction, + setMessageAction, + setCurrentPageAction('MessageDetail'), +]); + +export const gotoMessageDetailSequence = [ + isLoggedInAction, + { + isLoggedIn: gotoMessageDetail, + unauthorized: [redirectToCognitoAction], + }, +]; diff --git a/web-client/src/presenter/sequences/gotoRequestAccessSequence.js b/web-client/src/presenter/sequences/gotoRequestAccessSequence.js index ead46f4dde9..9eb735c3f72 100644 --- a/web-client/src/presenter/sequences/gotoRequestAccessSequence.js +++ b/web-client/src/presenter/sequences/gotoRequestAccessSequence.js @@ -12,6 +12,7 @@ import { setCaseAction } from '../actions/setCaseAction'; import { setCaseAssociationAction } from '../actions/setCaseAssociationAction'; import { setCurrentPageAction } from '../actions/setCurrentPageAction'; import { setDefaultFileDocumentFormValuesAction } from '../actions/FileDocument/setDefaultFileDocumentFormValuesAction'; +import { setRequestAccessWizardStepActionGenerator } from '../actions/setRequestAccessWizardStepActionGenerator'; import { state } from 'cerebral'; import { stopShowValidationAction } from '../actions/stopShowValidationAction'; @@ -32,12 +33,12 @@ const gotoRequestAccess = [ { irsPractitioner: [ set(state.form.partyIrsPractitioner, true), - set(state.wizardStep, 'RequestAccess'), + setRequestAccessWizardStepActionGenerator('RequestAccess'), setCurrentPageAction('RequestAccessWizard'), ], privatePractitioner: [ set(state.form.partyPrivatePractitioner, true), - set(state.wizardStep, 'RequestAccess'), + setRequestAccessWizardStepActionGenerator('RequestAccess'), setCurrentPageAction('RequestAccessWizard'), ], }, diff --git a/web-client/src/presenter/sequences/loginWithCodeSequence.test.js b/web-client/src/presenter/sequences/loginWithCodeSequence.test.js index d8854ae7742..b842448bf5a 100644 --- a/web-client/src/presenter/sequences/loginWithCodeSequence.test.js +++ b/web-client/src/presenter/sequences/loginWithCodeSequence.test.js @@ -1,5 +1,5 @@ import { CerebralTest } from 'cerebral/test'; -import { User } from '../../../../shared/src/business/entities/User'; +import { ROLES } from '../../../../shared/src/business/entities/EntityConstants'; import { applicationContextForClient as applicationContext } from '../../../../shared/src/business/test/createTestApplicationContext'; import { loginWithCodeSequence } from '../sequences/loginWithCodeSequence'; import { presenter } from '../presenter-mock'; @@ -12,7 +12,7 @@ describe('loginWithCodeSequence', () => { const NEW_TOKEN = 'eyJraWQiOiJ2U2pTa3FZVkJjVkJOWk5qZ1gzWFNzcERZSjU4QmQ3OGYrSzlDSXhtck44PSIsImFsZyI6IlJTMjU2In0.eyJhdF9oYXNoIjoiRk5mZ2tQZlVmTTBRRWtuak5Ic1lWQSIsInN1YiI6Ijc0YzA2NDBjLTljYjQtNGE0Ny04OWMyLThjOGU5YmFiMmUyNiIsImVtYWlsX3ZlcmlmaWVkIjp0cnVlLCJpc3MiOiJodHRwczpcL1wvY29nbml0by1pZHAudXMtZWFzdC0xLmFtYXpvbmF3cy5jb21cL3VzLWVhc3QtMV83dVJrRjBBeG4iLCJjb2duaXRvOnVzZXJuYW1lIjoiNzRjMDY0MGMtOWNiNC00YTQ3LTg5YzItOGM4ZTliYWIyZTI2IiwiYXVkIjoiNnR1Nmoxc3R2NXVnY3V0N2Rxc3FkdXJuOHEiLCJldmVudF9pZCI6ImQ5MGRjMGJlLTZhYjYtMTFlOS04YWI2LWMzNTYyYjI5YmEwOCIsInRva2VuX3VzZSI6ImlkIiwiYXV0aF90aW1lIjoxNTU2NTY2OTE3LCJuYW1lIjoiVGVzdCBwZXRpdGlvbnNjbGVyazEiLCJleHAiOjE1NTY1NzA1MTcsImN1c3RvbTpyb2xlIjoicGV0aXRpb25zY2xlcmsiLCJpYXQiOjE1NTY1NjY5MTcsImVtYWlsIjoicGV0aXRpb25zY2xlcmsxQGV4YW1wbGUuY29tIn0.mXE2yMgVhP_wHqpohtBHHcmL5WrxXxLB2KzvNMlldLRF-WcuGHIwhL1yXuYCp1Jobi1j823nYeXhAhPF4mzQLB6weXUga3UVT1op-KENSxvpfJJvuty2AGCBcjx6j85UDtA3KE9nx-xqWJkRpVHvfTVezMMc_v3QpmVuiPyfdO1gPCDUNiMpndVrBZW6iA6ANhMsud7IHx3R9ENauoDzohJBl_Zb1O-S34J-JjhbN6_fGKguzW8Hxwb3h-WImF_qZgKsR5B5gMzvhQhMAcSjltZI7a88L2OBwbTZjggxp5RAeju6GT_zY7xC_5vpUnJka8p4NwdLJyATi2GMXTSVDg'; const USER = { - role: User.ROLES.petitionsClerk, + role: ROLES.petitionsClerk, }; beforeAll(() => { applicationContext.getUseCases().authorizeCodeInteractor.mockReturnValue({ diff --git a/web-client/src/presenter/sequences/openCreateCaseMessageModalSequence.js b/web-client/src/presenter/sequences/openCreateCaseMessageModalSequence.js new file mode 100644 index 00000000000..99fba88bde1 --- /dev/null +++ b/web-client/src/presenter/sequences/openCreateCaseMessageModalSequence.js @@ -0,0 +1,12 @@ +import { clearModalStateAction } from '../actions/clearModalStateAction'; +import { setCreateMessageModalDialogModalStateAction } from '../actions/WorkItem/setCreateMessageModalDialogModalStateAction'; +import { setShowModalFactoryAction } from '../actions/setShowModalFactoryAction'; +import { showProgressSequenceDecorator } from '../utilities/sequenceHelpers'; + +export const openCreateCaseMessageModalSequence = showProgressSequenceDecorator( + [ + clearModalStateAction, + setCreateMessageModalDialogModalStateAction, + setShowModalFactoryAction('CreateCaseMessageModal'), + ], +); diff --git a/web-client/src/presenter/sequences/public/gotoTodaysOpinionsSequence.js b/web-client/src/presenter/sequences/public/gotoTodaysOpinionsSequence.js new file mode 100644 index 00000000000..ff5f1b40f35 --- /dev/null +++ b/web-client/src/presenter/sequences/public/gotoTodaysOpinionsSequence.js @@ -0,0 +1,10 @@ +import { getTodaysOpinionsAction } from '../../actions/Public/getTodaysOpinionsAction'; +import { setCurrentPageAction } from '../../actions/setCurrentPageAction'; +import { setTodaysOpinionsAction } from '../../actions/Public/setTodaysOpinionsAction'; +import { showProgressSequenceDecorator } from '../../utilities/sequenceHelpers'; + +export const gotoTodaysOpinionsSequence = showProgressSequenceDecorator([ + getTodaysOpinionsAction, + setTodaysOpinionsAction, + setCurrentPageAction('TodaysOpinions'), +]); diff --git a/web-client/src/presenter/sequences/setCaseTypeToDisplaySequence.js b/web-client/src/presenter/sequences/setCaseTypeToDisplaySequence.js new file mode 100644 index 00000000000..6c56e7c76dc --- /dev/null +++ b/web-client/src/presenter/sequences/setCaseTypeToDisplaySequence.js @@ -0,0 +1,3 @@ +import { setCaseTypeToDisplayAction } from '../actions/setCaseTypeToDisplayAction'; + +export const setCaseTypeToDisplaySequence = [setCaseTypeToDisplayAction]; diff --git a/web-client/src/presenter/sequences/showMoreClosedCasesSequence.js b/web-client/src/presenter/sequences/showMoreClosedCasesSequence.js new file mode 100644 index 00000000000..2fc0d42eaed --- /dev/null +++ b/web-client/src/presenter/sequences/showMoreClosedCasesSequence.js @@ -0,0 +1,5 @@ +import { incrementCurrentPageClosedCasesAction } from '../actions/Dashboard/incrementCurrentPageClosedCasesAction'; + +export const showMoreClosedCasesSequence = [ + incrementCurrentPageClosedCasesAction, +]; diff --git a/web-client/src/presenter/sequences/showMoreOpenCasesSequence.js b/web-client/src/presenter/sequences/showMoreOpenCasesSequence.js new file mode 100644 index 00000000000..e605a4e76f7 --- /dev/null +++ b/web-client/src/presenter/sequences/showMoreOpenCasesSequence.js @@ -0,0 +1,3 @@ +import { incrementCurrentPageOpenCasesAction } from '../actions/Dashboard/incrementCurrentPageOpenCasesAction'; + +export const showMoreOpenCasesSequence = [incrementCurrentPageOpenCasesAction]; diff --git a/web-client/src/presenter/sequences/submitCaseAssociationRequestSequence.js b/web-client/src/presenter/sequences/submitCaseAssociationRequestSequence.js index 6653e71f72c..a1c03366553 100644 --- a/web-client/src/presenter/sequences/submitCaseAssociationRequestSequence.js +++ b/web-client/src/presenter/sequences/submitCaseAssociationRequestSequence.js @@ -10,6 +10,7 @@ import { setPractitionerOnFormAction } from '../actions/FileDocument/setPractiti import { setSaveAlertsForNavigationAction } from '../actions/setSaveAlertsForNavigationAction'; import { showProgressSequenceDecorator } from '../utilities/sequenceHelpers'; import { submitCaseAssociationRequestAction } from '../actions/FileDocument/submitCaseAssociationRequestAction'; +import { unsetRequestAccessWizardStepAction } from '../actions/unsetRequestAccessWizardStepAction'; import { uploadExternalDocumentsAction } from '../actions/FileDocument/uploadExternalDocumentsAction'; export const submitCaseAssociationRequestSequence = [ @@ -24,6 +25,7 @@ export const submitCaseAssociationRequestSequence = [ closeFileUploadStatusModalAction, getPrintableFilingReceiptSequence, getFileExternalDocumentAlertSuccessAction, + unsetRequestAccessWizardStepAction, setAlertSuccessAction, setSaveAlertsForNavigationAction, navigateToCaseDetailAction, diff --git a/web-client/src/presenter/sequences/updateCreateCaseMessageAttachmentsSequence.js b/web-client/src/presenter/sequences/updateCreateCaseMessageAttachmentsSequence.js new file mode 100644 index 00000000000..6a6c7634400 --- /dev/null +++ b/web-client/src/presenter/sequences/updateCreateCaseMessageAttachmentsSequence.js @@ -0,0 +1,5 @@ +import { updateCreateCaseMessageAttachmentsAction } from '../actions/updateCreateCaseMessageAttachmentsAction'; + +export const updateCreateCaseMessageAttachmentsSequence = [ + updateCreateCaseMessageAttachmentsAction, +]; diff --git a/web-client/src/presenter/sequences/updateCreateCaseMessageValueInModalSequence.js b/web-client/src/presenter/sequences/updateCreateCaseMessageValueInModalSequence.js new file mode 100644 index 00000000000..90dec5719d3 --- /dev/null +++ b/web-client/src/presenter/sequences/updateCreateCaseMessageValueInModalSequence.js @@ -0,0 +1,39 @@ +/* eslint-disable sort-keys-fix/sort-keys-fix */ +import { clearUsersAction } from '../actions/clearUsersAction'; +import { getUsersInSectionSequence } from './getUsersInSectionSequence'; +import { isChambersPathAction } from '../actions/ForwardForm/isChambersPathAction'; +import { props, state } from 'cerebral'; +import { runKeyPathAction } from '../actions/runKeyPathAction'; +import { set } from 'cerebral/factories'; + +// TODO: refactor this +export const updateCreateCaseMessageValueInModalSequence = [ + ({ props: sequenceProps }) => ({ + form: 'modal.form', + section: sequenceProps.value, + }), + runKeyPathAction, + { + toSection: [ + isChambersPathAction, + { + yes: [ + set(state.modal.showChambersSelect, true), + set(state.modal.form.toSection, ''), + set(state.modal.form.assigneeId, ''), + clearUsersAction, + ], + no: [ + set(state.modal.showChambersSelect, false), + set(state.modal.form.toSection, props.value), + ...getUsersInSectionSequence, + ], + }, + ], + chambers: [ + set(state.modal.form.toSection, props.value), + ...getUsersInSectionSequence, + ], + default: [set(state.modal.form[props.key], props.value)], + }, +]; diff --git a/web-client/src/presenter/sequences/validateCreateCaseMessageInModalSequence.js b/web-client/src/presenter/sequences/validateCreateCaseMessageInModalSequence.js new file mode 100644 index 00000000000..258cd212ddc --- /dev/null +++ b/web-client/src/presenter/sequences/validateCreateCaseMessageInModalSequence.js @@ -0,0 +1,18 @@ +import { clearAlertsAction } from '../actions/clearAlertsAction'; +import { setValidationErrorsAction } from '../actions/setValidationErrorsAction'; +import { shouldValidateAction } from '../actions/shouldValidateAction'; +import { validateCreateCaseMessageAction } from '../actions/validateCreateCaseMessageAction'; + +export const validateCreateCaseMessageInModalSequence = [ + shouldValidateAction, + { + ignore: [], + validate: [ + validateCreateCaseMessageAction, + { + error: [setValidationErrorsAction], + success: [clearAlertsAction], + }, + ], + }, +]; diff --git a/web-client/src/presenter/state-public.js b/web-client/src/presenter/state-public.js index acce421e64f..18c4b5c8c49 100644 --- a/web-client/src/presenter/state-public.js +++ b/web-client/src/presenter/state-public.js @@ -6,6 +6,7 @@ import { loadingHelper } from './computeds/loadingHelper'; import { publicAlertHelper } from './computeds/public/publicAlertHelper'; import { publicCaseDetailHeaderHelper } from './computeds/public/publicCaseDetailHeaderHelper'; import { publicCaseDetailHelper } from './computeds/public/publicCaseDetailHelper'; +import { todaysOpinionsHelper } from './computeds/public/todaysOpinionsHelper'; const helpers = { advancedDocumentSearchHelper, @@ -15,6 +16,7 @@ const helpers = { menuHelper, publicCaseDetailHeaderHelper, publicCaseDetailHelper, + todaysOpinionsHelper, }; export const state = { @@ -26,12 +28,19 @@ export const state = { showUsaBannerDetails: false, }, currentPage: 'Interstitial', + header: { + searchTerm: '', + showBetaBar: true, + showMobileMenu: false, + showUsaBannerDetails: false, + }, isPublic: true, progressIndicator: { // used for the spinner that shows when waiting for network responses waitingForResponse: false, waitingForResponseRequests: 0, }, + todaysOpinions: [], user: {}, validationErrors: {}, }; diff --git a/web-client/src/presenter/state.js b/web-client/src/presenter/state.js index 140cb6179c3..ad8bed76f76 100644 --- a/web-client/src/presenter/state.js +++ b/web-client/src/presenter/state.js @@ -22,6 +22,7 @@ import { completeDocumentTypeSectionHelper } from './computeds/completeDocumentT import { confirmInitiateServiceModalHelper } from './computeds/confirmInitiateServiceModalHelper'; import { contactEditHelper } from './computeds/contactEditHelper'; import { contactsHelper } from './computeds/contactsHelper'; +import { createCaseMessageModalHelper } from './computeds/createCaseMessageModalHelper'; import { createOrderHelper } from './computeds/createOrderHelper'; import { createPractitionerUserHelper } from './computeds/createPractitionerUserHelper'; import { dashboardExternalHelper } from './computeds/dashboardExternalHelper'; @@ -32,14 +33,18 @@ import { editDocketEntryHelper } from './computeds/editDocketEntryHelper'; import { editDocketEntryMetaHelper } from './computeds/editDocketEntryMetaHelper'; import { editPetitionerInformationHelper } from './computeds/editPetitionerInformationHelper'; import { editStatisticFormHelper } from './computeds/editStatisticFormHelper'; +import { externalUserCasesHelper } from './computeds/Dashboard/externalUserCasesHelper'; import { extractedPendingMessagesFromCaseDetail } from './computeds/extractPendingMessagesFromCaseDetail'; import { fileDocumentHelper } from './computeds/fileDocumentHelper'; import { fileUploadStatusHelper } from './computeds/fileUploadStatusHelper'; import { formattedCaseDetail, - formattedCases, + formattedClosedCases, + formattedOpenCases, } from './computeds/formattedCaseDetail'; import { formattedDashboardTrialSessions } from './computeds/formattedDashboardTrialSessions'; +import { formattedMessageDetail } from './computeds/formattedMessageDetail'; +import { formattedMessages } from './computeds/formattedMessages'; import { formattedPendingItems } from './computeds/formattedPendingItems'; import { formattedTrialSessionDetails } from './computeds/formattedTrialSessionDetails'; import { formattedTrialSessions } from './computeds/formattedTrialSessions'; @@ -49,6 +54,7 @@ import { headerHelper } from './computeds/headerHelper'; import { internalTypesHelper } from './computeds/internalTypesHelper'; import { loadingHelper } from './computeds/loadingHelper'; import { menuHelper } from './computeds/menuHelper'; +import { messagesHelper } from './computeds/messagesHelper'; import { orderTypesHelper } from './computeds/orderTypesHelper'; import { pdfPreviewModalHelper } from './computeds/PDFPreviewModal/pdfPreviewModalHelper'; import { pdfSignerHelper } from './computeds/pdfSignerHelper'; @@ -101,6 +107,7 @@ const helpers = { confirmInitiateServiceModalHelper, contactEditHelper, contactsHelper, + createCaseMessageModalHelper, createOrderHelper, createPractitionerUserHelper, dashboardExternalHelper, @@ -111,12 +118,16 @@ const helpers = { editDocketEntryMetaHelper, editPetitionerInformationHelper, editStatisticFormHelper, + externalUserCasesHelper, extractedPendingMessagesFromCaseDetail, fileDocumentHelper, fileUploadStatusHelper, formattedCaseDetail, - formattedCases, + formattedClosedCases, formattedDashboardTrialSessions, + formattedMessageDetail, + formattedMessages, + formattedOpenCases, formattedPendingItems, formattedTrialSessionDetails, formattedTrialSessions, @@ -126,6 +137,7 @@ const helpers = { internalTypesHelper, loadingHelper, menuHelper, + messagesHelper, orderTypesHelper, pdfPreviewModalHelper, pdfSignerHelper, @@ -165,9 +177,10 @@ export const baseState = { assigneeId: null, // used for assigning workItems in assignSelectedWorkItemsAction batchDownloads: {}, // batch download of PDFs caseDetail: {}, - cases: [], + closedCases: [], cognitoLoginUrl: null, - completeForm: {}, // TODO: replace with state.form + completeForm: {}, + // TODO: replace with state.form currentPage: 'Interstitial', currentViewMetadata: { caseDetail: { @@ -194,16 +207,19 @@ export const baseState = { tab: null, }, }, - docketRecordIndex: 0, // needs its own object because it's present when other forms are on screen + docketRecordIndex: 0, + // needs its own object because it's present when other forms are on screen documentId: null, - fieldOrder: [], // TODO: related to errors + fieldOrder: [], + // TODO: related to errors fileUploadProgress: { // used for the progress bar shown in modal when uploading files isUploading: false, percentComplete: 0, timeRemaining: Number.POSITIVE_INFINITY, }, - form: {}, // shared object for creating new entities, clear before using + form: {}, + // shared object for creating new entities, clear before using header: { searchTerm: '', showBetaBar: true, @@ -216,6 +232,7 @@ export const baseState = { }, navigation: {}, notifications: {}, + openCases: [], pdfForSigning: { documentId: null, nameForSigning: '', diff --git a/web-client/src/presenter/utilities/filterQcItemsByAssociatedJudge.test.js b/web-client/src/presenter/utilities/filterQcItemsByAssociatedJudge.test.js index 2e8e82e4b4a..a3a9c4f06a4 100644 --- a/web-client/src/presenter/utilities/filterQcItemsByAssociatedJudge.test.js +++ b/web-client/src/presenter/utilities/filterQcItemsByAssociatedJudge.test.js @@ -1,5 +1,7 @@ -import { Case } from '../../../../shared/src/business/entities/cases/Case'; -import { User } from '../../../../shared/src/business/entities/User'; +import { + CHIEF_JUDGE, + ROLES, +} from '../../../../shared/src/business/entities/EntityConstants'; import { applicationContextForClient as applicationContext } from '../../../../shared/src/business/test/createTestApplicationContext'; import { filterQcItemsByAssociatedJudge } from './filterQcItemsByAssociatedJudge'; @@ -11,8 +13,8 @@ describe('filterQcItemsByAssociatedJudge', () => { beforeAll(() => { applicationContext.getCurrentUser.mockImplementation(() => currentUser); applicationContext.getConstants.mockReturnValue({ - CHIEF_JUDGE: Case.CHIEF_JUDGE, - USER_ROLES: User.ROLES, + CHIEF_JUDGE: CHIEF_JUDGE, + USER_ROLES: ROLES, }); }); @@ -40,7 +42,7 @@ describe('filterQcItemsByAssociatedJudge', () => { it('returns a pass-through filter if the user is not of the judge, chambers, or adc roles', () => { currentUser = { - role: User.ROLES.docketClerk, + role: ROLES.docketClerk, }; const filterFunction = filterQcItemsByAssociatedJudge({ @@ -56,7 +58,7 @@ describe('filterQcItemsByAssociatedJudge', () => { it('returns a filter for the current judge or chambers user', () => { currentUser = { - role: User.ROLES.chambers, + role: ROLES.chambers, }; judgeUser = { @@ -75,7 +77,7 @@ describe('filterQcItemsByAssociatedJudge', () => { it('returns a filter for the current adc user', () => { currentUser = { - role: User.ROLES.adc, + role: ROLES.adc, }; const filterFunction = filterQcItemsByAssociatedJudge({ diff --git a/web-client/src/router.js b/web-client/src/router.js index f2fc60e379c..53c5237efbf 100644 --- a/web-client/src/router.js +++ b/web-client/src/router.js @@ -979,6 +979,28 @@ const router = { }), ); + registerRoute( + '/case-messages/*/*', + ifHasAccess((queue, box) => { + setPageTitle('Messages'); + return app.getSequence('gotoCaseMessagesSequence')({ + box, + queue, + }); + }), + ); + + registerRoute( + '/case-messages/*/message-detail/*', + ifHasAccess((docketNumber, messageId) => { + setPageTitle('Message detail'); + return app.getSequence('gotoMessageDetailSequence')({ + docketNumber, + messageId, + }); + }), + ); + registerRoute( '/pdf-preview', ifHasAccess(() => { diff --git a/web-client/src/routerPublic.js b/web-client/src/routerPublic.js index bd6cbf51355..176ffc502b6 100644 --- a/web-client/src/routerPublic.js +++ b/web-client/src/routerPublic.js @@ -35,6 +35,11 @@ const router = { }); }); + route('/todays-opinions', () => { + setPageTitle('Today’s Opinions'); + app.getSequence('gotoTodaysOpinionsSequence')(); + }); + route('/', () => { setPageTitle('Dashboard'); app.getSequence('gotoPublicSearchSequence')(); diff --git a/web-client/src/styles/buttons.scss b/web-client/src/styles/buttons.scss index d816fe05d3e..c8cbc973cca 100644 --- a/web-client/src/styles/buttons.scss +++ b/web-client/src/styles/buttons.scss @@ -103,6 +103,10 @@ svg { margin-right: 5px; } + + &.usa-button--unstyled:visited { + color: $color-white; + } } .recall-button-box { diff --git a/web-client/src/styles/custom.scss b/web-client/src/styles/custom.scss index 0e9931508cd..de4b4abf9fd 100644 --- a/web-client/src/styles/custom.scss +++ b/web-client/src/styles/custom.scss @@ -1502,3 +1502,7 @@ button.change-scanner-button { .accordion-item-title { align-self: center; } + +.message-detail--attachments { + height: 1000px; +} diff --git a/web-client/src/styles/menus.scss b/web-client/src/styles/menus.scss index 9f4f2f11f33..4b268ed78b4 100644 --- a/web-client/src/styles/menus.scss +++ b/web-client/src/styles/menus.scss @@ -13,24 +13,31 @@ background-color: $color-white; box-shadow: 3px 9px 9px rgba(0, 0, 0, 0.2); - .usa-nav__submenu-item button { - padding: 0.2rem; - color: color($theme-color-primary); - font-weight: $font-semibold; + .usa-nav__submenu-item { + svg.fa-1x { + width: 16px; + } + + button { + padding: 0.2rem; + color: color($theme-color-primary); + font-weight: $font-semibold; - &:hover { - text-decoration: underline; + &:hover { + text-decoration: underline; + } } - } - .usa-nav__submenu-item a { - padding: 0.2rem; - background-color: $color-white; - color: color($theme-color-primary); - font-size: 0.93rem; - font-weight: $font-semibold; + a { + padding: 0.2rem; + background-color: $color-white; + color: color($theme-color-primary); + font-size: 0.93rem; + font-weight: $font-semibold; + } } + &.position-right-0 { right: 0; } diff --git a/web-client/src/styles/overrides.scss b/web-client/src/styles/overrides.scss index 46a972cd896..e6782ae648d 100644 --- a/web-client/src/styles/overrides.scss +++ b/web-client/src/styles/overrides.scss @@ -95,6 +95,10 @@ option:first-child { margin-bottom: 20px; } +.margin-bottom-20 { + margin-bottom: 20px; +} + .usa-error-message { margin: 15px 0 0 0; font-size: 17px; diff --git a/web-client/src/utilities/getScanModeLabel.test.js b/web-client/src/utilities/getScanModeLabel.test.js index 37e1ef89bbe..194a900a754 100644 --- a/web-client/src/utilities/getScanModeLabel.test.js +++ b/web-client/src/utilities/getScanModeLabel.test.js @@ -1,10 +1,8 @@ -import { Scan } from '../../../shared/src/business/entities/Scan'; +import { SCAN_MODES } from '../../../shared/src/business/entities/EntityConstants'; import { applicationContextForClient as applicationContext } from '../../../shared/src/business/test/createTestApplicationContext'; import { getScanModeLabel } from './getScanModeLabel'; describe('getScanModeLabel', () => { - const { SCAN_MODES } = Scan; - it('Returns Single Sided when the scan mode is feeder', () => { expect(getScanModeLabel(applicationContext, SCAN_MODES.FEEDER)).toEqual( 'Single sided', diff --git a/web-client/src/views/AdvancedSearch/DocumentSearchResults.jsx b/web-client/src/views/AdvancedSearch/DocumentSearchResults.jsx index 9a1777172a4..10ffe8591ef 100644 --- a/web-client/src/views/AdvancedSearch/DocumentSearchResults.jsx +++ b/web-client/src/views/AdvancedSearch/DocumentSearchResults.jsx @@ -9,14 +9,12 @@ export const DocumentSearchResults = connect( { advancedDocumentSearchHelper: state.advancedDocumentSearchHelper, baseUrl: state.baseUrl, - pageSize: state.constants.CASE_SEARCH_PAGE_SIZE, showMoreResultsSequence: sequences.showMoreResultsSequence, token: state.token, }, function DocumentSearchResults({ advancedDocumentSearchHelper, baseUrl, - pageSize, showMoreResultsSequence, token, }) { @@ -92,10 +90,10 @@ export const DocumentSearchResults = connect( {advancedDocumentSearchHelper.showLoadMore && ( )} {advancedDocumentSearchHelper.showNoMatches && ( diff --git a/web-client/src/views/AdvancedSearch/PractitionerSearchResults.jsx b/web-client/src/views/AdvancedSearch/PractitionerSearchResults.jsx index df15ff483de..8a5971fc08a 100644 --- a/web-client/src/views/AdvancedSearch/PractitionerSearchResults.jsx +++ b/web-client/src/views/AdvancedSearch/PractitionerSearchResults.jsx @@ -6,12 +6,10 @@ import React from 'react'; export const PractitionerSearchResults = connect( { advancedSearchHelper: state.advancedSearchHelper, - pageSize: state.constants.CASE_SEARCH_PAGE_SIZE, showMoreResultsSequence: sequences.showMoreResultsSequence, }, function PractitionerSearchResults({ advancedSearchHelper, - pageSize, showMoreResultsSequence, }) { return ( @@ -52,7 +50,7 @@ export const PractitionerSearchResults = connect( )} {advancedSearchHelper.showLoadMore && ( )} {advancedSearchHelper.showNoMatches && ( diff --git a/web-client/src/views/AdvancedSearch/SearchResults.jsx b/web-client/src/views/AdvancedSearch/SearchResults.jsx index 79b53e4e0ab..5428aa59fbf 100644 --- a/web-client/src/views/AdvancedSearch/SearchResults.jsx +++ b/web-client/src/views/AdvancedSearch/SearchResults.jsx @@ -8,14 +8,9 @@ import React from 'react'; export const SearchResults = connect( { advancedSearchHelper: state.advancedSearchHelper, - pageSize: state.constants.CASE_SEARCH_PAGE_SIZE, showMoreResultsSequence: sequences.showMoreResultsSequence, }, - function SearchResults({ - advancedSearchHelper, - pageSize, - showMoreResultsSequence, - }) { + function SearchResults({ advancedSearchHelper, showMoreResultsSequence }) { return ( <> {advancedSearchHelper.showSearchResults && ( @@ -91,7 +86,7 @@ export const SearchResults = connect( )} {advancedSearchHelper.showLoadMore && ( )} {advancedSearchHelper.showNoMatches && ( diff --git a/web-client/src/views/AppComponent.jsx b/web-client/src/views/AppComponent.jsx index 7d2267adee0..4e95b4110d6 100644 --- a/web-client/src/views/AppComponent.jsx +++ b/web-client/src/views/AppComponent.jsx @@ -13,6 +13,7 @@ import { CaseDetail } from './CaseDetail/CaseDetail'; import { CaseDetailInternal } from './CaseDetail/CaseDetailInternal'; import { CaseInventoryReport } from './CaseInventoryReport/CaseInventoryReport'; import { CaseInventoryReportModal } from './CaseInventoryReport/CaseInventoryReportModal'; +import { CaseMessages } from './Messages/CaseMessages'; import { CaseSearchNoMatches } from './CaseSearchNoMatches'; import { CourtIssuedDocketEntry } from './CourtIssuedDocketEntry/CourtIssuedDocketEntry'; import { CreateOrder } from './CreateOrder/CreateOrder'; @@ -45,6 +46,7 @@ import { IdleLogout } from './IdleLogout'; import { Interstitial } from './Interstitial'; import { Loading } from './Loading'; import { LogIn } from './LogIn'; +import { MessageDetail } from './Messages/MessageDetail'; import { Messages } from './Messages/Messages'; import { PendingReport } from './PendingReport/PendingReport'; import { PetitionQc } from './PetitionQc/PetitionQc'; @@ -92,6 +94,7 @@ const pages = { CaseDetail, CaseDetailInternal, CaseInventoryReport, + CaseMessages, CaseSearchNoMatches, CourtIssuedDocketEntry, CreateOrder, @@ -121,6 +124,7 @@ const pages = { Interstitial, Loading, LogIn, + MessageDetail, Messages, PendingReport, PetitionQc, diff --git a/web-client/src/views/AppComponentPublic.jsx b/web-client/src/views/AppComponentPublic.jsx index 22ef69da456..5fbb87c099b 100644 --- a/web-client/src/views/AppComponentPublic.jsx +++ b/web-client/src/views/AppComponentPublic.jsx @@ -6,6 +6,7 @@ import { Loading } from './Loading'; import { PublicCaseDetail } from './Public/PublicCaseDetail'; import { PublicPrintableDocketRecord } from './Public/PublicPrintableDocketRecord'; import { PublicSearch } from './Public/PublicSearch'; +import { TodaysOpinions } from './Public/TodaysOpinions'; import { UsaBanner } from './UsaBanner'; import { connect } from '@cerebral/react'; import { state } from 'cerebral'; @@ -17,6 +18,7 @@ const pages = { PublicCaseDetail, PublicPrintableDocketRecord, PublicSearch, + TodaysOpinions, }; /** diff --git a/web-client/src/views/CaseDetail/CaseDetailHeaderMenu.jsx b/web-client/src/views/CaseDetail/CaseDetailHeaderMenu.jsx index ffae81457df..08665aabeb5 100644 --- a/web-client/src/views/CaseDetail/CaseDetailHeaderMenu.jsx +++ b/web-client/src/views/CaseDetail/CaseDetailHeaderMenu.jsx @@ -3,6 +3,7 @@ import { AddToTrialModal } from './AddToTrialModal'; import { BlockFromTrialModal } from './BlockFromTrialModal'; import { Button } from '../../ustc-ui/Button/Button'; import { CreateCaseDeadlineModalDialog } from './CreateCaseDeadlineModalDialog'; +import { CreateCaseMessageModalDialog } from '../Messages/CreateCaseMessageModalDialog'; import { CreateOrderChooseTypeModal } from '../CreateOrder/CreateOrderChooseTypeModal'; import { DeleteCaseDeadlineModalDialog } from './DeleteCaseDeadlineModalDialog'; import { EditCaseDeadlineModalDialog } from './EditCaseDeadlineModalDialog'; @@ -26,6 +27,8 @@ export const CaseDetailHeaderMenu = connect( sequences.openAddEditCaseNoteModalSequence, openCreateCaseDeadlineModalSequence: sequences.openCreateCaseDeadlineModalSequence, + openCreateCaseMessageModalSequence: + sequences.openCreateCaseMessageModalSequence, openCreateOrderChooseTypeModalSequence: sequences.openCreateOrderChooseTypeModalSequence, openUpdateCaseModalSequence: sequences.openUpdateCaseModalSequence, @@ -39,6 +42,7 @@ export const CaseDetailHeaderMenu = connect( isCaseDetailMenuOpen, openAddEditCaseNoteModalSequence, openCreateCaseDeadlineModalSequence, + openCreateCaseMessageModalSequence, openCreateOrderChooseTypeModalSequence, openUpdateCaseModalSequence, resetCaseMenuSequence, @@ -101,6 +105,19 @@ export const CaseDetailHeaderMenu = connect( {isCaseDetailMenuOpen && (
        +
      • + +
      • +
      • )} diff --git a/web-client/src/views/CaseListPetitioner.jsx b/web-client/src/views/CaseListPetitioner.jsx index d974bf74d68..71200626580 100644 --- a/web-client/src/views/CaseListPetitioner.jsx +++ b/web-client/src/views/CaseListPetitioner.jsx @@ -9,12 +9,22 @@ import React from 'react'; export const CaseListPetitioner = connect( { - formattedCases: state.formattedCases, - getCasesByStatusForUserSequence: sequences.getCasesByStatusForUserSequence, + caseType: state.openClosedCases.caseType, + closedTab: state.constants.EXTERNAL_USER_DASHBOARD_TABS.CLOSED, + externalUserCasesHelper: state.externalUserCasesHelper, + openTab: state.constants.EXTERNAL_USER_DASHBOARD_TABS.OPEN, + setCaseTypeToDisplaySequence: sequences.setCaseTypeToDisplaySequence, + showMoreClosedCasesSequence: sequences.showMoreClosedCasesSequence, + showMoreOpenCasesSequence: sequences.showMoreOpenCasesSequence, }, function CaseListPetitioner({ - formattedCases, - getCasesByStatusForUserSequence, + caseType, + closedTab, + externalUserCasesHelper, + openTab, + setCaseTypeToDisplaySequence, + showMoreClosedCasesSequence, + showMoreOpenCasesSequence, }) { const renderStartButton = () => ( + )} + + )} + + ); + }; return ( <> @@ -66,16 +103,33 @@ export const CaseListPetitioner = connect( { - getCasesByStatusForUserSequence(); - }} + defaultActiveTab={openTab} > - - {renderCaseListTable()} + + {renderCaseListTable({ + cases: externalUserCasesHelper.openCaseResults, + showLoadMore: + externalUserCasesHelper.showLoadMoreOpenCases, + showMoreResultsSequence: showMoreOpenCasesSequence, + tabName: openTab, + })} - - {renderCaseListTable()} + + {renderCaseListTable({ + cases: externalUserCasesHelper.closedCaseResults, + showLoadMore: + externalUserCasesHelper.showLoadMoreClosedCases, + showMoreResultsSequence: showMoreClosedCasesSequence, + tabName: closedTab, + })}
        {renderStartButton()} @@ -90,21 +144,37 @@ export const CaseListPetitioner = connect(
        {renderStartButton()}
        - { - getCasesByStatusForUserSequence(); + +
        +
        + {caseType === closedTab && + renderCaseListTable({ + cases: externalUserCasesHelper.closedCaseResults, + showLoadMore: externalUserCasesHelper.showLoadMoreClosedCases, + showMoreResultsSequence: showMoreClosedCasesSequence, + tabName: closedTab, + })} + {caseType === openTab && + renderCaseListTable({ + cases: externalUserCasesHelper.openCaseResults, + showLoadMore: externalUserCasesHelper.showLoadMoreOpenCases, + showMoreResultsSequence: showMoreOpenCasesSequence, + tabName: openTab, + })}
        diff --git a/web-client/src/views/CaseListPractitioner.jsx b/web-client/src/views/CaseListPractitioner.jsx index fd608ecb896..517ffd77eb3 100644 --- a/web-client/src/views/CaseListPractitioner.jsx +++ b/web-client/src/views/CaseListPractitioner.jsx @@ -10,37 +10,71 @@ import React from 'react'; export const CaseListPractitioner = connect( { + caseType: state.openClosedCases.caseType, + closedTab: state.constants.EXTERNAL_USER_DASHBOARD_TABS.CLOSED, dashboardExternalHelper: state.dashboardExternalHelper, - formattedCases: state.formattedCases, - getCasesByStatusForUserSequence: sequences.getCasesByStatusForUserSequence, + externalUserCasesHelper: state.externalUserCasesHelper, + openTab: state.constants.EXTERNAL_USER_DASHBOARD_TABS.OPEN, + setCaseTypeToDisplaySequence: sequences.setCaseTypeToDisplaySequence, + showMoreClosedCasesSequence: sequences.showMoreClosedCasesSequence, + showMoreOpenCasesSequence: sequences.showMoreOpenCasesSequence, }, function CaseListPractitioner({ + caseType, + closedTab, dashboardExternalHelper, - formattedCases, - getCasesByStatusForUserSequence, + externalUserCasesHelper, + openTab, + setCaseTypeToDisplaySequence, + showMoreClosedCasesSequence, + showMoreOpenCasesSequence, }) { - const renderTable = () => ( - - - - - - - - - - - {formattedCases.map(item => ( - - ))} - -
        - Lead Case Indicator - Docket numberCase titleDate filed
        + const renderTable = ( + cases, + showLoadMore, + showMoreResultsSequence, + tabName, + ) => ( + <> + {!cases?.length &&

        You have no {tabName.toLowerCase()} cases.

        } + {cases.length > 0 && ( + + + + + + + + + + + {cases.map(item => ( + + ))} + +
        + Lead Case Indicator + Docket numberCase titleDate filed
        + )} + {showLoadMore && ( + + )} + ); const renderStartButton = () => ( @@ -63,16 +97,31 @@ export const CaseListPractitioner = connect( { - getCasesByStatusForUserSequence(); - }} + defaultActiveTab={openTab} > - - {renderTable()} + + {renderTable( + externalUserCasesHelper.openCaseResults, + externalUserCasesHelper.showLoadMoreOpenCases, + showMoreOpenCasesSequence, + openTab, + )} - - {renderTable()} + + {renderTable( + externalUserCasesHelper.closedCaseResults, + externalUserCasesHelper.showLoadMoreClosedCases, + showMoreClosedCasesSequence, + closedTab, + )}
        {renderStartButton()} @@ -90,25 +139,37 @@ export const CaseListPractitioner = connect(
        {renderStartButton()}
        - { - getCasesByStatusForUserSequence(); +
        -
        - {dashboardExternalHelper.showCaseSearch && } - +
        + {caseType === closedTab && + renderTable( + externalUserCasesHelper.closedCaseResults, + externalUserCasesHelper.showLoadMoreClosedCases, + showMoreClosedCasesSequence, + closedTab, + )} + {caseType === openTab && + renderTable( + externalUserCasesHelper.openCaseResults, + externalUserCasesHelper.showLoadMoreOpenCases, + showMoreOpenCasesSequence, + openTab, + )}
        diff --git a/web-client/src/views/CaseListRespondent.jsx b/web-client/src/views/CaseListRespondent.jsx index b8c7f02bf7a..618536260cd 100644 --- a/web-client/src/views/CaseListRespondent.jsx +++ b/web-client/src/views/CaseListRespondent.jsx @@ -1,3 +1,4 @@ +import { Button } from '../ustc-ui/Button/Button'; import { CaseListRowExternal } from './CaseListRowExternal'; import { CaseSearchBox } from './CaseSearchBox'; import { Mobile, NonMobile } from '../ustc-ui/Responsive/Responsive'; @@ -9,37 +10,72 @@ import React from 'react'; export const CaseListRespondent = connect( { + caseType: state.openClosedCases.caseType, + closedTab: state.constants.EXTERNAL_USER_DASHBOARD_TABS.CLOSED, dashboardExternalHelper: state.dashboardExternalHelper, - formattedCases: state.formattedCases, - getCasesByStatusForUserSequence: sequences.getCasesByStatusForUserSequence, + externalUserCasesHelper: state.externalUserCasesHelper, + openTab: state.constants.EXTERNAL_USER_DASHBOARD_TABS.OPEN, + pageSize: state.constants.CASE_LIST_PAGE_SIZE, + setCaseTypeToDisplaySequence: sequences.setCaseTypeToDisplaySequence, + showMoreClosedCasesSequence: sequences.showMoreClosedCasesSequence, + showMoreOpenCasesSequence: sequences.showMoreOpenCasesSequence, }, function CaseListRespondent({ + caseType, + closedTab, dashboardExternalHelper, - formattedCases, - getCasesByStatusForUserSequence, + externalUserCasesHelper, + openTab, + setCaseTypeToDisplaySequence, + showMoreClosedCasesSequence, + showMoreOpenCasesSequence, }) { - const renderTable = () => ( - - - - - - - - - - - {formattedCases.map(item => ( - - ))} - -
        - Lead Case Indicator - Docket numberCase titleDate filed
        + const renderTable = ( + cases, + showLoadMore, + showMoreResultsSequence, + tabName, + ) => ( + <> + {!cases?.length &&

        You have no {tabName.toLowerCase()} cases.

        } + {cases.length > 0 && ( + + + + + + + + + + + {cases.map(item => ( + + ))} + +
        + Lead Case Indicator + Docket numberCase titleDate filed
        + )} + {showLoadMore && ( + + )} + ); return ( @@ -51,16 +87,31 @@ export const CaseListRespondent = connect( { - getCasesByStatusForUserSequence(); - }} + defaultActiveTab={openTab} > - - {renderTable()} + + {renderTable( + externalUserCasesHelper.openCaseResults, + externalUserCasesHelper.showLoadMoreOpenCases, + showMoreOpenCasesSequence, + openTab, + )} - - {renderTable()} + + {renderTable( + externalUserCasesHelper.closedCaseResults, + externalUserCasesHelper.showLoadMoreClosedCases, + showMoreClosedCasesSequence, + closedTab, + )}
        @@ -74,21 +125,37 @@ export const CaseListRespondent = connect(
        - { - getCasesByStatusForUserSequence(); + +
        +
        + {caseType === closedTab && + renderTable( + externalUserCasesHelper.closedCaseResults, + externalUserCasesHelper.showLoadMoreClosedCases, + showMoreClosedCasesSequence, + closedTab, + )} + {caseType === openTab && + renderTable( + externalUserCasesHelper.openCaseResults, + externalUserCasesHelper.showLoadMoreOpenCases, + showMoreOpenCasesSequence, + openTab, + )}
        {dashboardExternalHelper.showCaseSearch && } diff --git a/web-client/src/views/Header/Header.jsx b/web-client/src/views/Header/Header.jsx index d66dfea7136..d98489353b1 100644 --- a/web-client/src/views/Header/Header.jsx +++ b/web-client/src/views/Header/Header.jsx @@ -38,17 +38,17 @@ const BetaBar = toggleBetaBarSequence => { }; const NavigationItems = ( - helper, + headerHelper, { isReportsMenuOpen, signOutSequence, toggleMobileMenuSequence }, ) => { return (
          - {helper.showHomeIcon && ( + {headerHelper.showHomeIcon && (
        • toggleMobileMenuSequence()} @@ -57,18 +57,41 @@ const NavigationItems = (
        • )} - {helper.showMessages && ( + {headerHelper.showMessages && (
        • toggleMobileMenuSequence()} + > + Case Messages{' '} + {headerHelper.showMessagesIcon && ( + + )} + +
        • + )} + {headerHelper.showMessages && ( +
        • + toggleMobileMenuSequence()} > Messages{' '} - {helper.showMessagesIcon && ( + {headerHelper.showMessagesIcon && (
        • )} - {helper.showDocumentQC && ( + {headerHelper.showDocumentQC && (
        • toggleMobileMenuSequence()} > Document QC
        • )} - {helper.showMyCases && ( + {headerHelper.showMyCases && (
        • toggleMobileMenuSequence()} @@ -108,12 +131,12 @@ const NavigationItems = (
        • )} - {helper.showSearchNavItem && ( + {headerHelper.showSearchNavItem && (
        • toggleMobileMenuSequence()} @@ -122,12 +145,12 @@ const NavigationItems = (
        • )} - {helper.showTrialSessions && ( + {headerHelper.showTrialSessions && (
        • toggleMobileMenuSequence()} @@ -136,7 +159,7 @@ const NavigationItems = (
        • )} - {helper.showReports && ( + {headerHelper.showReports && (
        • +
          +
          +

          {messagesHelper.messagesTitle}

          + + {inboxCount} + + {messagesHelper.showIndividualMessages && ( + + )} + {messagesHelper.showSectionMessages && ( + + )} +
          +
          + +
          + + + { + navigateToPathSequence({ + path: `/case-messages/${queue}/${box}`, + }); + }} + > + +
          + {messagesHelper.showIndividualMessages && ( + + )} + + {messagesHelper.showSectionMessages && ( + + )} +
          +
          + +
          + {messagesHelper.showIndividualMessages && ( + + )} + + {messagesHelper.showSectionMessages && ( + + )} +
          +
          + +
          +
          +
          +
          + + ); + }, +); diff --git a/web-client/src/views/Messages/CaseMessagesIndividualInbox.jsx b/web-client/src/views/Messages/CaseMessagesIndividualInbox.jsx new file mode 100644 index 00000000000..7152cbbee9c --- /dev/null +++ b/web-client/src/views/Messages/CaseMessagesIndividualInbox.jsx @@ -0,0 +1,77 @@ +import { Button } from '../../ustc-ui/Button/Button'; +import { CaseLink } from '../../ustc-ui/CaseLink/CaseLink'; +import { CaseMessagesRowAttachments } from './CaseMessagesRowAttachments'; +import { connect } from '@cerebral/react'; +import { state } from 'cerebral'; +import React from 'react'; + +export const CaseMessagesIndividualInbox = connect( + { formattedMessages: state.formattedMessages }, + function CaseMessagesIndividualInbox({ formattedMessages }) { + return ( + <> + + + + + + + + + + + + + {formattedMessages.map((message, idx) => { + return ( + + + + + + + + + + + + ); + })} +
          + Docket + ReceivedMessageCase StatusFromSectionAttachments
          + + + + {message.createdAtFormatted} + + +
          + +
          + +
          + {message.message} +
          +
          {message.caseStatus}{message.from} + {message.fromSection} + + {message.attachments.length > 0 && ( + + )} +
          + {formattedMessages.length === 0 &&
          There are no messages.
          } + + ); + }, +); diff --git a/web-client/src/views/Messages/CaseMessagesIndividualOutbox.jsx b/web-client/src/views/Messages/CaseMessagesIndividualOutbox.jsx new file mode 100644 index 00000000000..c42e8c6fc2b --- /dev/null +++ b/web-client/src/views/Messages/CaseMessagesIndividualOutbox.jsx @@ -0,0 +1,77 @@ +import { Button } from '../../ustc-ui/Button/Button'; +import { CaseLink } from '../../ustc-ui/CaseLink/CaseLink'; +import { CaseMessagesRowAttachments } from './CaseMessagesRowAttachments'; +import { connect } from '@cerebral/react'; +import { state } from 'cerebral'; +import React from 'react'; + +export const CaseMessagesIndividualOutbox = connect( + { formattedMessages: state.formattedMessages }, + function CaseMessagesIndividualInbox({ formattedMessages }) { + return ( + <> + + + + + + + + + + + + + {formattedMessages.map((message, idx) => { + return ( + + + + + + + + + + + + ); + })} +
          + Docket + SentMessageCase StatusToSectionAttachments
          + + + + {message.createdAtFormatted} + + +
          + +
          + +
          + {message.message} +
          +
          {message.caseStatus}{message.to} + {message.fromSection} + + {message.attachments.length > 0 && ( + + )} +
          + {formattedMessages.length === 0 &&
          There are no messages.
          } + + ); + }, +); diff --git a/web-client/src/views/Messages/CaseMessagesRowAttachments.js b/web-client/src/views/Messages/CaseMessagesRowAttachments.js new file mode 100644 index 00000000000..eb700d06c52 --- /dev/null +++ b/web-client/src/views/Messages/CaseMessagesRowAttachments.js @@ -0,0 +1,34 @@ +import { Button } from '../../ustc-ui/Button/Button'; +import { connect } from '@cerebral/react'; +import { state } from 'cerebral'; +import React from 'react'; + +export const CaseMessagesRowAttachments = connect( + { + baseUrl: state.baseUrl, + token: state.token, + }, + function CaseMessagesRowAttachments({ attachments, baseUrl, caseId, token }) { + return ( + <> + {attachments && + attachments.map(attachment => { + return ( +
          + +
          + ); + })} + + ); + }, +); diff --git a/web-client/src/views/Messages/CaseMessagesSectionInbox.jsx b/web-client/src/views/Messages/CaseMessagesSectionInbox.jsx new file mode 100644 index 00000000000..8c68cd5f665 --- /dev/null +++ b/web-client/src/views/Messages/CaseMessagesSectionInbox.jsx @@ -0,0 +1,68 @@ +import { Button } from '../../ustc-ui/Button/Button'; +import { CaseLink } from '../../ustc-ui/CaseLink/CaseLink'; +import { connect } from '@cerebral/react'; +import { state } from 'cerebral'; +import React from 'react'; + +export const CaseMessagesSectionInbox = connect( + { formattedMessages: state.formattedMessages }, + function CaseMessagesIndividualInbox({ formattedMessages }) { + return ( + <> + + + + + + + + + + + + + {formattedMessages.map((message, idx) => { + return ( + + + + + + + + + + + + ); + })} +
          + Docket + ReceivedMessageCase StatusToFromSection
          + + + + {message.createdAtFormatted} + + +
          + +
          +
          + {message.message} +
          +
          {message.caseStatus}{message.to}{message.from} + {message.fromSection} +
          + {formattedMessages.length === 0 &&
          There are no messages.
          } + + ); + }, +); diff --git a/web-client/src/views/Messages/CaseMessagesSectionOutbox.jsx b/web-client/src/views/Messages/CaseMessagesSectionOutbox.jsx new file mode 100644 index 00000000000..39c55ccee30 --- /dev/null +++ b/web-client/src/views/Messages/CaseMessagesSectionOutbox.jsx @@ -0,0 +1,69 @@ +import { Button } from '../../ustc-ui/Button/Button'; +import { CaseLink } from '../../ustc-ui/CaseLink/CaseLink'; +import { connect } from '@cerebral/react'; +import { state } from 'cerebral'; +import React from 'react'; + +export const CaseMessagesSectionOutbox = connect( + { formattedMessages: state.formattedMessages }, + function CaseMessagesIndividualInbox({ formattedMessages }) { + return ( + <> + + + + + + + + + + + + + {formattedMessages.map((message, idx) => { + return ( + + + + + + + + + + + + ); + })} +
          + Docket + SentMessageCase StatusToFromSection
          + + + + {message.createdAtFormatted} + + +
          + +
          + +
          + {message.message} +
          +
          {message.caseStatus}{message.to}{message.from} + {message.fromSection} +
          + {formattedMessages.length === 0 &&
          There are no messages.
          } + + ); + }, +); diff --git a/web-client/src/views/Messages/CreateCaseMessageModalDialog.jsx b/web-client/src/views/Messages/CreateCaseMessageModalDialog.jsx new file mode 100644 index 00000000000..e086b450ed1 --- /dev/null +++ b/web-client/src/views/Messages/CreateCaseMessageModalDialog.jsx @@ -0,0 +1,265 @@ +import { Button } from '../../ustc-ui/Button/Button'; +import { ConfirmModal } from '../../ustc-ui/Modal/ConfirmModal'; +import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; +import { FormGroup } from '../../ustc-ui/FormGroup/FormGroup'; +import { connect } from '@cerebral/react'; +import { sequences, state } from 'cerebral'; +import React from 'react'; + +const getDocumentOption = document => { + const title = document.documentTitle || document.documentType; + return ( + + ); +}; + +export const CreateCaseMessageModalDialog = connect( + { + constants: state.constants, + createCaseMessageModalHelper: state.createCaseMessageModalHelper, + form: state.modal.form, + showChambersSelect: state.modal.showChambersSelect, + updateCreateCaseMessageAttachmentsSequence: + sequences.updateCreateCaseMessageAttachmentsSequence, + updateCreateCaseMessageValueInModalSequence: + sequences.updateCreateCaseMessageValueInModalSequence, + updateScreenMetadataSequence: sequences.updateScreenMetadataSequence, + users: state.users, + validateCreateCaseMessageInModalSequence: + sequences.validateCreateCaseMessageInModalSequence, + validationErrors: state.validationErrors, + workQueueSectionHelper: state.workQueueSectionHelper, + }, + function CreateMessageModalDialog({ + constants, + createCaseMessageModalHelper, + form, + onConfirmSequence = 'createCaseMessageSequence', + showChambersSelect, + updateCreateCaseMessageAttachmentsSequence, + updateCreateCaseMessageValueInModalSequence, + updateScreenMetadataSequence, + users, + validateCreateCaseMessageInModalSequence, + validationErrors, + workQueueSectionHelper, + }) { + validationErrors = validationErrors || {}; + form = form || {}; + + return ( + + + + + + + + {showChambersSelect && ( + + + + + )} + + + + + + + + + { + updateCreateCaseMessageValueInModalSequence({ + key: e.target.name, + value: e.target.value, + }); + validateCreateCaseMessageInModalSequence(); + }} + /> + + + + +