mirror of
https://github.com/OFFIS-ESC/constellation-analyzer
synced 2026-01-27 07:43:41 +00:00
Update tests for new activeStateTangibles tracking
Changes: - Replace lastStateChangeSource with activeStateTangibles in tests - Update tuioStore.test.ts to test array-based tracking - Add tests for adding/removing multiple state tangibles - Add test for duplicate prevention - Update TUIO integration tests to use new API - Pass fromTangible=true parameter to switchToState in tests All 447 tests now passing. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
68ca121b19
commit
010d8a558c
2 changed files with 43 additions and 28 deletions
|
|
@ -308,14 +308,14 @@ describe('TUIO Integration', () => {
|
||||||
const config = useGraphStore.getState().tangibles.find((t) => t.hardwareId === '99');
|
const config = useGraphStore.getState().tangibles.find((t) => t.hardwareId === '99');
|
||||||
|
|
||||||
if (config?.stateId) {
|
if (config?.stateId) {
|
||||||
useTimelineStore.getState().switchToState(config.stateId);
|
useTuioStore.getState().addActiveStateTangible('99');
|
||||||
useTuioStore.getState().setLastStateChangeSource('99');
|
useTimelineStore.getState().switchToState(config.stateId, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verify state was switched
|
// Verify state was switched
|
||||||
const currentStateId = useTimelineStore.getState().timelines.get(docId)?.currentStateId;
|
const currentStateId = useTimelineStore.getState().timelines.get(docId)?.currentStateId;
|
||||||
expect(currentStateId).toBe(stateId);
|
expect(currentStateId).toBe(stateId);
|
||||||
expect(useTuioStore.getState().lastStateChangeSource).toBe('99');
|
expect(useTuioStore.getState().activeStateTangibles).toContain('99');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not revert state when state tangible is removed', () => {
|
it('should not revert state when state tangible is removed', () => {
|
||||||
|
|
@ -333,11 +333,12 @@ describe('TUIO Integration', () => {
|
||||||
} as TangibleConfig);
|
} as TangibleConfig);
|
||||||
|
|
||||||
// Switch to new state
|
// Switch to new state
|
||||||
useTimelineStore.getState().switchToState(newStateId);
|
useTuioStore.getState().addActiveStateTangible('100');
|
||||||
useTuioStore.getState().setLastStateChangeSource('100');
|
useTimelineStore.getState().switchToState(newStateId, true);
|
||||||
|
|
||||||
// Remove tangible
|
// Remove tangible
|
||||||
useTuioStore.getState().removeActiveTangible('100');
|
useTuioStore.getState().removeActiveTangible('100');
|
||||||
|
useTuioStore.getState().removeActiveStateTangible('100');
|
||||||
|
|
||||||
// State should NOT revert
|
// State should NOT revert
|
||||||
const currentStateId = useTimelineStore.getState().timelines.get(docId)?.currentStateId;
|
const currentStateId = useTimelineStore.getState().timelines.get(docId)?.currentStateId;
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ describe('tuioStore', () => {
|
||||||
isConnected: false,
|
isConnected: false,
|
||||||
connectionError: null,
|
connectionError: null,
|
||||||
activeTangibles: new Map(),
|
activeTangibles: new Map(),
|
||||||
lastStateChangeSource: null,
|
activeStateTangibles: [],
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -25,7 +25,7 @@ describe('tuioStore', () => {
|
||||||
expect(state.isConnected).toBe(false);
|
expect(state.isConnected).toBe(false);
|
||||||
expect(state.connectionError).toBe(null);
|
expect(state.connectionError).toBe(null);
|
||||||
expect(state.activeTangibles.size).toBe(0);
|
expect(state.activeTangibles.size).toBe(0);
|
||||||
expect(state.lastStateChangeSource).toBe(null);
|
expect(state.activeStateTangibles).toEqual([]);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -365,15 +365,15 @@ describe('tuioStore', () => {
|
||||||
expect(state.activeTangibles.size).toBe(0);
|
expect(state.activeTangibles.size).toBe(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should reset lastStateChangeSource', () => {
|
it('should reset activeStateTangibles', () => {
|
||||||
const { setLastStateChangeSource, clearActiveTangibles } = useTuioStore.getState();
|
const { addActiveStateTangible, clearActiveTangibles } = useTuioStore.getState();
|
||||||
|
|
||||||
setLastStateChangeSource('42');
|
addActiveStateTangible('42');
|
||||||
expect(useTuioStore.getState().lastStateChangeSource).toBe('42');
|
expect(useTuioStore.getState().activeStateTangibles).toEqual(['42']);
|
||||||
|
|
||||||
clearActiveTangibles();
|
clearActiveTangibles();
|
||||||
|
|
||||||
expect(useTuioStore.getState().lastStateChangeSource).toBe(null);
|
expect(useTuioStore.getState().activeStateTangibles).toEqual([]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should handle clearing empty tangibles map', () => {
|
it('should handle clearing empty tangibles map', () => {
|
||||||
|
|
@ -386,32 +386,46 @@ describe('tuioStore', () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('setLastStateChangeSource', () => {
|
describe('activeStateTangibles', () => {
|
||||||
it('should set last state change source', () => {
|
it('should add active state tangible', () => {
|
||||||
const { setLastStateChangeSource } = useTuioStore.getState();
|
const { addActiveStateTangible } = useTuioStore.getState();
|
||||||
|
|
||||||
setLastStateChangeSource('42');
|
addActiveStateTangible('42');
|
||||||
|
|
||||||
expect(useTuioStore.getState().lastStateChangeSource).toBe('42');
|
expect(useTuioStore.getState().activeStateTangibles).toEqual(['42']);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should clear last state change source', () => {
|
it('should remove active state tangible', () => {
|
||||||
const { setLastStateChangeSource } = useTuioStore.getState();
|
const { addActiveStateTangible, removeActiveStateTangible } = useTuioStore.getState();
|
||||||
|
|
||||||
setLastStateChangeSource('42');
|
addActiveStateTangible('42');
|
||||||
setLastStateChangeSource(null);
|
addActiveStateTangible('13');
|
||||||
|
expect(useTuioStore.getState().activeStateTangibles).toEqual(['42', '13']);
|
||||||
|
|
||||||
expect(useTuioStore.getState().lastStateChangeSource).toBe(null);
|
removeActiveStateTangible('42');
|
||||||
|
expect(useTuioStore.getState().activeStateTangibles).toEqual(['13']);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should update last state change source', () => {
|
it('should track multiple state tangibles in order', () => {
|
||||||
const { setLastStateChangeSource } = useTuioStore.getState();
|
const { addActiveStateTangible } = useTuioStore.getState();
|
||||||
|
|
||||||
setLastStateChangeSource('42');
|
addActiveStateTangible('42');
|
||||||
expect(useTuioStore.getState().lastStateChangeSource).toBe('42');
|
expect(useTuioStore.getState().activeStateTangibles).toEqual(['42']);
|
||||||
|
|
||||||
setLastStateChangeSource('13');
|
addActiveStateTangible('13');
|
||||||
expect(useTuioStore.getState().lastStateChangeSource).toBe('13');
|
expect(useTuioStore.getState().activeStateTangibles).toEqual(['42', '13']);
|
||||||
|
|
||||||
|
addActiveStateTangible('99');
|
||||||
|
expect(useTuioStore.getState().activeStateTangibles).toEqual(['42', '13', '99']);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should not add duplicate tangibles', () => {
|
||||||
|
const { addActiveStateTangible } = useTuioStore.getState();
|
||||||
|
|
||||||
|
addActiveStateTangible('42');
|
||||||
|
addActiveStateTangible('42');
|
||||||
|
|
||||||
|
expect(useTuioStore.getState().activeStateTangibles).toEqual(['42']);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue