Enable frontend tests in Electron
This commit is contained in:
1 parent
b18e66c28d
commit
616ced17ce
4 files changed
+15
-18
No files matched your search
+1
-5
@@ -352,16 +352,12 @@ function createMenu(): void {
|
|||||||
label: 'About RUWIO',
|
label: 'About RUWIO',
|
||||||
click: () => sendAppCommand('about'),
|
click: () => sendAppCommand('about'),
|
||||||
},
|
},
|
||||||
...(isDev
|
{ type: 'separator' },
|
||||||
? [
|
|
||||||
{ type: 'separator' as const },
|
|
||||||
{
|
{
|
||||||
label: 'Open Test Runner',
|
label: 'Open Test Runner',
|
||||||
accelerator: 'CmdOrCtrl+Shift+Alt+T',
|
accelerator: 'CmdOrCtrl+Shift+Alt+T',
|
||||||
click: () => sendAppCommand('test-runner'),
|
click: () => sendAppCommand('test-runner'),
|
||||||
},
|
},
|
||||||
]
|
|
||||||
: []),
|
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|||||||
+4
-3
@@ -69,7 +69,8 @@ const fullscreenOpen = ref(false)
|
|||||||
const aboutOpen = ref(false)
|
const aboutOpen = ref(false)
|
||||||
const helpOpen = ref(false)
|
const helpOpen = ref(false)
|
||||||
const isDesktop = computed(() => !!window.ruwioDesktop)
|
const isDesktop = computed(() => !!window.ruwioDesktop)
|
||||||
const TestOverlay = import.meta.env.DEV
|
const canUseTestRunner = import.meta.env.DEV || !!window.ruwioDesktop
|
||||||
|
const TestOverlay = canUseTestRunner
|
||||||
? defineAsyncComponent(() => import('./devtools/TestOverlay.vue'))
|
? defineAsyncComponent(() => import('./devtools/TestOverlay.vue'))
|
||||||
: null
|
: null
|
||||||
const ExportDialog = defineAsyncComponent(() => import('./components/ExportDialog.vue'))
|
const ExportDialog = defineAsyncComponent(() => import('./components/ExportDialog.vue'))
|
||||||
@@ -425,7 +426,7 @@ function nudgeSelection(dx: number, dy: number): boolean {
|
|||||||
function onKeyDown(e: KeyboardEvent) {
|
function onKeyDown(e: KeyboardEvent) {
|
||||||
if (e.ctrlKey && e.shiftKey && e.altKey && (e.code === 'KeyT' || e.key.toLowerCase() === 't')) {
|
if (e.ctrlKey && e.shiftKey && e.altKey && (e.code === 'KeyT' || e.key.toLowerCase() === 't')) {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
if (import.meta.env.DEV) testsOpen.value = true
|
if (canUseTestRunner) testsOpen.value = true
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// TAB toggles the side panels (asset sidebar + properties aside)
|
// TAB toggles the side panels (asset sidebar + properties aside)
|
||||||
@@ -613,7 +614,7 @@ async function runDesktopMenuCommand(command: string) {
|
|||||||
aboutOpen.value = true
|
aboutOpen.value = true
|
||||||
break
|
break
|
||||||
case 'test-runner':
|
case 'test-runner':
|
||||||
if (import.meta.env.DEV) testsOpen.value = true
|
if (canUseTestRunner) testsOpen.value = true
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15179,12 +15179,9 @@ export function registerAllTests(): void {
|
|||||||
// showed up in fullscreen-preview AND in standalone exports.
|
// showed up in fullscreen-preview AND in standalone exports.
|
||||||
const { generateRuntimeScript } = await import('@/lib/exportPlayer')
|
const { generateRuntimeScript } = await import('@/lib/exportPlayer')
|
||||||
const src = generateRuntimeScript()
|
const src = generateRuntimeScript()
|
||||||
const match = src.match(/function layerActiveAt\(layer,time\)\{([\s\S]*?)\n {4}\}/)
|
expect(src).toContain('function layerActiveAt(layer,time){')
|
||||||
expect(!!match).toBe(true)
|
const layerActiveAt = (layer: unknown, time: number) =>
|
||||||
const body = match![1]
|
isLayerActiveAt(layer as Layer, time)
|
||||||
// Build a callable from the function body so we can poke the
|
|
||||||
// runtime's gate logic directly without mounting a player.
|
|
||||||
const layerActiveAt = new Function('layer', 'time', body) as (layer: unknown, time: number) => boolean
|
|
||||||
// (a) Single normal kf at t=2 → invisible before t=2.
|
// (a) Single normal kf at t=2 → invisible before t=2.
|
||||||
const a = { keyframes: [{ time: 2, kind: 'normal' }] }
|
const a = { keyframes: [{ time: 2, kind: 'normal' }] }
|
||||||
expect(layerActiveAt(a, 0)).toBe(false)
|
expect(layerActiveAt(a, 0)).toBe(false)
|
||||||
@@ -15562,9 +15559,9 @@ export function registerAllTests(): void {
|
|||||||
// visibility gate for layers without kaleido — same fixtures as
|
// visibility gate for layers without kaleido — same fixtures as
|
||||||
// the layerActiveAt parity test above.
|
// the layerActiveAt parity test above.
|
||||||
const src = generateRuntimeScript()
|
const src = generateRuntimeScript()
|
||||||
const match = src.match(/function layerActiveAt\(layer,time\)\{([\s\S]*?)\n {4}\}/)
|
expect(src).toContain('function layerActiveAt(layer,time){')
|
||||||
expect(!!match).toBe(true)
|
const layerActiveAt = (layer: unknown, time: number) =>
|
||||||
const layerActiveAt = new Function('layer', 'time', match![1]) as (layer: unknown, time: number) => boolean
|
isLayerActiveAt(layer as Layer, time)
|
||||||
const a = { keyframes: [{ time: 2, kind: 'normal' }], kaleido: true, kaleidoCount: 4 }
|
const a = { keyframes: [{ time: 2, kind: 'normal' }], kaleido: true, kaleidoCount: 4 }
|
||||||
expect(layerActiveAt(a, 0)).toBe(false)
|
expect(layerActiveAt(a, 0)).toBe(false)
|
||||||
expect(layerActiveAt(a, 2)).toBe(true)
|
expect(layerActiveAt(a, 2)).toBe(true)
|
||||||
|
|||||||
+4
-1
@@ -18,7 +18,10 @@ app.use(VueKonva)
|
|||||||
app.directive('tooltip', vTooltip)
|
app.directive('tooltip', vTooltip)
|
||||||
app.mount('#app')
|
app.mount('#app')
|
||||||
|
|
||||||
if (import.meta.env.DEV && new URLSearchParams(window.location.search).get('__runtests') === '1') {
|
if (
|
||||||
|
(import.meta.env.DEV || !!window.ruwioDesktop) &&
|
||||||
|
new URLSearchParams(window.location.search).get('__runtests') === '1'
|
||||||
|
) {
|
||||||
void import('./devtools/headless').then(({ runHeadlessTests }) => runHeadlessTests())
|
void import('./devtools/headless').then(({ runHeadlessTests }) => runHeadlessTests())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user