Refactor BaseStoryScreenshotTest to use single activity#76
Draft
EmilioBejasa wants to merge 21 commits into
Draft
Refactor BaseStoryScreenshotTest to use single activity#76EmilioBejasa wants to merge 21 commits into
EmilioBejasa wants to merge 21 commits into
Conversation
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…chris-workspace Had to merge code from PRs #58 and 61.
loadStory doesn't need to be static — it's called from within the module instance where reactApplicationContext is already available. Removes the reactCtx field and init block that were only needed to bridge the instance context into the companion object. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds a native-to-JS event emitter so the test runner can signal which story to render without relaunching the activity. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds a NativeEventEmitter subscription to the loadStory event emitted by StorybookRegistry. Currently just logs the event — wiring up re-rendering is the next step. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Instead of storing ReactApplicationContext statically in StorybookRegistry companion object, expose loadStory() on BaseStoryRendererActivity which retrieves the module via the React instance manager. This removes the init block and reactCtx static field entirely. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Required by BaseStoryRendererActivity.loadStory() which retrieves the module via ReactContext.getNativeModule(). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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>
…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>
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.
Summary
loadStoryto an instance method onStorybookRegistry, removing the companion object hackloadStoryevent emitter and wires it throughBaseStoryRendererActivityBaseStoryScreenshotTestto use a single activity instead of launching a new one per storyTest plan
🤖 Generated with Claude Code