From 5112cbdf07cde1c4ec2d6cf8cbac85c233c20708 Mon Sep 17 00:00:00 2001
From: SidraJaved
Date: Fri, 3 Nov 2023 11:59:03 +0000
Subject: [PATCH 01/13] wip: updates in unit tests to support new external CATI
URL that will link to CaseInfo page. refactored config.tsx and
config.test.tsx work in progress in App.tsx and App.test.tsx
Co-authored-by: James Anthony Williams
Co-authored-by: motalm
---
server/Config.ts | 24 ++++++++++++----------
server/index.ts | 4 ++--
server/tests/config.test.ts | 6 +++---
src/App.test.tsx | 27 ++++++++++++++++++++++++-
src/App.tsx | 40 ++++++++++++++++++-------------------
5 files changed, 64 insertions(+), 37 deletions(-)
diff --git a/server/Config.ts b/server/Config.ts
index 531b6ee0..247db845 100644
--- a/server/Config.ts
+++ b/server/Config.ts
@@ -8,12 +8,12 @@ export interface EnvironmentVariables {
}
export function getEnvironmentVariables(): EnvironmentVariables {
- let {VM_EXTERNAL_CLIENT_URL,
- VM_EXTERNAL_WEB_URL,
- BLAISE_API_URL,
- BIMS_CLIENT_ID,
- BIMS_API_URL} = process.env;
- const CATI_DASHBOARD_URL = "https://" + VM_EXTERNAL_WEB_URL + "/Blaise";
+ let { VM_EXTERNAL_CLIENT_URL,
+ VM_EXTERNAL_WEB_URL,
+ BLAISE_API_URL,
+ BIMS_CLIENT_ID,
+ BIMS_API_URL } = process.env;
+ const CATI_DASHBOARD_URL = "https://" + VM_EXTERNAL_WEB_URL + "/Blaise/CaseInfo";
if (BLAISE_API_URL === undefined) {
console.error("BLAISE_API_URL environment variable has not been set");
@@ -40,12 +40,14 @@ export function getEnvironmentVariables(): EnvironmentVariables {
BIMS_API_URL = "ENV_VAR_NOT_SET";
}
- return {VM_EXTERNAL_CLIENT_URL,
- VM_EXTERNAL_WEB_URL,
+ return {
+ VM_EXTERNAL_CLIENT_URL,
+ VM_EXTERNAL_WEB_URL,
BLAISE_API_URL: fixURL(BLAISE_API_URL),
- CATI_DASHBOARD_URL,
- BIMS_CLIENT_ID,
- BIMS_API_URL};
+ CATI_DASHBOARD_URL,
+ BIMS_CLIENT_ID,
+ BIMS_API_URL
+ };
}
function fixURL(url: string): string {
diff --git a/server/index.ts b/server/index.ts
index d8561f71..c0360011 100644
--- a/server/index.ts
+++ b/server/index.ts
@@ -4,7 +4,7 @@ import * as profiler from "@google-cloud/profiler";
import { getEnvironmentVariables } from "./Config";
import dotenv from "dotenv";
-profiler.start({logLevel: 4}).catch((err: unknown) => {
+profiler.start({ logLevel: 4 }).catch((err: unknown) => {
console.log(`Failed to start profiler: ${err}`);
});
@@ -24,4 +24,4 @@ const app = nodeServer(environmentVariables, blaiseApiClient);
app.listen(port);
-console.log("App is listening on port " + port);
+console.log("App is listening on port " + port);
\ No newline at end of file
diff --git a/server/tests/config.test.ts b/server/tests/config.test.ts
index 58cce472..d3da0c8e 100644
--- a/server/tests/config.test.ts
+++ b/server/tests/config.test.ts
@@ -1,4 +1,4 @@
-import {getEnvironmentVariables} from "../Config";
+import { getEnvironmentVariables } from "../Config";
describe("Config setup", () => {
afterEach(() => {
@@ -20,7 +20,7 @@ describe("Config setup", () => {
expect(VM_EXTERNAL_CLIENT_URL).toBe("external-client-url");
expect(VM_EXTERNAL_WEB_URL).toBe("external-web-url");
expect(BLAISE_API_URL).toBe("http://mock");
- expect(CATI_DASHBOARD_URL).toBe("https://external-web-url/Blaise");
+ expect(CATI_DASHBOARD_URL).toBe("https://external-web-url/Blaise/CaseInfo");
expect(BIMS_CLIENT_ID).toBe("mock@id");
expect(BIMS_API_URL).toBe("mock-bims-api");
});
@@ -46,7 +46,7 @@ describe("Config setup", () => {
expect(VM_EXTERNAL_CLIENT_URL).toBe("ENV_VAR_NOT_SET");
expect(VM_EXTERNAL_WEB_URL).toBe("ENV_VAR_NOT_SET");
expect(BLAISE_API_URL).toBe("ENV_VAR_NOT_SET");
- expect(CATI_DASHBOARD_URL).toBe("https://undefined/Blaise");
+ expect(CATI_DASHBOARD_URL).toBe("https://undefined/Blaise/CaseInfo");
expect(BIMS_CLIENT_ID).toBe("ENV_VAR_NOT_SET");
expect(BIMS_API_URL).toBe("ENV_VAR_NOT_SET");
});
diff --git a/src/App.test.tsx b/src/App.test.tsx
index 5e1e92fe..f377634b 100644
--- a/src/App.test.tsx
+++ b/src/App.test.tsx
@@ -1,12 +1,13 @@
import React from "react";
import { render, waitFor, fireEvent, screen, cleanup } from "@testing-library/react";
-import App from "./App";
import "@testing-library/jest-dom";
import flushPromises from "./tests/utils";
import { act } from "react-dom/test-utils";
import { createMemoryHistory } from "history";
import { Router } from "react-router-dom";
import { Survey } from "blaise-api-node-client";
+import App from "./App";
+import { ExternalLink } from "blaise-design-system-react-components";
const surveyListReturned: Survey[] = [
{
@@ -187,3 +188,27 @@ describe("Given the API returns an empty list", () => {
cleanup();
});
});
+
+
+describe("Given the initial external CATI URL", () => {
+
+ beforeAll(() => {
+ mock_server_request(200, []);
+ });
+
+ it("it should return with /CaseInfo", async () => {
+
+ const history = createMemoryHistory();
+ render(
+
+
+
+ );
+
+ expect().toBeInTheDocument;
+
+ // const externalCATIUrlElement = getByText("/Blaise");
+ // const externalCATIUrl = externalCATIUrlElement.textContent;
+ // expect(externalCATIUrl).toEqual("/Blaise");
+ });
+});
\ No newline at end of file
diff --git a/src/App.tsx b/src/App.tsx
index 8ae3bed9..8719267a 100644
--- a/src/App.tsx
+++ b/src/App.tsx
@@ -1,12 +1,12 @@
-import React, {ReactElement, useEffect, useState} from "react";
-import {DefaultErrorBoundary} from "./Components/ErrorHandling/DefaultErrorBoundary";
-import {isDevEnv, isTrainingEnv} from "./Functions";
-import {Switch, Route} from "react-router-dom";
+import React, { ReactElement, useEffect, useState } from "react";
+import { DefaultErrorBoundary } from "./Components/ErrorHandling/DefaultErrorBoundary";
+import { isDevEnv, isTrainingEnv } from "./Functions";
+import { Switch, Route } from "react-router-dom";
import InstrumentList from "./Components/InstrumentList";
import SurveyList from "./Components/SurveyList";
-import {Survey} from "blaise-api-node-client";
-import {ErrorBoundary} from "./Components/ErrorHandling/ErrorBoundary";
-import {Footer, Header, ONSErrorPanel, ExternalLink} from "blaise-design-system-react-components";
+import { Survey } from "blaise-api-node-client";
+import { ErrorBoundary } from "./Components/ErrorHandling/ErrorBoundary";
+import { Footer, Header, ONSErrorPanel, ExternalLink } from "blaise-design-system-react-components";
interface listError {
error: boolean,
@@ -28,7 +28,7 @@ function App(): ReactElement {
useEffect(() => {
if (isTrainingEnv()) setHeaderText("Telephone Operations Blaise Interface (training)");
- });
+ });
const [externalClientUrl, setExternalClientUrl] = useState("External URL should be here");
const [externalCATIUrl, setExternalCATIUrl] = useState("/Blaise");
@@ -41,7 +41,7 @@ function App(): ReactElement {
}, [externalClientUrl, externalCATIUrl]);
const [surveys, setSurveys] = useState([]);
- const [listError, setListError] = useState({error: false, message: "Loading ..."});
+ const [listError, setListError] = useState({ error: false, message: "Loading ..." });
useEffect(() => {
getList();
@@ -61,20 +61,20 @@ function App(): ReactElement {
console.log("Retrieved instrument list, " + json.length + " items/s");
isDevEnv() && console.log(json);
setSurveys(json);
- setListError({error: false, message: ""});
+ setListError({ error: false, message: "" });
// If the list is empty then show this message in the list
- if (json.length === 0) setListError({error: false, message: "No active surveys found."});
+ if (json.length === 0) setListError({ error: false, message: "No active surveys found." });
})
.catch((error) => {
isDevEnv() && console.error("Unable to read json from response, error: " + error);
- setListError({error: true, message: "Unable to load surveys"});
+ setListError({ error: true, message: "Unable to load surveys" });
});
}).catch((error) => {
isDevEnv() && console.error("Failed to retrieve instrument list, error: " + error);
- setListError({error: true, message: "Unable to load surveys"});
+ setListError({ error: true, message: "Unable to load surveys" });
}
- );
+ );
}
@@ -93,28 +93,28 @@ function App(): ReactElement {
Please note, the table containing information on active questionnaires may
take a few seconds to load.
- {listError.error && }
+ {listError.error && }
+ link={externalCATIUrl}
+ id={"cati-dashboard"} />
-
+
-
+
-
+
>
);
}
From f33919c2692dfaacfaa41a1e1e9b3b75cf3aa92a Mon Sep 17 00:00:00 2001
From: James Anthony Williams <81305008+JAWilliamsONS@users.noreply.github.com>
Date: Fri, 3 Nov 2023 13:47:46 +0000
Subject: [PATCH 02/13] feat: change cati url to case info
---
src/App.test.tsx | 24 ------------------------
src/App.tsx | 2 +-
2 files changed, 1 insertion(+), 25 deletions(-)
diff --git a/src/App.test.tsx b/src/App.test.tsx
index f377634b..22ef664e 100644
--- a/src/App.test.tsx
+++ b/src/App.test.tsx
@@ -188,27 +188,3 @@ describe("Given the API returns an empty list", () => {
cleanup();
});
});
-
-
-describe("Given the initial external CATI URL", () => {
-
- beforeAll(() => {
- mock_server_request(200, []);
- });
-
- it("it should return with /CaseInfo", async () => {
-
- const history = createMemoryHistory();
- render(
-
-
-
- );
-
- expect().toBeInTheDocument;
-
- // const externalCATIUrlElement = getByText("/Blaise");
- // const externalCATIUrl = externalCATIUrlElement.textContent;
- // expect(externalCATIUrl).toEqual("/Blaise");
- });
-});
\ No newline at end of file
diff --git a/src/App.tsx b/src/App.tsx
index 8719267a..0a988266 100644
--- a/src/App.tsx
+++ b/src/App.tsx
@@ -31,7 +31,7 @@ function App(): ReactElement {
});
const [externalClientUrl, setExternalClientUrl] = useState("External URL should be here");
- const [externalCATIUrl, setExternalCATIUrl] = useState("/Blaise");
+ const [externalCATIUrl, setExternalCATIUrl] = useState("/Blaise/CaseInfo");
useEffect(function retrieveVariables() {
setExternalClientUrl(isDevEnv() ?
From af6cbff4e1f07bc48db1e8023ed3fd9a0e178804 Mon Sep 17 00:00:00 2001
From: James Anthony Williams <81305008+JAWilliamsONS@users.noreply.github.com>
Date: Fri, 3 Nov 2023 15:24:23 +0000
Subject: [PATCH 03/13] wip: bdd
---
src/features/CATI_Dashboard_Link.feature | 6 +++
.../CATI_Dashboard_Link.test.tsx | 54 +++++++++++++++++++
2 files changed, 60 insertions(+)
create mode 100644 src/features/CATI_Dashboard_Link.feature
create mode 100644 src/features/step_definitions/CATI_Dashboard_Link.test.tsx
diff --git a/src/features/CATI_Dashboard_Link.feature b/src/features/CATI_Dashboard_Link.feature
new file mode 100644
index 00000000..fadd0d22
--- /dev/null
+++ b/src/features/CATI_Dashboard_Link.feature
@@ -0,0 +1,6 @@
+Feature: Cati dashboard link
+
+ Scenario: Following the Cati dashboard link takes a user to the case info page
+ Given I access the Telephone Operations Blaise Interface URL
+ When I click the link to the CATI dashboard
+ Then I arrive at the Case Info tab URL
diff --git a/src/features/step_definitions/CATI_Dashboard_Link.test.tsx b/src/features/step_definitions/CATI_Dashboard_Link.test.tsx
new file mode 100644
index 00000000..bbc531bc
--- /dev/null
+++ b/src/features/step_definitions/CATI_Dashboard_Link.test.tsx
@@ -0,0 +1,54 @@
+
+import React from "react";
+import { defineFeature, loadFeature } from "jest-cucumber";
+import {cleanup, fireEvent, render, screen, waitFor} from "@testing-library/react";
+import { act } from "react-dom/test-utils";
+import { createMemoryHistory } from "history";
+import { Router } from "react-router-dom";
+import flushPromises from "../../tests/utils";
+
+import App from "../../App";
+
+const feature = loadFeature(
+ "./src/features/CATI_Dashboard_Link.feature",
+);
+
+
+defineFeature(feature, test => {
+ afterEach(() => {
+ jest.clearAllMocks();
+ cleanup();
+ jest.resetModules();
+ });
+
+ beforeEach(() => {
+ cleanup();
+ });
+
+ test("Following the Cati dashboard link takes a user to the case info page", ({ given, when, then }) => {
+ given("I access the Telephone Operations Blaise Interface URL", async () => {
+ const history = createMemoryHistory();
+ render(
+
+
+
+ );
+ await act(async () => {
+ await flushPromises();
+ });
+ });
+
+ when("I click the link to the CATI dashboard", async () => {
+ fireEvent.click(screen.getByText(/Link to CATI dashboard/i));
+ await act(async () => {
+ await flushPromises();
+ });
+ });
+
+ then("I arrive at the Case Info tab URL", async () => {
+ await waitFor(() => {
+ expect(window.location.pathname).toContain("/Blaise/CaseInfo");
+ });
+ });
+ });
+});
From fd31a47159e73d6af7fd54896a82ee3a31307d78 Mon Sep 17 00:00:00 2001
From: James Anthony Williams <81305008+JAWilliamsONS@users.noreply.github.com>
Date: Fri, 3 Nov 2023 15:56:31 +0000
Subject: [PATCH 04/13] chore: deploy dependabot bumps
---
.../CATI_Dashboard_Link.test.tsx | 123 ++++++++++--------
1 file changed, 69 insertions(+), 54 deletions(-)
diff --git a/src/features/step_definitions/CATI_Dashboard_Link.test.tsx b/src/features/step_definitions/CATI_Dashboard_Link.test.tsx
index bbc531bc..114733e1 100644
--- a/src/features/step_definitions/CATI_Dashboard_Link.test.tsx
+++ b/src/features/step_definitions/CATI_Dashboard_Link.test.tsx
@@ -1,54 +1,69 @@
-
-import React from "react";
-import { defineFeature, loadFeature } from "jest-cucumber";
-import {cleanup, fireEvent, render, screen, waitFor} from "@testing-library/react";
-import { act } from "react-dom/test-utils";
-import { createMemoryHistory } from "history";
-import { Router } from "react-router-dom";
-import flushPromises from "../../tests/utils";
-
-import App from "../../App";
-
-const feature = loadFeature(
- "./src/features/CATI_Dashboard_Link.feature",
-);
-
-
-defineFeature(feature, test => {
- afterEach(() => {
- jest.clearAllMocks();
- cleanup();
- jest.resetModules();
- });
-
- beforeEach(() => {
- cleanup();
- });
-
- test("Following the Cati dashboard link takes a user to the case info page", ({ given, when, then }) => {
- given("I access the Telephone Operations Blaise Interface URL", async () => {
- const history = createMemoryHistory();
- render(
-
-
-
- );
- await act(async () => {
- await flushPromises();
- });
- });
-
- when("I click the link to the CATI dashboard", async () => {
- fireEvent.click(screen.getByText(/Link to CATI dashboard/i));
- await act(async () => {
- await flushPromises();
- });
- });
-
- then("I arrive at the Case Info tab URL", async () => {
- await waitFor(() => {
- expect(window.location.pathname).toContain("/Blaise/CaseInfo");
- });
- });
- });
-});
+//
+// import React from "react";
+// import { defineFeature, loadFeature } from "jest-cucumber";
+// import {cleanup, fireEvent, render, screen, waitFor} from "@testing-library/react";
+// import { act } from "react-dom/test-utils";
+// import { createMemoryHistory } from "history";
+// import { Router } from "react-router-dom";
+// import flushPromises from "../../tests/utils";
+//
+// import App from "../../App";
+// import {survey_list_with_OPN_and_LMS_with_one_active_instrument_each} from "./API_Mock_Objects";
+// import {Survey} from "blaise-api-node-client";
+//
+// const feature = loadFeature(
+// "./src/features/CATI_Dashboard_Link.feature",
+// );
+//
+// function mock_server_request(returnedStatus: number, returnedJSON: Survey[]) {
+// global.fetch = jest.fn(() =>
+// Promise.resolve({
+// status: returnedStatus,
+// json: () => Promise.resolve(returnedJSON),
+// })
+// ) as jest.Mock;
+// }
+//
+// defineFeature(feature, test => {
+// afterEach(() => {
+// jest.clearAllMocks();
+// cleanup();
+// jest.resetModules();
+// });
+//
+// beforeEach(() => {
+// cleanup();
+// });
+//
+// test("Following the Cati dashboard link takes a user to the case info page", ({ given, when, then }) => {
+// given("I access the Telephone Operations Blaise Interface URL", async () => {
+// mock_server_request(
+// 200,
+// survey_list_with_OPN_and_LMS_with_one_active_instrument_each
+// );
+//
+// const history = createMemoryHistory();
+// render(
+//
+//
+//
+// );
+// await act(async () => {
+// await flushPromises();
+// });
+// });
+//
+// when("I click the link to the CATI dashboard", async () => {
+// fireEvent.click(screen.getByText(/Link to CATI dashboard/i));
+// await act(async () => {
+// await flushPromises();
+// });
+// });
+//
+// then("I arrive at the Case Info tab URL", async () => {
+// await waitFor(() => {
+// expect(window.location.pathname).toContain("/Blaise/CaseInfo");
+// });
+// });
+// });
+// });
From b9320e360ee23411a13f60b6d7878952ce41e40a Mon Sep 17 00:00:00 2001
From: James Anthony Williams <81305008+JAWilliamsONS@users.noreply.github.com>
Date: Mon, 6 Nov 2023 09:05:36 +0000
Subject: [PATCH 05/13] wip: bdd tests
---
src/features/step_definitions/CATI_Dashboard_Link.test.tsx | 1 -
1 file changed, 1 deletion(-)
diff --git a/src/features/step_definitions/CATI_Dashboard_Link.test.tsx b/src/features/step_definitions/CATI_Dashboard_Link.test.tsx
index 114733e1..fdbd5b61 100644
--- a/src/features/step_definitions/CATI_Dashboard_Link.test.tsx
+++ b/src/features/step_definitions/CATI_Dashboard_Link.test.tsx
@@ -1,4 +1,3 @@
-//
// import React from "react";
// import { defineFeature, loadFeature } from "jest-cucumber";
// import {cleanup, fireEvent, render, screen, waitFor} from "@testing-library/react";
From 93770a44aefde4ab54ee5cac51507057aa395d2c Mon Sep 17 00:00:00 2001
From: James Anthony Williams <81305008+JAWilliamsONS@users.noreply.github.com>
Date: Mon, 6 Nov 2023 09:23:14 +0000
Subject: [PATCH 06/13] chore: deploy dependabot bumps
---
src/features/CATI_Dashboard_Link.feature | 6 --
.../CATI_Dashboard_Link.test.tsx | 68 -------------------
2 files changed, 74 deletions(-)
delete mode 100644 src/features/CATI_Dashboard_Link.feature
delete mode 100644 src/features/step_definitions/CATI_Dashboard_Link.test.tsx
diff --git a/src/features/CATI_Dashboard_Link.feature b/src/features/CATI_Dashboard_Link.feature
deleted file mode 100644
index fadd0d22..00000000
--- a/src/features/CATI_Dashboard_Link.feature
+++ /dev/null
@@ -1,6 +0,0 @@
-Feature: Cati dashboard link
-
- Scenario: Following the Cati dashboard link takes a user to the case info page
- Given I access the Telephone Operations Blaise Interface URL
- When I click the link to the CATI dashboard
- Then I arrive at the Case Info tab URL
diff --git a/src/features/step_definitions/CATI_Dashboard_Link.test.tsx b/src/features/step_definitions/CATI_Dashboard_Link.test.tsx
deleted file mode 100644
index fdbd5b61..00000000
--- a/src/features/step_definitions/CATI_Dashboard_Link.test.tsx
+++ /dev/null
@@ -1,68 +0,0 @@
-// import React from "react";
-// import { defineFeature, loadFeature } from "jest-cucumber";
-// import {cleanup, fireEvent, render, screen, waitFor} from "@testing-library/react";
-// import { act } from "react-dom/test-utils";
-// import { createMemoryHistory } from "history";
-// import { Router } from "react-router-dom";
-// import flushPromises from "../../tests/utils";
-//
-// import App from "../../App";
-// import {survey_list_with_OPN_and_LMS_with_one_active_instrument_each} from "./API_Mock_Objects";
-// import {Survey} from "blaise-api-node-client";
-//
-// const feature = loadFeature(
-// "./src/features/CATI_Dashboard_Link.feature",
-// );
-//
-// function mock_server_request(returnedStatus: number, returnedJSON: Survey[]) {
-// global.fetch = jest.fn(() =>
-// Promise.resolve({
-// status: returnedStatus,
-// json: () => Promise.resolve(returnedJSON),
-// })
-// ) as jest.Mock;
-// }
-//
-// defineFeature(feature, test => {
-// afterEach(() => {
-// jest.clearAllMocks();
-// cleanup();
-// jest.resetModules();
-// });
-//
-// beforeEach(() => {
-// cleanup();
-// });
-//
-// test("Following the Cati dashboard link takes a user to the case info page", ({ given, when, then }) => {
-// given("I access the Telephone Operations Blaise Interface URL", async () => {
-// mock_server_request(
-// 200,
-// survey_list_with_OPN_and_LMS_with_one_active_instrument_each
-// );
-//
-// const history = createMemoryHistory();
-// render(
-//
-//
-//
-// );
-// await act(async () => {
-// await flushPromises();
-// });
-// });
-//
-// when("I click the link to the CATI dashboard", async () => {
-// fireEvent.click(screen.getByText(/Link to CATI dashboard/i));
-// await act(async () => {
-// await flushPromises();
-// });
-// });
-//
-// then("I arrive at the Case Info tab URL", async () => {
-// await waitFor(() => {
-// expect(window.location.pathname).toContain("/Blaise/CaseInfo");
-// });
-// });
-// });
-// });
From 288a0227462ea7733f2fa541c2bdf3f96962d4ab Mon Sep 17 00:00:00 2001
From: James Anthony Williams <81305008+JAWilliamsONS@users.noreply.github.com>
Date: Mon, 6 Nov 2023 12:50:42 +0000
Subject: [PATCH 07/13] wip: quick push for rich
---
src/features/CATI_Dashboard_Link.feature | 6 ++
.../CATI_Dashboard_Link.test.tsx | 72 +++++++++++++++++++
2 files changed, 78 insertions(+)
create mode 100644 src/features/CATI_Dashboard_Link.feature
create mode 100644 src/features/step_definitions/CATI_Dashboard_Link.test.tsx
diff --git a/src/features/CATI_Dashboard_Link.feature b/src/features/CATI_Dashboard_Link.feature
new file mode 100644
index 00000000..414f5d2b
--- /dev/null
+++ b/src/features/CATI_Dashboard_Link.feature
@@ -0,0 +1,6 @@
+Feature: Cati dashboard link
+
+ Scenario: Following the Cati dashboard link takes a user to the case info page
+ Given I access the Telephone Operations Blaise Interface URL
+ When I click the link to the CATI dashboard
+ Then I arrive at the Case Info tab URL
diff --git a/src/features/step_definitions/CATI_Dashboard_Link.test.tsx b/src/features/step_definitions/CATI_Dashboard_Link.test.tsx
new file mode 100644
index 00000000..badd9eac
--- /dev/null
+++ b/src/features/step_definitions/CATI_Dashboard_Link.test.tsx
@@ -0,0 +1,72 @@
+import React from "react";
+import { defineFeature, loadFeature } from "jest-cucumber";
+import {cleanup, fireEvent, render, screen, waitFor} from "@testing-library/react";
+import { act } from "react-dom/test-utils";
+import { createMemoryHistory } from "history";
+import { Router } from "react-router-dom";
+import flushPromises from "../../tests/utils";
+
+
+import App from "../../App";
+import {survey_list_with_OPN_and_LMS_with_one_active_instrument_each} from "./API_Mock_Objects";
+import {Survey} from "blaise-api-node-client";
+
+const feature = loadFeature(
+ "./src/features/CATI_Dashboard_Link.feature",
+);
+
+
+function mock_server_request(returnedStatus: number, returnedJSON: Survey[]) {
+ global.fetch = jest.fn(() =>
+ Promise.resolve({
+ status: returnedStatus,
+ json: () => Promise.resolve(returnedJSON),
+ })
+ ) as jest.Mock;
+}
+
+defineFeature(feature, test => {
+
+ afterEach(() => {
+ jest.clearAllMocks();
+ cleanup();
+ jest.resetModules();
+ });
+
+ beforeEach(() => {
+ cleanup();
+ });
+
+
+ test("Following the Cati dashboard link takes a user to the case info page", ({ given, when, then }) => {
+ given("I access the Telephone Operations Blaise Interface URL", async () => {
+ mock_server_request(
+ 200,
+ survey_list_with_OPN_and_LMS_with_one_active_instrument_each
+ );
+
+ const history = createMemoryHistory();
+ render(
+
+
+
+ );
+ await act(async () => {
+ await flushPromises();
+ });
+ });
+
+ when("I click the link to the CATI dashboard", async () => {
+ fireEvent.click(screen.getByText(/Link to CATI dashboard/i));
+ await act(async () => {
+ await flushPromises();
+ });
+ });
+
+ then("I arrive at the Case Info tab URL", async () => {
+ await waitFor(() => {
+ expect(window.location.pathname).toContain("/Blaise/CaseInfo");
+ });
+ });
+});
+});
From f6c8bc7d05a6202ab63bfb3677410b3ad916b67b Mon Sep 17 00:00:00 2001
From: kristian4res <57638182+kristian4res@users.noreply.github.com>
Date: Mon, 6 Nov 2023 15:10:00 +0000
Subject: [PATCH 08/13] test: CATI link points to {URL}/Blaise/CaseInfo
---
src/App.test.tsx | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/App.test.tsx b/src/App.test.tsx
index 22ef664e..80da2640 100644
--- a/src/App.test.tsx
+++ b/src/App.test.tsx
@@ -7,7 +7,6 @@ import { createMemoryHistory } from "history";
import { Router } from "react-router-dom";
import { Survey } from "blaise-api-node-client";
import App from "./App";
-import { ExternalLink } from "blaise-design-system-react-components";
const surveyListReturned: Survey[] = [
{
@@ -104,6 +103,8 @@ describe("React homepage", () => {
await waitFor(() => {
expect(getByText(/Telephone Operations Blaise Interface/i)).toBeDefined();
+ expect(queryByText(/Link to CATI dashboard/i)).toBeInTheDocument();
+ expect(queryByText(/Link to CATI dashboard/i)?.getAttribute("href")).toContain("/Blaise/CaseInfo");
expect(getByText(/OPN/i)).toBeDefined();
expect(queryByText(/Loading/i)).not.toBeInTheDocument();
});
From 6f3041e060290249dbe732d35b2ed4e43015526a Mon Sep 17 00:00:00 2001
From: kristian4res <57638182+kristian4res@users.noreply.github.com>
Date: Mon, 6 Nov 2023 15:10:59 +0000
Subject: [PATCH 09/13] test: specify node_env to dev and add test env URL
---
jest.config.js | 2 ++
1 file changed, 2 insertions(+)
diff --git a/jest.config.js b/jest.config.js
index a0addb24..1c8fff64 100644
--- a/jest.config.js
+++ b/jest.config.js
@@ -1,4 +1,6 @@
process.env = Object.assign(process.env, {
+ NODE_ENV: "development",
+ REACT_APP_CATI_DASHBOARD_URL: "cati-dashboard-url/Blaise/CaseInfo",
VM_EXTERNAL_CLIENT_URL: "external-client-url",
VM_EXTERNAL_WEB_URL: "external-web-url",
BLAISE_API_URL: "mock",
From a76a722906411a42b5ab2aacc06886835bd31f67 Mon Sep 17 00:00:00 2001
From: kristian4res <57638182+kristian4res@users.noreply.github.com>
Date: Mon, 6 Nov 2023 15:11:32 +0000
Subject: [PATCH 10/13] test: update App snapshot with new CATI endpoint
---
src/__snapshots__/App.test.tsx.snap | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/src/__snapshots__/App.test.tsx.snap b/src/__snapshots__/App.test.tsx.snap
index 37a016a6..bb137017 100644
--- a/src/__snapshots__/App.test.tsx.snap
+++ b/src/__snapshots__/App.test.tsx.snap
@@ -81,6 +81,7 @@ Object {
>
Date: Mon, 6 Nov 2023 16:35:03 +0000
Subject: [PATCH 11/13] check da link dunt clicky the link
---
src/features/step_definitions/CATI_Dashboard_Link.test.tsx | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/features/step_definitions/CATI_Dashboard_Link.test.tsx b/src/features/step_definitions/CATI_Dashboard_Link.test.tsx
index badd9eac..67f82b6d 100644
--- a/src/features/step_definitions/CATI_Dashboard_Link.test.tsx
+++ b/src/features/step_definitions/CATI_Dashboard_Link.test.tsx
@@ -65,7 +65,7 @@ defineFeature(feature, test => {
then("I arrive at the Case Info tab URL", async () => {
await waitFor(() => {
- expect(window.location.pathname).toContain("/Blaise/CaseInfo");
+ expect(screen.getByText(/Link to CATI dashboard/i).getAttribute("href")).toContain("/Blaise/CaseInfo");
});
});
});
From cdd8639305015bd863b00b7800a3b3679795e799 Mon Sep 17 00:00:00 2001
From: James Anthony Williams <81305008+JAWilliamsONS@users.noreply.github.com>
Date: Mon, 6 Nov 2023 16:40:10 +0000
Subject: [PATCH 12/13] refactor: change test desciprtions
---
src/features/CATI_Dashboard_Link.feature | 4 ++--
.../step_definitions/CATI_Dashboard_Link.test.tsx | 9 ++++-----
2 files changed, 6 insertions(+), 7 deletions(-)
diff --git a/src/features/CATI_Dashboard_Link.feature b/src/features/CATI_Dashboard_Link.feature
index 414f5d2b..89717379 100644
--- a/src/features/CATI_Dashboard_Link.feature
+++ b/src/features/CATI_Dashboard_Link.feature
@@ -2,5 +2,5 @@ Feature: Cati dashboard link
Scenario: Following the Cati dashboard link takes a user to the case info page
Given I access the Telephone Operations Blaise Interface URL
- When I click the link to the CATI dashboard
- Then I arrive at the Case Info tab URL
+ When the link to the CATI dashboard is present
+ Then it will take me to the CATI dashboard
diff --git a/src/features/step_definitions/CATI_Dashboard_Link.test.tsx b/src/features/step_definitions/CATI_Dashboard_Link.test.tsx
index 67f82b6d..e936b35f 100644
--- a/src/features/step_definitions/CATI_Dashboard_Link.test.tsx
+++ b/src/features/step_definitions/CATI_Dashboard_Link.test.tsx
@@ -56,14 +56,13 @@ defineFeature(feature, test => {
});
});
- when("I click the link to the CATI dashboard", async () => {
- fireEvent.click(screen.getByText(/Link to CATI dashboard/i));
- await act(async () => {
- await flushPromises();
+ when("the link to the CATI dashboard is present", async () => {
+ await waitFor(() => {
+ expect(screen.getByText(/Link to CATI dashboard/i))
});
});
- then("I arrive at the Case Info tab URL", async () => {
+ then("it will take me to the CATI dashboard", async () => {
await waitFor(() => {
expect(screen.getByText(/Link to CATI dashboard/i).getAttribute("href")).toContain("/Blaise/CaseInfo");
});
From df53e5ed62f09ca73d2a443be5e67ecbd3a237ef Mon Sep 17 00:00:00 2001
From: James Anthony Williams <81305008+JAWilliamsONS@users.noreply.github.com>
Date: Mon, 6 Nov 2023 17:00:30 +0000
Subject: [PATCH 13/13] refactor: change test desciprtions
---
src/features/step_definitions/CATI_Dashboard_Link.test.tsx | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/features/step_definitions/CATI_Dashboard_Link.test.tsx b/src/features/step_definitions/CATI_Dashboard_Link.test.tsx
index e936b35f..df429bd7 100644
--- a/src/features/step_definitions/CATI_Dashboard_Link.test.tsx
+++ b/src/features/step_definitions/CATI_Dashboard_Link.test.tsx
@@ -1,6 +1,6 @@
import React from "react";
import { defineFeature, loadFeature } from "jest-cucumber";
-import {cleanup, fireEvent, render, screen, waitFor} from "@testing-library/react";
+import {cleanup, render, screen, waitFor} from "@testing-library/react";
import { act } from "react-dom/test-utils";
import { createMemoryHistory } from "history";
import { Router } from "react-router-dom";
@@ -58,7 +58,7 @@ defineFeature(feature, test => {
when("the link to the CATI dashboard is present", async () => {
await waitFor(() => {
- expect(screen.getByText(/Link to CATI dashboard/i))
+ expect(screen.getByText(/Link to CATI dashboard/i));
});
});