Feature/validate request header (#189)
* validate request header * Validate request header for API tests Co-authored-by: Nandan Anantharamu <Nandan@thinkify.com>
This commit is contained in:
parent
60efdb998b
commit
3c5d93e699
|
|
@ -37,5 +37,9 @@
|
|||
"prevUrl": ".data.previous}}",
|
||||
"methodsWithParam": "users?page=2",
|
||||
"invalidHeader": "invalid",
|
||||
"invalidValue": "invalid"
|
||||
}
|
||||
"invalidValue": "invalid",
|
||||
"Put": "PUT",
|
||||
"Get": "GET",
|
||||
"next": "?page=2&pageSize=10",
|
||||
"prev": "?page=1&pageSize=10"
|
||||
}
|
||||
|
|
@ -30,9 +30,10 @@ describe("API Panel Test Functionality", function() {
|
|||
.click({ force: true })
|
||||
.focus()
|
||||
.type(json, { force: true });
|
||||
cy.WaitAutoSave();
|
||||
cy.RunAPI();
|
||||
cy.validateRequest(testdata.baseUrl2, testdata.methodput, testdata.Put);
|
||||
});
|
||||
cy.WaitAutoSave();
|
||||
cy.RunAPI();
|
||||
cy.ResponseStatusCheck("200 OK");
|
||||
cy.log("Response code check successful");
|
||||
cy.ResponseCheck("updatedAt");
|
||||
|
|
@ -55,9 +56,10 @@ describe("API Panel Test Functionality", function() {
|
|||
.click({ force: true })
|
||||
.focus()
|
||||
.type(json, { force: true });
|
||||
cy.WaitAutoSave();
|
||||
cy.RunAPI();
|
||||
cy.validateRequest(testdata.baseUrl2, testdata.methodpost, testdata.Post);
|
||||
});
|
||||
cy.WaitAutoSave();
|
||||
cy.RunAPI();
|
||||
cy.ResponseStatusCheck("201 CREATED");
|
||||
cy.log("Response code check successful");
|
||||
cy.ResponseCheck("createdAt");
|
||||
|
|
@ -80,9 +82,14 @@ describe("API Panel Test Functionality", function() {
|
|||
.click({ force: true })
|
||||
.focus()
|
||||
.type(json, { force: true });
|
||||
cy.WaitAutoSave();
|
||||
cy.RunAPI();
|
||||
cy.validateRequest(
|
||||
testdata.baseUrl2,
|
||||
testdata.methodpatch,
|
||||
testdata.Patch,
|
||||
);
|
||||
});
|
||||
cy.WaitAutoSave();
|
||||
cy.RunAPI();
|
||||
cy.ResponseStatusCheck("200 OK");
|
||||
cy.log("Response code check successful");
|
||||
cy.ResponseCheck("updatedAt");
|
||||
|
|
@ -101,6 +108,11 @@ describe("API Panel Test Functionality", function() {
|
|||
);
|
||||
cy.WaitAutoSave();
|
||||
cy.RunAPI();
|
||||
cy.validateRequest(
|
||||
testdata.baseUrl2,
|
||||
testdata.methodpatch,
|
||||
testdata.Delete,
|
||||
);
|
||||
cy.ResponseStatusCheck("204 NO_CONTENT");
|
||||
cy.log("Response code check successful");
|
||||
});
|
||||
|
|
@ -112,6 +124,7 @@ describe("API Panel Test Functionality", function() {
|
|||
cy.enterDatasourceAndPath(testdata.baseUrl, testdata.methods);
|
||||
cy.WaitAutoSave();
|
||||
cy.RunAPI();
|
||||
cy.validateRequest(testdata.baseUrl, testdata.methods, testdata.Get);
|
||||
cy.ResponseStatusCheck(testdata.successStatusCode);
|
||||
cy.log("Response code check successful");
|
||||
cy.ResponseCheck(testdata.responsetext);
|
||||
|
|
@ -120,12 +133,22 @@ describe("API Panel Test Functionality", function() {
|
|||
cy.selectPaginationType(apiwidget.paginationWithUrl);
|
||||
cy.enterUrl(apiname, apiwidget.panigationNextUrl, testdata.nextUrl);
|
||||
cy.clickTest(apiwidget.TestNextUrl);
|
||||
cy.validateRequest(
|
||||
testdata.baseUrl,
|
||||
testdata.methods.concat(testdata.next),
|
||||
testdata.Get,
|
||||
);
|
||||
cy.ResponseStatusCheck(testdata.successStatusCode);
|
||||
cy.log("Response code check successful");
|
||||
cy.ResponseCheck("Josh M Krantz");
|
||||
cy.log("Response data check successful");
|
||||
cy.enterUrl(apiname, apiwidget.panigationPrevUrl, testdata.prevUrl);
|
||||
cy.clickTest(apiwidget.TestPreUrl);
|
||||
cy.validateRequest(
|
||||
testdata.baseUrl,
|
||||
testdata.methods.concat(testdata.prev),
|
||||
testdata.Get,
|
||||
);
|
||||
cy.ResponseStatusCheck(testdata.successStatusCode);
|
||||
cy.log("Response code check successful");
|
||||
cy.ResponseCheck(testdata.responsetext);
|
||||
|
|
@ -138,6 +161,7 @@ describe("API Panel Test Functionality", function() {
|
|||
cy.enterDatasourceAndPath(testdata.baseUrl, testdata.queryAndValue);
|
||||
cy.WaitAutoSave();
|
||||
cy.RunAPI();
|
||||
cy.validateRequest(testdata.baseUrl, testdata.queryAndValue, testdata.Get);
|
||||
cy.ResponseStatusCheck("200 OK");
|
||||
cy.log("Response code check successful");
|
||||
cy.ResponseCheck(testdata.responsetext3);
|
||||
|
|
@ -157,6 +181,7 @@ describe("API Panel Test Functionality", function() {
|
|||
);
|
||||
cy.WaitAutoSave();
|
||||
cy.RunAPI();
|
||||
cy.validateRequest(testdata.baseUrl, testdata.methods, testdata.Get);
|
||||
cy.ResponseStatusCheck("5000");
|
||||
cy.log("Response code check successful");
|
||||
cy.ResponseCheck("Invalid value for Content-Type");
|
||||
|
|
|
|||
|
|
@ -9,8 +9,8 @@ describe("API Panel Test Functionality", function() {
|
|||
cy.CreateAPI("FirstAPI");
|
||||
cy.log("Creation of FirstAPI Action successful");
|
||||
cy.enterDatasourceAndPath(testdata.baseUrl, testdata.methods);
|
||||
cy.WaitAutoSave();
|
||||
cy.RunAPI();
|
||||
cy.SaveAndRunAPI();
|
||||
cy.validateRequest(testdata.baseUrl, testdata.methods, testdata.Get);
|
||||
cy.ResponseStatusCheck(testdata.successStatusCode);
|
||||
cy.get(apiwidget.createApiOnSideBar)
|
||||
.first()
|
||||
|
|
|
|||
|
|
@ -34,5 +34,12 @@
|
|||
"TestNextUrl": ".t--apiFormPaginationNextTest",
|
||||
"TestPreUrl": ".t--apiFormPaginationPrevTest",
|
||||
"EditApiName": "img[alt='Edit pen']",
|
||||
"ApiName": ".t--action-name-edit-field span"
|
||||
"ApiName": ".t--action-name-edit-field span",
|
||||
"Request": "//li[text()='Request']",
|
||||
"RequestURL": "(//span[@class='bp3-tree-node-label']/span)[1]",
|
||||
"RequestMethod": "(//span[@class='bp3-tree-node-label']/span)[2]",
|
||||
"content-Type": "(//span[@class='bp3-tree-node-label']/span)[3]",
|
||||
"requestBody": "(//div[contains(@class,'bp3-collapse-body')]//textarea)[1]",
|
||||
"showrequest": "span:contains('Show Request')",
|
||||
"Responsetab": "//li[text()='Response Body']"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -377,6 +377,17 @@ Cypress.Commands.add("SaveAndRunAPI", () => {
|
|||
cy.RunAPI();
|
||||
});
|
||||
|
||||
Cypress.Commands.add("validateRequest", (baseurl, path, verb) => {
|
||||
cy.xpath(apiwidget.Request)
|
||||
.should("be.visible")
|
||||
.click({ force: true });
|
||||
cy.xpath(apiwidget.RequestURL).contains(baseurl.concat(path));
|
||||
cy.xpath(apiwidget.RequestMethod).contains(verb);
|
||||
cy.xpath(apiwidget.Responsetab)
|
||||
.should("be.visible")
|
||||
.click({ force: true });
|
||||
});
|
||||
|
||||
Cypress.Commands.add("SelectAction", action => {
|
||||
cy.get(ApiEditor.ApiVerb)
|
||||
.first()
|
||||
|
|
@ -471,9 +482,12 @@ Cypress.Commands.add("selectPaginationType", option => {
|
|||
});
|
||||
|
||||
Cypress.Commands.add("clickTest", testbutton => {
|
||||
cy.wait(2000);
|
||||
cy.wait("@saveAction");
|
||||
cy.get(testbutton)
|
||||
.first()
|
||||
.click({ force: true });
|
||||
cy.wait("@postExecute");
|
||||
});
|
||||
|
||||
Cypress.Commands.add("enterUrl", (apiname, url, value) => {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user