Skip to content

Commit 4d5d4e7

Browse files
review fix
1 parent 20af907 commit 4d5d4e7

5 files changed

Lines changed: 33 additions & 33 deletions

File tree

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ test.beforeAll(async () => {
1111
baseUrl = await getRestApiGatewayBaseUrl();
1212
});
1313

14-
test.describe('API Gateway Tests To Get List Of Pending ', () =>
14+
test.describe('API Gateway Tests To Get List Of Pending Letters', () =>
1515
{
1616
test('GET /letters should return 200 and list items', async ({ request }) =>
1717
{

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

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,6 @@ export type PatchMessageRequestBody = {
1414
};
1515
};
1616

17-
export type ErrorLink = {
18-
about: string;
19-
};
20-
21-
type PatchErrorResponse = {
22-
id: string;
23-
code: string;
24-
links: ErrorLink;
25-
status: string;
26-
title: string;
27-
detail: string;
28-
};
29-
30-
export type PatchErrorMessageBody = {
31-
errors: PatchErrorResponse[];
32-
};
33-
34-
3517
export type PatchMessageResponseBody = {
3618
data: {
3719
type: string;
@@ -46,7 +28,7 @@ export type PatchMessageResponseBody = {
4628
};
4729
};
4830

49-
export async function patchRequestHeaders(): Promise<RequestHeaders> {
31+
export function patchRequestHeaders(): RequestHeaders {
5032
let requestHeaders: RequestHeaders;
5133
requestHeaders = {
5234
headerauth1: process.env.HEADERAUTH || '',
@@ -58,7 +40,7 @@ export async function patchRequestHeaders(): Promise<RequestHeaders> {
5840
};
5941

6042

61-
export async function patchValidRequestBody (id: string, status: string) : Promise<PatchMessageRequestBody>{
43+
export function patchValidRequestBody (id: string, status: string) : PatchMessageRequestBody{
6244
let requestBody: PatchMessageRequestBody;
6345

6446
requestBody = {
@@ -74,7 +56,7 @@ export async function patchValidRequestBody (id: string, status: string) : Promi
7456
return requestBody;
7557
}
7658

77-
export async function patchFailureRequestBody (id: string, status: string) : Promise<PatchMessageRequestBody>{
59+
export function patchFailureRequestBody (id: string, status: string) : PatchMessageRequestBody{
7860
let requestBody: PatchMessageRequestBody;
7961

8062
requestBody = {

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ test.describe('API Gateway Tests to Verify Patch Status Endpoint', () => {
2323
return;
2424
}
2525
const letter = letters[0];
26-
const headers = await patchRequestHeaders();
27-
const body = await patchValidRequestBody(letter.id, 'ACCEPTED');
26+
const headers = patchRequestHeaders();
27+
const body = patchValidRequestBody(letter.id, 'ACCEPTED');
2828

2929
const response = await request.patch(`${baseUrl}/${SUPPLIER_LETTERS}/${letter.id}`, {
3030
headers: headers,
@@ -58,8 +58,8 @@ test.describe('API Gateway Tests to Verify Patch Status Endpoint', () => {
5858
return;
5959
}
6060
const letter = letters[0];
61-
const headers = await patchRequestHeaders();
62-
const body = await patchFailureRequestBody(letter.id, 'REJECTED');
61+
const headers = patchRequestHeaders();
62+
const body = patchFailureRequestBody(letter.id, 'REJECTED');
6363

6464
const response = await request.patch(`${baseUrl}/${SUPPLIER_LETTERS}/${letter.id}`, {
6565
headers: headers,
@@ -74,8 +74,8 @@ test.describe('API Gateway Tests to Verify Patch Status Endpoint', () => {
7474
test(`Patch /letters returns 400 if request Body is invalid`, async ({ request }) => {
7575

7676
const id = randomUUID()
77-
const headers = await patchRequestHeaders();
78-
const body = await patchValidRequestBody(id, '');
77+
const headers = patchRequestHeaders();
78+
const body = patchValidRequestBody(id, '');
7979

8080
const response = await request.patch(`${baseUrl}/${SUPPLIER_LETTERS}/${id}`, {
8181
headers: headers,
@@ -88,9 +88,9 @@ test.describe('API Gateway Tests to Verify Patch Status Endpoint', () => {
8888
});
8989

9090
test(`Patch /letters returns 500 if Id doesn't exist for SupplierId`, async ({ request }) => {
91-
const headers = await patchRequestHeaders();
91+
const headers = patchRequestHeaders();
9292
const id = randomUUID()
93-
const body = await patchValidRequestBody(id, 'PENDING');
93+
const body = patchValidRequestBody(id, 'PENDING');
9494

9595
const response = await request.patch(`${baseUrl}/${SUPPLIER_LETTERS}/${id}`, {
9696
headers: headers,
@@ -104,7 +104,7 @@ test.describe('API Gateway Tests to Verify Patch Status Endpoint', () => {
104104
test(`Patch /letters returns 403 for invalid headers`, async ({ request }) => {
105105
const headers = await createInvalidRequestHeaders();
106106
const id = randomUUID()
107-
const body = await patchValidRequestBody(id, 'PENDING');
107+
const body = patchValidRequestBody(id, 'PENDING');
108108

109109
const response = await request.patch(`${baseUrl}/${SUPPLIER_LETTERS}/${id}`, {
110110
headers: headers,

tests/helpers/commonTypes.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
export type ErrorLink = {
2+
about: string;
3+
};
4+
5+
type ErrorResponse = {
6+
id: string;
7+
code: string;
8+
links: ErrorLink;
9+
status: string;
10+
title: string;
11+
detail: string;
12+
};
13+
14+
export type ErrorMessageBody = {
15+
errors: ErrorResponse[];
16+
};

tests/sandbox/testCases/updateLetterStatus_testCases.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11

2-
import { PatchErrorMessageBody, PatchMessageRequestBody, PatchMessageResponseBody } from '../../component-tests/apiGateway-tests/testCases/UpdateLetterStatus';
2+
import { PatchMessageRequestBody, PatchMessageResponseBody } from '../../component-tests/apiGateway-tests/testCases/UpdateLetterStatus';
33
import { RequestSandBoxHeaders, sandBoxHeader } from '../../constants/request_headers';
4+
import { ErrorMessageBody } from '../../helpers/commonTypes';
45
import { SandboxErrorResponse } from './getListOfLetters_testCases';
56

7+
68
export type ApiSandboxUpdateLetterStatusTestData = {
79
testCase: string;
810
id: string,
911
header: RequestSandBoxHeaders;
1012
body?: PatchMessageRequestBody;
1113
expectedStatus: number;
12-
expectedResponse?: PatchMessageResponseBody | SandboxErrorResponse | PatchErrorMessageBody;
14+
expectedResponse?: PatchMessageResponseBody | SandboxErrorResponse | ErrorMessageBody;
1315
};
1416

1517
export const apiSandboxUpdateLetterStatusTestData: ApiSandboxUpdateLetterStatusTestData[] = [

0 commit comments

Comments
 (0)