Skip to content

Commit 6d3e4bf

Browse files
committed
add component tests
1 parent 76b53b4 commit 6d3e4bf

2 files changed

Lines changed: 33 additions & 0 deletions

File tree

tests/component-tests/apiGateway-tests/get-letter-status.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ test.describe("API Gateway Tests to Verify Get Letter Status Endpoint", () => {
3939
expect(responseBody).toMatchObject({
4040
data: {
4141
attributes: {
42+
sha256Hash: createdLetter.sha256Hash,
4243
status: "PENDING",
4344
specificationId: createdLetter.specificationId,
4445
groupId: createdLetter.groupId,

tests/component-tests/apiGateway-tests/get-letters.spec.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
isErrorResponse,
1111
isGetLettersResponse,
1212
} from "../../helpers/generate-fetch-test-data";
13+
import { SUPPLIER_LETTERS } from "../../constants/api-constants";
1314

1415
let baseUrl: string;
1516

@@ -34,6 +35,37 @@ test.describe("API Gateway Tests To Get List Of Pending Letters", () => {
3435
throw new Error("Expected GetLettersResponse body for 200 status");
3536
}
3637
expect(responseBody.data.length).toBeGreaterThanOrEqual(1);
38+
39+
responseBody.data.forEach((letter) => {
40+
expect(letter.attributes.sha256Hash).toBeDefined();
41+
expect(letter.attributes.sha256Hash).not.toBeNull();
42+
});
43+
});
44+
45+
test("GET /letters retrieve letter should match SHA256 from GET /letter{id} of the same letter", async ({ request }) => {
46+
const headers = createValidRequestHeaders();
47+
const { responseBody, statusCode } = await getLettersWithRetry(
48+
request,
49+
baseUrl,
50+
headers,
51+
{
52+
lettersLimit: "2",
53+
},
54+
);
55+
56+
expect(statusCode).toBe(200);
57+
if (!isGetLettersResponse(responseBody)) {
58+
throw new Error("Expected GetLettersResponse body for 200 status");
59+
}
60+
expect(responseBody.data.length).toBeGreaterThanOrEqual(1);
61+
const getLettersSha = responseBody.data[0].attributes.sha256Hash;
62+
const id = responseBody.data[0].id;
63+
const response = await request.get(`${baseUrl}/${SUPPLIER_LETTERS}/${id}`, {
64+
headers,
65+
});
66+
const letterResponseBody = await response.json();
67+
expect(response.status()).toBe(200);
68+
expect(letterResponseBody.data.attributes.sha256Hash).toBe(getLettersSha);
3769
});
3870

3971
test("GET /letters with invalid authentication should return 403", async ({

0 commit comments

Comments
 (0)