Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 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 Down Expand Up @@ -39,12 +40,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("Executed successfully from user request");
});
cy.ResponseCheck("updatedAt");
});
Expand All @@ -63,12 +60,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("Executed successfully from user request");
});
cy.ResponseCheck("createdAt");
});
Expand All @@ -87,12 +80,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("Executed successfully from user request");
});
cy.ResponseCheck("updatedAt");
});
Expand All @@ -111,12 +100,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("Executed successfully from user request");
});
});

Expand All @@ -127,12 +112,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("Executed successfully from user request");
Comment thread
sagar-qa007 marked this conversation as resolved.
Outdated

apiPage.SelectPaneTab("Pagination");
agHelper.GetNClick(apiwidget.paginationWithUrl);
Expand All @@ -144,12 +125,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("Executed successfully from user request");

apiPage.SelectPaneTab("Pagination");
cy.enterUrl(
Expand All @@ -160,12 +137,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("Executed successfully from user request");
});

it("6. API check with query params test API feature", function () {
Expand All @@ -174,12 +147,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("Executed successfully from user request");
});

it("7. API check with Invalid Header", function () {
Expand All @@ -188,13 +157,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("Executed successfully from user request");
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) {
Comment thread
sagar-qa007 marked this conversation as resolved.
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