mirror of
https://github.com/Novaloop-AG/healthchat-web.git
synced 2026-10-31 08:15:07 +00:00
34c388f760
* Refactor E2eMessageSharedIcon to MVVM * FIx Prettier and i18n * Fix prettier * Remove legacy E2eMessageSharedIcon component * Cover E2eMessageSharedIcon MVVM updates * Fix prettier * Update apps/web/src/components/views/rooms/EventTile.tsx Co-authored-by: Florian Duros <florian.duros@ormaz.fr> * Skip unknown E2E shared icon visual * Track E2E shared icon listener disposal * Remove E2E shared icon room state guard * Remove E2E shared icon client resync * Use built-in disposables for shared icon VM * Update shared icon VM without React key --------- Co-authored-by: Florian Duros <florian.duros@ormaz.fr>
55 lines
1.8 KiB
TypeScript
55 lines
1.8 KiB
TypeScript
/*
|
|
* Copyright 2026 Element Creations Ltd.
|
|
*
|
|
* SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial
|
|
* Please see LICENSE files in the repository root for full details.
|
|
*/
|
|
|
|
import React from "react";
|
|
import { composeStories } from "@storybook/react-vite";
|
|
import { describe, expect, it } from "vitest";
|
|
import { render, screen } from "@test-utils";
|
|
|
|
import { MockViewModel } from "../../../../../core/viewmodel";
|
|
import {
|
|
E2eMessageSharedIconView,
|
|
type E2eMessageSharedIconViewModel,
|
|
type E2eMessageSharedIconViewSnapshot,
|
|
} from "./E2eMessageSharedIconView";
|
|
import * as stories from "./E2eMessageSharedIcon.stories";
|
|
|
|
const { Default, UnknownUser } = composeStories(stories);
|
|
|
|
describe("E2eMessageSharedIconView", () => {
|
|
it("renders the default shared-message icon", () => {
|
|
const { container } = render(<Default />);
|
|
|
|
expect(container).toMatchSnapshot();
|
|
});
|
|
|
|
it("renders an unknown user tooltip state", () => {
|
|
const { container } = render(<UnknownUser />);
|
|
|
|
expect(container).toMatchSnapshot();
|
|
});
|
|
|
|
it("applies a custom className to the icon container", () => {
|
|
const vm = new MockViewModel<E2eMessageSharedIconViewSnapshot>({
|
|
displayName: "Bob",
|
|
userId: "@bob:example.com",
|
|
}) as E2eMessageSharedIconViewModel;
|
|
|
|
render(<E2eMessageSharedIconView vm={vm} className="custom-shared-icon" />);
|
|
|
|
expect(screen.getByTestId("e2e-padlock")).toHaveClass("custom-shared-icon");
|
|
});
|
|
|
|
it("uses the shared translation for the icon accessible name", () => {
|
|
render(<Default />);
|
|
|
|
expect(screen.getByTestId("e2e-padlock")).toHaveAccessibleName(
|
|
"Bob (@bob:example.com) shared this message since you were not in the room when it was sent.",
|
|
);
|
|
});
|
|
});
|