mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-03 21:31:26 +00:00
perf(test): trim more browser reload churn
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
|
||||
vi.mock("node:child_process", () => ({
|
||||
execFileSync: vi.fn(),
|
||||
@@ -24,17 +24,10 @@ import { execFileSync } from "node:child_process";
|
||||
import * as fs from "node:fs";
|
||||
import os from "node:os";
|
||||
|
||||
async function loadResolveBrowserExecutableForPlatform() {
|
||||
const mod = await import("./chrome.executables.js");
|
||||
return mod.resolveBrowserExecutableForPlatform;
|
||||
}
|
||||
|
||||
describe("browser default executable detection", () => {
|
||||
const launchServicesPlist = "com.apple.launchservices.secure.plist";
|
||||
const chromeExecutablePath = "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome";
|
||||
let resolveBrowserExecutableForPlatform: Awaited<
|
||||
ReturnType<typeof loadResolveBrowserExecutableForPlatform>
|
||||
>;
|
||||
let resolveBrowserExecutableForPlatform: typeof import("./chrome.executables.js").resolveBrowserExecutableForPlatform;
|
||||
|
||||
function mockMacDefaultBrowser(bundleId: string, appPath = ""): void {
|
||||
vi.mocked(execFileSync).mockImplementation((cmd, args) => {
|
||||
@@ -62,11 +55,13 @@ describe("browser default executable detection", () => {
|
||||
});
|
||||
}
|
||||
|
||||
beforeEach(async () => {
|
||||
vi.resetModules();
|
||||
beforeAll(async () => {
|
||||
({ resolveBrowserExecutableForPlatform } = await import("./chrome.executables.js"));
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
vi.mocked(os.homedir).mockReturnValue("/Users/test");
|
||||
resolveBrowserExecutableForPlatform = await loadResolveBrowserExecutableForPlatform();
|
||||
});
|
||||
|
||||
it("prefers default Chromium browser on macOS", async () => {
|
||||
@@ -119,8 +114,6 @@ describe("browser default executable detection", () => {
|
||||
// return Chrome from the fallback list — not Edge — failing the assert.
|
||||
return value === edgeExecutablePath || value.includes(chromeExecutablePath);
|
||||
});
|
||||
const resolveBrowserExecutableForPlatform = await loadResolveBrowserExecutableForPlatform();
|
||||
|
||||
const exe = resolveBrowserExecutableForPlatform(
|
||||
{} as Parameters<typeof resolveBrowserExecutableForPlatform>[0],
|
||||
"darwin",
|
||||
@@ -144,8 +137,6 @@ describe("browser default executable detection", () => {
|
||||
return "";
|
||||
});
|
||||
mockChromeExecutableExists();
|
||||
const resolveBrowserExecutableForPlatform = await loadResolveBrowserExecutableForPlatform();
|
||||
|
||||
const exe = resolveBrowserExecutableForPlatform(
|
||||
{} as Parameters<typeof resolveBrowserExecutableForPlatform>[0],
|
||||
"darwin",
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { beforeAll, describe, expect, it, vi } from "vitest";
|
||||
import { createBrowserRouteApp, createBrowserRouteResponse } from "./test-helpers.js";
|
||||
|
||||
vi.mock("../chrome-mcp.js", () => ({
|
||||
@@ -52,8 +52,7 @@ async function callBasicRouteWithState(params: {
|
||||
return response;
|
||||
}
|
||||
|
||||
beforeEach(async () => {
|
||||
vi.resetModules();
|
||||
beforeAll(async () => {
|
||||
({ BrowserProfileUnavailableError } = await import("../errors.js"));
|
||||
({ registerBrowserBasicRoutes } = await import("./basic.js"));
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user