Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into johanna/5600_replace_…
Browse files Browse the repository at this point in the history
…generic_exceptions

Merged with latest main code
  • Loading branch information
johanna-skylight committed Oct 10, 2023
2 parents 93c5f08 + 1f6d302 commit 7f6b83b
Show file tree
Hide file tree
Showing 13 changed files with 321 additions and 365 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/deployDemo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ jobs:
deploy:
runs-on: ubuntu-latest
environment:
name: ${{ env.DEPLOY_ENV }}
url: https://${{ env.DEPLOY_ENV }}.simplereport.gov
name: demo
url: https://demo.simplereport.gov
needs: [prerelease_backend]
steps:
- uses: actions/checkout@v4
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/deployProd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ jobs:
okta_enabled: true
okta_url: https://hhs-prime.okta.com
okta_client_id: 0oa5ahrdfSpxmNZO74h6
base_domain_name: www.simplereport.gov

prerelease_backend:
runs-on: ubuntu-latest
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/deployStg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ jobs:
deploy:
runs-on: ubuntu-latest
environment:
name: ${{ env.DEPLOY_ENV }}
url: https://${{ env.DEPLOY_ENV }}.simplereport.gov
name: stg
url: https://stg.simplereport.gov
needs: [prerelease_backend]
steps:
- uses: actions/checkout@v4
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/deployTest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ jobs:
deploy:
runs-on: ubuntu-latest
environment:
name: ${{ env.DEPLOY_ENV }}
url: https://${{ env.DEPLOY_ENV }}.simplereport.gov
name: test
url: https://test.simplereport.gov
needs: [prerelease_backend]
steps:
- uses: actions/checkout@v4
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/deployTraining.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ jobs:
deploy:
runs-on: ubuntu-latest
environment:
name: ${{ env.DEPLOY_ENV }}
url: https://${{ env.DEPLOY_ENV }}.simplereport.gov
name: training
url: https://training.simplereport.gov
needs: [prerelease_backend]
steps:
- uses: actions/checkout@v4
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/testingWorkflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ jobs:
outputs:
version: ${{ steps.set_backend_version.outputs.version }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Build Backend Image
id: set_backend_version
uses: ./.github/actions/docker-buildx
Expand All @@ -96,7 +96,7 @@ jobs:
outputs:
version: ${{ steps.set_cypress_version.outputs.version }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Build Cypress Image
id: set_cypress_version
uses: ./.github/actions/docker-buildx
Expand All @@ -121,7 +121,7 @@ jobs:
outputs:
version: ${{ steps.set_database_version.outputs.version }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Build Database Image
id: set_database_version
uses: ./.github/actions/docker-buildx
Expand All @@ -146,7 +146,7 @@ jobs:
outputs:
version: ${{ steps.set_frontend_version.outputs.version }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Build Frontend Image
id: set_frontend_version
uses: ./.github/actions/docker-buildx
Expand Down Expand Up @@ -179,7 +179,7 @@ jobs:
outputs:
version: ${{ steps.set_frontend_lighthouse_version.outputs.version }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Build Frontend Lighthouse Image
id: set_frontend_lighthouse_version
uses: ./.github/actions/docker-buildx
Expand Down Expand Up @@ -210,7 +210,7 @@ jobs:
outputs:
version: ${{ steps.set_nginx_version.outputs.version }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Build Nginx Image
id: set_nginx_version
uses: ./.github/actions/docker-buildx
Expand Down
186 changes: 77 additions & 109 deletions frontend/src/app/signUp/IdentityVerification/QuestionsForm.test.tsx
Original file line number Diff line number Diff line change
@@ -1,140 +1,108 @@
import {
act,
fireEvent,
render,
screen,
waitFor,
} from "@testing-library/react";
import { act, render, screen, waitFor } from "@testing-library/react";
import userEvent, { UserEvent } from "@testing-library/user-event";
import { MemoryRouter } from "react-router-dom";

import { exampleQuestionSet } from "./constants";
import QuestionsForm from "./QuestionsForm";
import { answerIdVerificationQuestions } from "./QuestionsFormContainer.test";

describe("QuestionsForm", () => {
let onSubmit: jest.Mock;
let onFail: jest.Mock;

const renderWithUser = () => ({
user: userEvent.setup(),
...render(
<MemoryRouter>
<QuestionsForm
questionSet={exampleQuestionSet}
saving={false}
onSubmit={onSubmit}
onFail={onFail}
/>
</MemoryRouter>
),
});

beforeEach(() => {
onSubmit = jest.fn();
onFail = jest.fn();

render(
<QuestionsForm
questionSet={exampleQuestionSet}
saving={false}
onSubmit={onSubmit}
onFail={onFail}
/>
);
});

it("initializes with the submit button enabled", () => {
renderWithUser();
expect(screen.getByText("Submit")).toBeEnabled();
});

describe("tests with fake timers", () => {
beforeAll(() => {
jest.useFakeTimers();
it("initializes with a counter and starts counting down", async () => {
jest.useFakeTimers();
renderWithUser();
expect(screen.getByText("5:00")).toBeInTheDocument();
await act(async () => {
jest.advanceTimersByTime(1000);
});

it("initializes with a counter and starts counting down", async () => {
expect(screen.getByText("5:00")).toBeInTheDocument();
await act(async () => {
jest.advanceTimersByTime(1000);
});
expect(screen.getByText("4:59")).toBeInTheDocument();
await act(async () => {
jest.advanceTimersByTime(2000);
});
expect(screen.getByText("4:59")).toBeInTheDocument();
await act(async () => {
jest.advanceTimersByTime(2000);
});
jest.runOnlyPendingTimers();
jest.useRealTimers();
});

afterAll(() => {
jest.runOnlyPendingTimers();
jest.useRealTimers();
});
it("enables the submit button when one field completed", async () => {
const { user } = renderWithUser();
await user.click(screen.getByLabelText("2002", { exact: false }));
await waitFor(() => expect(screen.getByText("Submit")).toBeEnabled());
});

describe("One field entered", () => {
it("enables the submit button", async () => {
fireEvent.click(screen.getByLabelText("2002", { exact: false }));
await waitFor(() => expect(screen.getByText("Submit")).toBeEnabled());
it("shows errors for required fields on submit of incomplete form", async () => {
const { user } = renderWithUser();
await user.click(screen.getByLabelText("2002", { exact: false }));
await user.click(
screen.queryAllByText("Submit", {
exact: false,
})[0]
);
await waitFor(() => {
expect(screen.queryAllByText("This field is required").length).toBe(4);
});
});

describe("On submit", () => {
it("shows errors for required fields", async () => {
fireEvent.click(screen.getByLabelText("2002", { exact: false }));
fireEvent.click(
screen.queryAllByText("Submit", {
exact: false,
})[0]
);
await waitFor(() => {
expect(screen.queryAllByText("This field is required").length).toBe(
4
);
});
});

it("does not call the onSubmit callback", async () => {
fireEvent.click(screen.getByLabelText("2002", { exact: false }));
fireEvent.click(
screen.queryAllByText("Submit", {
exact: false,
})[0]
);
await waitFor(() => {
expect(onSubmit).not.toHaveBeenCalled();
});
});
it("does not call the onSubmit callback", async () => {
const { user } = renderWithUser();
await user.click(screen.getByLabelText("2002", { exact: false }));
await user.click(
screen.queryAllByText("Submit", {
exact: false,
})[0]
);
await waitFor(() => {
expect(onSubmit).not.toHaveBeenCalled();
});
});

describe("Completed form", () => {
describe("On submit", () => {
it("does not show an error", async () => {
fireEvent.click(screen.getByLabelText("2002", { exact: false }));
fireEvent.click(
screen.getByLabelText("OPTICIAN / OPTOMETRIST", { exact: false })
);
fireEvent.click(
screen.getByLabelText("MID AMERICA MORTGAGE", { exact: false })
);
fireEvent.click(screen.getByLabelText("TWO", { exact: false }));
fireEvent.click(
screen.getByLabelText("AGUA DULCE HIGH SCHOOL", { exact: false })
);
fireEvent.click(
screen.queryAllByText("Submit", {
exact: false,
})[0]
);
await waitFor(() => {
expect(screen.queryAllByText("This field is required").length).toBe(
0
);
});
});
it("does not show error on submit of completed form", async () => {
const { user } = renderWithUser();
await fillAndSubmitIdVerificationQuestions(user);
await waitFor(() => {
expect(screen.queryAllByText("This field is required").length).toBe(0);
});
});

it("calls the onSubmit callback", async () => {
fireEvent.click(screen.getByLabelText("2002", { exact: false }));
fireEvent.click(
screen.getByLabelText("OPTICIAN / OPTOMETRIST", { exact: false })
);
fireEvent.click(
screen.getByLabelText("MID AMERICA MORTGAGE", { exact: false })
);
fireEvent.click(screen.getByLabelText("TWO", { exact: false }));
fireEvent.click(
screen.getByLabelText("AGUA DULCE HIGH SCHOOL", { exact: false })
);
fireEvent.click(
screen.queryAllByText("Submit", {
exact: false,
})[0]
);
await waitFor(() => {
expect(onSubmit).toHaveBeenCalled();
});
});
it("calls the onSubmit callback on submit of completed form", async () => {
const { user } = renderWithUser();
await fillAndSubmitIdVerificationQuestions(user);
await waitFor(() => {
expect(onSubmit).toHaveBeenCalled();
});
});
});

const fillAndSubmitIdVerificationQuestions = async (user: UserEvent) => {
await answerIdVerificationQuestions(user);
await user.click(
screen.queryAllByText("Submit", {
exact: false,
})[0]
);
};
Loading

0 comments on commit 7f6b83b

Please sign in to comment.