From 1d12d525acd19765be414f988e53c03f9020c8dc Mon Sep 17 00:00:00 2001 From: pKallert <91674611+pKallert@users.noreply.github.com> Date: Fri, 16 Feb 2024 21:28:37 +0100 Subject: [PATCH 1/2] Feature: Add failing tests for workspace publish --- .../WorkspaceBasedContentPublishing.feature | 27 +++++++++++++++++++ .../Bootstrap/CRTestSuiteRuntimeVariables.php | 17 ++++++++++++ .../Features/WorkspacePublishing.php | 14 ++++++++++ 3 files changed, 58 insertions(+) diff --git a/Neos.ContentRepository.BehavioralTests/Tests/Behavior/Features/WorkspacePublishing/WorkspaceBasedContentPublishing.feature b/Neos.ContentRepository.BehavioralTests/Tests/Behavior/Features/WorkspacePublishing/WorkspaceBasedContentPublishing.feature index 7e855d224bd..f089a98f784 100644 --- a/Neos.ContentRepository.BehavioralTests/Tests/Behavior/Features/WorkspacePublishing/WorkspaceBasedContentPublishing.feature +++ b/Neos.ContentRepository.BehavioralTests/Tests/Behavior/Features/WorkspacePublishing/WorkspaceBasedContentPublishing.feature @@ -264,3 +264,30 @@ Feature: Workspace based content publishing And I expect this node to have the following properties: | Key | Value | | text | "Modified in live workspace" | + + Scenario: Publishing workspace with PublishIndividualNodesFromWorkspace not possible with outdated workspace + And the command CreateWorkspace is executed with payload: + | Key | Value | + | workspaceName | "user-test-2" | + | baseWorkspaceName | "live" | + | newContentStreamId | "user-cs-identifier-2" | + | workspaceOwner | "owner-identifier-2" | + And the graph projection is fully up to date + + # Make sure the first workspace is UP_TO_DATE by publishing first + When the command PublishWorkspace is executed with payload: + | Key | Value | + | workspaceName | "user-test" | + + And the graph projection is fully up to date + Then I expect the status of the workspace "user-test" to be "UP_TO_DATE" + And I expect the status of the workspace "user-test-2" to be "OUTDATED" + + # Publish outdated workspace + When the command PublishIndividualNodesFromWorkspace is executed with payload and exceptions are caught: + | Key | Value | + | workspaceName | "user-test-2" | + | nodesToPublish | [{"nodeAggregateId": "nody-mc-nodeface", "contentStreamId": "user-cs-identifier-2", "dimensionSpacePoint": {}}] | + Then the last command should have thrown an exception of type "BaseWorkspaceHasBeenModifiedInTheMeantime" + Then I expect the status of the workspace "user-test" to be "UP_TO_DATE" + And I expect the status of the workspace "user-test-2" to be "OUTDATED" diff --git a/Neos.ContentRepository.TestSuite/Classes/Behavior/Features/Bootstrap/CRTestSuiteRuntimeVariables.php b/Neos.ContentRepository.TestSuite/Classes/Behavior/Features/Bootstrap/CRTestSuiteRuntimeVariables.php index b4e6246665b..0651389a3eb 100644 --- a/Neos.ContentRepository.TestSuite/Classes/Behavior/Features/Bootstrap/CRTestSuiteRuntimeVariables.php +++ b/Neos.ContentRepository.TestSuite/Classes/Behavior/Features/Bootstrap/CRTestSuiteRuntimeVariables.php @@ -30,6 +30,7 @@ use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceName; use Neos\ContentRepository\TestSuite\Behavior\Features\Bootstrap\Helpers\FakeClock; use Neos\ContentRepository\TestSuite\Behavior\Features\Bootstrap\Helpers\FakeUserIdProvider; +use PHPUnit\Framework\Assert; /** * The node creation trait for behavioral tests @@ -168,6 +169,22 @@ public function iRememberNodeAggregateIdOfNodesChildAs(string $parentNodeAggrega )->nodeAggregateId; } + + + /** + * @Then /^I expect the status of the workspace "([^"]*)" to be "([^"]*)"$/ + */ + public function iExpectTheStatusOfTheWorkspaceToBe(string $workspaceName, string $workspaceStatus): void + { + $workspace = $this->currentContentRepository->getWorkspaceFinder()->findOneByName(WorkspaceName::fromString($workspaceName)); + + if ($workspace === null) { + throw new \Exception(sprintf('Workspace "%s" does not exist, projection not yet up to date?', $workspaceName), 1548149355); + } + Assert::assertSame($workspace->status->value, $workspaceStatus); + + } + protected function getCurrentNodeAggregateId(): NodeAggregateId { assert($this->currentNode instanceof Node); diff --git a/Neos.ContentRepository.TestSuite/Classes/Behavior/Features/Bootstrap/Features/WorkspacePublishing.php b/Neos.ContentRepository.TestSuite/Classes/Behavior/Features/Bootstrap/Features/WorkspacePublishing.php index 4d23e13bbcd..27ec01c3a39 100644 --- a/Neos.ContentRepository.TestSuite/Classes/Behavior/Features/Bootstrap/Features/WorkspacePublishing.php +++ b/Neos.ContentRepository.TestSuite/Classes/Behavior/Features/Bootstrap/Features/WorkspacePublishing.php @@ -84,4 +84,18 @@ public function theCommandPublishWorkspaceIsExecutedAndExceptionsAreCaught(Table $this->lastCommandException = $exception; } } + + /** + * @Given /^the command PublishIndividualNodesFromWorkspace is executed with payload and exceptions are caught:$/ + * @param TableNode $payloadTable + * @throws \Exception + */ + public function theCommandPublishIndividualNodesFromWorkspaceIsExecutedAndExceptionsAreCaught(TableNode $payloadTable): void + { + try { + $this->theCommandPublishIndividualNodesFromWorkspaceIsExecuted($payloadTable); + } catch (\Exception $exception) { + $this->lastCommandException = $exception; + } + } } From e562c7cef3709a6961e962c81acb3ae855dd6858 Mon Sep 17 00:00:00 2001 From: pKallert <91674611+pKallert@users.noreply.github.com> Date: Fri, 16 Feb 2024 21:39:34 +0100 Subject: [PATCH 2/2] Feature: fix linter --- .../Features/Bootstrap/CRTestSuiteRuntimeVariables.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/Neos.ContentRepository.TestSuite/Classes/Behavior/Features/Bootstrap/CRTestSuiteRuntimeVariables.php b/Neos.ContentRepository.TestSuite/Classes/Behavior/Features/Bootstrap/CRTestSuiteRuntimeVariables.php index 0651389a3eb..d6ca2488540 100644 --- a/Neos.ContentRepository.TestSuite/Classes/Behavior/Features/Bootstrap/CRTestSuiteRuntimeVariables.php +++ b/Neos.ContentRepository.TestSuite/Classes/Behavior/Features/Bootstrap/CRTestSuiteRuntimeVariables.php @@ -169,8 +169,6 @@ public function iRememberNodeAggregateIdOfNodesChildAs(string $parentNodeAggrega )->nodeAggregateId; } - - /** * @Then /^I expect the status of the workspace "([^"]*)" to be "([^"]*)"$/ */ @@ -182,7 +180,6 @@ public function iExpectTheStatusOfTheWorkspaceToBe(string $workspaceName, string throw new \Exception(sprintf('Workspace "%s" does not exist, projection not yet up to date?', $workspaceName), 1548149355); } Assert::assertSame($workspace->status->value, $workspaceStatus); - } protected function getCurrentNodeAggregateId(): NodeAggregateId