File tree Expand file tree Collapse file tree 3 files changed +11
-9
lines changed
component-testing/components
preview-api/modules/preview-web/render Expand file tree Collapse file tree 3 files changed +11
-9
lines changed Original file line number Diff line number Diff line change @@ -247,6 +247,7 @@ export const Panel = memo<{ refId?: string; storyId: string; storyUrl: string }>
247247 return ( ) => observer ?. disconnect ( ) ;
248248 } , [ ] ) ;
249249
250+ const lastStoryId = useRef < string > ( undefined ) ;
250251 const lastRenderId = useRef < number > ( 0 ) ;
251252 const emit = useChannel (
252253 {
@@ -261,12 +262,16 @@ export const Panel = memo<{ refId?: string; storyId: string; storyUrl: string }>
261262 ) ;
262263 } ,
263264 [ STORY_RENDER_PHASE_CHANGED ] : ( event ) => {
264- if ( event . newPhase === 'preparing' || event . newPhase === 'loading' ) {
265- // A render cycle may not actually make it to the rendering phase.
265+ if (
266+ lastStoryId . current === event . storyId &&
267+ [ 'preparing' , 'loading' ] . includes ( event . newPhase )
268+ ) {
269+ // A rerender cycle may not actually make it to the rendering phase.
266270 // We don't want to update any state until it does.
267271 return ;
268272 }
269273
274+ lastStoryId . current = event . storyId ;
270275 lastRenderId . current = Math . max ( lastRenderId . current , event . renderId || 0 ) ;
271276 if ( lastRenderId . current !== event . renderId ) {
272277 return ;
Original file line number Diff line number Diff line change @@ -42,14 +42,12 @@ export const Creating = {
4242} satisfies Story ;
4343
4444export const Created : Story = {
45- play : async ( { canvas, context, userEvent } ) => {
45+ play : async ( { canvas, context } ) => {
4646 await Creating . play ( context ) ;
47- const event = userEvent . setup ( { delay : null } ) ;
4847
4948 const dialog = await canvas . findByRole ( 'dialog' ) ;
5049 const input = await within ( dialog ) . findByRole ( 'textbox' ) ;
51- await event . type ( input , 'MyNewStory' ) ;
52-
50+ await fireEvent . change ( input , { target : { value : 'MyNewStory' } } ) ;
5351 await fireEvent . submit ( dialog . getElementsByTagName ( 'form' ) [ 0 ] ) ;
5452 await expect ( context . args . createStory ) . toHaveBeenCalledWith ( 'MyNewStory' ) ;
5553 } ,
Original file line number Diff line number Diff line change @@ -116,16 +116,15 @@ export class StoryRender<TRenderer extends Renderer> implements Render<TRenderer
116116 }
117117
118118 private checkIfAborted ( signal : AbortSignal ) : boolean {
119- if ( signal . aborted ) {
119+ if ( signal . aborted && ! [ 'finished' , 'aborted' , 'errored' ] . includes ( this . phase as RenderPhase ) ) {
120120 this . phase = 'aborted' ;
121121 this . channel . emit ( STORY_RENDER_PHASE_CHANGED , {
122122 newPhase : this . phase ,
123123 renderId : this . renderId ,
124124 storyId : this . id ,
125125 } ) ;
126- return true ;
127126 }
128- return false ;
127+ return signal . aborted ;
129128 }
130129
131130 async prepare ( ) {
You can’t perform that action at this time.
0 commit comments