Skip to content

Commit ed945d7

Browse files
committed
Add microphone error browser validation
1 parent 20a09a9 commit ed945d7

1 file changed

Lines changed: 72 additions & 0 deletions

File tree

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: microphone-errors-e2e
2+
3+
on:
4+
push:
5+
branches: [validation/microphone-errors-e2e]
6+
7+
permissions:
8+
contents: read
9+
10+
jobs:
11+
browser:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v7
15+
with:
16+
ref: post-freeze-permission-errors
17+
- uses: actions/setup-node@v6
18+
with:
19+
node-version: 22
20+
- run: corepack enable
21+
- run: pnpm install --frozen-lockfile
22+
- run: pnpm build
23+
- name: Install browser harness
24+
run: |
25+
mkdir -p /tmp/er-browser
26+
cd /tmp/er-browser
27+
npm init -y >/dev/null
28+
npm install playwright@1.62.0 >/dev/null
29+
npx playwright install chromium
30+
- name: Validate public microphone failures
31+
run: |
32+
pnpm --filter @everything-rings/web exec vite preview --host 127.0.0.1 --port 4173 --strictPort >/tmp/er-preview.log 2>&1 &
33+
SERVER_PID=$!
34+
trap 'kill "$SERVER_PID" 2>/dev/null || true' EXIT
35+
for _ in $(seq 1 40); do curl -fsS http://127.0.0.1:4173 >/dev/null && break; sleep .25; done
36+
cat >/tmp/er-browser/test.mjs <<'JS'
37+
import { chromium } from 'playwright';
38+
39+
const cases = [
40+
['NotAllowedError', 'Microphone access is blocked. Allow microphone access for this site, then try again.'],
41+
['NotFoundError', 'No microphone is available on this device.'],
42+
['NotReadableError', 'The microphone could not be opened. Close other apps using it, then try again.'],
43+
];
44+
const browser = await chromium.launch({ headless: true });
45+
try {
46+
for (const [name, expected] of cases) {
47+
const context = await browser.newContext();
48+
const page = await context.newPage();
49+
const pageErrors = [];
50+
page.on('pageerror', (error) => pageErrors.push(String(error)));
51+
await page.addInitScript((errorName) => {
52+
const getUserMedia = async () => { throw new DOMException('synthetic microphone failure', errorName); };
53+
Object.defineProperty(navigator, 'mediaDevices', {
54+
configurable: true,
55+
value: { getUserMedia },
56+
});
57+
}, name);
58+
await page.goto('http://127.0.0.1:4173/', { waitUntil: 'networkidle' });
59+
await page.getByRole('button', { name: 'START LISTENING' }).click();
60+
await page.getByRole('alert').waitFor({ state: 'visible' });
61+
const body = await page.locator('body').innerText();
62+
if (!body.includes(expected)) throw new Error(`${name}: expected recovery copy not found: ${body}`);
63+
if (body.includes(name)) throw new Error(`${name}: raw browser exception leaked into UI`);
64+
if (pageErrors.length !== 0) throw new Error(`${name}: page errors: ${pageErrors.join('; ')}`);
65+
await context.close();
66+
}
67+
} finally {
68+
await browser.close();
69+
}
70+
console.log('Microphone startup error E2E passed.');
71+
JS
72+
node /tmp/er-browser/test.mjs

0 commit comments

Comments
 (0)