Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
19 changes: 6 additions & 13 deletions Classes/Suffle/Snapshot/Fusion/FusionService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
}
}
2 changes: 2 additions & 0 deletions Configuration/Settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ Suffle:
snapshotSavePath: '%FLOW_PATH_DATA%Persistent/fusionSnapshots/'
annotationKey: 'snapshot'
previewPrototypeName: 'Suffle.Snapshot:Preview.Page'
exclude:
packageKeys: []

Neos:
Flow:
Expand Down
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down