Skip to content

Commit

Permalink
add test for not showing shield
Browse files Browse the repository at this point in the history
  • Loading branch information
uhoreg committed Oct 25, 2024
1 parent 63c1245 commit be05fa1
Showing 1 changed file with 36 additions and 1 deletion.
37 changes: 36 additions & 1 deletion test/unit-tests/components/views/rooms/EventTile-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,14 @@ import {
Room,
TweakName,
} from "matrix-js-sdk/src/matrix";
import { CryptoApi, EventEncryptionInfo, EventShieldColour, EventShieldReason } from "matrix-js-sdk/src/crypto-api";
import {
CryptoApi,
DecryptionFailureCode,
EventEncryptionInfo,
EventShieldColour,
EventShieldReason,
} from "matrix-js-sdk/src/crypto-api";
import { DecryptionError } from "matrix-js-sdk/src/crypto/algorithms";

Check failure on line 29 in test/unit-tests/components/views/rooms/EventTile-test.tsx

View workflow job for this annotation

GitHub Actions / ESLint

'matrix-js-sdk/src/crypto/algorithms' import is restricted from being used by a pattern. Please use matrix-js-sdk/src/matrix instead
import { mkEncryptedMatrixEvent } from "matrix-js-sdk/src/testing";

import EventTile, { EventTileProps } from "../../../../../src/components/views/rooms/EventTile";
Expand Down Expand Up @@ -350,6 +357,34 @@ describe("EventTile", () => {
"mx_EventTile_e2eIcon_decryption_failure",
);
});

it("should not show a shield for previously-verified users", async () => {
mxEvent = mkEvent({
type: "m.room.encrypted",
room: room.roomId,
user: "@alice:example.org",
event: true,
content: {},
});

const mockCrypto = {
decryptEvent: async (_ev): Promise<IEventDecryptionResult> => {
throw new DecryptionError(
DecryptionFailureCode.SENDER_IDENTITY_PREVIOUSLY_VERIFIED,
"The sender identity is unverified, but was previously verified.",
);
},
} as Parameters<MatrixEvent["attemptDecryption"]>[0];
await mxEvent.attemptDecryption(mockCrypto);

const { container } = getComponent();
await act(flushPromises);

const eventTiles = container.getElementsByClassName("mx_EventTile");
expect(eventTiles).toHaveLength(1);

expect(container.getElementsByClassName("mx_EventTile_e2eIcon")).toHaveLength(0);
});
});

it("should update the warning when the event is edited", async () => {
Expand Down

0 comments on commit be05fa1

Please sign in to comment.