@@ -71,6 +71,7 @@ import ErrorDialog from "../../../../src/components/views/dialogs/ErrorDialog.ts
7171import * as pinnedEventHooks from "../../../../src/hooks/usePinnedEvents" ;
7272import { TimelineRenderingType } from "../../../../src/contexts/RoomContext" ;
7373import { ModuleApi } from "../../../../src/modules/Api" ;
74+ import { ComposerInsertPayload , ComposerType } from "../../../../src/dispatcher/payloads/ComposerInsertPayload.ts" ;
7475
7576// Used by group calls
7677jest . spyOn ( MediaDeviceHandler , "getDevices" ) . mockResolvedValue ( {
@@ -1075,6 +1076,54 @@ describe("RoomView", () => {
10751076 expect ( onRoomViewUpdateMock ) . toHaveBeenCalledWith ( true ) ;
10761077 } ) ;
10771078
1079+ describe ( "handles Action.ComposerInsert" , ( ) => {
1080+ it ( "redispatches an empty composerType, timelineRenderingType with the current state" , async ( ) => {
1081+ jest . spyOn ( defaultDispatcher , "dispatch" ) ;
1082+ await mountRoomView ( ) ;
1083+ const promise = untilDispatch ( ( payload ) => {
1084+ try {
1085+ expect ( payload ) . toEqual ( {
1086+ action : Action . ComposerInsert ,
1087+ text : "Hello world" ,
1088+ timelineRenderingType : TimelineRenderingType . Room ,
1089+ composerType : ComposerType . Send ,
1090+ } ) ;
1091+ } catch {
1092+ return false ;
1093+ }
1094+ return true ;
1095+ } , defaultDispatcher ) ;
1096+ defaultDispatcher . dispatch ( {
1097+ action : Action . ComposerInsert ,
1098+ text : "Hello world" ,
1099+ } satisfies ComposerInsertPayload ) ;
1100+ await promise ;
1101+ } ) ;
1102+ it ( "redispatches an empty composerType with the current state" , async ( ) => {
1103+ jest . spyOn ( defaultDispatcher , "dispatch" ) ;
1104+ await mountRoomView ( ) ;
1105+ const promise = untilDispatch ( ( payload ) => {
1106+ try {
1107+ expect ( payload ) . toEqual ( {
1108+ action : Action . ComposerInsert ,
1109+ text : "Hello world" ,
1110+ timelineRenderingType : TimelineRenderingType . Room ,
1111+ composerType : ComposerType . Send ,
1112+ } ) ;
1113+ } catch {
1114+ return false ;
1115+ }
1116+ return true ;
1117+ } , defaultDispatcher ) ;
1118+ defaultDispatcher . dispatch ( {
1119+ action : Action . ComposerInsert ,
1120+ text : "Hello world" ,
1121+ timelineRenderingType : TimelineRenderingType . Room ,
1122+ } satisfies ComposerInsertPayload ) ;
1123+ await promise ;
1124+ } ) ;
1125+ } ) ;
1126+
10781127 describe ( "when there is a RoomView" , ( ) => {
10791128 const widget1Id = "widget1" ;
10801129 const widget2Id = "widget2" ;
0 commit comments