Merge branch 'develop' of https://github.com/vector-im/element-web into dbkr/stateafter
# Conflicts: # test/unit-tests/components/structures/RoomView-test.tsx # test/unit-tests/components/structures/TimelinePanel-test.tsx
This commit is contained in:
@@ -13,7 +13,7 @@ import { createTestClient, flushPromises, setupAsyncStoreWithClient } from "../.
|
||||
import SettingsStore from "../../../src/settings/SettingsStore";
|
||||
import { BreadcrumbsStore } from "../../../src/stores/BreadcrumbsStore";
|
||||
import { Action } from "../../../src/dispatcher/actions";
|
||||
import { defaultDispatcher } from "../../../src/dispatcher/dispatcher";
|
||||
import defaultDispatcher from "../../../src/dispatcher/dispatcher";
|
||||
|
||||
describe("BreadcrumbsStore", () => {
|
||||
let store: BreadcrumbsStore;
|
||||
|
||||
@@ -189,8 +189,7 @@ describe("MemberListStore", () => {
|
||||
});
|
||||
|
||||
it("does not use lazy loading on encrypted rooms", async () => {
|
||||
client.isRoomEncrypted = jest.fn();
|
||||
mocked(client.isRoomEncrypted).mockReturnValue(true);
|
||||
jest.spyOn(client.getCrypto()!, "isEncryptionEnabledInRoom").mockResolvedValue(true);
|
||||
|
||||
const { joined } = await store.loadMemberList(roomId);
|
||||
expect(joined).toEqual([room.getMember(alice)]);
|
||||
|
||||
@@ -338,7 +338,7 @@ describe("RoomViewStore", function () {
|
||||
});
|
||||
dis.dispatch({ action: Action.ViewRoom, room_id: roomId });
|
||||
await untilDispatch(Action.ActiveRoomChanged, dis);
|
||||
expect(mockClient.setRoomAccountData).toHaveBeenCalledWith(roomId, "com.famedly.marked_unread", {
|
||||
expect(mockClient.setRoomAccountData).toHaveBeenCalledWith(roomId, "m.marked_unread", {
|
||||
unread: false,
|
||||
});
|
||||
});
|
||||
|
||||
@@ -37,6 +37,7 @@ describe("SetupEncryptionStore", () => {
|
||||
getDeviceVerificationStatus: jest.fn(),
|
||||
isDehydrationSupported: jest.fn().mockResolvedValue(false),
|
||||
startDehydration: jest.fn(),
|
||||
getKeyBackupInfo: jest.fn().mockResolvedValue(null),
|
||||
} as unknown as Mocked<CryptoApi>;
|
||||
client.getCrypto.mockReturnValue(mockCrypto);
|
||||
|
||||
@@ -170,15 +171,10 @@ describe("SetupEncryptionStore", () => {
|
||||
|
||||
await setupEncryptionStore.resetConfirm();
|
||||
|
||||
expect(mocked(accessSecretStorage)).toHaveBeenCalledWith(expect.any(Function), true);
|
||||
expect(makeRequest).toHaveBeenCalledWith({
|
||||
identifier: {
|
||||
type: "m.id.user",
|
||||
user: "@userId:matrix.org",
|
||||
},
|
||||
password: cachedPassword,
|
||||
type: "m.login.password",
|
||||
user: "@userId:matrix.org",
|
||||
expect(mocked(accessSecretStorage)).toHaveBeenCalledWith(expect.any(Function), {
|
||||
accountPassword: cachedPassword,
|
||||
forceReset: true,
|
||||
resetCrossSigning: true,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -91,7 +91,7 @@ describe("RoomNotificationState", () => {
|
||||
const listener = jest.fn();
|
||||
roomNotifState.addListener(NotificationStateEvents.Update, listener);
|
||||
const accountDataEvent = {
|
||||
getType: () => "com.famedly.marked_unread",
|
||||
getType: () => "m.marked_unread",
|
||||
getContent: () => {
|
||||
return { unread: true };
|
||||
},
|
||||
|
||||
@@ -8,7 +8,14 @@ Please see LICENSE files in the repository root for full details.
|
||||
|
||||
import { mocked, MockedObject } from "jest-mock";
|
||||
import { last } from "lodash";
|
||||
import { MatrixEvent, MatrixClient, ClientEvent, EventTimeline } from "matrix-js-sdk/src/matrix";
|
||||
import {
|
||||
MatrixEvent,
|
||||
MatrixClient,
|
||||
ClientEvent,
|
||||
EventTimeline,
|
||||
EventType,
|
||||
MatrixEventEvent,
|
||||
} from "matrix-js-sdk/src/matrix";
|
||||
import { ClientWidgetApi, WidgetApiFromWidgetAction } from "matrix-widget-api";
|
||||
import { waitFor } from "jest-matrix-react";
|
||||
|
||||
@@ -134,6 +141,46 @@ describe("StopGapWidget", () => {
|
||||
expect(messaging.feedEvent).toHaveBeenLastCalledWith(event2.getEffectiveEvent(), "!1:example.org");
|
||||
});
|
||||
|
||||
it("feeds decrypted events asynchronously", async () => {
|
||||
const event1Encrypted = new MatrixEvent({
|
||||
event_id: event1.getId(),
|
||||
type: EventType.RoomMessageEncrypted,
|
||||
sender: event1.sender?.userId,
|
||||
room_id: event1.getRoomId(),
|
||||
content: {},
|
||||
});
|
||||
const decryptingSpy1 = jest.spyOn(event1Encrypted, "isBeingDecrypted").mockReturnValue(true);
|
||||
client.emit(ClientEvent.Event, event1Encrypted);
|
||||
const event2Encrypted = new MatrixEvent({
|
||||
event_id: event2.getId(),
|
||||
type: EventType.RoomMessageEncrypted,
|
||||
sender: event2.sender?.userId,
|
||||
room_id: event2.getRoomId(),
|
||||
content: {},
|
||||
});
|
||||
const decryptingSpy2 = jest.spyOn(event2Encrypted, "isBeingDecrypted").mockReturnValue(true);
|
||||
client.emit(ClientEvent.Event, event2Encrypted);
|
||||
expect(messaging.feedEvent).not.toHaveBeenCalled();
|
||||
|
||||
// "Decrypt" the events, but in reverse order; first event 2…
|
||||
event2Encrypted.event.type = event2.getType();
|
||||
event2Encrypted.event.content = event2.getContent();
|
||||
decryptingSpy2.mockReturnValue(false);
|
||||
client.emit(MatrixEventEvent.Decrypted, event2Encrypted);
|
||||
expect(messaging.feedEvent).toHaveBeenCalledTimes(1);
|
||||
expect(messaging.feedEvent).toHaveBeenLastCalledWith(event2Encrypted.getEffectiveEvent(), "!1:example.org");
|
||||
// …then event 1
|
||||
event1Encrypted.event.type = event1.getType();
|
||||
event1Encrypted.event.content = event1.getContent();
|
||||
decryptingSpy1.mockReturnValue(false);
|
||||
client.emit(MatrixEventEvent.Decrypted, event1Encrypted);
|
||||
// The events should be fed in that same order so that event 2
|
||||
// doesn't have to be blocked on the decryption of event 1 (or
|
||||
// worse, dropped)
|
||||
expect(messaging.feedEvent).toHaveBeenCalledTimes(2);
|
||||
expect(messaging.feedEvent).toHaveBeenLastCalledWith(event1Encrypted.getEffectiveEvent(), "!1:example.org");
|
||||
});
|
||||
|
||||
it("should not feed incoming event if not in timeline", () => {
|
||||
const event = mkEvent({
|
||||
event: true,
|
||||
|
||||
Reference in New Issue
Block a user