Skip to content

Improve consistency of scrolled's Jest test suite and document rules#2436

Merged
tf merged 11 commits into
codevise:masterfrom
tf:page-object-matchers
Jun 11, 2026
Merged

Improve consistency of scrolled's Jest test suite and document rules#2436
tf merged 11 commits into
codevise:masterfrom
tf:page-object-matchers

Conversation

@tf

@tf tf commented Jun 11, 2026

Copy link
Copy Markdown
Member

No description provided.

tf added 11 commits June 11, 2026 11:54
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.
@tf tf added this to the v17.2 milestone Jun 11, 2026
@tf tf merged commit 50d36e4 into codevise:master Jun 11, 2026
18 checks passed
@tf tf deleted the page-object-matchers branch June 11, 2026 10:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant