Skip to content

Commit

Permalink
Merge pull request #5169 from mhsdesign/task/5034-fully-workspace-awa…
Browse files Browse the repository at this point in the history
…re-behat-tests

TASK: 5034 fully completely workspace aware behat tests
  • Loading branch information
mhsdesign authored Jul 12, 2024
2 parents f7fab11 + 35155bd commit 56e5218
Show file tree
Hide file tree
Showing 19 changed files with 101 additions and 117 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,16 @@ Feature: On forking a content stream, hidden nodes should be correctly copied as
| nodeVariantSelectionStrategy | "allVariants" |

Scenario: on ForkContentStream, the disabled nodes in the target content stream should still be invisible.
When the command ForkContentStream is executed with payload:
| Key | Value |
| sourceContentStreamId | "cs-identifier" |
| contentStreamId | "user-cs-identifier" |

# Uses ForkContentStream implicitly
When the command CreateWorkspace is executed with payload:
| Key | Value |
| baseWorkspaceName | "live" |
| workspaceName | "user-test" |
| newContentStreamId | "user-cs-identifier" |

# node aggregate occupation and coverage is not relevant without dimensions and thus not tested

When I am in content stream "user-cs-identifier" and dimension space point {}
When I am in workspace "user-test" and dimension space point {}
And VisibilityConstraints are set to "withoutRestrictions"
Then I expect node aggregate identifier "lady-eleonode-rootford" to lead to node user-cs-identifier;lady-eleonode-rootford;{}
And I expect this node to have the following child nodes:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,24 @@ Feature: ForkContentStream Without Dimensions
| propertiesToUnset | {} |

Scenario: Ensure that the node is available in the forked content stream
When the command "ForkContentStream" is executed with payload:
| Key | Value |
| contentStreamId | "user-cs-identifier" |
| sourceContentStreamId | "cs-identifier" |
And I am in content stream "user-cs-identifier" and dimension space point {}
# Uses ForkContentStream implicitly
When the command CreateWorkspace is executed with payload:
| Key | Value |
| baseWorkspaceName | "live" |
| workspaceName | "user-test" |
| newContentStreamId | "user-cs-identifier" |

When I am in workspace "user-test" and dimension space point {}
Then I expect node aggregate identifier "nody-mc-nodeface" to lead to node user-cs-identifier;nody-mc-nodeface;{}

Scenario: When a change is applied to the forked content stream AFTER the fork, it is not visible in the live content stream.
When the command "ForkContentStream" is executed with payload:
| Key | Value |
| contentStreamId | "user-cs-identifier" |
| sourceContentStreamId | "cs-identifier" |
# Uses ForkContentStream implicitly
When the command CreateWorkspace is executed with payload:
| Key | Value |
| baseWorkspaceName | "live" |
| workspaceName | "user-test" |
| newContentStreamId | "user-cs-identifier" |

And the event NodePropertiesWereSet was published with payload:
| Key | Value |
| workspaceName | "user" |
Expand All @@ -73,26 +78,28 @@ Feature: ForkContentStream Without Dimensions
| propertyValues | {"text": {"value": "modified value", "type": "string"}} |
| propertiesToUnset | {} |

# live
When I am in content stream "cs-identifier" and dimension space point {}
# live
When I am in workspace "live" and dimension space point {}
Then I expect node aggregate identifier "nody-mc-nodeface" to lead to node cs-identifier;nody-mc-nodeface;{}
And I expect this node to have the following properties:
| Key | Value |
| text | "original value" |

# forked content stream
When I am in content stream "user-cs-identifier" and dimension space point {}
When I am in workspace "user-test" and dimension space point {}
Then I expect node aggregate identifier "nody-mc-nodeface" to lead to node user-cs-identifier;nody-mc-nodeface;{}
And I expect this node to have the following properties:
| Key | Value |
| text | "modified value" |

# this is a "reverse" scenario of the scenario above.
Scenario: When a change is applied on the live content stream AFTER the fork, it is NOT visible in the forked content stream.
When the command "ForkContentStream" is executed with payload:
| Key | Value |
| contentStreamId | "user-cs-identifier" |
| sourceContentStreamId | "cs-identifier" |
# Uses ForkContentStream implicitly
When the command CreateWorkspace is executed with payload:
| Key | Value |
| baseWorkspaceName | "live" |
| workspaceName | "user-test" |
| newContentStreamId | "user-cs-identifier" |
And the event NodePropertiesWereSet was published with payload:
| Key | Value |
| workspaceName | "live" |
Expand All @@ -104,14 +111,14 @@ Feature: ForkContentStream Without Dimensions
| propertiesToUnset | {} |

# live
When I am in content stream "cs-identifier" and dimension space point {}
When I am in workspace "live" and dimension space point {}
Then I expect node aggregate identifier "nody-mc-nodeface" to lead to node cs-identifier;nody-mc-nodeface;{}
And I expect this node to have the following properties:
| Key | Value |
| text | "modified value" |

# forked content stream
When I am in content stream "user-cs-identifier" and dimension space point {}
When I am in workspace "user-test" and dimension space point {}
Then I expect node aggregate identifier "nody-mc-nodeface" to lead to node user-cs-identifier;nody-mc-nodeface;{}
And I expect this node to have the following properties:
| Key | Value |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,15 @@ Feature: On forking a content stream, node references should be copied as well.
| referenceName | "referenceProperty" |
| references | [{"target": "anthony-destinode"}] |

When the command ForkContentStream is executed with payload:
| Key | Value |
| contentStreamId | "user-cs-identifier" |
| sourceContentStreamId | "cs-identifier" |
# Uses ForkContentStream implicitly
When the command CreateWorkspace is executed with payload:
| Key | Value |
| baseWorkspaceName | "live" |
| workspaceName | "user-test" |
| newContentStreamId | "user-cs-identifier" |

# after forking, the reference must still exist on the forked content stream (no surprises here).
When I am in content stream "user-cs-identifier" and dimension space point {"language": "de"}
When I am in workspace "user-test" and dimension space point {"language": "de"}
Then I expect node aggregate identifier "source-nodandaise" to lead to node user-cs-identifier;source-nodandaise;{"language": "de"}
Then I expect this node to have the following references:
| Name | Node | Properties |
Expand All @@ -61,7 +63,7 @@ Feature: On forking a content stream, node references should be copied as well.
| Name | Node | Properties |
| referenceProperty | user-cs-identifier;source-nodandaise;{"language": "de"} | null |

When I am in content stream "user-cs-identifier" and dimension space point {"language": "ch"}
When I am in workspace "user-test" and dimension space point {"language": "ch"}
Then I expect node aggregate identifier "source-nodandaise" to lead to node user-cs-identifier;source-nodandaise;{"language": "de"}
Then I expect this node to have the following references:
| Name | Node | Properties |
Expand All @@ -73,7 +75,7 @@ Feature: On forking a content stream, node references should be copied as well.

# after then modifying the node's properties (thus triggering copy-on-write), the reference property
# should still exist (this was a BUG)
When I am in content stream "user-cs-identifier" and dimension space point {"language": "de"}
When I am in workspace "user-test" and dimension space point {"language": "de"}
And the command SetNodeProperties is executed with payload:
| Key | Value |
| nodeAggregateId | "source-nodandaise" |
Expand All @@ -87,7 +89,7 @@ Feature: On forking a content stream, node references should be copied as well.
| Name | Node | Properties |
| referenceProperty | user-cs-identifier;source-nodandaise;{"language": "de"} | null |

When I am in content stream "user-cs-identifier" and dimension space point {"language": "ch"}
When I am in workspace "user-test" and dimension space point {"language": "ch"}
Then I expect node aggregate identifier "source-nodandaise" to lead to node user-cs-identifier;source-nodandaise;{"language": "de"}
And I expect this node to have the following references:
| Name | Node | Properties |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ Feature: Move dimension space point
to: { language: 'de_DE' }
"""
# the original content stream has not been touched
When I am in content stream "cs-identifier" and dimension space point {"language": "de"}
When I am in workspace "live" and dimension space point {"language": "de"}
Then I expect a node identified by cs-identifier;sir-david-nodenborough;{"language": "de"} to exist in the content graph
And I expect this node to be of type "Neos.ContentRepository.Testing:Document"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Feature: Publishing hide/show scenario of nodes
| Key | Value |
| workspaceName | "live" |
| newContentStreamId | "cs-identifier" |
And I am in workspace "live"
And I am in workspace "live" and dimension space point {}
And the command CreateRootNodeAggregateWithNode is executed with payload:
| Key | Value |
| nodeAggregateId | "lady-eleonode-rootford" |
Expand Down Expand Up @@ -104,13 +104,16 @@ Feature: Publishing hide/show scenario of nodes
| contentStreamIdForRemainingPart | "remaining-cs-id" |
| contentStreamIdForMatchingPart | "matching-cs-id" |
When I am in workspace "live" and dimension space point {}
When I am in workspace "live"
Then I expect node aggregate identifier "sir-david-nodenborough" to lead to no node
And I expect node aggregate identifier "nody-mc-nodeface" to lead to no node
And I expect node aggregate identifier "sir-nodeward-nodington-iii" to lead to node cs-identifier;sir-nodeward-nodington-iii;{}
When I am in content stream "remaining-cs-id" and dimension space point {}
Then I expect node aggregate identifier "sir-david-nodenborough" to lead to no node
When I am in workspace "user-test"
# Ensure that we are in content stream remaining-cs-id
Then I expect node aggregate identifier "lady-eleonode-rootford" to lead to node remaining-cs-id;lady-eleonode-rootford;{}
And I expect node aggregate identifier "sir-david-nodenborough" to lead to no node
And I expect node aggregate identifier "nody-mc-nodeface" to lead to no node
And I expect node aggregate identifier "sir-nodeward-nodington-iii" to lead to no node
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,18 @@ Feature: If content streams are not in use anymore by the workspace, they can be
| workspaceName | "user-test" |
| baseWorkspaceName | "live" |
| newContentStreamId | "user-cs-identifier" |
When I am in workspace "user-test" and dimension space point {}
# Ensure that we are in content user-cs-identifier
Then I expect node aggregate identifier "root-node" to lead to node user-cs-identifier;root-node;{}

When the command RebaseWorkspace is executed with payload:
| Key | Value |
| workspaceName | "user-test" |
| rebasedContentStreamId | "user-cs-identifier-rebased" |
# now, we have one unused content stream (the old content stream of the user-test workspace)

When I prune unused content streams

When I am in content stream "user-cs-identifier" and dimension space point {}
Then I expect node aggregate identifier "root-node" to lead to no node
Then I expect the content stream "user-cs-identifier" to not exist

When I am in workspace "user-test" and dimension space point {}
Then I expect node aggregate identifier "root-node" to lead to node user-cs-identifier-rebased;root-node;{}
Expand Down
2 changes: 1 addition & 1 deletion Neos.ContentRepository.Core/Classes/ContentGraphFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function forgetInstances(): void
*
* @param WorkspaceName $workspaceName
* @param ContentStreamId $contentStreamId
* @internal Only for testing
* @internal Only for the write side during publishing {@see \Neos\ContentRepository\Core\CommandHandlingDependencies::overrideContentStreamId}
*/
public function getByWorkspaceNameAndContentStreamId(WorkspaceName $workspaceName, ContentStreamId $contentStreamId): ContentGraphInterface
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
use Neos\ContentRepository\Core\SharedModel\Workspace\ContentStreamId;

/**
* @api commands are the write-API of the ContentRepository
* @internal implementation detail. You must not use this command directly.
* Direct use may lead to hard to revert senseless state in your content repository.
* Please use the higher level workspace commands instead.
*/
final readonly class CloseContentStream implements CommandInterface
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
use Neos\ContentRepository\Core\SharedModel\Workspace\ContentStreamState;

/**
* @api commands are the write-API of the ContentRepository
* @internal implementation detail. You must not use this command directly.
* Direct use may lead to hard to revert senseless state in your content repository.
* Please use the higher level workspace commands instead.
*/
final readonly class ReopenContentStream implements CommandInterface
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
* CreateContentStream for creating the FIRST content stream.
* All other content streams will be FORKED from this FIRST content stream.
*
* @api commands are the write-API of the ContentRepository
* @internal implementation detail. You must not use this command directly.
* Direct use may lead to hard to revert senseless state in your content repository.
* Please use the higher level workspace commands instead.
*/
final readonly class CreateContentStream implements CommandInterface
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
/**
* ForkContentStream for creating a new fork of a content stream.
*
* @api commands are the write-API of the ContentRepository
* @internal implementation detail. You must not use this command directly.
* Direct use may lead to hard to revert senseless state in your content repository.
* Please use the higher level workspace commands instead.
*/
final readonly class ForkContentStream implements CommandInterface
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
/**
* Command to remove an existing content stream
*
* @api commands are the write-API of the ContentRepository
* @internal implementation detail. You must not use this command directly.
* Direct use may lead to hard to revert senseless state in your content repository.
* Please use the higher level workspace commands instead.
*/
final readonly class RemoveContentStream implements CommandInterface
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ trait CRTestSuiteRuntimeVariables
{
protected ?ContentRepository $currentContentRepository = null;

protected ?ContentStreamId $currentContentStreamId = null;

protected ?WorkspaceName $currentWorkspaceName = null;

protected ?DimensionSpacePoint $currentDimensionSpacePoint = null;
Expand Down Expand Up @@ -87,21 +85,12 @@ public function theCurrentDateAndTimeIs(string $timestamp): void
FakeClock::setNow(\DateTimeImmutable::createFromFormat(\DateTimeInterface::ATOM, $timestamp));
}

/**
* @Given /^I am in content stream "([^"]*)"$/
*/
public function iAmInContentStream(string $contentStreamId): void
{
$this->currentContentStreamId = ContentStreamId::fromString($contentStreamId);
}

/**
* @Given /^I am in workspace "([^"]*)"$/
*/
public function iAmInWorkspace(string $workspaceName): void
{
$this->currentWorkspaceName = WorkspaceName::fromString($workspaceName);
$this->currentContentStreamId = null;
}

/**
Expand All @@ -122,15 +111,6 @@ public function iAmInWorkspaceAndDimensionSpacePoint(string $workspaceName, stri
$this->iAmInDimensionSpacePoint($dimensionSpacePoint);
}

/**
* @Given /^I am in content stream "([^"]*)" and dimension space point (.*)$/
*/
public function iAmInContentStreamAndDimensionSpacePoint(string $contentStreamId, string $dimensionSpacePoint): void
{
$this->iAmInContentStream($contentStreamId);
$this->iAmInDimensionSpacePoint($dimensionSpacePoint);
}

/**
* @When /^VisibilityConstraints are set to "(withoutRestrictions|frontend)"$/
*/
Expand All @@ -146,11 +126,8 @@ public function visibilityConstraintsAreSetTo(string $restrictionType): void
public function getCurrentSubgraph(): ContentSubgraphInterface
{
$contentGraphFinder = $this->currentContentRepository->projectionState(ContentGraphFinder::class);
// todo why do we use the ContentGraphFinder here and clear caches? Test pass without
$contentGraphFinder->forgetInstances();
if (isset($this->currentContentStreamId)) {
// This must still be supported for low level tests, e.g. for content stream forking
return $contentGraphFinder->getByWorkspaceNameAndContentStreamId($this->currentWorkspaceName, $this->currentContentStreamId)->getSubgraph($this->currentDimensionSpacePoint, $this->currentVisibilityConstraints);
}

return $contentGraphFinder->getByWorkspaceName($this->currentWorkspaceName)->getSubgraph(
$this->currentDimensionSpacePoint,
Expand Down
Loading

0 comments on commit 56e5218

Please sign in to comment.