display my queries
This commit is contained in:
parent
341b49cbfa
commit
d5b2930092
11 changed files with 691 additions and 43 deletions
|
|
@ -132,15 +132,71 @@ public class BillingCommandPageViewModelTests
|
|||
Assert.Equal(22, prestations[1].GetProperty("PrestationId").GetInt32());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task InitializeAsync_with_existing_brush_query_prefills_and_submit_updates_query()
|
||||
{
|
||||
var api = new RecordingApi
|
||||
{
|
||||
HairPrestations = new List<HairPrestationDto>
|
||||
{
|
||||
new() { Id = 30, Title = "Femme · Cheveux longs", Details = "Coupe · Brushing" },
|
||||
new() { Id = 31, Title = "Homme · Cheveux courts", Details = "Coupe" },
|
||||
}
|
||||
};
|
||||
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);
|
||||
|
||||
await vm.InitializeAsync(new BillingQueryDetailsDto
|
||||
{
|
||||
Id = 77,
|
||||
BillingCode = "Brush",
|
||||
ActivityCode = "brush",
|
||||
PerformerId = "perf-2",
|
||||
ClientId = "cli-1",
|
||||
EventDate = new DateTime(2026, 9, 2, 14, 30, 0, DateTimeKind.Utc),
|
||||
Consent = true,
|
||||
Status = QueryStatus.Accepted,
|
||||
PrestationId = 30,
|
||||
AdditionalInfo = "Ancienne note",
|
||||
Location = new BillingLocationDto
|
||||
{
|
||||
Address = "1 rue du Test",
|
||||
Latitude = 48.8566,
|
||||
Longitude = 2.3522,
|
||||
}
|
||||
});
|
||||
|
||||
vm.SelectedPrestation = vm.AvailablePrestations[1];
|
||||
vm.AdditionalInfo = "Note mise à jour";
|
||||
await vm.SubmitCommand.ExecuteAsync(null);
|
||||
|
||||
Assert.Equal(HttpMethod.Put, api.LastMethod);
|
||||
Assert.Equal("https://business.example/api/v1/billing/Brush/77", api.LastPath);
|
||||
Assert.True(vm.IsEditingExisting);
|
||||
Assert.Equal("Mettre à jour la commande", vm.SubmitLabel);
|
||||
|
||||
using var json = JsonDocument.Parse(JsonSerializer.Serialize(api.LastBody));
|
||||
Assert.Equal(77, json.RootElement.GetProperty("Id").GetInt32());
|
||||
Assert.Equal(31, json.RootElement.GetProperty("PrestationId").GetInt32());
|
||||
Assert.Equal("Note mise à jour", json.RootElement.GetProperty("AdditionalInfo").GetString());
|
||||
Assert.Equal((int)QueryStatus.Accepted, json.RootElement.GetProperty("Status").GetInt32());
|
||||
}
|
||||
|
||||
private sealed class RecordingApi : IYavscApiClient
|
||||
{
|
||||
public HttpClient Http { get; } = new();
|
||||
public HttpMethod? LastMethod { get; private set; }
|
||||
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)
|
||||
{
|
||||
LastMethod = method;
|
||||
LastPath = path;
|
||||
LastBody = body;
|
||||
if (typeof(T) == typeof(List<HairPrestationDto>))
|
||||
|
|
@ -152,6 +208,7 @@ public class BillingCommandPageViewModelTests
|
|||
|
||||
public Task CallAsync(HttpMethod method, string path, object? body = null, CancellationToken ct = default)
|
||||
{
|
||||
LastMethod = method;
|
||||
LastPath = path;
|
||||
LastBody = body;
|
||||
return Task.CompletedTask;
|
||||
|
|
|
|||
|
|
@ -22,9 +22,33 @@ public class BillingQueriesPageViewModelTests
|
|||
await vm.InitializeAsync();
|
||||
|
||||
Assert.Equal("https://business.example/api/v1/billing/Rdv", api.Paths.Single());
|
||||
Assert.Equal(1, vm.Queries.Count);
|
||||
Assert.Equal("Rendez-vous #1", vm.Queries[0].Description);
|
||||
Assert.Contains("1 commande", vm.StatusMessage, StringComparison.OrdinalIgnoreCase);
|
||||
Assert.Equal(3, vm.Queries.Count);
|
||||
Assert.Contains(vm.Queries, q => q.Description == "Rendez-vous #1");
|
||||
Assert.Contains("3 commande", vm.StatusMessage, StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task RefreshAsync_in_readonly_ongoing_mode_keeps_only_ongoing_statuses_and_disables_open()
|
||||
{
|
||||
var api = new StubBillingApi();
|
||||
var client = new BillingApiClient(api, "https://business.example/api/v1/");
|
||||
var vm = new BillingQueriesPageViewModel(
|
||||
new ActivityBrowseItemDto { Code = "dev", Name = "Développement" },
|
||||
new ActivityUserDisplayItem { PerformerId = "perf-1", UserName = "Alice" },
|
||||
new CommandFormSummaryDto { Id = 1, ActionName = "Rdv", Title = "Rendez-vous" },
|
||||
client,
|
||||
isReadOnly: true,
|
||||
ongoingOnly: true);
|
||||
|
||||
await vm.InitializeAsync();
|
||||
|
||||
Assert.Equal(2, vm.Queries.Count);
|
||||
Assert.All(vm.Queries, q => Assert.DoesNotContain("Rejected", q.StatusLabel, StringComparison.OrdinalIgnoreCase));
|
||||
Assert.Contains("lecture seule", vm.StatusMessage, StringComparison.OrdinalIgnoreCase);
|
||||
Assert.False(vm.CanOpenDetails);
|
||||
|
||||
vm.SelectedQuery = vm.Queries[0];
|
||||
Assert.False(vm.OpenSelectedQueryCommand.CanExecute(null));
|
||||
}
|
||||
|
||||
private sealed class StubBillingApi : IYavscApiClient
|
||||
|
|
@ -70,6 +94,26 @@ public class BillingQueriesPageViewModelTests
|
|||
Status = QueryStatus.Accepted,
|
||||
Description = "Autre performer",
|
||||
EventDate = new DateTime(2026, 9, 3, 10, 0, 0, DateTimeKind.Utc),
|
||||
},
|
||||
new()
|
||||
{
|
||||
Id = 14,
|
||||
ActivityCode = "dev",
|
||||
PerformerId = "perf-1",
|
||||
ClientId = "cli-1",
|
||||
Status = QueryStatus.InProgress,
|
||||
Description = "En cours",
|
||||
EventDate = new DateTime(2026, 9, 4, 10, 0, 0, DateTimeKind.Utc),
|
||||
},
|
||||
new()
|
||||
{
|
||||
Id = 15,
|
||||
ActivityCode = "dev",
|
||||
PerformerId = "perf-1",
|
||||
ClientId = "cli-1",
|
||||
Status = QueryStatus.Rejected,
|
||||
Description = "Rejetée",
|
||||
EventDate = new DateTime(2026, 9, 5, 10, 0, 0, DateTimeKind.Utc),
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue