Skip to content

Commit

Permalink
TASK: Introduce test for neos#5364 expecting a `PartialWorkspaceRebas…
Browse files Browse the repository at this point in the history
…eFailed`
  • Loading branch information
mhsdesign committed Dec 1, 2024
1 parent ff334f4 commit 5f234c7
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ Feature: Workspace publication - complex chained functionality
| originDimensionSpacePoint | {"language": "de"} |
| propertyValues | {"text": "Modified text"} |

Then workspace user-ws has status OUTDATED

When the command PublishIndividualNodesFromWorkspace is executed with payload and exceptions are caught:
| Key | Value |
| workspaceName | "user-ws" |
Expand All @@ -101,12 +103,14 @@ Feature: Workspace publication - complex chained functionality
| sourceOrigin | {"language": "de"} |
| targetOrigin | {"language": "en"} |

Then workspace user-ws has status UP_TO_DATE

When the command PublishIndividualNodesFromWorkspace is executed with payload and exceptions are caught:
| Key | Value |
| workspaceName | "user-ws" |
| nodesToPublish | [{"workspaceName": "user-ws", "dimensionSpacePoint": {"language": "en"}, "nodeAggregateId": "nody-mc-nodeface"}] |
| newContentStreamId | "user-cs-id-rebased" |
Then the last command should have thrown the WorkspaceRebaseFailed exception with:
Then the last command should have thrown the PartialWorkspaceRebaseFailed exception with:
| SequenceNumber | Event | Exception |
| 13 | NodeGeneralizationVariantWasCreated | NodeAggregateDoesCurrentlyNotCoverDimensionSpacePoint |

Expand All @@ -116,3 +120,32 @@ Feature: Workspace publication - complex chained functionality
| newContentStreamId | "user-cs-id-yet-again-rebased" |
When I am in workspace "user-ws" and dimension space point {"language": "de"}
Then I expect node aggregate identifier "nody-mc-nodeface" to lead to node user-cs-id-yet-again-rebased;nody-mc-nodeface;{"language": "de"}

Scenario: Publish a deletion and try to keep a move node from its descendants
see issue: https://github.com/neos/neos-development-collection/issues/5364

When the command MoveNodeAggregate is executed with payload:
| Key | Value |
| workspaceName | "user-ws" |
| nodeAggregateId | "nody-mc-nodeface" |
| dimensionSpacePoint | {"language": "de"} |
| newParentNodeAggregateId | "sir-nodebelig" |
| relationDistributionStrategy | "gatherAll" |

When the command RemoveNodeAggregate is executed with payload:
| Key | Value |
| workspaceName | "user-ws" |
| nodeAggregateId | "sir-david-nodenborough" |
| coveredDimensionSpacePoint | {"language": "de"} |
| nodeVariantSelectionStrategy | "allVariants" |

Then workspace user-ws has status UP_TO_DATE

When the command PublishIndividualNodesFromWorkspace is executed with payload and exceptions are caught:
| Key | Value |
| workspaceName | "user-ws" |
| nodesToPublish | [{"dimensionSpacePoint": {"language": "de"}, "nodeAggregateId": "sir-david-nodenborough"}] |
| newContentStreamId | "user-cs-id-rebased" |
Then the last command should have thrown the PartialWorkspaceRebaseFailed exception with:
| SequenceNumber | Event | Exception |
| 11 | NodeAggregateWasMoved | NodeAggregateCurrentlyDoesNotExist |
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
use Neos\ContentRepository\Core\Feature\WorkspacePublication\Command\PublishIndividualNodesFromWorkspace;
use Neos\ContentRepository\Core\Feature\WorkspacePublication\Command\PublishWorkspace;
use Neos\ContentRepository\Core\Feature\WorkspaceRebase\Command\RebaseWorkspace;
use Neos\ContentRepository\Core\Feature\WorkspaceRebase\Exception\PartialWorkspaceRebaseFailed;
use Neos\ContentRepository\Core\Feature\WorkspaceRebase\Exception\WorkspaceRebaseFailed;
use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateId;
use Neos\ContentRepository\Core\SharedModel\Node\ReferenceName;
Expand Down Expand Up @@ -310,7 +311,7 @@ protected function publishEvent(string $eventType, StreamName $streamName, array
*/
public function theLastCommandShouldHaveThrown(string $shortExceptionName, ?int $expectedCode = null, PyStringNode $expectedMessage = null): void
{
if ($shortExceptionName === 'WorkspaceRebaseFailed') {
if ($shortExceptionName === 'WorkspaceRebaseFailed' || $shortExceptionName === 'PartialWorkspaceRebaseFailed') {
throw new \RuntimeException('Please use the assertion "the last command should have thrown the WorkspaceRebaseFailed exception with" instead.');
}

Expand All @@ -332,14 +333,18 @@ public function theLastCommandShouldHaveThrown(string $shortExceptionName, ?int
}

/**
* @Then the last command should have thrown the WorkspaceRebaseFailed exception with:
* @Then /^the last command should have thrown the (WorkspaceRebaseFailed|PartialWorkspaceRebaseFailed) exception with:$/
*/
public function theLastCommandShouldHaveThrownTheWorkspaceRebaseFailedWith(TableNode $payloadTable)
public function theLastCommandShouldHaveThrownTheWorkspaceRebaseFailedWith(string $shortExceptionName, TableNode $payloadTable)
{
/** @var WorkspaceRebaseFailed $exception */
/** @var WorkspaceRebaseFailed|PartialWorkspaceRebaseFailed $exception */
$exception = $this->lastCommandException;
Assert::assertNotNull($exception, 'Command did not throw exception');
Assert::assertInstanceOf(WorkspaceRebaseFailed::class, $exception, sprintf('Actual exception: %s (%s): %s', get_class($exception), $exception->getCode(), $exception->getMessage()));

match($shortExceptionName) {
'WorkspaceRebaseFailed' => Assert::assertInstanceOf(WorkspaceRebaseFailed::class, $exception, sprintf('Actual exception: %s (%s): %s', get_class($exception), $exception->getCode(), $exception->getMessage())),
'PartialWorkspaceRebaseFailed' => Assert::assertInstanceOf(PartialWorkspaceRebaseFailed::class, $exception, sprintf('Actual exception: %s (%s): %s', get_class($exception), $exception->getCode(), $exception->getMessage())),
};

$actualComparableHash = [];
foreach ($exception->conflictingEvents as $conflictingEvent) {
Expand Down

0 comments on commit 5f234c7

Please sign in to comment.