Skip to content

Commit

Permalink
Merge pull request #34 from episerver/develop
Browse files Browse the repository at this point in the history
Merge bugfix from develop
  • Loading branch information
hungoptimizely authored Jul 17, 2023
2 parents 9d11647 + 087e3f0 commit 59eae93
Show file tree
Hide file tree
Showing 12 changed files with 52 additions and 52 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @episerver/addons-developers
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -228,4 +228,5 @@ ModelManifest.xml
/samples/EPiServer.Templates.Alloy.Mvc/App_Code/**
/nupkgs
modules
zipoutput
zipoutput
/samples/QuickSilver/EPiServer.Reference.Commerce.Site/App_Data/**
2 changes: 1 addition & 1 deletion EPiServer.Marketing.Testing.sln
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<Import Project="../DependencyVersions.props" Condition="'$(DependencyVersions_props)' == ''" />
<Import Project="../../../build/DependencyVersions.props" Condition="'$(DependencyVersions_props)' == ''" />
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<AddRazorSupportForMvc>true</AddRazorSupportForMvc>
Expand All @@ -13,8 +13,8 @@
<EmbeddedResource Include="lang\**\*" />
<PackageReference Include="Adyen" Version="5.7.0" />
<PackageReference Include="BuildBundlerMinifier" Version="3.2.449" />
<PackageReference Include="EPiServer.Cms" Version="12.6.0" />
<PackageReference Include="EPiServer.Commerce" Version="14.3.0" />
<PackageReference Include="EPiServer.Cms" Version="$(CmsUiVersionCommon)" />
<PackageReference Include="EPiServer.Commerce" Version="$(CmsCommerceVersionCommon)" />
<PackageReference Include="EPiServer.Personalization.Commerce" Version="4.0.5" />
<PackageReference Include="EPiServer.Tracking.Commerce" Version="4.0.5" />
<PackageReference Include="Lucene.Net" Version="4.8.0-beta00014" />
Expand Down
2 changes: 1 addition & 1 deletion src/EPiServer.Marketing.KPI.Commerce/MenuProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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";

/// <summary>
/// Initializes a new instance of <see cref="MenuProvider"/>
Expand Down
23 changes: 10 additions & 13 deletions src/EPiServer.Marketing.KPI/Common/ContentComparatorKPI.cs
Original file line number Diff line number Diff line change
@@ -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
{
Expand Down Expand Up @@ -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
{
Expand Down
4 changes: 2 additions & 2 deletions src/EPiServer.Marketing.Testing.Web/Controllers/KpiStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ public RestResult Get()
/// <param name="id"></param>
/// <param name="entity"></param>
/// <returns></returns>
[HttpPut]
public ActionResult Put([FromBody]KpiPutRequest request)
[HttpPost]
public ActionResult Post([FromBody]KpiPutRequest request)
{
List<IKpi> validKpiInstances = new List<IKpi>();
Dictionary<string, string> kpiErrors = new Dictionary<string, string>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
19 changes: 2 additions & 17 deletions src/EPiServer.Marketing.Testing.Web/MenuProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -33,13 +33,6 @@ public IEnumerable<MenuItem> GetMenuItems()
}
return new List<MenuItem>
{
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"))
Expand All @@ -48,15 +41,7 @@ public IEnumerable<MenuItem> 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
}
}
};
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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
{
Expand Down Expand Up @@ -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<IContent>();
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<IContent>(It.Is<Guid>(g => g == LandingPageGuid))).Returns(content3.Object);
_kpiHelper.Setup(call => call.GetUrl(It.Is<ContentReference>(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()
{
Expand Down
8 changes: 4 additions & 4 deletions test/EPiServer.Marketing.Testing.Test/Web/KpiStoreTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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);

Expand Down Expand Up @@ -113,7 +113,7 @@ public void Put_Returns_Correct_Weight_For_Each_Kpi()
_kpiWebRepoMock.Setup(call => call.ActivateKpiInstance(It.IsAny<Dictionary<string, string>>())).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<Guid,string>)retResult.Data.GetType().GetProperty("obj").GetValue(retResult.Data, null);

Expand Down Expand Up @@ -149,7 +149,7 @@ public void Put_With_Duplicate_Kpis_and_Values_Returns_Proper_Errors()
_kpiWebRepoMock.Setup(call => call.ActivateKpiInstance(It.IsAny<Dictionary<string, string>>())).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<Dictionary<string,string>>(retResult.Data.GetType().GetProperty("errors").GetValue(retResult.Data, null).ToString());

Expand Down

0 comments on commit 59eae93

Please sign in to comment.