From 6d676be6605bc17bf3cefbfb56cda81cb6d5004e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Herceg?= Date: Thu, 8 Feb 2024 17:41:59 +0100 Subject: [PATCH] Updates in samples + added UI tests --- .../MarkupControl/CommandAsProperty.cs | 6 ++--- .../CommandAsProperty.dotcontrol | 2 +- .../CommandAsPropertyPage.dothtml | 16 ++++++++++++- .../CommandAsPropertyWrapper.dotcontrol | 23 ++++++++++++++---- .../Abstractions/SamplesRouteUrls.designer.cs | 1 + .../Tests/Tests/Feature/MarkupControlTests.cs | 24 +++++++++++++++++++ 6 files changed, 62 insertions(+), 10 deletions(-) diff --git a/src/Samples/Common/Views/FeatureSamples/MarkupControl/CommandAsProperty.cs b/src/Samples/Common/Views/FeatureSamples/MarkupControl/CommandAsProperty.cs index b5fcbe49b3..bba02836e9 100644 --- a/src/Samples/Common/Views/FeatureSamples/MarkupControl/CommandAsProperty.cs +++ b/src/Samples/Common/Views/FeatureSamples/MarkupControl/CommandAsProperty.cs @@ -11,13 +11,13 @@ namespace DotVVM.Samples.Common.Views.FeatureSamples.MarkupControl public class CommandAsProperty : DotvvmMarkupControl { - public Func Click + public Func Click { - get => (Func)GetValue(ClickProperty)!; + get => (Func)GetValue(ClickProperty)!; set => SetValue(ClickProperty, value); } public static readonly DotvvmProperty ClickProperty - = DotvvmProperty.Register, CommandAsProperty>(c => c.Click, null); + = DotvvmProperty.Register, CommandAsProperty>(c => c.Click, null); } } diff --git a/src/Samples/Common/Views/FeatureSamples/MarkupControl/CommandAsProperty.dotcontrol b/src/Samples/Common/Views/FeatureSamples/MarkupControl/CommandAsProperty.dotcontrol index 18f66e6db9..4419a16506 100644 --- a/src/Samples/Common/Views/FeatureSamples/MarkupControl/CommandAsProperty.dotcontrol +++ b/src/Samples/Common/Views/FeatureSamples/MarkupControl/CommandAsProperty.dotcontrol @@ -7,4 +7,4 @@ <%--The following with ToString works somehow and I am not sure by what magic--%> - + diff --git a/src/Samples/Common/Views/FeatureSamples/MarkupControl/CommandAsPropertyPage.dothtml b/src/Samples/Common/Views/FeatureSamples/MarkupControl/CommandAsPropertyPage.dothtml index 14096e0037..71ba6b9cee 100644 --- a/src/Samples/Common/Views/FeatureSamples/MarkupControl/CommandAsPropertyPage.dothtml +++ b/src/Samples/Common/Views/FeatureSamples/MarkupControl/CommandAsPropertyPage.dothtml @@ -9,9 +9,23 @@ +

Pass as command

+
-

Selected item: {{value: Name}}, {{value: IsTrue}}

+ <%--

Pass as static command

+ +
--%> + + <%--

Pass as value

+ +
--%> + + <%--

Pass as resource

+ +
--%> + +

Selected item: {{value: Name}}, {{value: IsTrue}}

diff --git a/src/Samples/Common/Views/FeatureSamples/MarkupControl/CommandAsPropertyWrapper.dotcontrol b/src/Samples/Common/Views/FeatureSamples/MarkupControl/CommandAsPropertyWrapper.dotcontrol index 8452273875..fc84905e3a 100644 --- a/src/Samples/Common/Views/FeatureSamples/MarkupControl/CommandAsPropertyWrapper.dotcontrol +++ b/src/Samples/Common/Views/FeatureSamples/MarkupControl/CommandAsPropertyWrapper.dotcontrol @@ -2,9 +2,22 @@ @baseType DotVVM.Samples.Common.Views.FeatureSamples.MarkupControl.CommandAsPropertyWrapper, DotVVM.Samples.Common - <%-- - The correct syntax would be Click="{value: _control.Click(_parent.Name, _parent.IsTrue)}" - Btw is value binding the right thing, or shall we use resource binding here? - --%> - +
+
+

Passed as command

+ +
+
+

Passed as static command

+ +
+
+

Passed as value

+ +
+
+

Passed as resource

+ +
+
diff --git a/src/Samples/Tests/Abstractions/SamplesRouteUrls.designer.cs b/src/Samples/Tests/Abstractions/SamplesRouteUrls.designer.cs index fe2388d721..84518eb640 100644 --- a/src/Samples/Tests/Abstractions/SamplesRouteUrls.designer.cs +++ b/src/Samples/Tests/Abstractions/SamplesRouteUrls.designer.cs @@ -281,6 +281,7 @@ public partial class SamplesRouteUrls public const string FeatureSamples_Localization_Localization_FormatString = "FeatureSamples/Localization/Localization_FormatString"; public const string FeatureSamples_Localization_Localization_NestedPage_Type = "FeatureSamples/Localization/Localization_NestedPage_Type"; public const string FeatureSamples_MarkupControl_ComboBoxDataSourceBoundToStaticCollection = "FeatureSamples/MarkupControl/ComboBoxDataSourceBoundToStaticCollection"; + public const string FeatureSamples_MarkupControl_CommandAsPropertyPage = "FeatureSamples/MarkupControl/CommandAsPropertyPage"; public const string FeatureSamples_MarkupControl_CommandBindingInDataContextWithControlProperty = "FeatureSamples/MarkupControl/CommandBindingInDataContextWithControlProperty"; public const string FeatureSamples_MarkupControl_CommandBindingInRepeater = "FeatureSamples/MarkupControl/CommandBindingInRepeater"; public const string FeatureSamples_MarkupControl_CommandPropertiesInMarkupControl = "FeatureSamples/MarkupControl/CommandPropertiesInMarkupControl"; diff --git a/src/Samples/Tests/Tests/Feature/MarkupControlTests.cs b/src/Samples/Tests/Tests/Feature/MarkupControlTests.cs index ef51f5007f..f034ca4ce6 100644 --- a/src/Samples/Tests/Tests/Feature/MarkupControlTests.cs +++ b/src/Samples/Tests/Tests/Feature/MarkupControlTests.cs @@ -409,5 +409,29 @@ public void Feature_MarkupControl_MarkupDeclaredProperties() browser.WaitFor(() => AssertUI.InnerTextEquals(browser.First("[data-ui=counter]"), "2"), 2000); }); } + + [Fact] + public void Feature_MarkupControl_CommandAsPropertyPage() + { + RunInAllBrowsers(browser => { + browser.NavigateToUrl(SamplesRouteUrls.FeatureSamples_MarkupControl_CommandAsPropertyPage); + + var lists = browser.FindElements("div[data-ui=button-list]"); + for (var j = 0; j < 4; j++) + { + for (var i = 0; i < lists.Count; i++) + { + lists[i].ElementAt("input[type=button]", j).Click(); + AssertUI.InnerTextEquals(browser.Single("p[data-ui=result]"), (i % 3) switch { + 0 => "Selected item: One, true", + 1 => "Selected item: Two, false", + _ => "Selected item: Three, true" + }); + + i++; + } + } + }); + } } }