Skip to content
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

Added cypress test case for cypress-health API #4140

Merged
merged 1 commit into from
Sep 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions tests/functional/cypress/e2e/health.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import {validateApiResponse,validate_200_Status,getTokenKey} from '../support/commands'

describe("To Validate & get health status via API call", function () {

//Reference api doc: https://api-gw.dev.platform.linuxfoundation.org/cla-service/v4/api-docs#tag/health/operation/healthCheck
const claEndpoint = `${Cypress.env("APP_URL")}cla-service/v4`;

let bearerToken: string = null;
before(() => {
if(bearerToken==null){
getTokenKey(bearerToken);
cy.window().then((win) => {
bearerToken = win.localStorage.getItem('bearerToken');
});
}
});

it("Returns the Health of the application- Record should Returns 200 Response", function () {
cy.request({
method: 'GET',
url: `${claEndpoint}/ops/health`,
auth: {
'bearer': bearerToken,
}
}).then((response) => {
validate_200_Status(response);
//To validate schema of response
validateApiResponse("health/healthCheck.json",response)
});
});

})
65 changes: 65 additions & 0 deletions tests/functional/cypress/fixtures/health/healthCheck.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"Branch": {
"type": "string"
},
"BuildTimeStamp": {
"type": "string"
},
"Githash": {
"type": "string"
},
"Healths": {
"type": "array",
"items": [
{
"type": "object",
"properties": {
"Duration": {
"type": "string"
},
"Error": {
"type": "string"
},
"Healthy": {
"type": "boolean"
},
"Name": {
"type": "string"
},
"TimeStamp": {
"type": "string"
}
},
"required": [
"Duration",

"Healthy",
"Name",
"TimeStamp"
]
}
]
},
"Status": {
"type": "string"
},
"TimeStamp": {
"type": "string"
},
"Version": {
"type": "string"
}
},
"required": [
"Branch",
"BuildTimeStamp",
"Githash",
"Healths",
"Status",
"TimeStamp",
"Version"
]
}
Loading