Support dynamic room predecessors in RoomNotificationStateStore (#10297)

* Tests for RoomNotificationStateStore emitting events

* Support dynamic room predecessors in RoomNotificationStateStore

* Remove unused arguments from emit call.

UPDATE_STATUS_INDICATOR is used in:
* SpacePanel
* MatrixChat
* RoomHeaderButtons

but these arguments are not used in any of those places. Remove them so
when I refactor I don't have to make up values for them.

* Fix broken test (wrong expected args to emit)

UPDATE_STATUS_INDICATOR is used in:
* SpacePanel
* MatrixChat
* RoomHeaderButtons

but these arguments are not used in any of those places. Remove them so
when I refactor I don't have to make up values for them.

* Update the RoomNotificationStore whenever the predecessor labs flag changes

* Fix type errors

* Fix other tests that trigger our new watcher
This commit is contained in:
Andy Balaam
2023-03-08 14:18:03 +00:00
committed by GitHub
parent 80fc0997a4
commit b8d502be2e
4 changed files with 186 additions and 15 deletions

View File

@@ -203,11 +203,19 @@ describe("RoomView", () => {
expect(instance.getHiddenHighlightCount()).toBe(23);
});
it("and feature_dynamic_room_predecessors is enabled it should pass the setting to findPredecessor", async () => {
SettingsStore.setValue("feature_dynamic_room_predecessors", null, SettingLevel.DEVICE, true);
expect(instance.getHiddenHighlightCount()).toBe(0);
expect(room.findPredecessor).toHaveBeenCalledWith(true);
SettingsStore.setValue("feature_dynamic_room_predecessors", null, SettingLevel.DEVICE, null);
describe("and feature_dynamic_room_predecessors is enabled", () => {
beforeEach(() => {
instance.setState({ msc3946ProcessDynamicPredecessor: true });
});
afterEach(() => {
instance.setState({ msc3946ProcessDynamicPredecessor: false });
});
it("should pass the setting to findPredecessor", async () => {
expect(instance.getHiddenHighlightCount()).toBe(0);
expect(room.findPredecessor).toHaveBeenCalledWith(true);
});
});
});

View File

@@ -198,11 +198,17 @@ describe("Spotlight Dialog", () => {
describe("when MSC3946 dynamic room predecessors is enabled", () => {
beforeEach(() => {
SettingsStore.setValue("feature_dynamic_room_predecessors", null, SettingLevel.DEVICE, true);
jest.spyOn(SettingsStore, "getValue").mockImplementation((settingName, roomId, excludeDefault) => {
if (settingName === "feature_dynamic_room_predecessors") {
return true;
} else {
return []; // SpotlightSearch.recentSearches
}
});
});
afterEach(() => {
SettingsStore.setValue("feature_dynamic_room_predecessors", null, SettingLevel.DEVICE, null);
jest.restoreAllMocks();
});
it("should call getVisibleRooms with MSC3946 dynamic room predecessors", async () => {