GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — test(app): initial e2e test setup · iyoda/opencode@03d7467

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • .github/workflows
    • test.yml
  • bun.lock
  • package.json
  • packages
    • app
      • .gitignore
      • README.md
      • e2e
        • home.spec.ts
      • package.json
      • playwright.config.ts
    • opencode
      • script
        • seed-e2e.ts
      • src/share
        • share-next.ts
        • share.ts
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎.github/workflows/test.yml‎

Copy file name to clipboardExpand all lines: .github/workflows/test.yml
+63Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,52 @@ jobs:
1818
- name: Setup Bun
1919
uses: ./.github/actions/setup-bun
2020

21+
- name: Install Playwright browsers
22+
run: bun --cwd packages/app x playwright install --with-deps
23+
24+
- name: Seed opencode data
25+
run: bun --cwd packages/opencode script/seed-e2e.ts
26+
env:
27+
MODELS_DEV_API_JSON: ${{ github.workspace }}/packages/opencode/test/tool/fixtures/models-api.json
28+
OPENCODE_DISABLE_MODELS_FETCH: "true"
29+
OPENCODE_DISABLE_SHARE: "true"
30+
OPENCODE_DISABLE_LSP_DOWNLOAD: "true"
31+
OPENCODE_DISABLE_DEFAULT_PLUGINS: "true"
32+
OPENCODE_EXPERIMENTAL_DISABLE_FILEWATCHER: "true"
33+
OPENCODE_TEST_HOME: ${{ runner.temp }}/opencode-e2e/home
34+
XDG_DATA_HOME: ${{ runner.temp }}/opencode-e2e/share
35+
XDG_CACHE_HOME: ${{ runner.temp }}/opencode-e2e/cache
36+
XDG_CONFIG_HOME: ${{ runner.temp }}/opencode-e2e/config
37+
XDG_STATE_HOME: ${{ runner.temp }}/opencode-e2e/state
38+
OPENCODE_E2E_PROJECT_DIR: ${{ github.workspace }}
39+
OPENCODE_E2E_SESSION_TITLE: "E2E Session"
40+
OPENCODE_E2E_MESSAGE: "Seeded for UI e2e"
41+
OPENCODE_E2E_MODEL: "opencode/gpt-5-nano"
42+
43+
- name: Run opencode server
44+
run: bun --cwd packages/opencode run dev -- --print-logs --log-level WARN serve --port 4096 --hostname 0.0.0.0 &
45+
env:
46+
MODELS_DEV_API_JSON: ${{ github.workspace }}/packages/opencode/test/tool/fixtures/models-api.json
47+
OPENCODE_DISABLE_MODELS_FETCH: "true"
48+
OPENCODE_DISABLE_SHARE: "true"
49+
OPENCODE_DISABLE_LSP_DOWNLOAD: "true"
50+
OPENCODE_DISABLE_DEFAULT_PLUGINS: "true"
51+
OPENCODE_EXPERIMENTAL_DISABLE_FILEWATCHER: "true"
52+
OPENCODE_TEST_HOME: ${{ runner.temp }}/opencode-e2e/home
53+
XDG_DATA_HOME: ${{ runner.temp }}/opencode-e2e/share
54+
XDG_CACHE_HOME: ${{ runner.temp }}/opencode-e2e/cache
55+
XDG_CONFIG_HOME: ${{ runner.temp }}/opencode-e2e/config
56+
XDG_STATE_HOME: ${{ runner.temp }}/opencode-e2e/state
57+
OPENCODE_CLIENT: "app"
58+
59+
- name: Wait for opencode server
60+
run: |
61+
for i in {1..60}; do
62+
curl -fsS "http://localhost:4096/global/health" > /dev/null && exit 0
63+
sleep 1
64+
done
65+
exit 1
66+
2167
- name: run
2268
run: |
2369
git config --global user.email "[email protected]"
@@ -26,3 +72,20 @@ jobs:
2672
bun turbo test
2773
env:
2874
CI: true
75+
MODELS_DEV_API_JSON: ${{ github.workspace }}/packages/opencode/test/tool/fixtures/models-api.json
76+
OPENCODE_DISABLE_MODELS_FETCH: "true"
77+
OPENCODE_DISABLE_SHARE: "true"
78+
OPENCODE_DISABLE_LSP_DOWNLOAD: "true"
79+
OPENCODE_DISABLE_DEFAULT_PLUGINS: "true"
80+
OPENCODE_EXPERIMENTAL_DISABLE_FILEWATCHER: "true"
81+
OPENCODE_TEST_HOME: ${{ runner.temp }}/opencode-e2e/home
82+
XDG_DATA_HOME: ${{ runner.temp }}/opencode-e2e/share
83+
XDG_CACHE_HOME: ${{ runner.temp }}/opencode-e2e/cache
84+
XDG_CONFIG_HOME: ${{ runner.temp }}/opencode-e2e/config
85+
XDG_STATE_HOME: ${{ runner.temp }}/opencode-e2e/state
86+
PLAYWRIGHT_SERVER_HOST: "localhost"
87+
PLAYWRIGHT_SERVER_PORT: "4096"
88+
VITE_OPENCODE_SERVER_HOST: "localhost"
89+
VITE_OPENCODE_SERVER_PORT: "4096"
90+
OPENCODE_CLIENT: "app"
91+
timeout-minutes: 30
Collapse file

‎bun.lock‎

Copy file name to clipboardExpand all lines: bun.lock
+10Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Collapse file

‎package.json‎

Copy file name to clipboardExpand all lines: package.json
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
"luxon": "3.6.1",
4545
"marked": "17.0.1",
4646
"marked-shiki": "1.2.1",
47+
"@playwright/test": "1.51.0",
4748
"typescript": "5.8.2",
4849
"@typescript/native-preview": "7.0.0-dev.20251207.1",
4950
"zod": "4.1.8",
Collapse file

‎packages/app/.gitignore‎

Copy file name to clipboard
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
src/assets/theme.css
2+
e2e/test-results
3+
e2e/playwright-report
Collapse file

‎packages/app/README.md‎

Copy file name to clipboardExpand all lines: packages/app/README.md
+15Lines changed: 15 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,21 @@ It correctly bundles Solid in production mode and optimizes the build for the be
2929
The build is minified and the filenames include the hashes.<br>
3030
Your app is ready to be deployed!
3131

32+
## E2E Testing
33+
34+
The Playwright runner expects the app already running at `http://localhost:3000`.
35+
36+
```bash
37+
bun add -D @playwright/test
38+
bunx playwright install
39+
bun run test:e2e
40+
```
41+
42+
Environment options:
43+
44+
- `PLAYWRIGHT_BASE_URL` (default: `http://localhost:3000`)
45+
- `PLAYWRIGHT_PORT` (default: `3000`)
46+
3247
## Deployment
3348

3449
You can deploy the `dist` folder to any static host provider (netlify, surge, now, etc.)
Collapse file

‎packages/app/e2e/home.spec.ts‎

Copy file name to clipboard
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { test, expect } from "@playwright/test"
2+
3+
test("home shows recent projects header", async ({ page }) => {
4+
await page.goto("/")
5+
await expect(page.getByText("Recent projects")).toBeVisible()
6+
})
Collapse file

‎packages/app/package.json‎

Copy file name to clipboardExpand all lines: packages/app/package.json
+6-1Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,16 @@
1212
"start": "vite",
1313
"dev": "vite",
1414
"build": "vite build",
15-
"serve": "vite preview"
15+
"serve": "vite preview",
16+
"test": "playwright test",
17+
"test:e2e": "playwright test",
18+
"test:e2e:ui": "playwright test --ui",
19+
"test:e2e:report": "playwright show-report e2e/playwright-report"
1620
},
1721
"license": "MIT",
1822
"devDependencies": {
1923
"@happy-dom/global-registrator": "20.0.11",
24+
"@playwright/test": "1.57.0",
2025
"@tailwindcss/vite": "catalog:",
2126
"@tsconfig/bun": "1.0.9",
2227
"@types/bun": "catalog:",
Collapse file

‎packages/app/playwright.config.ts‎

Copy file name to clipboard
+43Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import { defineConfig, devices } from "@playwright/test"
2+
3+
const port = Number(process.env.PLAYWRIGHT_PORT ?? 3000)
4+
const baseURL = process.env.PLAYWRIGHT_BASE_URL ?? `http://localhost:${port}`
5+
const serverHost = process.env.PLAYWRIGHT_SERVER_HOST ?? "localhost"
6+
const serverPort = process.env.PLAYWRIGHT_SERVER_PORT ?? "4096"
7+
const command = `bun run dev -- --host 0.0.0.0 --port ${port}`
8+
const reuse = !process.env.CI
9+
10+
export default defineConfig({
11+
testDir: "./e2e",
12+
outputDir: "./e2e/test-results",
13+
timeout: 60_000,
14+
expect: {
15+
timeout: 10_000,
16+
},
17+
fullyParallel: true,
18+
forbidOnly: !!process.env.CI,
19+
retries: process.env.CI ? 2 : 0,
20+
reporter: [["html", { outputFolder: "e2e/playwright-report", open: "never" }], ["line"]],
21+
webServer: {
22+
command,
23+
url: baseURL,
24+
reuseExistingServer: reuse,
25+
timeout: 120_000,
26+
env: {
27+
VITE_OPENCODE_SERVER_HOST: serverHost,
28+
VITE_OPENCODE_SERVER_PORT: serverPort,
29+
},
30+
},
31+
use: {
32+
baseURL,
33+
trace: "on-first-retry",
34+
screenshot: "only-on-failure",
35+
video: "retain-on-failure",
36+
},
37+
projects: [
38+
{
39+
name: "chromium",
40+
use: { ...devices["Desktop Chrome"] },
41+
},
42+
],
43+
})
Collapse file

‎packages/opencode/script/seed-e2e.ts‎

Copy file name to clipboard
+50Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
const dir = process.env.OPENCODE_E2E_PROJECT_DIR ?? process.cwd()
2+
const title = process.env.OPENCODE_E2E_SESSION_TITLE ?? "E2E Session"
3+
const text = process.env.OPENCODE_E2E_MESSAGE ?? "Seeded for UI e2e"
4+
const model = process.env.OPENCODE_E2E_MODEL ?? "opencode/gpt-5-nano"
5+
const parts = model.split("/")
6+
const providerID = parts[0] ?? "opencode"
7+
const modelID = parts[1] ?? "gpt-5-nano"
8+
const now = Date.now()
9+
10+
const seed = async () => {
11+
const { Instance } = await import("../src/project/instance")
12+
const { InstanceBootstrap } = await import("../src/project/bootstrap")
13+
const { Session } = await import("../src/session")
14+
const { Identifier } = await import("../src/id/id")
15+
const { Project } = await import("../src/project/project")
16+
17+
await Instance.provide({
18+
directory: dir,
19+
init: InstanceBootstrap,
20+
fn: async () => {
21+
const session = await Session.create({ title })
22+
const messageID = Identifier.descending("message")
23+
const partID = Identifier.descending("part")
24+
const message = {
25+
id: messageID,
26+
sessionID: session.id,
27+
role: "user" as const,
28+
time: { created: now },
29+
agent: "build",
30+
model: {
31+
providerID,
32+
modelID,
33+
},
34+
}
35+
const part = {
36+
id: partID,
37+
sessionID: session.id,
38+
messageID,
39+
type: "text" as const,
40+
text,
41+
time: { start: now },
42+
}
43+
await Session.updateMessage(message)
44+
await Session.updatePart(part)
45+
await Project.update({ projectID: Instance.project.id, name: "E2E Project" })
46+
},
47+
})
48+
}
49+
50+
await seed()
Collapse file

‎packages/opencode/src/share/share-next.ts‎

Copy file name to clipboardExpand all lines: packages/opencode/src/share/share-next.ts
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ export namespace ShareNext {
1515
return Config.get().then((x) => x.enterprise?.url ?? "https://opncd.ai")
1616
}
1717

18+
const disabled = process.env["OPENCODE_DISABLE_SHARE"] === "true" || process.env["OPENCODE_DISABLE_SHARE"] === "1"
19+
1820
export async function init() {
21+
if (disabled) return
1922
Bus.subscribe(Session.Event.Updated, async (evt) => {
2023
await sync(evt.properties.info.id, [
2124
{
@@ -63,6 +66,7 @@ export namespace ShareNext {
6366
}
6467

6568
export async function create(sessionID: string) {
69+
if (disabled) return { id: "", url: "", secret: "" }
6670
log.info("creating share", { sessionID })
6771
const result = await fetch(`${await url()}/api/share`, {
6872
method: "POST",
@@ -110,6 +114,7 @@ export namespace ShareNext {
110114

111115
const queue = new Map<string, { timeout: NodeJS.Timeout; data: Map<string, Data> }>()
112116
async function sync(sessionID: string, data: Data[]) {
117+
if (disabled) return
113118
const existing = queue.get(sessionID)
114119
if (existing) {
115120
for (const item of data) {
@@ -145,6 +150,7 @@ export namespace ShareNext {
145150
}
146151

147152
export async function remove(sessionID: string) {
153+
if (disabled) return
148154
log.info("removing share", { sessionID })
149155
const share = await get(sessionID)
150156
if (!share) return

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.