app: fix Playwright e2e helpers using import.meta.url in CJS context

Revert dynamic import path resolution from `new URL(..., import.meta.url)`
to `path.resolve(__dirname, ...)` + `pathToFileURL(...)` in three e2e
helpers. Playwright's TS loader emits CommonJS, where import.meta.url
is undefined, causing "exports is not defined in ES module scope" and
blocking all e2e test discovery.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Mohamed Boudra
2026-04-11 00:46:46 +00:00
parent 84e4bf1742
commit b0e446fee8
3 changed files with 18 additions and 3 deletions

View File

@@ -1,4 +1,6 @@
import { expect, type Page } from "@playwright/test";
import path from "node:path";
import { pathToFileURL } from "node:url";
import { randomUUID } from "node:crypto";
import { buildHostWorkspaceRoute } from "../../src/utils/host-routes";
@@ -88,7 +90,10 @@ async function loadDaemonClientConstructor(): Promise<
clientType: "cli";
}) => DaemonClientInstance
> {
const moduleUrl = new URL("../../../server/dist/server/server/exports.js", import.meta.url).href;
const repoRoot = path.resolve(__dirname, "../../../../");
const moduleUrl = pathToFileURL(
path.join(repoRoot, "packages/server/dist/server/server/exports.js"),
).href;
const mod = (await import(moduleUrl)) as {
DaemonClient: new (config: {
url: string;

View File

@@ -1,4 +1,6 @@
import { randomUUID } from "node:crypto";
import path from "node:path";
import { pathToFileURL } from "node:url";
import { expect, type Page } from "@playwright/test";
import { buildCreateAgentPreferences, buildSeededHost } from "./daemon-registry";
import { waitForWorkspaceTabsVisible } from "./workspace-tabs";
@@ -72,7 +74,10 @@ async function loadDaemonClientConstructor(): Promise<
clientType: "cli";
}) => ArchiveTabDaemonClient
> {
const moduleUrl = new URL("../../../server/dist/server/server/exports.js", import.meta.url).href;
const repoRoot = path.resolve(__dirname, "../../../../");
const moduleUrl = pathToFileURL(
path.join(repoRoot, "packages/server/dist/server/server/exports.js"),
).href;
const mod = (await import(moduleUrl)) as {
DaemonClient: new (config: {
url: string;

View File

@@ -1,4 +1,6 @@
import type { Page } from "@playwright/test";
import path from "node:path";
import { pathToFileURL } from "node:url";
import { randomUUID } from "node:crypto";
import { buildHostWorkspaceRoute } from "../../src/utils/host-routes";
@@ -48,7 +50,10 @@ async function loadDaemonClientConstructor(): Promise<
clientType: "cli";
}) => TerminalPerfDaemonClient
> {
const moduleUrl = new URL("../../../server/dist/server/server/exports.js", import.meta.url).href;
const repoRoot = path.resolve(__dirname, "../../../../");
const moduleUrl = pathToFileURL(
path.join(repoRoot, "packages/server/dist/server/server/exports.js"),
).href;
const mod = (await import(moduleUrl)) as {
DaemonClient: new (config: {
url: string;