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
This commit is contained in:
Aishwarya-U-R 2023-07-26 14:26:36 +05:30 committed by GitHub
parent 93060477cc
commit c6be140eb2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 30 additions and 34 deletions

View File

@ -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");
});

View File

@ -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}`,

View File

@ -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");

View File

@ -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

View File

@ -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)
);

View File

@ -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);
}