Skip to content

Commit

Permalink
Merge branch 'staging' of https://github.com/ustaxcourt/ef-cms into 1…
Browse files Browse the repository at this point in the history
…0007-story
  • Loading branch information
rachelschneiderman committed Dec 7, 2023
2 parents 90a28f6 + 24e068b commit dc41c76
Show file tree
Hide file tree
Showing 188 changed files with 2,182 additions and 1,939 deletions.
5 changes: 1 addition & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ WORKDIR /home/app
# needed to install jre successfully
RUN mkdir -p /usr/share/man/man1

# delete duplicate list if it exists
RUN [ -f /etc/apt/sources.list.d/microsoft-edge.list ] && [ -f /etc/apt/sources.list.d/microsoft-edge-stable.list ] && rm /etc/apt/sources.list.d/microsoft-edge-stable.list

RUN apt-get update

RUN apt-get install -y \
Expand Down Expand Up @@ -48,4 +45,4 @@ RUN wget -q -O terraform.zip https://releases.hashicorp.com/terraform/1.6.4/terr
rm terraform.zip && \
cp terraform /usr/local/bin/

CMD echo "🔥"
CMD echo "🔥"
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { externalUserSearchesDocketNumber } from '../../helpers/external-user-searches-docket-number';
import { loginAsPetitioner } from '../../helpers/auth/login-as-helpers';
import { petitionerCreatesEletronicCase } from '../../helpers/petitioner-creates-electronic-case';
import { petitionsClerkServesPetition } from '../support/setup/petitionsclerk-serves-petition';

describe(
'Petitioner files external document on case',
{ scrollBehavior: 'center' },
() => {
it('should create an electronic petition, serve the petition, and files an "Answer" on the petition', () => {
loginAsPetitioner();
petitionerCreatesEletronicCase().then(docketNumber => {
petitionsClerkServesPetition(docketNumber);
loginAsPetitioner();
externalUserSearchesDocketNumber(docketNumber);
});
cy.get('[data-testid="button-file-document"]').click();
cy.get('[data-testid="ready-to-file"]').click();
cy.get('[data-testid="document-type"] .select-react-element__input').type(
'Motion for Leave to File{enter}',
);
cy.get(
'[data-testid="secondary-doc-secondary-document-type"] .select-react-element__input',
).type('Answer{enter}');
cy.get('[data-testid="submit-document"]').click();
cy.get('[data-testid="primary-document"]').attachFile(
'../fixtures/w3-dummy.pdf',
);
cy.get('[data-testid=primaryDocument-objections-No]').click();
cy.get('#submit-document').click();
cy.get('[data-testid=redaction-acknowledgement-label]').click();
cy.get('#submit-document').click();
cy.get('[data-testid="document-download-link-M115"]').should(
'have.text',
'Motion for Leave to File Answer (No Objection)',
);
});
},
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { faker } from '@faker-js/faker';
import { loginAsPetitionsClerk } from '../../helpers/auth/login-as-helpers';
import { petitionsClerkCreatesTrialSession } from '../../helpers/petitionsclerk-creates-trial-session';

faker.seed(faker.number.int());

describe('trial sessions', () => {
it('verify the auto fill functionality for chambers phone number works when selectin a judge', () => {
loginAsPetitionsClerk();
petitionsClerkCreatesTrialSession().then(trialSessionId => {
cy.get('[data-testid=new-trial-sessions-tab]').click();
cy.get(`[data-testid=trial-location-link-${trialSessionId}]`).click();
});
cy.get('[data-testid=assignments-sessions-chambers-phone-number]').should(
'have.text',
'(202) 521-0662',
);

cy.get('[data-testid="edit-trial-session"]').click();
cy.get('[data-testid="edit-trial-session-chambers-phone-number"]').clear();
cy.get('[data-testid="edit-trial-session-chambers-phone-number"]').type(
'(123) 4567890',
);
cy.get('[data-testid="submit-edit-trial-session"]').click();
cy.get('[data-testid=assignments-sessions-chambers-phone-number]').should(
'have.text',
'(123) 4567890',
);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { generateRandomPhoneNumber } from '../support/helpers';
import { navigateTo as loginAs } from '../support/pages/maintenance';

describe('Practitioners with no cases', () => {
it('should allow the practitioner to edit their phone number multiple times', () => {
loginAs('privatepractitioner4');
cy.get('[data-testid="account-menu-button"]').click();
cy.get('[data-testid="my-account-link"]').click();
cy.get('[data-testid="edit-contact-info"]').click();

const randomPhoneNumber = generateRandomPhoneNumber();
cy.get('[data-testid="phone-number-input"').as('phoneNumberInput');
cy.get('@phoneNumberInput').clear();
cy.get('@phoneNumberInput').type(randomPhoneNumber);

cy.get('[data-testid="save-edit-contact"]').click();
cy.get('[data-testid="success-alert"]').should('exist');

cy.get('[data-testid="account-menu-button"]').click();
cy.get('[data-testid="my-account-link"]').click();
cy.get('[data-testid="contact-info-phone-number"]').should(
'contain.text',
randomPhoneNumber,
);

cy.get('[data-testid="edit-contact-info"]').click();
const anotherRandomPhoneNumber = generateRandomPhoneNumber();
cy.get('[data-testid="phone-number-input"').as('phoneNumberInput');
cy.get('@phoneNumberInput').clear();
cy.get('@phoneNumberInput').type(anotherRandomPhoneNumber);

cy.get('[data-testid="save-edit-contact"]').click();
cy.get('[data-testid="success-alert"]').should('exist');

cy.get('[data-testid="account-menu-button"]').click();
cy.get('[data-testid="my-account-link"]').click();
cy.get('[data-testid="contact-info-phone-number"]').should(
'contain.text',
anotherRandomPhoneNumber,
);
});
});
13 changes: 13 additions & 0 deletions cypress/cypress-integration/support/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,16 @@ export function b64toBlob(b64Data, contentType, sliceSize) {
blob.lastModifiedDate = new Date();
return blob;
}

export function generateRandomPhoneNumber(): string {
function getRandomNumber(min: number, max: number) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}

const areaCode = getRandomNumber(100, 999);
const firstPart = getRandomNumber(100, 999);
const secondPart = getRandomNumber(1000, 9999);
const phoneNumber = `+1 (${areaCode}) ${firstPart}-${secondPart}`;

return phoneNumber;
}
32 changes: 4 additions & 28 deletions cypress/cypress-smoketests/integration/create-trial-session.cy.ts
Original file line number Diff line number Diff line change
@@ -1,36 +1,12 @@
import { faker } from '@faker-js/faker';
import { loginAsPetitionsClerk } from '../../helpers/auth/login-as-helpers';
import { petitionsClerkCreatesTrialSession } from '../../helpers/petitionsclerk-creates-trial-session';

faker.seed(faker.number.int());

describe('trial sessions', () => {
it('a petitionsclerk should be able to create a trial session', () => {
cy.login('petitionsclerk1');
cy.get('[data-testid="inbox-tab-content"]').should('exist');
cy.get('[data-testid="trial-session-link"]').click();
cy.get('[data-testid="add-trial-session-button"]').click();
cy.get('#start-date-picker').clear();
cy.get('#start-date-picker').type('02/02/2099');
cy.get('#estimated-end-date-picker').clear();
cy.get('#estimated-end-date-picker').type('02/02/2100');
cy.get('[data-testid="session-type-Hybrid"]').click();
cy.get('[data-testid="trial-session-number-of-cases-allowed"]').clear();
cy.get('[data-testid="trial-session-number-of-cases-allowed"]').type('10');
cy.get('[data-testid="inPerson-proceeding-label"]').click();
cy.get('[data-testid="trial-session-trial-location"]').select(
'Anchorage, Alaska',
);
cy.get('[data-testid="courthouse-name"]').clear();
cy.get('[data-testid="courthouse-name"]').type('a courthouse');
cy.get('[data-testid="city"]').clear();
cy.get('[data-testid="city"]').type('cleveland');
cy.get('[data-testid="state"]').select('TN');
cy.get('[data-testid="postal-code"]').clear();
cy.get('[data-testid="postal-code"]').type('33333');
cy.get('[data-testid="trial-session-judge"]').select('Colvin');
cy.get('[data-testid="trial-session-trial-clerk"]').select(
'Test trialclerk1',
);
cy.get('[data-testid="submit-trial-session"]').click();
cy.get('[data-testid="success-alert"]').should('exist');
loginAsPetitionsClerk();
petitionsClerkCreatesTrialSession();
});
});
4 changes: 4 additions & 0 deletions cypress/helpers/external-user-searches-docket-number.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export function externalUserSearchesDocketNumber(docketNumber: string) {
cy.get('[data-testid="docket-search-field"]').type(docketNumber);
cy.get('[data-testid="search-by-docket-number"]').click();
}
33 changes: 33 additions & 0 deletions cypress/helpers/petitionsclerk-creates-trial-session.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
export function petitionsClerkCreatesTrialSession() {
cy.get('[data-testid="inbox-tab-content"]').should('exist');
cy.get('[data-testid="trial-session-link"]').click();
cy.get('[data-testid="add-trial-session-button"]').click();
cy.get('#start-date-picker').clear();
cy.get('#start-date-picker').type('02/02/2099');
cy.get('#estimated-end-date-picker').clear();
cy.get('#estimated-end-date-picker').type('02/02/2100');
cy.get('[data-testid="session-type-Hybrid"]').click();
cy.get('[data-testid="trial-session-number-of-cases-allowed"]').clear();
cy.get('[data-testid="trial-session-number-of-cases-allowed"]').type('10');
cy.get('[data-testid="inPerson-proceeding-label"]').click();
cy.get('[data-testid="trial-session-trial-location"]').select(
'Anchorage, Alaska',
);
cy.get('[data-testid="courthouse-name"]').clear();
cy.get('[data-testid="courthouse-name"]').type('a courthouse');
cy.get('[data-testid="city"]').clear();
cy.get('[data-testid="city"]').type('cleveland');
cy.get('[data-testid="state"]').select('TN');
cy.get('[data-testid="postal-code"]').clear();
cy.get('[data-testid="postal-code"]').type('33333');
cy.get('[data-testid="trial-session-judge"]').select('Colvin');
cy.get('[data-testid="trial-session-trial-clerk"]').select(
'Test trialclerk1',
);
cy.get('[data-testid="submit-trial-session"]').click();
cy.get('[data-testid="success-alert"]').should('exist');

return cy
.get('[data-testid="success-alert"]')
.invoke('attr', 'data-metadata');
}
2 changes: 2 additions & 0 deletions docker-to-ecr.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash -e

export DOCKER_DEFAULT_PLATFORM=linux/amd64

./check-env-variables.sh \
"DESTINATION_TAG" \
"AWS_ACCOUNT_ID" \
Expand Down
1 change: 0 additions & 1 deletion docs/dependency-updates.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ At the moment, the only task we rotate is updating dependencies. As an open-sour
- Increment the docker image version being used in `.circleci/config.yml` in the docker variable:
`define: &efcms-docker-image`. e.g. `ef-cms-us-east-1:3.0.18` -> `ef-cms-us-east-1:3.0.19`
- Publish a docker image tagged with the incremented version number to ECR with the command: `export DESTINATION_TAG=[INSERT NEW DOCKER IMAGE VERSION] && npm run deploy:ci-image`. Do this for both the USTC account AND the Flexion account (using environment switcher).
- If you are on an M1 Machine, make sure to set the environment variable `DOCKER_DEFAULT_PLATFORM=linux/amd64`.
- example: `export DESTINATION_TAG=3.0.19 && npm run deploy:ci-image`
- you can verify the image deployed on AWS ECR repository "ef-cms-us-east-1"

Expand Down
31 changes: 31 additions & 0 deletions scripts/dynamo/setup-clerk-of-court-config.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash

# Sets the title and name of the clerk of the court

# Usage
# ENV=dev ./setup-clerk-of-court-config.sh

./check-env-variables.sh \
"ENV" \
"AWS_SECRET_ACCESS_KEY" \
"AWS_ACCESS_KEY_ID"

ITEM=$(cat <<-END
{
"pk": {
"S": "clerk-of-court-configuration"
},
"sk":{
"S": "clerk-of-court-configuration"
},
"current": {
"M": {"name": {"S": "Stephanie A. Servoss"}, "title": {"S": "Clerk of the Court"}}
}
}
END
)

aws dynamodb put-item \
--region us-east-1 \
--table-name "efcms-deploy-${ENV}" \
--item "${ITEM}"
65 changes: 24 additions & 41 deletions setup-for-blue-green-migration.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

( ! command -v jq > /dev/null ) && echo "jq must be installed on your machine." && exit 1

FORCE_MIGRATION=$1
FORCE_MIGRATION="$1"

set -e
./check-env-variables.sh \
Expand All @@ -24,7 +24,7 @@ source ./scripts/helpers/opensearch-domain-exists.sh
node web-api/is-migration-needed.js
SKIP_MIGRATION="$?"

if [[ "${SKIP_MIGRATION}" == "1" ]] && [[ $FORCE_MIGRATION != "--force" ]]; then
if [[ "$SKIP_MIGRATION" == "1" ]] && [[ "$FORCE_MIGRATION" != "--force" ]]; then
exit 0
fi

Expand All @@ -37,7 +37,7 @@ aws dynamodb put-item --region us-east-1 --table-name "efcms-deploy-${ENV}" --it
SOURCE_TABLE_VERSION=$(aws dynamodb get-item --region us-east-1 --table-name "efcms-deploy-${ENV}" --key '{"pk":{"S":"source-table-version"},"sk":{"S":"source-table-version"}}' | jq -r ".Item.current.S")
echo "source table is currently ${SOURCE_TABLE_VERSION}"

if [[ "${SOURCE_TABLE_VERSION}" == "beta" ]]; then
if [[ "$SOURCE_TABLE_VERSION" == "beta" ]]; then
echo "setting destination table to alpha"
NEXT_VERSION="alpha"
aws dynamodb put-item --region us-east-1 --table-name "efcms-deploy-${ENV}" --item '{"pk":{"S":"destination-table-version"},"sk":{"S":"destination-table-version"},"current":{"S":"alpha"}}'
Expand All @@ -50,47 +50,30 @@ fi
NEXT_TABLE="efcms-${ENV}-${NEXT_VERSION}"
NEXT_OPENSEARCH_DOMAIN="efcms-search-${ENV}-${NEXT_VERSION}"

if [[ $FORCE_MIGRATION == "--force" ]]; then
./scripts/dynamo/delete-dynamo-table.sh "${NEXT_TABLE}"

EXISTS=$(check_opensearch_domain_exists "${NEXT_OPENSEARCH_DOMAIN}")
if [[ "${EXISTS}" == "1" ]]; then
aws es delete-elasticsearch-domain --domain-name "${NEXT_OPENSEARCH_DOMAIN}" --region us-east-1
while [[ "${EXISTS}" == "1" ]]; do
echo "${NEXT_OPENSEARCH_DOMAIN} is still being deleted. Waiting 30 seconds then checking again."
sleep 30
EXISTS=$(check_opensearch_domain_exists "${NEXT_OPENSEARCH_DOMAIN}")
done
fi
fi

EXISTS=$(check_dynamo_table_exists "${NEXT_TABLE}" us-east-1)
if [[ "${EXISTS}" == "1" ]]; then
NUM_ITEMS=$(aws dynamodb scan --table-name "${NEXT_TABLE}" --region us-west-1 --max-items 1 | jq .Count)
if [ "$NUM_ITEMS" != "0" ]; then
echo "error: expected the ${NEXT_TABLE} table to have been deleted or empty from us-east-1 before running migration ${NUM_ITEMS}"
exit 1
EAST_EXISTS=$(check_dynamo_table_exists "${NEXT_TABLE}" us-east-1)
WEST_EXISTS=$(check_dynamo_table_exists "${NEXT_TABLE}" us-west-1)
if [[ "$EAST_EXISTS" == "1" ]] || [[ "$WEST_EXISTS" == "1" ]]; then
NUM_EAST_ITEMS=$(aws dynamodb scan --table-name "${NEXT_TABLE}" --region us-east-1 --max-items 1 | jq .Count)
NUM_WEST_ITEMS=$(aws dynamodb scan --table-name "${NEXT_TABLE}" --region us-west-1 --max-items 1 | jq .Count)
if [[ "$NUM_EAST_ITEMS" != "0" ]] || [[ "$NUM_WEST_ITEMS" != "0" ]]; then
./scripts/dynamo/delete-dynamo-table.sh "$NEXT_TABLE"
else
echo "warn: the table ${NEXT_TABLE} exists, but it is empty"
fi
echo "warn: the table ${NEXT_TABLE} (us-east-1) exists, but it is empty"
fi

EXISTS=$(check_dynamo_table_exists "${NEXT_TABLE}" us-west-1)
if [[ "${EXISTS}" == "1" ]]; then
NUM_ITEMS=$(aws dynamodb scan --table-name "${NEXT_TABLE}" --region us-west-1 --max-items 1 | jq .Count)
if [ "$NUM_ITEMS" != "0" ]; then
echo "error: expected the ${NEXT_TABLE} table to have been deleted or empty from us-west-1 before running migration ${NUM_ITEMS}"
exit 1
fi
echo "warn: the table ${NEXT_TABLE} (us-west-1) exists, but it is empty"
fi

EXISTS=$(check_opensearch_domain_exists "${NEXT_OPENSEARCH_DOMAIN}")
if [[ "${EXISTS}" == "1" ]]; then
npx ts-node --transpile-only ./scripts/elasticsearch/ready-cluster-for-migration.ts "${NEXT_OPENSEARCH_DOMAIN}"
EXISTS=$(check_opensearch_domain_exists "$NEXT_OPENSEARCH_DOMAIN")
if [[ "$EXISTS" == "1" ]]; then
npx ts-node --transpile-only ./scripts/elasticsearch/ready-cluster-for-migration.ts "$NEXT_OPENSEARCH_DOMAIN"
CLUSTER_IS_NOT_EMPTY="$?"
if [[ "${CLUSTER_IS_NOT_EMPTY}" == "1" ]]; then
echo "error: expected the ${NEXT_OPENSEARCH_DOMAIN} openserach cluster to have been deleted from us-east-1 before running migration"
exit 1
if [[ "$CLUSTER_IS_NOT_EMPTY" == "1" ]]; then
aws es delete-elasticsearch-domain --domain-name "$NEXT_OPENSEARCH_DOMAIN" --region us-east-1
while [[ "$EXISTS" == "1" ]]; do
echo "${NEXT_OPENSEARCH_DOMAIN} is still being deleted. Waiting 30 seconds then checking again."
sleep 30
EXISTS=$(check_opensearch_domain_exists "$NEXT_OPENSEARCH_DOMAIN")
done
else
echo "warn: the opensearch cluster ${NEXT_OPENSEARCH_DOMAIN} exists, but it is empty"
fi
echo "warn: the openserach cluster ${NEXT_OPENSEARCH_DOMAIN} exists, but it is empty"
fi
Loading

0 comments on commit dc41c76

Please sign in to comment.