diff --git a/Classes/Suffle/Snapshot/Fusion/FusionService.php b/Classes/Suffle/Snapshot/Fusion/FusionService.php index 04d380b..078d8f4 100644 --- a/Classes/Suffle/Snapshot/Fusion/FusionService.php +++ b/Classes/Suffle/Snapshot/Fusion/FusionService.php @@ -28,11 +28,8 @@ class FusionService extends NeosFusionService */ protected $autoIncludeConfiguration = array(); - /** - * @Flow\InjectConfiguration() - * @var array - */ - protected $settings; + #[Flow\InjectConfiguration] + protected ?array $settings; /** * Returns a merged fusion object tree in the context of the given site-package @@ -143,26 +140,22 @@ public function getPrototypeNamesForTesting(string $siteResourcesPackageKey): ar /** * Add snapshot rendering configuration to the fusion-ast - * - * @param array $fusionAst - * @return array */ protected function filterSnapshotPrototypes(array $fusionAst): array { - $snapshotPrototypeConfigurations = []; $prototypesList = []; $annotationKey = $this->settings['annotationKey'] ?: 'snapshot'; + $excludedPackageKeys = $this->settings['exclude']['packageKeys'] ?? []; foreach ($fusionAst['__prototypes'] as $prototypeName => $prototypeConfiguration) { + $prototypePackageKey = explode(':', $prototypeName)[0]; if (array_key_exists('__meta', $prototypeConfiguration) && array_key_exists($annotationKey, $prototypeConfiguration['__meta']) + && !in_array($prototypePackageKey, $excludedPackageKeys, true) ) { - $snapshotPrototypeConfigurations[$prototypeName] = $prototypeConfiguration; - array_push($prototypesList, $prototypeName); + $prototypesList[] = $prototypeName; } } - - return $prototypesList; } } diff --git a/Configuration/Settings.yaml b/Configuration/Settings.yaml index 8ba2ab4..4020622 100644 --- a/Configuration/Settings.yaml +++ b/Configuration/Settings.yaml @@ -3,6 +3,8 @@ Suffle: snapshotSavePath: '%FLOW_PATH_DATA%Persistent/fusionSnapshots/' annotationKey: 'snapshot' previewPrototypeName: 'Suffle.Snapshot:Preview.Page' + exclude: + packageKeys: [] Neos: Flow: diff --git a/README.md b/README.md index 64bab6a..7ca8d44 100644 --- a/README.md +++ b/README.md @@ -26,16 +26,23 @@ Suffle: Snapshot: snapshotSavePath: '%FLOW_PATH_DATA%Persistent/fusionSnapshots/' annotationKey: 'snapshot' + exclude: + packageKeys: [] ```` ### snapshotSavePath The snapshotSavePath defines the directory, where the snapshots are saved. If you use any Version Control Software like Git, make sure not to ignore this folder. -## annotationKey +### annotationKey The annotationKey can be set, if you want to use another name to annotate test cases. Since the syntax of the cases is the same used for the [Monocle Styleguide](https://github.com/sitegeist/Sitegeist.Monocle), you can use the styleguide annotation for the testing as well. +### exclude.packageKeys + +You can exclude certain packages from the snapshot testing. +This is useful if you have packages that are not relevant for the snapshot testing. + ## Annotating Test Cases As long as the annotation ist present, the component is tested in a pure version, which uses the basic props of the Fusion Component.