Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix MSC3890 tests using wrong CSAPI helper #670

Merged
merged 2 commits into from
Oct 12, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading