storybookjs / storybook

Storybook is the industry standard workshop for building, documenting, and testing UI components in isolation
https://storybook.js.org
MIT License
84.72k stars 9.32k forks source link

[Bug]: Testing module can get in a non-escapable state if runs are not completed #29650

Open JReinhold opened 3 days ago

JReinhold commented 3 days ago

The testing module UI updates its own state (running/cancelling/done, etc.) when it receives updates from the server. It also saves the state in the browser's session storage.

That can cause issues, if the manager UI doesn't receive updates from the server, because:

All of these pretty common cases can lead to the testing module getting in a non-escapable locked state, where it is forever running, and you can't re-run or cancel the "current" run, because the server is in a completely different state.

This is explained in the following video:

https://github.com/user-attachments/assets/291938a5-497b-4dfb-8815-c6037c41190b

I think, that ideally the server state should be the single source of truth, and the manager shouldn't try to keep its own state, nor should it save it to session storage, because the server is the only entity that knows what the status of a run is. When the manager UI starts up (ie. the SB app is loaded), it should ask the server for what the current state is.

It should also be able to handle loosing connection to the server, resetting the run state in the UI.

We could maybe leverage the useUniversalState POC that I have built here: https://github.com/storybookjs/storybook/compare/next...jeppe/universal-state

Also open to other suggestions.

Discussed internally at https://chromaticqa.slack.com/archives/C07AXQABXDZ/p1731622600573489