-
Notifications
You must be signed in to change notification settings - Fork 559
Tree schema open polymorphism examples #25805
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
Tree schema open polymorphism examples #25805
Conversation
…to OpenPolcyExamples
…to OpenPolcyExamples
…to OpenPolcyExamples
packages/dds/tree/src/test/README.md
Outdated
| If there is a corresponding `spec` file which is sufficiently large in scope, the tests should be placed within it: | ||
| only when the tests don't cleanly correspond to a particular source file should a separate `integration` file be created. | ||
| When created, the file should be placed in the `src/test` directory's sub folder which is the most nested it can be while still including all the relevant APIs. | ||
| For example an example of using `src/thing/foo` with `src/thing/bar` would belong in `src/test/thing` and could be named something like `fooWithBar.example.ts`. |
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.
Should this not be a test file? I would have expected fooWithBar.spec.ts or fooWithBar.integration.spec.ts or something.
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.
This documentation defines them to be test files, so they are. Just above this is the definition of what we mean by ".spec" in a file, and these do not meet that. Nowhere in here (or anywhere that I know of) do we define that files without ".spec" in there name are not test files. Historically we have inaccurately followed that convention throughout our repo in a mostly undocumented way. Here in tree we have a documented policy (this file) and thus can make changes to the convention (as done here).
I don't think there is any value in making every kind of test file include ".spec" in its file name. If we wanted something to put in the name of every test file, we would pick something like ".test" (well we went with /src/test/ as path prefix which also works).
".spec" (which I assume is short for "specification test") can have a more useful meaning (defined above in this file) if we don't stick it on everything.
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.
Fair enough. I guess my real concern is the overloaded use of ".example.ts". We use that below for examples we want to keep up to date. This seems distinct from that. Seems like it should have a different naming convention.
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.
Actually, the new test suite in this PR does use .integration.ts, so I'm guessing this paragraph just needs to be fixed to say that instead of example.ts.
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.
Oh, .example.ts here is wrong. I was doing that earlier and changed my mind since a lot of examples fit inside of .spec tests. I'll update this
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.
Done.
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.
Pull Request Overview
This PR adds a new integration test file demonstrating the "Open Polymorphism" design pattern and updates the testing documentation to clarify guidance for integration tests and examples.
- Adds comprehensive integration tests showing various approaches to implementing open polymorphic schema patterns
- Updates testing documentation to better distinguish integration tests from spec tests and provide guidance on examples
- Demonstrates component-based composition patterns for managing polymorphic schemas
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 9 comments.
| File | Description |
|---|---|
| packages/dds/tree/src/test/openPolymorphism.integration.ts | New integration test file containing examples and tests for open polymorphism design patterns with schema composition utilities |
| packages/dds/tree/src/test/README.md | Updated test documentation to add integration test guidelines and examples section |
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
|
🔗 Found some broken links! 💔 Run a link check locally to find them. See linkcheck output |
Description
Add some examples showing patterns for open polymorphism with tree schema.
These examples are derived from those in #23084, showing cases which motivate that work, but do not (yet) include the examples from that PR showing how it helps. Merging this PR first will help that one better show its value.
Reviewer Guidance
The review process is outlined on this wiki page.