TypeScript
refactor(web): observe preview tests through the live registry (#10064)
Julius Marminge43700b83e73f
diff --git a/apps/web/src/previewStateStore.test.ts b/apps/web/src/previewStateStore.test.tsindex 862fe46081e..f9956f9c02c 100644--- a/apps/web/src/previewStateStore.test.ts+++ b/apps/web/src/previewStateStore.test.ts@@ -19,10 +19,10 @@ import {reconcilePreviewServerSessions,rememberPreviewUrl,resetPreviewStateForTests,- subscribeThreadPreviewState,setActivePreviewTab,updatePreviewServerSnapshot,} from "./previewStateStore";+import { appAtomRegistry } from "./rpc/atomRegistry";const environmentId = "env-1" as EnvironmentId;const ref = scopeThreadRef(environmentId, ThreadId.make("thread-1"));@@ -352,7 +352,7 @@ describe("previewStateStore (single-tab)", () => {},};let updateCount = 0;- const unsubscribe = subscribeThreadPreviewState(ref, () => {+ const unsubscribe = appAtomRegistry.subscribe(previewStateAtom(scopedThreadKey(ref)), () => {updateCount += 1;});diff --git a/apps/web/src/previewStateStore.ts b/apps/web/src/previewStateStore.tsindex 90f8e27c358..1e7ec370661 100644--- a/apps/web/src/previewStateStore.ts+++ b/apps/web/src/previewStateStore.ts@@ -173,19 +173,6 @@ export function readThreadPreviewState(ref: ScopedThreadRef): ThreadPreviewStatereturn appAtomRegistry.get(previewStateAtom(scopedThreadKey(ref)));}-export function subscribeThreadPreviewState(- ref: ScopedThreadRef,- listener: (state: ThreadPreviewState, previous: ThreadPreviewState) => void,-): () => void {- const atom = previewStateAtom(scopedThreadKey(ref));- let previous = appAtomRegistry.get(atom);- return appAtomRegistry.subscribe(atom, (state) => {- const prior = previous;- previous = state;- listener(state, prior);- });-}-export function applyPreviewServerEvent(ref: ScopedThreadRef, event: PreviewEvent): void {updateThreadPreviewState(ref, (current) => {if (current.serverEpoch !== null && event.serverEpoch !== current.serverEpoch) return current;