Skip to content

Commit

Permalink
Fix MSC3890 tests using wrong CSAPI helper (#670)
Browse files Browse the repository at this point in the history
* Fix MSC3890 tests using wrong CSAPI helper

Regressed in #665.

* Signposts in MSC3890 tests
  • Loading branch information
David Robertson authored Oct 12, 2023
1 parent 73ee61e commit b2863ec
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions tests/msc3890/msc3890_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,10 @@ func TestDeletingDeviceRemovesDeviceLocalNotificationSettings(t *testing.T) {
deployment := Deploy(t, b.BlueprintCleanHS)
defer deployment.Destroy(t)

// Create a user which we can log in to multiple times
t.Log("Alice registers on device 1 and logs in to device 2.")
aliceLocalpart := "alice"
alicePassword := "hunter2"
aliceDeviceOne := deployment.RegisterUser(t, "hs1", aliceLocalpart, alicePassword, false)

// Log in to another device on this user
aliceDeviceTwo := deployment.LoginUser(t, "hs1", aliceLocalpart, alicePassword)

accountDataType := "org.matrix.msc3890.local_notification_settings." + aliceDeviceTwo.DeviceID
Expand All @@ -38,7 +36,7 @@ func TestDeletingDeviceRemovesDeviceLocalNotificationSettings(t *testing.T) {
client.SyncReq{},
)

// Using the first device, create some local notification settings in the user's account data for the second device.
t.Log("Using her first device, Alice creates some local notification settings in her account data for the second device.")
aliceDeviceOne.MustSetGlobalAccountData(
t, accountDataType, accountDataContent,
)
Expand All @@ -51,28 +49,28 @@ func TestDeletingDeviceRemovesDeviceLocalNotificationSettings(t *testing.T) {
return match.JSONKeyEqual("content", accountDataContent)(r) == nil
}

// Check that the content of the user account data for this type has been set successfully
t.Log("Alice syncs on device 1 until she sees the account data she just wrote.")
aliceDeviceOne.MustSyncUntil(
t,
client.SyncReq{
Since: nextBatchToken,
},
client.SyncGlobalAccountDataHas(checkAccountDataContent),
)
// Also check via the dedicated account data endpoint to ensure the similar check later is not 404'ing for some other reason.
// Using `MustDo` ensures that the response code is 2xx.

t.Log("Alice also checks for the account data she wrote on the dedicated account data endpoint.")
res := aliceDeviceOne.MustGetGlobalAccountData(t, accountDataType)
must.MatchResponse(t, res, match.HTTPResponse{
JSON: []match.JSON{
match.JSONKeyEqual("is_silenced", true),
},
})

// Log out the second device
t.Log("Alice logs out her second device.")
aliceDeviceTwo.MustDo(t, "POST", []string{"_matrix", "client", "v3", "logout"})

// Using the first device, check that the local notification setting account data for the deleted device was removed.
res = aliceDeviceOne.MustGetGlobalAccountData(t, accountDataType)
t.Log("Alice re-fetches the global account data. The response should now have status 404.")
res = aliceDeviceOne.GetGlobalAccountData(t, accountDataType)
must.MatchResponse(t, res, match.HTTPResponse{
StatusCode: 404,
JSON: []match.JSON{
Expand Down

0 comments on commit b2863ec

Please sign in to comment.