Skip to content

Commit

Permalink
Adding tests for validating the extensions in f2f events (#387)
Browse files Browse the repository at this point in the history
* Adding tests for validating the extensions in f2f events

* Adding tests for validating the extensions in f2f events
  • Loading branch information
sreeni-lutukurthy-gds authored Oct 23, 2023
1 parent 97b11fe commit 003b1c1
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tests/helpers/query-constant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,15 @@ export const IPV_JOURNEY_DATA = (eventname: string): string => {
"'";
return query;
};

export const IPV_CRI_F2F_DATA = (eventname: string): string => {
const query =
"SELECT event_id, extensions_evidence,extensions_iss, extensions_successful, extensions_previousgovuksigninjourneyid, restricted_passport, restricted_residencepermit, restricted_drivingpermit, restricted_idcard FROM IPV_CRI_F2F where event_name='" +
eventname +
"'";
return query;
};

export const GET_EVENT_ID = (eventname: string): string => {
const query =
'SELECT event_id FROM ' +
Expand Down
43 changes: 43 additions & 0 deletions tests/regression-tests/ipv_cri_f2f_group_data_validation.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { getQueryResults } from '../helpers/db-helpers';
import { GET_EVENT_ID, extensionsnotnullquery, IPV_CRI_F2F_DATA } from '../helpers/query-constant';
import { txmaProcessingWorkGroupName, txmaRawDatabaseName, txmaStageDatabaseName } from '../helpers/envHelper';
import { eventidlist } from '../helpers/common-helpers';

describe('IPV_CRI_F2F GROUP Test - validate data at stage layer', () => {
test.concurrent.each`
eventName
${'F2F_YOTI_RESPONSE_RECEIVED'}
${'IPR_USER_REDIRECTED'}
${'IPR_RESULT_NOTIFICATION_EMAILED'}
`(
'Should validate $eventName event extensions stored in raw and stage layer',
async ({ ...data }) => {
// given
const eventname = data.eventName;
const eventidresults = await getQueryResults(
GET_EVENT_ID(eventname),
txmaStageDatabaseName(),
txmaProcessingWorkGroupName(),
);
const querystring = eventidlist(eventidresults);
const query = `${extensionsnotnullquery(eventname)} and event_id in (${querystring})`;
const athenaQueryResults = await getQueryResults(query, txmaRawDatabaseName(), txmaProcessingWorkGroupName());
for (let index = 0; index <= athenaQueryResults.length - 1; index++) {
const eventId = athenaQueryResults[index].event_id;
const stExtensions = athenaQueryResults[index].extensions.replace('{', '').replace('}', '').split('=')[1];
const queryStage = `${IPV_CRI_F2F_DATA(eventname)} and event_id = '${eventId}'`;
const athenaQueryResultsStage = await getQueryResults(
queryStage,
txmaStageDatabaseName(),
txmaProcessingWorkGroupName(),
);
if (stExtensions !== 'null' && stExtensions !== null && stExtensions !== undefined) {
const previousgovuksigninjourneyid =
athenaQueryResultsStage[0].extensions_previousgovuksigninjourneyid.replaceAll('"', '');
expect(stExtensions).toEqual(previousgovuksigninjourneyid);
}
}
},
240000,
);
});

0 comments on commit 003b1c1

Please sign in to comment.