Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: cypress flakiness due to focus cypress function #33106

Merged
merged 7 commits into from
May 2, 2024
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 @@ -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);
AmanAgarwal041 marked this conversation as resolved.
Show resolved Hide resolved
// 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",
Expand All @@ -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");
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
8 changes: 7 additions & 1 deletion app/client/cypress/support/Pages/AggregateHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -934,6 +938,8 @@ export class AggregateHelper {
element.focus();
}

if (value === "") return element;

return element.wait(100).type(value, {
parseSpecialCharSequences: parseSpecialCharSeq,
delay: delay,
Expand Down
Loading