test: cover constrained browser concurrency

This commit is contained in:
mARTin-B78 2026-09-04 08:59:09 +02:00
parent fbb5fc52dd
commit d03c9841e9
4 changed files with 27 additions and 1 deletions

View File

@ -25,6 +25,8 @@ Follows [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) · versioned wi
headers so browser and intermediary caches cannot retain the client-visible access-key handoff.
- **Navigation Race Protection.** Rehearser phase requests now survive late feature-module initialization, and
overlapping character-library refreshes cannot overwrite a newer table/card view.
- **Constrained Browser Smoke Coverage.** Added a 4 GB `navigator.deviceMemory` regression that verifies shared
batch work is capped at two concurrent operations.
- **API Boundary Hardening.** External API authentication is enabled by default, request and mutation limits are
enforced, and settings responses redact provider credentials for non-browser callers.
- **Server-side Provider Credentials.** Provider keys are now masked even for same-origin Settings responses, are

View File

@ -60,7 +60,8 @@ the first block before investing in architecture or polish.
- [x] **M — Add explicit cache invalidation and eviction.** Fish.audio search responses, persisted synthesized
audio, image-generation job mappings, and browser object URLs have bounded cleanup.
- [ ] **M — Add constrained-device validation.** Test with Chrome CPU/memory throttling,
a 4 GB VM/container, and measure browser, Docker and temporary-disk usage.
a 4 GB VM/container, and measure browser, Docker and temporary-disk usage. Automated browser emulation now proves
the 4 GB shared-pool cap; physical VM/container and resource measurements remain.
- [ ] **L — Add background jobs and bounded queues.** Give voice design, transcription,
casting and image generation IDs, progress, cancellation, timeout, retry and
idempotency support.

View File

@ -367,6 +367,7 @@ async function runPool(items, worker, concurrency = 4, onProgress) {
}
await Promise.all(Array.from({ length: Math.min(effectiveConcurrency, arr.length) }, run));
}
window.runPool = runPool;
async function copyText(text) {
try {
await navigator.clipboard.writeText(text);

22
tests/constrained.spec.js Normal file
View File

@ -0,0 +1,22 @@
// @ts-check
// Lightweight constrained-device regression: the browser's 4 GB profile must
// reduce shared batch concurrency before multiple audio/image operations run.
const { test, expect } = require('@playwright/test');
test('4 GB browser profile caps shared batch concurrency at two', async ({ page }) => {
await page.goto('/', { waitUntil: 'domcontentloaded' });
await page.waitForFunction(() => typeof window.runPool === 'function', null, { timeout: 15_000 });
const maxActive = await page.evaluate(async () => {
Object.defineProperty(navigator, 'deviceMemory', { configurable: true, value: 4 });
let active = 0;
let max = 0;
await window.runPool(Array.from({ length: 8 }, (_, i) => i), async () => {
active += 1;
max = Math.max(max, active);
await new Promise(resolve => setTimeout(resolve, 15));
active -= 1;
}, 4);
return max;
});
expect(maxActive).toBeLessThanOrEqual(2);
});