Track room list sorting algorithm changes (#32556)
* Update analytics package * Add method for tracking event * Track event on resort * Add test * Fix lint
This commit is contained in:
@@ -25,6 +25,7 @@ import {
|
||||
} from "../../../src/utils/space";
|
||||
import { createTestClient, mkSpace } from "../../test-utils";
|
||||
import { createRoom, hasCreateRoomRights } from "../../../src/viewmodels/room-list/utils";
|
||||
import PosthogTrackers from "../../../src/PosthogTrackers";
|
||||
|
||||
jest.mock("../../../src/PosthogTrackers", () => ({
|
||||
trackInteraction: jest.fn(),
|
||||
@@ -276,10 +277,25 @@ describe("RoomListHeaderViewModel", () => {
|
||||
const resortSpy = jest.spyOn(RoomListStoreV3.instance, "resort").mockImplementation(jest.fn());
|
||||
vm = new RoomListHeaderViewModel({ matrixClient, spaceStore: SpaceStore.instance });
|
||||
vm.sort(option);
|
||||
|
||||
expect(resortSpy).toHaveBeenCalledWith(expectedAlgorithm);
|
||||
});
|
||||
|
||||
it("should track analytics on resort", () => {
|
||||
jest.spyOn(RoomListStoreV3.instance, "activeSortAlgorithm", "get").mockReturnValue(
|
||||
SortingAlgorithm.Alphabetic,
|
||||
);
|
||||
PosthogTrackers.trackRoomListSortingAlgorithmChange = jest.fn();
|
||||
|
||||
vm = new RoomListHeaderViewModel({ matrixClient, spaceStore: SpaceStore.instance });
|
||||
jest.spyOn(RoomListStoreV3.instance, "resort").mockImplementation(jest.fn());
|
||||
vm.sort("unread-first");
|
||||
|
||||
expect(PosthogTrackers.trackRoomListSortingAlgorithmChange).toHaveBeenCalledWith(
|
||||
SortingAlgorithm.Alphabetic,
|
||||
SortingAlgorithm.Unread,
|
||||
);
|
||||
});
|
||||
|
||||
it("should toggle message preview from enabled to disabled", () => {
|
||||
jest.spyOn(SettingsStore, "getValue").mockImplementation((settingName: string) => {
|
||||
if (settingName === "RoomList.showMessagePreview") return true;
|
||||
|
||||
Reference in New Issue
Block a user