chore(live-preview): load schemaJSON from proper client config in integration tests #12167
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.
What?
The integration tests in live-preview has been using the
fieldSchemaToJSON
method with wrong params/types.It's defined as
In the test setup
fields
was set toPages.fields
which wasField[]
, not the expectedClientField[]
config
was set toconfig
which wasPromise<SanitizedConfig>
not the expectedClientConfig
Why?
I'm working on some other changes to live-preview where I need the proper values wired up correctly to properly add integration tests.
The test has worked up until now because Field is very similar to ClientField. But it should test with the correct type.
How?
By creating the clientConfig and using the correct types/params when calling fieldSchemaToJSON in the test setup.
Note: Removed test "Collections - Live Preview › merges data", the test worked before because id field is not part of Field, but part of ClientField. So test code does not behave like this in real scenario when real ClientField is used. There are lots of real tests for correct data, removed this one which seems very simple and not correct.