Skip to content

support ticket 31521: money regression issues #434

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

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,17 @@
using commercetools.Base.Client.Error;
using commercetools.Sdk.Api.Client;
using commercetools.Sdk.Api.Models.Carts;
using commercetools.Sdk.Api.Models.Common;
using commercetools.Sdk.Api.Models.Types;
using commercetools.Sdk.GraphQL.Api;
using Xunit;
using static commercetools.Api.IntegrationTests.Cart.CartFixture;
using static commercetools.Api.IntegrationTests.Type.TypeFixtures;
using CartDraft = commercetools.Sdk.Api.Models.Carts.CartDraft;
using CustomFieldsDraft = commercetools.Sdk.Api.Models.Types.CustomFieldsDraft;
using FieldDefinition = commercetools.Sdk.Api.Models.Types.FieldDefinition;
using LocalizedString = commercetools.Sdk.Api.Models.Common.LocalizedString;
using Money = commercetools.Sdk.Api.Models.Common.Money;

namespace commercetools.Api.IntegrationTests.Cart
{
Expand Down Expand Up @@ -184,5 +193,54 @@ await WithUpdateableCart(_client, async cart =>
}
});
}

[Fact]
public async Task TestMoney()
{
var gqlClient = _client.GraphQLClient();
var key = $"GetTypeById-{TestingUtility.RandomString()}";
await WithType(_client, typeDraft =>
{
var draft = DefaultTypeDraftWithKey(typeDraft, key);
draft.FieldDefinitions = new List<IFieldDefinition>()
{
new FieldDefinition()
{
Type = new CustomFieldMoneyType()
{
},
Label = new LocalizedString()
{
{ "en", "money" }
},
Required = false,
Name = "money"
}
};
return draft;
}, async type =>
{
await WithCart(_client, draft =>
{
draft.Currency = "EUR";
draft.Custom = new CustomFieldsDraft()
{
Type = new TypeResourceIdentifier() { Key = type.Key },
Fields = new FieldContainer()
{
{ "money", new MoneyDraft() { CurrencyCode = "EUR", CentAmount = 100 } }
}
};
return draft;
}, async cart =>
{
var retrieveCart = await _client.Carts().WithId(cart.Id).Get().ExecuteAsync();
Assert.IsAssignableFrom<IMoney>(retrieveCart.Custom.Fields["money"]);
var cartId = cart.Id;
var t = await gqlClient.Query(o => o.Cart(id: cartId, selector: cart => new { Custom = cart.Custom(custom => new { Field = custom.CustomFieldsRaw(selector: field => field.Value) }) }));
Assert.NotNull(t);
});
});
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<IsPackable>false</IsPackable>
<UserSecretsId>6e42aa04-1612-4e1c-8bb2-190e5c88343f</UserSecretsId>
<IsTestProject>true</IsTestProject>
Expand Down
Loading