From 8fed1bbbd5732131175170ce083c9b918f7c54eb Mon Sep 17 00:00:00 2001 From: veerendra thakur Date: Tue, 26 Sep 2023 16:41:09 +0530 Subject: [PATCH] Added cypress test case for cypress-docs API Signed-off-by: veerendra thakur --- tests/functional/cypress/e2e/docs.cy.ts | 43 +++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 tests/functional/cypress/e2e/docs.cy.ts diff --git a/tests/functional/cypress/e2e/docs.cy.ts b/tests/functional/cypress/e2e/docs.cy.ts new file mode 100644 index 000000000..eaacf9b94 --- /dev/null +++ b/tests/functional/cypress/e2e/docs.cy.ts @@ -0,0 +1,43 @@ +import {validateApiResponse,validate_200_Status,getTokenKey} from '../support/commands' + +describe("To Validate & get api-docs via API call", function () { + + + //Reference api doc: https://api-gw.dev.platform.linuxfoundation.org/cla-service/v4/api-docs#tag/docs + 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("Endpoint to render the API documentation- Record should Returns 200 Response", function () { + cy.request({ + method: 'GET', + url: `${claEndpoint}/api-docs`, + auth: { + 'bearer': bearerToken, + } + }).then((response) => { + validate_200_Status(response); + }); + }); + +it("Returns the Swagger specification as a JSON document- Record should Returns 200 Response", function () { + cy.request({ + method: 'GET', + url: `${claEndpoint}/swagger.json`, + auth: { + 'bearer': bearerToken, + } + }).then((response) => { + validate_200_Status(response); + }); + }); + +}) \ No newline at end of file