Skip to content

Commit

Permalink
Merge pull request #388 from govuk-one-login/KIWI-1696-api-tests
Browse files Browse the repository at this point in the history
KIWI-1696 Refactor api tests
  • Loading branch information
Caitlin-cooling authored Mar 8, 2024
2 parents d24c219 + 02ed84f commit ddcae6f
Show file tree
Hide file tree
Showing 18 changed files with 480 additions and 486 deletions.
3 changes: 2 additions & 1 deletion src/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ DEV_F2F_MISSING_SUB_ACCESS_TOKEN=
DEV_F2F_YOTI_STUB_URL=
DEV_F2F_PO_STUB_URL=
GOV_NOTIFY_API=
DNS_SUFFIX=
DNS_SUFFIX=
VC_SIGNING_KEY_ID=
1 change: 1 addition & 0 deletions src/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,7 @@ const JEST_RULES = {
}

const OVERRIDE_DEFAULTS_RULES = {
'import/named': 0,
// Allow defining functions (incl. arrow expressions) after use as per "Stepdown Rule" best practice
'@typescript-eslint/no-use-before-define': 'off',

Expand Down
7 changes: 3 additions & 4 deletions src/tests/api/AbortApi.test.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import f2fStubPayload from "../data/exampleStubPayload.json";
import abortPayload from "../data/abortPayload.json";

import { startStubServiceAndReturnSessionId, postAbortSession } from "../utils/ApiTestSteps";
import { startStubServiceAndReturnSessionId, postAbortSession } from "./ApiTestSteps";

describe("E2E Happy Path /abort enpoint", () => {
let sessionId: string;
beforeEach(async () => {
f2fStubPayload.yotiMockID = "0000";
const sessionResponse = await startStubServiceAndReturnSessionId(f2fStubPayload);
sessionId = sessionResponse.data.session_id;
const { sessionId: newSessionId } = await startStubServiceAndReturnSessionId(f2fStubPayload);
sessionId = newSessionId;
console.log("session id: " + sessionId);
});

Expand Down
35 changes: 17 additions & 18 deletions src/tests/api/Address.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
/* eslint-disable max-lines-per-function */
import dataPassport from "../data/docSelectionPayloadPassportValid.json";
import f2fStubPayload from "../data/exampleStubPayload.json";
import { postDocumentSelection, startStubServiceAndReturnSessionId } from "../utils/ApiTestSteps";
import { postDocumentSelection, startStubServiceAndReturnSessionId } from "./ApiTestSteps";

describe("Address fields tests", () => {
let sessionId: string;
beforeEach(() => {
f2fStubPayload.yotiMockID = "0000";
f2fStubPayload.shared_claims.address[0].uprn = "123456789";
Expand All @@ -17,13 +16,13 @@ describe("Address fields tests", () => {
f2fStubPayload.shared_claims.address[0].buildingNumber = "32";
f2fStubPayload.shared_claims.address[0].buildingName = "";
f2fStubPayload.shared_claims.address[0].subBuildingName = "";
console.log(JSON.stringify(f2fStubPayload));
const sessionResponse = await startStubServiceAndReturnSessionId(f2fStubPayload);
sessionId = sessionResponse.data.session_id;

const { sessionId } = await startStubServiceAndReturnSessionId(f2fStubPayload);
console.log("session id: " + sessionId);
expect(sessionId).toBeTruthy();

const response = await postDocumentSelection(dataPassport, sessionId);
console.log(response.data);

expect(response.status).toBe(200);
expect(response.data).toBe("Instructions PDF Generated");
});
Expand All @@ -32,13 +31,13 @@ describe("Address fields tests", () => {
f2fStubPayload.shared_claims.address[0].buildingNumber = "";
f2fStubPayload.shared_claims.address[0].buildingName = "19 A";
f2fStubPayload.shared_claims.address[0].subBuildingName = "";
console.log(JSON.stringify(f2fStubPayload));
const sessionResponse = await startStubServiceAndReturnSessionId(f2fStubPayload);
sessionId = sessionResponse.data.session_id;

const { sessionId } = await startStubServiceAndReturnSessionId(f2fStubPayload);
console.log("session id: " + sessionId);
expect(sessionId).toBeTruthy();

const response = await postDocumentSelection(dataPassport, sessionId);
console.log(response.data);

expect(response.status).toBe(200);
expect(response.data).toBe("Instructions PDF Generated");
});
Expand All @@ -47,13 +46,13 @@ describe("Address fields tests", () => {
f2fStubPayload.shared_claims.address[0].buildingNumber = "";
f2fStubPayload.shared_claims.address[0].buildingName = "";
f2fStubPayload.shared_claims.address[0].subBuildingName = "Flat 5";
console.log(JSON.stringify(f2fStubPayload));
const sessionResponse = await startStubServiceAndReturnSessionId(f2fStubPayload);
sessionId = sessionResponse.data.session_id;

const { sessionId } = await startStubServiceAndReturnSessionId(f2fStubPayload);
console.log("session id: " + sessionId);
expect(sessionId).toBeTruthy();

const response = await postDocumentSelection(dataPassport, sessionId);
console.log(response.data);

expect(response.status).toBe(200);
expect(response.data).toBe("Instructions PDF Generated");
});
Expand All @@ -62,13 +61,13 @@ describe("Address fields tests", () => {
f2fStubPayload.shared_claims.address[0].buildingNumber = "";
f2fStubPayload.shared_claims.address[0].buildingName = "19 A";
f2fStubPayload.shared_claims.address[0].subBuildingName = "Flat 5";
console.log(JSON.stringify(f2fStubPayload));
const sessionResponse = await startStubServiceAndReturnSessionId(f2fStubPayload);
sessionId = sessionResponse.data.session_id;

const { sessionId } = await startStubServiceAndReturnSessionId(f2fStubPayload);
console.log("session id: " + sessionId);
expect(sessionId).toBeTruthy();

const response = await postDocumentSelection(dataPassport, sessionId);
console.log(response.data);

expect(response.status).toBe(200);
expect(response.data).toBe("Instructions PDF Generated");
});
Expand Down
File renamed without changes.
Loading

0 comments on commit ddcae6f

Please sign in to comment.