From 5478f0aa484f8cca41e40516b5dc750fe73f8368 Mon Sep 17 00:00:00 2001 From: Patrice Kaufmann <41791606+patricekaufmann@users.noreply.github.com> Date: Tue, 11 Jul 2023 18:15:14 +0200 Subject: [PATCH 01/28] BUGFIX: fix specific cases where the requested croparea would be larger than the image itself --- .../src/SecondaryEditors/ImageCropper/index.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/neos-ui-editors/src/SecondaryEditors/ImageCropper/index.js b/packages/neos-ui-editors/src/SecondaryEditors/ImageCropper/index.js index ffab7c0302..834b01471f 100644 --- a/packages/neos-ui-editors/src/SecondaryEditors/ImageCropper/index.js +++ b/packages/neos-ui-editors/src/SecondaryEditors/ImageCropper/index.js @@ -159,8 +159,14 @@ export default class ImageCropper extends PureComponent { const normalizedAspectRatioHeight = currentAspectRatioStrategy.height / aspectRatioGcd; // pixel perfect calculations - const naturalCropWidth = Math.floor(imageWidth * (cropArea.width / 100) / normalizedAspectRatioWidth) * normalizedAspectRatioWidth; - const naturalCropHeight = naturalCropWidth / normalizedAspectRatioWidth * normalizedAspectRatioHeight; + let naturalCropWidth = Math.floor(imageWidth * (cropArea.width / 100) / normalizedAspectRatioWidth) * normalizedAspectRatioWidth; + let naturalCropHeight = naturalCropWidth / normalizedAspectRatioWidth * normalizedAspectRatioHeight; + + while (naturalCropHeight > imageHeight) { + // can't crop area larger than image itself, so keep subtracting normalized aspect ratio values until area is valid + naturalCropHeight -= normalizedAspectRatioHeight; + naturalCropWidth -= normalizedAspectRatioWidth; + } // modify cropArea with pixel snapping values cropArea.width = (naturalCropWidth / imageWidth) * 100; From c829cb956133685d493da00d42e343b2e5147a18 Mon Sep 17 00:00:00 2001 From: Wilhelm Behncke Date: Tue, 2 Jul 2024 19:29:35 +0200 Subject: [PATCH 02/28] TASK: Make tree node drop targets discoverable in E2E tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The drop targets used to have `visibility: hidden` set via CSS. Testcafé considers them absent, which is semantically correct. This commit uses a different CSS tactic do make the drop targets invisible, but "physically" present. --- .../react-ui-components/src/Tree/node.module.css | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/packages/react-ui-components/src/Tree/node.module.css b/packages/react-ui-components/src/Tree/node.module.css index 47b6a66286..4ff78fe870 100644 --- a/packages/react-ui-components/src/Tree/node.module.css +++ b/packages/react-ui-components/src/Tree/node.module.css @@ -132,23 +132,25 @@ right: 0; padding-left: 15px; height: 2px; - visibility: hidden; - - [data-is-drag-happening] & { - visibility: visible; - } + z-index: -1; } .dropTarget--before { top: -5px; - z-index: var(--zIndex-SideBar-DropTargetBefore); padding-top: 4px; padding-bottom: 4px; + + [data-is-drag-happening] & { + z-index: var(--zIndex-SideBar-DropTargetBefore); + } } .dropTarget--after { bottom: 1px; - z-index: var(--zIndex-SideBar-DropTargetAfter); padding-top: 6px; padding-bottom: 0; + + [data-is-drag-happening] & { + z-index: var(--zIndex-SideBar-DropTargetAfter); + } } .dropTarget__inner { visibility: hidden; From 57aa6b61c0b36c2079f4834cde233cf12c321800 Mon Sep 17 00:00:00 2001 From: Wilhelm Behncke Date: Tue, 2 Jul 2024 19:39:22 +0200 Subject: [PATCH 03/28] TASK: Make document tree filter toggle button discoverable in E2E tests --- .../src/Containers/LeftSideBar/NodeTreeSearchBar/index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/neos-ui/src/Containers/LeftSideBar/NodeTreeSearchBar/index.js b/packages/neos-ui/src/Containers/LeftSideBar/NodeTreeSearchBar/index.js index 5c46cbaeb6..bd493186de 100644 --- a/packages/neos-ui/src/Containers/LeftSideBar/NodeTreeSearchBar/index.js +++ b/packages/neos-ui/src/Containers/LeftSideBar/NodeTreeSearchBar/index.js @@ -96,6 +96,7 @@ class NodeTreeSearchBar extends PureComponent { return (
Date: Tue, 2 Jul 2024 19:40:03 +0200 Subject: [PATCH 04/28] TASK: Make node tree filter select box reset button discoverable in E2E tests --- .../LeftSideBar/NodeTreeSearchBar/NodeTreeFilter/index.js | 1 + packages/react-ui-components/src/SelectBox/selectBox.js | 5 +++++ .../src/SelectBox_Header/selectBox_Header.js | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/neos-ui/src/Containers/LeftSideBar/NodeTreeSearchBar/NodeTreeFilter/index.js b/packages/neos-ui/src/Containers/LeftSideBar/NodeTreeSearchBar/NodeTreeFilter/index.js index 4edc1a3dde..f70915f0c0 100644 --- a/packages/neos-ui/src/Containers/LeftSideBar/NodeTreeSearchBar/NodeTreeFilter/index.js +++ b/packages/neos-ui/src/Containers/LeftSideBar/NodeTreeSearchBar/NodeTreeFilter/index.js @@ -60,6 +60,7 @@ export default class NodeTreeFilter extends PureComponent { return (
- + ); From 71300ecd81d8d296e15be23d17fffddd2b2525ed Mon Sep 17 00:00:00 2001 From: Wilhelm Behncke Date: Tue, 2 Jul 2024 19:40:24 +0200 Subject: [PATCH 05/28] TASK: Make document tree search reset button discoverable in E2E tests --- .../LeftSideBar/NodeTreeSearchBar/NodeTreeSearchInput/index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/neos-ui/src/Containers/LeftSideBar/NodeTreeSearchBar/NodeTreeSearchInput/index.js b/packages/neos-ui/src/Containers/LeftSideBar/NodeTreeSearchBar/NodeTreeSearchInput/index.js index 4090872428..8a410b4801 100644 --- a/packages/neos-ui/src/Containers/LeftSideBar/NodeTreeSearchBar/NodeTreeSearchInput/index.js +++ b/packages/neos-ui/src/Containers/LeftSideBar/NodeTreeSearchBar/NodeTreeSearchInput/index.js @@ -45,6 +45,7 @@ const NodeTreeSearchInput = ({ /> {showClear && ( Date: Tue, 2 Jul 2024 19:55:47 +0200 Subject: [PATCH 06/28] TASK: Add mechanism that allows to alter Settings during E2E test For this, the E2E test distribution now exposes two endpoints: - /test/write-additional-settings - /test/remove-additional-settings An E2E test can thus via `fetch` add settings to the current setup and remove the altered settings on cleanup. This became necessary, because the tests for the node tree preset feature require explicit settings to configure node tree presets. By default, node tree presets are inactive. --- .../RemoveAdditionalSettingsController.php | 72 +++++++++++++++++++ .../RemoveAdditionalSettingsCommand.php | 30 ++++++++ ...RemoveAdditionalSettingsCommandHandler.php | 43 +++++++++++ .../WriteAdditionalSettingsController.php | 72 +++++++++++++++++++ .../WriteAdditionalSettingsCommand.php | 42 +++++++++++ .../WriteAdditionalSettingsCommandHandler.php | 48 +++++++++++++ .../Configuration/Policy.yaml | 15 ++++ .../Configuration/Routes.yaml | 17 +++++ .../Configuration/Settings.Neos.Flow.yaml | 6 ++ 9 files changed, 345 insertions(+) create mode 100644 Tests/IntegrationTests/SharedNodeTypesPackage/Classes/Application/RemoveAdditionalSettings/Controller/RemoveAdditionalSettingsController.php create mode 100644 Tests/IntegrationTests/SharedNodeTypesPackage/Classes/Application/RemoveAdditionalSettings/RemoveAdditionalSettingsCommand.php create mode 100644 Tests/IntegrationTests/SharedNodeTypesPackage/Classes/Application/RemoveAdditionalSettings/RemoveAdditionalSettingsCommandHandler.php create mode 100644 Tests/IntegrationTests/SharedNodeTypesPackage/Classes/Application/WriteAdditionalSettings/Controller/WriteAdditionalSettingsController.php create mode 100644 Tests/IntegrationTests/SharedNodeTypesPackage/Classes/Application/WriteAdditionalSettings/WriteAdditionalSettingsCommand.php create mode 100644 Tests/IntegrationTests/SharedNodeTypesPackage/Classes/Application/WriteAdditionalSettings/WriteAdditionalSettingsCommandHandler.php create mode 100644 Tests/IntegrationTests/SharedNodeTypesPackage/Configuration/Policy.yaml create mode 100644 Tests/IntegrationTests/SharedNodeTypesPackage/Configuration/Routes.yaml create mode 100644 Tests/IntegrationTests/SharedNodeTypesPackage/Configuration/Settings.Neos.Flow.yaml diff --git a/Tests/IntegrationTests/SharedNodeTypesPackage/Classes/Application/RemoveAdditionalSettings/Controller/RemoveAdditionalSettingsController.php b/Tests/IntegrationTests/SharedNodeTypesPackage/Classes/Application/RemoveAdditionalSettings/Controller/RemoveAdditionalSettingsController.php new file mode 100644 index 0000000000..badea48a01 --- /dev/null +++ b/Tests/IntegrationTests/SharedNodeTypesPackage/Classes/Application/RemoveAdditionalSettings/Controller/RemoveAdditionalSettingsController.php @@ -0,0 +1,72 @@ +setDispatched(true); + $response->setContentType('application/json'); + + try { + $command = RemoveAdditionalSettingsCommand::fromArray($request->getArguments()); + $this->commandHandler->handle($command); + + $response->setStatusCode(200); + $response->setContent( + json_encode( + ['success' => true], + JSON_THROW_ON_ERROR + ) + ); + } catch (\InvalidArgumentException $e) { + $response->setStatusCode(400); + $response->setContent( + json_encode( + ['error' => [ + 'type' => $e::class, + 'code' => $e->getCode(), + 'message' => $e->getMessage(), + ]], + JSON_THROW_ON_ERROR + ) + ); + } catch (\Exception $e) { + $response->setStatusCode(500); + $response->setContent( + json_encode( + ['error' => [ + 'type' => $e::class, + 'code' => $e->getCode(), + 'message' => $e->getMessage(), + ]], + JSON_THROW_ON_ERROR + ) + ); + } + } +} diff --git a/Tests/IntegrationTests/SharedNodeTypesPackage/Classes/Application/RemoveAdditionalSettings/RemoveAdditionalSettingsCommand.php b/Tests/IntegrationTests/SharedNodeTypesPackage/Classes/Application/RemoveAdditionalSettings/RemoveAdditionalSettingsCommand.php new file mode 100644 index 0000000000..bba253a1b6 --- /dev/null +++ b/Tests/IntegrationTests/SharedNodeTypesPackage/Classes/Application/RemoveAdditionalSettings/RemoveAdditionalSettingsCommand.php @@ -0,0 +1,30 @@ +bootstrap->getSignalSlotDispatcher(); + $dispatcher->connect(Bootstrap::class, 'bootstrapShuttingDown', function () { + $this->bootstrap->getObjectManager()->get(CacheManager::class)->flushCaches(); + }); + } + } +} diff --git a/Tests/IntegrationTests/SharedNodeTypesPackage/Classes/Application/WriteAdditionalSettings/Controller/WriteAdditionalSettingsController.php b/Tests/IntegrationTests/SharedNodeTypesPackage/Classes/Application/WriteAdditionalSettings/Controller/WriteAdditionalSettingsController.php new file mode 100644 index 0000000000..cfbed1e39a --- /dev/null +++ b/Tests/IntegrationTests/SharedNodeTypesPackage/Classes/Application/WriteAdditionalSettings/Controller/WriteAdditionalSettingsController.php @@ -0,0 +1,72 @@ +setDispatched(true); + $response->setContentType('application/json'); + + try { + $command = WriteAdditionalSettingsCommand::fromArray($request->getArguments()); + $this->commandHandler->handle($command); + + $response->setStatusCode(200); + $response->setContent( + json_encode( + ['success' => true], + JSON_THROW_ON_ERROR + ) + ); + } catch (\InvalidArgumentException $e) { + $response->setStatusCode(400); + $response->setContent( + json_encode( + ['error' => [ + 'type' => $e::class, + 'code' => $e->getCode(), + 'message' => $e->getMessage(), + ]], + JSON_THROW_ON_ERROR + ) + ); + } catch (\Exception $e) { + $response->setStatusCode(500); + $response->setContent( + json_encode( + ['error' => [ + 'type' => $e::class, + 'code' => $e->getCode(), + 'message' => $e->getMessage(), + ]], + JSON_THROW_ON_ERROR + ) + ); + } + } +} diff --git a/Tests/IntegrationTests/SharedNodeTypesPackage/Classes/Application/WriteAdditionalSettings/WriteAdditionalSettingsCommand.php b/Tests/IntegrationTests/SharedNodeTypesPackage/Classes/Application/WriteAdditionalSettings/WriteAdditionalSettingsCommand.php new file mode 100644 index 0000000000..9abb345c15 --- /dev/null +++ b/Tests/IntegrationTests/SharedNodeTypesPackage/Classes/Application/WriteAdditionalSettings/WriteAdditionalSettingsCommand.php @@ -0,0 +1,42 @@ + $settings + */ + public function __construct( + public readonly array $settings + ) { + } + + public static function fromArray(array $array): self + { + isset($array['settings']) or + throw new \InvalidArgumentException('"settings" must be set.'); + + is_array($array['settings']) or + throw new \InvalidArgumentException('"settings" must be an array.'); + + return new self( + settings: $array['settings'] + ); + } +} diff --git a/Tests/IntegrationTests/SharedNodeTypesPackage/Classes/Application/WriteAdditionalSettings/WriteAdditionalSettingsCommandHandler.php b/Tests/IntegrationTests/SharedNodeTypesPackage/Classes/Application/WriteAdditionalSettings/WriteAdditionalSettingsCommandHandler.php new file mode 100644 index 0000000000..3b87e3d8df --- /dev/null +++ b/Tests/IntegrationTests/SharedNodeTypesPackage/Classes/Application/WriteAdditionalSettings/WriteAdditionalSettingsCommandHandler.php @@ -0,0 +1,48 @@ +yamlConfigurationSource->save( + Files::concatenatePaths([ + FLOW_PATH_CONFIGURATION, + 'Settings.Additional' + ]), + $command->settings + ); + + $dispatcher = $this->bootstrap->getSignalSlotDispatcher(); + $dispatcher->connect(Bootstrap::class, 'bootstrapShuttingDown', function () { + $this->bootstrap->getObjectManager()->get(CacheManager::class)->flushCaches(); + }); + } +} diff --git a/Tests/IntegrationTests/SharedNodeTypesPackage/Configuration/Policy.yaml b/Tests/IntegrationTests/SharedNodeTypesPackage/Configuration/Policy.yaml new file mode 100644 index 0000000000..dad9151654 --- /dev/null +++ b/Tests/IntegrationTests/SharedNodeTypesPackage/Configuration/Policy.yaml @@ -0,0 +1,15 @@ +--- +privilegeTargets: + + 'Neos\Flow\Security\Authorization\Privilege\Method\MethodPrivilege': + + 'Neos.TestNodeTypes:TestApiAccess': + matcher: 'method(Neos\TestNodeTypes\Application\.*\Controller\.*Controller->processRequest())' + +roles: + + 'Neos.Flow:Everybody': + privileges: + - + privilegeTarget: 'Neos.TestNodeTypes:TestApiAccess' + permission: GRANT diff --git a/Tests/IntegrationTests/SharedNodeTypesPackage/Configuration/Routes.yaml b/Tests/IntegrationTests/SharedNodeTypesPackage/Configuration/Routes.yaml new file mode 100644 index 0000000000..a0ebef023b --- /dev/null +++ b/Tests/IntegrationTests/SharedNodeTypesPackage/Configuration/Routes.yaml @@ -0,0 +1,17 @@ +- + name: 'RemoveAdditionalSettings Command' + uriPattern: 'test/remove-additional-settings' + defaults: + '@package': 'Neos.TestNodeTypes' + '@subpackage': 'Application\RemoveAdditionalSettings' + '@controller': 'RemoveAdditionalSettings' + '@action': 'ignored' + +- + name: 'WriteAdditionalSettings Command' + uriPattern: 'test/write-additional-settings' + defaults: + '@package': 'Neos.TestNodeTypes' + '@subpackage': 'Application\WriteAdditionalSettings' + '@controller': 'WriteAdditionalSettings' + '@action': 'ignored' diff --git a/Tests/IntegrationTests/SharedNodeTypesPackage/Configuration/Settings.Neos.Flow.yaml b/Tests/IntegrationTests/SharedNodeTypesPackage/Configuration/Settings.Neos.Flow.yaml new file mode 100644 index 0000000000..7b866f21bf --- /dev/null +++ b/Tests/IntegrationTests/SharedNodeTypesPackage/Configuration/Settings.Neos.Flow.yaml @@ -0,0 +1,6 @@ +Neos: + Flow: + mvc: + routes: + 'Neos.TestNodeTypes': + position: 'before Neos.Neos' From 9f3e833f5ca4880af589f8693b46f70c1434087f Mon Sep 17 00:00:00 2001 From: Wilhelm Behncke Date: Tue, 2 Jul 2024 19:56:54 +0200 Subject: [PATCH 07/28] TASK: Add E2E tests for node tree presets --- .../Resources/Private/Content/Sites.xml | 481 ++++++++++++++++-- .../1Dimension/nodeTreePresets.e2e.js | 113 ++++ .../NodeTypes/Document/Blog.yaml | 17 + .../NodeTypes/Document/BlogArticle.yaml | 17 + 4 files changed, 590 insertions(+), 38 deletions(-) create mode 100644 Tests/IntegrationTests/Fixtures/1Dimension/nodeTreePresets.e2e.js create mode 100644 Tests/IntegrationTests/SharedNodeTypesPackage/NodeTypes/Document/Blog.yaml create mode 100644 Tests/IntegrationTests/SharedNodeTypesPackage/NodeTypes/Document/BlogArticle.yaml diff --git a/Tests/IntegrationTests/Fixtures/1Dimension/SitePackage/Resources/Private/Content/Sites.xml b/Tests/IntegrationTests/Fixtures/1Dimension/SitePackage/Resources/Private/Content/Sites.xml index 06d505de63..0b506d9d48 100644 --- a/Tests/IntegrationTests/Fixtures/1Dimension/SitePackage/Resources/Private/Content/Sites.xml +++ b/Tests/IntegrationTests/Fixtures/1Dimension/SitePackage/Resources/Private/Content/Sites.xml @@ -16,6 +16,19 @@ home + - @@ -551,6 +551,411 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +