Data stream
diff --git a/frontend/src/app/testResults/submissions/Submissions.test.tsx b/frontend/src/app/testResults/submissions/Submissions.test.tsx
index 58c1a830dc..325344f69f 100644
--- a/frontend/src/app/testResults/submissions/Submissions.test.tsx
+++ b/frontend/src/app/testResults/submissions/Submissions.test.tsx
@@ -1,4 +1,10 @@
-import { fireEvent, render, screen, waitFor } from "@testing-library/react";
+import {
+ act,
+ fireEvent,
+ render,
+ screen,
+ waitFor,
+} from "@testing-library/react";
import createMockStore from "redux-mock-store";
import { MockedProvider } from "@apollo/client/testing";
import { Provider } from "react-redux";
@@ -142,7 +148,7 @@ describe("Submissions", () => {
);
- await new Promise((resolve) => setTimeout(resolve, 0));
+
expect(await screen.findByText("No results"));
expect(screen.queryByRole("navigation")).not.toBeInTheDocument();
});
@@ -157,7 +163,6 @@ describe("Submissions", () => {
);
- await new Promise((resolve) => setTimeout(resolve, 0));
expect(await screen.findByText("reportId_1"));
expect(await screen.findByText("reportId_2"));
@@ -186,9 +191,7 @@ describe("Submissions", () => {
const startDateInput = screen.getByTestId("start-date");
fireEvent.change(startDateInput, { target: { value: "2021-01-01" } });
await waitFor(() => expect(startDateInput).toHaveValue("2021-01-01"));
- await userEvent.tab();
-
- await new Promise((resolve) => setTimeout(resolve, 0));
+ await act(async () => await userEvent.tab());
expect(await screen.findByText("reportId_2"));
expect(await screen.findByText("reportId_3"));
@@ -213,7 +216,6 @@ describe("Submissions", () => {
const endDateInput = screen.getByTestId("end-date");
fireEvent.change(endDateInput, { target: { value: "2022-01-01" } });
- await new Promise((resolve) => setTimeout(resolve, 0));
await waitFor(() =>
expect(screen.queryByText("reportId_1")).not.toBeInTheDocument()
@@ -235,8 +237,6 @@ describe("Submissions", () => {
);
- await new Promise((resolve) => setTimeout(resolve, 0));
-
await forEach([result_1, result_2, result_3], async (result) => {
await waitFor(() =>
expect(screen.getByText(result.reportId).closest("a")).toHaveAttribute(
diff --git a/frontend/src/app/testResults/uploads/Uploads.test.tsx b/frontend/src/app/testResults/uploads/Uploads.test.tsx
index 15bec5ba31..fa74594c77 100644
--- a/frontend/src/app/testResults/uploads/Uploads.test.tsx
+++ b/frontend/src/app/testResults/uploads/Uploads.test.tsx
@@ -1,4 +1,4 @@
-import { render, screen, waitFor } from "@testing-library/react";
+import { act, render, screen, waitFor } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import createMockStore from "redux-mock-store";
import { Provider } from "react-redux";
@@ -7,6 +7,7 @@ import { ApplicationInsights } from "@microsoft/applicationinsights-web";
import React from "react";
import { MemoryRouter as Router } from "react-router";
+import { file } from "../../utils/file";
import { getAppInsights } from "../../TelemetryService";
import { FileUploadService } from "../../../fileUploadService/FileUploadService";
import SRToastContainer from "../../commonComponents/SRToastContainer";
@@ -36,13 +37,6 @@ const validFileContents =
"Patient_last_name,Patient_first_name,Patient_middle_name,Patient_suffix,Patient_tribal_affiliation,Patient_ID,Ordered_test_code,Specimen_source_site_code,Specimen_type_code,Device_ID,Instrument_ID,Result_ID,Corrected_result_ID,Test_correction_reason,Test_result_status,Test_result_code,Illness_onset_date,Specimen_collection_date_time,Order_test_date,Test_date,Date_result_released,Patient_race,Patient_DOB,Patient_gender,Patient_ethnicity,Patient_preferred_language,Patient_street,Patient_street_2,Patient_city,Patient_state,Patient_zip_code,Patient_country,Patient_phone_number,Patient_county,Patient_email,Patient_role,Processing_mode_code,Employed_in_healthcare,Resident_congregate_setting,First_test,Symptomatic_for_disease,Testing_lab_name,Testing_lab_CLIA,Testing_lab_street,Testing_lab_street_2,Testing_lab_city,Testing_lab_state,Testing_lab_zip_code,Testing_lab_phone_number,Testing_lab_county,Organization_name,Ordering_facility_name,Ordering_facility_street,Ordering_facility_street_2,Ordering_facility_city,Ordering_facility_state,Ordering_facility_zip_code,Ordering_facility_phone_number,Ordering_facility_county,Ordering_provider_ID,Ordering_provider_last_name,Ordering_provider_first_name,Ordering_provider_street,Ordering_provider_street_2,Ordering_provider_city,Ordering_provider_state,Ordering_provider_zip_code,Ordering_provider_phone_number,Ordering_provider_county,Site_of_care\n" +
"Alaska1,Judy,Suellen,,39,xen4p,94558-4,71836000,440500007,BD Veritor System for Rapid Detection of SARS-CoV-2,939273,Alaska1,613603,nh1rigems,F,260373001,20220225,202202201809-0500,202202261540-0500,20220221,20220220,2106-3,,F,H,Iloko,10269 Larry Villages,,Yellow jacket,AK,81335,USA,2853464789,Montezuma,lyndon.smitham@email.com,kgvmoxba,P,Y,UNK,N,Y,Any lab USA,BadCLIA,3279 Schroeder Mountain,,Yellow jacket,AK,81335,2365001476,Montezuma,see3r8,Any facility USA,35260 Dustin Crossroad,,Yellow jacket,AK,81335,2862149859,Montezuma,1368398388,Huels,Bradley,283 Runolfsson Drive,,Yellow jacket,AK,81335,2241497529,Montezuma,camp\n";
-export const file = (text: BlobPart) => {
- const blob = new Blob([text]);
- const file = new File([blob], "values.csv", { type: "text/csv" });
- File.prototype.text = jest.fn().mockResolvedValueOnce(text);
- return file;
-};
-
const validFile = () => file(validFileContents);
const TestContainer = () => (
@@ -70,7 +64,7 @@ describe("Uploads", () => {
const emptyFile = file("");
const input = screen.getByTestId("upload-csv-input");
- await userEvent.upload(input, emptyFile);
+ await act(async () => await userEvent.upload(input, emptyFile));
expect(
await screen.findByText(
"The file 'values.csv' doesn't contain any valid data. File should have a header line and at least one line of data."
@@ -88,7 +82,7 @@ describe("Uploads", () => {
const tooManyRows = file("\n".repeat(10001));
const input = screen.getByTestId("upload-csv-input");
- await userEvent.upload(input, tooManyRows);
+ await act(async () => await userEvent.upload(input, tooManyRows));
expect(
await screen.findByText(
@@ -107,7 +101,7 @@ describe("Uploads", () => {
const tooBig = file("0".repeat(50 * 1000 * 1000 + 1));
const input = screen.getByTestId("upload-csv-input");
- await userEvent.upload(input, tooBig);
+ await act(async () => await userEvent.upload(input, tooBig));
expect(
await screen.findByText(
@@ -126,7 +120,7 @@ describe("Uploads", () => {
const tooManyColumns = file("a, ".repeat(2001) + "\n");
const input = screen.getByTestId("upload-csv-input");
- await userEvent.upload(input, tooManyColumns);
+ await act(async () => await userEvent.upload(input, tooManyColumns));
expect(
await screen.findByText(
@@ -180,7 +174,7 @@ describe("Uploads", () => {
render(
);
const fileInput = screen.getByTestId("upload-csv-input");
- await userEvent.upload(fileInput, file);
+ await act(async () => await userEvent.upload(fileInput, file));
expect(
screen.getByText(
@@ -189,7 +183,7 @@ describe("Uploads", () => {
).toBeInTheDocument();
const submitButton = screen.getByTestId("button");
- await userEvent.click(submitButton);
+ await act(async () => await userEvent.click(submitButton));
await waitFor(() => {
expect(
screen.getByText("Success: File Accepted")
@@ -233,14 +227,14 @@ describe("Uploads", () => {
render(
);
const fileInput = screen.getByTestId("upload-csv-input");
- await userEvent.upload(fileInput, validFile());
+ await act(async () => await userEvent.upload(fileInput, validFile()));
expect(
screen.getByText("Drag file here or choose from folder to change file")
).toBeInTheDocument();
const submitButton = screen.getByTestId("button");
- await userEvent.click(submitButton);
+ await act(async () => await userEvent.click(submitButton));
await waitFor(() => {
expect(
@@ -288,13 +282,13 @@ describe("Uploads", () => {
await render(
);
const fileInput = screen.getByTestId("upload-csv-input");
- await userEvent.upload(fileInput, validFile());
+ await act(async () => await userEvent.upload(fileInput, validFile()));
expect(
screen.getByText("Drag file here or choose from folder to change file")
).toBeInTheDocument();
const submitButton = screen.getByTestId("button");
- await userEvent.click(submitButton);
+ await act(async () => await userEvent.click(submitButton));
await waitFor(() => {
expect(
diff --git a/frontend/src/app/utils/Prompt.test.tsx b/frontend/src/app/utils/Prompt.test.tsx
index 6791ea6e75..8c990b9b74 100644
--- a/frontend/src/app/utils/Prompt.test.tsx
+++ b/frontend/src/app/utils/Prompt.test.tsx
@@ -1,5 +1,5 @@
import { Link, MemoryRouter, Outlet, Route, Routes } from "react-router-dom";
-import { render, screen } from "@testing-library/react";
+import { act, render, screen } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import Prompt from "./Prompt";
@@ -42,7 +42,9 @@ describe("A
", () => {
expect(screen.getByText("This is the first page")).toBeInTheDocument();
// WHEN
- await userEvent.click(screen.getByText("Go to a new page"));
+ await act(
+ async () => await userEvent.click(screen.getByText("Go to a new page"))
+ );
// THEN
expect(screen.queryByText("Went to a new page!")).not.toBeInTheDocument();
@@ -89,7 +91,9 @@ describe("A ", () => {
expect(screen.getByText("This is the first page")).toBeInTheDocument();
// WHEN
- await userEvent.click(screen.getByText("Go to a new page"));
+ await act(
+ async () => await userEvent.click(screen.getByText("Go to a new page"))
+ );
// THEN
expect(confirmMock).toHaveBeenCalledWith(
@@ -136,7 +140,9 @@ describe("A ", () => {
expect(screen.getByText("This is the first page")).toBeInTheDocument();
// WHEN
- await userEvent.click(screen.getByText("Go to a new page"));
+ await act(
+ async () => await userEvent.click(screen.getByText("Go to a new page"))
+ );
// THEN
expect(screen.getByText("Went to a new page!")).toBeInTheDocument();
diff --git a/frontend/src/app/utils/file.ts b/frontend/src/app/utils/file.ts
new file mode 100644
index 0000000000..bffd11b7f0
--- /dev/null
+++ b/frontend/src/app/utils/file.ts
@@ -0,0 +1,6 @@
+export const file = (text: BlobPart) => {
+ const blob = new Blob([text]);
+ const file = new File([blob], "values.csv", { type: "text/csv" });
+ File.prototype.text = jest.fn().mockResolvedValueOnce(text);
+ return file;
+};
diff --git a/frontend/src/patientApp/PatientHeader.test.tsx b/frontend/src/patientApp/PatientHeader.test.tsx
index c5c16a2c5d..c910d0c4b9 100644
--- a/frontend/src/patientApp/PatientHeader.test.tsx
+++ b/frontend/src/patientApp/PatientHeader.test.tsx
@@ -1,4 +1,4 @@
-import { render, screen } from "@testing-library/react";
+import { act, render, screen } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import { MemoryRouter } from "react-router-dom";
import configureStore from "redux-mock-store";
@@ -45,7 +45,7 @@ describe("PatientHeader", () => {
expect(screen.getByText("Español")).toBeInTheDocument();
- await userEvent.click(screen.getByRole("button"));
+ await act(async () => await userEvent.click(screen.getByRole("button")));
expect(screen.queryByText("Español")).not.toBeInTheDocument();
expect(screen.getByText("English")).toBeInTheDocument();