Skip to content

Commit

Permalink
Merge branch 'master' into jim/2314-payload-name
Browse files Browse the repository at this point in the history
  • Loading branch information
jimduff-usds committed Dec 13, 2021
2 parents 3444adb + 9ee7f2a commit 7640a4f
Show file tree
Hide file tree
Showing 23 changed files with 456 additions and 190 deletions.
31 changes: 16 additions & 15 deletions .environment/gitleaks/run-gitleaks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,18 @@ function note() {
}

# Use a well known, stable version
GITLEAKS_IMG_NAME="zricethezav/gitleaks:v7.5.0"
GITLEAKS_IMG_NAME="zricethezav/gitleaks:v8.2.0"
REPO_ROOT=$(git rev-parse --show-toplevel)
CONTAINER_SOURCE_LOCATION="/repo"
CONTAINER_LOCATION="repo"
VERBOSE=${VERBOSE:-0}
SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"

REPORT_JSON="gitleaks.report.json"
LOGFILE="gitleaks.log"

REPO_CONFIG_PATH=".environment/gitleaks/gitleaks-config.toml"
CONFIG_FILE="gitleaks-config.toml"

# Run gitleaks locally if installed
LOCAL_GITLEAKS=0
Expand All @@ -62,25 +64,25 @@ fi
function base_command() {
if [[ ${LOCAL_GITLEAKS?} == 1 ]]; then
echo "running gitleaks locally"
gitleaks \
--path="${REPO_ROOT?}" \
--repo-config-path="${REPO_CONFIG_PATH?}" \
--report="${REPO_ROOT?}/${REPORT_JSON?}" \
gitleaks protect \
--source="${REPO_ROOT?}" \
--report-path="${REPO_ROOT?}/${REPORT_JSON?}" \
--config="${SCRIPT_DIR?}/${CONFIG_FILE?}" \
--report-format "json" \
$(if [[ ${VERBOSE?} != 0 ]]; then echo "--verbose"; else echo ""; fi) \
$1 \
2>"${LOGFILE?}"
$1
else
echo "running gitleaks in docker"
docker run \
-v "${REPO_ROOT?}:${CONTAINER_SOURCE_LOCATION?}" \
--rm \
"${GITLEAKS_IMG_NAME?}" \
--path="${CONTAINER_LOCATION?}" \
--repo-config-path="${REPO_CONFIG_PATH?}" \
--report="${CONTAINER_LOCATION?}/${REPORT_JSON?}" \
"${GITLEAKS_IMG_NAME?}" protect \
--source="${CONTAINER_SOURCE_LOCATION?}" \
--report-path="${CONTAINER_SOURCE_LOCATION?}/${REPORT_JSON?}" \
--config="${CONTAINER_SOURCE_LOCATION?}/${REPO_CONFIG_PATH?}" \
--report-format "json" \
$(if [[ ${VERBOSE?} != 0 ]]; then echo "--verbose"; else echo ""; fi) \
$1 \
2>"${LOGFILE?}"
$1
fi
RC=$?

Expand All @@ -89,9 +91,8 @@ function base_command() {

function scan_uncommitted() {
note "Scanning your suggested changes."
# NOTE: ironically, the switch to scan your staged (i.e. to be committed) changes is to use the --unstaged switch

base_command "--unstaged"
base_command "--staged"

RC=$?

Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/build_frontend.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,9 @@ jobs:
- name: Build staging fallthrough for PR branch (conditional check)
if: (!(github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' || github.ref == 'refs/heads/production'))
working-directory: ./frontend-react
run: |
yarn lint:prettier
yarn lint:eslint
yarn test:ci
yarn build:staging
6 changes: 4 additions & 2 deletions frontend-react/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-frontend",
"version": "0.1.0",
"version": "0.1.1",
"private": true,
"npmClient": "yarn",
"proxy": "http://localhost:7071",
Expand All @@ -15,6 +15,7 @@
"@rest-hooks/hooks": "^2.0.0",
"@rest-hooks/rest": "^2.2.0",
"@rest-hooks/test": "^7.1.0",
"@testing-library/user-event": "^13.5.0",
"@trussworks/react-uswds": "^2.3.0",
"@types/downloadjs": "^1.4.2",
"@types/hookrouter": "^2.2.5",
Expand Down Expand Up @@ -55,7 +56,8 @@
"build:production": "env-cmd -f .env.production craco build",
"postbuild:staging": "cp build/index.html build/404.html",
"postbuild:production": "cp build/index.html build/404.html",
"test": "react-scripts test",
"test": "craco test",
"test:ci": "CI=true yarn test --coverage",
"eject": "react-scripts eject",
"lint": "npm-run-all -p lint:eslint lint:prettier",
"lint:write": "npm-run-all -p lint:eslint:write lint:prettier:write",
Expand Down
16 changes: 16 additions & 0 deletions frontend-react/src/components/Title.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { render, screen } from "@testing-library/react";

import Title from "./Title";

describe("Title component", () => {
const UNIQUE_TITLE = `Title for test`;
const UNIQUE_PRETITLE = `Unique PreTitle for unit test`;
beforeEach(() => {
render(<Title title={UNIQUE_TITLE} preTitle={UNIQUE_PRETITLE} />);
});

it("verify title shows", async () => {
expect(await screen.findByText(UNIQUE_TITLE)).toBeInTheDocument();
expect(await screen.findByText(UNIQUE_PRETITLE)).toBeInTheDocument();
});
});
17 changes: 1 addition & 16 deletions frontend-react/src/content/content.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
"imgAlt": "Map of the U.S. showing states and territories where ReportStream is currently live",
"linkInternal": "/how-it-works/where-were-live"
}
]
]
},
{
"title": "Interested in learning more about ReportStream?",
Expand All @@ -115,20 +115,5 @@
"buttonText": "Get in touch",
"buttonUrlSubject": "?subject=I'm interested in learning more about ReportStream"
}
],

"freeSecure": [
{
"title": "Free and created by the CDC",
"summary": "Developed for COVID-19 test data and public health departments, ReportStream is 100% free.",
"icon": "cdc-logo.svg",
"iconDescription": "CDC logo"
},
{
"title": "Safe and secure",
"summary": "Test results and patient data are securely stored and protected by two-factor authentication, database encryption, and HTTPS.",
"icon": "shield.svg",
"iconDescription": "Icon of a shield"
}
]
}
24 changes: 13 additions & 11 deletions frontend-react/src/pages/home/Home.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,23 @@ describe("Home rendering", () => {
render(<Home />);
});

test("Container renders", () => {
expect(screen.getByTestId("container")).toBeInTheDocument();
test("Container renders", async () => {
expect(await screen.getByTestId("container")).toBeInTheDocument();
});

test("Renders correct number of elements", async () => {
content.sections.forEach(async (section) => {
expect(await screen.findAllByTestId("feature")).toHaveLength(
section.features?.length || 0
);
});
// these tests require each new feature section has a `data-testid="feature"` set!

// note: forEach() is not async friendly
for (const eachSection of content.sections) {
for (const eachFeature of eachSection.features) {
// make sure each feature for each section appears somewhere on the page.
expect(await screen.findByText(eachFeature.title)).toBeValid();
}
}

expect(await screen.findAllByTestId("section")).toHaveLength(
content.sections.length
);
expect(await screen.findAllByTestId("free-secure")).toHaveLength(
content.freeSecure.length
content.sections.length + content.liveMapContact.length
);
});
});
4 changes: 2 additions & 2 deletions frontend-react/src/pages/home/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const Home = () => {
return (
<section
data-testid="section"
key={`section=${sectionIndex}`}
key={`home-${sectionIndex}`}
className="usa-section margin-y-0 tablet:padding-top-6 tablet:padding-bottom-3"
>
<div className="grid-row grid-gap">
Expand Down Expand Up @@ -52,7 +52,7 @@ export const Home = () => {
return (
<section
data-testid="section"
key={`section=${sectionIndex}`}
key={`livemap-${sectionIndex}`}
className="usa-section margin-y-0 tablet:padding-top-2 tablet:padding-bottom-2"
>
<div className="grid-row grid-gap">
Expand Down
18 changes: 8 additions & 10 deletions frontend-react/src/pages/tos-sign/SuccessPage.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,18 @@ describe("Basic rendering", () => {

test("Data is displayed", () => {
const name = screen.getByText(
`Full name: ${mockData.firstName} ${mockData.lastName}`,
`${mockData.firstName} ${mockData.lastName}`,
{ exact: false }
);
const email = screen.getByText(`Email: ${mockData.email}`, {
const email = screen.getByText(mockData.email, {
exact: false,
});
const territory = screen.getByText(mockData.territory, {
exact: false,
});
const organizationName = screen.getByText(mockData.organizationName, {
exact: false,
});
const territory = screen.getByText(
`State or territory: ${mockData.territory}`,
{ exact: false }
);
const organizationName = screen.getByText(
`Organization name: ${mockData.organizationName}`,
{ exact: false }
);

expect(name).toBeInTheDocument();
expect(email).toBeInTheDocument();
Expand Down
4 changes: 2 additions & 2 deletions frontend-react/src/pages/tos-sign/SuccessPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ function SuccessPage({ data }: { data: AgreementBody | null }) {
Registration request submitted
</h4>
<p className="usa-alert__text">
<strong>Name:</strong> {data.firstName}{" "}
{data.lastName}
<strong>Name:</strong>{" "}
{`${data.firstName} ${data.lastName}`}
<br />
<strong>Email:</strong> {data.email}
<br />
Expand Down
Loading

0 comments on commit 7640a4f

Please sign in to comment.