Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions tests/playwright-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"test:regression_e2e_epic2Med": "cross-env TEST_TYPE=RegressionEpic2Med npx playwright test --project=dev --config=src/config/playwright.config.ts --grep=@epic2-med",
"test:regression_e2e_epic3Med": "cross-env TEST_TYPE=RegressionEpic3Med npx playwright test --project=dev --config=src/config/playwright.config.ts --grep=@epic3-med",
"test:regression_e2e_epic4c": "cross-env TEST_TYPE=RegressionEpic4c npx playwright test --project=dev --config=src/config/playwright.config.ts --grep=@epic4c-",
"test:regression_e2e_epic4b": "cross-env TEST_TYPE=RegressionEpic4d npx playwright test --project=dev --config=src/config/playwright.config.ts --grep=epic4b-7719-block-paricipant-tessuite",
"test:regression_e2e_epic4d": "cross-env TEST_TYPE=RegressionEpic4d npx playwright test --project=dev --config=src/config/playwright.config.ts --grep=@epic4d-",
"test": "cross-env TEST_TYPE=SMOKE npx playwright test --project=dev --config=src/config/playwright.config.ts --grep=\"@smoke @e2e\"",
"test:validation-exceptions": "cross-env TEST_TYPE=VALIDATION npx playwright test tests/api/bsselect/validationExceptions/ --project=dev --config=src/config/playwright.config.ts",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
import { expect, test } from '../../fixtures/test-fixtures';
import { createParquetFromJson } from '../../../parquet/parquet-multiplier';
import { getApiTestData, processFileViaStorage, validateSqlDatabaseFromAPI, cleanupDatabaseFromAPI } from '../../steps/steps';
import { getRecordsFromParticipantManagementService} from '../../../api/distributionService/bsSelectService';
import { TestHooks } from '../../hooks/test-hooks';
import { APIRequestContext, TestInfo } from '@playwright/test';
import { config } from '../../../config/env';
import { getRecordsFromExceptionService } from '../../../api/dataService/exceptionService';
import { sendHttpGet, sendHttpPOSTCall } from '../../../api/core/sendHTTPRequest';

annotation: [{
type: 'Requirement',
description: 'Tests - https://nhsd-jira.digital.nhs.uk/browse/DTOSS-7667'
}]

test.describe('@regression @e2e @epic4b-block-tests @smoke Tests', async () => {
TestHooks.setupAllTestHooks();

test('@DTOSS-7667-01 - AC1 - Verify participant does not have a subscription in our database when they are blocked', async ({ request }: { request: APIRequestContext }, testInfo: TestInfo) => {
// Arrange: Get test data
const [addValidations, inputParticipantRecord, nhsNumbers, testFilesPath] = await getApiTestData(testInfo.title, 'ADD_BLOCKED');
const nhsNumber = nhsNumbers[0];
await cleanupDatabaseFromAPI(request, [nhsNumber]);


const parquetFile = await createParquetFromJson(nhsNumbers, inputParticipantRecord, testFilesPath);

await test.step(`When I ADD participant is processed via storage ready to be blocked by the block function`, async () => {
await processFileViaStorage(parquetFile);
});

let nhsNumberFromPds = 0;
let familyName = "";
let dateOfBirth = "";

await test.step(`Then participant should be in the participant management table`, async () => {

await validateSqlDatabaseFromAPI(request, addValidations);
});


// Call the block participant function
await test.step(`Go to PDS and get the participant data for the blocking of a participant that already exists in the database`, async () => {
// Call the block participant function
let url = `${config.createPDSDemographic}${config.createPDSDemographicPath}?nhsNumber=${nhsNumbers[0]}`;

let response = await sendHttpGet(url)
expect(response.status).toBe(200)

let json = await response.json();
nhsNumberFromPds = json["NhsNumber"];
familyName = json["FamilyName"]
dateOfBirth = json["DateOfBirth"];

expect(nhsNumberFromPds).toBeDefined()
});

const blockPayload = {
NhsNumber: Number(nhsNumberFromPds),
FamilyName: familyName,
DateOfBirth: dateOfBirth
};

await test.step(`running step to make sure that item can be subscribed to in nems`, async () => {
let subscribeToNemsResponse = await sendHttpPOSTCall(`${config.SubToNems}${config.SubToNemsPath}?nhsNumber=${nhsNumbers[0]}`, "");

expect(subscribeToNemsResponse.status).toBe(200);
});

await test.step(`When the participant is not blocked list they are subscribed to nems for PDS updates`, async () => {
var checkNemsSubscriptionStatusURL = `${config.SubToNems}${config.CheckNemsSubPath}?nhsNumber=${nhsNumbers[0]}` ;
Comment thread
SamRobinson75684 marked this conversation as resolved.
Outdated
let nemsResponse = await sendHttpGet(checkNemsSubscriptionStatusURL);

expect(nemsResponse.status).toBe(200);
});

await test.step(`Send block to existing participant and make sure they are blocked`, async () => {

let url = `${config.endpointBsSelectUpdateBlockFlag}${config.routeBsSelectBlockParticipant}`;
let body = JSON.stringify(blockPayload);
let response = await sendHttpPOSTCall(url, body);
expect(response.status).toBe(200);
});


await test.step(`make sure the participant has been blocked`, async () => {
let blocked = false;
for(let i =0; i<10; i++) {
const resp = await getRecordsFromParticipantManagementService(request);
if (resp?.data?.[0]?.BlockedFlag === 1) {
blocked = true;
break;
}
console.log(`Waiting for participant to be blocked...(${i}/10)`);
await new Promise(res => setTimeout(res, 2000));
}
expect(blocked).toBe(true);
});

await test.step(`When the participant is in the blocked list they are not subscribed to nems for PDS updates`, async () => {
var checkNemsSubscriptionStatusURL = `${config.SubToNems}${config.CheckNemsSubPath}?nhsNumber=${nhsNumbers[0]}` ;
Comment thread
SamRobinson75684 marked this conversation as resolved.
Outdated
let nemsResponse = await sendHttpGet(checkNemsSubscriptionStatusURL);

expect(nemsResponse.status).toBe(404);
});
});
});
Loading