@@ -781,8 +781,9 @@ describe("MatrixClient", function () {
781781 const roomId = "!room:example.org" ;
782782 const body = "This is the body" ;
783783 const content = { body, msgtype : MsgType . Text } satisfies RoomMessageEventContent ;
784- const timeoutDelayOpts = { delay : 2000 } ;
785- const realTimeoutDelayOpts = { "org.matrix.msc4140.delay" : 2000 } ;
784+ const delayOpts = { delay : 2000 } ;
785+ const realDelayOpts = { "org.matrix.msc4140.delay" : 2000 } ;
786+ const delayData = { delay_id : "did" } ;
786787
787788 beforeEach ( ( ) => {
788789 unstableFeatures [ "org.matrix.msc4140" ] = true ;
@@ -795,7 +796,7 @@ describe("MatrixClient", function () {
795796 await expect (
796797 client . _unstable_sendDelayedEvent (
797798 roomId ,
798- timeoutDelayOpts ,
799+ delayOpts ,
799800 null ,
800801 EventType . RoomMessage ,
801802 { ...content } ,
@@ -804,7 +805,7 @@ describe("MatrixClient", function () {
804805 ) . rejects . toThrow ( errorMessage ) ;
805806
806807 await expect (
807- client . _unstable_sendDelayedStateEvent ( roomId , timeoutDelayOpts , EventType . RoomTopic , {
808+ client . _unstable_sendDelayedStateEvent ( roomId , delayOpts , EventType . RoomTopic , {
808809 topic : "topic" ,
809810 } ) ,
810811 ) . rejects . toThrow ( errorMessage ) ;
@@ -822,48 +823,29 @@ describe("MatrixClient", function () {
822823
823824 // eslint-disable-next-line @vitest/expect-expect
824825 it ( "works with null threadId" , async ( ) => {
825- httpLookups = [ ] ;
826-
827- const timeoutDelayTxnId = client . makeTxnId ( ) ;
828- httpLookups . push ( {
829- method : "PUT" ,
830- path : `/rooms/${ encodeURIComponent ( roomId ) } /send/m.room.message/${ timeoutDelayTxnId } ` ,
831- expectQueryParams : realTimeoutDelayOpts ,
832- data : { delay_id : "id1" } ,
833- expectBody : content ,
834- } ) ;
835-
836- const { delay_id : timeoutDelayId } = await client . _unstable_sendDelayedEvent (
837- roomId ,
838- timeoutDelayOpts ,
839- null ,
840- EventType . RoomMessage ,
841- { ...content } ,
842- timeoutDelayTxnId ,
843- ) ;
844-
845- const actionDelayTxnId = client . makeTxnId ( ) ;
846- httpLookups . push ( {
847- method : "PUT" ,
848- path : `/rooms/${ encodeURIComponent ( roomId ) } /send/m.room.message/${ actionDelayTxnId } ` ,
849- expectQueryParams : { "org.matrix.msc4140.parent_delay_id" : timeoutDelayId } ,
850- data : { delay_id : "id2" } ,
851- expectBody : content ,
852- } ) ;
826+ const txnId = client . makeTxnId ( ) ;
827+ httpLookups = [
828+ {
829+ method : "PUT" ,
830+ path : `/rooms/${ encodeURIComponent ( roomId ) } /send/m.room.message/${ txnId } ` ,
831+ data : delayData ,
832+ expectQueryParams : realDelayOpts ,
833+ expectBody : content ,
834+ } ,
835+ ] ;
853836
854837 await client . _unstable_sendDelayedEvent (
855838 roomId ,
856- { parent_delay_id : timeoutDelayId } ,
839+ delayOpts ,
857840 null ,
858841 EventType . RoomMessage ,
859842 { ...content } ,
860- actionDelayTxnId ,
843+ txnId ,
861844 ) ;
862845 } ) ;
863846
864847 // eslint-disable-next-line @vitest/expect-expect
865848 it ( "works with non-null threadId" , async ( ) => {
866- httpLookups = [ ] ;
867849 const threadId = "$threadId:server" ;
868850 const expectBody = {
869851 ...content ,
@@ -874,46 +856,29 @@ describe("MatrixClient", function () {
874856 } ,
875857 } ;
876858
877- const timeoutDelayTxnId = client . makeTxnId ( ) ;
878- httpLookups . push ( {
879- method : "PUT" ,
880- path : `/rooms/${ encodeURIComponent ( roomId ) } /send/m.room.message/${ timeoutDelayTxnId } ` ,
881- expectQueryParams : realTimeoutDelayOpts ,
882- data : { delay_id : "id1" } ,
883- expectBody,
884- } ) ;
885-
886- const { delay_id : timeoutDelayId } = await client . _unstable_sendDelayedEvent (
887- roomId ,
888- timeoutDelayOpts ,
889- threadId ,
890- EventType . RoomMessage ,
891- { ...content } ,
892- timeoutDelayTxnId ,
893- ) ;
894-
895- const actionDelayTxnId = client . makeTxnId ( ) ;
896- httpLookups . push ( {
897- method : "PUT" ,
898- path : `/rooms/${ encodeURIComponent ( roomId ) } /send/m.room.message/${ actionDelayTxnId } ` ,
899- expectQueryParams : { "org.matrix.msc4140.parent_delay_id" : timeoutDelayId } ,
900- data : { delay_id : "id2" } ,
901- expectBody,
902- } ) ;
859+ const txnId = client . makeTxnId ( ) ;
860+ httpLookups = [
861+ {
862+ method : "PUT" ,
863+ path : `/rooms/${ encodeURIComponent ( roomId ) } /send/m.room.message/${ txnId } ` ,
864+ data : delayData ,
865+ expectQueryParams : realDelayOpts ,
866+ expectBody,
867+ } ,
868+ ] ;
903869
904870 await client . _unstable_sendDelayedEvent (
905871 roomId ,
906- { parent_delay_id : timeoutDelayId } ,
872+ delayOpts ,
907873 threadId ,
908874 EventType . RoomMessage ,
909875 { ...content } ,
910- actionDelayTxnId ,
876+ txnId ,
911877 ) ;
912878 } ) ;
913879
914880 // eslint-disable-next-line @vitest/expect-expect
915881 it ( "should add thread relation if threadId is passed and the relation is missing" , async ( ) => {
916- httpLookups = [ ] ;
917882 const threadId = "$threadId:server" ;
918883 const expectBody = {
919884 ...content ,
@@ -934,39 +899,23 @@ describe("MatrixClient", function () {
934899 room . createThread ( threadId , rootEvent , [ rootEvent ] , false ) ;
935900
936901 const timeoutDelayTxnId = client . makeTxnId ( ) ;
937- httpLookups . push ( {
938- method : "PUT" ,
939- path : `/rooms/${ encodeURIComponent ( roomId ) } /send/m.room.message/${ timeoutDelayTxnId } ` ,
940- expectQueryParams : realTimeoutDelayOpts ,
941- data : { delay_id : "id1" } ,
942- expectBody,
943- } ) ;
944-
945- const { delay_id : timeoutDelayId } = await client . _unstable_sendDelayedEvent (
946- roomId ,
947- timeoutDelayOpts ,
948- threadId ,
949- EventType . RoomMessage ,
950- { ...content } ,
951- timeoutDelayTxnId ,
952- ) ;
953-
954- const actionDelayTxnId = client . makeTxnId ( ) ;
955- httpLookups . push ( {
956- method : "PUT" ,
957- path : `/rooms/${ encodeURIComponent ( roomId ) } /send/m.room.message/${ actionDelayTxnId } ` ,
958- expectQueryParams : { "org.matrix.msc4140.parent_delay_id" : timeoutDelayId } ,
959- data : { delay_id : "id2" } ,
960- expectBody,
961- } ) ;
902+ httpLookups = [
903+ {
904+ method : "PUT" ,
905+ path : `/rooms/${ encodeURIComponent ( roomId ) } /send/m.room.message/${ timeoutDelayTxnId } ` ,
906+ data : delayData ,
907+ expectQueryParams : realDelayOpts ,
908+ expectBody,
909+ } ,
910+ ] ;
962911
963912 await client . _unstable_sendDelayedEvent (
964913 roomId ,
965- { parent_delay_id : timeoutDelayId } ,
914+ delayOpts ,
966915 threadId ,
967916 EventType . RoomMessage ,
968917 { ...content } ,
969- actionDelayTxnId ,
918+ timeoutDelayTxnId ,
970919 ) ;
971920 } ) ;
972921
@@ -1003,39 +952,23 @@ describe("MatrixClient", function () {
1003952 room . createThread ( threadId , rootEvent , [ rootEvent ] , false ) ;
1004953
1005954 const timeoutDelayTxnId = client . makeTxnId ( ) ;
1006- httpLookups . push ( {
1007- method : "PUT" ,
1008- path : `/rooms/${ encodeURIComponent ( roomId ) } /send/m.room.message/${ timeoutDelayTxnId } ` ,
1009- expectQueryParams : realTimeoutDelayOpts ,
1010- data : { delay_id : "id1" } ,
1011- expectBody,
1012- } ) ;
1013-
1014- const { delay_id : timeoutDelayId } = await client . _unstable_sendDelayedEvent (
1015- roomId ,
1016- timeoutDelayOpts ,
1017- threadId ,
1018- EventType . RoomMessage ,
1019- { ...content } ,
1020- timeoutDelayTxnId ,
1021- ) ;
1022-
1023- const actionDelayTxnId = client . makeTxnId ( ) ;
1024- httpLookups . push ( {
1025- method : "PUT" ,
1026- path : `/rooms/${ encodeURIComponent ( roomId ) } /send/m.room.message/${ actionDelayTxnId } ` ,
1027- expectQueryParams : { "org.matrix.msc4140.parent_delay_id" : timeoutDelayId } ,
1028- data : { delay_id : "id2" } ,
1029- expectBody,
1030- } ) ;
955+ httpLookups = [
956+ {
957+ method : "PUT" ,
958+ path : `/rooms/${ encodeURIComponent ( roomId ) } /send/m.room.message/${ timeoutDelayTxnId } ` ,
959+ data : delayData ,
960+ expectQueryParams : realDelayOpts ,
961+ expectBody,
962+ } ,
963+ ] ;
1031964
1032965 await client . _unstable_sendDelayedEvent (
1033966 roomId ,
1034- { parent_delay_id : timeoutDelayId } ,
967+ delayOpts ,
1035968 threadId ,
1036969 EventType . RoomMessage ,
1037970 { ...content } ,
1038- actionDelayTxnId ,
971+ timeoutDelayTxnId ,
1039972 ) ;
1040973 } ) ;
1041974
@@ -1044,32 +977,19 @@ describe("MatrixClient", function () {
1044977 httpLookups = [ ] ;
1045978 const content = { topic : "The year 2000" } ;
1046979
1047- httpLookups . push ( {
1048- method : "PUT" ,
1049- path : `/rooms/${ encodeURIComponent ( roomId ) } /state/m.room.topic/` ,
1050- expectQueryParams : realTimeoutDelayOpts ,
1051- data : { delay_id : "id1" } ,
1052- expectBody : content ,
1053- } ) ;
1054-
1055- const { delay_id : timeoutDelayId } = await client . _unstable_sendDelayedStateEvent (
1056- roomId ,
1057- timeoutDelayOpts ,
1058- EventType . RoomTopic ,
1059- { ...content } ,
1060- ) ;
1061-
1062- httpLookups . push ( {
1063- method : "PUT" ,
1064- path : `/rooms/${ encodeURIComponent ( roomId ) } /state/m.room.topic/` ,
1065- expectQueryParams : { "org.matrix.msc4140.parent_delay_id" : timeoutDelayId } ,
1066- data : { delay_id : "id2" } ,
1067- expectBody : content ,
1068- } ) ;
980+ httpLookups = [
981+ {
982+ method : "PUT" ,
983+ path : `/rooms/${ encodeURIComponent ( roomId ) } /state/m.room.topic/` ,
984+ data : delayData ,
985+ expectQueryParams : realDelayOpts ,
986+ expectBody : content ,
987+ } ,
988+ ] ;
1069989
1070990 await client . _unstable_sendDelayedStateEvent (
1071991 roomId ,
1072- { parent_delay_id : timeoutDelayId } ,
992+ delayOpts ,
1073993 EventType . RoomTopic ,
1074994 { ...content } ,
1075995 ) ;
0 commit comments