test(voice): build watch attempt keys from the shared builder (#2693)

This commit is contained in:
Hampus authored and GitHub committed 2026-09-11 19:44:34 +02:00
1 parent 2e3f78b3c6
commit cadca2c18e
2 files changed
+7 -5

No files matched your search

@@ -1,5 +1,6 @@
// SPDX-License-Identifier: AGPL-3.0-or-later // SPDX-License-Identifier: AGPL-3.0-or-later
import {screenShareWatchAttemptKey} from '@app/features/voice/components/useScreenShareWatchFailure';
import { import {
selectVoiceMediaGraphFailure, selectVoiceMediaGraphFailure,
selectVoiceMediaGraphViewerStreamKeys, selectVoiceMediaGraphViewerStreamKeys,
@@ -101,7 +102,7 @@ describe('VoiceMediaGraphTimerScheduler', () => {
store.transition({ store.transition({
type: 'watch.attemptEnsured', type: 'watch.attemptEnsured',
streamKey: STREAM_KEY, streamKey: STREAM_KEY,
attemptKey: `${STREAM_KEY}:1:watch`, attemptKey: screenShareWatchAttemptKey({streamKey: STREAM_KEY, watchGeneration: 1}),
startedAt: store.nowMs(), startedAt: store.nowMs(),
}); });
harness.advance(WATCH_ATTEMPT_TIMEOUT_MS); harness.advance(WATCH_ATTEMPT_TIMEOUT_MS);
@@ -1,5 +1,6 @@
// SPDX-License-Identifier: AGPL-3.0-or-later // SPDX-License-Identifier: AGPL-3.0-or-later
import {screenShareWatchAttemptKey} from '@app/features/voice/components/useScreenShareWatchFailure';
import {voiceMediaGraphStore} from '@app/features/voice/engine/VoiceMediaGraphStore'; import {voiceMediaGraphStore} from '@app/features/voice/engine/VoiceMediaGraphStore';
import {ScreenShareWatchErrorCode, ScreenShareWatchFailures} from '@app/features/voice/state/ScreenShareWatchFailures'; import {ScreenShareWatchErrorCode, ScreenShareWatchFailures} from '@app/features/voice/state/ScreenShareWatchFailures';
import type {RemoteTrackPublication} from 'livekit-client'; import type {RemoteTrackPublication} from 'livekit-client';
@@ -104,7 +105,7 @@ describe('ScreenShareWatchFailures failure history', () => {
it('keeps a failure raised by a watch deadline after the viewer stops watching', () => { it('keeps a failure raised by a watch deadline after the viewer stops watching', () => {
const streamKey = 'guild-a:channel-a:connection-deadline'; const streamKey = 'guild-a:channel-a:connection-deadline';
const attemptKey = `${streamKey}:1:watch`; const attemptKey = screenShareWatchAttemptKey({streamKey, watchGeneration: 1});
ScreenShareWatchFailures.markWatchStarted(streamKey); ScreenShareWatchFailures.markWatchStarted(streamKey);
ScreenShareWatchFailures.ensureAttempt({streamKey}, attemptKey); ScreenShareWatchFailures.ensureAttempt({streamKey}, attemptKey);
ScreenShareWatchFailures.setWatchTarget(streamKey, {videoRef: {current: null}}); ScreenShareWatchFailures.setWatchTarget(streamKey, {videoRef: {current: null}});
@@ -122,7 +123,7 @@ describe('ScreenShareWatchFailures failure history', () => {
it('records the inbound counters of the watched publication alongside the failure', async () => { it('records the inbound counters of the watched publication alongside the failure', async () => {
const streamKey = 'guild-a:channel-a:connection-counters'; const streamKey = 'guild-a:channel-a:connection-counters';
const attemptKey = `${streamKey}:1:watch`; const attemptKey = screenShareWatchAttemptKey({streamKey, watchGeneration: 1});
ScreenShareWatchFailures.markWatchStarted(streamKey); ScreenShareWatchFailures.markWatchStarted(streamKey);
ScreenShareWatchFailures.ensureAttempt({streamKey}, attemptKey); ScreenShareWatchFailures.ensureAttempt({streamKey}, attemptKey);
ScreenShareWatchFailures.setWatchTarget(streamKey, { ScreenShareWatchFailures.setWatchTarget(streamKey, {
@@ -160,7 +161,7 @@ describe('ScreenShareWatchFailures failure history', () => {
it('records the size and readiness of the attached video element', () => { it('records the size and readiness of the attached video element', () => {
const streamKey = 'guild-a:channel-a:connection-tile'; const streamKey = 'guild-a:channel-a:connection-tile';
const attemptKey = `${streamKey}:1:watch`; const attemptKey = screenShareWatchAttemptKey({streamKey, watchGeneration: 1});
const video = {readyState: 0, videoWidth: 0, videoHeight: 0, clientWidth: 960, clientHeight: 540}; const video = {readyState: 0, videoWidth: 0, videoHeight: 0, clientWidth: 960, clientHeight: 540};
ScreenShareWatchFailures.markWatchStarted(streamKey); ScreenShareWatchFailures.markWatchStarted(streamKey);
ScreenShareWatchFailures.ensureAttempt({streamKey}, attemptKey); ScreenShareWatchFailures.ensureAttempt({streamKey}, attemptKey);
@@ -186,7 +187,7 @@ describe('ScreenShareWatchFailures failure history', () => {
it('leaves the running watch deadline alone when the watch target is registered', () => { it('leaves the running watch deadline alone when the watch target is registered', () => {
const streamKey = 'guild-a:channel-a:connection-target'; const streamKey = 'guild-a:channel-a:connection-target';
const attemptKey = `${streamKey}:1:watch`; const attemptKey = screenShareWatchAttemptKey({streamKey, watchGeneration: 1});
ScreenShareWatchFailures.markWatchStarted(streamKey); ScreenShareWatchFailures.markWatchStarted(streamKey);
ScreenShareWatchFailures.ensureAttempt({streamKey}, attemptKey); ScreenShareWatchFailures.ensureAttempt({streamKey}, attemptKey);
const deadline = watchDeadlineFor(streamKey); const deadline = watchDeadlineFor(streamKey);