Skip to content

Add deterministic SimpleComponent screenshot test#99

Open
EmilioBejasa wants to merge 9 commits intomainfrom
deterministic-simple-component
Open

Add deterministic SimpleComponent screenshot test#99
EmilioBejasa wants to merge 9 commits intomainfrom
deterministic-simple-component

Conversation

@EmilioBejasa
Copy link
Copy Markdown
Collaborator

Summary

  • Adds SimpleComponent to the library — a static, stateless <View><Text>Hello</Text></View> with no timers, animations, or random values, so it renders identically every run
  • Registers it with AppRegistry in index.js
  • Adds SimpleComponentScreenshotTest which mounts it via WindowManager + ReactSurface (same approach as BaseStoryScreenshotTest), waits two Choreographer frames for Fabric to flush, then snaps a screenshot

This gives us a known-good deterministic baseline to verify the screenshot pipeline works before testing the more complex stories.

Test plan

  • CI passes screenshotSimpleComponent
  • Screenshot shows a white view with "Hello" centered

🤖 Generated with Claude Code

EmilioBejasa and others added 5 commits March 27, 2026 16:08
Kicks off loadStory() for all stories immediately in configure(), using
_preview.storyStoreValue directly (bypasses _preview.ready() which only
resolves when the Storybook UI renders — never in a test run).

By the time StoryRenderer mounts, _idToPrepared is already fully
populated, so the render effect is synchronous (no await in the hot
path). Combined with the JS-driven Promise handshake from the previous
experiment, this removes all async work between "set story" and
"notify native ready".

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Without an explicit measure/layout pass, Screenshot.snap(surface.view)
captures a blank bitmap on Fabric. Mirror what the old arch path already
does with ViewHelpers so the view tree is software-rendered and properly
sized before capture.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
view.draw(canvas) skips Fabric child views that have hardware display
lists, leaving only the root container's white background. Walking the
entire view tree and setting LAYER_TYPE_SOFTWARE on every node ensures
all content is visible to the software canvas used by Screenshot.snap().

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@EmilioBejasa EmilioBejasa changed the base branch from experiment/eager-story-prep to main March 31, 2026 22:07
EmilioBejasa and others added 4 commits March 31, 2026 18:20
Documents why waitTwoFrames exists with a regression-guarding assertion test.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The "childCount == 0 before waitTwoFrames" assumption was wrong — Fabric
can mount children synchronously before the check runs.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@EmilioBejasa EmilioBejasa requested a review from tdrhq April 2, 2026 15:53
Comment on lines +55 to +70
instrumentation.runOnMainSync {
view.setLayerType(View.LAYER_TYPE_SOFTWARE, null)
wm.addView(view, params)
surface.start()
}

waitTwoFrames()

instrumentation.runOnMainSync {
setLayerTypeSoftwareRecursively(view)
Screenshot.snap(view).setName("simple_component").record()
}

instrumentation.runOnMainSync {
surface.stop()
wm.removeView(view)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not deterministic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants