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: Allow to enable Fusion caching for Behat tests #5014
Merged
mhsdesign
merged 2 commits into
neos:9.0
from
dlubitz:90/feature/allow-fusion-cache-in-behat
Apr 29, 2024
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
Neos.Neos/Tests/Behavior/Features/Fusion/ContentCache.feature
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
@flowEntities @contentrepository | ||
Feature: Tests for Fusion ContentCache | ||
Background: | ||
Given I have Fusion content cache enabled | ||
And I have the following Fusion setup: | ||
"""fusion | ||
include: resource://Neos.Fusion/Private/Fusion/Root.fusion | ||
include: resource://Neos.Neos/Private/Fusion/Root.fusion | ||
|
||
prototype(Neos.Neos:Test.ContentCache) < prototype(Neos.Fusion:Component) { | ||
foo = '' | ||
renderer = ${props.foo} | ||
@cache { | ||
mode = 'cached' | ||
entryIdentifier { | ||
test = 'test' | ||
} | ||
} | ||
} | ||
|
||
""" | ||
|
||
Scenario: Render a cached prototype and check if rerendering doesn't happen on second try | ||
When I execute the following Fusion code: | ||
"""fusion | ||
test = Neos.Neos:Test.ContentCache { | ||
foo = 'some-cached-string' | ||
} | ||
""" | ||
Then I expect the following Fusion rendering result: | ||
""" | ||
some-cached-string | ||
""" | ||
When I execute the following Fusion code: | ||
"""fusion | ||
test = Neos.Neos:Test.ContentCache { | ||
foo = 'some-other-string' | ||
} | ||
""" | ||
Then I expect the following Fusion rendering result: | ||
""" | ||
some-cached-string | ||
""" | ||
|
||
|
||
Scenario: Check if cached got flushed before running a new scenario and no leftover of last test is there | ||
When I execute the following Fusion code: | ||
"""fusion | ||
test = Neos.Neos:Test.ContentCache { | ||
foo = 'some-new-string' | ||
} | ||
""" | ||
Then I expect the following Fusion rendering result: | ||
""" | ||
some-new-string | ||
""" | ||
When I execute the following Fusion code: | ||
"""fusion | ||
test = Neos.Neos:Test.ContentCache { | ||
foo = 'totally-different-string' | ||
} | ||
""" | ||
Then I expect the following Fusion rendering result: | ||
""" | ||
some-new-string | ||
""" |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm i understand the idea but this is not how fusion works normally ... it. doesnt change its fusion code.
I rather have the test follow how fusion works:
or do you think differently?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, maybe. But actually the test work as expected 🤔 And actually this test it's just ensuring, that a caching is enabled.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, but if I think about this...
The tests I need this for, will look the same. I need somehow check, if a already cached entry got changed, because of a cache invalidation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Imo what we want to test is this:
that way the test does exactly what we do when we run fusion in multiple requests.
Changing the fusion configuration at runtime might work in this test environment but is not how fusion is supposed to work and this behaviour might actually be buggy. So id prefer that ^^
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like and IMO we could have a test for both scenarios
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, IIRC this is exactly the preparation for such tests to cover the behaviour of the content cache flusher, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like to keep it as it is. We use this existing feature already in multiple test cases and all I want to add with this PR is the ability to enable tjhe content cache. I guess an change in "how to test fusion" would be nice, but is currently not on my todo list.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dlubitz for the record: my blabbering above was meant as "this could be done as follow up", I already approved this one.
However, Marc-Henry has a point ofc. We should try to make those tests as realistic as possible.
@mhsdesign what do you think of merging this one as is and then tweaking this (and the other!) features along the lines you suggested?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, yes... I know. I was just trying to convince @mhsdesign to postpone that 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay i see im overruled thats fine ^^. And i also agree that its unfair to block denny while i approved the initial pr that introduced this syntax #4641 i was thinking at that time that this might be a good idea :) So its definitely no drama and we would gain a lot if we have tests regarding the content cache in any syntax so thanks for dealing with this ❤️