Doubao-powered voice input for Linux, Wayland and Omarchy
test: expand Midscene onboarding regression coverage (#27)
Leyange63fbd0d7e9f
diff --git a/.github/workflows/midscene-ubuntu-22.04.yml b/.github/workflows/midscene-ubuntu-22.04.ymlindex 77b9a94..fa22275 100644--- a/.github/workflows/midscene-ubuntu-22.04.yml+++ b/.github/workflows/midscene-ubuntu-22.04.yml@@ -42,7 +42,7 @@ jobs:name: Midscene onboardingif: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repositoryruns-on: ubuntu-22.04- timeout-minutes: 15+ timeout-minutes: 60env:MIDSCENE_MODEL_API_KEY: ${{ secrets.MIDSCENE_MODEL_API_KEY }}MIDSCENE_MODEL_NAME: ${{ secrets.MIDSCENE_MODEL_NAME }}diff --git a/tests/e2e/README.md b/tests/e2e/README.mdindex 41d6f8e..8ba26cd 100644--- a/tests/e2e/README.md+++ b/tests/e2e/README.md@@ -94,3 +94,21 @@ The SSH and `hyprctl` calls in this PoC set up the scene and wait for the menu;the three user-visible conclusions come from Midscene's image assertions. Theguest runs Hyprland/Wayland; Midscene operates an X11 VNC viewer on the host.This demonstrates visual testing of a Wayland desktop through a VM bridge.++## Ubuntu regression cases++`cases/onboarding-regressions.yaml` adds five cases: cancelling and retrying+sign-in, returning to the signed-in account page, blocking a disabled trigger+and retaining F8, toggling polishing, and correcting a failed endpoint model.+The Ubuntu project runs these alongside the successful onboarding case.++Each case receives a fresh computer agent, GTK fixture, and temporary config+directory. Fixture cleanup completes before the next case starts. Shortcut and+polishing changes stay in memory; `synthetic-failing-model` produces a synthetic+endpoint error, while `synthetic-model` succeeds without network traffic.+These cases exercise production GTK widgets with synthetic callbacks, not live+ASR, recording, credential persistence, or global shortcut delivery.++Run `npm test -- --project ubuntu` with the system dependencies and model+configuration from the Ubuntu workflow. The Omarchy projects retain their shared+onboarding and shell cases.diff --git a/tests/e2e/cases/onboarding-regressions.yaml b/tests/e2e/cases/onboarding-regressions.yamlnew file mode 100644index 0000000..7ba2fe6--- /dev/null+++ b/tests/e2e/cases/onboarding-regressions.yaml@@ -0,0 +1,72 @@+cases:+ - name: Cancel sign-in and retry+ steps:+ - aiAct: "Verify the current step is Sign in, the account is not signed in, and both left-arrow Previous and right-arrow Next in the fixed top navigation are disabled."+ - aiAct: "Click Open Doubao sign-in exactly once, then stop."+ - aiAct: "Verify the CI-only Synthetic Doubao sign-in window is visible. Close only that synthetic window using its title-bar close button, without clicking Simulate successful sign-in."+ - aiAct: "Verify the synthetic sign-in window is gone, Doubao Say still shows Sign in and Not signed in, right-arrow Next remains disabled, and Open Doubao sign-in is available."+ - aiAct: "Verify the visible Doubao Say window starts on the Sign in step, says the user is not signed in, and shows an Open Doubao sign-in button. Do not click anything."+ - aiAct: "Click Open Doubao sign-in exactly once, then stop immediately."+ - aiAct: "Verify a Synthetic Doubao sign-in window is visible and explicitly says it is CI-only, makes no network request, and uses no real credentials. Do not click anything."+ - aiAct: "In the Synthetic Doubao sign-in window, click Simulate successful sign-in exactly once, then stop immediately."+ - aiAct: "Verify the synthetic sign-in window closed and the visible Doubao Say window automatically advanced to the Microphone step with a right-arrow Next button in the fixed top navigation."+ - name: Preserve signed-in account across backward navigation+ steps:+ - aiAct: "Verify the visible Doubao Say window starts on the Sign in step, says the user is not signed in, and shows an Open Doubao sign-in button. Do not click anything."+ - aiAct: "Click Open Doubao sign-in exactly once, then stop immediately."+ - aiAct: "Verify a Synthetic Doubao sign-in window is visible and explicitly says it is CI-only, makes no network request, and uses no real credentials. Do not click anything."+ - aiAct: "In the Synthetic Doubao sign-in window, click Simulate successful sign-in exactly once, then stop immediately."+ - aiAct: "Verify the synthetic sign-in window closed and the visible Doubao Say window automatically advanced to the Microphone step with a right-arrow Next button in the fixed top navigation."+ - aiAct: "Scroll to the bottom of the Microphone central content panel, then click left-arrow Previous in the fixed top navigation exactly once and stop."+ - aiAct: "Verify the Sign in step shows the heading Your voice, wherever you type near the top of the content without scrolling, and left-arrow Previous is disabled while right-arrow Next is enabled."+ - aiAct: "Scroll within the Sign in content if needed. Verify it says Signed in and shows Sign in again / change account. Do not open sign-in."+ - aiAct: "Click right-arrow Next in the fixed top navigation exactly once, then stop."+ - aiAct: "Verify the Microphone step and its heading Let's make sure we can hear you are visible without scrolling, and no synthetic sign-in window is open."+ - name: Require an enabled trigger and retain the replacement+ steps:+ - aiAct: "Verify the visible Doubao Say window starts on the Sign in step, says the user is not signed in, and shows an Open Doubao sign-in button. Do not click anything."+ - aiAct: "Click Open Doubao sign-in exactly once, then stop immediately."+ - aiAct: "Verify a Synthetic Doubao sign-in window is visible and explicitly says it is CI-only, makes no network request, and uses no real credentials. Do not click anything."+ - aiAct: "In the Synthetic Doubao sign-in window, click Simulate successful sign-in exactly once, then stop immediately."+ - aiAct: "Verify the synthetic sign-in window closed and the visible Doubao Say window automatically advanced to the Microphone step with a right-arrow Next button in the fixed top navigation."+ - aiAct: "Click right-arrow Next in the fixed top navigation exactly once, then stop."+ - aiAct: "Verify the current step is Trigger key and the heading Choose how to start speaking is visible. Do not navigate."+ - aiAct: "In the trigger selection dropdown below Active trigger, select Disabled. Do not change Voice polishing."+ - aiAct: "Click right-arrow Next in the fixed top navigation exactly once, then stop."+ - aiAct: "Verify the current step is still Trigger key and the message Choose an enabled trigger to continue is visible."+ - aiAct: "In the trigger selection dropdown select F8. Verify Active trigger: F8 is visible and F8 is selected in the trigger dropdown."+ - aiAct: "Click right-arrow Next in the fixed top navigation exactly once, then stop."+ - aiAct: "Verify the current step is Voice test, the heading Try a sentence. Nothing gets pasted is visible, and right-arrow Next is disabled."+ - aiAct: "Click left-arrow Previous exactly once, then stop."+ - aiAct: "Verify the Trigger key step still shows Active trigger: F8 and F8 is selected in the trigger dropdown."+ - name: Toggle polishing without losing configuration+ steps:+ - aiAct: "Verify the visible Doubao Say window starts on the Sign in step, says the user is not signed in, and shows an Open Doubao sign-in button. Do not click anything."+ - aiAct: "Click Open Doubao sign-in exactly once, then stop immediately."+ - aiAct: "Verify a Synthetic Doubao sign-in window is visible and explicitly says it is CI-only, makes no network request, and uses no real credentials. Do not click anything."+ - aiAct: "In the Synthetic Doubao sign-in window, click Simulate successful sign-in exactly once, then stop immediately."+ - aiAct: "Verify the synthetic sign-in window closed and the visible Doubao Say window automatically advanced to the Microphone step with a right-arrow Next button in the fixed top navigation."+ - aiAct: "Click right-arrow Next in the fixed top navigation exactly once, then stop."+ - aiAct: "Verify the current step is Trigger key and the heading Choose how to start speaking is visible. Do not navigate."+ - aiAct: "Scroll inside the central content panel to Voice polishing. Turn off the switch beside that heading."+ - aiAct: "Verify Voice polishing disabled is visible, the switch is off, and the polishing Base URL and Model fields are hidden."+ - aiAct: "Turn on the switch beside Voice polishing."+ - aiAct: "Verify Voice polishing enabled is visible, the switch is on, and the Base URL and Model fields have returned. Scroll within the content if needed and verify Model still contains synthetic-model."+ - name: Recover from an endpoint failure+ steps:+ - aiAct: "Verify the visible Doubao Say window starts on the Sign in step, says the user is not signed in, and shows an Open Doubao sign-in button. Do not click anything."+ - aiAct: "Click Open Doubao sign-in exactly once, then stop immediately."+ - aiAct: "Verify a Synthetic Doubao sign-in window is visible and explicitly says it is CI-only, makes no network request, and uses no real credentials. Do not click anything."+ - aiAct: "In the Synthetic Doubao sign-in window, click Simulate successful sign-in exactly once, then stop immediately."+ - aiAct: "Verify the synthetic sign-in window closed and the visible Doubao Say window automatically advanced to the Microphone step with a right-arrow Next button in the fixed top navigation."+ - aiAct: "Click right-arrow Next in the fixed top navigation exactly once, then stop."+ - aiAct: "Verify the current step is Trigger key and the heading Choose how to start speaking is visible. Do not navigate."+ - aiAct: "Scroll inside the central content panel to Voice polishing. Replace the Model field with synthetic-failing-model, then click Test endpoint exactly once, scrolling within the panel if needed."+ - aiAct: "Verify the visible endpoint feedback says Endpoint test failed: Synthetic endpoint unavailable, and the enabled retry button says Test failed — try again."+ - aiAct: "Scroll upward inside the central content panel until the Voice polishing Model input is visible. Stop with that input on screen."+ - aiAct: "In the Model input, select all existing text and replace it with exactly synthetic-model. Do not change Base URL or API Key. Stop after entering the new value."+ - aiAct: "Verify the Model input now contains exactly synthetic-model, without the word failing. Do not click or type anything."+ - aiAct: "Scroll downward inside the central content panel until the Test failed — try again button is visible. Do not click it yet."+ - aiAct: "Click the Test failed — try again button exactly once to run a new endpoint test. Stop immediately after the click."+ - aiAct: "Scroll within the central content panel if needed until the endpoint result text below the retry button is fully visible."+ - aiAct: "Verify the endpoint result says Endpoint works: Synthetic endpoint response, the enabled button says Endpoint works, and the previous Synthetic endpoint unavailable error is no longer visible."diff --git a/tests/e2e/gtk_fixture.py b/tests/e2e/gtk_fixture.pyindex e468983..8dd7c28 100644--- a/tests/e2e/gtk_fixture.py+++ b/tests/e2e/gtk_fixture.py@@ -9,7 +9,7 @@ from gi.repository import GLib, Gtkfrom doubao_input.doubao.app_state import AppState, LoginStatusfrom doubao_input.i18n import set_language-from doubao_input.settings import Settings+from doubao_input.settings import Settings, trigger_shortcut_displayfrom doubao_input.ui.control_window import ControlWindowfrom doubao_input.ui.setup_actions import SetupActions@@ -90,13 +90,24 @@ def main():holder["login"] = loginlogin.present()- def test_endpoint(_settings, _key, done):+ def test_endpoint(endpoint_settings, _key, done):def finish():- done("Synthetic endpoint response", None)+ if endpoint_settings.polish_model == "synthetic-failing-model":+ done(None, "Synthetic endpoint unavailable")+ else:+ done("Synthetic endpoint response", None)return GLib.SOURCE_REMOVEGLib.timeout_add(350, finish)+ def apply_key(key, modifiers=()):+ summary.update(key_code=key, key_modifiers=modifiers,+ key=trigger_shortcut_display(key, modifiers))++ def save_polish(updated_settings, _key):+ nonlocal settings+ settings = updated_settings+def complete_setup():control = holder["control"]message = "Setup completed by the synthetic E2E fixture."@@ -111,10 +122,10 @@ def main():is_preview_testing=lambda: False,summary=lambda: summary,complete_setup=complete_setup,- apply_key=lambda _key, _modifiers=(): None,+ apply_key=apply_key,polish_settings=lambda: settings,polish_has_key=lambda: True,- save_polish=lambda _settings, _key: None,+ save_polish=save_polish,test_polish=test_endpoint,apply_microphone=lambda _microphone: None,)diff --git a/tests/e2e/midscene-node-reference.md b/tests/e2e/midscene-node-reference.mdindex d497907..917a1e6 100644--- a/tests/e2e/midscene-node-reference.md+++ b/tests/e2e/midscene-node-reference.md@@ -31,7 +31,7 @@ Projects created by `midscene-test create` select `cases/**/*.{yaml,yml}` by def**Config file:** `midscene.config.ts`-**Case files:** `cases/onboarding.yaml` (Execution Project: ubuntu)+**Case files:** `cases/onboarding.yaml`, `cases/onboarding-regressions.yaml` (Execution Project: ubuntu)**Case files:** `cases/onboarding.yaml` (Execution Project: omarchy-onboarding)diff --git a/tests/e2e/midscene.config.ts b/tests/e2e/midscene.config.tsindex fc9bc5f..884d96b 100644--- a/tests/e2e/midscene.config.ts+++ b/tests/e2e/midscene.config.ts@@ -1,21 +1,31 @@import { execFileSync, spawn, type ChildProcess } from 'node:child_process';import { resolve } from 'node:path';+import { mkdtemp, rm } from 'node:fs/promises';+import { tmpdir } from 'node:os';import { ComputerAgent, agentForComputer } from '@midscene/computer';import { defineNode, z } from '@midscene/test';import { defineProjectSetup, defineTestProject } from '@midscene/test/config';import { createMidsceneNodes } from '@midscene/test/midscene';interface DesktopContext {- agent: ComputerAgent;+ agent?: ComputerAgent;+ createAgent: () => Promise<ComputerAgent>;+ resetFixture?: () => Promise<void>;barConfigBackup?: string;barConfigExisted?: boolean;}const sleep = (ms: number) => new Promise((done) => setTimeout(done, ms));-const stop = (child?: ChildProcess) => {- if (child?.pid) {- try { process.kill(-child.pid, 'SIGTERM'); } catch { /* already exited */ }- }+const stop = async (child?: ChildProcess) => {+ if (!child?.pid || child.exitCode !== null || child.signalCode !== null) return;+ await new Promise<void>((done) => {+ const timer = setTimeout(() => {+ try { process.kill(-child.pid!, 'SIGKILL'); } catch { /* already exited */ }+ }, 3000);+ child.once('exit', () => { clearTimeout(timer); done(); });+ try { process.kill(-child.pid!, 'SIGTERM'); }+ catch { clearTimeout(timer); done(); }+ });};function guest(command: string): string {@@ -50,6 +60,7 @@ async function waitForFixture(child: ChildProcess): Promise<void> {};child.stdout?.on('data', capture);child.stderr?.on('data', capture);+ child.once('error', (error) => { clearTimeout(timer); fail(error); });child.once('exit', (code) => {clearTimeout(timer);fail(new Error(`GTK fixture exited (${code}):\n${output}`));@@ -62,16 +73,24 @@ const setup = defineProjectSetup<DesktopContext>({async setup({ project, onTeardown }) {const omarchy = project.name.startsWith('omarchy-');const shell = project.name === 'omarchy-shell';- const agent = await agentForComputer({- xvfbResolution: omarchy ? '1280x800x24' : '1280x960x24',- // libnut and the VNC viewer may still hold X11 connections while the- // Agent finalizes its report. Stop Xvfb only after this process exits.- keepXvfbAliveUntilProcessExit: true,- aiContexts: shell- ? { aiAssert: 'Inspect the real Omarchy desktop through VNC. Judge only visible pixels; do not infer success from commands or configuration.' }- : { aiAct: `Test the English Doubao Say GTK onboarding window${omarchy ? ' inside a real Omarchy VM shown through VNC' : ''}. Interact only with Doubao Say and use visible labels.` },- });- onTeardown(() => agent.destroy());+ let desktopReady = false;+ const createAgent = async () => {+ const agent = await agentForComputer({+ // Later case agents share the Xvfb display hosting Fluxbox and libnut.+ headless: desktopReady ? false : undefined,+ xvfbResolution: omarchy ? '1280x800x24' : '1280x960x24',+ // libnut and the VNC viewer may still hold X11 connections while the+ // Agent finalizes its report. Stop Xvfb only after this process exits.+ keepXvfbAliveUntilProcessExit: true,+ aiContexts: shell+ ? { aiAssert: 'Inspect the real Omarchy desktop through VNC. Judge only visible pixels; do not infer success from commands or configuration.' }+ : { aiAct: `Test the English Doubao Say GTK onboarding window${omarchy ? ' inside a real Omarchy VM shown through VNC' : ''}. Interact only with Doubao Say and use visible labels.` },+ });+ desktopReady = true;+ return agent;+ };+ const context: DesktopContext = { agent: await createAgent(), createAgent };+ onTeardown(() => context.agent?.destroy());const fluxbox = spawn('fluxbox', [], { detached: true, stdio: 'ignore', env: process.env });onTeardown(() => stop(fluxbox));await sleep(1000);@@ -83,18 +102,31 @@ const setup = defineProjectSetup<DesktopContext>({await sleep(4000);} else {const root = resolve(import.meta.dirname, '../..');- const fixture = spawn('/usr/bin/python3', ['tests/e2e/gtk_fixture.py'], {- cwd: root, detached: true, stdio: ['ignore', 'pipe', 'pipe'],- env: {- ...process.env, GDK_BACKEND: 'x11', GSK_RENDERER: 'cairo', GTK_A11Y: 'none',- PYTHONPATH: resolve(root, 'src'), XDG_CONFIG_HOME: resolve(root, '.midscene-config'),- },- });- onTeardown(() => stop(fixture));- await waitForFixture(fixture);- await sleep(1000);+ let fixture: ChildProcess | undefined;+ let configDirectory: string | undefined;+ const cleanup = async () => {+ await stop(fixture);+ fixture = undefined;+ if (configDirectory) {+ await rm(configDirectory, { recursive: true, force: true });+ configDirectory = undefined;+ }+ };+ onTeardown(cleanup);+ context.resetFixture = async () => {+ await cleanup();+ configDirectory = await mkdtemp(resolve(tmpdir(), 'doubao-midscene-'));+ fixture = spawn('/usr/bin/python3', ['tests/e2e/gtk_fixture.py'], {+ cwd: root, detached: true, stdio: ['ignore', 'pipe', 'pipe'],+ env: {+ ...process.env, GDK_BACKEND: 'x11', GSK_RENDERER: 'cairo', GTK_A11Y: 'none',+ PYTHONPATH: resolve(root, 'src'), XDG_CONFIG_HOME: configDirectory,+ },+ });+ await waitForFixture(fixture);+ await sleep(1000);+ };}- const context: DesktopContext = { agent };if (shell) {onTeardown(() => {try {@@ -145,7 +177,7 @@ const moveBarLeft = defineNode<typeof empty, void, DesktopContext>({export default defineTestProject<DesktopContext>({test: { maxConcurrency: 1, testTimeout: 8 * 60_000 },projects: [- { name: 'ubuntu', setup, files: { include: ['cases/onboarding.yaml'] } },+ { name: 'ubuntu', setup, files: { include: ['cases/onboarding.yaml', 'cases/onboarding-regressions.yaml'] } },{ name: 'omarchy-onboarding', setup, files: { include: ['cases/onboarding.yaml'] } },{ name: 'omarchy-shell', setup, files: { include: ['cases/omarchy-shell.yaml'] } },],@@ -153,17 +185,23 @@ export default defineTestProject<DesktopContext>({...createMidsceneNodes<DesktopContext>({agentClass: ComputerAgent,agentProvider: (() => {- const active = new Map<string, ComputerAgent>();+ const active = new Map<string, { agent: ComputerAgent; context: DesktopContext }>();return {- getAgent(runId: string, { context }: { context: DesktopContext }) {- active.set(runId, context.agent);+ async getAgent(runId: string, { context }: { context: DesktopContext }) {+ const existing = active.get(runId);+ if (existing) return existing.agent;+ context.agent ??= await context.createAgent();+ await context.resetFixture?.();+ active.set(runId, { agent: context.agent, context });return context.agent;},async releaseAgent(runId: string) {- const agent = active.get(runId);- if (!agent) throw new Error(`No Agent for Midscene case ${runId}`);+ const entry = active.get(runId);+ if (!entry) throw new Error(`No Agent for Midscene case ${runId}`);active.delete(runId);+ const { agent, context } = entry;await agent.destroy();+ context.agent = undefined;if (!agent.reportFile) throw new Error(`No Agent report for Midscene case ${runId}`);return { reportPath: agent.reportFile };},