Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OCC-174: Downloading the Chrome WebDriver fails with Chrome >=15 #325

Merged
merged 8 commits into from
Aug 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
-->

<ItemGroup>
<PackageReference Include="Lombiq.Analyzers" Version="3.1.0">
<PackageReference Include="Lombiq.Analyzers" Version="3.2.0">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public string ToString(decimal amount)

public static bool operator !=(Currency left, Currency right) => !(left == right);

private static void ThrowIfMissing(string argument, [CallerArgumentExpression("argument")] string name = null)
private static void ThrowIfMissing(string argument, [CallerArgumentExpression(nameof(argument))] string name = null)
{
if (string.IsNullOrWhiteSpace(argument))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ static int RankCultureByExpectedRelevance(CultureInfo cultureInfo)
var cultures = CultureInfo.GetCultures(CultureTypes.AllCultures).Where(IsValid).ToList();

CurrencyTable = cultures
.GroupBy(culture => culture.Name.Split('-').Last())
.GroupBy(culture => culture.Name.Split('-')[^1])
.Select(group => group
.OrderBy(RankCultureByExpectedRelevance)
.ThenBy(culture => culture.EnglishName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="System.Text.Json" Version="7.0.2" />
<PackageReference Include="System.Text.Json" Version="7.0.3" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace OrchardCore.Commerce.MoneyDataType.Serialization;

internal class AmountConverter : JsonConverter<Amount>
internal sealed class AmountConverter : JsonConverter<Amount>
{
public const string ValueName = "value";
public const string CurrencyName = "currency";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace OrchardCore.Commerce.MoneyDataType.Serialization;

internal class CurrencyConverter : System.Text.Json.Serialization.JsonConverter<ICurrency>
internal sealed class CurrencyConverter : System.Text.Json.Serialization.JsonConverter<ICurrency>
{
public override ICurrency Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) =>
Currency.FromIsoCode(reader.GetString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace OrchardCore.Commerce.MoneyDataType.Serialization;

internal class LegacyAmountConverter : JsonConverter<Amount>
internal sealed class LegacyAmountConverter : JsonConverter<Amount>
{
public override Amount ReadJson(
JsonReader reader,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace OrchardCore.Commerce.MoneyDataType.Serialization;

internal class LegacyCurrencyConverter : JsonConverter<ICurrency>
internal sealed class LegacyCurrencyConverter : JsonConverter<ICurrency>
{
public override ICurrency ReadJson(
JsonReader reader,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
<ProjectReference Include="$(LombiqHelpfulLibrariesPath)" />
</ItemGroup>
<ItemGroup Condition="!Exists($(LombiqHelpfulLibrariesPath))">
<PackageReference Include="Lombiq.HelpfulLibraries.OrchardCore" Version="6.0.1-alpha.0.gov-15" />
<PackageReference Include="Lombiq.HelpfulLibraries.OrchardCore" Version="7.0.0" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ public override async Task<IDisplayResult> UpdateAsync(
var viewModel = new InventoryPartViewModel();
if (await updater.TryUpdateModelAsync(viewModel, Prefix))
{
var currentSku = _hca.HttpContext.Request.Form["ProductPart.Sku"].ToString().ToUpperInvariant();
var currentSku = _hca.HttpContext?.Request.Form["ProductPart.Sku"].ToString().ToUpperInvariant();
var skuBefore = viewModel.Inventory.FirstOrDefault().Key != null
? viewModel.Inventory.FirstOrDefault().Key.Split("-").First()
? viewModel.Inventory.FirstOrDefault().Key.Split('-')[0]
: "DEFAULT";

part.Inventory.Clear();
Expand All @@ -51,7 +51,7 @@ public override async Task<IDisplayResult> UpdateAsync(
foreach (var inventoryEntry in oldInventory)
{
var updatedKey = oldInventory.Count > 1
? currentSku + "-" + inventoryEntry.Key.Split('-').Last()
? currentSku + "-" + inventoryEntry.Key.Split('-')[^1]
DemeSzabolcs marked this conversation as resolved.
Show resolved Hide resolved
: currentSku;

part.Inventory.Remove(inventoryEntry.Key);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
<ProjectReference Include="$(LombiqHelpfulLibrariesPath)" />
</ItemGroup>
<ItemGroup Condition="!Exists($(LombiqHelpfulLibrariesPath))">
<PackageReference Include="Lombiq.HelpfulLibraries.OrchardCore" Version="6.0.1-alpha.0.gov-15" />
<PackageReference Include="Lombiq.HelpfulLibraries.OrchardCore" Version="7.0.0" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public static IEnumerable<string> GetProductAttributesCombinations(
this IPredefinedValuesProductAttributeService service,
ContentItem product) =>
CartesianProduct(service.GetProductAttributesPredefinedValues(product))
.Select(predefinedValues => string.Join("-", predefinedValues));
.Select(predefinedValues => string.Join('-', predefinedValues));

private static IEnumerable<IEnumerable<T>> CartesianProduct<T>(IEnumerable<IEnumerable<T>> sequences)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public OrderCreatedEvent(IStringLocalizer<OrderCreatedEvent> localizer) =>
public override IEnumerable<Outcome> GetPossibleOutcomes(
WorkflowExecutionContext workflowContext,
ActivityContext activityContext) =>
Outcomes(new[] { T["Done"] });
new[] { new Outcome(T["Done"]) };

public override ActivityExecutionResult Resume(
WorkflowExecutionContext workflowContext,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class ProductAddedToCartEvent : EventActivity
public override IEnumerable<Outcome> GetPossibleOutcomes(
WorkflowExecutionContext workflowContext,
ActivityContext activityContext) =>
Outcomes(new[] { T["Done"] });
new[] { new Outcome(T["Done"]) };

public override ActivityExecutionResult Resume(
WorkflowExecutionContext workflowContext,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ public override IDisplayResult Edit(ContentTypeDefinition model) =>
{
var displayText = link.Url
.Query
.Split("name=")
.Last()
.Split("name=")[^1]
.Replace("Order_Checkout__", string.Empty)
.Replace("__", " - ");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ private static void UpdateAvailabilityKeys(ProductPart part, int inventoryCount)
foreach (var entry in part.CanBeBought)
{
var updatedKey = inventoryCount > 1
? part.Sku + "-" + entry.Key.Split('-').Last()
? $"{part.Sku}-{entry.Key.Split('-')[^1]}"
: part.Sku;

newAvailabilities.Add(updatedKey, entry.Value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,7 @@ public override async Task<IDisplayResult> UpdateAsync(RegionSettings section, B
.Select(region => region.TwoLetterISORegionName);

section.AllowedRegions = allowedRegions?.Any() == true
? allRegionTwoLetterIsoRegionNames
.Where(regionTwoLetterIsoRegionName => allowedRegions.Contains(regionTwoLetterIsoRegionName))
? allRegionTwoLetterIsoRegionNames.Where(allowedRegions.Contains)
: allRegionTwoLetterIsoRegionNames;

// Release the tenant to apply settings.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public ShoppingCartWidgetPartDisplayDriver(IShoppingCartPersistence shoppingCart
_shoppingCartPersistence = shoppingCartPersistence;

public override IDisplayResult Display(ShoppingCartWidgetPart part, BuildPartDisplayContext context) =>
Initialize<ShoppingCartWidgetPartViewModel>(GetDisplayShapeType(context), viewModel => PopulateViewModelAsync(viewModel))
Initialize<ShoppingCartWidgetPartViewModel>(GetDisplayShapeType(context), PopulateViewModelAsync)
.Location("Detail", "Content:25")
.Location("Summary", "Meta:10");

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
using OrchardCore.Commerce.Settings;
using OrchardCore.ContentManagement;
using OrchardCore.ContentManagement.Metadata.Models;
using System.Diagnostics.CodeAnalysis;

namespace OrchardCore.Commerce.Fields;

[SuppressMessage(
"Minor Code Smell",
"S2094:Classes should not be empty",
Justification = "Intermediate ancestor class to group together attribute fields.")]
public abstract class ProductAttributeField : ContentField
{
}
Expand Down
4 changes: 2 additions & 2 deletions src/Modules/OrchardCore.Commerce/Models/PrioritizedPrice.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using OrchardCore.Commerce.MoneyDataType;
using OrchardCore.Commerce.Serialization;
using System;
using System.Diagnostics;
using System.Globalization;
using System.Text.Json.Serialization;

namespace OrchardCore.Commerce.Models;
Expand All @@ -23,7 +23,7 @@ public class PrioritizedPrice
/// </summary>
public Amount Price { get; }

private string DebuggerDisplay => FormattableString.Invariant($"{Price} ^{Priority}");
private string DebuggerDisplay => string.Create(CultureInfo.InvariantCulture, $"{Price} ^{Priority}");

public PrioritizedPrice(int priority, Amount price)
{
Expand Down
8 changes: 4 additions & 4 deletions src/Modules/OrchardCore.Commerce/Models/ShoppingCartItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ public string GetVariantKeyFromAttributes(ISet<string> predefinedAttributeValues
.OrderBy(value => value.AttributeName);

return string.Join(
"-",
predefinedAttributes
.Select(attr => attr.UntypedPredefinedValue)
.Where(value => value != null))
'-',
predefinedAttributes
.Select(attr => attr.UntypedPredefinedValue)
.Where(value => value != null))
.HtmlClassify()
.ToUpperInvariant();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
using OrchardCore.ContentManagement;
using System.Diagnostics.CodeAnalysis;

namespace OrchardCore.Commerce.Models;

[SuppressMessage(
"Minor Code Smell",
"S2094:Classes should not be empty",
Justification = "This part doesn't store data.")]
public class ShoppingCartWidgetPart : ContentPart
{
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<PackageReference Include="OrchardCore.Title" Version="1.6.0" />
<PackageReference Include="OrchardCore.Templates" Version="1.6.0" />
<PackageReference Include="OrchardCore.Workflows.Abstractions" Version="1.6.0" />
<PackageReference Include="Stripe.net" Version="41.18.0" />
<PackageReference Include="Stripe.net" Version="41.27.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace OrchardCore.Commerce.ProductAttributeValues;
/// Used only to deserialize attributes, before they're post-processed into concrete attribute values.
/// </summary>
[JsonConverter(typeof(RawProductAttributeValueConverter))]
internal class RawProductAttributeValue : BaseProductAttributeValue<object>
internal sealed class RawProductAttributeValue : BaseProductAttributeValue<object>
{
public RawProductAttributeValue(object value)
: base(attributeName: null, value)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace OrchardCore.Commerce.Serialization;

internal class PrioritizedPriceConverter : JsonConverter<PrioritizedPrice>
internal sealed class PrioritizedPriceConverter : JsonConverter<PrioritizedPrice>
{
private const string PriorityName = "priority";
private const string AmountName = "amount";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace OrchardCore.Commerce.Serialization;

internal class ProductAttributeValueConverter : JsonConverter<IProductAttributeValue>
internal sealed class ProductAttributeValueConverter : JsonConverter<IProductAttributeValue>
{
private const string Type = "type";
private const string Value = "value";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace OrchardCore.Commerce.Serialization;

internal class RawProductAttributeValueConverter : JsonConverter<RawProductAttributeValue>
internal sealed class RawProductAttributeValueConverter : JsonConverter<RawProductAttributeValue>
{
public override RawProductAttributeValue Read(
ref Utf8JsonReader reader,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace OrchardCore.Commerce.Serialization;

internal class ShoppingCartItemConverter : JsonConverter<ShoppingCartItem>
internal sealed class ShoppingCartItemConverter : JsonConverter<ShoppingCartItem>
{
private const string QuantityName = "quantity";
private const string SkuName = "sku";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ await GetFieldShapeTypes(contentItem, displayType)
if (_hca.HttpContext is not { } context) throw new InvalidOperationException("Missing HTTP context!");
var returnUrl = context.Request.PathBase + context.Request.Path + context.Request.QueryString;

var editAction = context.Action<TemplateController>(controller => controller.Edit(null, false, returnUrl));
var createAction = context.Action<TemplateController>(controller => controller.Create(null, false, returnUrl));
var editAction = context.ActionTask<TemplateController>(controller => controller.Edit(null, false, returnUrl));
var createAction = context.ActionTask<TemplateController>(controller => controller.Create(null, false, returnUrl));

return GetFieldShapeTypes(contentItem, displayType)
.Select(name =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ await _taxProviders.GetFirstApplicableProviderAsync(promotionAndTaxContext) is {

var total = viewModelLineItems.CalculateTotals().Any()
? viewModelLineItems.CalculateTotals().Single()
: new Amount(0, lineItems.First().LinePrice.Currency);
: new Amount(0, lineItems[0].LinePrice.Currency);

return (viewModelLineItems, total);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Modules/OrchardCore.Commerce/Services/PriceService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public async Task<IList<ShoppingCartItem>> AddPricesAsync(IList<ShoppingCartItem
var applicable = await unhandled.WhereAsync(pair => provider.IsApplicableAsync(new[] { pair.Item }));
if (!applicable.Any()) continue;

unhandled.RemoveAll(pair => applicable.Contains(pair));
unhandled.RemoveAll(applicable.Contains);

var providerResult = await provider.UpdateAsync(applicable.Select(pair => pair.Item).ToList());
handled.AddRange(providerResult.Select((item, index) => (item, applicable[index].Index)));
Expand Down
5 changes: 2 additions & 3 deletions src/Modules/OrchardCore.Commerce/Services/ProductService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public ProductService(

public async Task<IEnumerable<ProductPart>> GetProductsAsync(IEnumerable<string> skus)
{
var trimmedSkus = skus.Select(sku => sku.Split('-').First());
var trimmedSkus = skus.Select(sku => sku.Split('-')[0]);

var contentItemIds = (await _session
.QueryIndex<ProductPartIndex>(index => index.Sku.IsIn(trimmedSkus))
Expand Down Expand Up @@ -67,8 +67,7 @@ public string GetOrderFullSku(ShoppingCartItem item, ProductPart productPart)
public async Task<IEnumerable<ProductPart>> GetProductsByContentItemVersionsAsync(IEnumerable<string> contentItemVersions)
{
// There is no GetVersionAsync that accepts a collection.
var contentItems = await contentItemVersions.AwaitEachAsync(async contentItemVersion =>
await _contentManager.GetVersionAsync(contentItemVersion));
var contentItems = await contentItemVersions.AwaitEachAsync(_contentManager.GetVersionAsync);

// We have to replicate some things that BuildDisplayAsync does to fill part.Elements with the fields. We can't
// use BuildDisplayAsync directly because it requires a BuildDisplayContext.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,7 @@ private async Task<ShoppingCartViewModel> CreateShoppingCartViewModelAsync(
line.UnitPrice = line.UnitPrice.GetRounded();
}

model.Totals.AddRange(
totals.Any() ? totals.Round() : new List<Amount> { new Amount(0, lines.First().LinePrice.Currency) });
model.Totals.AddRange(totals.Any() ? totals.Round() : new List<Amount> { new(0, lines[0].LinePrice.Currency) });

model.Headers.AddRange(headers);
model.Lines.AddRange(lines);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ public async Task<IEnumerable<OrderLineItem>> CreateOrderLineItemsAsync(Shopping
// void."
foreach (var item in shoppingCart.Items)
{
var trimmedSku = item.ProductSku.Split('-').First();
var trimmedSku = item.ProductSku.Split('-')[0];

var contentItemId = (await _session
.QueryIndex<ProductPartIndex>(productPartIndex => productPartIndex.Sku == trimmedSku)
Expand Down
4 changes: 1 addition & 3 deletions src/Modules/OrchardCore.Commerce/Views/Checkout.cshtml
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
@using OrchardCore.Commerce.Controllers;
@using OrchardCore.Commerce.Tax.Extensions
@using OrchardCore.Mvc.Core.Utilities;
DemeSzabolcs marked this conversation as resolved.
Show resolved Hide resolved

@model CheckoutViewModel

Expand Down Expand Up @@ -99,7 +97,7 @@
prop-NetTotal="@Model.NetTotal"
prop-GrossTotal="@Model.GrossTotal"
prop-PublishableKey="@Model.StripePublishableKey"
prop-ClientSecret="@Model.PaymentIntentClientSecret"/>
prop-ClientSecret="@Model.PaymentIntentClientSecret"/>
}
else
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
@using OrchardCore
@using OrchardCore.Commerce.Abstractions
@using OrchardCore.DisplayManagement.TagHelpers

@{
var line = (ShoppingCartLineViewModel)Model.Line;
var attributes = (IList<(IProductAttributeValue Value, string Type, int Index)>)Model.ProductAttributes;
}

<a href="@Orchard.GetItemDisplayUrl(line.Product.ContentItem)" class="link-primary">@line.ProductName</a>
<div class="cart-product-name">
<a href="@Orchard.GetItemDisplayUrl(line.Product.ContentItem)" class="link-primary">@line.ProductName</a>
</div>

@if (line.Attributes?.Any() == true)
{
<ul class="cart-product-attributes list-inline">
Expand Down
Loading