From 2445a6981bfff910186cdd55cb505c8d1823748d Mon Sep 17 00:00:00 2001 From: Martin Ficzel Date: Sun, 22 Dec 2024 12:08:54 +0100 Subject: [PATCH 1/3] TASK: Add testcase for documents that are projected without uriPathSegments The testcase verifies that the nodeAggregateId is used as fallback in case no uriPathSegment was set and that this can be overwritten afterwards of a proper uriPathSegment is set later. Relates: #5413 --- .../MissingPathSegments.feature | 104 ++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 Neos.Neos/Tests/Behavior/Features/FrontendRouting/MissingPathSegments.feature diff --git a/Neos.Neos/Tests/Behavior/Features/FrontendRouting/MissingPathSegments.feature b/Neos.Neos/Tests/Behavior/Features/FrontendRouting/MissingPathSegments.feature new file mode 100644 index 0000000000..b5bd62887a --- /dev/null +++ b/Neos.Neos/Tests/Behavior/Features/FrontendRouting/MissingPathSegments.feature @@ -0,0 +1,104 @@ +@flowEntities @contentrepository +Feature: Basic routing functionality if path segments are missing after node creation (like with tethered nodes) + + Background: + Given using no content dimensions + And using the following node types: + """yaml + 'Neos.Neos:Sites': + superTypes: + 'Neos.ContentRepository:Root': true + 'Neos.Neos:Document': {} + 'Neos.Neos:Content': {} + 'Neos.Neos:Test.Routing.Page': + superTypes: + 'Neos.Neos:Document': true + properties: + uriPathSegment: + type: string + 'Neos.Neos:Test.Routing.Content': + superTypes: + 'Neos.Neos:Content': true + properties: + uriPathSegment: + type: string + """ + And using identifier "default", I define a content repository + And I am in content repository "default" + And I am user identified by "initiating-user-identifier" + + When the command CreateRootWorkspace is executed with payload: + | Key | Value | + | workspaceName | "live" | + | newContentStreamId | "cs-identifier" | + And I am in workspace "live" and dimension space point {} + And the command CreateRootNodeAggregateWithNode is executed with payload: + | Key | Value | + | nodeAggregateId | "lady-eleonode-rootford" | + | nodeTypeName | "Neos.Neos:Sites" | + + # lady-eleonode-rootford + # shernode-homes + # sir-david-nodenborough + # duke-of-contentshire (content node) + # earl-o-documentbourgh + # nody-mc-nodeface + # + And the following CreateNodeAggregateWithNode commands are executed: + | nodeAggregateId | parentNodeAggregateId | nodeTypeName | initialPropertyValues | nodeName | + | shernode-homes | lady-eleonode-rootford | Neos.Neos:Test.Routing.Page | {} | node1 | + | sir-david-nodenborough | shernode-homes | Neos.Neos:Test.Routing.Page | {} | node2 | + | duke-of-contentshire | sir-david-nodenborough | Neos.Neos:Test.Routing.Content | {} | node3 | + | earl-o-documentbourgh | sir-david-nodenborough | Neos.Neos:Test.Routing.Page | {} | node4 | + | nody-mc-nodeface | shernode-homes | Neos.Neos:Test.Routing.Page | {} | node5 | + And A site exists for node name "node1" + And the sites configuration is: + """yaml + Neos: + Neos: + sites: + 'node1': + preset: 'default' + uriPathSuffix: '' + contentDimensions: + resolver: + factoryClassName: Neos\Neos\FrontendRouting\DimensionResolution\Resolver\NoopResolverFactory + """ + Scenario: Match homepage URL + When I am on URL "/" + Then the matched node should be "shernode-homes" in content stream "cs-identifier" and dimension "{}" + + Scenario: Resolve nodes correctly from homepage + When I am on URL "/" + Then the node "shernode-homes" in content stream "cs-identifier" and dimension "{}" should resolve to URL "/" + And the node "sir-david-nodenborough" in content stream "cs-identifier" and dimension "{}" should resolve to URL "/sir-david-nodenborough" + And the node "earl-o-documentbourgh" in content stream "cs-identifier" and dimension "{}" should resolve to URL "/sir-david-nodenborough/earl-o-documentbourgh" + + Scenario: Match node lower in the tree + When I am on URL "/sir-david-nodenborough/earl-o-documentbourgh" + Then the matched node should be "earl-o-documentbourgh" in content stream "cs-identifier" and dimension "{}" + + Scenario: Resolve from node lower in the tree + When I am on URL "/sir-david-nodenborough/earl-o-documentbourgh" + Then the node "shernode-homes" in content stream "cs-identifier" and dimension "{}" should resolve to URL "/" + And the node "sir-david-nodenborough" in content stream "cs-identifier" and dimension "{}" should resolve to URL "/sir-david-nodenborough" + And the node "earl-o-documentbourgh" in content stream "cs-identifier" and dimension "{}" should resolve to URL "/sir-david-nodenborough/earl-o-documentbourgh" + + Scenario: Change uri path segment on first level + When the command SetNodeProperties is executed with payload: + | Key | Value | + | nodeAggregateId | "sir-david-nodenborough" | + | originDimensionSpacePoint | {} | + | propertyValues | {"uriPathSegment": "david-nodenborough-updated"} | + And I am on URL "/" + Then the node "sir-david-nodenborough" in content stream "cs-identifier" and dimension "{}" should resolve to URL "/david-nodenborough-updated" + And the node "earl-o-documentbourgh" in content stream "cs-identifier" and dimension "{}" should resolve to URL "/david-nodenborough-updated/earl-o-documentbourgh" + + Scenario: Change uri path segment on second level + When the command SetNodeProperties is executed with payload: + | Key | Value | + | nodeAggregateId | "earl-o-documentbourgh" | + | originDimensionSpacePoint | {} | + | propertyValues | {"uriPathSegment": "earl-documentbourgh-updated"} | + And I am on URL "/" + Then the node "earl-o-documentbourgh" in content stream "cs-identifier" and dimension "{}" should resolve to URL "/sir-david-nodenborough/earl-documentbourgh-updated" From 828908e85c4a1bb7c4b528ee38a2a18b444a879b Mon Sep 17 00:00:00 2001 From: Martin Ficzel Date: Sun, 22 Dec 2024 12:42:06 +0100 Subject: [PATCH 2/3] BUGFIX: Use nodeAggregateId as fallback for uriPathSegment instead of "" Since "" is treated as the uriPath for a site node this causes confusion if it is projected for a document in cases where one was created without an uriPathSegment which may happen for tethered nodes. Resolves: #5412 --- .../Projection/DocumentUriPathProjection.php | 2 +- .../Features/FrontendRouting/MissingPathSegments.feature | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Neos.Neos/Classes/FrontendRouting/Projection/DocumentUriPathProjection.php b/Neos.Neos/Classes/FrontendRouting/Projection/DocumentUriPathProjection.php index 4adcba2389..36459b4aa3 100644 --- a/Neos.Neos/Classes/FrontendRouting/Projection/DocumentUriPathProjection.php +++ b/Neos.Neos/Classes/FrontendRouting/Projection/DocumentUriPathProjection.php @@ -209,7 +209,7 @@ private function whenNodeAggregateWithNodeWasCreated(NodeAggregateWithNodeWasCre } $propertyValues = $event->initialPropertyValues->getPlainValues(); - $uriPathSegment = $propertyValues['uriPathSegment'] ?? ''; + $uriPathSegment = $propertyValues['uriPathSegment'] ?? $event->nodeAggregateId->value; $shortcutTarget = null; if ($documentTypeClassification === DocumentTypeClassification::CLASSIFICATION_SHORTCUT) { diff --git a/Neos.Neos/Tests/Behavior/Features/FrontendRouting/MissingPathSegments.feature b/Neos.Neos/Tests/Behavior/Features/FrontendRouting/MissingPathSegments.feature index b5bd62887a..2180393587 100644 --- a/Neos.Neos/Tests/Behavior/Features/FrontendRouting/MissingPathSegments.feature +++ b/Neos.Neos/Tests/Behavior/Features/FrontendRouting/MissingPathSegments.feature @@ -1,5 +1,5 @@ @flowEntities @contentrepository -Feature: Basic routing functionality if path segments are missing after node creation (like with tethered nodes) +Feature: Routing functionality if path segments are missing like during tethered node creation Background: Given using no content dimensions @@ -84,7 +84,7 @@ Feature: Basic routing functionality if path segments are missing after node cre And the node "sir-david-nodenborough" in content stream "cs-identifier" and dimension "{}" should resolve to URL "/sir-david-nodenborough" And the node "earl-o-documentbourgh" in content stream "cs-identifier" and dimension "{}" should resolve to URL "/sir-david-nodenborough/earl-o-documentbourgh" - Scenario: Change uri path segment on first level + Scenario: Add uri path segment on first level When the command SetNodeProperties is executed with payload: | Key | Value | | nodeAggregateId | "sir-david-nodenborough" | @@ -94,7 +94,7 @@ Feature: Basic routing functionality if path segments are missing after node cre Then the node "sir-david-nodenborough" in content stream "cs-identifier" and dimension "{}" should resolve to URL "/david-nodenborough-updated" And the node "earl-o-documentbourgh" in content stream "cs-identifier" and dimension "{}" should resolve to URL "/david-nodenborough-updated/earl-o-documentbourgh" - Scenario: Change uri path segment on second level + Scenario: Add uri path segment on second level When the command SetNodeProperties is executed with payload: | Key | Value | | nodeAggregateId | "earl-o-documentbourgh" | From 64d52a7b7753c8ceb3fe272857fda86b457200f3 Mon Sep 17 00:00:00 2001 From: Martin Ficzel Date: Sun, 22 Dec 2024 13:58:02 +0100 Subject: [PATCH 3/3] TASK: Add site nodeName to testcases to avoid relying on invalid behavior The projection detects site nodes that should have an empty path by verifying that the parent is a root node and they have a nodeName. --- .../Features/FrontendRouting/NodeCreationEdgeCases.feature | 1 + .../Features/FrontendRouting/NodeVariationEdgeCases.feature | 3 +++ .../Behavior/Features/FrontendRouting/PartialPublish.feature | 5 +++-- .../Features/FrontendRouting/UnknownNodeTypes.feature | 1 + 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Neos.Neos/Tests/Behavior/Features/FrontendRouting/NodeCreationEdgeCases.feature b/Neos.Neos/Tests/Behavior/Features/FrontendRouting/NodeCreationEdgeCases.feature index 747782161d..8512383265 100644 --- a/Neos.Neos/Tests/Behavior/Features/FrontendRouting/NodeCreationEdgeCases.feature +++ b/Neos.Neos/Tests/Behavior/Features/FrontendRouting/NodeCreationEdgeCases.feature @@ -36,6 +36,7 @@ Feature: Test cases for node creation edge cases | nodeTypeName | "Neos.Neos:Site" | | parentNodeAggregateId | "lady-eleonode-rootford" | | originDimensionSpacePoint | {"example":"source"} | + | nodeName | "site" | And the following CreateNodeAggregateWithNode commands are executed: | nodeAggregateId | nodeName | parentNodeAggregateId | succeedingSiblingNodeAggregateId | nodeTypeName | initialPropertyValues | # Let's prepare some siblings to check orderings. Also, everything gets better with siblings. diff --git a/Neos.Neos/Tests/Behavior/Features/FrontendRouting/NodeVariationEdgeCases.feature b/Neos.Neos/Tests/Behavior/Features/FrontendRouting/NodeVariationEdgeCases.feature index 7e4d76f0ca..b049cef11b 100644 --- a/Neos.Neos/Tests/Behavior/Features/FrontendRouting/NodeVariationEdgeCases.feature +++ b/Neos.Neos/Tests/Behavior/Features/FrontendRouting/NodeVariationEdgeCases.feature @@ -36,6 +36,7 @@ Feature: Test cases for node variation edge cases | nodeTypeName | "Neos.Neos:Site" | | parentNodeAggregateId | "lady-eleonode-rootford" | | originDimensionSpacePoint | {"example":"source"} | + | nodeName | "site" | And the command CreateNodeVariant is executed with payload: | Key | Value | | nodeAggregateId | "shernode-homes" | @@ -135,6 +136,7 @@ Feature: Test cases for node variation edge cases | nodeTypeName | "Neos.Neos:Site" | | parentNodeAggregateId | "lady-eleonode-rootford" | | originDimensionSpacePoint | {"example":"rootGeneral"} | + | nodeName | "site" | And the following CreateNodeAggregateWithNode commands are executed: | nodeAggregateId | originDimensionSpacePoint | nodeName | parentNodeAggregateId | succeedingSiblingNodeAggregateId | nodeTypeName | initialPropertyValues | # Let's create some siblings, both in source and target, to check ordering @@ -225,6 +227,7 @@ Feature: Test cases for node variation edge cases | nodeTypeName | "Neos.Neos:Site" | | parentNodeAggregateId | "lady-eleonode-rootford" | | originDimensionSpacePoint | {"example":"source"} | + | nodeName | "site" | And the following CreateNodeAggregateWithNode commands are executed: | nodeAggregateId | nodeName | parentNodeAggregateId | succeedingSiblingNodeAggregateId | nodeTypeName | initialPropertyValues | # Let's create our test subject... diff --git a/Neos.Neos/Tests/Behavior/Features/FrontendRouting/PartialPublish.feature b/Neos.Neos/Tests/Behavior/Features/FrontendRouting/PartialPublish.feature index 803b0e8b5e..322a1346e6 100644 --- a/Neos.Neos/Tests/Behavior/Features/FrontendRouting/PartialPublish.feature +++ b/Neos.Neos/Tests/Behavior/Features/FrontendRouting/PartialPublish.feature @@ -36,6 +36,7 @@ Feature: Test cases for partial publish to live and uri path generation | nodeTypeName | "Neos.Neos:Site" | | parentNodeAggregateId | "lady-eleonode-rootford" | | originDimensionSpacePoint | {"example":"source"} | + | nodeName | "site" | And the command CreateWorkspace is executed with payload: | Key | Value | | workspaceName | "myworkspace" | @@ -49,7 +50,7 @@ Feature: Test cases for partial publish to live and uri path generation | nodeTypeName | "Neos.Neos:Document" | | parentNodeAggregateId | "shernode-homes" | | originDimensionSpacePoint | {"example":"source"} | - | properties | {"uriPathSegment": "just"}| + | initialPropertyValues | {"uriPathSegment": "just"}| | workspaceName | "myworkspace" | And the command PublishIndividualNodesFromWorkspace is executed with payload: | Key | Value | @@ -65,4 +66,4 @@ Feature: Test cases for partial publish to live and uri path generation | "65901ded4f068dac14ad0dce4f459b29" | "" | "lady-eleonode-rootford" | "lady-eleonode-rootford" | null | null | null | "Neos.Neos:Sites" | | "fbe53ddc3305685fbb4dbf529f283a0e" | "" | "lady-eleonode-rootford" | "lady-eleonode-rootford" | null | null | null | "Neos.Neos:Sites" | | "65901ded4f068dac14ad0dce4f459b29" | "" | "lady-eleonode-rootford/shernode-homes" | "shernode-homes" | "lady-eleonode-rootford" | null | null | "Neos.Neos:Site" | - | "65901ded4f068dac14ad0dce4f459b29" | "" | "lady-eleonode-rootford/shernode-homes/justsomepage" | "justsomepage" | "shernode-homes" | null | null | "Neos.Neos:Document" | + | "65901ded4f068dac14ad0dce4f459b29" | "just" | "lady-eleonode-rootford/shernode-homes/justsomepage" | "justsomepage" | "shernode-homes" | null | null | "Neos.Neos:Document" | diff --git a/Neos.Neos/Tests/Behavior/Features/FrontendRouting/UnknownNodeTypes.feature b/Neos.Neos/Tests/Behavior/Features/FrontendRouting/UnknownNodeTypes.feature index 904990f72d..040b41d288 100644 --- a/Neos.Neos/Tests/Behavior/Features/FrontendRouting/UnknownNodeTypes.feature +++ b/Neos.Neos/Tests/Behavior/Features/FrontendRouting/UnknownNodeTypes.feature @@ -39,6 +39,7 @@ Feature: Basic routing functionality (match & resolve nodes with unknown types) | nodeTypeName | "Neos.Neos:Test.Routing.Page" | | parentNodeAggregateId | "lady-eleonode-rootford" | | nodeAggregateClassification | "regular" | + | nodeName | "site" | And the event NodeAggregateWithNodeWasCreated was published with payload: | Key | Value | | workspaceName | "live" |