Files
DndGamePlayer/app/renderer/shared/videoSceneMapParity.test.ts
Ivan Fontosh 7362a36fe5 feat(scene): rotate video previews like images
Reuse previewRotationDeg for video scenes across editor, control,
presentation and overlays via ContainedVideo layout parity.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-11 12:17:57 +08:00

64 lines
2.8 KiB
TypeScript

import assert from 'node:assert/strict';
import fs from 'node:fs';
import path from 'node:path';
import test from 'node:test';
import { fileURLToPath } from 'node:url';
const here = path.dirname(fileURLToPath(import.meta.url));
const rendererRoot = path.resolve(here, '..');
void test('video scenes share map overlays / effects with image scenes', () => {
const control = fs.readFileSync(path.join(rendererRoot, 'control/ControlApp.tsx'), 'utf8');
const presentation = fs.readFileSync(path.join(rendererRoot, 'shared/PresentationView.tsx'), 'utf8');
const sceneEditor = fs.readFileSync(path.join(rendererRoot, 'sceneEditor/SceneEditorApp.tsx'), 'utf8');
const editor = fs.readFileSync(path.join(rendererRoot, 'editor/EditorApp.tsx'), 'utf8');
const main = fs.readFileSync(path.join(rendererRoot, '../main/index.ts'), 'utf8');
assert.equal(control.includes('isVideoPreviewScene'), false);
assert.ok(fs.readFileSync(path.join(rendererRoot, 'control/ControlScenePreview.tsx'), 'utf8').includes('ContainedVideo'));
assert.ok(presentation.includes('ContainedVideo'));
assert.ok(presentation.includes("previewAssetType === 'video'"));
assert.ok(presentation.includes('SceneTrapsOverlay'));
assert.ok(presentation.includes('PixiEffectsOverlay'));
assert.ok(presentation.includes('SceneDarknessOverlay'));
assert.ok(sceneEditor.includes('ContainedVideo'));
assert.ok(sceneEditor.includes('hasMapMedia'));
assert.ok(sceneEditor.includes('Нужно изображение или видео сцены'));
assert.ok(editor.includes("previewAssetType === 'image' || previewAssetType === 'video'"));
assert.ok(editor.includes('windows.openSceneEditor'));
assert.ok(editor.includes('ContainedVideo'));
assert.ok(editor.includes('onRotatePreview'));
assert.match(
editor,
/previewAssetId && \(previewAssetType === 'image' \|\| previewAssetType === 'video'\) \? \([\s\S]*?onRotatePreview/,
);
assert.ok(fs.readFileSync(path.join(rendererRoot, 'shared/ContainedVideo.tsx'), 'utf8').includes('rotationDeg'));
assert.ok(
fs
.readFileSync(path.join(rendererRoot, 'control/ControlScenePreview.tsx'), 'utf8')
.includes('rotationDeg={rot}'),
);
assert.ok(presentation.includes('rotationDeg={rot}'));
assert.ok(sceneEditor.includes('rotationDeg={rot}'));
assert.ok(main.includes("scene?.previewAssetType === 'video'"));
assert.ok(main.includes('syncSceneDarknessForProject'));
assert.match(
main,
/darkenScene[\s\S]{0,120}previewAssetType === 'image'[\s\S]{0,80}previewAssetType === 'video'/,
);
});
void test('control traps: GM-hidden markers stay relatively bright', () => {
const css = fs.readFileSync(
path.join(rendererRoot, 'shared/traps/SceneTrapsOverlay.module.css'),
'utf8',
);
assert.ok(css.includes('.trapGmHidden'));
assert.doesNotMatch(css, /\.trapGmHidden\s*\{[^}]*opacity:\s*0\.[0-6]/);
});