diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 000000000..49cd98347 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1 @@ +* @episerver/addons-developers \ No newline at end of file diff --git a/.gitignore b/.gitignore index 7c40483d0..099ed5fc5 100644 --- a/.gitignore +++ b/.gitignore @@ -228,4 +228,5 @@ ModelManifest.xml /samples/EPiServer.Templates.Alloy.Mvc/App_Code/** /nupkgs modules -zipoutput \ No newline at end of file +zipoutput +/samples/QuickSilver/EPiServer.Reference.Commerce.Site/App_Data/** \ No newline at end of file diff --git a/EPiServer.Marketing.Testing.sln b/EPiServer.Marketing.Testing.sln index 6d22d8e7c..011fdf3b0 100644 --- a/EPiServer.Marketing.Testing.sln +++ b/EPiServer.Marketing.Testing.sln @@ -14,7 +14,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{00563401 README.md = README.md setup.cmd = setup.cmd Build\test.props = Build\test.props - src\EPiServer.Marketing.KPI\version.props = src\EPiServer.Marketing.KPI\version.props + build\version.props = build\version.props EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{4DCCE100-6879-491C-BCC9-85A6DA6B0EE7}" diff --git a/samples/QuickSilver/EPiServer.Reference.Commerce.Site/EPiServer.Reference.Commerce.Site.csproj b/samples/QuickSilver/EPiServer.Reference.Commerce.Site/EPiServer.Reference.Commerce.Site.csproj index 92a3f9aa7..331b2832d 100644 --- a/samples/QuickSilver/EPiServer.Reference.Commerce.Site/EPiServer.Reference.Commerce.Site.csproj +++ b/samples/QuickSilver/EPiServer.Reference.Commerce.Site/EPiServer.Reference.Commerce.Site.csproj @@ -1,5 +1,5 @@ - + net6.0 true @@ -13,8 +13,8 @@ - - + + diff --git a/src/EPiServer.Marketing.KPI.Commerce/MenuProvider.cs b/src/EPiServer.Marketing.KPI.Commerce/MenuProvider.cs index 9b87d0c18..e5061d022 100644 --- a/src/EPiServer.Marketing.KPI.Commerce/MenuProvider.cs +++ b/src/EPiServer.Marketing.KPI.Commerce/MenuProvider.cs @@ -14,7 +14,7 @@ public class MenuProvider : IMenuProvider { private readonly LocalizationService _localizationService; - private const string MarketingToolSettingsPath = MenuPaths.Global + "/addons"; + private const string MarketingToolSettingsPath = MenuPaths.Global + "/cms"; /// /// Initializes a new instance of diff --git a/src/EPiServer.Marketing.KPI/Common/ContentComparatorKPI.cs b/src/EPiServer.Marketing.KPI/Common/ContentComparatorKPI.cs index 9f1bcde76..2b13d9570 100644 --- a/src/EPiServer.Marketing.KPI/Common/ContentComparatorKPI.cs +++ b/src/EPiServer.Marketing.KPI/Common/ContentComparatorKPI.cs @@ -1,21 +1,17 @@ using EPiServer.Core; +using EPiServer.Framework.Localization; using EPiServer.Marketing.KPI.Common.Attributes; +using EPiServer.Marketing.KPI.Common.Helpers; +using EPiServer.Marketing.KPI.Exceptions; using EPiServer.Marketing.KPI.Manager.DataClass; +using EPiServer.Marketing.KPI.Results; using EPiServer.ServiceLocation; +using EPiServer.Web.Routing; using System; using System.Collections.Generic; -using System.Runtime.Serialization; -using Microsoft.AspNetCore.Mvc.Routing; -using EPiServer.Framework.Localization; -using EPiServer.Marketing.KPI.Exceptions; -using EPiServer.Web.Mvc.Html; -using EPiServer.Marketing.KPI.Results; -using EPiServer.Web.Routing; -using System.Web; -using System.Runtime.Caching; -using EPiServer.Marketing.KPI.Common.Helpers; using System.Linq; -using EPiServer.Web.Mvc; +using System.Runtime.Caching; +using System.Runtime.Serialization; namespace EPiServer.Marketing.KPI.Common { @@ -138,8 +134,9 @@ public override IKpiResult Evaluate(object sender, EventArgs e) // if the target content is the start page, we also need to check // the path to make sure its not just a request for some other static // resources such as css or jscript - retval = (_startpagepaths.Contains(_kpiHelper.Service.GetRequestPath(), StringComparer.OrdinalIgnoreCase) - && ContentGuid.Equals(ea.Content.ContentGuid)); + retval = _startpagepaths.Any(path => path.Trim('/') + .Equals(_kpiHelper.Service.GetRequestPath().Trim('/'), StringComparison.OrdinalIgnoreCase)) + && ContentGuid.Equals(ea.Content.ContentGuid); } else { diff --git a/src/EPiServer.Marketing.Testing.Web/Controllers/KpiStore.cs b/src/EPiServer.Marketing.Testing.Web/Controllers/KpiStore.cs index 0b364d2c1..95918e56a 100644 --- a/src/EPiServer.Marketing.Testing.Web/Controllers/KpiStore.cs +++ b/src/EPiServer.Marketing.Testing.Web/Controllers/KpiStore.cs @@ -49,8 +49,8 @@ public RestResult Get() /// /// /// - [HttpPut] - public ActionResult Put([FromBody]KpiPutRequest request) + [HttpPost] + public ActionResult Post([FromBody]KpiPutRequest request) { List validKpiInstances = new List(); Dictionary kpiErrors = new Dictionary(); diff --git a/src/EPiServer.Marketing.Testing.Web/Controllers/SettingController.cs b/src/EPiServer.Marketing.Testing.Web/Controllers/SettingController.cs index 85e425f4c..35df967d8 100644 --- a/src/EPiServer.Marketing.Testing.Web/Controllers/SettingController.cs +++ b/src/EPiServer.Marketing.Testing.Web/Controllers/SettingController.cs @@ -12,7 +12,7 @@ namespace EPiServer.Marketing.Testing.Web.Controllers { - [Authorize(Roles = "Administrators,WebAdmins")] + [Authorize(Roles = "Administrators, CmsAdmins")] public class SettingController : Controller { private readonly ILogger _logger; diff --git a/src/EPiServer.Marketing.Testing.Web/Helpers/TestDataCookieHelper.cs b/src/EPiServer.Marketing.Testing.Web/Helpers/TestDataCookieHelper.cs index 790601118..e2cd85bdb 100644 --- a/src/EPiServer.Marketing.Testing.Web/Helpers/TestDataCookieHelper.cs +++ b/src/EPiServer.Marketing.Testing.Web/Helpers/TestDataCookieHelper.cs @@ -141,7 +141,7 @@ public TestDataCookie GetTestDataFromCookie(string testContentId, string culture bool outval; - retCookie.TestStart = DateTime.Parse(cookieData["start"]); + retCookie.TestStart = DateTime.Parse(cookieData["start"], CultureInfo.InvariantCulture); retCookie.Viewed = bool.TryParse(cookieData["viewed"], out outval) ? outval : false; retCookie.Converted = bool.TryParse(cookieData["converted"], out outval) ? outval : false; diff --git a/src/EPiServer.Marketing.Testing.Web/MenuProvider.cs b/src/EPiServer.Marketing.Testing.Web/MenuProvider.cs index 53c04c8f8..4bc7c3694 100644 --- a/src/EPiServer.Marketing.Testing.Web/MenuProvider.cs +++ b/src/EPiServer.Marketing.Testing.Web/MenuProvider.cs @@ -15,7 +15,7 @@ public class MenuProvider : IMenuProvider private readonly ModuleTable _moduleTable; private readonly LocalizationService _localizationService; - private const string MarketingToolSettingsPath = MenuPaths.Global + "/addons"; + private const string MarketingToolSettingsPath = MenuPaths.Global + "/cms"; public MenuProvider(LocalizationService localizationService, ModuleTable moduleTable) { @@ -33,13 +33,6 @@ public IEnumerable GetMenuItems() } return new List { - new SectionMenuItem(_localizationService.GetString("", "Addons"), - MarketingToolSettingsPath) - { - SortIndex = 10, - Alignment = MenuItemAlignment.Left, - IsAvailable = (context) => true - }, new UrlMenuItem(_localizationService.GetString("", "Marketing Tools"), MarketingToolSettingsPath + "/marketingtools", Paths.ToResource(GetType(), "Setting")) @@ -48,15 +41,7 @@ public IEnumerable GetMenuItems() Alignment = MenuItemAlignment.Left, IsAvailable = (context) => true, AuthorizationPolicy = CmsPolicyNames.CmsAdmin - }, - new UrlMenuItem(_localizationService.GetString("/abtesting/admin/displayname", "AB Testing Configuration"), - MarketingToolSettingsPath + "/marketingtools/setting", - Paths.ToResource(GetType(), "Setting")) - { - SortIndex = SortIndex.Early + 110, - Alignment = MenuItemAlignment.Left, - AuthorizationPolicy = CmsPolicyNames.CmsAdmin - } + } }; } } diff --git a/test/EPiServer.Marketing.KPI.Test/Common/ContentComparatorKPITests.cs b/test/EPiServer.Marketing.KPI.Test/Common/ContentComparatorKPITests.cs index 1fb2c6857..3ba7455ff 100644 --- a/test/EPiServer.Marketing.KPI.Test/Common/ContentComparatorKPITests.cs +++ b/test/EPiServer.Marketing.KPI.Test/Common/ContentComparatorKPITests.cs @@ -1,20 +1,19 @@ using EPiServer.Core; -using EPiServer.Marketing.KPI.Common; -using EPiServer.Marketing.KPI.Results; -using Moq; -using System; -using System.Collections.Generic; -using System.Threading; using EPiServer.DataAbstraction; using EPiServer.Framework.Localization; +using EPiServer.Marketing.KPI.Common; +using EPiServer.Marketing.KPI.Common.Helpers; using EPiServer.Marketing.KPI.Exceptions; using EPiServer.Marketing.KPI.Manager.DataClass; using EPiServer.Marketing.KPI.Test.Fakes; using EPiServer.ServiceLocation; using EPiServer.Web.Routing; -using Xunit; -using EPiServer.Marketing.KPI.Common.Helpers; using Microsoft.Extensions.DependencyInjection; +using Moq; +using System; +using System.Collections.Generic; +using System.Threading; +using Xunit; namespace EPiServer.Marketing.KPI.Test.Common { @@ -256,6 +255,23 @@ public void Kpi_Converts_IfContentPathEqualsRequestedPath_IgnoringRequestedConte Assert.True(retVal.HasConverted); } + [Fact] + public void Kpi_Converts_IfRequestedPathEqualsStartPagePath_IgnoringUrlTrailingSlash_AndGuidsAreEqual() + { + var content3 = new Mock(); + content3.SetupGet(get => get.ContentLink).Returns(ContentReference.StartPage); + content3.SetupGet(get => get.ContentGuid).Returns(LandingPageGuid); + var arg = new ContentEventArgs(new ContentReference()) { Content = content3.Object }; + + var kpi = GetUnitUnderTest(); + _contentRepo.Setup(c => c.Get(It.Is(g => g == LandingPageGuid))).Returns(content3.Object); + _kpiHelper.Setup(call => call.GetUrl(It.Is(c => c == ContentReference.StartPage))).Returns("/en/"); + _kpiHelper.Setup(call => call.GetRequestPath()).Returns("/en"); + + var retVal = kpi.Evaluate(new object(), arg); + Assert.True(retVal.HasConverted); + } + [Fact] public void Kpi_DoesNotConvert_IfContentPathEqualsRequestedPath_AndGuidsAreNotEqual() { diff --git a/test/EPiServer.Marketing.Testing.Test/Web/KpiStoreTests.cs b/test/EPiServer.Marketing.Testing.Test/Web/KpiStoreTests.cs index 2e1b4696a..875ae557c 100644 --- a/test/EPiServer.Marketing.Testing.Test/Web/KpiStoreTests.cs +++ b/test/EPiServer.Marketing.Testing.Test/Web/KpiStoreTests.cs @@ -62,7 +62,7 @@ public void Put_With_Null_Entity() { var testClass = GetUnitUnderTest(); var request = new KpiPutRequest { entity = "", id = "" }; - var retResult = testClass.Put(request) as RestResult; + var retResult = testClass.Post(request) as RestResult; var responseDataStatus = (bool)retResult.Data.GetType().GetProperty("status").GetValue(retResult.Data, null); @@ -78,7 +78,7 @@ public void Put_With_Non_Null_Entity_Throws_Exception() entity = "{\"kpiType\": \"EPiServer.Marketing.KPI.Common.ContentComparatorKPI, EPiServer.Marketing.KPI, Version=2.0.0.0, Culture=neutral, PublicKeyToken=8fe83dea738b45b7\",\"ConversionPage\": \"16\",\"CurrentContent\": \"6_197\"}", id = "" }; - var retResult = testClass.Put(request) as RestResult; + var retResult = testClass.Post(request) as RestResult; var responseDataStatus = (bool)retResult.Data.GetType().GetProperty("status").GetValue(retResult.Data, null); @@ -113,7 +113,7 @@ public void Put_Returns_Correct_Weight_For_Each_Kpi() _kpiWebRepoMock.Setup(call => call.ActivateKpiInstance(It.IsAny>())).Returns(sticky.Object); var request = new KpiPutRequest { entity = "", id = "KpiFormData" }; - var retResult = testClass.Put(request) as RestResult; + var retResult = testClass.Post(request) as RestResult; var responseDataObj= (Dictionary)retResult.Data.GetType().GetProperty("obj").GetValue(retResult.Data, null); @@ -149,7 +149,7 @@ public void Put_With_Duplicate_Kpis_and_Values_Returns_Proper_Errors() _kpiWebRepoMock.Setup(call => call.ActivateKpiInstance(It.IsAny>())).Returns(sticky.Object); var request = new KpiPutRequest { entity = "", id = "KpiFormData" }; - var retResult = testClass.Put(request) as RestResult; + var retResult = testClass.Post(request) as RestResult; var responseDataErrors = JsonConvert.DeserializeObject>(retResult.Data.GetType().GetProperty("errors").GetValue(retResult.Data, null).ToString());