Skip to content

Commit 109ba45

Browse files
committed
Disable MSC4306 push rules in non-MSC4306 test
1 parent 4d86f15 commit 109ba45

2 files changed

Lines changed: 27 additions & 0 deletions

File tree

client/client.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,14 @@ func (c *CSAPI) SetPushRule(t ct.TestLike, scope string, kind string, ruleID str
319319
return c.MustDo(t, "PUT", []string{"_matrix", "client", "v3", "pushrules", scope, kind, ruleID}, WithJSONBody(t, body), WithQueries(queryParams))
320320
}
321321

322+
// MustDisablePushRule disables a push rule on the user.
323+
// Fails the test if response is non-2xx.
324+
func (c *CSAPI) MustDisablePushRule(t ct.TestLike, scope string, kind string, ruleID string) {
325+
c.MustDo(t, "PUT", []string{"_matrix", "client", "v3", "pushrules", scope, kind, ruleID, "enabled"}, WithJSONBody(t, map[string]interface{}{
326+
"enabled": false,
327+
}))
328+
}
329+
322330
// Unsafe_SendEventUnsynced sends `e` into the room. This function is UNSAFE as it does not wait
323331
// for the event to be fully processed. This can cause flakey tests. Prefer `SendEventSynced`.
324332
// Returns the event ID of the sent event.

tests/csapi/thread_notifications_test.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,21 @@ func syncHasThreadedReadReceipt(roomID, userID, eventID, threadID string) client
5151
})
5252
}
5353

54+
// Disables push rules that are introduced in MSC4306 (if present),
55+
// because they interfere with the normal semantics of notifications in threads.
56+
func disableMsc4306PushRules(t *testing.T, user *client.CSAPI) {
57+
rules := []string{".io.element.msc4306.rule.subscribed_thread", ".io.element.msc4306.rule.unsubscribed_thread"}
58+
for _, rule := range rules {
59+
res := user.GetPushRule(t, "global", "postcontent", rule)
60+
if res.StatusCode == 404 {
61+
// No push rule to disable
62+
continue
63+
}
64+
65+
user.MustDisablePushRule(t, "global", "postcontent", rule)
66+
}
67+
}
68+
5469
// Test behavior of threaded receipts and notifications.
5570
//
5671
// 1. Send a series of messages, some of which are in threads.
@@ -79,7 +94,9 @@ func TestThreadedReceipts(t *testing.T) {
7994

8095
// Create a room with alice and bob.
8196
alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{})
97+
disableMsc4306PushRules(t, alice)
8298
bob := deployment.Register(t, "hs1", helpers.RegistrationOpts{})
99+
disableMsc4306PushRules(t, bob)
83100

84101
roomID := alice.MustCreateRoom(t, map[string]interface{}{"preset": "public_chat"})
85102
bob.MustJoinRoom(t, roomID, nil)
@@ -312,7 +329,9 @@ func TestThreadReceiptsInSyncMSC4102(t *testing.T) {
312329

313330
// Create a room with alice and bob.
314331
alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{})
332+
disableMsc4306PushRules(t, alice)
315333
bob := deployment.Register(t, "hs2", helpers.RegistrationOpts{})
334+
disableMsc4306PushRules(t, bob)
316335
roomID := alice.MustCreateRoom(t, map[string]interface{}{"preset": "public_chat"})
317336
bob.MustJoinRoom(t, roomID, []spec.ServerName{
318337
deployment.GetFullyQualifiedHomeserverName(t, "hs1"),

0 commit comments

Comments
 (0)