From c29862ac732f876bd344c7e33cf374fdaac5984a Mon Sep 17 00:00:00 2001 From: delchev Date: Tue, 4 Aug 2026 15:34:02 +0300 Subject: [PATCH] test(intent): lock the .print scaffold's authored-wins semantics (#6497) The generator already emits doc/Templates//Print/en/standard.print through writeModelFileIfAbsent (generate-once, like the developer-owned .settings) and the CMS seeding is create-if-absent - but nothing locked that contract, so a regression could silently reintroduce clobbering a hand-improved template. The new IntentEngineIT case regenerates a project with a hand-edited standard.print and asserts it survives byte-identical, and that a fresh project still receives the scaffold. Co-Authored-By: Claude Fable 5 --- .../integration/tests/api/IntentEngineIT.java | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tests/tests-integrations/src/main/java/org/eclipse/dirigible/integration/tests/api/IntentEngineIT.java b/tests/tests-integrations/src/main/java/org/eclipse/dirigible/integration/tests/api/IntentEngineIT.java index 0b8ab13e54..40b46d7e56 100644 --- a/tests/tests-integrations/src/main/java/org/eclipse/dirigible/integration/tests/api/IntentEngineIT.java +++ b/tests/tests-integrations/src/main/java/org/eclipse/dirigible/integration/tests/api/IntentEngineIT.java @@ -15,6 +15,7 @@ import static org.hamcrest.Matchers.hasItems; import static org.hamcrest.Matchers.hasSize; import static org.hamcrest.Matchers.not; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -1288,6 +1289,31 @@ public void execute(DelegateExecution execution) { /* MY IMPLEMENTATION */ } "the developer's service-task handler must be preserved across regeneration"); } + @Test + void a_hand_edited_print_template_is_preserved_across_regeneration() { + writeIntent(INTENT_YAML); + restAssuredExecutor.execute(() -> given().when() + .post(GENERATE_URL) + .then() + .statusCode(200)); + // A fresh project gets the scaffold: the minimal, model-derived starting point. + String printPath = "doc/Templates/Order/Print/en/standard.print"; + String scaffold = contentOf(printPath); + assertTrue(scaffold.contains(""), + "the first Generate must scaffold the standard print template, got: " + scaffold); + + // The developer hand-improves it. A printed invoice is a formatted/audited artifact - the + // scaffold is a customization point (like the CMS seeding, which is create-if-absent), so a + // regeneration must leave the authored template BYTE-IDENTICAL, never re-emit over it. + String authored = "
{{document.Id}}
"; + writeProjectFile(printPath, authored); + restAssuredExecutor.execute(() -> given().when() + .post(GENERATE_URL) + .then() + .statusCode(200)); + assertEquals(authored, contentOf(printPath), "an authored print template must survive regeneration byte-identical"); + } + @Test void generating_the_events_template_preserves_the_full_stack_gen_output() { writeIntent(INTENT_YAML);