Skip to content

Doubao-powered voice input for Linux, Wayland and Omarchy

test: stabilize Omarchy visual checks under parallel model load

quanrue95b5cb23e10
diff --git a/.github/workflows/midscene-omarchy-4.0.3.yml b/.github/workflows/midscene-omarchy-4.0.3.yml
index dccfe02..fcac954 100644
--- a/.github/workflows/midscene-omarchy-4.0.3.yml
+++ b/.github/workflows/midscene-omarchy-4.0.3.yml
@@ -15,6 +15,7 @@ on:
- "scripts/verify-omarchy-evidence.mjs"
- "scripts/omarchy-shell-evidence.mjs"
- "tests/contracts/test_pages_report_history.mjs"
+ - "tests/contracts/test_model_rate_gate.mjs"
- "tests/e2e/package.json"
- "tests/e2e/package-lock.json"
- "tests/e2e/gtk_fixture.py"
@@ -23,6 +24,7 @@ on:
- "tests/e2e/capture-report-preview.mjs"
- "tests/e2e/cases/**"
- "tests/e2e/midscene.config.ts"
+ - "tests/e2e/model-rate-gate.mjs"
- "tests/e2e/run-omarchy-midscene.sh"
- "tests/e2e/restore-omarchy-vm.sh"
- "tests/e2e/omarchy-vm.env"
@@ -54,8 +56,8 @@ jobs:
strategy:
# Each shard restores an independent disposable VM. Sharing one Hyprland
# session would make fixture resets, focus and screenshots race.
- # Run independent VMs concurrently. The current Ark endpoint may still
- # return 429 under this load; MIDSCENE_MODEL_RETRY_* handles short bursts.
+ # Run independent VMs concurrently. Each worker paces model requests to
+ # one every 20s, keeping the aggregate below the Ark endpoint RPM.
fail-fast: false
max-parallel: 5
matrix:
diff --git a/tests/contracts/test_model_rate_gate.mjs b/tests/contracts/test_model_rate_gate.mjs
new file mode 100644
index 0000000..dfb8bae
--- /dev/null
+++ b/tests/contracts/test_model_rate_gate.mjs
@@ -0,0 +1,53 @@
+import assert from 'node:assert/strict';
+import { spawn } from 'node:child_process';
+import http from 'node:http';
+import test from 'node:test';
+
+const listen = (server) => new Promise((resolve) => server.listen(0, '127.0.0.1', resolve));
+const close = (server) => new Promise((resolve) => server.close(resolve));
+
+test('forwards model requests and spaces their starts without changing payloads', async () => {
+ const received = [];
+ const upstream = http.createServer(async (request, response) => {
+ let body = '';
+ for await (const chunk of request) body += chunk;
+ received.push({ at: Date.now(), path: request.url, authorization: request.headers.authorization, body });
+ response.writeHead(200, { 'content-type': 'application/json' }).end('{"ok":true}');
+ });
+ await listen(upstream);
+ const gatePort = upstream.address().port + 1;
+ const gate = spawn(process.execPath, ['tests/e2e/model-rate-gate.mjs'], {
+ env: {
+ ...process.env,
+ MIDSCENE_RATE_GATE_UPSTREAM: `http://127.0.0.1:${upstream.address().port}/api/v3`,
+ MIDSCENE_RATE_GATE_PORT: String(gatePort),
+ MIDSCENE_RATE_GATE_INTERVAL_MS: '100',
+ },
+ stdio: 'ignore',
+ });
+ try {
+ let ready = false;
+ for (let attempt = 0; attempt < 50; attempt++) {
+ try {
+ ready = (await fetch(`http://127.0.0.1:${gatePort}/healthz`)).ok;
+ if (ready) break;
+ } catch { /* startup */ }
+ await new Promise((resolve) => setTimeout(resolve, 20));
+ }
+ assert.equal(ready, true);
+ const send = (body) => fetch(`http://127.0.0.1:${gatePort}/chat/completions`, {
+ method: 'POST',
+ headers: { authorization: 'Bearer test-key', 'content-type': 'application/json' },
+ body,
+ });
+ const responses = await Promise.all([send('{"call":1}'), send('{"call":2}')]);
+ assert.deepEqual(await Promise.all(responses.map((response) => response.json())), [{ ok: true }, { ok: true }]);
+ assert.deepEqual(received.map(({ path }) => path), ['/api/v3/chat/completions', '/api/v3/chat/completions']);
+ assert.deepEqual(received.map(({ authorization }) => authorization), ['Bearer test-key', 'Bearer test-key']);
+ assert.deepEqual(received.map(({ body }) => body).sort(), ['{"call":1}', '{"call":2}']);
+ assert.ok(received[1].at - received[0].at >= 70);
+ } finally {
+ gate.kill();
+ await close(upstream);
+ }
+});
diff --git a/tests/contracts/test_pages_report_history.mjs b/tests/contracts/test_pages_report_history.mjs
index 78cc95c..6103141 100644
--- a/tests/contracts/test_pages_report_history.mjs
+++ b/tests/contracts/test_pages_report_history.mjs
@@ -184,6 +184,8 @@ test('keeps visual E2E interactions at task level with proven tap exceptions', a
'- aiTap: Test failed — try again button in the Voice polishing section',
'- aiTap: Right-arrow Next button in the fixed top navigation',
'- aiScroll:',
+ '- computer.tapPoint: { target: Left-arrow Previous button in the fixed top navigation, point: { x: 240, y: 203 } }',
+ '- aiTap: Check microphone · 3 seconds button on the Microphone step',
'- aiTap: Right-arrow Next button in the fixed top navigation',
'- aiScroll:',
'- aiTap: Start voice test button in the Voice test section',
diff --git a/tests/e2e/cases/omarchy-shell.yaml b/tests/e2e/cases/omarchy-shell.yaml
index fd8e312..c79532d 100644
--- a/tests/e2e/cases/omarchy-shell.yaml
+++ b/tests/e2e/cases/omarchy-shell.yaml
@@ -3,7 +3,7 @@ cases:
steps:
- shell.openSystemMenu: {}
- aiAssert: The Omarchy system menu is open, and its Shutdown item is clearly readable.
- - aiAssert: Exactly one row in the open system menu has a visible focus highlight or accent, and the highlight is rendered cleanly.
+ - aiAssert: The Lock row in the open system menu has a blue-gray focus highlight behind its text; the adjacent Screensaver and Suspend rows do not have that highlighted background.
- shell.closeSystemMenu: {}
- shell.moveBarLeft: {}
- aiAssert: The Omarchy bar is visible as a tall vertical bar docked to the left edge of the desktop, rather than a horizontal bar across the top or bottom.
diff --git a/tests/e2e/cases/onboarding-regressions.yaml b/tests/e2e/cases/onboarding-regressions.yaml
index 0edf3e9..aad77f9 100644
--- a/tests/e2e/cases/onboarding-regressions.yaml
+++ b/tests/e2e/cases/onboarding-regressions.yaml
@@ -18,9 +18,9 @@ cases:
options: { timeoutMs: 30000, checkIntervalMs: 1000 }
- aiTap: The blue Simulate successful sign-in button in the CI-only modal, around 50% width and 43% screen height
- aiWaitFor:
- prompt: The sign-in window is closed and Doubao Say has advanced to the Microphone step.
+ prompt: The Doubao Say page heading says Microphone and the page offers Check microphone · 3 seconds.
options: { timeoutMs: 30000, checkIntervalMs: 1000 }
- - aiAssert: Doubao Say is on the Microphone step and no synthetic sign-in window is open.
+ - aiAssert: The visible Doubao Say page is the Microphone step with Synthetic microphone one selected.
- name: Preserve signed-in account across backward navigation
tags: [shard-4]
@@ -80,7 +80,7 @@ cases:
- aiWaitFor:
prompt: Voice polishing is enabled and its Model input is visible.
options: { timeoutMs: 30000, checkIntervalMs: 1000 }
- - aiAssert: The Voice polishing switch is on and the Model input contains exactly synthetic-model.
+ - aiAssert: The blue Voice polishing switch is on, and the Model text field visibly reads synthetic-model.
- name: Recover from an endpoint failure
tags: [shard-2]
@@ -113,7 +113,11 @@ cases:
prompt: Voice test is visible and Finish setup is fully visible.
options: { timeoutMs: 30000, checkIntervalMs: 1000 }
- aiAssert: The Finish setup button is visibly disabled.
- - aiAct: Return to Microphone and run Check microphone · 3 seconds.
+ - computer.tapPoint: { target: Left-arrow Previous button in the fixed top navigation, point: { x: 240, y: 203 } }
+ - aiWaitFor:
+ prompt: The Microphone step and Check microphone · 3 seconds button are visible.
+ options: { timeoutMs: 30000, checkIntervalMs: 1000 }
+ - aiTap: Check microphone · 3 seconds button on the Microphone step
- aiWaitFor:
prompt: The visible feedback says Microphone is working and instructs the user to continue to the trigger key step.
options: { timeoutMs: 30000, checkIntervalMs: 1000 }
diff --git a/tests/e2e/model-rate-gate.mjs b/tests/e2e/model-rate-gate.mjs
new file mode 100644
index 0000000..27ab36b
--- /dev/null
+++ b/tests/e2e/model-rate-gate.mjs
@@ -0,0 +1,44 @@
+import http from 'node:http';
+import https from 'node:https';
+
+// Each GitHub matrix job has one independent VM and one Midscene worker. Pace
+// requests per worker so five concurrent jobs stay below the Ark endpoint RPM.
+const upstream = new URL(process.env.MIDSCENE_RATE_GATE_UPSTREAM);
+const intervalMs = Number(process.env.MIDSCENE_RATE_GATE_INTERVAL_MS ?? 20000);
+const port = Number(process.env.MIDSCENE_RATE_GATE_PORT ?? 18783);
+if (!['http:', 'https:'].includes(upstream.protocol) || !Number.isFinite(intervalMs) || intervalMs < 0) {
+ throw new Error('Invalid model rate gate configuration');
+}
+
+let nextStart = 0;
+const server = http.createServer(async (request, response) => {
+ if (request.url === '/healthz') {
+ response.writeHead(200).end('ready');
+ return;
+ }
+
+ const path = request.url?.replace(/^\/+/, '') ?? '';
+ const target = new URL(`${upstream.pathname.replace(/\/$/, '')}/${path}`, upstream.origin);
+ const scheduled = Math.max(Date.now(), nextStart);
+ nextStart = scheduled + intervalMs;
+ await new Promise((resolve) => setTimeout(resolve, scheduled - Date.now()));
+
+ const transport = target.protocol === 'https:' ? https : http;
+ const headers = { ...request.headers, host: target.host };
+ const forwarded = transport.request(target, {
+ method: request.method,
+ headers,
+ timeout: 180000,
+ }, (upstreamResponse) => {
+ response.writeHead(upstreamResponse.statusCode ?? 502, upstreamResponse.headers);
+ upstreamResponse.pipe(response);
+ });
+ forwarded.on('timeout', () => forwarded.destroy(new Error('Model upstream timed out')));
+ forwarded.on('error', () => {
+ if (!response.headersSent) response.writeHead(502);
+ response.end('Model upstream unavailable');
+ });
+ request.pipe(forwarded);
+});
+
+server.listen(port, '127.0.0.1');
diff --git a/tests/e2e/run-omarchy-midscene.sh b/tests/e2e/run-omarchy-midscene.sh
index c59931f..104669b 100755
--- a/tests/e2e/run-omarchy-midscene.sh
+++ b/tests/e2e/run-omarchy-midscene.sh
@@ -19,8 +19,12 @@ export OMARCHY_SSH_KEY="$SSH_KEY"
VM_PID=""
XVFB_PID=""
+MODEL_GATE_PID=""
cleanup() {
+ if [[ -n $MODEL_GATE_PID ]]; then
+ kill "$MODEL_GATE_PID" 2>/dev/null || true
+ fi
if [[ -n $XVFB_PID ]]; then
kill "$XVFB_PID" 2>/dev/null || true
fi
@@ -196,6 +200,21 @@ for _xvfb_attempt in {1..200}; do
sleep 0.2
done
+export MIDSCENE_RATE_GATE_UPSTREAM="$MIDSCENE_MODEL_BASE_URL"
+export MIDSCENE_MODEL_BASE_URL="http://127.0.0.1:18783"
+node "$ROOT_DIR/tests/e2e/model-rate-gate.mjs" >"$WORK_DIR/model-rate-gate.log" 2>&1 &
+MODEL_GATE_PID=$!
+for _gate_attempt in {1..100}; do
+ if curl --silent --fail --max-time 1 "$MIDSCENE_MODEL_BASE_URL/healthz" >/dev/null; then
+ break
+ fi
+ if ! kill -0 "$MODEL_GATE_PID" 2>/dev/null || ((_gate_attempt == 100)); then
+ echo "Model rate gate did not become ready." >&2
+ exit 1
+ fi
+ sleep 0.2
+done
+
case "$MIDSCENE_PROJECT" in
omarchy-shard-[1-4])
npm --prefix tests/e2e test -- --project "$MIDSCENE_PROJECT"