From 63c86d9393272190bc88cf2e5e3a7051067c1565 Mon Sep 17 00:00:00 2001 From: Vijetha-Kaja Date: Mon, 28 Aug 2023 21:53:25 +0530 Subject: [PATCH] test: Cypress - Fix Flaky Tests (#26694) ## Description **Fixed below flaky tests** - Widget_property_navigation_spec.ts - PropertyControl_spec.ts - Fork_Template_To_App_spec.js - Video2_Spec.ts ## Type of change - Flaky test fix ## How Has This Been Tested? - Cypress test runs ## Checklist: ### QA activity: - [ ] Test plan has been approved by relevant developers - [ ] Test plan has been peer reviewed by QA - [ ] Cypress test cases have been added and approved by either SDET or manual QA - [ ] Organized project review call with relevant stakeholders after Round 1/2 of QA - [ ] Added Test Plan Approved label after reveiwing all Cypress test --------- Co-authored-by: Aishwarya UR --- .../Widget_property_navigation_spec.ts | 2 +- .../Templates/Fork_Template_To_App_spec.js | 29 +-- .../ClientSide/Widgets/Camera/Video_Spec.ts | 184 +++++++++--------- .../ClientSide/Widgets/Video/Video2_Spec.ts | 2 +- .../locators/OneClickBindingLocator.ts | 4 +- 5 files changed, 111 insertions(+), 110 deletions(-) diff --git a/app/client/cypress/e2e/Regression/ClientSide/Debugger/Widget_property_navigation_spec.ts b/app/client/cypress/e2e/Regression/ClientSide/Debugger/Widget_property_navigation_spec.ts index 0148c0811d..10a7c3a865 100644 --- a/app/client/cypress/e2e/Regression/ClientSide/Debugger/Widget_property_navigation_spec.ts +++ b/app/client/cypress/e2e/Regression/ClientSide/Debugger/Widget_property_navigation_spec.ts @@ -143,7 +143,7 @@ describe("excludeForAirgap", "Widget property navigation", () => { _.agHelper.Sleep(3000); //for tables to populate for CI runs _.agHelper.GetNClick(OneClickBindingLocator.tableOrSpreadsheetDropdown); _.agHelper.GetNClick( - OneClickBindingLocator.tableOrSpreadsheetDropdownOption(), + OneClickBindingLocator.tableOrSpreadsheetDropdownOption("movies"), ); _.agHelper.GetNClick(OneClickBindingLocator.searchableColumn); _.agHelper.GetNClick( diff --git a/app/client/cypress/e2e/Regression/ClientSide/Templates/Fork_Template_To_App_spec.js b/app/client/cypress/e2e/Regression/ClientSide/Templates/Fork_Template_To_App_spec.js index 9ee00f99a7..9137a564c9 100644 --- a/app/client/cypress/e2e/Regression/ClientSide/Templates/Fork_Template_To_App_spec.js +++ b/app/client/cypress/e2e/Regression/ClientSide/Templates/Fork_Template_To_App_spec.js @@ -1,16 +1,19 @@ import widgetLocators from "../../../../locators/Widgets.json"; import template from "../../../../locators/TemplatesLocators.json"; -import * as _ from "../../../../support/Objects/ObjectsCore"; - -let appId, newWorkspaceName; +import { + agHelper, + assertHelper, + deployMode, + entityExplorer, +} from "../../../../support/Objects/ObjectsCore"; describe("excludeForAirgap", "Fork a template to the current app", () => { afterEach(() => { - _.agHelper.SaveLocalStorageCache(); + agHelper.SaveLocalStorageCache(); }); beforeEach(() => { - _.agHelper.RestoreLocalStorageCache(); + agHelper.RestoreLocalStorageCache(); // Closes template dialog if it is already open - useful for retry cy.get("body").then(($ele) => { if ($ele.find(template.templateDialogBox).length) { @@ -25,7 +28,7 @@ describe("excludeForAirgap", "Fork a template to the current app", () => { it("1. Fork a template to the current app + Bug 17477", () => { cy.wait(3000); - _.entityExplorer.AddNewPage("Add page from template"); + entityExplorer.AddNewPage("Add page from template"); // Commented out below code as fetch template call is not going through when template dialog is closed // cy.wait("@fetchTemplate").should( // "have.nested.property", @@ -38,7 +41,7 @@ describe("excludeForAirgap", "Fork a template to the current app", () => { .scrollIntoView() .wait(500) .click(); - _.agHelper.CheckForErrorToast("INTERNAL_SERVER_ERROR"); + agHelper.CheckForErrorToast("INTERNAL_SERVER_ERROR"); cy.wait(6000); cy.get("body").then(($ele) => { if ($ele.find(widgetLocators.toastAction).length <= 0) { @@ -51,14 +54,14 @@ describe("excludeForAirgap", "Fork a template to the current app", () => { "contain", "template added successfully", ); - _.assertHelper.AssertNetworkStatus("updateLayout"); + assertHelper.AssertNetworkStatus("updateLayout"); // [Bug]: Getting 'Resource not found' error on deploying template #17477 - _.deployMode.DeployApp(); + deployMode.DeployApp(); cy.get(".t--page-switch-tab") .contains("1 Track Applications") .click({ force: true }); cy.wait(4000); - _.deployMode.NavigateBacktoEditor(); + deployMode.NavigateBacktoEditor(); cy.wait(2000); }); @@ -79,7 +82,7 @@ describe("excludeForAirgap", "Fork a template to the current app", () => { cy.wait(5000); cy.get(template.templateDialogBox).should("be.visible"); cy.xpath("//h1[text()='Applicant Tracker-test']").click(); - _.agHelper.CheckForErrorToast("INTERNAL_SERVER_ERROR"); + agHelper.CheckForErrorToast("INTERNAL_SERVER_ERROR"); cy.wait("@getTemplatePages").should( "have.nested.property", "response.body.responseMeta.status", @@ -95,10 +98,10 @@ describe("excludeForAirgap", "Fork a template to the current app", () => { "response.body.responseMeta.status", 200, ); - cy.get(widgetLocators.toastAction, { timeout: 40000 }).should( + cy.get(widgetLocators.toastAction, { timeout: 50000 }).should( "contain", "template added successfully", ); - _.assertHelper.AssertNetworkStatus("updateLayout"); + assertHelper.AssertNetworkStatus("updateLayout"); }); }); diff --git a/app/client/cypress/e2e/Regression/ClientSide/Widgets/Camera/Video_Spec.ts b/app/client/cypress/e2e/Regression/ClientSide/Widgets/Camera/Video_Spec.ts index 2163320cf8..977ff16262 100644 --- a/app/client/cypress/e2e/Regression/ClientSide/Widgets/Camera/Video_Spec.ts +++ b/app/client/cypress/e2e/Regression/ClientSide/Widgets/Camera/Video_Spec.ts @@ -156,107 +156,107 @@ describe("Camera widget - Video test", () => { //Tests to Validate camera to video widget binding //Skipping below tests due to issue - https://github.com/appsmithorg/appsmith/issues/26166 - it.skip("7. Video Recording test - Disabled Camera but Enabled Microphone", () => { - deployMode.NavigateBacktoEditor(); - entityExplorer.SelectEntityByName("Camera1"); - agHelper.GetNClick(propPane._mode("Video"), 1); - entityExplorer.DragNDropWidget(draggableWidgets.VIDEO); - propPane.TypeTextIntoField("URL", "{{Camera1.videoBlobURL}}"); + // it("7. Video Recording test - Disabled Camera but Enabled Microphone", () => { + // deployMode.NavigateBacktoEditor(); + // entityExplorer.SelectEntityByName("Camera1"); + // agHelper.GetNClick(propPane._mode("Video"), 1); + // entityExplorer.DragNDropWidget(draggableWidgets.VIDEO); + // propPane.TypeTextIntoField("URL", "{{Camera1.videoBlobURL}}"); - deployMode.DeployApp(locators._widgetInDeployed(draggableWidgets.CAMERA)); - agHelper.GetNClick(widgetLocators.cameraVideoOnOffBtn); - agHelper.GetNClick(widgetLocators.cameraCaptureBtn); - agHelper.Sleep(3000); - agHelper.GetNClick(widgetLocators.cameraStopRecordingBtn); - agHelper.GetNClick(widgetLocators.cameraSaveBtn); - agHelper.GetNClick(draggableWidgets.VIDEO); - agHelper.Sleep(5000); - agHelper - .GetElement(widgetLocators.cameraVideo) - .eq(1) - .should(($el) => { - const attrValue = $el[0].webkitAudioDecodedByteCount; + // deployMode.DeployApp(locators._widgetInDeployed(draggableWidgets.CAMERA)); + // agHelper.GetNClick(widgetLocators.cameraVideoOnOffBtn); + // agHelper.GetNClick(widgetLocators.cameraCaptureBtn); + // agHelper.Sleep(3000); + // agHelper.GetNClick(widgetLocators.cameraStopRecordingBtn); + // agHelper.GetNClick(widgetLocators.cameraSaveBtn); + // agHelper.GetNClick(draggableWidgets.VIDEO); + // agHelper.Sleep(5000); + // agHelper + // .GetElement(widgetLocators.cameraVideo) + // .eq(1) + // .should(($el) => { + // const attrValue = $el[0].webkitAudioDecodedByteCount; - //Threshold greater than 30000 shows that the audio is playing - expect(attrValue).be.greaterThan(30000); - }); - agHelper - .GetElement(widgetLocators.cameraVideo) - .eq(1) - .should(($el) => { - const attrValue = $el[0].webkitVideoDecodedByteCount; + // //Threshold greater than 30000 shows that the audio is playing + // expect(attrValue).be.greaterThan(30000); + // }); + // agHelper + // .GetElement(widgetLocators.cameraVideo) + // .eq(1) + // .should(($el) => { + // const attrValue = $el[0].webkitVideoDecodedByteCount; - //Threshold less than 10000 shows that the video is not playing - expect(attrValue).be.lessThan(10000); - }); - }); + // //Threshold less than 10000 shows that the video is not playing + // expect(attrValue).be.lessThan(10000); + // }); + // }); - it.skip("8. Video Recording test - Enabled Camera but Disabled Microphone", () => { - entityExplorer.SelectEntityByName("Camera1"); - agHelper.GetNClick(propPane._mode("Video"), 1); - entityExplorer.DragNDropWidget(draggableWidgets.VIDEO); - propPane.TypeTextIntoField("URL", "{{Camera1.videoBlobURL}}"); + // it("8. Video Recording test - Enabled Camera but Disabled Microphone", () => { + // entityExplorer.SelectEntityByName("Camera1"); + // agHelper.GetNClick(propPane._mode("Video"), 1); + // entityExplorer.DragNDropWidget(draggableWidgets.VIDEO); + // propPane.TypeTextIntoField("URL", "{{Camera1.videoBlobURL}}"); - deployMode.DeployApp(locators._widgetInDeployed(draggableWidgets.CAMERA)); - agHelper.GetNClick(widgetLocators.cameraVideoOnOffBtn); - agHelper.GetNClick(widgetLocators.cameraMicrophoneBtn); - agHelper.GetNClick(widgetLocators.cameraCaptureBtn); - agHelper.Sleep(3000); - agHelper.GetNClick(widgetLocators.cameraStopRecordingBtn); - agHelper.GetNClick(widgetLocators.cameraSaveBtn); - agHelper.GetNClick(draggableWidgets.VIDEO); - agHelper.Sleep(5000); - agHelper - .GetElement(widgetLocators.cameraVideo) - .eq(1) - .should(($el) => { - const attrValue = $el[0].webkitAudioDecodedByteCount; + // deployMode.DeployApp(locators._widgetInDeployed(draggableWidgets.CAMERA)); + // agHelper.GetNClick(widgetLocators.cameraVideoOnOffBtn); + // agHelper.GetNClick(widgetLocators.cameraMicrophoneBtn); + // agHelper.GetNClick(widgetLocators.cameraCaptureBtn); + // agHelper.Sleep(3000); + // agHelper.GetNClick(widgetLocators.cameraStopRecordingBtn); + // agHelper.GetNClick(widgetLocators.cameraSaveBtn); + // agHelper.GetNClick(draggableWidgets.VIDEO); + // agHelper.Sleep(5000); + // agHelper + // .GetElement(widgetLocators.cameraVideo) + // .eq(1) + // .should(($el) => { + // const attrValue = $el[0].webkitAudioDecodedByteCount; - //Threshold less than 1000 shows that the audio is not playing - expect(attrValue).be.lessThan(1000); - }); - agHelper - .GetElement(widgetLocators.cameraVideo) - .eq(1) - .should(($el) => { - const attrValue = $el[0].webkitVideoDecodedByteCount; + // //Threshold less than 1000 shows that the audio is not playing + // expect(attrValue).be.lessThan(1000); + // }); + // agHelper + // .GetElement(widgetLocators.cameraVideo) + // .eq(1) + // .should(($el) => { + // const attrValue = $el[0].webkitVideoDecodedByteCount; - //Threshold greater than 30000 shows that the video is playing - expect(attrValue).be.greaterThan(30000); - }); - }); + // //Threshold greater than 30000 shows that the video is playing + // expect(attrValue).be.greaterThan(30000); + // }); + // }); - it.skip("9. Video Recording test - Enabled Camera but Enabled Microphone", () => { - entityExplorer.SelectEntityByName("Camera1"); - agHelper.GetNClick(propPane._mode("Video"), 1); - entityExplorer.DragNDropWidget(draggableWidgets.VIDEO); - propPane.TypeTextIntoField("URL", "{{Camera1.videoBlobURL}}"); + // it("9. Video Recording test - Enabled Camera but Enabled Microphone", () => { + // entityExplorer.SelectEntityByName("Camera1"); + // agHelper.GetNClick(propPane._mode("Video"), 1); + // entityExplorer.DragNDropWidget(draggableWidgets.VIDEO); + // propPane.TypeTextIntoField("URL", "{{Camera1.videoBlobURL}}"); - deployMode.DeployApp(locators._widgetInDeployed(draggableWidgets.CAMERA)); - agHelper.GetNClick(widgetLocators.cameraMicrophoneBtn); - agHelper.GetNClick(widgetLocators.cameraCaptureBtn); - agHelper.Sleep(3000); - agHelper.GetNClick(widgetLocators.cameraStopRecordingBtn); - agHelper.GetNClick(widgetLocators.cameraSaveBtn); - agHelper.GetNClick(draggableWidgets.VIDEO); - agHelper.Sleep(5000); - agHelper - .GetElement(widgetLocators.cameraVideo) - .eq(1) - .should(($el) => { - const attrValue = $el[0].webkitAudioDecodedByteCount; + // deployMode.DeployApp(locators._widgetInDeployed(draggableWidgets.CAMERA)); + // agHelper.GetNClick(widgetLocators.cameraMicrophoneBtn); + // agHelper.GetNClick(widgetLocators.cameraCaptureBtn); + // agHelper.Sleep(3000); + // agHelper.GetNClick(widgetLocators.cameraStopRecordingBtn); + // agHelper.GetNClick(widgetLocators.cameraSaveBtn); + // agHelper.GetNClick(draggableWidgets.VIDEO); + // agHelper.Sleep(5000); + // agHelper + // .GetElement(widgetLocators.cameraVideo) + // .eq(1) + // .should(($el) => { + // const attrValue = $el[0].webkitAudioDecodedByteCount; - //Threshold greater than 30000 shows that the audio is playing - expect(attrValue).be.greaterThan(30000); - }); - agHelper - .GetElement(widgetLocators.cameraVideo) - .eq(1) - .should(($el) => { - const attrValue = $el[0].webkitVideoDecodedByteCount; + // //Threshold greater than 30000 shows that the audio is playing + // expect(attrValue).be.greaterThan(30000); + // }); + // agHelper + // .GetElement(widgetLocators.cameraVideo) + // .eq(1) + // .should(($el) => { + // const attrValue = $el[0].webkitVideoDecodedByteCount; - //Threshold greater than 30000 shows that the video is playing - expect(attrValue).be.greaterThan(30000); - }); - }); + // //Threshold greater than 30000 shows that the video is playing + // expect(attrValue).be.greaterThan(30000); + // }); + // }); }); diff --git a/app/client/cypress/e2e/Regression/ClientSide/Widgets/Video/Video2_Spec.ts b/app/client/cypress/e2e/Regression/ClientSide/Widgets/Video/Video2_Spec.ts index 54799f8ed1..cd97165b97 100644 --- a/app/client/cypress/e2e/Regression/ClientSide/Widgets/Video/Video2_Spec.ts +++ b/app/client/cypress/e2e/Regression/ClientSide/Widgets/Video/Video2_Spec.ts @@ -186,7 +186,7 @@ describe("Video widget tests", function () { deployMode.NavigateBacktoEditor(); entityExplorer.SelectEntityByName("Video1", "Widgets"); propPane.MoveToTab("Style"); - propPane.SelectColorFromColorPicker("backgroundcolor", 14); + propPane.SelectColorFromColorPicker("backgroundcolor", 9); agHelper.ContainsNClick("Medium"); propPane.EnterJSContext("Border radius", "1.5rem"); deployMode.DeployApp(locators._widgetInDeployed(draggableWidgets.VIDEO)); diff --git a/app/client/cypress/locators/OneClickBindingLocator.ts b/app/client/cypress/locators/OneClickBindingLocator.ts index 781a8e4bb9..44bbb23138 100644 --- a/app/client/cypress/locators/OneClickBindingLocator.ts +++ b/app/client/cypress/locators/OneClickBindingLocator.ts @@ -27,9 +27,7 @@ export default { tableOrSpreadsheetDropdown: '[data-testid="t--one-click-binding-table-selector"] .rc-select-selector', tableOrSpreadsheetDropdownOption: (table?: string) => - `[data-testId='t--one-click-binding-table-selector--table']${ - table ? `:contains(${table})` : "" - }`, + `//div[@data-testId='t--one-click-binding-table-selector--table']//div[text()='${table}']`, tableOrSpreadsheetSelectedOption: (table?: string) => `[data-testid="t--one-click-binding-table-selector"] .rc-select-selection-item${ table ? `:contains(${table})` : ""