-
Notifications
You must be signed in to change notification settings - Fork 32
Data model lookups + data model binding validations #1473
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
Merged
Merged
Conversation
This file contains hidden or 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
…ctory into the getAllLayoutSets.ts file
…can read all current layout files and trim any comments/trailing commas/etc
…ayout.json scenario as well
…rprisingly it works for every single (working) app with a schema - I did NOT expect that.
…upport for mocked repeating groups, producing nodes with indexed data model bindings, cleaning the layout, aaaand fixing the test so that it actually fails when the path was not found (I suspect it got wrong because 'undefined' is in any array?)
…test. This makes it painfully obvious that the newer oneOf-based schemas create trouble for us.
…o see if it was hard to do - and I think I've made a much better one. Using the library, we had 194 layout sets with errors, but now we're at ~103 (below 100 after accounting for arrays of types with null). This also tries to give app developers a more informed error about why we couldn't seem to find the path, and it's orders of magnitudes faster (while probably sacrificing some edge-cases by not strictly adhering to the allOf/anyOf/oneOf spec).
…handling (makes the flow much easier to read)
…property when misspelled, resolving TODOs
… least one schema that did not expect this.
…rocessed (and possibly faster) way to figure out the location of the data model schema from a pointer/path
… model schema paths, as these may be encoded into JSON pointers in that file
…tching it is deprecated, and it won't work in real apps with multiple data models anyway.
…anguage support came with compromises). Started implementing checks for layout validation for components and data model bindings.
…ple one in dataModelLookups.test.ts
…also be defined in the application metadata (it somehow wasn't, but it surely would fail later in that case). Rewriting in appMetadata.ts to get rid of the deprecated function, and adding an error to the developer tools when this fails for some apps in v4.
…ly solve how to find the root of the data model, and I finally found one (after about 2 days). Using the IDataType defined in the application metadata file, I can figure out the root of the model by looking at the definitions and finding the sub-type that matches the class name in `classRef`. This works for all currently known apps, and should be a lot more future-proof than just picking the first property. Added a test that helped me prove it by comparing all data model bindings in (hopefully) working apps, and only one of them failed (for a few data model bindings), which I believe is a mistake on the app developers part.
# Conflicts: # src/components/presentation/NavBar.test.tsx # src/layout/Custom/CustomWebComponent.test.tsx
… all arguments required. This makes the page order API work again
… errors in the devtools
…isplayed on the devTools button)
bjosttveit
approved these changes
Sep 20, 2023
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.
# Conflicts: # src/layout/RadioButtons/RadioButtonsContainerComponent.test.tsx
SonarCloud Quality Gate failed.
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
Oh boy, this started off simple and then turned into a large undertaking.
To summarize the changes here:
SimpleSchemaTraversal.ts
testUtils.tsx
into a dedicated directory to make it easier to see that the code I wrote to read real-life apps (with their layout configuration files, etc) belongs to tests. This work is included here.JSON.parse()
. That way we could actually read the JSON files in all apps, as the backend parser is more tolerant than ours, and it strips away these comments (and trailing commas, etc) before we see it on the frontend, so these apps worked in real-life situations. See Fixing JSON parsing in schema tests #1439. This work was swallowed in here.getRootElementPath()
used to look up the schema and fetch the first property as the obvious real root of the model. That failed for some newer data models, in effect voiding all schema-based validation for these apps. After lots of struggling, I found a way to look up the 'real root' of models that worked for all existing apps. This is a breaking change, because validations should start working for some apps that didn't before.Related Issue(s)
Verification/QA
kind/*
label to this PR for proper release notes grouping