Improve consistency of scrolled's Jest test suite and document rules#2436
Merged
Conversation
Expose toContainContentElementBox and toContainFitViewport via pageflow-scrolled/testHelpers so content element plugin authors can assert box and FitViewport state directly, without relying on internal page objects or full entry renders. The matchers accept a plain DOM node or a page object and run under the lightweight renderInContentElement helper. Migrate the inline image and content element box specs as the first adopters and drop the page object predicates they replace.
Extract the page object's margin, scroll space, and alignment predicates into internal jest matchers (toHaveContentElementMargin, toHaveScrollSpace, toHaveAlignment), registered via useContentElementLayoutMatchers. This keeps page objects focused on locating and acting, and lets the same assertions read consistently across specs. These stay internal to the package since they assert framework state applied around the content element rather than chrome the element itself controls.
Give contributors a single written reference for choosing a render helper, custom wrappers, setup hooks, the public/internal matcher split, and spec layout — complementing the generated JSDoc, which is less accessible outside the docs site. Surface the public content element matchers and the useContentElementMatchers hook in the generated API reference under a Test Helpers heading so content element plugin authors can discover them.
Move specs that split a single source file's tests by topic into a features/ subdirectory, matching the spec-layout convention. This keeps behavior-grouped specs visually distinct from unit specs that mirror a source file or a named export.
Replace the white-box hook specs with feature specs that render a probe content element through renderEntry and assert the hook's observable value — in the frontend context (default provider, reads the browser) and the inline-editing context (provider driven by the editor's emulation-mode messages). This commits the tests to the usePhonePlatform interface rather than the provider-replacement wiring, so the providers can be restructured without breaking the specs.
Reorganize the testing conventions guides so they work as a reference for coding agents and collaborators extending the test suite: each guide now leads with a decision procedure, followed by rationale and a scannable checklist that frontloads review judgment. Volatile detail such as matcher signatures and import paths defers to the source files to keep the guides from drifting out of date; examples remain only where they disambiguate a rule.
`renderWithReviewState` only sets up state for testing review UI components, which no plugin is expected to extend, so it does not belong in the public `testHelpers` package. Moving it alongside the other package-internal helpers keeps the shipped `testHelpers` surface uniformly public and drops test-only code from the build.
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
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.
No description provided.