fix(api): ExceptionFilter 409 para ProductTypeInactivo y RubroInactivo (PRD-002 W1)
This commit is contained in:
@@ -336,4 +336,32 @@ public sealed class ProductsControllerTests : IAsyncLifetime
|
||||
var resp = await _client.SendAsync(req);
|
||||
Assert.Equal(HttpStatusCode.NotFound, resp.StatusCode);
|
||||
}
|
||||
|
||||
// ── PRD-002 W1: ExceptionFilter 409 for ProductTypeInactivo ──────────────
|
||||
|
||||
[Fact]
|
||||
public async Task Create_WithInactiveProductType_Returns409()
|
||||
{
|
||||
var token = await GetAdminTokenAsync();
|
||||
var (medioId, productTypeId) = await EnsureMedioAndProductTypeAsync(token);
|
||||
|
||||
// Deactivate the ProductType first
|
||||
using var deactivatePtReq = BuildRequest(HttpMethod.Delete, $"/api/v1/admin/product-types/{productTypeId}", bearerToken: token);
|
||||
var deactivatePtResp = await _client.SendAsync(deactivatePtReq);
|
||||
Assert.Equal(HttpStatusCode.NoContent, deactivatePtResp.StatusCode);
|
||||
|
||||
// Now attempt to create a product with the inactive ProductType
|
||||
using var createReq = BuildRequest(HttpMethod.Post, AdminEndpoint, new
|
||||
{
|
||||
nombre = $"Prod_{Guid.NewGuid():N}"[..28],
|
||||
medioId,
|
||||
productTypeId,
|
||||
basePrice = 50m
|
||||
}, token);
|
||||
var createResp = await _client.SendAsync(createReq);
|
||||
|
||||
Assert.Equal(HttpStatusCode.Conflict, createResp.StatusCode);
|
||||
var body = await createResp.Content.ReadFromJsonAsync<JsonElement>();
|
||||
Assert.Equal("product_type_inactivo", body.GetProperty("error").GetString());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user