Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Avoid using hardcoded coordinates for widget placement

Using fixed coordinates (500, 100) makes the test brittle and susceptible to viewport size changes.

-entityExplorer.DragDropWidgetNVerify(draggableWidgets.TEXT, 500, 100);
+entityExplorer.DragDropWidgetNVerify(draggableWidgets.TEXT);

Committable suggestion skipped: line range outside the PR's diff.

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",
);
Comment on lines +123 to +137
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Extract export/import logic to reusable helper

The export/import logic is duplicated from test case 1. Consider extracting it to a reusable helper function.

+const performWidgetExportImport = (pageName: string, widgetNames: string[]) => {
+  partialImportExport.OpenExportModal(pageName);
+  partialImportExport.PartiallyExportFile(
+    4,
+    partialImportExport.locators.export.modelContents.widgetsSection,
+    widgetNames,
+  );
+
+  partialImportExport.OpenImportModal(pageName);
+  partialImportExport.ImportPartiallyExportedFile(
+    "PageActions.json",
+    "Widgets",
+    widgetNames,
+    "downloads",
+  );
+};
+
-    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",
-    );
+    performWidgetExportImport("HomePage", ["Text1"]);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
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",
);
const performWidgetExportImport = (pageName: string, widgetNames: string[]) => {
partialImportExport.OpenExportModal(pageName);
partialImportExport.PartiallyExportFile(
4,
partialImportExport.locators.export.modelContents.widgetsSection,
widgetNames,
);
partialImportExport.OpenImportModal(pageName);
partialImportExport.ImportPartiallyExportedFile(
"PageActions.json",
"Widgets",
widgetNames,
"downloads",
);
};
performWidgetExportImport("HomePage", ["Text1"]);

});
});
1 change: 1 addition & 0 deletions app/client/cypress/support/Objects/CommonLocators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -352,4 +352,5 @@ export class CommonLocators {
`[data-testid="t--entity-item-${entity}"]`;
_dropdownOption = ".rc-select-item-option-content";
_dropdownActiveOption = ".rc-select-dropdown .rc-select-item-option-active";
_homeIcon = "[data-testid='t--default-home-icon']";
}
9 changes: 4 additions & 5 deletions app/client/cypress/support/Pages/PartialImportExport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ export default class PartialImportExport {
},
};

OpenExportModal() {
OpenExportModal(entityName = "Home") {
this.entityExplorer.ActionContextMenuByEntityName({
entityNameinLeftSidebar: "Home",
entityNameinLeftSidebar: entityName,
action: "Export",
entityType: EntityItems.Page,
});
Expand All @@ -49,18 +49,17 @@ export default class PartialImportExport {
);
}

OpenImportModal() {
OpenImportModal(entityName = "Page1") {
AppSidebar.navigate(AppSidebarButton.Editor);

this.entityExplorer.ActionContextMenuByEntityName({
entityNameinLeftSidebar: "Page1",
entityNameinLeftSidebar: entityName,
Comment on lines +52 to +56
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Extract default page name and remove redundant method

Similar to the export modal, the default page name should be a constant. Additionally, the OpenImportModalWithPage method at the bottom of the file is now redundant.

+ private readonly DEFAULT_IMPORT_PAGE = "Page1";
- OpenImportModal(entityName = "Page1") {
+ OpenImportModal(entityName = this.DEFAULT_IMPORT_PAGE) {

Please remove the redundant OpenImportModalWithPage method as its functionality is now covered by OpenImportModal.

Committable suggestion skipped: line range outside the PR's diff.

action: "Import",
entityType: EntityItems.Page,
});

this.agHelper.AssertElementVisibility(this.locators.import.importModal);
}

ExportAndCompareDownloadedFile(
sectionName: keyof typeof exportedPropertiesToUIEntitiesMap,
sectionIndex: number,
Expand Down
Loading