diff --git a/README.md b/README.md
index 1d354259..a113dada 100644
--- a/README.md
+++ b/README.md
@@ -66,14 +66,15 @@ Create a new .env file and add the following variables.
| Variable | Description | Var Example |
|----------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------|
| PORT | **Optional variable**, specify the Port for express server to run on. If not passed in this is set as 5000 by default.
It's best not to set this as the react project will try and use the variable as well and conflict. By default, React project locally runs on port 3000 | 5009 |
-| BLAISE_API_URL | Url that the [Blaise Rest API](https://github.com/ONSdigital/blaise-api-rest) is running on to send calls to | localhost:90 |
+| BLAISE_API_URL | URL that the [Blaise Rest API](https://github.com/ONSdigital/blaise-api-rest) is running on to send calls to | localhost:90 |
| PROJECT_ID | GCP Project ID | ons-blaise-dev-matt55 |
| BUCKET_NAME | GCP Bucket name for the Questionnaire file to be put in | ons-blaise-dev-matt55-dqs |
| SERVER_PARK | Name of Blaise Server Park | gusty |
-| BIMS_API_URL | Url that the [BIMS Service](https://github.com/ONSdigital/blaise-instrument-metadata-service) is running on to send calls to set and get the live date | localhost:5011 |
+| BIMS_API_URL | URL that the [BIMS Service](https://github.com/ONSdigital/blaise-instrument-metadata-service) is running on to send calls to set and get the live date | localhost:5011 |
| BIMS_CLIENT_ID | GCP IAP ID for the [BIMS Service](https://github.com/ONSdigital/blaise-instrument-metadata-service) | randomKey0112 |
| BUS_API_CLIENT | Not needed for local development but the config will look for this variables in the .env file and throw an error if it is not found. Hence, give them a random string | FOO |
| BUS_CLIENT_ID | Not needed for local development but the config will look for this variables in the .env file and throw an error if it is not found. Hence, give them a random string | FOO |
+| CREATE_DONOR_CASES_CLOUD_FUNCTION_URL | URL to trigger the Create Donor Cases Cloud Function in GCP. This is needed when you want to deploy donor cases for an IPS questionnaire. **The Cloud Function needs to be deployed in GCP**. | https://example-cloud-function-url.com |
To find the `X_CLIENT_ID`, navigate to the GCP console, search for `IAP`, click the three dots on right of the service and select `OAuth`. `Client Id` will be on the right.
@@ -90,7 +91,9 @@ BIMS_API_URL=localhost:5000
BIMS_CLIENT_ID=randomKey0778
BUS_API_URL=FOO
BUS_CLIENT_ID=FOO
+CREATE_DONOR_CASES_CLOUD_FUNCTION_URL=
```
+**NB** DQS environment variables for sandboxes can be found within GCP > App Engine > Versions > DQS service > Config
Install the project dependencies:
diff --git a/src/components/questionnaireDetailsPage/sections/createDonorCases.test.tsx b/src/components/questionnaireDetailsPage/sections/createDonorCases.test.tsx
index ad3a418c..5723889b 100644
--- a/src/components/questionnaireDetailsPage/sections/createDonorCases.test.tsx
+++ b/src/components/questionnaireDetailsPage/sections/createDonorCases.test.tsx
@@ -8,7 +8,7 @@ import { act } from "react-dom/test-utils";
import React from "react";
import axios from "axios";
import MockAdapter from "axios-mock-adapter";
-import { ipsQuestionnaire } from "../../../features/step_definitions/helpers/apiMockObjects";
+import { ipsPilotQuestionnaire, ipsQuestionnaire } from "../../../features/step_definitions/helpers/apiMockObjects";
import { Authenticate } from "blaise-login-react/blaise-login-react-client";
import CreateDonorCases from "./createDonorCases";
import { MemoryRouter } from "react-router-dom";
@@ -21,20 +21,18 @@ const { MockAuthenticate } = jest.requireActual("blaise-login-react/blaise-login
Authenticate.prototype.render = MockAuthenticate.prototype.render;
MockAuthenticate.OverrideReturnValues(null, true);
-describe("IPS questionnaire", () => {
- beforeEach(() => {
+describe("IPS questionnaires", () => {
+ afterEach(() => {
+ mock.reset();
+ });
+
+ it("should display the option to create donor cases for IPS Manager and IPS Field Interviewer", async () => {
render(
);
- });
- afterEach(() => {
- mock.reset();
- });
-
- it("should display the option to create donor cases for IPS Manager and IPS Field Interviewer", async () => {
await act(async () => {
await flushPromises();
});
@@ -47,4 +45,22 @@ describe("IPS questionnaire", () => {
});
});
+
+ it("should display the option to create donor cases for IPS Pilot Interviewer only given it's an IPS Pilot Questionnaire", async () => {
+ render(
+
+
+
+ );
+
+ await act(async () => {
+ await flushPromises();
+ });
+
+ await waitFor(() => {
+ expect(screen.getByText("IPS Pilot Interviewer")).toBeDefined();
+ const createCasesElements = screen.getAllByText("Create cases");
+ expect(createCasesElements.length).toBe(1);
+ });
+ });
});
\ No newline at end of file
diff --git a/src/components/questionnaireDetailsPage/sections/createDonorCases.tsx b/src/components/questionnaireDetailsPage/sections/createDonorCases.tsx
index 8c9567c2..2bf4219e 100644
--- a/src/components/questionnaireDetailsPage/sections/createDonorCases.tsx
+++ b/src/components/questionnaireDetailsPage/sections/createDonorCases.tsx
@@ -1,6 +1,4 @@
import React, { ReactElement } from "react";
-import dateFormatter from "dayjs";
-import QuestionnaireStatus from "../../questionnaireStatus";
import { Questionnaire } from "blaise-api-node-client";
import { Link } from "react-router-dom";
@@ -8,7 +6,16 @@ interface Props {
questionnaire: Questionnaire;
}
+const VALID_IPS_ROLES = ["IPS Manager", "IPS Field Interviewer", "IPS Pilot Interviewer"];
+
function CreateDonorCases({ questionnaire }: Props): ReactElement {
+ const ipsPilotQuestionnairePattern = /^IPS\d{2}00[A-Za-z]$/;
+ const isIPSPilotQuestionnaire = ipsPilotQuestionnairePattern.test(questionnaire.name);
+
+ const rolesToRender = isIPSPilotQuestionnaire
+ ? ["IPS Pilot Interviewer"]
+ : VALID_IPS_ROLES.filter(role => role !== "IPS Pilot Interviewer");
+
return (
<>