mv element.io @types __mocks__/ debian docker module_system/ playwright res src test webapp Dockerfile .dockerignore .eslintignore .stylelintrc.cjs babel.config.cjs recorder-worklet-loader.cjs .modernizr.json components.json config.json config.sample.json package.json project.json tsconfig.json tsconfig.module_system.json jest.config.ts playwright.config.ts webpack.config.ts build_config.sample.yaml apps/web/

mkdir apps/web/scripts
mv scripts/{cleanup.sh,ci_package.sh,copy-res.ts,deploy.py,package.sh} apps/web/scripts

And a couple of gitignore tweaks

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
Michael Telatynski
2026-02-24 15:43:58 +00:00
parent e7509c92a1
commit 91a3cb03c1
3408 changed files with 28 additions and 32 deletions
@@ -0,0 +1,88 @@
/*
Copyright 2025 New Vector Ltd.
SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial
Please see LICENSE files in the repository root for full details.
*/
import { type Mocked } from "jest-mock";
import { type MatrixEvent, type Room } from "matrix-js-sdk/src/matrix";
import { PlaybackQueue } from "../../../src/audio/PlaybackQueue";
import { type Playback, PlaybackState } from "../../../src/audio/Playback";
import { UPDATE_EVENT } from "../../../src/stores/AsyncStore";
import { MockedPlayback } from "./MockedPlayback";
import { SdkContextClass } from "../../../src/contexts/SDKContext";
describe("PlaybackQueue", () => {
let playbackQueue: PlaybackQueue;
let mockRoom: Mocked<Room>;
beforeEach(() => {
mockRoom = {
getMember: jest.fn(),
} as unknown as Mocked<Room>;
playbackQueue = new PlaybackQueue(mockRoom, SdkContextClass.instance.roomViewStore);
});
it.each([
[PlaybackState.Playing, true],
[PlaybackState.Paused, true],
[PlaybackState.Preparing, false],
[PlaybackState.Decoding, false],
[PlaybackState.Stopped, false],
])("should save (or not) the clock PlayBackState=%s expected=%s", (playbackState, expected) => {
const mockEvent = {
getId: jest.fn().mockReturnValue("$foo:bar"),
} as unknown as Mocked<MatrixEvent>;
const mockPlayback = new MockedPlayback(playbackState, 0, 0) as unknown as Mocked<Playback>;
// Enqueue
playbackQueue.unsortedEnqueue(mockEvent, mockPlayback);
// Emit our clockInfo of 0, which will playbackQueue to save the state.
mockPlayback.clockInfo.liveData.update([1]);
// @ts-ignore
expect(playbackQueue.clockStates.has(mockEvent.getId()!)).toBe(expected);
});
it("does call skipTo on playback if clock advances to 1s", () => {
const mockEvent = {
getId: jest.fn().mockReturnValue("$foo:bar"),
} as unknown as Mocked<MatrixEvent>;
const mockPlayback = new MockedPlayback(PlaybackState.Playing, 0, 0) as unknown as Mocked<Playback>;
// Enqueue
playbackQueue.unsortedEnqueue(mockEvent, mockPlayback);
// Emit our clockInfo of 0, which will playbackQueue to save the state.
mockPlayback.clockInfo.liveData.update([1]);
// Fire an update event to say that we have stopped.
// Note that Playback really emits an UPDATE_EVENT whenever state changes, the types are lies.
mockPlayback.emit(UPDATE_EVENT as any, PlaybackState.Stopped);
expect(mockPlayback.skipTo).toHaveBeenCalledWith(1);
});
it("should ignore the nullish clock state when loading", () => {
const clockStates = new Map([
["a", 1],
["b", null],
["c", 3],
]);
localStorage.setItem(
`mx_voice_message_clocks_${mockRoom.roomId}`,
JSON.stringify(Array.from(clockStates.entries())),
);
playbackQueue = new PlaybackQueue(mockRoom, SdkContextClass.instance.roomViewStore);
// @ts-ignore
expect(playbackQueue.clockStates.has("a")).toBe(true);
// @ts-ignore
expect(playbackQueue.clockStates.has("b")).toBe(false);
// @ts-ignore
expect(playbackQueue.clockStates.has("c")).toBe(true);
});
});