|
| 1 | +import { expect, test } from "@playwright/test" |
| 2 | +import { base64Encode } from "@opencode-ai/core/util/encode" |
| 3 | +import { mockOpenCodeServer } from "../utils/mock-server" |
| 4 | + |
| 5 | +const draftID = "draft_legacy_new_session" |
| 6 | +const directory = "C:/OpenCode/LegacyNewSession" |
| 7 | +const server = `http://${process.env.PLAYWRIGHT_SERVER_HOST ?? "127.0.0.1"}:${process.env.PLAYWRIGHT_SERVER_PORT ?? "4096"}` |
| 8 | + |
| 9 | +test("redirects a draft to the legacy new-session route", async ({ page }) => { |
| 10 | + await mockOpenCodeServer(page, { |
| 11 | + directory, |
| 12 | + project: { |
| 13 | + id: "proj_legacy_new_session", |
| 14 | + worktree: directory, |
| 15 | + vcs: "git", |
| 16 | + name: "legacy-new-session", |
| 17 | + time: { created: 1700000000000, updated: 1700000000000 }, |
| 18 | + sandboxes: [], |
| 19 | + }, |
| 20 | + provider: { all: [], connected: [], default: {} }, |
| 21 | + sessions: [], |
| 22 | + pageMessages: () => ({ items: [] }), |
| 23 | + }) |
| 24 | + await page.addInitScript( |
| 25 | + ({ directory, draftID, server }) => { |
| 26 | + localStorage.setItem("settings.v3", JSON.stringify({ general: { newLayoutDesigns: false } })) |
| 27 | + localStorage.setItem( |
| 28 | + "opencode.window.browser.dat:tabs", |
| 29 | + JSON.stringify([{ type: "draft", draftID, server, directory }]), |
| 30 | + ) |
| 31 | + }, |
| 32 | + { directory, draftID, server }, |
| 33 | + ) |
| 34 | + |
| 35 | + await page.goto(`/new-session?draftId=${draftID}`) |
| 36 | + |
| 37 | + await expect(page).toHaveURL(`/${base64Encode(directory)}/session`) |
| 38 | + await expect(page.locator("header[data-tauri-drag-region]")).toBeVisible() |
| 39 | + await expect(page.locator('[data-component="prompt-input"]')).toBeVisible() |
| 40 | +}) |
0 commit comments