Skip to content

Commit

Permalink
Merge pull request #3569 from neos/task/e2e-tests-on-9-0
Browse files Browse the repository at this point in the history
TASK: Make E2E tests work for Neos 9.0
  • Loading branch information
mhsdesign authored Sep 23, 2023
2 parents 5c4d8ff + dd99278 commit d632b6a
Show file tree
Hide file tree
Showing 69 changed files with 562 additions and 1,309 deletions.
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
51 changes: 49 additions & 2 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,8 +24,8 @@
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")
Expand Down Expand Up @@ -155,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 @@ -93,9 +93,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
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()
];
}
}
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ test-e2e:
bash Tests/IntegrationTests/e2e.sh chrome

## Executes integration tests locally in a docker-compose setup.
#
# Note: On mac os you might need those two additional `/etc/hosts` entries:
# 127.0.0.1 onedimension.localhost
# 127.0.0.1 twodimensions.localhost
test-e2e-docker: build-e2e-testing
@bash Tests/IntegrationTests/e2e-docker.sh $(or $(browser),chrome)

Expand Down

This file was deleted.

Binary file not shown.
Loading

0 comments on commit d632b6a

Please sign in to comment.