-
Notifications
You must be signed in to change notification settings - Fork 2
feat: end to end tests for DTOSS 7719 #1583
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
fdf3b2c
feat: new end to end tests for DTOSS-7719
SamRobinson75684 ab57d5d
chore: adding test script to runner for testng in azure
SamRobinson75684 0d1fb1a
fix: removing uwanted to code
SamRobinson75684 d180c4b
Merge branch 'main' into feat/DTOSS-7719-end-to-end-tess
SamRobinson75684 510e5c1
chore: using let instead of var
SamRobinson75684 99d6a80
Merge branch 'feat/DTOSS-7719-end-to-end-tess' of https://github.com/…
SamRobinson75684 1c92368
Merge branch 'main' into feat/DTOSS-7719-end-to-end-tess
SamRobinson75684 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
107 changes: 107 additions & 0 deletions
107
...rc/tests/e2e/epic4b-block-participant-tests/epic4b-7719-block-paricipant-tessuite.spec.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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]}` ; | ||
| 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]}` ; | ||
|
SamRobinson75684 marked this conversation as resolved.
Outdated
|
||
| let nemsResponse = await sendHttpGet(checkNemsSubscriptionStatusURL); | ||
|
|
||
| expect(nemsResponse.status).toBe(404); | ||
| }); | ||
| }); | ||
| }); | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.