From c2d3eb0aefdb40a00ca141a870a4654492aaffba Mon Sep 17 00:00:00 2001 From: seraphima Date: Mon, 4 Mar 2024 20:30:42 +0100 Subject: [PATCH] interact with context menu items --- .../RunFancyZonesEditorTest.cs | 33 ++++++++++++++++++- .../Utils/FancyZonesEditorSession.cs | 8 ++++- 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/src/modules/fancyzones/UITests-FancyZonesEditor/RunFancyZonesEditorTest.cs b/src/modules/fancyzones/UITests-FancyZonesEditor/RunFancyZonesEditorTest.cs index 8fabba5c01..d09525bbc4 100644 --- a/src/modules/fancyzones/UITests-FancyZonesEditor/RunFancyZonesEditorTest.cs +++ b/src/modules/fancyzones/UITests-FancyZonesEditor/RunFancyZonesEditorTest.cs @@ -117,7 +117,22 @@ namespace Microsoft.FancyZonesEditor.UITests CustomLayouts customLayouts = new CustomLayouts(); CustomLayouts.CustomLayoutListWrapper customLayoutListWrapper = new CustomLayouts.CustomLayoutListWrapper { - CustomLayouts = new List { }, + CustomLayouts = new List + { + new CustomLayouts.CustomLayoutWrapper + { + Uuid = "{E7807D0D-6223-4883-B15B-1F3883944C09}", + Type = Constants.CustomLayoutTypeNames[Constants.CustomLayoutType.Canvas], + Name = "Custom layout", + Info = new CustomLayouts().ToJsonElement(new CustomLayouts.CanvasInfoWrapper + { + RefHeight = 952, + RefWidth = 1500, + SensitivityRadius = 10, + Zones = new List { }, + }), + }, + }, }; FancyZonesEditorSession.Files.CustomLayoutsIOHelper.WriteData(customLayouts.Serialize(customLayoutListWrapper)); @@ -183,6 +198,22 @@ namespace Microsoft.FancyZonesEditor.UITests Assert.IsNotNull(_session?.Session?.FindElementsByName("Edit 'Grid'")); // verify it's opened for the correct layout } + [TestMethod] + public void OpenEditLayoutDialog_ByContextMenu_TemplateLayout() // verify the edit layout dialog is opened + { + _session?.Click_ContextMenuItem(Constants.TemplateLayoutNames[Constants.TemplateLayouts.Grid], "Edit"); + Assert.IsNotNull(_session?.Session?.FindElementByAccessibilityId("EditLayoutDialogTitle")); // check the pane header + Assert.IsNotNull(_session?.Session?.FindElementsByName("Edit 'Grid'")); // verify it's opened for the correct layout + } + + [TestMethod] + public void OpenEditLayoutDialog_ByContextMenu_CustomLayout() // verify the edit layout dialog is opened + { + _session?.Click_ContextMenuItem("Custom layout", "Edit"); + Assert.IsNotNull(_session?.Session?.FindElementByAccessibilityId("EditLayoutDialogTitle")); // check the pane header + Assert.IsNotNull(_session?.Session?.FindElementsByName("Edit 'Grid'")); // verify it's opened for the correct layout + } + [TestMethod] public void OpenContextMenu() // verify the context menu is opened { diff --git a/src/modules/fancyzones/UITests-FancyZonesEditor/Utils/FancyZonesEditorSession.cs b/src/modules/fancyzones/UITests-FancyZonesEditor/Utils/FancyZonesEditorSession.cs index e4e16407bc..2767e572da 100644 --- a/src/modules/fancyzones/UITests-FancyZonesEditor/Utils/FancyZonesEditorSession.cs +++ b/src/modules/fancyzones/UITests-FancyZonesEditor/Utils/FancyZonesEditorSession.cs @@ -154,7 +154,7 @@ namespace Microsoft.FancyZonesEditor.UnitTests.Utils } } - public WindowsElement? OpenContextMenu(string layoutName) + public WindowsElement OpenContextMenu(string layoutName) { RightClick_Layout(layoutName); var menu = Session?.FindElementByClassName("ContextMenu"); @@ -312,6 +312,12 @@ namespace Microsoft.FancyZonesEditor.UnitTests.Utils button.Click(); } + public void Click_ContextMenuItem(string layoutName, string menuItem) + { + WindowsElement menu = OpenContextMenu(layoutName); + Click(menu.FindElementByName(menuItem)); + } + private WindowsElement? FindByAccessibilityId(string name) { try