backend + web: Monitor attachment storage and download PDFs

This commit is contained in:
GonnaHetzMe committed 2026-12-04 22:25:00 +01:00
1 parent 4f95c8a379
commit 5470818841
6 files changed
+67 -5

No files matched your search

@@ -3,7 +3,10 @@ using System.Net.Http.Headers;
using System.Text;
using System.Text.Json.Nodes;
using Helpdesk.Web.Api;
using Helpdesk.Web.Controllers;
using Helpdesk.Web.Models;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
namespace Helpdesk.Web.Tests;
@@ -136,6 +139,27 @@ public class IssueActionsApiTests
Assert.Equal("image/jpeg", file.ContentType);
}
[Theory]
[InlineData("application/pdf", "attachment")]
[InlineData("image/png", "inline")]
public async Task Web_pdf_stahuje_a_png_zobrazuje_v_prohlizeci(string contentType, string expectedDisposition)
{
using var handler = new RecordingHandler("", response =>
{
response.Content = new ByteArrayContent([1]);
response.Content.Headers.ContentType = new MediaTypeHeaderValue(contentType);
response.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment") { FileNameStar = "příloha" };
});
var context = new DefaultHttpContext();
var controller = new IssuesController(Client(handler)) { ControllerContext = new ControllerContext { HttpContext = context } };
var result = Assert.IsType<FileStreamResult>(await controller.Attachment(9, CancellationToken.None));
using var stream = result.FileStream;
var disposition = ContentDispositionHeaderValue.Parse(context.Response.Headers.ContentDisposition.ToString());
Assert.Equal(expectedDisposition, disposition.DispositionType);
Assert.Equal("příloha", disposition.FileNameStar);
}
[Fact]
public void Chyby_poli_z_API_se_spoji_do_jedne_zpravy()
{