From 3cb3ce69565231d4523381e6b0ea5e1bd3b320fa Mon Sep 17 00:00:00 2001 From: Niek Otten Date: Wed, 15 Jul 2026 12:01:46 +0200 Subject: [PATCH] test(acceptance): beoordeling scenario asserts the workflow task is completed (refs #13) Co-Authored-By: Claude Opus 4.8 (1M context) --- .../Features/EenRegistratieBeoordelen.feature | 2 ++ .../Steps/EenRegistratieBeoordelenSteps.cs | 9 +++++++- tests/acceptance/Support/BffAcceptanceHost.cs | 3 +++ .../acceptance/Support/InMemoryDomainPorts.cs | 23 +++++++++++++++++++ 4 files changed, 36 insertions(+), 1 deletion(-) diff --git a/tests/acceptance/Features/EenRegistratieBeoordelen.feature b/tests/acceptance/Features/EenRegistratieBeoordelen.feature index 7c94fa6..1ff6aec 100644 --- a/tests/acceptance/Features/EenRegistratieBeoordelen.feature +++ b/tests/acceptance/Features/EenRegistratieBeoordelen.feature @@ -15,6 +15,7 @@ Feature: Een registratie beoordelen When the behandelaar decides "goedkeuren" Then the registration has status "INGESCHREVEN" And the zaak's final status is set via the ACL + And the beoordeling task is completed with "goedkeuren" Scenario: Afwijzen wijst de registratie af zonder de ACL Given a submitted registration with an opened zaak @@ -22,3 +23,4 @@ Feature: Een registratie beoordelen And the behandelaar decides "afwijzen" Then the registration has status "AFGEWEZEN" And the ACL is not asked to set the zaak status + And the beoordeling task is completed with "afwijzen" diff --git a/tests/acceptance/Steps/EenRegistratieBeoordelenSteps.cs b/tests/acceptance/Steps/EenRegistratieBeoordelenSteps.cs index 181951d..39bfa3b 100644 --- a/tests/acceptance/Steps/EenRegistratieBeoordelenSteps.cs +++ b/tests/acceptance/Steps/EenRegistratieBeoordelenSteps.cs @@ -16,6 +16,7 @@ public sealed class EenRegistratieBeoordelenSteps { private readonly InMemoryAclClient _acl = new(); private readonly InMemoryRegistrationStore _store = new(); + private readonly InMemoryUserTaskClient _tasks = new(); private RegistrationId _id; [Given("a submitted registration with an opened zaak")] @@ -25,6 +26,8 @@ public sealed class EenRegistratieBeoordelenSteps registration.AttachZaak(InMemoryAclClient.OpenedZaakUrl); await _store.SaveAsync(registration); _id = registration.Id; + // The process has parked at the Beoordelen user task awaiting the behandelaar. + _tasks.Open(_id); } [When("the behandelaar takes it into behandeling")] @@ -37,7 +40,7 @@ public sealed class EenRegistratieBeoordelenSteps [When("the behandelaar decides \"(.*)\"")] public async Task WhenTheBehandelaarDecides(string besluit) - => await new BeoordeelRegistratie(_store, _acl).HandleAsync( + => await new BeoordeelRegistratie(_store, _acl, _tasks).HandleAsync( new BeoordeelRegistratieCommand(_id, Enum.Parse(besluit, ignoreCase: true))); [Then("the registration has status \"(.*)\"")] @@ -55,4 +58,8 @@ public sealed class EenRegistratieBeoordelenSteps [Then("the ACL is not asked to set the zaak status")] public void ThenTheAclIsNotAskedToSetTheZaakStatus() => Assert.Null(_acl.ApprovedZaakUrl); + + [Then("the beoordeling task is completed with \"(.*)\"")] + public void ThenTheBeoordelingTaskIsCompletedWith(string besluit) + => Assert.Equal(Enum.Parse(besluit, ignoreCase: true), _tasks.Completed?.Besluit); } diff --git a/tests/acceptance/Support/BffAcceptanceHost.cs b/tests/acceptance/Support/BffAcceptanceHost.cs index 574a686..b574377 100644 --- a/tests/acceptance/Support/BffAcceptanceHost.cs +++ b/tests/acceptance/Support/BffAcceptanceHost.cs @@ -71,6 +71,9 @@ public sealed class CapturingDomainClient : IDomainClient public Task> GetWerkbakAsync(CancellationToken ct = default) => Task.FromResult>([]); + + public Task DecideAsync(string registrationId, string besluit, CancellationToken ct = default) + => Task.CompletedTask; } /// Serves configurable projection rows. diff --git a/tests/acceptance/Support/InMemoryDomainPorts.cs b/tests/acceptance/Support/InMemoryDomainPorts.cs index fefb2e9..b5714ef 100644 --- a/tests/acceptance/Support/InMemoryDomainPorts.cs +++ b/tests/acceptance/Support/InMemoryDomainPorts.cs @@ -43,6 +43,29 @@ public sealed class InMemoryAclClient : IAclClient } } +/// An in-memory user-task client for the beoordeling acceptance scenario: it holds one open +/// Beoordelen task per registration and records the besluit each is completed with. +public sealed class InMemoryUserTaskClient : IUserTaskClient +{ + private readonly List _open = []; + + public (string TaskId, BeoordelingsBesluit Besluit)? Completed { get; private set; } + + public void Open(RegistrationId registrationId) => _open.Add(new BeoordelingTask($"task-{registrationId}", registrationId)); + + public Task> GetOpenBeoordelingenAsync(CancellationToken ct = default) + => Task.FromResult>(_open); + + public Task ClaimAsync(string taskId, string behandelaar, CancellationToken ct = default) => Task.CompletedTask; + + public Task CompleteBeoordelingAsync(string taskId, BeoordelingsBesluit besluit, CancellationToken ct = default) + { + Completed = (taskId, besluit); + _open.RemoveAll(t => t.TaskId == taskId); + return Task.CompletedTask; + } +} + /// An in-memory registration store for the domain acceptance scenario. public sealed class InMemoryRegistrationStore : IRegistrationStore {