-
Notifications
You must be signed in to change notification settings - Fork 0
fix: include view data in pipeline responses and skip zero-delta commits #159
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
b7f187f
fix: include view data in pipeline responses and skip zero-delta commits
streamkit-devin d22dbd7
style: format compositorDragResize test file
streamkit-devin 6c50fa8
fix: preserve server geometry in Monitor view 'sync from props' effect
streamkit-devin 6684fe5
fix: preserve all server-resolved fields in Monitor view merge
streamkit-devin a44b9c1
test: add integration tests for Monitor view compositor data flow
streamkit-devin 3b7caa3
fix: add hasExtraChanges comparator for image overlay merge in Monito…
streamkit-devin e3cc1a0
test: add integration test for image overlay dataBase64 change in Mon…
streamkit-devin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,134 @@ | ||
| // SPDX-FileCopyrightText: © 2025 StreamKit Contributors | ||
| // | ||
| // SPDX-License-Identifier: MPL-2.0 | ||
|
|
||
| /** | ||
| * Unit tests for the zero-delta click guard in useCompositorDragResize. | ||
| * | ||
| * Verifies that a pointer-up at the exact same position as pointer-down | ||
| * (i.e. a click-to-select with zero movement) does NOT fire the config | ||
| * change callback, preventing stale client positions from overwriting | ||
| * the server's resolved layout. | ||
| */ | ||
|
|
||
| import { renderHook, act } from '@testing-library/react'; | ||
| import { describe, it, expect, vi, beforeEach } from 'vitest'; | ||
| import React from 'react'; | ||
|
|
||
| import type { DragResizeDeps } from './compositorDragResize'; | ||
| import { useCompositorDragResize } from './compositorDragResize'; | ||
| import type { LayerState } from './compositorLayerParsers'; | ||
|
|
||
| /** Build a minimal layer for testing. */ | ||
| function makeLayer(id: string): LayerState { | ||
| return { | ||
| id, | ||
| x: 100, | ||
| y: 100, | ||
| width: 200, | ||
| height: 150, | ||
| opacity: 1, | ||
| zIndex: 0, | ||
| visible: true, | ||
| rotationDegrees: 0, | ||
| mirrorHorizontal: false, | ||
| mirrorVertical: false, | ||
| cropZoom: 1.0, | ||
| cropX: 0.5, | ||
| cropY: 0.5, | ||
| }; | ||
| } | ||
|
|
||
| function makeDeps(overrides: Partial<DragResizeDeps> = {}): DragResizeDeps { | ||
| const layer = makeLayer('layer-1'); | ||
| return { | ||
| canvasWidth: 1280, | ||
| canvasHeight: 720, | ||
| dragStateRef: { current: null }, | ||
| layerRefs: { current: new Map() }, | ||
| layersRef: { current: [layer] }, | ||
| textOverlaysRef: { current: [] }, | ||
| imageOverlaysRef: { current: [] }, | ||
| setLayers: vi.fn(), | ||
| setTextOverlays: vi.fn(), | ||
| setImageOverlays: vi.fn(), | ||
| setSelectedLayerId: vi.fn(), | ||
| setIsDragging: vi.fn(), | ||
| findAnyLayer: (id: string) => { | ||
| if (id === 'layer-1') return { state: layer, kind: 'video' as const }; | ||
| return null; | ||
| }, | ||
| throttledConfigChange: vi.fn(), | ||
| commitOverlaysRef: { current: vi.fn() }, | ||
| snapGuideRefs: { current: { vertical: null, horizontal: null } }, | ||
| ...overrides, | ||
| }; | ||
| } | ||
|
|
||
| describe('useCompositorDragResize zero-delta guard', () => { | ||
| let deps: DragResizeDeps; | ||
|
|
||
| beforeEach(() => { | ||
| deps = makeDeps(); | ||
| }); | ||
|
|
||
| it('should NOT fire throttledConfigChange on zero-delta click (video layer)', () => { | ||
| const { result } = renderHook(() => useCompositorDragResize(deps)); | ||
|
|
||
| // Simulate pointer-down at (500, 300) | ||
| act(() => { | ||
| result.current.handleLayerPointerDown('layer-1', { | ||
| button: 0, | ||
| clientX: 500, | ||
| clientY: 300, | ||
| stopPropagation: vi.fn(), | ||
| preventDefault: vi.fn(), | ||
| } as unknown as React.PointerEvent); | ||
| }); | ||
|
|
||
| // Verify drag state was set | ||
| expect(deps.dragStateRef.current).not.toBeNull(); | ||
|
|
||
| // Simulate pointer-up at the exact same position (zero delta) | ||
| act(() => { | ||
| const pointerUpEvent = new PointerEvent('pointerup', { | ||
| clientX: 500, | ||
| clientY: 300, | ||
| }); | ||
| document.dispatchEvent(pointerUpEvent); | ||
| }); | ||
|
|
||
| // throttledConfigChange must NOT have been called | ||
| expect(deps.throttledConfigChange).not.toHaveBeenCalled(); | ||
|
|
||
| // setLayers must NOT have been called (no state update) | ||
| expect(deps.setLayers).not.toHaveBeenCalled(); | ||
| }); | ||
|
|
||
| it('should fire throttledConfigChange on actual drag (video layer)', () => { | ||
| const { result } = renderHook(() => useCompositorDragResize(deps)); | ||
|
|
||
| // Simulate pointer-down at (500, 300) | ||
| act(() => { | ||
| result.current.handleLayerPointerDown('layer-1', { | ||
| button: 0, | ||
| clientX: 500, | ||
| clientY: 300, | ||
| stopPropagation: vi.fn(), | ||
| preventDefault: vi.fn(), | ||
| } as unknown as React.PointerEvent); | ||
| }); | ||
|
|
||
| // Simulate pointer-up at a DIFFERENT position (non-zero delta) | ||
| act(() => { | ||
| const pointerUpEvent = new PointerEvent('pointerup', { | ||
| clientX: 520, | ||
| clientY: 310, | ||
| }); | ||
| document.dispatchEvent(pointerUpEvent); | ||
| }); | ||
|
|
||
| // throttledConfigChange SHOULD have been called | ||
| expect(deps.throttledConfigChange).toHaveBeenCalled(); | ||
| }); | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.