feat(recording): render the safe frame from a recording store

RecordingControls publishes the safe frame a recording composes in, 16:9
or 9:16 (null while none records), to the new recording store, and the
scene chrome renders the overlay's active and ratio classes from it
instead of the controls writing them. Any frame but 9:16, even none named,
records in 16:9 as before.
This commit is contained in:
Sameh Khamis committed 2026-11-01 14:15:36 -08:00
1 parent 0949f6a776
commit 3a750c9021
11 files changed
+116 -38

No files matched your search

+59
View File
@@ -0,0 +1,59 @@
// src/ui/safeFrameView.test.mjs — the recording safe frame renders what
// RecordingControls publishes to the recording store.
import '../testSupport/registerDom.mjs';
import test from 'node:test';
import assert from 'node:assert/strict';
import { createApp, nextTick } from 'vue';
import { createPinia } from 'pinia';
import { useRecordingStore } from './stores/recording.js';
import { RecordingControls } from './recordingControls.js';
import SceneChromeView from './views/SceneChromeView.vue';
test('the safe frame shows while a recording composes in it', async (t) => {
document.body.replaceChildren();
const pinia = createPinia();
const app = createApp(SceneChromeView).use(pinia);
app.mount(document.body.appendChild(document.createElement('div')));
t.after(() => app.unmount());
const store = useRecordingStore(pinia);
const recording = new RecordingControls({
syncShareState() {},
syncHudControls() {},
publishSafeFrame: (frame) => store.publishSafeFrame(frame),
});
recording.hud = {
getMode: () => 'auto',
getVariant: () => 'tactical',
setMode() {},
setVariant() {},
};
t.after(() => recording.destroy());
const overlay = document.getElementById('safe-frame-overlay');
const classes = () =>
['active', 'ratio-16-9', 'ratio-9-16'].filter((name) =>
overlay.classList.contains(name),
);
recording._initRecordingOverlay();
await nextTick();
assert.deepEqual(classes(), []);
recording.setRecordingMode(true, { safeFrame: '9:16' });
await nextTick();
assert.deepEqual(classes(), ['active', 'ratio-9-16']);
recording.setRecordingMode(true);
await nextTick();
assert.deepEqual(classes(), ['active', 'ratio-16-9']);
recording.setRecordingMode(false);
await nextTick();
assert.deepEqual(classes(), []);
// Any frame but 9:16, even none named, records in 16:9.
recording.setRecordingMode(true, { safeFrame: null });
await nextTick();
assert.deepEqual(classes(), ['active', 'ratio-16-9']);
recording.setRecordingMode(true, { safeFrame: '4:3' });
await nextTick();
assert.deepEqual(classes(), ['active', 'ratio-16-9']);
// A recording that ends with its controls takes its frame with it.
recording.destroy();
await nextTick();
assert.deepEqual(classes(), []);
});