hitting the performer
This commit is contained in:
parent
fbc72f0c85
commit
341b49cbfa
27 changed files with 1603 additions and 35 deletions
|
|
@ -4,6 +4,7 @@ using PostIt.ViewModels;
|
|||
using Yavsc;
|
||||
using Yavsc.Abstract.Workflow;
|
||||
using Yavsc.Api.Client;
|
||||
using Yavsc.Models.Haircut;
|
||||
|
||||
namespace PostIt.Tests;
|
||||
|
||||
|
|
@ -46,9 +47,9 @@ public class BillingCommandPageViewModelTests
|
|||
var api = new RecordingApi();
|
||||
var client = new BillingApiClient(api, "https://business.example/api/v1/");
|
||||
var vm = new BillingCommandPageViewModel(
|
||||
new ActivityBrowseItemDto { Code = "brush", Name = "Brush" },
|
||||
new ActivityBrowseItemDto { Code = "book", Name = "Book" },
|
||||
new ActivityUserDisplayItem { PerformerId = "perf-2", UserName = "Bob" },
|
||||
new CommandFormSummaryDto { Id = 13, ActionName = "Brush", Title = "Coupe" },
|
||||
new CommandFormSummaryDto { Id = 13, ActionName = "Book", Title = "Réservation" },
|
||||
client);
|
||||
|
||||
await vm.SubmitCommand.ExecuteAsync(null);
|
||||
|
|
@ -57,16 +58,95 @@ public class BillingCommandPageViewModelTests
|
|||
Assert.Contains("n'est pas encore pris en charge", vm.StatusMessage, StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task InitializeAsync_loads_prestations_for_brush_and_submit_posts_selected_prestation()
|
||||
{
|
||||
var api = new RecordingApi
|
||||
{
|
||||
HairPrestations = new List<HairPrestationDto>
|
||||
{
|
||||
new() { Id = 10, Title = "Femme · Cheveux mi-longs", Details = "Coupe · Brushing" },
|
||||
new() { Id = 11, Title = "Homme · Cheveux courts", Details = "Coupe · Coiffage" },
|
||||
}
|
||||
};
|
||||
var client = new BillingApiClient(api, "https://business.example/api/v1/");
|
||||
var vm = new BillingCommandPageViewModel(
|
||||
new ActivityBrowseItemDto { Code = "brush", Name = "Brush" },
|
||||
new ActivityUserDisplayItem { PerformerId = "perf-2", UserName = "Bob" },
|
||||
new CommandFormSummaryDto { Id = 13, ActionName = "Brush", Title = "Coupe" },
|
||||
client)
|
||||
{
|
||||
EventDateText = "2026-09-02 14:30",
|
||||
Address = "1 rue du Test",
|
||||
LatitudeText = "48.8566",
|
||||
LongitudeText = "2.3522",
|
||||
Consent = true,
|
||||
AdditionalInfo = "Prévoir shampoing",
|
||||
};
|
||||
|
||||
await vm.InitializeAsync();
|
||||
vm.SelectedPrestation = vm.AvailablePrestations[1];
|
||||
await vm.SubmitCommand.ExecuteAsync(null);
|
||||
|
||||
Assert.Equal("https://business.example/api/v1/billing/Brush", api.LastPath);
|
||||
using var json = JsonDocument.Parse(JsonSerializer.Serialize(api.LastBody));
|
||||
Assert.Equal(11, json.RootElement.GetProperty("PrestationId").GetInt32());
|
||||
Assert.Equal("Prévoir shampoing", json.RootElement.GetProperty("AdditionalInfo").GetString());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task InitializeAsync_loads_prestations_for_mbrush_and_submit_posts_selected_prestations()
|
||||
{
|
||||
var api = new RecordingApi
|
||||
{
|
||||
HairPrestations = new List<HairPrestationDto>
|
||||
{
|
||||
new() { Id = 21, Title = "Femme · Cheveux longs", Details = "Coupe · Couleur" },
|
||||
new() { Id = 22, Title = "Enfant · Cheveux courts", Details = "Coupe · Sans technique" },
|
||||
}
|
||||
};
|
||||
var client = new BillingApiClient(api, "https://business.example/api/v1/");
|
||||
var vm = new BillingCommandPageViewModel(
|
||||
new ActivityBrowseItemDto { Code = "mbrush", Name = "MBrush" },
|
||||
new ActivityUserDisplayItem { PerformerId = "perf-3", UserName = "Cara" },
|
||||
new CommandFormSummaryDto { Id = 14, ActionName = "MBrush", Title = "Coupe groupée" },
|
||||
client)
|
||||
{
|
||||
EventDateText = "2026-09-03 10:00",
|
||||
Address = "2 rue du Test",
|
||||
LatitudeText = "48.8567",
|
||||
LongitudeText = "2.3523",
|
||||
Consent = true,
|
||||
};
|
||||
|
||||
await vm.InitializeAsync();
|
||||
vm.MultiPrestations[0].IsSelected = true;
|
||||
vm.MultiPrestations[1].IsSelected = true;
|
||||
await vm.SubmitCommand.ExecuteAsync(null);
|
||||
|
||||
Assert.Equal("https://business.example/api/v1/billing/MBrush", api.LastPath);
|
||||
using var json = JsonDocument.Parse(JsonSerializer.Serialize(api.LastBody));
|
||||
var prestations = json.RootElement.GetProperty("Prestations");
|
||||
Assert.Equal(2, prestations.GetArrayLength());
|
||||
Assert.Equal(21, prestations[0].GetProperty("PrestationId").GetInt32());
|
||||
Assert.Equal(22, prestations[1].GetProperty("PrestationId").GetInt32());
|
||||
}
|
||||
|
||||
private sealed class RecordingApi : IYavscApiClient
|
||||
{
|
||||
public HttpClient Http { get; } = new();
|
||||
public string? LastPath { get; private set; }
|
||||
public object? LastBody { get; private set; }
|
||||
public List<HairPrestationDto>? HairPrestations { get; init; }
|
||||
|
||||
public Task<T> CallAsync<T>(HttpMethod method, string path, object? body = null, CancellationToken ct = default)
|
||||
{
|
||||
LastPath = path;
|
||||
LastBody = body;
|
||||
if (typeof(T) == typeof(List<HairPrestationDto>))
|
||||
{
|
||||
return Task.FromResult((T)(object)(HairPrestations ?? new List<HairPrestationDto>()));
|
||||
}
|
||||
return Task.FromResult(default(T)!);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue