electrobun-kitchen-sink
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseElectrobun Kitchen Sink
Electrobun Kitchen Sink
The Kitchen Sink is Electrobun's integration test app. It contains automated and interactive tests for every Electrobun API, plus standalone playground windows for manual exploration.
Kitchen Sink 是 Electrobun 的集成测试应用。它包含针对每个 Electrobun API 的自动化测试和交互式测试,以及用于手动探索的独立 playground 窗口。
Project Layout
项目结构
kitchen/
├── scripts/
│ ├── generate-manifest.ts # static parser → feature-manifest.json
│ └── validate-manifest.ts # consistency checks
├── src/
│ ├── bun/index.ts # Electrobun bun-side entrypoint
│ ├── generated/
│ │ ├── manifest-types.ts # TypeScript types for the manifest
│ │ └── feature-manifest.json # generated feature index
│ ├── test-framework/ # test executor & result types
│ ├── test-runner/ # test runner UI (views://test-runner/)
│ ├── test-harness/ # webview used by automated tests
│ ├── tests/
│ │ ├── index.ts # aggregates all suites
│ │ ├── *.test.ts # automated test suites
│ │ └── interactive/ # interactive test suites
│ └── playgrounds/ # standalone feature demo windows
└── electrobun.config.tskitchen/
├── scripts/
│ ├── generate-manifest.ts # static parser → feature-manifest.json
│ └── validate-manifest.ts # consistency checks
├── src/
│ ├── bun/index.ts # Electrobun bun-side entrypoint
│ ├── generated/
│ │ ├── manifest-types.ts # TypeScript types for the manifest
│ │ └── feature-manifest.json # generated feature index
│ ├── test-framework/ # test executor & result types
│ ├── test-runner/ # test runner UI (views://test-runner/)
│ ├── test-harness/ # webview used by automated tests
│ ├── tests/
│ │ ├── index.ts # aggregates all suites
│ │ ├── *.test.ts # automated test suites
│ │ └── interactive/ # interactive test suites
│ └── playgrounds/ # standalone feature demo windows
└── electrobun.config.tsRunning the Kitchen Sink
运行 Kitchen Sink
bash
cd kitchen && bun installbash
cd kitchen && bun installDev mode — opens test runner window
Dev mode — opens test runner window
electrobun dev
electrobun dev
Watch mode — auto-rebuilds on file change
Watch mode — auto-rebuilds on file change
electrobun dev --watch
electrobun dev --watch
Auto-run all automated tests and exit (CI / headless)
Auto-run all automated tests and exit (CI / headless)
AUTO_RUN=1 electrobun dev
AUTO_RUN=1 electrobun dev
Run a single test by name
Run a single test by name
AUTO_RUN_TEST_NAME="Window creation with URL" electrobun dev
Exit codes: `0` = all pass, `1` = any failure.AUTO_RUN_TEST_NAME="Window creation with URL" electrobun dev
退出码:`0` = 全部通过,`1` = 存在任何失败。Feature Manifest
Feature Manifest(功能清单)
Generated at . Each entry:
kitchen/src/generated/feature-manifest.jsonjsonc
{
"id": "window-creation-with-url", // stable slug
"title": "Window creation with URL", // human-readable
"category": "BrowserWindow", // API grouping
"description": "Test creating a window with a URL",
"interactive": false, // true = requires human input
"testFile": "src/tests/window.test.ts", // source location
"playgroundRoute": null, // e.g. "playgrounds/clipboard/index.html"
"apiSurface": ["BrowserWindow"], // Electrobun APIs exercised
"uiSelectors": [], // CSS selectors used in playground
"platformCaveats": [] // e.g. ["requires CEF renderer"]
}生成文件位于 。每个条目如下:
kitchen/src/generated/feature-manifest.jsonjsonc
{
"id": "window-creation-with-url", // stable slug
"title": "Window creation with URL", // human-readable
"category": "BrowserWindow", // API grouping
"description": "Test creating a window with a URL",
"interactive": false, // true = requires human input
"testFile": "src/tests/window.test.ts", // source location
"playgroundRoute": null, // e.g. "playgrounds/clipboard/index.html"
"apiSurface": ["BrowserWindow"], // Electrobun APIs exercised
"uiSelectors": [], // CSS selectors used in playground
"platformCaveats": [] // e.g. ["requires CEF renderer"]
}Regenerate / Validate
重新生成 / 验证
bash
cd kitchen
npx tsx scripts/generate-manifest.ts # parse defineTest() calls, write manifest
npx tsx scripts/validate-manifest.ts # check all tests have manifest entries, no dupsGenerator does static analysis only — no Electrobun runtime required.
bash
cd kitchen
npx tsx scripts/generate-manifest.ts # parse defineTest() calls, write manifest
npx tsx scripts/validate-manifest.ts # check all tests have manifest entries, no dups生成器仅执行静态分析——无需 Electrobun 运行时。
Test Suites
测试套件
Automated (run unattended)
自动化(无人值守运行)
| Suite | Key APIs |
|---|---|
| RPC | BrowserView.defineRPC, Electroview.defineRPC |
| BrowserWindow | new BrowserWindow, all lifecycle methods |
| Navigation | setNavigationRules, will-navigate, did-navigate |
| Utils | clipboard, paths, openFileDialog, showNotification |
| Screen | getPrimaryDisplay, getAllDisplays, getCursorScreenPoint |
| Session | Session.fromPartition, cookies |
| Events | Electrobun.events.on (all global events) |
| Preload | preload script injection |
| Updater | checkForUpdate, downloadUpdate, applyUpdate |
| Sandbox | sandbox: true isolation |
| Tray | new Tray, setMenu, tray-clicked |
| WGPU FFI | WGPUBridge low-level FFI |
| WGPU Adapter | GpuWindow, WGPUView adapter layer |
| Babylon Adapter | BabylonJS WebGPU integration |
| WGPU Adapter Extended | extended WGPU surface coverage |
| 套件 | 关键 API |
|---|---|
| RPC | BrowserView.defineRPC、Electroview.defineRPC |
| BrowserWindow | new BrowserWindow、所有生命周期方法 |
| Navigation | setNavigationRules、will-navigate、did-navigate |
| Utils | 剪贴板、路径、openFileDialog、showNotification |
| Screen | getPrimaryDisplay、getAllDisplays、getCursorScreenPoint |
| Session | Session.fromPartition、cookies |
| Events | Electrobun.events.on(所有全局事件) |
| Preload | preload 脚本注入 |
| Updater | checkForUpdate、downloadUpdate、applyUpdate |
| Sandbox | sandbox: true 隔离 |
| Tray | new Tray、setMenu、tray-clicked |
| WGPU FFI | WGPUBridge 低层级 FFI |
| WGPU Adapter | GpuWindow、WGPUView 适配器层 |
| Babylon Adapter | BabylonJS WebGPU 集成 |
| WGPU Adapter Extended | 扩展的 WGPU surface 覆盖测试 |
Interactive (require human)
交互式(需要人工操作)
| Suite | Feature area |
|---|---|
| Dialogs | openFileDialog, showMessageBox |
| Tray | Tray visibility, icon, menu |
| Shortcuts | GlobalShortcut register/unregister |
| Webview Tag | |
| Clipboard | clipboardRead/WriteText/Image |
| Menus | ApplicationMenu, ContextMenu |
| Window Events | move, resize, blur, focus events |
| Chromeless | titleBarStyle: hidden, draggable regions |
| Multiwindow CEF | CEF renderer multi-window |
| Quit test | before-quit lifecycle |
| Webview settings | renderer options, sandbox |
| Webview cleanup | view lifecycle and removal |
| WGPU View | WGPUView interactive |
| WGPU Tag | |
| Fullsize frame repro | window frame edge cases |
| 套件 | 功能领域 |
|---|---|
| Dialogs | openFileDialog、showMessageBox |
| Tray | Tray 可见性、图标、菜单 |
| Shortcuts | GlobalShortcut 注册/注销 |
| Webview Tag | |
| Clipboard | clipboardRead/WriteText/Image |
| Menus | ApplicationMenu、ContextMenu |
| Window Events | move、resize、blur、focus 事件 |
| Chromeless | titleBarStyle: hidden、可拖动区域 |
| Multiwindow CEF | CEF renderer 多窗口 |
| Quit test | before-quit 生命周期 |
| Webview settings | renderer 选项、sandbox |
| Webview cleanup | view 生命周期和移除 |
| WGPU View | WGPUView 交互测试 |
| WGPU Tag | |
| Fullsize frame repro | 全尺寸 frame 问题复现 |
Test Runner UI — CSS Selectors
Test Runner UI — CSS 选择器
Main window:
views://test-runner/index.html主窗口:
views://test-runner/index.htmlControls
控件
| Selector | Action |
|---|---|
| |
| |
| |
| Fuzzy filter by name/category/description |
| |
| Toggle update status history panel |
| |
| 选择器 | 操作 |
|---|---|
| |
| |
| |
| 按名称、分类或描述进行模糊筛选 |
| |
| 切换更新状态历史面板 |
| |
Status elements
状态元素
| Selector | Shows |
|---|---|
| Total test count |
| Passed |
| Failed |
| Pending/not-run |
| Category groups + test cards |
| Total or filtered count |
| 选择器 | 显示内容 |
|---|---|
| 测试总数 |
| 已通过 |
| 失败 |
| 待运行/未运行 |
| 分类组和测试卡片 |
| 总数或筛选后的数量 |
Interactive modal
交互式模态框
| Selector | Purpose |
|---|---|
| Modal container |
| Test name |
| Instructions text |
| |
| |
| |
| |
| Optional notes |
| 选择器 | 用途 |
|---|---|
| 模态框容器 |
| 测试名称 |
| 说明文本 |
| |
| |
| |
| |
| 可选备注 |
Bun↔UI RPC Contract
Bun↔UI RPC 契约
Requests (bun exposes to UI)
请求(bun 暴露给 UI)
- → test list
getTests() - → run one test
runTest({ testId }) - → run all automated
runAllAutomated() - → start interactive sequence
runInteractiveTests() - → submit result
submitInteractiveResult({ testId, passed, notes }) - → signal ready for interactive step
submitReady({ testId }) - → pass/fail/retest
submitVerification({ testId, action, notes }) - → apply downloaded update
applyUpdate() - /
getUpdateStatusHistory()clearUpdateStatusHistory() - /
getTestRunnerPreferences()setTestRunnerPreferences({ searchQuery })
- → 测试列表
getTests() - → 运行单个测试
runTest({ testId }) - → 运行所有自动化测试
runAllAutomated() - → 启动交互式测试序列
runInteractiveTests() - → 提交结果
submitInteractiveResult({ testId, passed, notes }) - → 发出交互步骤已准备就绪的信号
submitReady({ testId }) - → 通过/失败/重测
submitVerification({ testId, action, notes }) - → 应用已下载的更新
applyUpdate() - /
getUpdateStatusHistory()clearUpdateStatusHistory() - /
getTestRunnerPreferences()→ 获取/设置测试运行器首选项setTestRunnerPreferences({ searchQuery })
Messages (bun sends to UI)
消息(bun 发送给 UI)
- — test execution began
testStarted - — result with pass/fail/duration
testCompleted - — log line
testLog - — all tests done
allCompleted - — waiting for user to click Start
interactiveWaiting - — user ready, perform the action
interactiveReady - — show pass/fail/retest controls
interactiveVerify - — app metadata
buildConfig - /
updateStatus— updater stateupdateStatusEntry
- ——测试执行已开始
testStarted - ——包含通过/失败状态和耗时的结果
testCompleted - ——日志行
testLog - ——所有测试已完成
allCompleted - ——等待用户点击“开始”
interactiveWaiting - ——用户已准备就绪,请执行操作
interactiveReady - ——显示通过/失败/重测控件
interactiveVerify - ——应用元数据
buildConfig - /
updateStatus——更新器状态updateStatusEntry
Interactive Test Flow (Two-Step)
交互式测试流程(两步)
1. User clicks Open on an interactive test
2. Runner shows modal: instructions + #btn-start
3. User reads instructions, clicks Start → submitReady()
4. A secondary playground window opens (bun-side)
5. User performs the described action in that window
6. Modal shows: #btn-pass, #btn-fail, #btn-retest
7. User marks result → submitVerification()
8. Modal closes, result recorded1. User clicks Open on an interactive test
2. Runner shows modal: instructions + #btn-start
3. User reads instructions, clicks Start → submitReady()
4. A secondary playground window opens (bun-side)
5. User performs the described action in that window
6. Modal shows: #btn-pass, #btn-fail, #btn-retest
7. User marks result → submitVerification()
8. Modal closes, result recordedConsuming the Manifest (agent usage)
使用 Manifest(agent 用法)
bash
undefinedbash
undefinedRead the manifest
Read the manifest
cat kitchen/src/generated/feature-manifest.json
cat kitchen/src/generated/feature-manifest.json
Filter: automated tests only
Filter: automated tests only
jq '[.[] | select(.interactive == false)]' feature-manifest.json
jq '[.[] | select(.interactive == false)]' feature-manifest.json
Filter: tests for a specific API
Filter: tests for a specific API
jq '[.[] | select(.apiSurface | contains(["BrowserWindow"]))]' feature-manifest.json
jq '[.[] | select(.apiSurface | contains(["BrowserWindow"]))]' feature-manifest.json
Map test to source file
Map test to source file
jq '.[] | select(.id == "window-creation-with-url") | .testFile' feature-manifest.json
undefinedjq '.[] | select(.id == "window-creation-with-url") | .testFile' feature-manifest.json
undefinedPlayground Windows
Playground 窗口
Each interactive suite opens a dedicated playground window. Key ones:
| Playground | URL | Key Controls |
|---|---|---|
| File dialog | | |
| App menu | | Sets app menu via RPC |
| Context menu | | Shows context menu via RPC |
| Webview tag | | masks, passthrough, navigation |
| Session/partition | | Compares cross-partition localStorage |
| Window events | | move/resize/blur/focus detection |
| Clipboard | | read/write text and image |
| Tray | | tray icon and menu |
每个交互式测试套件都会打开一个专用的 playground 窗口。主要包括:
| Playground | URL | 关键控件 |
|---|---|---|
| 文件对话框 | | |
| 应用菜单 | | 通过 RPC 设置应用菜单 |
| 上下文菜单 | | 通过 RPC 显示上下文菜单 |
| Webview 标签 | | 遮罩、穿透、导航 |
| Session/分区 | | 比较跨分区 localStorage |
| 窗口事件 | | 检测 move/resize/blur/focus |
| 剪贴板 | | 读写文本和图像 |
| 托盘 | | 托盘图标和菜单 |
Platform Caveats in Tests
测试中的平台注意事项
- Zoom: exact zoom level only verified on macOS; defaults to on other platforms
1.0 - Minimize/unminimize: marked unreliable on some Linux window managers
- Session cookies: some tests commented out due to ARM Windows VM crashes
- Application menus: intentionally skipped on Linux in interactive tests
- Context menus: marked macOS-only in interactive tests
- CEF devtools: only available in builds, at
devhttp://localhost:9222
- 缩放:仅在 macOS 上验证精确的缩放级别;其他平台默认为
1.0 - 最小化/取消最小化:在某些 Linux 窗口管理器中被标记为不可靠
- Session cookie:部分测试因 ARM Windows 虚拟机崩溃而被注释掉
- 应用菜单:交互式测试中有意在 Linux 上跳过
- 上下文菜单:交互式测试中标记为仅支持 macOS
- CEF devtools:仅在 构建中可用,地址为
devhttp://localhost:9222