mirror of
https://github.com/vector-im/element-web.git
synced 2026-05-08 13:46:16 +02:00
* Refactor RoomStatusBar into MVVM * cleanup * updated snaps * More cleanup * fix loop * fixup * drop comment * lint * cleanup console statements * Starting to move to a MVVM v2 component. * extra * Refactor as a shared-componend / MVVM v2 * some cleanup * i18n for banner * remove removed css * Update playwright tests to have a two stage on the consent bar. * Update snaps * Update snapshots * cleanup * update snaps * refactor to use enum * fix slight differences in pw snaps * Add unit tests * fix snaps * snaps updated * more test cleanups * fix snaps * fixed now? * Disable animationsq * lint lint lint * remove console * lint * fix snap * Refactor based on review comments. * update view model test * oops! * fix snap * Update snaps * snap snap snap * switch to a const map of strings * Use this.disposables * Update translations to be inside shared-components * fix the tac * Also retry * Cleanup * update snaps * update other snaps * snap updates
70 lines
2.7 KiB
TypeScript
70 lines
2.7 KiB
TypeScript
/*
|
|
* Copyright (c) 2025 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 { render } from "jest-matrix-react";
|
|
import { composeStories } from "@storybook/react-vite";
|
|
import userEvent from "@testing-library/user-event";
|
|
|
|
import * as stories from "./RoomStatusBarView.stories.tsx";
|
|
|
|
const { WithConnectionLost, WithConsentLink, WithResourceLimit, WithUnsentMessages, WithLocalRoomRetry } =
|
|
composeStories(stories);
|
|
|
|
describe("RoomStatusBarView", () => {
|
|
it("renders connection lost", () => {
|
|
const { container } = render(<WithConnectionLost />);
|
|
expect(container).toMatchSnapshot();
|
|
});
|
|
it("renders resource limit error", () => {
|
|
const { container } = render(<WithResourceLimit />);
|
|
expect(container).toMatchSnapshot();
|
|
});
|
|
it("renders consent link", () => {
|
|
const { container, getByRole } = render(<WithConsentLink />);
|
|
expect(container).toMatchSnapshot();
|
|
|
|
const button = getByRole("link");
|
|
expect(button.getAttribute("href")).toEqual("#example");
|
|
});
|
|
it("renders unsent messages", async () => {
|
|
const { container } = render(
|
|
<WithUnsentMessages onDeleteAllClick={jest.fn()} onRetryRoomCreationClick={jest.fn()} />,
|
|
);
|
|
expect(container).toMatchSnapshot();
|
|
});
|
|
it("renders unsent messages and deletes all", async () => {
|
|
const onDeleteAllClick = jest.fn();
|
|
const { container, getByRole } = render(<WithUnsentMessages onDeleteAllClick={onDeleteAllClick} />);
|
|
expect(container).toMatchSnapshot();
|
|
|
|
const button = getByRole("button", { name: "Delete all" });
|
|
await userEvent.click(button);
|
|
expect(onDeleteAllClick).toHaveBeenCalled();
|
|
});
|
|
it("renders unsent messages and resends all", async () => {
|
|
const onResendAllClick = jest.fn();
|
|
const { container, getByRole } = render(<WithUnsentMessages onResendAllClick={onResendAllClick} />);
|
|
expect(container).toMatchSnapshot();
|
|
|
|
const button = getByRole("button", { name: "Retry all" });
|
|
await userEvent.click(button);
|
|
expect(onResendAllClick).toHaveBeenCalled();
|
|
});
|
|
it("renders local room error", async () => {
|
|
const onRetryRoomCreationClick = jest.fn();
|
|
const { container, getByRole } = render(
|
|
<WithLocalRoomRetry onRetryRoomCreationClick={onRetryRoomCreationClick} />,
|
|
);
|
|
expect(container).toMatchSnapshot();
|
|
|
|
const button = getByRole("button", { name: "Retry" });
|
|
await userEvent.click(button);
|
|
expect(onRetryRoomCreationClick).toHaveBeenCalled();
|
|
});
|
|
});
|