Skip to content

Commit

Permalink
Add tests for MSC4102 (#709)
Browse files Browse the repository at this point in the history
* Add failing test for matrix-org/matrix-spec#1727

* Logs are fun

* Update with semantics of MSC4102

* Also test over federation
  • Loading branch information
kegsay authored Feb 20, 2024
1 parent 503bf6e commit 0f482b4
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions tests/csapi/thread_notifications_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -301,3 +301,54 @@ func TestThreadedReceipts(t *testing.T) {
}),
)
}

// Regression test for https://github.com/matrix-org/matrix-spec/issues/1727
// Servers should always prefer the unthreaded receipt when there is a clash of receipts
func TestThreadReceiptsInSyncMSC4102(t *testing.T) {
runtime.SkipIf(t, runtime.Dendrite) // not supported
deployment := complement.Deploy(t, 2)
defer deployment.Destroy(t)

// Create a room with alice and bob.
alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{})
bob := deployment.Register(t, "hs2", helpers.RegistrationOpts{})
roomID := alice.MustCreateRoom(t, map[string]interface{}{"preset": "public_chat"})
bob.MustJoinRoom(t, roomID, []string{"hs1"})
eventA := alice.SendEventSynced(t, roomID, b.Event{
Type: "m.room.message",
Content: map[string]interface{}{
"msgtype": "m.text",
"body": "Hello world!",
},
})
eventB := alice.SendEventSynced(t, roomID, b.Event{
Type: "m.room.message",
Content: map[string]interface{}{
"msgtype": "m.text",
"body": "Start thread!",
"m.relates_to": map[string]interface{}{
"event_id": eventA,
"rel_type": "m.thread",
},
},
})
// now send an unthreaded RR for event B and a threaded RR for event B and ensure we see the unthreaded RR
// down /sync. Non-compliant servers will typically send the last one only.
alice.MustDo(t, "POST", []string{"_matrix", "client", "v3", "rooms", roomID, "receipt", "m.read", eventB}, client.WithJSONBody(t, struct{}{}))
alice.MustDo(t, "POST", []string{"_matrix", "client", "v3", "rooms", roomID, "receipt", "m.read", eventB}, client.WithJSONBody(t, map[string]interface{}{"thread_id": eventA}))

alice.MustSyncUntil(
t,
client.SyncReq{},
syncHasUnthreadedReadReceipt(roomID, alice.UserID, eventB),
)

// bob over federation must also see the same result, to show that the receipt EDUs over
// federation are bundled correctly, or are sent as separate EDUs.
bob.MustSyncUntil(
t,
client.SyncReq{},
syncHasUnthreadedReadReceipt(roomID, alice.UserID, eventB),
)

}

0 comments on commit 0f482b4

Please sign in to comment.