Skip to content

Commit 7c57d35

Browse files
lint fixes
1 parent ffdf716 commit 7c57d35

32 files changed

+782
-724
lines changed

tests/component-tests/apiGateway-tests/createMi.spec.ts renamed to tests/component-tests/apiGateway-tests/create-mi.spec.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
import { expect, test } from "@playwright/test";
2-
import { getRestApiGatewayBaseUrl } from "../../helpers/awsGatewayHelper";
3-
import { MI_ENDPOINT } from "../../constants/api_constants";
2+
import { getRestApiGatewayBaseUrl } from "../../helpers/aws-gateway-helper";
3+
import { MI_ENDPOINT } from "../../constants/api-constants";
44
import {
55
createHeaderWithNoCorrelationId,
66
createHeaderWithNoRequestId,
77
createInvalidRequestHeaders,
88
createValidRequestHeaders,
9-
} from "../../constants/request_headers";
9+
} from "../../constants/request-headers";
1010
import {
1111
miInvalidDateRequest,
1212
miInvalidRequest,
1313
miValidRequest,
14-
} from "./testCases/createMi";
14+
} from "./testCases/create-mi";
1515
import {
1616
error400InvalidDate,
1717
error400ResponseBody,
1818
error403ResponseBody,
1919
requestId500Error,
20-
} from "../../helpers/commonTypes";
20+
} from "../../helpers/common-types";
2121

2222
let baseUrl: string;
2323

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
import { expect, test } from "@playwright/test";
2+
import { getRestApiGatewayBaseUrl } from "../../helpers/aws-gateway-helper";
3+
import { getLettersBySupplier } from "../../helpers/generate-fetch-test-data";
4+
import { SUPPLIERID, SUPPLIER_LETTERS } from "../../constants/api-constants";
5+
import { createValidRequestHeaders } from "../../constants/request-headers";
6+
import {
7+
error404ResponseBody,
8+
error500ResponseBody,
9+
} from "../../helpers/common-types";
10+
11+
let baseUrl: string;
12+
13+
test.beforeAll(async () => {
14+
baseUrl = await getRestApiGatewayBaseUrl();
15+
});
16+
17+
test.describe("API Gateway Tests to Verify Get Letter Status Endpoint", () => {
18+
test(`Get /letters/{id} returns 200 and valid response for a given id`, async ({
19+
request,
20+
}) => {
21+
const letters = await getLettersBySupplier(SUPPLIERID, "PENDING", 1);
22+
23+
if (!letters?.length) {
24+
test.fail(true, `No PENDING letters found for supplier ${SUPPLIERID}`);
25+
return;
26+
}
27+
const letter = letters[0];
28+
const headers = createValidRequestHeaders();
29+
const response = await request.get(
30+
`${baseUrl}/${SUPPLIER_LETTERS}/${letter.id}`,
31+
{
32+
headers,
33+
},
34+
);
35+
36+
const responseBody = await response.json();
37+
38+
expect(response.status()).toBe(200);
39+
expect(responseBody).toMatchObject({
40+
data: {
41+
attributes: {
42+
status: "PENDING",
43+
specificationId: letter.specificationId,
44+
groupId: letter.groupId,
45+
},
46+
id: letter.id,
47+
type: "Letter",
48+
},
49+
});
50+
});
51+
52+
test(`Get /letters/{id} returns 404 if no resource is found for id`, async ({
53+
request,
54+
}) => {
55+
const id = "11";
56+
const headers = createValidRequestHeaders();
57+
const response = await request.get(`${baseUrl}/${SUPPLIER_LETTERS}/${id}`, {
58+
headers,
59+
});
60+
61+
const responseBody = await response.json();
62+
expect(response.status()).toBe(404);
63+
expect(responseBody).toMatchObject(error404ResponseBody());
64+
});
65+
66+
test(`Get /letters/{id} returns 500 if letter is not found for supplierId ${SUPPLIERID}`, async ({
67+
request,
68+
}) => {
69+
const id = "non-existing-id-12345";
70+
const headers = createValidRequestHeaders();
71+
const response = await request.get(`${baseUrl}/${SUPPLIER_LETTERS}/${id}`, {
72+
headers,
73+
});
74+
75+
const responseBody = await response.json();
76+
expect(response.status()).toBe(500);
77+
expect(responseBody).toMatchObject(error500ResponseBody(id));
78+
});
79+
});

tests/component-tests/apiGateway-tests/getLetters.spec.ts renamed to tests/component-tests/apiGateway-tests/get-letters.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { expect, test } from "@playwright/test";
2-
import { SUPPLIER_LETTERS } from "../../constants/api_constants";
2+
import { SUPPLIER_LETTERS } from "../../constants/api-constants";
33
import {
44
createHeaderWithNoCorrelationId,
55
createInvalidRequestHeaders,
66
createValidRequestHeaders,
7-
} from "../../constants/request_headers";
8-
import { getRestApiGatewayBaseUrl } from "../../helpers/awsGatewayHelper";
7+
} from "../../constants/request-headers";
8+
import { getRestApiGatewayBaseUrl } from "../../helpers/aws-gateway-helper";
99
import { validateApiResponse } from "../../helpers/validateJsonSchema";
1010

1111
let baseUrl: string;

tests/component-tests/apiGateway-tests/getLetterStatus.spec.ts

Lines changed: 0 additions & 71 deletions
This file was deleted.
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
export type MiRequestBody = {
2+
data: {
3+
type: string;
4+
attributes: {
5+
groupId: string;
6+
lineItem: string;
7+
quantity: number;
8+
specificationId: string;
9+
stockRemaining: number;
10+
timestamp: string;
11+
};
12+
};
13+
};
14+
15+
export function miValidRequest(): MiRequestBody {
16+
const requestBody: MiRequestBody = {
17+
data: {
18+
attributes: {
19+
groupId: "group123",
20+
lineItem: "envelope-business-standard",
21+
quantity: 10,
22+
specificationId: "Test-Spec-Id",
23+
stockRemaining: 100,
24+
timestamp: new Date().toISOString(),
25+
},
26+
type: "ManagementInformation",
27+
},
28+
};
29+
return requestBody;
30+
}
31+
32+
export function miInvalidRequest(): MiRequestBody {
33+
const requestBody: MiRequestBody = {
34+
data: {
35+
attributes: {
36+
groupId: "group123",
37+
lineItem: "envelope-business-standard",
38+
quantity: 10,
39+
specificationId: "Test-Spec-Id",
40+
stockRemaining: 100,
41+
timestamp: new Date().toISOString(),
42+
},
43+
type: "?",
44+
},
45+
};
46+
return requestBody;
47+
}
48+
49+
export function miInvalidDateRequest(): MiRequestBody {
50+
const requestBody: MiRequestBody = {
51+
data: {
52+
attributes: {
53+
groupId: "group123",
54+
lineItem: "envelope-business-standard",
55+
quantity: 10,
56+
specificationId: "Test-Spec-Id",
57+
stockRemaining: 100,
58+
timestamp: "2021-10-28T",
59+
},
60+
type: "ManagementInformation",
61+
},
62+
};
63+
return requestBody;
64+
}

tests/component-tests/apiGateway-tests/testCases/createMi.ts

Lines changed: 0 additions & 70 deletions
This file was deleted.

tests/component-tests/apiGateway-tests/testCases/updateLetterStatus.ts renamed to tests/component-tests/apiGateway-tests/testCases/update-letter-status.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
/* eslint-disable prefer-const */
2-
import { RequestHeaders } from "../../../constants/request_headers";
3-
import { SUPPLIERID } from "../../../constants/api_constants";
4-
import { ErrorMessageBody } from "../../../helpers/commonTypes";
1+
import { RequestHeaders } from "../../../constants/request-headers";
2+
import { SUPPLIERID } from "../../../constants/api-constants";
3+
import { ErrorMessageBody } from "../../../helpers/common-types";
54

65
export type PatchMessageRequestBody = {
76
data: {

tests/component-tests/apiGateway-tests/updateLetterStatus.spec.ts renamed to tests/component-tests/apiGateway-tests/update-letter-status.spec.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
11
import { expect, test } from "@playwright/test";
22
import { randomUUID } from "node:crypto";
3-
import { SUPPLIERID, SUPPLIER_LETTERS } from "../../constants/api_constants";
4-
import { getRestApiGatewayBaseUrl } from "../../helpers/awsGatewayHelper";
3+
import { SUPPLIERID, SUPPLIER_LETTERS } from "../../constants/api-constants";
4+
import { getRestApiGatewayBaseUrl } from "../../helpers/aws-gateway-helper";
55
import {
66
patch400ErrorResponseBody,
7-
patch500ErrorResponseBody,
87
patchFailureRequestBody,
98
patchRequestHeaders,
109
patchValidRequestBody,
11-
} from "./testCases/updateLetterStatus";
10+
} from "./testCases/update-letter-status";
1211
import {
1312
createTestData,
1413
deleteLettersBySupplier,
1514
getLettersBySupplier,
16-
} from "../../helpers/generate_fetch_testData";
17-
import { createInvalidRequestHeaders } from "../../constants/request_headers";
18-
import { error400IdError, error403ResponseBody } from "../../helpers/commonTypes";
15+
} from "../../helpers/generate-fetch-test-data";
16+
import { createInvalidRequestHeaders } from "../../constants/request-headers";
17+
import {
18+
error400IdError,
19+
error403ResponseBody,
20+
} from "../../helpers/common-types";
1921

2022
let baseUrl: string;
2123

tests/constants/api-constants.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
export const SUPPLIER_LETTERS = "letters";
2+
export const SUPPLIER_API_URL_SANDBOX =
3+
"https://internal-dev-sandbox.api.service.nhs.uk/nhs-notify-supplier";
4+
export const AWS_REGION = "eu-west-2";
5+
export const envName = process.env.PR_NUMBER ?? "main";
6+
export const API_NAME = `nhs-${envName}-supapi`;
7+
export const LETTERSTABLENAME = `nhs-${envName}-supapi-letters`;
8+
export const SUPPLIERID = "TestSupplier1";
9+
export const MI_ENDPOINT = "mi";

tests/constants/api_constants.ts

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)