Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TASK: Make E2E tests work for Neos 9.0 #3569

Merged
merged 31 commits into from
Sep 23, 2023
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
65232ef
Merge remote-tracking branch 'origin/bugfix/3301-part-2/fix-docker-e2…
grebaldi Jul 7, 2023
3b1f00c
TASK: Initialize ESCR-driven E2E test setup for 1Dimension fixture
grebaldi Jul 7, 2023
6e8e0c9
TASK: Replace context paths with node addresses in E2E assertions
grebaldi Jul 7, 2023
eb3182f
BUGFIX: Read .node-context-path innerHTML when parsing a node search …
grebaldi Jul 8, 2023
f692333
BUGFIX: (9.0) Predict nodes that will be deleted through discard
grebaldi Jul 8, 2023
57a5bc1
TASK: Replace usage of `Neos.Node.inBackend(node)` with `Neos.Backend…
mficzel Jul 9, 2023
ad36bc7
TASK: Make E2E tests work for 2Dimension fixture
grebaldi Jul 10, 2023
a53af29
Merge remote-tracking branch 'upstream/90-replace-node-inbackend-usag…
grebaldi Jul 10, 2023
1375319
TASK: Get rid of `RemoveNode` feedback in Move* changes
grebaldi Jul 10, 2023
ce395ca
TASK: Add rudimentary support for EditPreviewModes in 9.0
grebaldi Jul 10, 2023
7b451a0
TASK: Update CircleCI php image to cimg/php:8.2-node
grebaldi Jul 11, 2023
e018877
TASK: Adjust e2e.sh test script for CI to match local setup for Neos 9.0
grebaldi Jul 11, 2023
c43bb47
TASK: Merge integration test site packages into one unified distribution
grebaldi Jul 11, 2023
895ca5c
TASK: Adjust e2e.sh script to match new unified test setup
grebaldi Jul 11, 2023
228f551
TASK: Remove patch for neos/neos-development-collection#4395 from Tes…
grebaldi Jul 12, 2023
cc06094
TASK: Restore dependency to neos/buildessentials and phpunit in TestD…
grebaldi Jul 12, 2023
b6f3970
TASK: Add E2E test for switching between sites in a multi-site setup
grebaldi Jul 12, 2023
65a80c7
Merge remote-tracking branch 'upstream/9.0' into task/e2e-tests-on-9-0
grebaldi Jul 12, 2023
c250be1
TASK: Fix StyleCI issues
grebaldi Jul 12, 2023
ea1dd48
TASK: Switch to a strategy based on symlinks rather than copies for d…
grebaldi Jul 12, 2023
0a858bb
TASK: Merge Testcafé runs into a single one
grebaldi Jul 12, 2023
3f2f886
TASK: Symlink composer.json in docker e2e setup (rather than cp)
grebaldi Jul 28, 2023
27c6bb4
Merge remote-tracking branch 'upstream/9.0' into task/e2e-tests-on-9-0
grebaldi Aug 2, 2023
07b620a
TASK: Remove patches for neos/neos-development-collection#4393 and #4…
grebaldi Aug 2, 2023
d0c743c
Revert "TASK: Add rudimentary support for EditPreviewModes in 9.0"
mhsdesign Sep 16, 2023
3bf7dde
Merge branch 'bugfix/90editPreviewModes' into task/e2e-tests-on-9-0
mhsdesign Sep 16, 2023
103afcf
BUGFIX: E2E Error: cannot require `......./FlowContextTrait` in `CRRe…
mhsdesign Sep 21, 2023
084bd2e
BUGFIX: `make test-e2e-docker` composer.json not found
mhsdesign Sep 21, 2023
353aa83
Merge remote-tracking branch 'origin/9.0' into task/e2e-tests-on-9-0
mhsdesign Sep 21, 2023
dcefe42
TASK: Document need for additional etc host entries for local tests
mhsdesign Sep 22, 2023
dd99278
TASK: Move testing hack yaml to reduce impact on other projects
mhsdesign Sep 22, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ jobs:
environment:
COMPOSER_CACHE_DIR: /home/circleci/composer/cache-dir
docker:
- image: cimg/php:8.0-node
- image: cimg/php:8.2-node
steps:
- attach_workspace: *attach_workspace
- run: chmod -R 777 /home/circleci
Expand All @@ -81,8 +81,9 @@ jobs:
e2e:
environment:
FLOW_CONTEXT: Production
DB_HOST: 127.0.0.1
docker:
- image: cimg/php:8.0-node
- image: cimg/php:8.2-node
- image: cimg/mariadb:10.6
environment:
MYSQL_DATABASE: neos
Expand Down Expand Up @@ -113,6 +114,8 @@ jobs:
cd /home/circleci/app/Packages/Application/Neos.Neos.Ui
nvm install
nvm use
echo 127.0.0.1 onedimension.localhost | sudo tee -a /etc/hosts
echo 127.0.0.1 twodimensions.localhost | sudo tee -a /etc/hosts
make test-e2e-saucelabs
- store_artifacts:
path: /home/circleci/app/Data/Logs
Expand All @@ -121,7 +124,7 @@ jobs:
environment:
FLOW_CONTEXT: Production
docker:
- image: cimg/php:8.0-node
- image: cimg/php:8.2-node
- image: cimg/mariadb:10.6
environment:
MYSQL_DATABASE: neos
Expand Down
52 changes: 49 additions & 3 deletions Classes/ContentRepository/Service/WorkspaceService.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

use Neos\ContentRepository\Core\ContentRepository;
use Neos\ContentRepository\Core\Factory\ContentRepositoryId;
use Neos\ContentRepository\Core\Projection\ContentGraph\ContentSubgraphIdentity;
use Neos\ContentRepository\Core\Feature\WorkspacePublication\Command\DiscardIndividualNodesFromWorkspace;
use Neos\ContentRepository\Core\Projection\ContentGraph\Node;
use Neos\ContentRepository\Core\Projection\Workspace\Workspace;
use Neos\Neos\FrontendRouting\NodeAddress;
Expand All @@ -24,15 +24,14 @@
use Neos\Flow\Annotations as Flow;
use Neos\Neos\Domain\Service\UserService as DomainUserService;
use Neos\Neos\PendingChangesProjection\ChangeFinder;
use Neos\Neos\PendingChangesProjection\ChangeProjection;
use Neos\Neos\Service\UserService;
use Neos\Neos\Ui\Domain\Model\Feedback\Operations\RemoveNode;

/**
* @Flow\Scope("singleton")
*/
class WorkspaceService
{

/**
* @Flow\Inject
* @var UserService
Expand Down Expand Up @@ -156,6 +155,53 @@ public function getAllowedTargetWorkspaces(ContentRepository $contentRepository)
return $workspacesArray;
}

public function predictRemoveNodeFeedbackFromDiscardIndividualNodesFromWorkspaceCommand(
DiscardIndividualNodesFromWorkspace $command,
ContentRepository $contentRepository
): array {
$workspace = $contentRepository->getWorkspaceFinder()->findOneByName($command->workspaceName);
if (is_null($workspace)) {
return Nodes::createEmpty();
}

$changeFinder = $contentRepository->projectionState(ChangeFinder::class);
$changes = $changeFinder->findByContentStreamId($workspace->currentContentStreamId);

$handledNodes = [];
$result = [];
foreach ($changes as $change) {
if ($change->created) {
foreach ($command->nodesToDiscard as $nodeToDiscard) {
if (in_array($nodeToDiscard, $handledNodes)) {
continue;
}

if (
$nodeToDiscard->contentStreamId->equals($change->contentStreamId)
&& $nodeToDiscard->nodeAggregateId->equals($change->nodeAggregateId)
&& $nodeToDiscard->dimensionSpacePoint->equals($change->originDimensionSpacePoint)
) {
$subgraph = $contentRepository->getContentGraph()
->getSubgraph(
$nodeToDiscard->contentStreamId,
$nodeToDiscard->dimensionSpacePoint,
VisibilityConstraints::withoutRestrictions()
);

$childNode = $subgraph->findNodeById($nodeToDiscard->nodeAggregateId);
$parentNode = $subgraph->findParentNode($nodeToDiscard->nodeAggregateId);
if ($parentNode) {
$result[] = new RemoveNode($childNode, $parentNode);
$handledNodes[] = $nodeToDiscard;
}
}
}
}
}

return $result;
}

private function getClosestDocumentNode(Node $node): ?Node
{
$subgraph = $this->contentRepositoryRegistry->subgraphForNode($node);
Expand Down
21 changes: 15 additions & 6 deletions Classes/Controller/BackendServiceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -294,18 +294,27 @@ public function discardAction(array $nodeContextPaths): void
$nodeAddress->dimensionSpacePoint
);
}
$contentRepository->handle(
DiscardIndividualNodesFromWorkspace::create(
$workspaceName,
NodeIdsToPublishOrDiscard::create(...$nodeIdentifiersToDiscard)
)
)->block();

$command = DiscardIndividualNodesFromWorkspace::create(
$workspaceName,
NodeIdsToPublishOrDiscard::create(...$nodeIdentifiersToDiscard)
);
$removeNodeFeedback = $this->workspaceService
->predictRemoveNodeFeedbackFromDiscardIndividualNodesFromWorkspaceCommand(
$command,
$contentRepository
);

$contentRepository->handle($command)->block();

$success = new Success();
$success->setMessage(sprintf('Discarded %d node(s).', count($nodeContextPaths)));

$updateWorkspaceInfo = new UpdateWorkspaceInfo($contentRepositoryId, $workspaceName);
$this->feedbackCollection->add($success);
foreach ($removeNodeFeedback as $removeNode) {
$this->feedbackCollection->add($removeNode);
}
$this->feedbackCollection->add($updateWorkspaceInfo);
} catch (\Exception $e) {
$error = new Error();
Expand Down
1 change: 0 additions & 1 deletion Classes/Domain/Model/ChangeInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
* source code.
*/


use Neos\ContentRepository\Core\Projection\ContentGraph\Node;

/**
Expand Down
3 changes: 0 additions & 3 deletions Classes/Domain/Model/Changes/MoveAfter.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,6 @@ public function apply(): void
$updateParentNodeInfo->setNode($parentNodeOfPreviousSibling);
$this->feedbackCollection->add($updateParentNodeInfo);

$removeNode = new RemoveNode($subject, $parentNodeOfPreviousSibling);
$this->feedbackCollection->add($removeNode);

$this->finish($subject);
}
}
Expand Down
3 changes: 0 additions & 3 deletions Classes/Domain/Model/Changes/MoveBefore.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,6 @@ public function apply(): void

$this->feedbackCollection->add($updateParentNodeInfo);

$removeNode = new RemoveNode($subject, $succeedingSiblingParent);
$this->feedbackCollection->add($removeNode);

$this->finish($subject);
}
}
Expand Down
3 changes: 0 additions & 3 deletions Classes/Domain/Model/Changes/MoveInto.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,6 @@ public function apply(): void
$updateParentNodeInfo->setNode($parentNode);
$this->feedbackCollection->add($updateParentNodeInfo);

$removeNode = new RemoveNode($subject, $parentNode);
$this->feedbackCollection->add($removeNode);

$this->finish($subject);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,20 @@ protected function renderContent(ControllerContext $controllerContext): string|R

if ($this->nodeDomAddress) {
$fusionView = new FusionView();
$fusionView->setControllerContext($controllerContext);

$fakeActionRequest = clone $controllerContext->getRequest();
$fakeActionRequest->setControllerPackageKey('Neos.Neos');
$fakeActionRequest->setControllerName('Frontend\\Node');
$fakeActionRequest->setControllerActionName('edit');

$fakeControllerContext = new ControllerContext(
$fakeActionRequest,
$controllerContext->getResponse(),
$controllerContext->getArguments(),
$controllerContext->getUriBuilder(),
);

$fusionView->setControllerContext($fakeControllerContext);

$fusionView->assign('value', $this->node);
$fusionView->setFusionPath($this->nodeDomAddress->getFusionPathForContentRendering());
Expand Down
20 changes: 16 additions & 4 deletions Classes/Domain/Model/Feedback/Operations/RemoveNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry;
use Neos\Flow\Annotations as Flow;
use Neos\Neos\FrontendRouting\NodeAddressFactory;
use Neos\Neos\FrontendRouting\NodeAddress;
use Neos\ContentRepository\Core\Projection\ContentGraph\Node;
use Neos\Flow\Mvc\Controller\ControllerContext;
use Neos\Neos\Ui\Domain\Model\AbstractFeedback;
Expand All @@ -25,6 +26,10 @@ class RemoveNode extends AbstractFeedback

protected Node $parentNode;

private NodeAddress $nodeAddress;

private NodeAddress $parentNodeAddress;

/**
* @Flow\Inject
* @var ContentRepositoryRegistry
Expand All @@ -37,6 +42,15 @@ public function __construct(Node $node, Node $parentNode)
$this->parentNode = $parentNode;
}

protected function initializeObject(): void
{
$contentRepository = $this->contentRepositoryRegistry->get($this->node->subgraphIdentity->contentRepositoryId);
$nodeAddressFactory = NodeAddressFactory::create($contentRepository);

$this->nodeAddress = $nodeAddressFactory->createFromNode($this->node);
$this->parentNodeAddress = $nodeAddressFactory->createFromNode($this->parentNode);
}

public function getNode(): Node
{
return $this->node;
Expand Down Expand Up @@ -87,11 +101,9 @@ public function isSimilarTo(FeedbackInterface $feedback)
*/
public function serializePayload(ControllerContext $controllerContext)
{
$contentRepository = $this->contentRepositoryRegistry->get($this->node->subgraphIdentity->contentRepositoryId);
$nodeAddressFactory = NodeAddressFactory::create($contentRepository);
return [
'contextPath' => $nodeAddressFactory->createFromNode($this->node)->serializeForUri(),
'parentContextPath' => $nodeAddressFactory->createFromNode($this->parentNode)->serializeForUri()
'contextPath' => $this->nodeAddress->serializeForUri(),
'parentContextPath' => $this->parentNodeAddress->serializeForUri()
];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,20 @@ protected function renderContent(ControllerContext $controllerContext): string|R
$parentDomAddress = $this->getParentDomAddress();
if ($parentDomAddress) {
$fusionView = new FusionView();
$fusionView->setControllerContext($controllerContext);

$fakeActionRequest = clone $controllerContext->getRequest();
$fakeActionRequest->setControllerPackageKey('Neos.Neos');
$fakeActionRequest->setControllerName('Frontend\\Node');
$fakeActionRequest->setControllerActionName('edit');

$fakeControllerContext = new ControllerContext(
$fakeActionRequest,
$controllerContext->getResponse(),
$controllerContext->getArguments(),
$controllerContext->getUriBuilder(),
);

$fusionView->setControllerContext($fakeControllerContext);

$fusionView->assign('value', $parentNode);
$fusionView->setFusionPath($parentDomAddress->getFusionPath());
Expand Down
1 change: 0 additions & 1 deletion Classes/Domain/Model/ReferencingChangeInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

use Neos\ContentRepository\Core\Projection\ContentGraph\Node;


/**
* A change that needs to reference another node
*/
Expand Down
2 changes: 1 addition & 1 deletion Classes/Domain/Service/NodePropertyConverterService.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public function getProperty(Node $node, $propertyName)
);

return $this->toNodeIdentifierStrings($references);
// Here, the normal property access logic starts.
// Here, the normal property access logic starts.
} elseif ($propertyName[0] === '_' && $propertyName !== '_hiddenInIndex') {
$propertyValue = ObjectAccess::getProperty($node, ltrim($propertyName, '_'));
} else {
Expand Down
14 changes: 11 additions & 3 deletions Classes/Fusion/Helper/NodeInfoHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ protected function getUriInformation(Node $node, ControllerContext $controllerCo
if (!$node->nodeType->isOfType($this->documentNodeTypeRole)) {
return $nodeInfo;
}
$nodeInfo['uri'] = $this->previewUri($node, $controllerContext);
$nodeInfo['uri'] = $this->editUri($node, $controllerContext);
return $nodeInfo;
}

Expand Down Expand Up @@ -281,8 +281,8 @@ protected function renderChildrenInformation(Node $node, string $nodeTypeFilterS
// child nodes for content tree, must not include those nodes filtered out by `baseNodeType`
$contentChildNodes = $subgraph->findChildNodes(
$node->nodeAggregateId,
FindChildNodesFilter::create(nodeTypeConstraints:
$this->buildContentChildNodeFilterString()
FindChildNodesFilter::create(
nodeTypeConstraints: $this->buildContentChildNodeFilterString()
)
);
$childNodes = $documentChildNodes->merge($contentChildNodes);
Expand Down Expand Up @@ -442,6 +442,14 @@ public function uri(Node|NodeAddress $nodeAddress, ControllerContext $controller
return (string)NodeUriBuilder::fromRequest($controllerContext->getRequest())->uriFor($nodeAddress);
}

public function editUri(Node $node, ControllerContext $controllerContext): string
{
$contentRepository = $this->contentRepositoryRegistry->get($node->subgraphIdentity->contentRepositoryId);
$nodeAddressFactory = NodeAddressFactory::create($contentRepository);
$nodeAddress = $nodeAddressFactory->createFromNode($node);
return (string)NodeUriBuilder::fromRequest($controllerContext->getRequest())->editUriFor($nodeAddress);
}

public function previewUri(Node $node, ControllerContext $controllerContext): string
{
$contentRepository = $this->contentRepositoryRegistry->get($node->subgraphIdentity->contentRepositoryId);
Expand Down
2 changes: 1 addition & 1 deletion Configuration/Settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ Neos:
personalWorkspace: '${Neos.Ui.Workspace.getPersonalWorkspace(contentRepositoryId)}'
ui:
contentCanvas:
src: '${Neos.Ui.NodeInfo.uri(documentNode, controllerContext)}'
src: '${Neos.Ui.NodeInfo.editUri(documentNode, controllerContext)}'
backgroundColor: '${Configuration.setting(''Neos.Neos.Ui.contentCanvas.backgroundColor'')}'
debugMode: false
editPreviewMode: '${q(user).property("preferences.preferences")["contentEditing.editPreviewMode"] || Configuration.setting(''Neos.Neos.userInterface.defaultEditPreviewMode'')}'
Expand Down
12 changes: 6 additions & 6 deletions Resources/Private/Fusion/Prototypes/Page.fusion
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ prototype(Neos.Neos:Page) {

@process.json = ${Json.stringify(value)}
@process.wrapInJsObject = ${'<script>window[\'@Neos.Neos.Ui:DocumentInformation\']=' + value + '</script>'}
@if.inBackend = ${Neos.Node.inBackend(documentNode)}
@if.inBackend = ${Neos.Backend.isEditMode(request) || Neos.Backend.isPreviewMode(request)}

// We need to ensure the JS backend information is always up to date, especially
// when child nodes change. Otherwise errors like the following might happen:
Expand All @@ -35,11 +35,11 @@ prototype(Neos.Neos:Page) {
entryIdentifier {
jsBackendInfo = 'javascriptBackendInformation'
documentNode = ${Neos.Caching.entryIdentifierForNode(documentNode)}
inBackend = ${Neos.Node.inBackend(documentNode)}
inBackend = ${Neos.Backend.isEditMode(request) || Neos.Backend.isPreviewMode(request)}
}
entryTags {
1 = ${Neos.Caching.nodeTag(documentNode)}
2 = ${Neos.Node.inBackend(documentNode) ? Neos.Caching.descendantOfTag(documentNode) : null}
2 = ${(Neos.Backend.isEditMode(request) || Neos.Backend.isPreviewMode(request)) ? Neos.Caching.descendantOfTag(documentNode) : null}
}
}
}
Expand All @@ -51,18 +51,18 @@ prototype(Neos.Neos:Page) {
compiledResourcePackage = ${Neos.Ui.StaticResources.compiledResourcePackage()}

sectionName = 'guestFrameApplication'
@if.inBackend = ${Neos.Node.inBackend(documentNode)}
@if.inBackend = ${Neos.Backend.isEditMode(request) || Neos.Backend.isPreviewMode(request)}
}
}

neosBackendContainer = '<div id="neos-backend-container"></div>'
neosBackendContainer.@position = 'before closingBodyTag'
[email protected] = ${Neos.Node.inBackend(documentNode)}
[email protected] = ${Neos.Backend.isEditMode(request) || Neos.Backend.isPreviewMode(request)}

neosBackendNotification = Neos.Fusion:Template {
@position = 'before closingBodyTag'
templatePath = 'resource://Neos.Neos.Ui/Private/Templates/Backend/GuestNotificationScript.html'
@if.inBackend = ${Neos.Node.inBackend(documentNode)}
@if.inBackend = ${Neos.Backend.isEditMode(request) || Neos.Backend.isPreviewMode(request)}
}

@exceptionHandler = 'Neos\\Neos\\Ui\\Fusion\\ExceptionHandler\\PageExceptionHandler'
Expand Down
2 changes: 1 addition & 1 deletion Resources/Private/Fusion/Prototypes/Shortcut.fusion
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ prototype(Neos.Neos:Page) {
}

@if {
inBackend = ${Neos.Node.inBackend(documentNode)}
inBackend = ${Neos.Backend.isEditMode(request) || Neos.Backend.isPreviewMode(request)}
isShortcut = ${q(node).is('[instanceof Neos.Neos:Shortcut]')}
}
}
Expand Down
Loading