Refactor EventTile using the MVVM pattern - #2 (#33489)

* Improve coverage

* Add view model unit tests to improve coverage

* Extract initial pure EventTile derived state helpers

* Extract EventTile derived state helpers

* Extract EventTile class state derivation

* Extract EventTile line class derivation

* Extract EventTile sender profile state

* Extract EventTile avatar member selection

* Extract EventTile avatar clickability state

* Extract EventTile sender profile mode

* Extract EventTile action bar visibility

* Extract EventTile timestamp visibility

* Extract EventTile timestamp selection

* Extract EventTile timestamp display state

* Extract ReplyChain timestamp visibility

* Extract EventTile footer display state

* Fix sonar issue
This commit is contained in:
rbondesson
2026-05-18 05:36:13 +00:00
committed by GitHub
parent 1922266ba7
commit 7fe8cdafe0
7 changed files with 1011 additions and 153 deletions
@@ -65,6 +65,18 @@ describe("AudioPlayerViewModel", () => {
expect(playback.skipTo).toHaveBeenCalledWith(10 + 5); // 5 seconds forward
});
it("does not stop propagation for unhandled key down events", () => {
const vm = new AudioPlayerViewModel({ playback, mediaName: "mediaName" });
const event = new KeyboardEvent("keydown", { key: "a" });
const stopPropagationSpy = jest.spyOn(event, "stopPropagation");
vm.onKeyDown(event as unknown as ReactKeyboardEvent<HTMLDivElement>);
expect(stopPropagationSpy).not.toHaveBeenCalled();
expect(playback.toggle).not.toHaveBeenCalled();
expect(playback.skipTo).not.toHaveBeenCalled();
});
it("should update snapshot when setProps is called with new mediaName", () => {
const vm = new AudioPlayerViewModel({ playback, mediaName: "oldName" });
expect(vm.getSnapshot().mediaName).toBe("oldName");