Skip to content

Commit b001f01

Browse files
SamRobinson75684stephhou
authored andcommitted
feat: end to end tests for DTOSS-7680 (#1576)
1 parent 2895776 commit b001f01

7 files changed

Lines changed: 350 additions & 1 deletion

File tree

tests/playwright-tests/src/api/core/sendHTTPRequest.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,12 @@ export const sendHttpGet =
2020
url: string
2121
): Promise<Response> =>
2222
{
23-
const response = await fetch(url);
23+
const response = await fetch(url, {
24+
method: "GET",
25+
headers: {
26+
"Content-Type": "application/json",
27+
},
28+
});
2429
return response;
2530
}
2631

tests/playwright-tests/src/config/env.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ export const config = {
4444
SubToNems: subToNemsEndPoint,
4545
wireMockUrl: wireMockUrl,
4646
SubToNemsPath: 'api/Subscribe',
47+
CheckNemsSubPath:'api/CheckSubscriptionStatus',
4748
routeBsSelectRetrieveCohortDistributionData: 'api/RetrieveCohortDistributionData',
4849
routeBsSelectRetrieveCohortRequestAudit: 'api/RetrieveCohortRequestAudit',
4950
routeBsSelectDeleteParticipant: 'api/DeleteParticipant',
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
{
2+
"validations": [
3+
{
4+
"validations": {
5+
"apiEndpoint": "api/CohortDistributionDataService",
6+
"NHSNumber": 9998380197
7+
}
8+
}
9+
],
10+
"inputParticipantRecord": [
11+
{
12+
"record_type": "ADD",
13+
"change_time_stamp": null,
14+
"serial_change_number": 1,
15+
"nhs_number": 9998380197,
16+
"superseded_by_nhs_number": null,
17+
"primary_care_provider": "A81623",
18+
"primary_care_effective_from_date": "20240101",
19+
"current_posting": "LA",
20+
"current_posting_effective_from_date": "20240101",
21+
"name_prefix": "BRO",
22+
"given_name": "smith",
23+
"other_given_name": "OtherGivenName 1",
24+
"family_name": "smith",
25+
"previous_family_name": "PreviousFamilyName 1",
26+
"date_of_birth": "20101022",
27+
"gender": 2,
28+
"address_line_1": "1 Test Street",
29+
"address_line_2": "Test Area",
30+
"address_line_3": "TestAddress",
31+
"address_line_4": "Chelmsford",
32+
"address_line_5": "United Kingdom",
33+
"postcode": "LS1 1AA",
34+
"paf_key": "Z3S4Q5X9",
35+
"address_effective_from_date": "20240101",
36+
"reason_for_removal": "ORR",
37+
"reason_for_removal_effective_from_date": null,
38+
"date_of_death": null,
39+
"death_status": null,
40+
"home_telephone_number": "01619999999",
41+
"home_telephone_effective_from_date": "20240101",
42+
"mobile_telephone_number": "07888888888",
43+
"mobile_telephone_effective_from_date": "20240101",
44+
"email_address": "blockedadd@example.com",
45+
"email_address_effective_from_date": "20240101",
46+
"preferred_language": "en",
47+
"is_interpreter_required": false,
48+
"invalid_flag": false,
49+
"eligibility": true
50+
}
51+
],
52+
"nhsNumbers": [
53+
"9998380197"
54+
]
55+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
{
2+
"validations": [
3+
{
4+
"validations": {
5+
"apiEndpoint": "api/CohortDistributionDataService",
6+
"NHSNumber": 9998380197
7+
}
8+
}
9+
],
10+
"inputParticipantRecord": [
11+
{
12+
"record_type": "DEL",
13+
"change_time_stamp": null,
14+
"serial_change_number": 1,
15+
"nhs_number": 9998380197,
16+
"superseded_by_nhs_number": null,
17+
"primary_care_provider": "A81623",
18+
"primary_care_effective_from_date": "20240101",
19+
"current_posting": "LA",
20+
"current_posting_effective_from_date": "20240101",
21+
"name_prefix": "BRO",
22+
"given_name": "smith",
23+
"other_given_name": "OtherGivenName 1",
24+
"family_name": "smith",
25+
"previous_family_name": "PreviousFamilyName 1",
26+
"date_of_birth": "20101022",
27+
"gender": 2,
28+
"address_line_1": "1 Test Street",
29+
"address_line_2": "Test Area",
30+
"address_line_3": "TestAddress",
31+
"address_line_4": "Chelmsford",
32+
"address_line_5": "United Kingdom",
33+
"postcode": "LS1 1AA",
34+
"paf_key": "Z3S4Q5X9",
35+
"address_effective_from_date": "20240101",
36+
"reason_for_removal": "ORR",
37+
"reason_for_removal_effective_from_date": null,
38+
"date_of_death": null,
39+
"death_status": null,
40+
"home_telephone_number": "01619999999",
41+
"home_telephone_effective_from_date": "20240101",
42+
"mobile_telephone_number": "07888888888",
43+
"mobile_telephone_effective_from_date": "20240101",
44+
"email_address": "blockedadd@example.com",
45+
"email_address_effective_from_date": "20240101",
46+
"preferred_language": "en",
47+
"is_interpreter_required": false,
48+
"invalid_flag": false,
49+
"eligibility": true
50+
}
51+
],
52+
"nhsNumbers": [
53+
"9998380197"
54+
]
55+
}
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
import { expect, test } from '../../fixtures/test-fixtures';
2+
import { createParquetFromJson } from '../../../parquet/parquet-multiplier';
3+
import { getApiTestData, processFileViaStorage, validateSqlDatabaseFromAPI, cleanupDatabaseFromAPI } from '../../steps/steps';
4+
import { getRecordsFromParticipantManagementService} from '../../../api/distributionService/bsSelectService';
5+
import { TestHooks } from '../../hooks/test-hooks';
6+
import { APIRequestContext, TestInfo } from '@playwright/test';
7+
import { config } from '../../../config/env';
8+
import { getRecordsFromExceptionService } from '../../../api/dataService/exceptionService';
9+
import { sendHttpGet, sendHttpPOSTCall } from '../../../api/core/sendHTTPRequest';
10+
11+
annotation: [{
12+
type: 'Requirement',
13+
description: 'Tests - https://nhsd-jira.digital.nhs.uk/browse/DTOSS-7667'
14+
}]
15+
16+
test.describe('@regression @e2e @epic4b-block-tests @smoke Tests', async () => {
17+
TestHooks.setupAllTestHooks();
18+
19+
test('@DTOSS-7680-01 - AC12- verify that a participant when marked as ineligible and ublocked they are not added to the cohort and unsubscribed from PDS updates', async ({ request }: { request: APIRequestContext }, testInfo: TestInfo) => {
20+
// Arrange: Get test data
21+
const [addValidations, inputParticipantRecord, nhsNumbers, testFilesPath] = await getApiTestData(testInfo.title, 'ADD_BLOCKED');
22+
const nhsNumber = nhsNumbers[0];
23+
await cleanupDatabaseFromAPI(request, [nhsNumber]);
24+
25+
26+
const parquetFile = await createParquetFromJson(nhsNumbers, inputParticipantRecord, testFilesPath);
27+
28+
await test.step(`When I ADD participant is processed via storage ready to be blocked by the block function`, async () => {
29+
await processFileViaStorage(parquetFile);
30+
});
31+
32+
let nhsNumberFromPds = 0;
33+
let familyName = "";
34+
let dateOfBirth = "";
35+
36+
await test.step(`Then participant should be in the participant management table`, async () => {
37+
38+
await validateSqlDatabaseFromAPI(request, addValidations);
39+
});
40+
41+
42+
// Call the block participant function
43+
await test.step(`Go to PDS and get the participant data for the blocking of a participant that already exists in the database`, async () => {
44+
// Call the block participant function
45+
let url = `${config.createPDSDemographic}${config.createPDSDemographicPath}?nhsNumber=${nhsNumbers[0]}`;
46+
47+
let response = await sendHttpGet(url)
48+
expect(response.status).toBe(200)
49+
50+
let json = await response.json();
51+
nhsNumberFromPds = json["NhsNumber"];
52+
familyName = json["FamilyName"]
53+
dateOfBirth = json["DateOfBirth"];
54+
55+
expect(nhsNumberFromPds).toBeDefined()
56+
});
57+
58+
const blockPayload = {
59+
NhsNumber: Number(nhsNumberFromPds),
60+
FamilyName: familyName,
61+
DateOfBirth: dateOfBirth
62+
};
63+
64+
await test.step(`running step to make sure that item can be subscribed to in nems`, async () => {
65+
let subscribeToNemsResponse = await sendHttpPOSTCall(`${config.SubToNems}${config.SubToNemsPath}?nhsNumber=${nhsNumbers[0]}`, "");
66+
67+
expect(subscribeToNemsResponse.status).toBe(200);
68+
});
69+
70+
await test.step(`Send block to existing participant and make sure they are blocked`, async () => {
71+
72+
let url = `${config.endpointBsSelectUpdateBlockFlag}${config.routeBsSelectBlockParticipant}`;
73+
let body = JSON.stringify(blockPayload);
74+
let response = await sendHttpPOSTCall(url, body);
75+
expect(response.status).toBe(200);
76+
});
77+
78+
79+
await test.step(`the participant has been blocked`, async () => {
80+
let blocked = false;
81+
for(let i =0; i<10; i++) {
82+
const resp = await getRecordsFromParticipantManagementService(request);
83+
if (resp?.data?.[0]?.BlockedFlag === 1) {
84+
blocked = true;
85+
break;
86+
}
87+
console.log(`Waiting for participant to be blocked...(${i}/10)`);
88+
await new Promise(res => setTimeout(res, 2000));
89+
}
90+
expect(blocked).toBe(true);
91+
});
92+
93+
await test.step(`mark the paricipant as unblocked and they should be marked as ineligible`, async () => {
94+
let url = `${config.endpointBsSelectUpdateBlockFlag}${config.routeBsSelectUnblockParticipant}?nhsNumber=${nhsNumbers[0]}`;
95+
let body = ""
96+
let response = await sendHttpPOSTCall(url, body);
97+
98+
99+
let eligibility = false;
100+
let blocked = true;
101+
for(let i =0; i<10; i++) {
102+
const resp = await getRecordsFromParticipantManagementService(request);
103+
let responseData = resp?.data?.[0];
104+
if (responseData?.BlockedFlag === 0 && responseData?.EligibilityFlag === 0) {
105+
blocked = false;
106+
eligibility = false;
107+
108+
break;
109+
}
110+
console.log(`Waiting for participant to be blocked...(${i}/10)`);
111+
await new Promise(res => setTimeout(res, 2000));
112+
}
113+
114+
var checkNemsSubscriptionStatusURL = `${config.SubToNems}${config.CheckNemsSubPath}?nhsNumber=${nhsNumbers[0]}` ;
115+
let nemsResponse = await sendHttpGet(checkNemsSubscriptionStatusURL);
116+
117+
expect(nemsResponse.status).toBe(200);
118+
expect(eligibility).toBe(true);
119+
expect(blocked).toBe(false);
120+
expect(response.status).toBe(200);
121+
});
122+
});
123+
});
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
{
2+
"validations": [
3+
{
4+
"validations": {
5+
"apiEndpoint": "api/CohortDistributionDataService",
6+
"NHSNumber": 9998380197
7+
}
8+
}
9+
],
10+
"inputParticipantRecord": [
11+
{
12+
"record_type": "ADD",
13+
"change_time_stamp": null,
14+
"serial_change_number": 1,
15+
"nhs_number": 9998380197,
16+
"superseded_by_nhs_number": null,
17+
"primary_care_provider": "A81623",
18+
"primary_care_effective_from_date": "20240101",
19+
"current_posting": "LA",
20+
"current_posting_effective_from_date": "20240101",
21+
"name_prefix": "BRO",
22+
"given_name": "smith",
23+
"other_given_name": "OtherGivenName 1",
24+
"family_name": "smith",
25+
"previous_family_name": "PreviousFamilyName 1",
26+
"date_of_birth": "20101022",
27+
"gender": 2,
28+
"address_line_1": "1 Test Street",
29+
"address_line_2": "Test Area",
30+
"address_line_3": "TestAddress",
31+
"address_line_4": "Chelmsford",
32+
"address_line_5": "United Kingdom",
33+
"postcode": "LS1 1AA",
34+
"paf_key": "Z3S4Q5X9",
35+
"address_effective_from_date": "20240101",
36+
"reason_for_removal": "ORR",
37+
"reason_for_removal_effective_from_date": null,
38+
"date_of_death": null,
39+
"death_status": null,
40+
"home_telephone_number": "01619999999",
41+
"home_telephone_effective_from_date": "20240101",
42+
"mobile_telephone_number": "07888888888",
43+
"mobile_telephone_effective_from_date": "20240101",
44+
"email_address": "blockedadd@example.com",
45+
"email_address_effective_from_date": "20240101",
46+
"preferred_language": "en",
47+
"is_interpreter_required": false,
48+
"invalid_flag": false,
49+
"eligibility": true
50+
}
51+
],
52+
"nhsNumbers": [
53+
"9998380197"
54+
]
55+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
{
2+
"validations": [
3+
{
4+
"validations": {
5+
"apiEndpoint": "api/CohortDistributionDataService",
6+
"NHSNumber": 9998380197
7+
}
8+
}
9+
],
10+
"inputParticipantRecord": [
11+
{
12+
"record_type": "ADD",
13+
"change_time_stamp": null,
14+
"serial_change_number": 1,
15+
"nhs_number": 9998380197,
16+
"superseded_by_nhs_number": null,
17+
"primary_care_provider": "A81623",
18+
"primary_care_effective_from_date": "20240101",
19+
"current_posting": "LA",
20+
"current_posting_effective_from_date": "20240101",
21+
"name_prefix": "BRO",
22+
"given_name": "smith",
23+
"other_given_name": "OtherGivenName 1",
24+
"family_name": "smith",
25+
"previous_family_name": "PreviousFamilyName 1",
26+
"date_of_birth": "20101022",
27+
"gender": 2,
28+
"address_line_1": "1 Test Street",
29+
"address_line_2": "Test Area",
30+
"address_line_3": "TestAddress",
31+
"address_line_4": "Chelmsford",
32+
"address_line_5": "United Kingdom",
33+
"postcode": "LS1 1AA",
34+
"paf_key": "Z3S4Q5X9",
35+
"address_effective_from_date": "20240101",
36+
"reason_for_removal": "ORR",
37+
"reason_for_removal_effective_from_date": null,
38+
"date_of_death": null,
39+
"death_status": null,
40+
"home_telephone_number": "01619999999",
41+
"home_telephone_effective_from_date": "20240101",
42+
"mobile_telephone_number": "07888888888",
43+
"mobile_telephone_effective_from_date": "20240101",
44+
"email_address": "blockedadd@example.com",
45+
"email_address_effective_from_date": "20240101",
46+
"preferred_language": "en",
47+
"is_interpreter_required": false,
48+
"invalid_flag": false,
49+
"eligibility": true
50+
}
51+
],
52+
"nhsNumbers": [
53+
"9998380197"
54+
]
55+
}

0 commit comments

Comments
 (0)