Skip to content

Commit 01f78b3

Browse files
feat: TC_4B_Manage-Add_blocked_to_ParticipantManagement_not_in_cohort (#1540)
tests for DTOSS-7675
1 parent ed16cd3 commit 01f78b3

1 file changed

Lines changed: 93 additions & 0 deletions

File tree

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
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-7667-01 - AC1 - Verify participant is deleted from CohortDistributionDataService', 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(`Verify that the participant can be able to add record to the participant management service.`, 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(`Verify that the participant is being able to mark the record as blocked from breast screening`, 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+
});

0 commit comments

Comments
 (0)