fix: cypress flakiness due to focus cypress function (#33106)

This commit is contained in:
Aman Agarwal 2024-05-02 10:10:13 +05:30 committed by GitHub
parent 841b9f95c8
commit ff2e239f47
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 20 additions and 11 deletions

View File

@ -15,11 +15,13 @@ describe("Update Application", () => {
appname = localStorage.getItem("appName");
cy.get(homePage.searchInput).clear();
cy.get(homePage.searchInput).type(workspaceName);
cy.get(homePage.searchInput).click().type(workspaceName);
// eslint-disable-next-line cypress/no-unnecessary-waiting
cy.wait(2000);
cy.get(homePage.appMoreIcon).first().click({ force: true });
cy.get(homePage.applicationName).type(`${appname} updated` + "{enter}");
cy.get(homePage.applicationName)
.click()
.type(`${appname} updated` + "{enter}");
cy.wait("@updateApplication").should(
"have.nested.property",
"response.body.responseMeta.status",
@ -45,7 +47,7 @@ describe("Update Application", () => {
it("3. Check for errors in updating application name", () => {
cy.get(commonlocators.homeIcon).click({ force: true });
cy.get(homePage.searchInput).clear();
cy.get(homePage.searchInput).type(workspaceName);
cy.get(homePage.searchInput).click().type(workspaceName);
// eslint-disable-next-line cypress/no-unnecessary-waiting
cy.wait(2000);
cy.get(homePage.applicationCard).first().trigger("mouseover");
@ -55,14 +57,16 @@ describe("Update Application", () => {
cy.wait(2000);
cy.AppSetupForRename();
cy.get(homePage.applicationName).type(" ");
cy.get(homePage.applicationName).click().type(" ");
cy.get(homePage.toastMessage).should(
"contain",
"Application name can't be empty",
);
cy.AppSetupForRename();
cy.get(homePage.applicationName).type(" " + "{enter}");
cy.get(homePage.applicationName)
.click()
.type(" " + "{enter}");
cy.wait("@updateApplication").should(
"have.nested.property",
"response.body.data.name",
@ -76,7 +80,9 @@ describe("Update Application", () => {
// eslint-disable-next-line cypress/no-unnecessary-waiting
cy.wait(2000);
cy.get(homePage.appMoreIcon).first().click({ force: true });
cy.get(homePage.applicationName).type(veryLongAppName + "{enter}");
cy.get(homePage.applicationName)
.click()
.type(veryLongAppName + "{enter}");
agHelper.GetNClick(homePage.workspaceCompleteSection, 0, true);
cy.wait("@updateApplication").should(
"have.nested.property",
@ -85,7 +91,7 @@ describe("Update Application", () => {
);
// eslint-disable-next-line cypress/no-unnecessary-waiting
cy.wait(2000);
cy.get(homePage.searchInput).type(veryLongAppName);
cy.get(homePage.searchInput).click().type(veryLongAppName);
// eslint-disable-next-line cypress/no-unnecessary-waiting
cy.wait(2000);
cy.get(homePage.applicationCard)

View File

@ -92,11 +92,8 @@ describe(
deployMode.DeployApp();
agHelper.GetNClick(datePickerlocators.input);
agHelper.ClearNType(datePickerlocators.inputHour, "12", 0, true);
agHelper.Sleep(500); // wait for the input to be updated for CI runs
agHelper.ClearNType(datePickerlocators.inputMinute, "58", 0, true);
agHelper.Sleep(500); // wait for the input to be updated for CI runs
agHelper.ClearNType(datePickerlocators.inputSecond, "59", 0, true);
agHelper.Sleep(500); // wait for the input to be updated for CI runs
agHelper.PressEnter();
agHelper
.GetAttribute(datePickerlocators.input, "value")

View File

@ -885,7 +885,11 @@ export class AggregateHelper {
}
public ClearTextField(selector: string, force = false, index = 0) {
this.GetElement(selector).eq(index).focus().clear({ force });
this.GetElement(selector)
.eq(index)
.scrollIntoView({ easing: "linear" })
.click()
.clear({ force });
this.Sleep(500); //for text to clear for CI runs
}
@ -934,6 +938,8 @@ export class AggregateHelper {
element.focus();
}
if (value === "") return element;
return element.wait(100).type(value, {
parseSpecialCharSequences: parseSpecialCharSeq,
delay: delay,