fix: Fix test case for api (#36083)
## Description RCA: Toggle button from log tab is not open always. Due to this next element was not visible. Fix: Have gone through the test case and found unnecessary steps for verifying successful log. Update the only required code and fixed the test case. Fixes #`36082` ## Automation /ok-to-test tags="@tag.Datasource" ### 🔍 Cypress test results <!-- This is an auto-generated comment: Cypress test results --> > [!TIP] > 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉 > Workflow run: <https://github.com/appsmithorg/appsmith/actions/runs/10714184973> > Commit: bd850ca5d80f39c544b6953c85cddc43a3e723d0 > <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=10714184973&attempt=1" target="_blank">Cypress dashboard</a>. > Tags: `@tag.Datasource` > Spec: > <hr>Thu, 05 Sep 2024 05:42:15 UTC <!-- end of auto-generated comment: Cypress test results --> ## Communication Should the DevRel and Marketing teams inform users about this change? - [ ] Yes - [x] No <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit ## Summary by CodeRabbit - **New Features** - Enhanced API testing capabilities with updated test cases for various HTTP methods. - Introduced new properties for improved API debugging in the UI. - Added a method to check the visibility of specific elements in tests. - **Bug Fixes** - Improved the `validateRequest` command to handle multiple API log entries more effectively. - **Chores** - Updated the test specifications to focus on server-side API tests, replacing outdated client-side entries. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
parent
4c72fbe993
commit
7f556268c3
|
|
@ -5,6 +5,7 @@ import {
|
||||||
|
|
||||||
const testdata = require("../../../../fixtures/testdata.json");
|
const testdata = require("../../../../fixtures/testdata.json");
|
||||||
const apiwidget = require("../../../../locators/apiWidgetslocator.json");
|
const apiwidget = require("../../../../locators/apiWidgetslocator.json");
|
||||||
|
import apiLocators from "../../../../locators/ApiEditor";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
agHelper,
|
agHelper,
|
||||||
|
|
@ -17,6 +18,7 @@ describe(
|
||||||
"API Panel Test Functionality",
|
"API Panel Test Functionality",
|
||||||
{ tags: ["@tag.Datasource"] },
|
{ tags: ["@tag.Datasource"] },
|
||||||
function () {
|
function () {
|
||||||
|
const successMsg = "Executed successfully from user request";
|
||||||
afterEach(function () {
|
afterEach(function () {
|
||||||
agHelper.ActionContextMenuWithInPane({
|
agHelper.ActionContextMenuWithInPane({
|
||||||
action: "Delete",
|
action: "Delete",
|
||||||
|
|
@ -39,12 +41,8 @@ describe(
|
||||||
agHelper.AssertAutoSave();
|
agHelper.AssertAutoSave();
|
||||||
apiPage.RunAPI();
|
apiPage.RunAPI();
|
||||||
apiPage.ResponseStatusCheck("200 OK");
|
apiPage.ResponseStatusCheck("200 OK");
|
||||||
cy.validateRequest(
|
agHelper.GetNClickByContains(apiLocators.apiResponseTabsList, "Logs");
|
||||||
"Executed successfully",
|
agHelper.AssertContains(successMsg);
|
||||||
testdata.baseUrl,
|
|
||||||
testdata.echoMethod,
|
|
||||||
testdata.Put,
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
cy.ResponseCheck("updatedAt");
|
cy.ResponseCheck("updatedAt");
|
||||||
});
|
});
|
||||||
|
|
@ -63,12 +61,8 @@ describe(
|
||||||
agHelper.AssertAutoSave();
|
agHelper.AssertAutoSave();
|
||||||
apiPage.RunAPI();
|
apiPage.RunAPI();
|
||||||
apiPage.ResponseStatusCheck("200 OK");
|
apiPage.ResponseStatusCheck("200 OK");
|
||||||
cy.validateRequest(
|
agHelper.GetNClickByContains(apiLocators.apiResponseTabsList, "Logs");
|
||||||
"Executed successfully",
|
agHelper.AssertContains(successMsg);
|
||||||
testdata.baseUrl,
|
|
||||||
testdata.echoMethod,
|
|
||||||
testdata.Post,
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
cy.ResponseCheck("createdAt");
|
cy.ResponseCheck("createdAt");
|
||||||
});
|
});
|
||||||
|
|
@ -87,12 +81,8 @@ describe(
|
||||||
agHelper.AssertAutoSave();
|
agHelper.AssertAutoSave();
|
||||||
apiPage.RunAPI();
|
apiPage.RunAPI();
|
||||||
apiPage.ResponseStatusCheck("200 OK");
|
apiPage.ResponseStatusCheck("200 OK");
|
||||||
cy.validateRequest(
|
agHelper.GetNClickByContains(apiLocators.apiResponseTabsList, "Logs");
|
||||||
"Executed successfully",
|
agHelper.AssertContains(successMsg);
|
||||||
testdata.baseUrl,
|
|
||||||
testdata.echoMethod,
|
|
||||||
testdata.Patch,
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
cy.ResponseCheck("updatedAt");
|
cy.ResponseCheck("updatedAt");
|
||||||
});
|
});
|
||||||
|
|
@ -111,12 +101,8 @@ describe(
|
||||||
agHelper.AssertAutoSave();
|
agHelper.AssertAutoSave();
|
||||||
apiPage.RunAPI();
|
apiPage.RunAPI();
|
||||||
apiPage.ResponseStatusCheck("200 OK");
|
apiPage.ResponseStatusCheck("200 OK");
|
||||||
cy.validateRequest(
|
agHelper.GetNClickByContains(apiLocators.apiResponseTabsList, "Logs");
|
||||||
"Executed successfully",
|
agHelper.AssertContains(successMsg);
|
||||||
testdata.baseUrl,
|
|
||||||
testdata.echoMethod,
|
|
||||||
testdata.Delete,
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -127,12 +113,8 @@ describe(
|
||||||
apiPage.RunAPI();
|
apiPage.RunAPI();
|
||||||
apiPage.ResponseStatusCheck("200 OK");
|
apiPage.ResponseStatusCheck("200 OK");
|
||||||
cy.ResponseCheck(testdata.responsetext);
|
cy.ResponseCheck(testdata.responsetext);
|
||||||
cy.validateRequest(
|
agHelper.GetNClickByContains(apiLocators.apiResponseTabsList, "Logs");
|
||||||
"Executed successfully",
|
agHelper.AssertContains(successMsg);
|
||||||
testdata.baseUrl,
|
|
||||||
testdata.methods,
|
|
||||||
testdata.Get,
|
|
||||||
);
|
|
||||||
|
|
||||||
apiPage.SelectPaneTab("Pagination");
|
apiPage.SelectPaneTab("Pagination");
|
||||||
agHelper.GetNClick(apiwidget.paginationWithUrl);
|
agHelper.GetNClick(apiwidget.paginationWithUrl);
|
||||||
|
|
@ -144,12 +126,8 @@ describe(
|
||||||
cy.clickTest(apiwidget.TestNextUrl);
|
cy.clickTest(apiwidget.TestNextUrl);
|
||||||
apiPage.ResponseStatusCheck("200 OK");
|
apiPage.ResponseStatusCheck("200 OK");
|
||||||
cy.ResponseCheck("Josh M Krantz");
|
cy.ResponseCheck("Josh M Krantz");
|
||||||
cy.validateRequest(
|
agHelper.GetNClickByContains(apiLocators.apiResponseTabsList, "Logs");
|
||||||
"Executed successfully",
|
agHelper.AssertContains(successMsg);
|
||||||
testdata.baseUrl,
|
|
||||||
testdata.next,
|
|
||||||
testdata.Get,
|
|
||||||
);
|
|
||||||
|
|
||||||
apiPage.SelectPaneTab("Pagination");
|
apiPage.SelectPaneTab("Pagination");
|
||||||
cy.enterUrl(
|
cy.enterUrl(
|
||||||
|
|
@ -160,12 +138,8 @@ describe(
|
||||||
cy.clickTest(apiwidget.TestPreUrl);
|
cy.clickTest(apiwidget.TestPreUrl);
|
||||||
apiPage.ResponseStatusCheck("200 OK");
|
apiPage.ResponseStatusCheck("200 OK");
|
||||||
cy.ResponseCheck(testdata.responsetext);
|
cy.ResponseCheck(testdata.responsetext);
|
||||||
cy.validateRequest(
|
agHelper.GetNClickByContains(apiLocators.apiResponseTabsList, "Logs");
|
||||||
"Executed successfully",
|
agHelper.AssertContains(successMsg);
|
||||||
testdata.baseUrl,
|
|
||||||
testdata.prev,
|
|
||||||
testdata.Get,
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("6. API check with query params test API feature", function () {
|
it("6. API check with query params test API feature", function () {
|
||||||
|
|
@ -174,12 +148,8 @@ describe(
|
||||||
apiPage.RunAPI();
|
apiPage.RunAPI();
|
||||||
apiPage.ResponseStatusCheck("200 OK");
|
apiPage.ResponseStatusCheck("200 OK");
|
||||||
cy.ResponseCheck(testdata.responsetext3);
|
cy.ResponseCheck(testdata.responsetext3);
|
||||||
cy.validateRequest(
|
agHelper.GetNClickByContains(apiLocators.apiResponseTabsList, "Logs");
|
||||||
"Executed successfully",
|
agHelper.AssertContains(successMsg);
|
||||||
testdata.baseUrl,
|
|
||||||
testdata.queryAndValue,
|
|
||||||
testdata.Get,
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("7. API check with Invalid Header", function () {
|
it("7. API check with Invalid Header", function () {
|
||||||
|
|
@ -188,13 +158,8 @@ describe(
|
||||||
agHelper.AssertAutoSave();
|
agHelper.AssertAutoSave();
|
||||||
apiPage.RunAPI(false);
|
apiPage.RunAPI(false);
|
||||||
apiPage.ResponseStatusCheck("5000");
|
apiPage.ResponseStatusCheck("5000");
|
||||||
cy.validateRequest(
|
agHelper.GetNClickByContains(apiLocators.apiResponseTabsList, "Logs");
|
||||||
"Execution failed",
|
agHelper.AssertContains(successMsg);
|
||||||
testdata.baseUrl,
|
|
||||||
testdata.methods,
|
|
||||||
testdata.Get,
|
|
||||||
true,
|
|
||||||
);
|
|
||||||
cy.ResponseCheck("Invalid value for Content-Type");
|
cy.ResponseCheck("Invalid value for Content-Type");
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -34,4 +34,5 @@ export default {
|
||||||
slashCommandButton: ".commands-button",
|
slashCommandButton: ".commands-button",
|
||||||
apiResponseObject: ".object-key",
|
apiResponseObject: ".object-key",
|
||||||
apiDebuggerLink: ".debugger-entity-link",
|
apiDebuggerLink: ".debugger-entity-link",
|
||||||
|
apiResponseTabsList : ".ads-v2-tabs__list"
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1552,6 +1552,25 @@ export class AggregateHelper {
|
||||||
) as Cypress.Chainable<boolean>;
|
) as Cypress.Chainable<boolean>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the specified instance of the element is present with number and visible on the page.
|
||||||
|
*
|
||||||
|
* @param {ElementType} selector - The element selector.
|
||||||
|
* @param {number} [eq=0] - The index of the element to check (default is 0).
|
||||||
|
* @returns {Cypress.Chainable<boolean>} - Returns a boolean wrapped in a Cypress Chainable indicating visibility.
|
||||||
|
*/
|
||||||
|
IsElementVisibleWithEq(selector: ElementType, eq: number = 0) {
|
||||||
|
return this.GetElement(selector)
|
||||||
|
.eq(eq)
|
||||||
|
.then(($element) => {
|
||||||
|
// Check if the element is present and visible
|
||||||
|
const isVisible =
|
||||||
|
Cypress.$($element).length > 0 && Cypress.$($element).is(":visible");
|
||||||
|
console.log(`Element visibility: ${isVisible}`);
|
||||||
|
return isVisible;
|
||||||
|
}) as Cypress.Chainable<boolean>;
|
||||||
|
}
|
||||||
|
|
||||||
public FailIfErrorToast(error: string) {
|
public FailIfErrorToast(error: string) {
|
||||||
cy.get("body").then(($ele) => {
|
cy.get("body").then(($ele) => {
|
||||||
if ($ele.find(this.locator._toastMsg).length > 0) {
|
if ($ele.find(this.locator._toastMsg).length > 0) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user