-
Notifications
You must be signed in to change notification settings - Fork 2
CCM 12179: Add Component Tests #194
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 9 commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
345d687
test
Namitha-Prabhu 64e9995
Comp tests
Namitha-Prabhu d28f7d5
Comp tests
Namitha-Prabhu 8e56956
component tests
Namitha-Prabhu e658df2
test
Namitha-Prabhu 06f62fd
Comp tests
Namitha-Prabhu 24cc719
Comp tests
Namitha-Prabhu af781ad
component tests
Namitha-Prabhu 5c26997
Merge branch 'feature/CCM-12179-Component-tests' of https://github.co…
Namitha-Prabhu 84378d6
review comments
Namitha-Prabhu c17261e
tests on pipeline
Namitha-Prabhu e4ac798
dependencies
Namitha-Prabhu aa08f80
tests
Namitha-Prabhu a91577c
Merge branch 'main' into feature/CCM-12179-Component-tests
Namitha-Prabhu af33e9e
revert test data changes
Namitha-Prabhu 5b8ac87
fix
Namitha-Prabhu 406d529
fix-cicd
Namitha-Prabhu ed3de2e
fix
Namitha-Prabhu 8359886
to discuss schema
Namitha-Prabhu 765cb82
to discuss schema
Namitha-Prabhu bf015b7
Remove test from pipeline
Namitha-Prabhu f482da8
Merge branch 'main' into feature/CCM-12179-Component-tests
Namitha-Prabhu 5d8a6c3
Remove test from pipeline
Namitha-Prabhu 9996615
Merge branch 'feature/CCM-12179-Component-tests' of https://github.co…
Namitha-Prabhu f29c91d
amend workflow
Namitha-Prabhu 20af907
Review Changes
Namitha-Prabhu 4d5d4e7
review fix
Namitha-Prabhu 77a6544
review fixes
Namitha-Prabhu 9b56f6a
Merge branch 'main' into feature/CCM-12179-Component-tests
Namitha-Prabhu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,3 +7,5 @@ node_modules/ | |
| /playwright/.cache/ | ||
| /allure-results | ||
| /target | ||
| /playwright/.auth/ | ||
| /allure-report | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| import { test, expect } from '@playwright/test'; | ||
| import { SUPPLIER_API_GATEWAY_NAME, SUPPLIER_LETTERS, AWS_REGION } from '../../constants/api_constants'; | ||
| import { createHeaderWithNoCorrelationId, createInvalidRequestHeaders, createValidRequestHeaders } from '../../constants/request_headers'; | ||
| import { validateApiResponse } from '../../helpers/validateJsonSchema'; | ||
| import { getRestApiGatewayBaseUrl } from '../../helpers/awsGatewayHelper'; | ||
|
|
||
| let baseUrl: string; | ||
|
|
||
| test.beforeAll(async () => { | ||
| const region = AWS_REGION; | ||
Namitha-Prabhu marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| baseUrl = await getRestApiGatewayBaseUrl(SUPPLIER_API_GATEWAY_NAME, region); | ||
| }); | ||
|
|
||
| test.describe('API Gateway Tests To Get List Of Pending ', () => | ||
Namitha-Prabhu marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| { | ||
| test('GET /letters should return 200 and list items', async ({ request }) => | ||
| { | ||
| const header = await createValidRequestHeaders(); | ||
| const response = await request.get(`${baseUrl}/${SUPPLIER_LETTERS}` ,{ | ||
| headers: header, | ||
| params: { | ||
| limit:'2'}, | ||
| }, | ||
| ); | ||
|
|
||
| expect(response.status()).toBe(200); | ||
| const responseBody = await response.json(); | ||
|
|
||
| const validationResult = validateApiResponse("get", "/letters", response.status(), responseBody); | ||
| if (validationResult) { | ||
| console.error("API response validation failed:", validationResult); | ||
| } | ||
|
|
||
| expect(validationResult).toBeUndefined(); | ||
| }); | ||
Namitha-Prabhu marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| test('GET /letters with invalid apikey should return 403', async ({ request }) => { | ||
| const header = await createInvalidRequestHeaders(); | ||
| const response = await request.get(`${baseUrl}/${SUPPLIER_LETTERS}` ,{ | ||
| headers: header, | ||
| params:{ | ||
| limit:'2' | ||
| }, | ||
| }, | ||
| ); | ||
| expect(response.status()).toBe(403); | ||
| }); | ||
|
|
||
|
|
||
| test('GET /letters with empty correlationId should return 500', async ({ request }) => { | ||
| const header = await createHeaderWithNoCorrelationId(); | ||
| const response = await request.get(`${baseUrl}/${SUPPLIER_LETTERS}` ,{ | ||
| headers: header, | ||
| params:{ | ||
| limit:'2' | ||
| }, | ||
| }, | ||
| ); | ||
| expect(response.status()).toBe(500); | ||
| const responseBody = await response.json(); | ||
|
|
||
| const validationResult = validateApiResponse("get", "/letters", response.status(), responseBody); | ||
| if (validationResult) { | ||
| console.error("API response validation failed:", validationResult); | ||
| } | ||
|
|
||
| expect(validationResult).toBeUndefined(); | ||
| }); | ||
|
|
||
| test('GET /letters with invalid query param return 400', async ({ request }) => { | ||
| const header = await createValidRequestHeaders(); | ||
| const response = await request.get(`${baseUrl}/${SUPPLIER_LETTERS}` ,{ | ||
| headers: header, | ||
| params:{ | ||
| limit:'?' | ||
| }, | ||
| }); | ||
| expect(response.status()).toBe(400); | ||
| const responseBody = await response.json(); | ||
|
|
||
| const validationResult = validateApiResponse("get", "/letters", response.status(), responseBody); | ||
| if (validationResult) { | ||
| console.error("API response validation failed:", validationResult); | ||
| } | ||
|
|
||
| expect(validationResult).toBeUndefined(); | ||
| }); | ||
|
|
||
| }); | ||
172 changes: 172 additions & 0 deletions
172
tests/component-tests/apiGateway-tests/testCases/UpdateLetterStatus.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,172 @@ | ||
|
|
||
| import { createValidRequestHeaders, RequestHeaders } from '../../../constants/request_headers'; | ||
| import { test } from '@playwright/test'; | ||
|
|
||
| type APIPatchMessageRequestTestCase = { | ||
| testCase: string; | ||
| id: string, | ||
| body?: PatchMessageRequestBody; | ||
| expectedStatus: number; | ||
| expectedResponse?: PatchMessageResponseBody | PatchErrorMessageBody; | ||
| }; | ||
|
|
||
| export type PatchMessageRequestBody = { | ||
| data: { | ||
| type: string; | ||
| id: string; | ||
| attributes: { | ||
| reasonCode?: number; | ||
| reasonText?: string; | ||
| status: string; | ||
| }; | ||
| }; | ||
| }; | ||
|
|
||
Namitha-Prabhu marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| export type PatchMessageResponseBody = { | ||
| data: { | ||
| type: string; | ||
| id: string; | ||
| attributes: { | ||
| reasonCode?: number; | ||
| reasonText?: string; | ||
| status: string; | ||
| specificationId:string; | ||
| groupId?:string; | ||
| }; | ||
| }; | ||
| }; | ||
|
|
||
| export type ErrorLink = { | ||
| about: string; | ||
| }; | ||
|
|
||
| type PatchErrorResponse = { | ||
| id: string; | ||
| code: string; | ||
| links: ErrorLink; | ||
| status: string; | ||
| title: string; | ||
| detail: string; | ||
| }; | ||
|
|
||
| export type PatchErrorMessageBody = { | ||
| errors: PatchErrorResponse[]; | ||
| }; | ||
|
|
||
|
|
||
|
|
||
| export const apiPatchMessageRequestTestData: APIPatchMessageRequestTestCase[] = [ | ||
| { | ||
| testCase: '200 response if record is updated with status REJECTED', | ||
| id: '00c61654-24f0-410e-a77e-04deef7d1eeb', | ||
| body: { | ||
| data: { | ||
| type: 'Letter', | ||
| id: '00c61654-24f0-410e-a77e-04deef7d1eeb', | ||
| attributes: { | ||
| reasonCode: 123, | ||
| reasonText: 'Test Reason Text', | ||
| status: 'REJECTED', | ||
| }, | ||
| } | ||
| }, | ||
| expectedStatus: 200, | ||
| expectedResponse: { | ||
| data: { | ||
| type: 'Letter', | ||
| id: '00c61654-24f0-410e-a77e-04deef7d1eeb', | ||
| attributes: { | ||
| reasonCode: 123, | ||
| reasonText: 'Test Reason Text', | ||
| status: 'REJECTED', | ||
| specificationId:'specification-id', | ||
| groupId:'group-id' | ||
| }, | ||
| } | ||
| }, | ||
| }, | ||
|
|
||
| { | ||
| testCase: '200 response if record is updated with status ACCEPTED', | ||
| id: '00c61654-24f0-410e-a77e-04deef7d1eeb', | ||
| body: { | ||
| data: { | ||
| type: 'Letter', | ||
| id: '00c61654-24f0-410e-a77e-04deef7d1eeb', | ||
| attributes: { | ||
| status: 'ACCEPTED', | ||
| }, | ||
| } | ||
| }, | ||
| expectedStatus: 200, | ||
| expectedResponse: { | ||
| data: { | ||
| type: 'Letter', | ||
| id: '00c61654-24f0-410e-a77e-04deef7d1eeb', | ||
| attributes: { | ||
| reasonCode: 123, | ||
| reasonText: 'Test Reason Text', | ||
| status: 'ACCEPTED', | ||
| specificationId:'specification-id', | ||
| groupId:'group-id' | ||
| }, | ||
| } | ||
| }, | ||
| }, | ||
|
|
||
| { | ||
| testCase: '400 response if request body is invalid', | ||
| id: '00c61654-24f0-410e-a77e-04deef7d1eeb', | ||
| body: { | ||
| data: { | ||
| type: 'Letter', | ||
| id: '00c61654-24f0-410e-a77e-04deef7d1eeb', | ||
| attributes: { | ||
| reasonCode: 123, | ||
| reasonText: 'Test Reason Text', | ||
| status: '', | ||
| }, | ||
| } | ||
| }, | ||
| expectedStatus: 400, | ||
| expectedResponse: { | ||
| errors: [{ | ||
| id: '1234', | ||
| code: 'NOTIFY_INVALID_REQUEST', | ||
| links: { | ||
| about: "https://digital.nhs.uk/developer/api-catalogue/nhs-notify-supplier" | ||
| }, | ||
| status: '400', | ||
| title: 'Invalid request', | ||
| detail: 'The request body is invalid' | ||
| }] | ||
| }, | ||
| }, | ||
|
|
||
| { | ||
| testCase: '500 response if id doesnt exist supplierid', | ||
| id: '0', | ||
| body: { | ||
| data: { | ||
| type: 'Letter', | ||
| id: '0', | ||
| attributes: { | ||
| status: 'ACCEPTED', | ||
| }, | ||
| } | ||
| }, | ||
| expectedStatus: 500, | ||
| expectedResponse: { | ||
| errors: [{ | ||
| id: '1234', | ||
| code: 'NOTIFY_INTERNAL_SERVER_ERROR', | ||
| links: { | ||
| about: "https://digital.nhs.uk/developer/api-catalogue/nhs-notify-supplier" | ||
| }, | ||
| status: '500', | ||
| title: 'Internal server error', | ||
| detail: 'Letter with id 0 not found for supplier supplier-id' | ||
| }] | ||
| }, | ||
| }, | ||
| ]; | ||
28 changes: 28 additions & 0 deletions
28
tests/component-tests/apiGateway-tests/updateLetterStatus.spec.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| import { test, expect } from '@playwright/test'; | ||
| import { SUPPLIER_API_GATEWAY_NAME, SUPPLIER_LETTERS, AWS_REGION } from '../../constants/api_constants'; | ||
| import { getRestApiGatewayBaseUrl } from '../../helpers/awsGatewayHelper'; | ||
| import { createValidRequestHeaders } from '../../constants/request_headers'; | ||
| import { apiPatchMessageRequestTestData } from './testCases/UpdateLetterStatus'; | ||
|
|
||
| let baseUrl: string; | ||
|
|
||
| test.beforeAll(async () => { | ||
| const region = AWS_REGION; | ||
| baseUrl = await getRestApiGatewayBaseUrl(SUPPLIER_API_GATEWAY_NAME, region); | ||
| }); | ||
|
|
||
| test.describe('API Gateway Tests To Verify Patch Status Endpoint ', () => { | ||
| apiPatchMessageRequestTestData.forEach(({ testCase, id, body, expectedStatus, expectedResponse }) => { | ||
| test(`Patch /letters returns ${testCase}`, async ({ request }) => { | ||
| const response = await request.patch(`${baseUrl}/${SUPPLIER_LETTERS}/${id}` ,{ | ||
| headers: await createValidRequestHeaders(), | ||
| data: body | ||
| }, | ||
| ); | ||
| const res = await response.json(); | ||
|
|
||
| expect(response.status()).toBe(expectedStatus); | ||
| expect(res).toEqual(expectedResponse); | ||
| }); | ||
| }); | ||
| }); | ||
Namitha-Prabhu marked this conversation as resolved.
Show resolved
Hide resolved
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,20 +1,19 @@ | ||
| import type { PlaywrightTestConfig } from '@playwright/test'; | ||
| import { config as baseConfig } from './playwright.base.config'; | ||
| import { getReporters } from './reporters'; | ||
| import {defineConfig, PlaywrightTestConfig } from '@playwright/test'; | ||
| import baseConfig from './playwright.base.config'; | ||
| import { getReporters } from './reporters'; | ||
| import path from 'path'; | ||
|
|
||
| const localConfig: PlaywrightTestConfig = { | ||
| ...baseConfig, | ||
| /* Reporter to use. See https://playwright.dev/docs/test-reporters */ | ||
| reporter: getReporters('api-test'), | ||
| ...baseConfig, | ||
| //globalSetup: require.resolve('./setup/globalSetup'), | ||
| //globalTeardown: require.resolve('./setup/globalTeardown'), | ||
| testIgnore: [], | ||
| projects: [ | ||
| { | ||
| name: 'sandbox', | ||
| testMatch: 'tests/messages/get_single_letter/*.spec.ts', | ||
| name: 'component-tests', | ||
| testDir: path.resolve(__dirname, '../component-tests'), | ||
| testMatch: '**/*.spec.ts', | ||
| }, | ||
| ], | ||
| }; | ||
|
|
||
| export default localConfig; | ||
| export default defineConfig(localConfig); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.