From e35c60df44209e63e6982d73f89a70aa97182c48 Mon Sep 17 00:00:00 2001 From: Einar Date: Thu, 23 Jul 2026 17:47:14 +0200 Subject: [PATCH] Add a fully auto-mapped projection to the invoicing sample The sample showed AutoMap being disabled and overridden but never the default working on its own. The new CancelledInvoices archive slice projects InvoiceCancelled with zero explicit mappings - the strongest demonstration that AutoMap is the default and explicit mappings are the exception. Co-Authored-By: Claude Opus 4.8 (1M context) --- .../Screenplay/for_ScreenplayCompiler/invoicing.play | 11 +++++++++++ .../when_compiling_the_invoicing_sample.cs | 3 ++- .../Monaco/screenplay-editor/samples/invoicing.play | 11 +++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/Source/DotNET/Screenplay/for_ScreenplayCompiler/invoicing.play b/Source/DotNET/Screenplay/for_ScreenplayCompiler/invoicing.play index a8a052d..d6fc3ef 100644 --- a/Source/DotNET/Screenplay/for_ScreenplayCompiler/invoicing.play +++ b/Source/DotNET/Screenplay/for_ScreenplayCompiler/invoicing.play @@ -677,6 +677,17 @@ module Invoicing screen InvoiceLineReport file Screens/InvoiceLineReport.tsx + slice StateView CancelledInvoices + description "Archive of cancelled invoices - every property auto-maps from the event" + + query ListCancelledInvoices => CancelledInvoiceReadModel[] + authorize IsAccountant + + // No explicit mappings needed - AutoMap is on by default and copies + // every matching property from InvoiceCancelled onto the read model. + projection CancelledInvoices => CancelledInvoiceReadModel + from InvoiceCancelled + slice StateView InvoiceDashboard query GetInvoiceSummary => InvoiceSummaryReadModel diff --git a/Source/DotNET/Screenplay/for_ScreenplayCompiler/when_compiling_the_invoicing_sample.cs b/Source/DotNET/Screenplay/for_ScreenplayCompiler/when_compiling_the_invoicing_sample.cs index e6175f1..daae6dd 100644 --- a/Source/DotNET/Screenplay/for_ScreenplayCompiler/when_compiling_the_invoicing_sample.cs +++ b/Source/DotNET/Screenplay/for_ScreenplayCompiler/when_compiling_the_invoicing_sample.cs @@ -45,7 +45,8 @@ void Because() [Fact] void should_have_the_command_description() => RegisterCommand.Description.ShouldEqual("Registers a new invoice with its lines and payment terms"); [Fact] void should_have_both_layouts() => _result.Value!.Modules.Single().Layouts.Count().ShouldEqual(2); [Fact] void should_have_the_master_detail_slots() => _result.Value!.Modules.Single().Layouts.First().Slots.ShouldContainOnly("sidebar", "main"); - [Fact] void should_have_all_slices() => _feature.Slices.Count().ShouldEqual(13); + [Fact] void should_have_all_slices() => _feature.Slices.Count().ShouldEqual(14); + [Fact] void should_have_the_fully_auto_mapped_projection() => Slice("CancelledInvoices").Projection!.Blocks.OfType().Single().Mappings.ShouldBeEmpty(); [Fact] void should_have_the_nested_feature() => _feature.Features.Single().Name.ShouldEqual("Adjustments"); [Fact] void should_have_the_nested_feature_slices() => _feature.Features.Single().Slices.Select(_ => _.Name).ShouldContainOnly("ApplyDiscount", "WriteOffInvoice"); [Fact] void should_parse_conditional_produces() => RegisterCommand.Produces.Count(_ => _.When is not null).ShouldEqual(4); diff --git a/Source/Screenplay/Monaco/screenplay-editor/samples/invoicing.play b/Source/Screenplay/Monaco/screenplay-editor/samples/invoicing.play index a8a052d..d6fc3ef 100644 --- a/Source/Screenplay/Monaco/screenplay-editor/samples/invoicing.play +++ b/Source/Screenplay/Monaco/screenplay-editor/samples/invoicing.play @@ -677,6 +677,17 @@ module Invoicing screen InvoiceLineReport file Screens/InvoiceLineReport.tsx + slice StateView CancelledInvoices + description "Archive of cancelled invoices - every property auto-maps from the event" + + query ListCancelledInvoices => CancelledInvoiceReadModel[] + authorize IsAccountant + + // No explicit mappings needed - AutoMap is on by default and copies + // every matching property from InvoiceCancelled onto the read model. + projection CancelledInvoices => CancelledInvoiceReadModel + from InvoiceCancelled + slice StateView InvoiceDashboard query GetInvoiceSummary => InvoiceSummaryReadModel