|
1 | 1 | import { expect, test, type Page } from "@playwright/test" |
2 | 2 | import type { ConfigEntry, OpenCodeEvent, WorktreeDirectory } from "@opencode/client/promise" |
3 | 3 | import { NO_PROVIDER, REMOTE_SERVER, SERVER, holdRoute, project, session } from "../utils/app" |
4 | | -import { mockOpenCodeServer } from "../utils/mock-server" |
| 4 | +import { mockMissingLocation, mockOpenCodeServer } from "../utils/mock-server" |
5 | 5 | import { mockRemoteServer, mockWorkspace, openSettings, type WorkspaceInput } from "../utils/workspace" |
6 | 6 |
|
7 | 7 | const directory = "C:/Projects/settings-demo" |
@@ -248,6 +248,41 @@ test("project settings open as a nested view that keeps its route", async ({ pag |
248 | 248 | await expect(settings.getByRole("heading", { name: "Projects", exact: true })).toBeVisible() |
249 | 249 | }) |
250 | 250 |
|
| 251 | +// The desktop app reopens its last settings URL on launch, so a crash on this page would repeat on every restart. |
| 252 | +test("a project whose folder is gone opens its settings with a notice", async ({ page }) => { |
| 253 | + await mockWorkspace(page, { |
| 254 | + name: "Settings demo", |
| 255 | + directory, |
| 256 | + provider: NO_PROVIDER, |
| 257 | + sessions: [], |
| 258 | + seed: { tabs: [] }, |
| 259 | + }) |
| 260 | + await mockMissingLocation(page, directory) |
| 261 | + |
| 262 | + const plugins = page.waitForResponse((response) => { |
| 263 | + const url = new URL(response.url()) |
| 264 | + |
| 265 | + return url.pathname === "/api/plugin" && url.searchParams.get("location[directory]") === directory |
| 266 | + }) |
| 267 | + |
| 268 | + await page.goto( |
| 269 | + `/settings?server=${encodeURIComponent(SERVER)}&project=${encodeURIComponent(directory)}&tab=extensions`, |
| 270 | + ) |
| 271 | + expect((await plugins).status()).toBe(404) |
| 272 | + const settings = page.getByTestId("settings-screen") |
| 273 | + const notice = settings.getByRole("status").filter({ hasText: "Project folder not found" }) |
| 274 | + await expect(notice).toContainText(directory) |
| 275 | + await settings.getByRole("tab", { name: "Plugins", exact: true }).click() |
| 276 | + |
| 277 | + await expect( |
| 278 | + settings.getByRole("tabpanel", { name: "Plugins", exact: true }).getByText("No plugins yet", { exact: true }), |
| 279 | + ).toBeVisible() |
| 280 | + |
| 281 | + await settings.getByRole("tab", { name: "General", exact: true }).click() |
| 282 | + await expect(settings.getByRole("textbox", { name: "Project name", exact: true })).toBeVisible() |
| 283 | + await expect(notice).toContainText(directory) |
| 284 | +}) |
| 285 | + |
251 | 286 | for (const field of [ |
252 | 287 | { |
253 | 288 | name: "color", |
|
0 commit comments