From fd7219706fc03dc0ee595532b58162afb70e1864 Mon Sep 17 00:00:00 2001 From: NandanAnantharamu <67676905+NandanAnantharamu@users.noreply.github.com> Date: Sat, 18 Jan 2025 20:26:42 +0530 Subject: [PATCH] test: adding test for page functionality (#38538) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit /ok-to-test tags="@tag.Sanity" > [!TIP] > 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉 > Workflow run: > Commit: 88c823df3032a7fdf492e3a086d8be9daf03b062 > Cypress dashboard. > Tags: `@tag.Sanity` > Spec: >
Mon, 13 Jan 2025 11:37:45 UTC ## Summary by CodeRabbit - **New Features** - Added comprehensive end-to-end tests for page actions functionality. - Introduced new test coverage for page management operations like renaming, cloning, hiding, and setting home pages. - **Tests** - Created Cypress tests to verify page actions under different scenarios. - Updated test specifications to focus on partial import/export functionality. - **Improvements** - Enhanced modal opening methods with dynamic entity name support. - Added home icon locator for improved test reliability. --------- Co-authored-by: “NandanAnantharamu” <“nandan@thinkify.io”> --- .../PartialImportExport/PageActions_spec.ts | 139 ++++++++++++++++++ .../cypress/support/Objects/CommonLocators.ts | 1 + .../support/Pages/PartialImportExport.ts | 9 +- 3 files changed, 144 insertions(+), 5 deletions(-) create mode 100644 app/client/cypress/e2e/Regression/ClientSide/PartialImportExport/PageActions_spec.ts diff --git a/app/client/cypress/e2e/Regression/ClientSide/PartialImportExport/PageActions_spec.ts b/app/client/cypress/e2e/Regression/ClientSide/PartialImportExport/PageActions_spec.ts new file mode 100644 index 0000000000..1943783c3e --- /dev/null +++ b/app/client/cypress/e2e/Regression/ClientSide/PartialImportExport/PageActions_spec.ts @@ -0,0 +1,139 @@ +import EditorNavigation, { + EntityType, + PageLeftPane, +} from "../../../../support/Pages/EditorNavigation"; +import { + agHelper, + draggableWidgets, + entityExplorer, + entityItems, + homePage, + locators, + partialImportExport, + propPane, +} from "../../../../support/Objects/ObjectsCore"; +import PageList from "../../../../support/Pages/PageList"; + +describe("Check Page Actions Menu", {}, function () { + it("1. Verify Page Actions when a page is selected", function () { + homePage.RenameApplication("PageActions"); + PageList.AddNewPage("New blank page"); + entityExplorer.DragDropWidgetNVerify(draggableWidgets.TEXT, 500, 100); + PageList.ShowList(); + agHelper.GetNClick(entityExplorer._contextMenu("Page2"), 0, true); + agHelper.GetNClick(locators._contextMenuItem("Rename")); + agHelper.TypeText(propPane._placeholderName, `NewPage{enter}`, { + parseSpecialCharSeq: true, + }); + + PageList.ClonePage("NewPage"); + PageList.HidePage("NewPage Copy"); + PageList.ShowList(); + agHelper.AssertAttribute( + locators._entityTestId("NewPage Copy"), + "disabled", + "disabled", + ); + PageList.DeletePage("NewPage Copy"); + PageList.assertAbsence("NewPage Copy"); + + EditorNavigation.NavigateToPage("NewPage", true); + + entityExplorer.ActionContextMenuByEntityName({ + entityNameinLeftSidebar: "NewPage", + action: "Set as home page", + entityType: entityItems.Page, + }); + PageList.ShowList(); + agHelper.GetElement(locators._entityTestId("NewPage")).within(() => { + agHelper.AssertElementExist(locators._homeIcon); + }); + + entityExplorer.ActionContextMenuByEntityName({ + entityNameinLeftSidebar: "Page1", + action: "Set as home page", + entityType: entityItems.Page, + }); + PageList.ShowList(); + agHelper.GetElement(locators._entityTestId("Page1")).within(() => { + agHelper.AssertElementExist(locators._homeIcon); + }); + + EditorNavigation.NavigateToPage("NewPage", true); + partialImportExport.OpenExportModal("NewPage"); + partialImportExport.PartiallyExportFile( + 4, + partialImportExport.locators.export.modelContents.widgetsSection, + ["Text1"], + ); + + //Import the exported App + partialImportExport.OpenImportModal("NewPage"); + partialImportExport.ImportPartiallyExportedFile( + "PageActions.json", + "Widgets", + ["Text1"], + "downloads", + ); + }); + + it("2. Verify Page Actions when a page is not selected", function () { + EditorNavigation.NavigateToPage("Page1", true); + PageList.ShowList(); + agHelper.GetNClick(entityExplorer._contextMenu("NewPage"), 0, true); + agHelper.GetNClick(locators._contextMenuItem("Rename")); + agHelper.TypeText(propPane._placeholderName, `Page2{enter}`, { + parseSpecialCharSeq: true, + }); + + PageList.ClonePage("Page2"); + EditorNavigation.NavigateToPage("Page1", true); + PageList.HidePage("Page2 Copy"); + PageList.ShowList(); + agHelper.AssertAttribute( + locators._entityTestId("Page2 Copy"), + "disabled", + "disabled", + ); + PageList.DeletePage("Page2 Copy"); + PageList.assertAbsence("Page2 Copy"); + }); + + it("3. Verify Page Actions when a home page is selected", function () { + entityExplorer.DragDropWidgetNVerify(draggableWidgets.TEXT, 500, 100); + PageList.ShowList(); + agHelper.GetNClick(entityExplorer._contextMenu("Page1"), 0, true); + agHelper.GetNClick(locators._contextMenuItem("Rename")); + agHelper.TypeText(propPane._placeholderName, `HomePage{enter}`, { + parseSpecialCharSeq: true, + }); + + PageList.ClonePage("HomePage"); + PageList.HidePage("HomePage Copy"); + PageList.ShowList(); + agHelper.AssertAttribute( + locators._entityTestId("HomePage Copy"), + "disabled", + "disabled", + ); + PageList.DeletePage("HomePage Copy"); + PageList.assertAbsence("HomePage Copy"); + + EditorNavigation.NavigateToPage("HomePage", true); + partialImportExport.OpenExportModal("HomePage"); + partialImportExport.PartiallyExportFile( + 4, + partialImportExport.locators.export.modelContents.widgetsSection, + ["Text1"], + ); + + //Import the exported App + partialImportExport.OpenImportModal("HomePage"); + partialImportExport.ImportPartiallyExportedFile( + "PageActions.json", + "Widgets", + ["Text1"], + "downloads", + ); + }); +}); diff --git a/app/client/cypress/support/Objects/CommonLocators.ts b/app/client/cypress/support/Objects/CommonLocators.ts index bee52cb0da..f5a1d8d255 100644 --- a/app/client/cypress/support/Objects/CommonLocators.ts +++ b/app/client/cypress/support/Objects/CommonLocators.ts @@ -353,4 +353,5 @@ export class CommonLocators { _listItemTitle = ".ads-v2-listitem__title"; _dropdownOption = ".rc-select-item-option-content"; _dropdownActiveOption = ".rc-select-dropdown .rc-select-item-option-active"; + _homeIcon = "[data-testid='t--default-home-icon']"; } diff --git a/app/client/cypress/support/Pages/PartialImportExport.ts b/app/client/cypress/support/Pages/PartialImportExport.ts index b8a6e5c0ef..9a5bd98ff0 100644 --- a/app/client/cypress/support/Pages/PartialImportExport.ts +++ b/app/client/cypress/support/Pages/PartialImportExport.ts @@ -36,9 +36,9 @@ export default class PartialImportExport { }, }; - OpenExportModal() { + OpenExportModal(entityName = "Home") { this.entityExplorer.ActionContextMenuByEntityName({ - entityNameinLeftSidebar: "Home", + entityNameinLeftSidebar: entityName, action: "Export", entityType: EntityItems.Page, }); @@ -49,18 +49,17 @@ export default class PartialImportExport { ); } - OpenImportModal() { + OpenImportModal(entityName = "Page1") { AppSidebar.navigate(AppSidebarButton.Editor); this.entityExplorer.ActionContextMenuByEntityName({ - entityNameinLeftSidebar: "Page1", + entityNameinLeftSidebar: entityName, action: "Import", entityType: EntityItems.Page, }); this.agHelper.AssertElementVisibility(this.locators.import.importModal); } - ExportAndCompareDownloadedFile( sectionName: keyof typeof exportedPropertiesToUIEntitiesMap, sectionIndex: number,