From c6be140eb22c850b0c359456ccbd4e84a65d8675 Mon Sep 17 00:00:00 2001 From: Aishwarya-U-R <91450662+Aishwarya-U-R@users.noreply.github.com> Date: Wed, 26 Jul 2023 14:26:36 +0530 Subject: [PATCH] test: Cypress | Flaky fixes (#25700) ## Description - This PR does the below: - Improve HoverElement() - Button_onClickAction_spec.js - CI flaky fix - ListV2/Childwigets/List_FilePicker_spec.js - Datasources/RestApiOAuth2Validation_spec.js - ApiPage - EnterURL() improved - for the entered url to settle #### Type of change - Script fix (non-breaking change which fixes an issue) ## Testing > #### How Has This Been Tested? - [X] Cypress - ## Checklist: #### QA activity: - [X] Added `Test Plan Approved` label after Cypress tests were reviewed --- .../Button/Button_onClickAction_spec.js | 18 +++++------------- .../ListV2/Childwigets/List_FilePicker_spec.js | 6 ++++-- .../RestApiOAuth2Validation_spec.js | 15 +++++---------- app/client/cypress/limited-tests.txt | 3 +-- .../cypress/support/Pages/AggregateHelper.ts | 17 +++++++++++++---- app/client/cypress/support/Pages/ApiPage.ts | 5 ++--- 6 files changed, 30 insertions(+), 34 deletions(-) diff --git a/app/client/cypress/e2e/Regression/ClientSide/Widgets/Button/Button_onClickAction_spec.js b/app/client/cypress/e2e/Regression/ClientSide/Widgets/Button/Button_onClickAction_spec.js index 0d92b2f7cb..7c425db1f8 100644 --- a/app/client/cypress/e2e/Regression/ClientSide/Widgets/Button/Button_onClickAction_spec.js +++ b/app/client/cypress/e2e/Regression/ClientSide/Widgets/Button/Button_onClickAction_spec.js @@ -47,19 +47,11 @@ describe("Button Widget Functionality", function () { // Filling the messages for success/failure in the onClickAction of the button widget. cy.onClickActions("Success", "Error", "Execute a query", "buttonApi.run"); - _.deployMode.DeployApp(); - cy.get("body").then(($ele) => { - if ($ele.find(widgetsPage.apiCallToast).length <= 0) { - cy.get(publishPage.buttonWidget).click(); - } - }); - // Clicking the button to verify the success message - cy.get(publishPage.buttonWidget).click(); - cy.get("body").then(($ele) => { - if ($ele.find(widgetsPage.apiCallToast).length <= 0) { - cy.get(publishPage.buttonWidget).click(); - } - }); + _.deployMode.DeployApp( + _.locators._widgetInDeployed(_.draggableWidgets.BUTTON), + ); + _.agHelper.Sleep(); + _.agHelper.ClickButton("Submit"); cy.get(widgetsPage.apiCallToast).should("have.text", "Success"); }); diff --git a/app/client/cypress/e2e/Regression/ClientSide/Widgets/ListV2/Childwigets/List_FilePicker_spec.js b/app/client/cypress/e2e/Regression/ClientSide/Widgets/ListV2/Childwigets/List_FilePicker_spec.js index 1a9772fea5..74ff4254fd 100644 --- a/app/client/cypress/e2e/Regression/ClientSide/Widgets/ListV2/Childwigets/List_FilePicker_spec.js +++ b/app/client/cypress/e2e/Regression/ClientSide/Widgets/ListV2/Childwigets/List_FilePicker_spec.js @@ -57,13 +57,15 @@ describe(" File Picker Widget", function () { // Test for isValid === True cy.dragAndDropToWidget("textwidget", "listwidgetv2", { x: 550, - y: 50, + y: 100, }); - cy.RenameWidgetFromPropertyPane("textwidget", "Text1", "FilePicker_Widget"); + propPane.RenameWidget("Text1", "FilePicker_Widget"); + propPane.UpdatePropertyFieldValue( "Text", "{{currentView.FilePicker1.isDirty}}_{{currentView.FilePicker1.isValid}}_{{currentView.FilePicker1.files[0]?.name}}", + false, ); cy.get( `${widgetSelector("FilePicker_Widget")} ${commonlocators.bodyTextStyle}`, diff --git a/app/client/cypress/e2e/Sanity/Datasources/RestApiOAuth2Validation_spec.js b/app/client/cypress/e2e/Sanity/Datasources/RestApiOAuth2Validation_spec.js index 9f96ed652c..331f23c580 100644 --- a/app/client/cypress/e2e/Sanity/Datasources/RestApiOAuth2Validation_spec.js +++ b/app/client/cypress/e2e/Sanity/Datasources/RestApiOAuth2Validation_spec.js @@ -12,10 +12,8 @@ describe("Datasource form OAuth2 client credentials related tests", function () it("1. Create an API with app url and save as Datasource for Client Credentials test", function () { apiPage.CreateAndFillApi(testdata.appUrl, "TestOAuth"); agHelper.GetNClick(apiPage._saveAsDS); - // agHelper.ValidateToastMessage("datasource created"); //verifying there is no error toast, Bug 14566 - }); - it("2. Add Oauth details to datasource and save", function () { + // Add Oauth details to datasource and save cy.get(datasource.saveBtn).should("not.be.disabled"); dataSources.AddOAuth2AuthorizationCodeDetails( testdata.accessTokenUrl, @@ -27,7 +25,7 @@ describe("Datasource form OAuth2 client credentials related tests", function () // since we are moving to different, it will show unsaved changes dialog // save datasource and then proceed dataSources.SaveDatasource(); - + agHelper.ValidateToastMessage("datasource created"); //verifying there is no error toast, Bug 14566 entityExplorer.SelectEntityByName("TestOAuth", "Queries/JS"); agHelper.ActionContextMenuWithInPane({ action: "Delete", @@ -35,13 +33,10 @@ describe("Datasource form OAuth2 client credentials related tests", function () }); }); - it("3. Create an API with app url and save as Datasource for Authorization code details test", function () { + it("2. Create an API with app url and save as Datasource for Authorization code details test", function () { apiPage.CreateAndFillApi(testdata.appUrl, "TestOAuth"); agHelper.GetNClick(apiPage._saveAsDS); - // agHelper.ValidateToastMessage("datasource created"); //verifying there is no error toast, Bug 14566 - }); - - it("4. Add Oauth details to datasource and save", function () { + //Add Oauth details to datasource and save cy.get(datasource.saveBtn).should("not.be.disabled"); dataSources.AddOAuth2AuthorizationCodeDetails( testdata.accessTokenUrl, @@ -51,7 +46,7 @@ describe("Datasource form OAuth2 client credentials related tests", function () ); }); - it("5. Validate save and Authorise", function () { + it("3. Validate save and Authorise", function () { cy.get(datasource.saveAndAuthorize).click(); cy.contains("#login-submit", "Login"); cy.url().should("include", "oauth.mocklab.io/oauth/authorize"); diff --git a/app/client/cypress/limited-tests.txt b/app/client/cypress/limited-tests.txt index ce8d36c1b9..9950b1a335 100644 --- a/app/client/cypress/limited-tests.txt +++ b/app/client/cypress/limited-tests.txt @@ -3,5 +3,4 @@ # To run only limited tests - give the spec names in below format: cypress/e2e/Regression/ClientSide/Widgets/Dropdown/Dropdown_onOptionChange_spec.js -cypress/e2e/Regression/ClientSide/Widgets/Button/Button_onClickAction_spec.js -cypress/e2e/Regression/ClientSide/BugTests/DatasourceSchema_spec.ts +#cypress/e2e/Regression/ClientSide/BugTests/DatasourceSchema_spec.ts diff --git a/app/client/cypress/support/Pages/AggregateHelper.ts b/app/client/cypress/support/Pages/AggregateHelper.ts index 85e9694df5..01882e09af 100644 --- a/app/client/cypress/support/Pages/AggregateHelper.ts +++ b/app/client/cypress/support/Pages/AggregateHelper.ts @@ -674,11 +674,20 @@ export class AggregateHelper extends ReusableHelper { .wait(waitTimeInterval); } - public HoverElement(selector: string, index = 0, waitTimeInterval = 100) { - return ( - this.ScrollIntoView(selector, index) + public HoverElement( + selector: string, + index = 0, + realTouch = true, + waitTimeInterval = 100, + ) { + let chain = this.ScrollIntoView(selector, index); + if (realTouch) { + chain = chain .realTouch({ position: "center" }) - .realHover({ pointer: "mouse" }) + .realHover({ pointer: "mouse" }); + } + return ( + chain //.trigger("mousemove", { eventConstructor: "MouseEvent" }) .wait(waitTimeInterval) ); diff --git a/app/client/cypress/support/Pages/ApiPage.ts b/app/client/cypress/support/Pages/ApiPage.ts index 49eb9546da..2faebc74b0 100644 --- a/app/client/cypress/support/Pages/ApiPage.ts +++ b/app/client/cypress/support/Pages/ApiPage.ts @@ -115,7 +115,7 @@ export class ApiPage { ) { this.CreateApi(apiName, apiVerb, aftDSSaved); this.EnterURL(url); - //this.agHelper.Sleep(2000);// Added because api name edit takes some time to reflect in api sidebar after the call passes. + this.agHelper.Sleep(2000); // Added because api name edit takes some time to reflect in api sidebar after the call passes. this.AssertRunButtonDisability(); if (queryTimeout != 10000) this.SetAPITimeout(queryTimeout); } @@ -130,8 +130,7 @@ export class ApiPage { directInput: true, inputFieldName: "", }); - this.agHelper.AssertAutoSave(); - + this.agHelper.Sleep(); if (evaluatedValue) { this.agHelper.VerifyEvaluatedValue(evaluatedValue); }