Skip to content

Refactor BaseStoryScreenshotTest to use single activity#75

Draft
EmilioBejasa wants to merge 9 commits intoload-story-event-emitterfrom
refactor-base-story-screenshot-test
Draft

Refactor BaseStoryScreenshotTest to use single activity#75
EmilioBejasa wants to merge 9 commits intoload-story-event-emitterfrom
refactor-base-story-screenshot-test

Conversation

@EmilioBejasa
Copy link
Copy Markdown
Collaborator

Summary

  • Launches one ActivityScenario for the entire test run instead of one per story
  • Stories are switched via StorybookRegistry.loadStory() events instead of relaunching the activity
  • Removes screenshotStory() and bootstrapManifest() helper methods

Test plan

  • CI screenshot tests pass
  • Screenshots match baselines

🤖 Generated with Claude Code

@EmilioBejasa EmilioBejasa force-pushed the refactor-base-story-screenshot-test branch from 52ea702 to fa4abd8 Compare March 12, 2026 19:53
EmilioBejasa and others added 2 commits March 12, 2026 16:57
Instead of launching a new ActivityScenario per story, launch once
and loop through stories using StorybookRegistry.loadStory() events.
ActivityScenario is now opened and closed once per test run.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Uses scenario.onActivity { it.loadStory(storyName) } to trigger story
switching, removing the need for a static loadStory on StorybookRegistry.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@EmilioBejasa EmilioBejasa force-pushed the refactor-base-story-screenshot-test branch from fa4abd8 to a9cce63 Compare March 12, 2026 20:57
EmilioBejasa and others added 7 commits March 12, 2026 17:35
…Manager

reactInstanceManager throws IllegalStateException on new arch because
there is no ReactNativeHost. Use ReactApplication.reactHost to get the
current ReactContext instead.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…events

Two bugs:
- storyNameToId crashed on '__bootstrap__' (no '/') with TypeError on
  name.toLowerCase(). Bootstrap story only needs to register stories,
  not render anything, so bail out early when storyName has no '/'.
- loadStory event listener only logged; it never updated the displayed
  story. Add currentStoryName state, update it on the event, and reset
  loading so renderStory re-runs and notifyStoryReady fires.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
notifyStoryReady() was called synchronously in a useEffect, which runs
after React commits on the JS thread but before native view mutations
are flushed to the main thread. Wrapping in requestAnimationFrame
ensures the frame is painted before the screenshot is taken.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
After awaitStoryReady(), React Native's native view mutations may still
be pending on the UI thread. waitForIdleSync() ensures the UI thread
has flushed all pending operations before the screenshot is taken.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
waitForIdleSync() drains the message queue but view drawing is driven
by VSYNC via Choreographer, not the queue. Screenshots were capturing
a blank frame because drawing hadn't happened yet. waitForNextDraw()
uses OnDrawListener to block until the next frame is actually painted.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@EmilioBejasa EmilioBejasa requested a review from tdrhq March 16, 2026 16:10
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.

1 participant