backend: Expand backend integration test coverage
This commit is contained in:
1 parent
ce04c8beb3
commit
32bc5a4691
8 files changed
+500
-19
No files matched your search
@@ -1,4 +1,5 @@
|
||||
using Helpdesk.Api.Controllers;
|
||||
using System.Text.Json;
|
||||
using Helpdesk.Infrastructure.Persistence;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
@@ -42,6 +43,24 @@ public sealed class DatabaseTests(BackendFixture fixture) : IClassFixture<Backen
|
||||
await db.PushDevices.AsNoTracking().ToListAsync(Cancellation);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task OpenApiDescribesMultipartIssueRequests()
|
||||
{
|
||||
using var client = fixture.CreateClient();
|
||||
using var document = await ReadAsync<JsonDocument>(client.GetAsync("/swagger/v1/swagger.json", Cancellation));
|
||||
var paths = document.RootElement.GetProperty("paths");
|
||||
var create = paths.GetProperty("/api/v1/issues").GetProperty("post").GetProperty("requestBody").GetProperty("content");
|
||||
Assert.True(create.TryGetProperty("application/json", out _));
|
||||
var createSchema = create.GetProperty("multipart/form-data").GetProperty("schema");
|
||||
Assert.Contains(createSchema.GetProperty("required").EnumerateArray(), field => field.GetString() == "categoryId");
|
||||
var uploadSchema = paths.GetProperty("/api/v1/issues/{id}/attachments").GetProperty("post")
|
||||
.GetProperty("requestBody").GetProperty("content").GetProperty("multipart/form-data").GetProperty("schema");
|
||||
Assert.Equal("files", Assert.Single(uploadSchema.GetProperty("required").EnumerateArray()).GetString());
|
||||
var files = uploadSchema.GetProperty("properties").GetProperty("files");
|
||||
Assert.Equal(5, files.GetProperty("maxItems").GetInt32());
|
||||
Assert.Equal("binary", files.GetProperty("items").GetProperty("format").GetString());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task DatabaseRejectsAnAssignedIssueWithoutAnAssignee()
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user