diff --git a/services/acl/Acl.IntegrationTests/OpenZaakFixture.cs b/services/acl/Acl.IntegrationTests/OpenZaakFixture.cs index a743913..32dece6 100644 --- a/services/acl/Acl.IntegrationTests/OpenZaakFixture.cs +++ b/services/acl/Acl.IntegrationTests/OpenZaakFixture.cs @@ -77,6 +77,18 @@ public sealed class OpenZaakFixture : IDisposable return JsonDocument.Parse(json).RootElement.Clone(); } + /// The URL of the published "Diploma" informatieobjecttype (S-10b), or null when the + /// stack has not been seeded with OZ_PUBLISH=1. `status=definitief` returns published types only. + public async Task FindPublishedDiplomaInformatieobjecttypeAsync(CancellationToken ct = default) + { + var query = new Uri(BaseUrl, "/catalogi/api/v1/informatieobjecttypen?status=definitief"); + var page = await GetJsonAsync(query, ct); + foreach (var iot in page.GetProperty("results").EnumerateArray()) + if (iot.TryGetProperty("omschrijving", out var o) && o.GetString() == "Diploma") + return new Uri(iot.GetProperty("url").GetString()!); + return null; + } + /// The zaaktype's eindstatus (terminal statustype) URL — the one an approval sets. public async Task FindEindstatustypeAsync(Uri zaaktypeUrl, CancellationToken ct = default) { diff --git a/services/acl/Acl.IntegrationTests/OpenZaakGatewayIntegrationTests.cs b/services/acl/Acl.IntegrationTests/OpenZaakGatewayIntegrationTests.cs index 9cdac3c..1a7a87a 100644 --- a/services/acl/Acl.IntegrationTests/OpenZaakGatewayIntegrationTests.cs +++ b/services/acl/Acl.IntegrationTests/OpenZaakGatewayIntegrationTests.cs @@ -74,4 +74,55 @@ public sealed class OpenZaakGatewayIntegrationTests(OpenZaakFixture stack) var eindstatustype = await stack.FindEindstatustypeAsync(zaaktype!); Assert.Equal(eindstatustype.ToString(), status.GetProperty("statustype").GetString()); } + + [Fact] + public async Task Storing_a_diploma_creates_a_real_informatieobject_related_to_the_zaak() + { + var zaaktype = await stack.FindPublishedBigZaaktypeAsync(); + Assert.True(zaaktype is not null, + "No published BIG-REGISTRATIE zaaktype found — seed the stack with OZ_PUBLISH=1."); + var informatieobjecttype = await stack.FindPublishedDiplomaInformatieobjecttypeAsync(); + Assert.True(informatieobjecttype is not null, + "No published Diploma informatieobjecttype found — seed the stack with OZ_PUBLISH=1."); + + var gateway = new OpenZaakGateway(stack.Http, stack.Options); + var zaakUrl = await gateway.OpenZaakAsync(new ZaakRequest( + Bronorganisatie: "517439943", + VerantwoordelijkeOrganisatie: "517439943", + Vertrouwelijkheidaanduiding: "openbaar", + Zaaktype: zaaktype!, + Startdatum: DateOnly.FromDateTime(DateTime.UtcNow), + Identificatie: Guid.NewGuid().ToString())); + + var content = System.Text.Encoding.UTF8.GetBytes("%PDF-1.4 synthetic diploma\n"); + var documentUrl = await gateway.StoreDocumentAsync(new DocumentRequest( + Bronorganisatie: "517439943", + Informatieobjecttype: informatieobjecttype!, + Vertrouwelijkheidaanduiding: "openbaar", + Zaak: zaakUrl, + Creatiedatum: DateOnly.FromDateTime(DateTime.UtcNow), + Titel: "Diploma", + Auteur: "zorgprofessional", + Taal: "nld", + Bestandsnaam: "diploma.pdf", + Formaat: "application/pdf", + Inhoud: content)); + + // The gateway returns the canonical informatieobject URL... + Assert.StartsWith( + new Uri(stack.BaseUrl, "/documenten/api/v1/enkelvoudiginformatieobjecten/").ToString(), + documentUrl.ToString()); + + // ...the document is really persisted with the default-filled fields... + var doc = await stack.GetJsonAsync(documentUrl); + Assert.Equal("diploma.pdf", doc.GetProperty("bestandsnaam").GetString()); + Assert.Equal(informatieobjecttype.ToString(), doc.GetProperty("informatieobjecttype").GetString()); + Assert.Equal(content.Length, doc.GetProperty("bestandsomvang").GetInt32()); + + // ...and it is related to the zaak (a zaakinformatieobject links the two). + var relations = await stack.GetJsonAsync(new Uri(stack.BaseUrl, + "/zaken/api/v1/zaakinformatieobjecten?informatieobject=" + Uri.EscapeDataString(documentUrl.ToString()))); + Assert.Contains(relations.EnumerateArray(), + r => r.GetProperty("zaak").GetString() == zaakUrl.ToString()); + } } diff --git a/tests/e2e/registration.spec.ts b/tests/e2e/registration.spec.ts index b508352..8274ecb 100644 --- a/tests/e2e/registration.spec.ts +++ b/tests/e2e/registration.spec.ts @@ -56,6 +56,11 @@ test('DigiD submit → public INGEDIEND → documenten → behandelaar goedkeurt // why we supply the documents here rather than right after submit, when the trigger would race the // wait and no-op. (S-10b turns this into a real file upload; here it is the trigger that unblocks // beoordeling.) + await page.setInputFiles('#diploma', { + name: 'diploma.pdf', + mimeType: 'application/pdf', + buffer: Buffer.from('%PDF-1.4 synthetic diploma\n'), + }); await page.getByRole('button', { name: /documenten aanleveren/i }).click(); await expect(page.getByText(/documenten zijn aangeleverd/i)).toBeVisible();