chore(udt-011): register DateOnlyJsonConverter in Program.cs AddJsonOptions

This commit is contained in:
2026-04-18 09:47:19 -03:00
parent a75d2f75a0
commit 3c264aa7a1
2 changed files with 50 additions and 2 deletions

View File

@@ -693,4 +693,46 @@ public sealed class FiscalControllerTests : IAsyncLifetime
Assert.True(json.TryGetProperty("items", out _), "Response must have 'items'");
Assert.True(json.TryGetProperty("total", out _), "Response must have 'total'");
}
// ── UDT-011: DateOnly serialization format ────────────────────────────────
/// <summary>
/// [UDT-011 REQ-BE-JSON-001] POST /iva → vigenciaDesde en respuesta debe ser
/// "yyyy-MM-dd" (e.g. "2025-01-01"), no "2025-01-01T00:00:00" ni con sufijo "Z".
/// Valida que DateOnlyJsonConverter está activo en el pipeline de controllers.
/// </summary>
[Fact]
public async Task CreateIva_VigenciaDesde_SerializesAsDateOnlyString()
{
const string codigo = "IVA_9999";
var token = await GetAdminTokenAsync();
try
{
using var req = BuildRequest(HttpMethod.Post, IvaEndpoint, new
{
codigo,
descripcion = "IVA DateOnly Format Test",
porcentaje = 5.0m,
aplicaIVA = true,
vigenciaDesde = "2025-01-01"
}, token);
var resp = await _client.SendAsync(req);
Assert.Equal(HttpStatusCode.Created, resp.StatusCode);
// Read raw JSON string to inspect format (not deserialized)
var rawJson = await resp.Content.ReadAsStringAsync();
// vigenciaDesde MUST be "2025-01-01" — short date format
Assert.Contains("\"2025-01-01\"", rawJson);
// Must NOT contain datetime format or UTC suffix
Assert.DoesNotContain("T00:00:00", rawJson);
Assert.DoesNotContain("\"2025-01-01Z\"", rawJson);
}
finally
{
await DeleteTipoDeIvaByCodigoAsync(codigo);
}
}
}