Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {

const testdata = require("../../../../fixtures/testdata.json");
const apiwidget = require("../../../../locators/apiWidgetslocator.json");
import apiLocators from "../../../../locators/ApiEditor";

import {
agHelper,
Expand All @@ -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",
Expand All @@ -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");
});
Expand All @@ -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");
});
Expand All @@ -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");
});
Expand All @@ -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);
});
});

Expand All @@ -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);
Expand All @@ -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(
Expand All @@ -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 () {
Expand All @@ -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 () {
Expand All @@ -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");
});
},
Expand Down
1 change: 1 addition & 0 deletions app/client/cypress/locators/ApiEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,5 @@ export default {
slashCommandButton: ".commands-button",
apiResponseObject: ".object-key",
apiDebuggerLink: ".debugger-entity-link",
apiResponseTabsList : ".ads-v2-tabs__list"
};
19 changes: 19 additions & 0 deletions app/client/cypress/support/Pages/AggregateHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down