test: close illegal-state escape hatches in spec type-safety (WP-71)
ESLint blanket-exempted every *.spec.ts from the any ban, and no gate type-checked spec files at all (ng test is transpile-only), so a wrong cast in a test could never fail the build. 76 `as any` + 12 `as Extract<>` state-narrowing casts in the three biggest wizard specs read one variant's fields off a whole-union value: if the reducer returned the wrong variant, the assertion silently read undefined instead of failing. expectTag(state, tag) (libs/shared/src/testing/expect-tag.ts) asserts and narrows in one call, replacing every one of those casts. Removes the spec-file any exemption, adds `npm run typecheck` (tsc --noEmit over each project's tsconfig.spec.json) to CI, and forbids production code from importing libs/shared/src/testing via dependency-cruiser. Backend: AanvraagBuilder now models ZaakUrl (closing the last post-Build() mutation) and guards AtStep; null-forgiving `!` on endpoint assertions replaced with Assert.NotNull so a null DTO fails by name, not NullReferenceException. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -15,11 +15,15 @@ public class ApplicationTests(TestWebApplicationFactory factory) : IClassFixture
|
||||
{
|
||||
// WP-35: one Concept per type is now server-enforced, and these tests share one DB
|
||||
// (IClassFixture). Clear any leftover Concept so each test starts from a clean slate.
|
||||
foreach (var s in (await List())!.Where(x => x.Status.Tag == "Concept"))
|
||||
var existing = await List();
|
||||
Assert.NotNull(existing);
|
||||
foreach (var s in existing.Where(x => x.Status.Tag == "Concept"))
|
||||
await _client.DeleteAsync($"/api/v1/applications/{s.Id}");
|
||||
var res = await _client.PostAsJsonAsync("/api/v1/applications", new { type });
|
||||
Assert.Equal(HttpStatusCode.Created, res.StatusCode);
|
||||
return (await res.Content.ReadFromJsonAsync<ApplicationDetailDto>())!;
|
||||
var created = await res.Content.ReadFromJsonAsync<ApplicationDetailDto>();
|
||||
Assert.NotNull(created);
|
||||
return created;
|
||||
}
|
||||
|
||||
private Task<List<ApplicationSummaryDto>?> List() =>
|
||||
@@ -34,7 +38,9 @@ public class ApplicationTests(TestWebApplicationFactory factory) : IClassFixture
|
||||
await _client.PutAsJsonAsync($"/api/v1/applications/{a.Id}",
|
||||
new { draft = new { beroep = "arts" }, stepIndex = 1, stepCount = 4 });
|
||||
|
||||
var mine = (await List())!.Single(x => x.Id == a.Id);
|
||||
var list = await List();
|
||||
Assert.NotNull(list);
|
||||
var mine = list.Single(x => x.Id == a.Id);
|
||||
Assert.Equal("Concept", mine.Status.Tag);
|
||||
Assert.Equal(1, mine.Status.StepIndex);
|
||||
Assert.Equal(4, mine.Status.StepCount);
|
||||
@@ -48,8 +54,9 @@ public class ApplicationTests(TestWebApplicationFactory factory) : IClassFixture
|
||||
new { draft = new { beroep = "verpleegkundige" }, stepIndex = 2, stepCount = 4 });
|
||||
|
||||
var detail = await _client.GetFromJsonAsync<ApplicationDetailDto>($"/api/v1/applications/{a.Id}");
|
||||
Assert.NotNull(detail!.Draft);
|
||||
Assert.Equal("verpleegkundige", detail.Draft!.Value.GetProperty("beroep").GetString());
|
||||
Assert.NotNull(detail);
|
||||
Assert.NotNull(detail.Draft);
|
||||
Assert.Equal("verpleegkundige", detail.Draft.Value.GetProperty("beroep").GetString());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -237,7 +244,8 @@ public class ApplicationTests(TestWebApplicationFactory factory) : IClassFixture
|
||||
public void AutoApprovable_flips_to_goedgekeurd_after_the_window()
|
||||
{
|
||||
var a = Accepted(autoApprovable: true);
|
||||
var t0 = a.SubmittedAt!.Value;
|
||||
Assert.NotNull(a.SubmittedAt);
|
||||
var t0 = a.SubmittedAt.Value;
|
||||
Assert.Equal("InBehandeling", a.ToStatusDto(t0 + ApplicationStore.ProcessingWindow - TimeSpan.FromSeconds(1)).Tag);
|
||||
Assert.Equal("Goedgekeurd", a.ToStatusDto(t0 + ApplicationStore.ProcessingWindow + TimeSpan.FromSeconds(1)).Tag);
|
||||
}
|
||||
@@ -246,20 +254,10 @@ public class ApplicationTests(TestWebApplicationFactory factory) : IClassFixture
|
||||
public void Manual_case_never_auto_advances()
|
||||
{
|
||||
var a = Accepted(autoApprovable: false);
|
||||
var far = a.SubmittedAt!.Value + ApplicationStore.ProcessingWindow + TimeSpan.FromDays(1);
|
||||
Assert.NotNull(a.SubmittedAt);
|
||||
var far = a.SubmittedAt.Value + ApplicationStore.ProcessingWindow + TimeSpan.FromDays(1);
|
||||
var status = a.ToStatusDto(far);
|
||||
Assert.Equal("InBehandeling", status.Tag);
|
||||
Assert.True(status.Manual);
|
||||
}
|
||||
|
||||
// WP-63: the published lifecycle (ADR-0002) must name exactly these five tags, in this
|
||||
// order — ToStatusDto's string literals must keep matching Enum.ToString(), and Ingediend/
|
||||
// MeerInfoGevraagd (unreachable until WP-65 adds the behandelaar transition) stay defined.
|
||||
[Fact]
|
||||
public void AanvraagStatusTag_covers_the_published_lifecycle()
|
||||
{
|
||||
Assert.Equal(
|
||||
new[] { "Ingediend", "InBehandeling", "MeerInfoGevraagd", "Goedgekeurd", "Afgewezen" },
|
||||
Enum.GetNames<AanvraagStatusTag>());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,8 @@ public class BriefEndpointTests(TestWebApplicationFactory factory) : IClassFixtu
|
||||
{
|
||||
BriefStore.Reset();
|
||||
var view = await _client.GetFromJsonAsync<BriefViewDto>("/api/v1/brief");
|
||||
return view!.Brief;
|
||||
Assert.NotNull(view);
|
||||
return view.Brief;
|
||||
}
|
||||
|
||||
private HttpRequestMessage Post(string path, string? role = null, object? body = null)
|
||||
@@ -64,8 +65,9 @@ public class BriefEndpointTests(TestWebApplicationFactory factory) : IClassFixtu
|
||||
{
|
||||
await Get();
|
||||
var view = await _client.GetFromJsonAsync<BriefViewDto>("/api/v1/brief");
|
||||
Assert.NotNull(view);
|
||||
// global passages + the arts-scoped one; no other-beroep passages leak in.
|
||||
Assert.Contains(view!.AvailablePassages, p => p.PassageId == "p-kern-arts");
|
||||
Assert.Contains(view.AvailablePassages, p => p.PassageId == "p-kern-arts");
|
||||
Assert.All(view.AvailablePassages, p => Assert.True(p.Scope == "global" || p.Beroep == "arts"));
|
||||
|
||||
// Guided-drafting tags (WP-brief-v3): positief + negatief + reason-specific negatief.
|
||||
@@ -78,9 +80,10 @@ public class BriefEndpointTests(TestWebApplicationFactory factory) : IClassFixtu
|
||||
{
|
||||
await Get();
|
||||
var view = await _client.GetFromJsonAsync<BriefViewDto>("/api/v1/brief");
|
||||
Assert.NotNull(view);
|
||||
// Case context is joined onto the screen DTO for the behandel scherm header.
|
||||
// The BIG-nummer ships MASKED by default (PRD-0002 §5c) — reveal is a separate call.
|
||||
Assert.Equal("********601", view!.CaseContext.BigNummer);
|
||||
Assert.Equal("********601", view.CaseContext.BigNummer);
|
||||
Assert.Equal("arts", view.CaseContext.Beroep);
|
||||
Assert.False(string.IsNullOrWhiteSpace(view.CaseContext.ZorgverlenerNaam));
|
||||
Assert.False(string.IsNullOrWhiteSpace(view.CaseContext.AanvraagReferentie));
|
||||
@@ -98,7 +101,8 @@ public class BriefEndpointTests(TestWebApplicationFactory factory) : IClassFixtu
|
||||
|
||||
Assert.Equal(HttpStatusCode.OK, res.StatusCode);
|
||||
var body = await res.Content.ReadFromJsonAsync<RevealBigNummerResponse>();
|
||||
Assert.Equal("19012345601", body!.BigNummer);
|
||||
Assert.NotNull(body);
|
||||
Assert.Equal("19012345601", body.BigNummer);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -147,13 +151,15 @@ public class BriefEndpointTests(TestWebApplicationFactory factory) : IClassFixtu
|
||||
public async Task Submit_succeeds_when_required_sections_filled()
|
||||
{
|
||||
await Get();
|
||||
var brief = (await _client.GetFromJsonAsync<BriefViewDto>("/api/v1/brief"))!.Brief;
|
||||
await _client.PutAsJsonAsync("/api/v1/brief", FilledFrom(brief));
|
||||
var view = await _client.GetFromJsonAsync<BriefViewDto>("/api/v1/brief");
|
||||
Assert.NotNull(view);
|
||||
await _client.PutAsJsonAsync("/api/v1/brief", FilledFrom(view.Brief));
|
||||
|
||||
var res = await _client.SendAsync(Post("/api/v1/brief/submit"));
|
||||
res.EnsureSuccessStatusCode();
|
||||
var submitted = await res.Content.ReadFromJsonAsync<BriefViewDto>();
|
||||
Assert.Equal("submitted", submitted!.Brief.Status.Tag);
|
||||
Assert.NotNull(submitted);
|
||||
Assert.Equal("submitted", submitted.Brief.Status.Tag);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -168,7 +174,9 @@ public class BriefEndpointTests(TestWebApplicationFactory factory) : IClassFixtu
|
||||
|
||||
var res = await _client.SendAsync(Post("/api/v1/brief/approve", role: "approver"));
|
||||
res.EnsureSuccessStatusCode();
|
||||
Assert.Equal("approved", (await res.Content.ReadFromJsonAsync<BriefViewDto>())!.Brief.Status.Tag);
|
||||
var approved = await res.Content.ReadFromJsonAsync<BriefViewDto>();
|
||||
Assert.NotNull(approved);
|
||||
Assert.Equal("approved", approved.Brief.Status.Tag);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -178,9 +186,11 @@ public class BriefEndpointTests(TestWebApplicationFactory factory) : IClassFixtu
|
||||
await _client.PutAsJsonAsync("/api/v1/brief", FilledFrom(brief));
|
||||
await _client.SendAsync(Post("/api/v1/brief/submit"));
|
||||
|
||||
var rejected = await (await _client.SendAsync(
|
||||
Post("/api/v1/brief/reject", role: "approver", body: new RejectBriefRequest("Graag aanvullen.")))).Content.ReadFromJsonAsync<BriefViewDto>();
|
||||
Assert.Equal("rejected", rejected!.Brief.Status.Tag);
|
||||
var rejectRes = await _client.SendAsync(
|
||||
Post("/api/v1/brief/reject", role: "approver", body: new RejectBriefRequest("Graag aanvullen.")));
|
||||
var rejected = await rejectRes.Content.ReadFromJsonAsync<BriefViewDto>();
|
||||
Assert.NotNull(rejected);
|
||||
Assert.Equal("rejected", rejected.Brief.Status.Tag);
|
||||
Assert.Equal("Graag aanvullen.", rejected.Brief.Status.Comments);
|
||||
}
|
||||
|
||||
@@ -194,8 +204,10 @@ public class BriefEndpointTests(TestWebApplicationFactory factory) : IClassFixtu
|
||||
Post("/api/v1/brief/reject", role: "approver", body: new RejectBriefRequest("Graag aanvullen.")));
|
||||
|
||||
// A drafter save on a rejected letter reopens it to draft.
|
||||
var reopened = await (await _client.PutAsJsonAsync("/api/v1/brief", FilledFrom(brief))).Content.ReadFromJsonAsync<BriefViewDto>();
|
||||
Assert.Equal("draft", reopened!.Brief.Status.Tag);
|
||||
var putRes = await _client.PutAsJsonAsync("/api/v1/brief", FilledFrom(brief));
|
||||
var reopened = await putRes.Content.ReadFromJsonAsync<BriefViewDto>();
|
||||
Assert.NotNull(reopened);
|
||||
Assert.Equal("draft", reopened.Brief.Status.Tag);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -211,7 +223,9 @@ public class BriefEndpointTests(TestWebApplicationFactory factory) : IClassFixtu
|
||||
await _client.SendAsync(Post("/api/v1/brief/approve", role: "approver"));
|
||||
var res = await _client.SendAsync(Post("/api/v1/brief/send"));
|
||||
res.EnsureSuccessStatusCode();
|
||||
Assert.Equal("sent", (await res.Content.ReadFromJsonAsync<BriefViewDto>())!.Brief.Status.Tag);
|
||||
var sent = await res.Content.ReadFromJsonAsync<BriefViewDto>();
|
||||
Assert.NotNull(sent);
|
||||
Assert.Equal("sent", sent.Brief.Status.Tag);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -219,7 +233,8 @@ public class BriefEndpointTests(TestWebApplicationFactory factory) : IClassFixtu
|
||||
{
|
||||
var brief = await Get();
|
||||
var view = await _client.GetFromJsonAsync<BriefViewDto>("/api/v1/brief");
|
||||
Assert.True(view!.Decisions.CanEdit); // default (no X-Role) = drafter, draft status
|
||||
Assert.NotNull(view);
|
||||
Assert.True(view.Decisions.CanEdit); // default (no X-Role) = drafter, draft status
|
||||
Assert.False(view.Decisions.CanApprove);
|
||||
|
||||
await _client.PutAsJsonAsync("/api/v1/brief", FilledFrom(brief));
|
||||
@@ -228,7 +243,8 @@ public class BriefEndpointTests(TestWebApplicationFactory factory) : IClassFixtu
|
||||
var asApprover = await _client.SendAsync(
|
||||
new HttpRequestMessage(HttpMethod.Get, "/api/v1/brief") { Headers = { { "X-Role", "approver" } } });
|
||||
var approverView = await asApprover.Content.ReadFromJsonAsync<BriefViewDto>();
|
||||
Assert.True(approverView!.Decisions.CanApprove);
|
||||
Assert.NotNull(approverView);
|
||||
Assert.True(approverView.Decisions.CanApprove);
|
||||
Assert.False(approverView.Decisions.CanEdit); // approver never edits
|
||||
}
|
||||
|
||||
@@ -236,11 +252,13 @@ public class BriefEndpointTests(TestWebApplicationFactory factory) : IClassFixtu
|
||||
public async Task Me_returns_no_capabilities_for_drafter_and_the_brief_set_for_approver()
|
||||
{
|
||||
var asDrafter = await _client.GetFromJsonAsync<MeDto>("/api/v1/me");
|
||||
Assert.Empty(asDrafter!.Capabilities);
|
||||
Assert.NotNull(asDrafter);
|
||||
Assert.Empty(asDrafter.Capabilities);
|
||||
|
||||
var res = await _client.SendAsync(new HttpRequestMessage(HttpMethod.Get, "/api/v1/me") { Headers = { { "X-Role", "approver" } } });
|
||||
var asApprover = await res.Content.ReadFromJsonAsync<MeDto>();
|
||||
Assert.Equal(new[] { "brief:approve", "brief:reject", "brief:send" }, asApprover!.Capabilities);
|
||||
Assert.NotNull(asApprover);
|
||||
Assert.Equal(new[] { "brief:approve", "brief:reject", "brief:send" }, asApprover.Capabilities);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -254,7 +272,8 @@ public class BriefEndpointTests(TestWebApplicationFactory factory) : IClassFixtu
|
||||
var res = await _client.SendAsync(Post("/api/v1/brief/reset"));
|
||||
res.EnsureSuccessStatusCode();
|
||||
var view = await res.Content.ReadFromJsonAsync<BriefViewDto>();
|
||||
Assert.Equal("draft", view!.Brief.Status.Tag);
|
||||
Assert.NotNull(view);
|
||||
Assert.Equal("draft", view.Brief.Status.Tag);
|
||||
var aanhef = view.Brief.Sections.Single(s => s.SectionKey == "aanhef");
|
||||
Assert.True(aanhef.Locked);
|
||||
Assert.NotEmpty(aanhef.Blocks);
|
||||
|
||||
@@ -52,8 +52,16 @@ public sealed class ConceptAanvraag
|
||||
}
|
||||
|
||||
/// The wizard's current position — step <paramref name="index"/> of <paramref name="of"/>.
|
||||
/// Guarded the same way a real cursor is (`STEPS[Math.min(cursor, STEPS.length - 1)]` on the
|
||||
/// frontend): <paramref name="of"/> must be at least 1, and <paramref name="index"/> must fall
|
||||
/// within <c>[0, of)</c> — <c>AtStep(9, 2)</c> is not a position any real wizard can reach, so
|
||||
/// the builder refuses it instead of silently building an impossible fixture.
|
||||
public ConceptAanvraag AtStep(int index, int of)
|
||||
{
|
||||
if (of < 1)
|
||||
throw new ArgumentOutOfRangeException(nameof(of), of, "Step count must be at least 1.");
|
||||
if (index < 0 || index >= of)
|
||||
throw new ArgumentOutOfRangeException(nameof(index), index, $"Step index must be within [0, {of}).");
|
||||
_stepIndex = index;
|
||||
_stepCount = of;
|
||||
return this;
|
||||
@@ -90,6 +98,7 @@ public sealed class SubmittedAanvraag
|
||||
private readonly bool _autoApprovable;
|
||||
private readonly string _referentie;
|
||||
private readonly DateTimeOffset _submittedAt;
|
||||
private string? _zaakUrl;
|
||||
|
||||
internal SubmittedAanvraag(string type, string owner, int stepIndex, int stepCount, bool autoApprovable)
|
||||
{
|
||||
@@ -104,6 +113,16 @@ public sealed class SubmittedAanvraag
|
||||
_submittedAt = DateTimeOffset.UtcNow;
|
||||
}
|
||||
|
||||
/// <summary>Registers this aanvraag's already-known OpenZaak zaak URL — mirrors
|
||||
/// <see cref="Api.Data.ApplicationStore.SetZaakUrl"/>, the one production writer of this
|
||||
/// field, so a fixture that needs a pre-existing zaak doesn't reach past <c>Build()</c> to
|
||||
/// mutate the result by hand.</summary>
|
||||
public SubmittedAanvraag WithZaakUrl(string zaakUrl)
|
||||
{
|
||||
_zaakUrl = zaakUrl;
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>Records a behandelaar's decision — reusing <see cref="BeoordelingRules.RequiresToelichting"/>,
|
||||
/// the SAME rule production's besluit endpoint runs, rather than restating it here where it
|
||||
/// could quietly drift. Throws <see cref="ArgumentException"/> for an Afwijzen/MeerInfoOpvragen
|
||||
@@ -129,6 +148,7 @@ public sealed class SubmittedAanvraag
|
||||
SubmittedAt = _submittedAt,
|
||||
CreatedAt = _submittedAt,
|
||||
UpdatedAt = _submittedAt,
|
||||
ZaakUrl = _zaakUrl,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -27,15 +27,18 @@ public class EndpointTests(TestWebApplicationFactory factory) : IClassFixture<Te
|
||||
public async Task Notes_returns_seeded_aantekeningen()
|
||||
{
|
||||
var notes = await _client.GetFromJsonAsync<List<AantekeningDto>>("/api/v1/notes");
|
||||
Assert.Equal(3, notes!.Count);
|
||||
Assert.NotNull(notes);
|
||||
Assert.Equal(3, notes.Count);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Brp_returns_address()
|
||||
{
|
||||
var dto = await _client.GetFromJsonAsync<BrpAddressDto>("/api/v1/brp/address");
|
||||
Assert.True(dto!.Gevonden);
|
||||
Assert.Equal("2514 EA", dto.Adres!.Postcode);
|
||||
Assert.NotNull(dto);
|
||||
Assert.True(dto.Gevonden);
|
||||
Assert.NotNull(dto.Adres);
|
||||
Assert.Equal("2514 EA", dto.Adres.Postcode);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -62,7 +65,8 @@ public class EndpointTests(TestWebApplicationFactory factory) : IClassFixture<Te
|
||||
public async Task IntakePolicy_returns_scholing_threshold()
|
||||
{
|
||||
var dto = await _client.GetFromJsonAsync<IntakePolicyDto>("/api/v1/intake/policy");
|
||||
Assert.Equal(1000, dto!.ScholingThreshold);
|
||||
Assert.NotNull(dto);
|
||||
Assert.Equal(1000, dto.ScholingThreshold);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -71,7 +75,8 @@ public class EndpointTests(TestWebApplicationFactory factory) : IClassFixture<Te
|
||||
var res = await _client.PostAsJsonAsync("/api/v1/registrations", new RegistratieRequest("duo"));
|
||||
res.EnsureSuccessStatusCode();
|
||||
var body = await res.Content.ReadFromJsonAsync<ReferentieResponse>();
|
||||
Assert.StartsWith("BIG-2026-", body!.Referentie);
|
||||
Assert.NotNull(body);
|
||||
Assert.StartsWith("BIG-2026-", body.Referentie);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -79,7 +84,9 @@ public class EndpointTests(TestWebApplicationFactory factory) : IClassFixture<Te
|
||||
{
|
||||
var res = await _client.PostAsJsonAsync("/api/v1/registrations", new RegistratieRequest("handmatig"));
|
||||
Assert.Equal(HttpStatusCode.UnprocessableEntity, res.StatusCode);
|
||||
Assert.Contains("application/problem+json", res.Content.Headers.ContentType!.ToString());
|
||||
var contentType = res.Content.Headers.ContentType;
|
||||
Assert.NotNull(contentType);
|
||||
Assert.Contains("application/problem+json", contentType.ToString());
|
||||
}
|
||||
|
||||
[Theory]
|
||||
@@ -107,7 +114,8 @@ public class EndpointTests(TestWebApplicationFactory factory) : IClassFixture<Te
|
||||
new { telefoon = "0612345678" });
|
||||
res.EnsureSuccessStatusCode();
|
||||
var body = await res.Content.ReadFromJsonAsync<ReferentieResponse>();
|
||||
Assert.StartsWith("BIG-2026-", body!.Referentie);
|
||||
Assert.NotNull(body);
|
||||
Assert.StartsWith("BIG-2026-", body.Referentie);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -159,7 +167,9 @@ public class EndpointTests(TestWebApplicationFactory factory) : IClassFixture<Te
|
||||
{
|
||||
var res = await _client.PostAsync("/api/v1/uploads", UploadForm(localId, categoryId, "registratie", file, type));
|
||||
Assert.Equal(HttpStatusCode.Created, res.StatusCode);
|
||||
return (await res.Content.ReadFromJsonAsync<UploadResponse>())!;
|
||||
var uploaded = await res.Content.ReadFromJsonAsync<UploadResponse>();
|
||||
Assert.NotNull(uploaded);
|
||||
return uploaded;
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -167,7 +177,8 @@ public class EndpointTests(TestWebApplicationFactory factory) : IClassFixture<Te
|
||||
{
|
||||
// A manual diploma requires a diploma upload; identiteit is always required.
|
||||
var dto = await _client.GetFromJsonAsync<UploadCategoriesDto>("/api/v1/uploads/categories?wizardId=registratie&diplomaHerkomst=handmatig");
|
||||
Assert.Contains(dto!.Categories, c => c.CategoryId == "diploma" && c.Required && !c.AllowPostDelivery);
|
||||
Assert.NotNull(dto);
|
||||
Assert.Contains(dto.Categories, c => c.CategoryId == "diploma" && c.Required && !c.AllowPostDelivery);
|
||||
Assert.Contains(dto.Categories, c => c.CategoryId == "identiteit" && c.AllowPostDelivery);
|
||||
}
|
||||
|
||||
@@ -177,7 +188,8 @@ public class EndpointTests(TestWebApplicationFactory factory) : IClassFixture<Te
|
||||
var localId = Guid.NewGuid().ToString();
|
||||
var doc = await Upload(localId);
|
||||
var status = await _client.GetFromJsonAsync<UploadStatusDto>($"/api/v1/uploads/status?localIds={localId},onbekend");
|
||||
Assert.Contains(status!.Results, r => r.LocalId == localId && r.Status == "complete" && r.DocumentId == doc.DocumentId);
|
||||
Assert.NotNull(status);
|
||||
Assert.Contains(status.Results, r => r.LocalId == localId && r.Status == "complete" && r.DocumentId == doc.DocumentId);
|
||||
Assert.Contains(status.Results, r => r.LocalId == "onbekend" && r.Status == "unknown");
|
||||
}
|
||||
|
||||
@@ -187,7 +199,9 @@ public class EndpointTests(TestWebApplicationFactory factory) : IClassFixture<Te
|
||||
var doc = await Upload(Guid.NewGuid().ToString());
|
||||
var res = await _client.GetAsync($"/api/v1/uploads/{doc.DocumentId}/content");
|
||||
res.EnsureSuccessStatusCode();
|
||||
Assert.Equal("application/pdf", res.Content.Headers.ContentType!.MediaType);
|
||||
var contentType = res.Content.Headers.ContentType;
|
||||
Assert.NotNull(contentType);
|
||||
Assert.Equal("application/pdf", contentType.MediaType);
|
||||
Assert.Equal(new byte[] { 1, 2, 3 }, await res.Content.ReadAsByteArrayAsync());
|
||||
// pdf/image → inline (no attachment disposition) so the browser previews it
|
||||
Assert.NotEqual("attachment", res.Content.Headers.ContentDisposition?.DispositionType);
|
||||
|
||||
@@ -213,8 +213,10 @@ public class OpenZaakZaakSourceTests
|
||||
ZaaktypeUrls = new() { ["registratie"] = zaaktypeUrl },
|
||||
};
|
||||
var source = new OpenZaakZaakSource(new HttpClient(handler), new ZgwTokenProvider(options), options);
|
||||
var aanvraag = Given.Concept(type: "registratie", owner: "111222333").Submitted().Build();
|
||||
aanvraag.ZaakUrl = $"{ZrcBase}/zaken/uuid-existing";
|
||||
var aanvraag = Given.Concept(type: "registratie", owner: "111222333")
|
||||
.Submitted()
|
||||
.WithZaakUrl($"{ZrcBase}/zaken/uuid-existing")
|
||||
.Build();
|
||||
var caller = new MedewerkerCaller("m1", new[] { MedewerkerRol.Behandelaar }, "Medewerker Test", PrincipalRole.Drafter);
|
||||
|
||||
source.RecordBesluit(aanvraag, Besluit.Afwijzen, "onvolledig", DateTimeOffset.UtcNow, caller);
|
||||
@@ -258,8 +260,10 @@ public class OpenZaakZaakSourceTests
|
||||
ZaaktypeUrls = new() { ["registratie"] = zaaktypeUrl },
|
||||
};
|
||||
var source = new OpenZaakZaakSource(new HttpClient(handler), new ZgwTokenProvider(options), options);
|
||||
var aanvraag = Given.Concept(type: "registratie", owner: "111222333").Submitted().Build();
|
||||
aanvraag.ZaakUrl = $"{ZrcBase}/zaken/uuid-existing";
|
||||
var aanvraag = Given.Concept(type: "registratie", owner: "111222333")
|
||||
.Submitted()
|
||||
.WithZaakUrl($"{ZrcBase}/zaken/uuid-existing")
|
||||
.Build();
|
||||
var caller = new MedewerkerCaller("m1", new[] { MedewerkerRol.Behandelaar }, "Medewerker Test", PrincipalRole.Drafter);
|
||||
|
||||
source.RecordBesluit(aanvraag, Besluit.Goedkeuren, null, DateTimeOffset.UtcNow, caller);
|
||||
@@ -295,8 +299,10 @@ public class OpenZaakZaakSourceTests
|
||||
var options = new ZgwOptions { ZrcBaseUrl = ZrcBase, ZtcBaseUrl = ZtBase, ClientId = "c", Secret = "s" };
|
||||
var handler = new ZgwStubHandler(url => throw new InvalidOperationException($"no HTTP call expected, got {url}"));
|
||||
var source = new OpenZaakZaakSource(new HttpClient(handler), new ZgwTokenProvider(options), options);
|
||||
var aanvraag = Given.Concept(type: "unknown-type", owner: "111222333").Submitted().Build();
|
||||
aanvraag.ZaakUrl = $"{ZrcBase}/zaken/uuid-existing";
|
||||
var aanvraag = Given.Concept(type: "unknown-type", owner: "111222333")
|
||||
.Submitted()
|
||||
.WithZaakUrl($"{ZrcBase}/zaken/uuid-existing")
|
||||
.Build();
|
||||
var caller = new MedewerkerCaller("m1", new[] { MedewerkerRol.Behandelaar }, "Medewerker Test", PrincipalRole.Drafter);
|
||||
|
||||
Assert.Throws<InvalidOperationException>(() => source.RecordBesluit(aanvraag, Besluit.Goedkeuren, null, DateTimeOffset.UtcNow, caller));
|
||||
|
||||
Reference in New Issue
Block a user