Skip to content

Commit dab4654

Browse files
committed
Fix reg tests and uts
Signed-off-by: Connor Avery <[email protected]>
1 parent a72ddc2 commit dab4654

File tree

2 files changed

+106
-9
lines changed

2 files changed

+106
-9
lines changed

.github/workflows/run_regression_tests.yml

Lines changed: 64 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,30 +67,86 @@ jobs:
6767
env:
6868
PYTHON_CONFIGURE_OPTS: --enable-shared
6969

70-
- name: Run Regression Testing
70+
- name: Run Regression Testing Non-Proxygen
7171
working-directory: scripts
7272
env:
7373
TARGET_ENVIRONMENT: ${{ inputs.ENVIRONMENT }}
7474
VERSION_NUMBER: ${{ inputs.VERSION_NUMBER }}
7575
GITHUB-TOKEN: ${{ steps.generate-token.outputs.token }}
7676
run: |
7777
if [[ "$TARGET_ENVIRONMENT" != "prod" && "$TARGET_ENVIRONMENT" != "ref" ]]; then
78-
# this should be the tag of the tests you want to run
79-
REGRESSION_TEST_REPO_TAG=v3.3.1
78+
REGRESSION_TEST_REPO_TAG="AEA-6037" # This is the tag or branch of the regression test code to run, usually a version tag like v3.1.0 or a branch name
79+
REGRESSION_TEST_WORKFLOW_TAG="v3.6.1" # This is the tag of the github workflow to run, usually the same as REGRESSION_TEST_REPO_TAG
8080
81-
# this should be the tag of the regression test workflow you want to run
82-
# This will normally be the same as REGRESSION_TEST_REPO_TAG
83-
REGRESSION_TEST_WORKFLOW_TAG=v3.3.1
81+
if [[ -z "$REGRESSION_TEST_REPO_TAG" || -z "$REGRESSION_TEST_WORKFLOW_TAG" ]]; then
82+
echo "Error: One or both tag variables are not set" >&2
83+
exit 1
84+
fi
85+
86+
# HELPER IF STATEMENT - It will automatically determine the correct Git URL to use based on the REGRESSION_TEST_WORKFLOW_TAG value
87+
if [[ "$REGRESSION_TEST_WORKFLOW_TAG" =~ ^v([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then
88+
echo "REGRESSION_TEST_WORKFLOW_TAG is a version tag, using tag link"
89+
curl "https://raw.githubusercontent.com/NHSDigital/electronic-prescription-service-api-regression-tests/refs/tags/${REGRESSION_TEST_WORKFLOW_TAG}/scripts/run_regression_tests.py" -o run_regression_tests.py
90+
else
91+
echo "REGRESSION_TEST_WORKFLOW_TAG doesn't look like a version tag, using branch link"
92+
curl "https://raw.githubusercontent.com/NHSDigital/electronic-prescription-service-api-regression-tests/refs/heads/${REGRESSION_TEST_REPO_TAG}/scripts/run_regression_tests.py" -o run_regression_tests.py
93+
fi
94+
95+
if [[ ! -f run_regression_tests.py ]]; then
96+
echo "Error: run_regression_tests.py not found" >&2
97+
exit 1
98+
fi
99+
100+
poetry install
101+
echo Running regression tests in the "$TARGET_ENVIRONMENT" environment
102+
poetry run python -u run_regression_tests.py \
103+
--env="$TARGET_ENVIRONMENT" \
104+
--pr_label="$VERSION_NUMBER" \
105+
--token=${{ steps.generate-token.outputs.token }} \
106+
--is_called_from_github=true \
107+
--product=${{ inputs.REGRESSION_TEST_PRODUCT }} \
108+
--regression_test_repo_tag "${REGRESSION_TEST_REPO_TAG}" \
109+
--regression_test_workflow_tag "${REGRESSION_TEST_WORKFLOW_TAG}"
110+
fi
111+
112+
- name: Run Regression Testing Proxygen
113+
working-directory: scripts
114+
env:
115+
TARGET_ENVIRONMENT: ${{ inputs.ENVIRONMENT }}
116+
VERSION_NUMBER: ${{ inputs.VERSION_NUMBER }}
117+
GITHUB-TOKEN: ${{ steps.generate-token.outputs.token }}
118+
run: |
119+
if [[ "$TARGET_ENVIRONMENT" != "prod" && "$TARGET_ENVIRONMENT" != "ref" ]]; then
120+
REGRESSION_TEST_REPO_TAG="AEA-6037" # This is the tag or branch of the regression test code to run, usually a version tag like v3.1.0 or a branch name
121+
REGRESSION_TEST_WORKFLOW_TAG="v3.6.1" # This is the tag of the github workflow to run, usually the same as REGRESSION_TEST_REPO_TAG
122+
123+
if [[ -z "$REGRESSION_TEST_REPO_TAG" || -z "$REGRESSION_TEST_WORKFLOW_TAG" ]]; then
124+
echo "Error: One or both tag variables are not set" >&2
125+
exit 1
126+
fi
127+
128+
# HELPER IF STATEMENT - It will automatically determine the correct Git URL to use based on the REGRESSION_TEST_WORKFLOW_TAG value
129+
if [[ "$REGRESSION_TEST_WORKFLOW_TAG" =~ ^v([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then
130+
echo "REGRESSION_TEST_WORKFLOW_TAG is a version tag, using tag link"
131+
curl "https://raw.githubusercontent.com/NHSDigital/electronic-prescription-service-api-regression-tests/refs/tags/${REGRESSION_TEST_WORKFLOW_TAG}/scripts/run_regression_tests.py" -o run_regression_tests.py
132+
else
133+
echo "REGRESSION_TEST_WORKFLOW_TAG doesn't look like a version tag, using branch link"
134+
curl "https://raw.githubusercontent.com/NHSDigital/electronic-prescription-service-api-regression-tests/refs/heads/${REGRESSION_TEST_REPO_TAG}/scripts/run_regression_tests.py" -o run_regression_tests.py
135+
fi
136+
137+
if [[ ! -f run_regression_tests.py ]]; then
138+
echo "Error: run_regression_tests.py not found" >&2
139+
exit 1
140+
fi
84141
85-
curl https://raw.githubusercontent.com/NHSDigital/electronic-prescription-service-api-regression-tests/refs/tags/${REGRESSION_TEST_WORKFLOW_TAG}/scripts/run_regression_tests.py -o run_regression_tests.py
86142
poetry install
87143
echo Running regression tests in the "$TARGET_ENVIRONMENT" environment
88144
poetry run python -u run_regression_tests.py \
89145
--env="$TARGET_ENVIRONMENT" \
90146
--pr_label="$VERSION_NUMBER" \
91147
--token=${{ steps.generate-token.outputs.token }} \
92148
--is_called_from_github=true \
93-
--product ${{ inputs.REGRESSION_TEST_PRODUCT }} \
149+
--product="PFP-PROXYGEN" \
94150
--regression_test_repo_tag "${REGRESSION_TEST_REPO_TAG}" \
95151
--regression_test_workflow_tag "${REGRESSION_TEST_WORKFLOW_TAG}"
96152
fi

packages/getMyPrescriptions/tests/extractNHSNumber.test.ts

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
import {extractNHSNumber, NHSNumberValidationError, validateNHSNumber} from "../src/extractNHSNumber"
1+
import {
2+
extractNHSNumber,
3+
extractNHSNumberFromHeaders,
4+
NHSNumberValidationError,
5+
validateNHSNumber
6+
} from "../src/extractNHSNumber"
27
import "jest"
38

49
type failureTestData = {nhsdLoginUser: string | undefined; errorMessage: string; scenarioDescription: string}
@@ -61,3 +66,39 @@ describe("validateNHSNumber function", () => {
6166
}).toThrow(new NHSNumberValidationError(`Invalid check digit in NHS number ${nhsNumber}`))
6267
})
6368
})
69+
70+
describe("extractNHSNumberFromHeaders function", () => {
71+
it("should extract NHS number using validateNHSNumber when proofing level header is present", () => {
72+
const headers = {
73+
"nhs-login-identity-proofing-level": "P9",
74+
"nhsd-nhslogin-user": "9912003071"
75+
}
76+
const result = extractNHSNumberFromHeaders(headers)
77+
expect(result).toBe("9912003071")
78+
})
79+
80+
it("should extract NHS number using extractNHSNumber when proofing level header is absent", () => {
81+
const headers = {
82+
"nhsd-nhslogin-user": "P9:9912003071"
83+
}
84+
const result = extractNHSNumberFromHeaders(headers)
85+
expect(result).toBe("9912003071")
86+
})
87+
88+
it("should throw error when proofing level header is present but NHS number is invalid", () => {
89+
const headers = {
90+
"nhs-login-identity-proofing-level": "P9",
91+
"nhsd-nhslogin-user": "9912003072"
92+
}
93+
expect(() => {
94+
extractNHSNumberFromHeaders(headers)
95+
}).toThrow(new NHSNumberValidationError("Invalid check digit in NHS number 9912003072"))
96+
})
97+
98+
it("should throw error when proofing level header is absent and nhsd-nhslogin-user is undefined", () => {
99+
const headers = {}
100+
expect(() => {
101+
extractNHSNumberFromHeaders(headers)
102+
}).toThrow(new NHSNumberValidationError("nhsdloginUser not passed in"))
103+
})
104+
})

0 commit comments

Comments
 (0)