interact with context menu items

This commit is contained in:
seraphima
2024-03-04 20:30:42 +01:00
parent 7ae037edbd
commit c2d3eb0aef
2 changed files with 39 additions and 2 deletions

View File

@@ -117,7 +117,22 @@ namespace Microsoft.FancyZonesEditor.UITests
CustomLayouts customLayouts = new CustomLayouts();
CustomLayouts.CustomLayoutListWrapper customLayoutListWrapper = new CustomLayouts.CustomLayoutListWrapper
{
CustomLayouts = new List<CustomLayouts.CustomLayoutWrapper> { },
CustomLayouts = new List<CustomLayouts.CustomLayoutWrapper>
{
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<CustomLayouts.CanvasInfoWrapper.CanvasZoneWrapper> { },
}),
},
},
};
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
{

View File

@@ -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