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 apiwidget = require("../../../../locators/apiWidgetslocator.json");
|
||||
import apiLocators from "../../../../locators/ApiEditor";
|
||||
|
||||
import {
|
||||
agHelper,
|
||||
|
|
@ -17,6 +18,7 @@ describe(
|
|||
"API Panel Test Functionality",
|
||||
{ tags: ["@tag.Datasource"] },
|
||||
function () {
|
||||
const successMsg = "Executed successfully from user request";
|
||||
afterEach(function () {
|
||||
agHelper.ActionContextMenuWithInPane({
|
||||
action: "Delete",
|
||||
|
|
@ -39,12 +41,8 @@ describe(
|
|||
agHelper.AssertAutoSave();
|
||||
apiPage.RunAPI();
|
||||
apiPage.ResponseStatusCheck("200 OK");
|
||||
cy.validateRequest(
|
||||
"Executed successfully",
|
||||
testdata.baseUrl,
|
||||
testdata.echoMethod,
|
||||
testdata.Put,
|
||||
);
|
||||
agHelper.GetNClickByContains(apiLocators.apiResponseTabsList, "Logs");
|
||||
agHelper.AssertContains(successMsg);
|
||||
});
|
||||
cy.ResponseCheck("updatedAt");
|
||||
});
|
||||
|
|
@ -63,12 +61,8 @@ describe(
|
|||
agHelper.AssertAutoSave();
|
||||
apiPage.RunAPI();
|
||||
apiPage.ResponseStatusCheck("200 OK");
|
||||
cy.validateRequest(
|
||||
"Executed successfully",
|
||||
testdata.baseUrl,
|
||||
testdata.echoMethod,
|
||||
testdata.Post,
|
||||
);
|
||||
agHelper.GetNClickByContains(apiLocators.apiResponseTabsList, "Logs");
|
||||
agHelper.AssertContains(successMsg);
|
||||
});
|
||||
cy.ResponseCheck("createdAt");
|
||||
});
|
||||
|
|
@ -87,12 +81,8 @@ describe(
|
|||
agHelper.AssertAutoSave();
|
||||
apiPage.RunAPI();
|
||||
apiPage.ResponseStatusCheck("200 OK");
|
||||
cy.validateRequest(
|
||||
"Executed successfully",
|
||||
testdata.baseUrl,
|
||||
testdata.echoMethod,
|
||||
testdata.Patch,
|
||||
);
|
||||
agHelper.GetNClickByContains(apiLocators.apiResponseTabsList, "Logs");
|
||||
agHelper.AssertContains(successMsg);
|
||||
});
|
||||
cy.ResponseCheck("updatedAt");
|
||||
});
|
||||
|
|
@ -111,12 +101,8 @@ describe(
|
|||
agHelper.AssertAutoSave();
|
||||
apiPage.RunAPI();
|
||||
apiPage.ResponseStatusCheck("200 OK");
|
||||
cy.validateRequest(
|
||||
"Executed successfully",
|
||||
testdata.baseUrl,
|
||||
testdata.echoMethod,
|
||||
testdata.Delete,
|
||||
);
|
||||
agHelper.GetNClickByContains(apiLocators.apiResponseTabsList, "Logs");
|
||||
agHelper.AssertContains(successMsg);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
@ -127,12 +113,8 @@ describe(
|
|||
apiPage.RunAPI();
|
||||
apiPage.ResponseStatusCheck("200 OK");
|
||||
cy.ResponseCheck(testdata.responsetext);
|
||||
cy.validateRequest(
|
||||
"Executed successfully",
|
||||
testdata.baseUrl,
|
||||
testdata.methods,
|
||||
testdata.Get,
|
||||
);
|
||||
agHelper.GetNClickByContains(apiLocators.apiResponseTabsList, "Logs");
|
||||
agHelper.AssertContains(successMsg);
|
||||
|
||||
apiPage.SelectPaneTab("Pagination");
|
||||
agHelper.GetNClick(apiwidget.paginationWithUrl);
|
||||
|
|
@ -144,12 +126,8 @@ describe(
|
|||
cy.clickTest(apiwidget.TestNextUrl);
|
||||
apiPage.ResponseStatusCheck("200 OK");
|
||||
cy.ResponseCheck("Josh M Krantz");
|
||||
cy.validateRequest(
|
||||
"Executed successfully",
|
||||
testdata.baseUrl,
|
||||
testdata.next,
|
||||
testdata.Get,
|
||||
);
|
||||
agHelper.GetNClickByContains(apiLocators.apiResponseTabsList, "Logs");
|
||||
agHelper.AssertContains(successMsg);
|
||||
|
||||
apiPage.SelectPaneTab("Pagination");
|
||||
cy.enterUrl(
|
||||
|
|
@ -160,12 +138,8 @@ describe(
|
|||
cy.clickTest(apiwidget.TestPreUrl);
|
||||
apiPage.ResponseStatusCheck("200 OK");
|
||||
cy.ResponseCheck(testdata.responsetext);
|
||||
cy.validateRequest(
|
||||
"Executed successfully",
|
||||
testdata.baseUrl,
|
||||
testdata.prev,
|
||||
testdata.Get,
|
||||
);
|
||||
agHelper.GetNClickByContains(apiLocators.apiResponseTabsList, "Logs");
|
||||
agHelper.AssertContains(successMsg);
|
||||
});
|
||||
|
||||
it("6. API check with query params test API feature", function () {
|
||||
|
|
@ -174,12 +148,8 @@ describe(
|
|||
apiPage.RunAPI();
|
||||
apiPage.ResponseStatusCheck("200 OK");
|
||||
cy.ResponseCheck(testdata.responsetext3);
|
||||
cy.validateRequest(
|
||||
"Executed successfully",
|
||||
testdata.baseUrl,
|
||||
testdata.queryAndValue,
|
||||
testdata.Get,
|
||||
);
|
||||
agHelper.GetNClickByContains(apiLocators.apiResponseTabsList, "Logs");
|
||||
agHelper.AssertContains(successMsg);
|
||||
});
|
||||
|
||||
it("7. API check with Invalid Header", function () {
|
||||
|
|
@ -188,13 +158,8 @@ describe(
|
|||
agHelper.AssertAutoSave();
|
||||
apiPage.RunAPI(false);
|
||||
apiPage.ResponseStatusCheck("5000");
|
||||
cy.validateRequest(
|
||||
"Execution failed",
|
||||
testdata.baseUrl,
|
||||
testdata.methods,
|
||||
testdata.Get,
|
||||
true,
|
||||
);
|
||||
agHelper.GetNClickByContains(apiLocators.apiResponseTabsList, "Logs");
|
||||
agHelper.AssertContains(successMsg);
|
||||
cy.ResponseCheck("Invalid value for Content-Type");
|
||||
});
|
||||
},
|
||||
|
|
|
|||
|
|
@ -34,4 +34,5 @@ export default {
|
|||
slashCommandButton: ".commands-button",
|
||||
apiResponseObject: ".object-key",
|
||||
apiDebuggerLink: ".debugger-entity-link",
|
||||
apiResponseTabsList : ".ads-v2-tabs__list"
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1552,6 +1552,25 @@ export class AggregateHelper {
|
|||
) 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) {
|
||||
cy.get("body").then(($ele) => {
|
||||
if ($ele.find(this.locator._toastMsg).length > 0) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user