Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(web): desktop opens remote environments' browser tabs locally #17316

Mergedjuliusmarmingemerged 1 commit intomain fromrefs/pull/17316/headmerged by juliusmarminge View on GitHub

Showing 7 changed files with 95 additions and 1 deletion (loading 4).

x
0 of 7 viewed, 7 left
60 additions and 0 deletionsapps/web/src/browser/previewRuntime.test.tsAdded
View file
@@ -0,0 +1,60 @@
+import type { EnvironmentId } from "@t3tools/contracts";
+import { afterEach, describe, expect, it, vi } from "vite-plus/test";
+​
+const state = vi.hoisted(() => ({
+ desktop: false,
+ primary: null as string | null,
+ serverBrowser: new Set<string>(),
+}));
+​
+vi.mock("~/env", () => ({ isElectron: false }));
+vi.mock("~/previewStateStore", () => ({ isPreviewSupportedInRuntime: () => state.desktop }));
+vi.mock("~/rpc/atomRegistry", () => ({ appAtomRegistry: { get: () => state.primary } }));
+vi.mock("~/state/primaryEnvironment", () => ({ primaryEnvironmentIdAtom: {} }));
+vi.mock("~/state/entities", () => ({
+ readEnvironmentSupportsServerBrowser: (id: string) => state.serverBrowser.has(id),
+ useEnvironmentSupportsServerBrowser: () => false,
+}));
+​
+import { alternatePreviewRuntime, previewRuntimeFor } from "./previewRuntime";
+​
+const local = "local" as EnvironmentId;
+const remote = "remote" as EnvironmentId;
+​
+afterEach(() => {
+ state.desktop = false;
+ state.primary = null;
+ state.serverBrowser = new Set();
+});
+​
+describe("previewRuntimeFor", () => {