From 20504beae4721aabcb65c5233c66848fddeafa3b Mon Sep 17 00:00:00 2001 From: Aishwarya-U-R <91450662+Aishwarya-U-R@users.noreply.github.com> Date: Wed, 23 Nov 2022 16:02:35 +0530 Subject: [PATCH] test: Script updates for flaky tests (#18349) * flaky fix * remove only * NumberSlier & BasicLint fix * jsform hidden field spec fix * Theme_MultiSelectWidget_spec.js fix * Bug 16702 spec fix --- .../ClientSideTests/BugTests/Bug16702_Spec.ts | 2 + .../ClientSideTests/Linting/BasicLint_spec.ts | 3 +- .../Theme_MultiSelectWidget_spec.js | 8 +-- .../JSONForm/JSONForm_HiddenFields_spec.js | 27 +++++----- .../Widgets/Sliders/NumberSlider_spec.ts | 5 +- .../Widgets/TableV2/Add_new_row_spec.js | 50 ++++++++----------- .../cypress/support/Pages/AggregateHelper.ts | 13 +++-- .../cypress/support/Pages/PropertyPane.ts | 4 +- 8 files changed, 57 insertions(+), 55 deletions(-) diff --git a/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/BugTests/Bug16702_Spec.ts b/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/BugTests/Bug16702_Spec.ts index 038551c5a0..146b0353d9 100644 --- a/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/BugTests/Bug16702_Spec.ts +++ b/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/BugTests/Bug16702_Spec.ts @@ -49,6 +49,7 @@ describe("Binding Expressions should not be truncated in Url and path extraction // }) //.trigger("mouseover") .dblclick() + .dblclick() .type("{{JSObject1."); agHelper.GetNAssertElementText(locator._hints, "offsetValue", "have.text", 1); agHelper.Sleep(); @@ -65,6 +66,7 @@ describe("Binding Expressions should not be truncated in Url and path extraction .contains("__limit__") //.trigger("mouseover") .dblclick() + .dblclick() .type("{{JSObject1."); agHelper.GetNClickByContains(locator._hints, "limitValue"); agHelper.Sleep(2000); diff --git a/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/Linting/BasicLint_spec.ts b/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/Linting/BasicLint_spec.ts index e679e96f4e..1c9c44820c 100644 --- a/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/Linting/BasicLint_spec.ts +++ b/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/Linting/BasicLint_spec.ts @@ -271,9 +271,10 @@ describe("Linting", () => { apiPage.CreateAndFillApi("https://jsonplaceholder.typicode.com/"); createMySQLDatasourceQuery(); - + agHelper.RefreshPage();//Since this seems failing a bit clickButtonAndAssertLintError(false); }); + it("8. Doesn't show lint errors for supported web apis", () => { const JS_OBJECT_WITH_WEB_API = `export default { myFun1: () => { diff --git a/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/ThemingTests/Theme_MultiSelectWidget_spec.js b/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/ThemingTests/Theme_MultiSelectWidget_spec.js index f7551b2c28..21a32ceb21 100644 --- a/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/ThemingTests/Theme_MultiSelectWidget_spec.js +++ b/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/ThemingTests/Theme_MultiSelectWidget_spec.js @@ -10,7 +10,7 @@ let propPane = ObjectsRegistry.PropertyPane, ee = ObjectsRegistry.EntityExplorer; describe("Theme validation usecase for multi-select widget", function() { - it("Drag and drop multi-select widget and validate Default font and list of font validation + Bug 15007", function() { + it("1. Drag and drop multi-select widget and validate Default font and list of font validation + Bug 15007", function() { //cy.reload(); // To remove the rename tooltip ee.DragDropWidgetNVerify("multiselectwidgetv2", 300, 80); cy.get(themelocator.canvas).click({ force: true }); @@ -96,7 +96,7 @@ describe("Theme validation usecase for multi-select widget", function() { cy.contains("Color").click({ force: true }); }); - it.skip("Publish the App and validate Font across the app + Bug 15007", function() { + it.skip("2. Publish the App and validate Font across the app + Bug 15007", function() { //Skipping due to mentioned bug cy.PublishtheApp(); cy.get(".rc-select-selection-item > .rc-select-selection-item-content") @@ -118,7 +118,7 @@ describe("Theme validation usecase for multi-select widget", function() { cy.goToEditFromPublish(); }); - it("Validate current theme feature", function() { + it("3. Validate current theme feature", function() { cy.get("#canvas-selection-0").click({ force: true }); //Change the Theme cy.get(commonlocators.changeThemeBtn).click({ force: true }); @@ -138,7 +138,7 @@ describe("Theme validation usecase for multi-select widget", function() { }); }); - it("Publish the App and validate change of Theme across the app in publish mode", function() { + it("4. Publish the App and validate change of Theme across the app in publish mode", function() { cy.PublishtheApp(); cy.get(".rc-select-selection-item > .rc-select-selection-item-content") .first() diff --git a/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/Widgets/JSONForm/JSONForm_HiddenFields_spec.js b/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/Widgets/JSONForm/JSONForm_HiddenFields_spec.js index 1be037bda0..5c02495515 100644 --- a/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/Widgets/JSONForm/JSONForm_HiddenFields_spec.js +++ b/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/Widgets/JSONForm/JSONForm_HiddenFields_spec.js @@ -83,7 +83,7 @@ describe("JSON Form Hidden fields", () => { cy.testJsontext("text", "{{JSON.stringify(JSONForm1.formData)}}"); }); - it("can hide Array Field", () => { + it("1. can hide Array Field", () => { cy.openPropertyPane("jsonformwidget"); cy.openFieldConfiguration("education"); hideAndVerifyProperties("education", [ @@ -94,7 +94,7 @@ describe("JSON Form Hidden fields", () => { ]); }); - it("can hide Array Field's inner fields", () => { + it("2. can hide Array Field's inner fields", () => { cy.openPropertyPane("jsonformwidget"); cy.openFieldConfiguration("education"); cy.openFieldConfiguration("__array_item__"); @@ -105,7 +105,7 @@ describe("JSON Form Hidden fields", () => { }); }); - it("can hide Checkbox Field", () => { + it("3. can hide Checkbox Field", () => { // Add new custom field addCustomField("Checkbox"); @@ -114,7 +114,7 @@ describe("JSON Form Hidden fields", () => { removeCustomField(); }); - it("can hide Currency Field", () => { + it("4. can hide Currency Field", () => { const defaultValue = 1000; // Add new custom field addCustomField("Currency Input"); @@ -123,28 +123,28 @@ describe("JSON Form Hidden fields", () => { removeCustomField(); }); - it("can hide Date Field", () => { + it("5. can hide Date Field", () => { cy.openPropertyPane("jsonformwidget"); cy.openFieldConfiguration("dob"); hideAndVerifyProperties("dob", "10/12/1992"); }); - it("can hide Input Field", () => { + it("6. can hide Input Field", () => { cy.openPropertyPane("jsonformwidget"); cy.openFieldConfiguration("name"); hideAndVerifyProperties("name", "John"); }); - it("can hide Multiselect Field", () => { + it("7. can hide Multiselect Field", () => { cy.openPropertyPane("jsonformwidget"); cy.openFieldConfiguration("hobbies"); hideAndVerifyProperties("hobbies", ["travelling", "swimming"]); }); - it("can hide Object Field", () => { + it("8. can hide Object Field", () => { cy.openPropertyPane("jsonformwidget"); cy.openFieldConfiguration("address"); @@ -154,7 +154,7 @@ describe("JSON Form Hidden fields", () => { }); }); - it("can hide Phone Number Input Field", () => { + it("9. can hide Phone Number Input Field", () => { const defaultValue = "1000"; // Add new custom field addCustomField("Phone Number Input"); @@ -166,7 +166,7 @@ describe("JSON Form Hidden fields", () => { removeCustomField(); }); - it("can hide Radio Group Field", () => { + it("10. can hide Radio Group Field", () => { const defaultValue = "Y"; // Add new custom field addCustomField("Phone Number Input"); @@ -178,7 +178,7 @@ describe("JSON Form Hidden fields", () => { removeCustomField(); }); - it("can hide Select Field", () => { + it("11. can hide Select Field", () => { const defaultValue = "BLUE"; // Add new custom field addCustomField(/^Select/); @@ -190,7 +190,7 @@ describe("JSON Form Hidden fields", () => { removeCustomField(); }); - it("can hide Switch Field", () => { + it("12. can hide Switch Field", () => { // Add new custom field addCustomField("Switch"); @@ -199,7 +199,7 @@ describe("JSON Form Hidden fields", () => { removeCustomField(); }); - it("hides fields on first load", () => { + it("13. hides fields on first load", () => { cy.openPropertyPane("jsonformwidget"); // hide education field @@ -214,6 +214,7 @@ describe("JSON Form Hidden fields", () => { // publish the app cy.PublishtheApp(); + cy.wait(1000); // Check if name is hidden cy.get(`${fieldPrefix}-name`).should("not.exist"); diff --git a/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/Widgets/Sliders/NumberSlider_spec.ts b/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/Widgets/Sliders/NumberSlider_spec.ts index a4a30f6117..abc7993d80 100644 --- a/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/Widgets/Sliders/NumberSlider_spec.ts +++ b/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/Widgets/Sliders/NumberSlider_spec.ts @@ -121,6 +121,8 @@ describe("Number Slider spec", () => { .focus() .type("{rightArrow}"); + agHelper.Sleep(2000); //for the changes to reflect in text widget + // Assert the Text widget has value 20 agHelper.GetText(getWidgetSelector(WIDGET.TEXT)).then(($label) => { expect($label).to.eq("20"); @@ -133,8 +135,7 @@ describe("Number Slider spec", () => { .type("{leftArrow}") .type("{leftArrow}"); - agHelper.Sleep(200); - + agHelper.Sleep(2000); //for the changes to reflect in text widget // Assert the Text widget has value 0 agHelper.GetText(getWidgetSelector(WIDGET.TEXT)).then(($label) => { expect($label).to.eq("0"); diff --git a/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/Widgets/TableV2/Add_new_row_spec.js b/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/Widgets/TableV2/Add_new_row_spec.js index abc1712f09..d52ae3ebae 100644 --- a/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/Widgets/TableV2/Add_new_row_spec.js +++ b/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/Widgets/TableV2/Add_new_row_spec.js @@ -16,7 +16,7 @@ describe("Table widget Add new row feature's", () => { cy.addDsl(dsl); }); - it("should test that allow Add new row property is present", () => { + it("1.1. should test that allow Add new row property is present", () => { cy.openPropertyPane("tablewidgetv2"); cy.get(".t--property-control-allowaddingarow").should("exist"); cy.get( @@ -24,7 +24,7 @@ describe("Table widget Add new row feature's", () => { ).should("exist"); }); - it("should test that Add new row link appears on the UI when the allow add new row property is enabled", () => { + it("1.2. should test that Add new row link appears on the UI when the allow add new row property is enabled", () => { cy.get(".t--add-new-row").should("not.exist"); propPane.ToggleOnOrOff("Allow adding a row", "On"); cy.get(".t--add-new-row").should("exist"); @@ -32,7 +32,7 @@ describe("Table widget Add new row feature's", () => { cy.get(".t--add-new-row").should("not.exist"); }); - it("should test that onSave, onDiscard and default row are showing up only when the allow add new property is enabled", () => { + it("1.3. should test that onSave, onDiscard and default row are showing up only when the allow add new property is enabled", () => { cy.get(".t--property-control-onsave").should("not.exist"); cy.get(".t--property-control-ondiscard").should("not.exist"); cy.get(".t--property-control-defaultvalues").should("not.exist"); @@ -42,14 +42,14 @@ describe("Table widget Add new row feature's", () => { cy.get(".t--property-control-defaultvalues").should("exist"); }); - it("should test that add new row link is disabled during the inline editing flow", () => { + it("1.4. should test that add new row link is disabled during the inline editing flow", () => { cy.get(".t--add-new-row.disabled").should("not.exist"); cy.makeColumnEditable("step"); cy.editTableCell(0, 0); cy.get(".t--add-new-row.disabled").should("exist"); }); - it("should test that clicking on add new row link adds an empty row at the top of the table", () => { + it("1.5. should test that clicking on add new row link adds an empty row at the top of the table", () => { cy.openPropertyPane("tablewidgetv2"); cy.get(".tableWrap .new-row").should("not.exist"); cy.get(".t--add-new-row").click(); @@ -57,7 +57,7 @@ describe("Table widget Add new row feature's", () => { cy.get(".t--discard-new-row").click({ force: true }); }); - it("should test that new row is getting populated with the default row property value", () => { + it("1.6. should test that new row is getting populated with the default row property value", () => { cy.updateCodeInput( ".t--property-control-defaultvalues", "{{{step: 'newStepCell'}}}", @@ -70,7 +70,7 @@ describe("Table widget Add new row feature's", () => { cy.get(".t--discard-new-row").click({ force: true }); }); - it("should test that inline editing, row selection, pagination, search, filters are actions cannot be performed while in add new row feature", () => { + it("1.7. should test that inline editing, row selection, pagination, search, filters are actions cannot be performed while in add new row feature", () => { cy.get(".t--widget-tablewidgetv2 .t--search-input").should("exist"); cy.get(".t--widget-tablewidgetv2 .t--table-filter-toggle-btn").should( "exist", @@ -111,7 +111,7 @@ describe("Table widget Add new row feature's", () => { cy.get(".t--discard-new-row").click({ force: true }); }); - it("should test that only editable column cells are in editmode in the new row", () => { + it("1.8. should test that only editable column cells are in editmode in the new row", () => { cy.get(".t--add-new-row").click(); cy.get( `[data-colindex=0][data-rowindex=0] .t--inlined-cell-editor`, @@ -136,7 +136,7 @@ describe("Table widget Add new row feature's", () => { ).should("not.exist"); }); - it("should test that newRow property holds the entered data", () => { + it("1.9. should test that newRow property holds the entered data", () => { cy.makeColumnEditable("step"); cy.makeColumnEditable("task"); cy.enterTableCellValue(0, 0, "22"); @@ -150,7 +150,7 @@ describe("Table widget Add new row feature's", () => { ); }); - it("should test that non data (iconBitton, button, menubutton) column cells are not showing up", () => { + it("1.10. should test that non data (iconBitton, button, menubutton) column cells are not showing up", () => { cy.openPropertyPane("tablewidgetv2"); cy.editColumn("step"); ["Button", "Menu Button", "Icon Button"].forEach((columnType) => { @@ -174,7 +174,7 @@ describe("Table widget Add new row feature's", () => { cy.addDsl(dsl); }); - it("should test that validation is working for a new row cell", () => { + it("2.1. should test that validation is working for a new row cell", () => { cy.openPropertyPane("tablewidgetv2"); propPane.ToggleOnOrOff("Allow adding a row", "On"); cy.get(".t--add-new-row").click(); @@ -262,7 +262,7 @@ describe("Table widget Add new row feature's", () => { cy.get(".t--discard-new-row").click({ force: true }); }); - it("should test that validation variable isNewRow is working", () => { + it("2.2. should test that validation variable isNewRow is working", () => { propPane.UpdatePropertyFieldValue( "Valid", "{{isNewRow ? (editedValue === 1) : (editedValue === 2)}}", @@ -290,7 +290,7 @@ describe("Table widget Add new row feature's", () => { cy.get(".t--discard-new-row").click({ force: true }); }); - it("should test that validation is working for more than one add new row cell at a time", () => { + it("2.3. should test that validation is working for more than one add new row cell at a time", () => { propPane.UpdatePropertyFieldValue("Valid", "{{editedValue === 1}}"); cy.get(".t--property-pane-back-btn").click(); cy.wait(500); @@ -306,7 +306,7 @@ describe("Table widget Add new row feature's", () => { cy.get(`.t--inlined-cell-editor-has-error`).should("have.length", 2); }); - it("should test that validation error message only appears when a cell is in focus", () => { + it("2.4. should test that validation error message only appears when a cell is in focus", () => { cy.get(".error-tooltip .bp3-popover-content").should("not.exist"); cy.get(`[data-colindex=1][data-rowindex=0] input`).focus(); cy.get(".error-tooltip .bp3-popover-content").should("have.length", 1); @@ -316,7 +316,7 @@ describe("Table widget Add new row feature's", () => { cy.get(".error-tooltip .bp3-popover-content").should("have.length", 1); }); - it("should test that save button is disabled when there is an error", () => { + it("2.5. should test that save button is disabled when there is an error", () => { cy.get(".t--save-new-row").should("be.disabled"); cy.get(`.t--inlined-cell-editor-has-error`).should("have.length", 2); cy.enterTableCellValue(0, 0, "1"); @@ -335,7 +335,7 @@ describe("Table widget Add new row feature's", () => { cy.addDsl(dsl); }); - it("should test that discard button is undoing the add new feature", () => { + it("3.1. should test that discard button is undoing the add new feature", () => { cy.openPropertyPane("tablewidgetv2"); propPane.ToggleOnOrOff("Allow adding a row", "On"); cy.get(".tableWrap .new-row").should("not.exist"); @@ -344,7 +344,7 @@ describe("Table widget Add new row feature's", () => { cy.get(".t--discard-new-row").click({ force: true }); }); - it("should test that discard events is triggered when user clicks on the discard button", () => { + it("3.2. should test that discard events is triggered when user clicks on the discard button", () => { cy.get( ".t--property-control-ondiscard .t--open-dropdown-Select-Action", ).click({ force: true }); @@ -354,16 +354,11 @@ describe("Table widget Add new row feature's", () => { cy.get(".tableWrap .new-row").should("exist"); cy.get(".t--discard-new-row").click({ force: true }); cy.get(widgetsPage.toastAction).should("be.visible"); - cy.get(widgetsPage.toastActionText) - .last() - .invoke("text") - .then((text) => { - expect(text).to.equal("discarded!!"); - }); + agHelper.AssertContains("discarded!!"); cy.get(".tableWrap .new-row").should("not.exist"); }); - it("should test that save event is triggered when user clicks on the save button", () => { + it("3.3. should test that save event is triggered when user clicks on the save button", () => { cy.get( ".t--property-control-onsave .t--open-dropdown-Select-Action", ).click({ force: true }); @@ -373,12 +368,7 @@ describe("Table widget Add new row feature's", () => { cy.get(".tableWrap .new-row").should("exist"); cy.get(".t--save-new-row").click({ force: true }); cy.get(widgetsPage.toastAction).should("be.visible"); - cy.get(widgetsPage.toastActionText) - .last() - .invoke("text") - .then((text) => { - expect(text).to.equal("saved!!"); - }); + agHelper.AssertContains("saved!!"); cy.get(".tableWrap .new-row").should("not.exist"); }); }); diff --git a/app/client/cypress/support/Pages/AggregateHelper.ts b/app/client/cypress/support/Pages/AggregateHelper.ts index 2167f12db8..dfe356c27a 100644 --- a/app/client/cypress/support/Pages/AggregateHelper.ts +++ b/app/client/cypress/support/Pages/AggregateHelper.ts @@ -426,9 +426,14 @@ export class AggregateHelper { .invoke("text"); } - public EnterActionValue(actionName: string, value: string, paste = true) { + public EnterActionValue( + actionName: string, + value: string, + paste = true, + index = 0, + ) { cy.xpath(this.locator._actionTextArea(actionName)) - .first() + .eq(index) .scrollIntoView() .focus() .type("{uparrow}", { force: true }) @@ -437,7 +442,7 @@ export class AggregateHelper { if ($cm.contents != "") { cy.log("The field is not empty"); cy.xpath(this.locator._actionTextArea(actionName)) - .first() + .eq(index) .scrollIntoView() .click({ force: true }) .focused() @@ -447,7 +452,7 @@ export class AggregateHelper { } this.Sleep(); cy.xpath(this.locator._actionTextArea(actionName)) - .first() + .eq(index) .scrollIntoView() .then((el: any) => { if (paste) { diff --git a/app/client/cypress/support/Pages/PropertyPane.ts b/app/client/cypress/support/Pages/PropertyPane.ts index 6a354a4550..1c91d2612d 100644 --- a/app/client/cypress/support/Pages/PropertyPane.ts +++ b/app/client/cypress/support/Pages/PropertyPane.ts @@ -95,7 +95,9 @@ export class PropertyPane { this.agHelper.GetNClick(this._colorPickerV2Popover); this.agHelper.GetNClick(this._colorPickerV2Color, colorIndex); } else { - this.agHelper.GetElement(this._colorInput(type)).clear(); + this.agHelper.GetElement(this._colorInput(type)).clear().wait(200); + this.agHelper.TypeText(this._colorInput(type), colorIndex); + this.agHelper.GetElement(this._colorInput(type)).clear().wait(200); this.agHelper.TypeText(this._colorInput(type), colorIndex); //this.agHelper.UpdateInput(this._colorInputField(type), colorIndex);//not working! }