summaryrefslogtreecommitdiffhomepage
path: root/packages/app/e2e/projects
diff options
context:
space:
mode:
authorAdam <[email protected]>2026-02-11 09:11:41 -0600
committeropencode <[email protected]>2026-02-11 15:12:28 +0000
commitfc88dde63f1c4a7f547bbe0634c68c5ce9fc787c (patch)
tree4e6aaad7afb646348c3b676a6269455dac63a7d8 /packages/app/e2e/projects
parent4619e9d183d036f2f7234046927ec2f72d426168 (diff)
downloadopencode-fc88dde63f1c4a7f547bbe0634c68c5ce9fc787c.tar.gz
opencode-fc88dde63f1c4a7f547bbe0634c68c5ce9fc787c.zip
test(app): more e2e tests (#13162)
Diffstat (limited to 'packages/app/e2e/projects')
-rw-r--r--packages/app/e2e/projects/projects-close.spec.ts32
-rw-r--r--packages/app/e2e/projects/workspaces.spec.ts44
2 files changed, 58 insertions, 18 deletions
diff --git a/packages/app/e2e/projects/projects-close.spec.ts b/packages/app/e2e/projects/projects-close.spec.ts
index 95768d21e..4b39ed82c 100644
--- a/packages/app/e2e/projects/projects-close.spec.ts
+++ b/packages/app/e2e/projects/projects-close.spec.ts
@@ -1,6 +1,6 @@
import { test, expect } from "../fixtures"
-import { createTestProject, cleanupTestProject, openSidebar, clickMenuItem } from "../actions"
-import { projectCloseHoverSelector, projectCloseMenuSelector, projectSwitchSelector } from "../selectors"
+import { createTestProject, cleanupTestProject, openSidebar, clickMenuItem, openProjectMenu } from "../actions"
+import { projectCloseHoverSelector, projectSwitchSelector } from "../selectors"
import { dirSlug } from "../utils"
test("can close a project via hover card close button", async ({ page, withProject }) => {
@@ -31,16 +31,15 @@ test("can close a project via hover card close button", async ({ page, withProje
}
})
-test("can close a project via project header more options menu", async ({ page, withProject }) => {
+test("closing active project navigates to another open project", async ({ page, withProject }) => {
await page.setViewportSize({ width: 1400, height: 800 })
const other = await createTestProject()
- const otherName = other.split("/").pop() ?? other
const otherSlug = dirSlug(other)
try {
await withProject(
- async () => {
+ async ({ slug }) => {
await openSidebar(page)
const otherButton = page.locator(projectSwitchSelector(otherSlug)).first()
@@ -49,21 +48,20 @@ test("can close a project via project header more options menu", async ({ page,
await expect(page).toHaveURL(new RegExp(`/${otherSlug}/session`))
- const header = page
- .locator(".group\\/project")
- .filter({ has: page.locator(`[data-action="project-menu"][data-project="${otherSlug}"]`) })
- .first()
- await expect(header).toContainText(otherName)
+ const menu = await openProjectMenu(page, otherSlug)
- const trigger = header.locator(`[data-action="project-menu"][data-project="${otherSlug}"]`).first()
- await expect(trigger).toHaveCount(1)
- await trigger.focus()
- await page.keyboard.press("Enter")
+ await clickMenuItem(menu, /^Close$/i, { force: true })
- const menu = page.locator('[data-component="dropdown-menu-content"]').first()
- await expect(menu).toBeVisible({ timeout: 10_000 })
+ await expect
+ .poll(() => {
+ const pathname = new URL(page.url()).pathname
+ if (new RegExp(`^/${slug}/session(?:/[^/]+)?/?$`).test(pathname)) return "project"
+ if (pathname === "/") return "home"
+ return ""
+ })
+ .toMatch(/^(project|home)$/)
- await clickMenuItem(menu, /^Close$/i, { force: true })
+ await expect(page).not.toHaveURL(new RegExp(`/${otherSlug}/session(?:[/?#]|$)`))
await expect(otherButton).toHaveCount(0)
},
{ extra: [other] },
diff --git a/packages/app/e2e/projects/workspaces.spec.ts b/packages/app/e2e/projects/workspaces.spec.ts
index 41a28e3e3..071c398b2 100644
--- a/packages/app/e2e/projects/workspaces.spec.ts
+++ b/packages/app/e2e/projects/workspaces.spec.ts
@@ -1,5 +1,6 @@
import { base64Decode } from "@opencode-ai/util/encode"
import fs from "node:fs/promises"
+import os from "node:os"
import path from "node:path"
import type { Page } from "@playwright/test"
@@ -10,11 +11,18 @@ import {
cleanupTestProject,
clickMenuItem,
confirmDialog,
+ openProjectMenu,
openSidebar,
openWorkspaceMenu,
setWorkspacesEnabled,
} from "../actions"
-import { inlineInputSelector, workspaceItemSelector } from "../selectors"
+import {
+ inlineInputSelector,
+ projectSwitchSelector,
+ projectWorkspacesToggleSelector,
+ workspaceItemSelector,
+} from "../selectors"
+import { dirSlug } from "../utils"
function slugFromUrl(url: string) {
return /\/([^/]+)\/session(?:\/|$)/.exec(url)?.[1] ?? ""
@@ -126,6 +134,40 @@ test("can create a workspace", async ({ page, withProject }) => {
})
})
+test("non-git projects keep workspace mode disabled", async ({ page, withProject }) => {
+ await page.setViewportSize({ width: 1400, height: 800 })
+
+ const nonGit = await fs.mkdtemp(path.join(os.tmpdir(), "opencode-e2e-project-nongit-"))
+ const nonGitSlug = dirSlug(nonGit)
+
+ await fs.writeFile(path.join(nonGit, "README.md"), "# e2e nongit\n")
+
+ try {
+ await withProject(
+ async () => {
+ await openSidebar(page)
+
+ const nonGitButton = page.locator(projectSwitchSelector(nonGitSlug)).first()
+ await expect(nonGitButton).toBeVisible()
+ await nonGitButton.click()
+ await expect(page).toHaveURL(new RegExp(`/${nonGitSlug}/session`))
+
+ const menu = await openProjectMenu(page, nonGitSlug)
+ const toggle = menu.locator(projectWorkspacesToggleSelector(nonGitSlug)).first()
+
+ await expect(toggle).toBeVisible()
+ await expect(toggle).toBeDisabled()
+
+ await expect(menu.getByRole("menuitem", { name: "New workspace" })).toHaveCount(0)
+ await expect(page.getByRole("button", { name: "New workspace" })).toHaveCount(0)
+ },
+ { extra: [nonGit] },
+ )
+ } finally {
+ await cleanupTestProject(nonGit)
+ }
+})
+
test("can rename a workspace", async ({ page, withProject }) => {
await page.setViewportSize({ width: 1400, height: 800 })