P1c: microphone recording through the material pipeline

This commit is contained in:
Emil
2026-11-01 01:44:36 +03:00
parent 0acf11ccb0
commit 88663a384e
14 changed files with 421 additions and 18 deletions
+60
View File
@@ -0,0 +1,60 @@
import { chromium } from 'playwright-core';
import path from 'node:path';
const chrome = process.env.CHROME_PATH ?? '/home/emil/.cache/ms-playwright/chromium-1248/chrome-linux64/chrome';
const fixture = path.resolve('../fixtures/clicks-01.wav');
const browser = await chromium.launch({
executablePath: chrome,
args: [
'--no-sandbox',
'--autoplay-policy=no-user-gesture-required',
'--use-fake-ui-for-media-stream',
'--use-fake-device-for-media-stream',
`--use-file-for-fake-audio-capture=${fixture}`
]
});
const page = await browser.newPage({ viewport: { width: 1600, height: 1000 }, deviceScaleFactor: 1 });
const errors = [];
page.on('pageerror', (error) => errors.push(`pageerror: ${error.message}`));
page.on('console', (message) => { if (message.type() === 'error') errors.push(`console: ${message.text()}`); });
await page.goto('http://127.0.0.1:5173/', { waitUntil: 'load' });
await page.waitForTimeout(2200);
await page.locator('.room', { hasText: 'quarry' }).click();
await page.waitForTimeout(500);
const record = page.locator('.quarry-actions .record');
await record.click();
await page.waitForSelector('.quarry-actions .record.is-on', { timeout: 5000 });
await page.waitForTimeout(2300);
const during = await record.textContent();
await record.click();
await page.waitForFunction(
() => [...document.querySelectorAll('.core-name')].some((el) => el.textContent?.includes('take-01')),
null,
{ timeout: 25000 }
);
await page.waitForTimeout(900);
await page.screenshot({ path: '../preview-p1c-record.png' });
const report = await page.evaluate(() => ({
cores: [...document.querySelectorAll('.core-name')].map((el) => el.textContent),
faces: document.querySelectorAll('.face').length,
selected: document.querySelector('.core-tab.is-on .core-name')?.textContent,
stats: document.querySelector('.face-stats')?.textContent?.replace(/\s+/g, ' ').trim(),
wire: [...document.querySelectorAll('.wire-label')].map((el) => el.textContent).slice(-6),
recordText: document.querySelector('.quarry-actions .record')?.textContent?.trim()
}));
console.log(JSON.stringify({ during, report, errors }, null, 2));
const failures = [];
if (!during || !during.includes('stop')) failures.push('record button did not switch to stop');
if (!report.cores.includes('take-01')) failures.push('take-01 was not imported');
if (report.faces !== 16) failures.push('take did not produce 16 faces');
if (!report.stats || !report.stats.includes('recorded')) failures.push('seal is not recorded');
if (errors.length) failures.push('console errors');
await browser.close();
if (failures.length) {
console.error('RECORD SMOKE FAILED: ' + failures.join('; '));
process.exit(1);
}
console.log('record smoke passed');