Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions packages/app/component-tests/browser-pane-restore.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { fileURLToPath } from "node:url"
import { expect, story } from "../../storybook/playwright/story"
import { expect, sourceURL, story } from "../../storybook/playwright/story"

const source = (path: string) => `/@fs/${fileURLToPath(new URL(path, import.meta.url)).replaceAll("\\", "/")}`
const source = (path: string) => sourceURL(new URL(path, import.meta.url))

const modules = {
fixture: source("../../gui-extensions/src/browser/panel.fixture.tsx"),
Expand Down
5 changes: 2 additions & 3 deletions packages/app/component-tests/browser-pane.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { fileURLToPath } from "node:url"
import { expect, story } from "../../storybook/playwright/story"
import { expect, sourceURL, story } from "../../storybook/playwright/story"

const source = (path: string) => `/@fs/${fileURLToPath(new URL(path, import.meta.url)).replaceAll("\\", "/")}`
const source = (path: string) => sourceURL(new URL(path, import.meta.url))

const modules = {
fixture: source("../../gui-extensions/src/browser/panel.fixture.tsx"),
Expand Down
5 changes: 2 additions & 3 deletions packages/app/component-tests/extension-graph.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { fileURLToPath } from "node:url"
import type { Definition } from "@opencode/gui-extensions/sdk"
import { expect, story } from "../../storybook/playwright/story"
import { expect, sourceURL, story } from "../../storybook/playwright/story"

const source = (path: string) => `/@fs/${fileURLToPath(new URL(path, import.meta.url)).replaceAll("\\", "/")}`
const source = (path: string) => sourceURL(new URL(path, import.meta.url))

const modules = {
fixture: source("./extension-host.fixture.tsx"),
Expand Down
5 changes: 2 additions & 3 deletions packages/app/component-tests/extension-host.spec.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { fileURLToPath } from "node:url"
import type { Owner } from "solid-js"
import type { Context, Contract, DialogHandle, Dialogs, SessionRef } from "@opencode/gui-extensions/sdk"
import { expect, story } from "../../storybook/playwright/story"
import { expect, sourceURL, story } from "../../storybook/playwright/story"

const fixture = `/@fs/${fileURLToPath(new URL("./extension-host.fixture.tsx", import.meta.url)).replaceAll("\\", "/")}`
const fixture = sourceURL(new URL("./extension-host.fixture.tsx", import.meta.url))

/** What the scoped-registration case keeps from inside its extension. */
type Scope = { owner?: Owner | null; end: () => void; ctx?: Context }
Expand Down
5 changes: 2 additions & 3 deletions packages/app/component-tests/timeline-virtualizer.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { fileURLToPath } from "node:url"
import { expect, story } from "../../storybook/playwright/story"
import { expect, sourceURL, story } from "../../storybook/playwright/story"

const fixture = `/@fs/${fileURLToPath(new URL("./timeline-virtualizer.fixture.tsx", import.meta.url)).replaceAll("\\", "/")}`
const fixture = sourceURL(new URL("./timeline-virtualizer.fixture.tsx", import.meta.url))

story.beforeEach(async ({ mount }) => {
const component = await mount("opencode-composer-flow--mixed-attachments")
Expand Down
5 changes: 2 additions & 3 deletions packages/session-ui/component-tests/basic-tool.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { fileURLToPath } from "node:url"
import { expect, story } from "../../storybook/playwright/story"
import { expect, sourceURL, story } from "../../storybook/playwright/story"

const fixture = `/@fs/${fileURLToPath(new URL("./basic-tool.fixture.tsx", import.meta.url)).replaceAll("\\", "/")}`
const fixture = sourceURL(new URL("./basic-tool.fixture.tsx", import.meta.url))

story("does not render completed reasoning until it is opened", async ({ mount, page }) => {
const root = await mount("current-session-timeline-rows--conversation", {
Expand Down
5 changes: 2 additions & 3 deletions packages/session-ui/component-tests/markdown.spec.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import { fileURLToPath } from "node:url"
import type { Page } from "@playwright/test"
import { expect, story } from "../../storybook/playwright/story"
import { expect, sourceURL, story } from "../../storybook/playwright/story"

const png = Buffer.from(
"iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+a4ioAAAAASUVORK5CYII=",
"base64",
)

const fixture = `/@fs/${fileURLToPath(new URL("./markdown.fixture.tsx", import.meta.url)).replaceAll("\\", "/")}`
const fixture = sourceURL(new URL("./markdown.fixture.tsx", import.meta.url))

story.beforeEach(async ({ mount }) => {
const root = await mount("components-markdown--complete-response")
Expand Down
5 changes: 2 additions & 3 deletions packages/session-ui/component-tests/read-image.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { fileURLToPath } from "node:url"
import { expect, story } from "../../storybook/playwright/story"
import { expect, sourceURL, story } from "../../storybook/playwright/story"

const fixture = `/@fs/${fileURLToPath(new URL("./read-image.fixture.tsx", import.meta.url)).replaceAll("\\", "/")}`
const fixture = sourceURL(new URL("./read-image.fixture.tsx", import.meta.url))
const png = Buffer.from(
"iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+a4ioAAAAASUVORK5CYII=",
"base64",
Expand Down
5 changes: 5 additions & 0 deletions packages/storybook/playwright/story.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import { expect } from "@playwright/test";
import type { Locator } from "@playwright/test";
export { expect };
/**
* The dev server URL of a source module, in the form Vite rewrites imports to. A different spelling, such as
* `/@fs//Users/...`, loads a second instance of the module, whose contexts the rest of the page never provides.
*/
export declare const sourceURL: (url: URL) => string;
export declare const story: import("@playwright/test").TestType<import("@playwright/test").PlaywrightTestArgs & import("@playwright/test").PlaywrightTestOptions & {
mount: (id: string, options?: {
args?: Record<string, string | boolean> | undefined;
Expand Down
6 changes: 6 additions & 0 deletions packages/storybook/playwright/story.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ import type { Locator } from "@playwright/test"

export { expect }

/**
* The dev server URL of a source module, in the form Vite rewrites imports to. A different spelling, such as
* `/@fs//Users/...`, loads a second instance of the module, whose contexts the rest of the page never provides.
*/
export const sourceURL = (url: URL) => `/@fs${url.pathname}`

export const story = test.extend<{
mount: (
id: string,
Expand Down
Loading