mirror of
https://github.com/openswarm-ai/openswarm.git
synced 2026-09-06 17:57:43 +02:00
[eric] frontend: extend the store-on-window gate so an init-script flag also exposes it on production builds, letting e2e subscribe to redux diffs against the packaged app
This commit is contained in:
@@ -58,9 +58,10 @@ export const store = configureStore({
|
||||
export type RootState = ReturnType<typeof store.getState>;
|
||||
export type AppDispatch = typeof store.dispatch;
|
||||
|
||||
// Expose the store on window in dev so playwright + the user's devtools
|
||||
// can drive UI flows without hunting for selectors. The expose is
|
||||
// guarded by NODE_ENV so production bundles don't ship it.
|
||||
if (typeof window !== 'undefined' && process.env.NODE_ENV !== 'production') {
|
||||
// Expose the store on window in dev. In production it stays hidden UNLESS the
|
||||
// renderer was launched with __OPENSWARM_E2E__ pre-set by a Playwright init
|
||||
// script, which is the only way the e2e visibility recorder can subscribe to
|
||||
// state diffs against the packaged build. Normal user runs never set the flag.
|
||||
if (typeof window !== 'undefined' && (process.env.NODE_ENV !== 'production' || (window as unknown as { __OPENSWARM_E2E__?: boolean }).__OPENSWARM_E2E__ === true)) {
|
||||
(window as unknown as { __OPENSWARM_STORE__?: typeof store }).__OPENSWARM_STORE__ = store;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user