This repository has been archived by the owner on Sep 11, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 828
Migrate the hidden read receipts flag to new "send read receipts" option #9141
Merged
Merged
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
/* | ||
Copyright 2022 The Matrix.org Foundation C.I.C. | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
/// <reference types="cypress" /> | ||
|
||
import { SynapseInstance } from "../../plugins/synapsedocker"; | ||
|
||
function seedLabs(synapse: SynapseInstance, labsVal: boolean | null) { | ||
turt2live marked this conversation as resolved.
Show resolved
Hide resolved
|
||
cy.initTestUser(synapse, "Sally", () => { | ||
// seed labs flag | ||
cy.window({ log: false }).then(win => { | ||
if (typeof labsVal === "boolean") { | ||
// stringify boolean | ||
win.localStorage.setItem("mx_labs_feature_feature_hidden_read_receipts", `${labsVal}`); | ||
} | ||
}); | ||
}); | ||
} | ||
|
||
function testForVal(settingVal: boolean | null) { | ||
turt2live marked this conversation as resolved.
Show resolved
Hide resolved
|
||
const testRoomName = "READ RECEIPTS"; | ||
cy.createRoom({ name: testRoomName }).as("roomId"); | ||
cy.all([cy.get<string>("@roomId")]).then(() => { | ||
cy.viewRoomByName(testRoomName).then(() => { | ||
// if we can see the room, then sync is working for us. It's time to see if the | ||
// migration even ran. | ||
|
||
cy.getSettingValue("sendReadReceipts", null, true).should("satisfy", (val) => { | ||
if (typeof settingVal === "boolean") { | ||
return val === settingVal; | ||
} else { | ||
return !val; // falsy - we don't actually care if it's undefined, null, or a literal false | ||
} | ||
}); | ||
}); | ||
}); | ||
} | ||
|
||
describe("Hidden Read Receipts Setting Migration", () => { | ||
// We run this as a full-blown end-to-end test to ensure it works in an integration | ||
// sense. If we unit tested it, we'd be testing that the code works but not that the | ||
// migration actually runs. | ||
// | ||
// Here, we get to test that not only the code works but also that it gets run. Most | ||
// of our interactions are with the JS console as we're honestly just checking that | ||
// things got set correctly. | ||
// | ||
// For a security-sensitive feature like hidden read receipts, it's absolutely vital | ||
// that we migrate the setting appropriately. | ||
|
||
let synapse: SynapseInstance; | ||
|
||
beforeEach(() => { | ||
cy.startSynapse("default").then(data => { | ||
synapse = data; | ||
}); | ||
}); | ||
|
||
afterEach(() => { | ||
cy.stopSynapse(synapse); | ||
}); | ||
|
||
it('should not migrate the lack of a labs flag', () => { | ||
seedLabs(synapse, null); | ||
testForVal(null); | ||
}); | ||
|
||
it('should migrate labsHiddenRR=false as sendRR=true', () => { | ||
seedLabs(synapse, false); | ||
testForVal(true); | ||
}); | ||
|
||
it('should migrate labsHiddenRR=true as sendRR=false', () => { | ||
seedLabs(synapse, true); | ||
testForVal(false); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would make sense to make this into
settings-migrations.spec.ts
and put the hidden RRs into adescribe
. This way new settings migrations have a place to go(this is more of a personal preference and it is not a blocker)