Files
ThreadNet-Web/packages/shared-components/src/room/WidgetPip/WidgetPipView.test.tsx
T
TimoandGitHub 6d99678ade Redesign widget pip and move into shared component (#32654)
* redesign widget pip and move into shared component

* fix onBackClick handler

* fix ci

* Update README.md prepare -> prepack

* add vm tests

* Update WidgetPipView.stories.tsx

* fix tests

* playwright tests

* fix test id

* remove unused files (reappeared after rebase)

* update storybook screenshot tests

* update playwright tests

* adjust padding

* review

* comment and docstring corrections

* fix imports and `this.props`

* fix double `complementary` item

* add WidgetPipView tests and revmoe `setViewingRoom` from
WidgetPipViewModelInterface.

* add doc sting to `setViewingRoom`

* Update RoomStatusBarView.test.tsx

* fix copyright

* Update RoomView-test.tsx.snap

* revert accidental Copyright year changes

* update snapshot RoomView-test
2026-03-10 16:59:51 +00:00

52 lines
1.9 KiB
TypeScript

/*
* Copyright (c) 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 { render } from "@test-utils";
import { composeStories } from "@storybook/react-vite";
import userEvent from "@testing-library/user-event";
import { describe, it, vi, expect } from "vitest";
import { getByTestId } from "storybook/test";
import * as stories from "./WidgetPipView.stories.tsx";
const { WithGreyWidget } = composeStories(stories);
describe("WidgetPipView", () => {
it("renders with gray widget", () => {
const { container } = render(<WithGreyWidget />);
expect(container).toMatchSnapshot();
});
it("detects back click action", async () => {
const onBackClick = vi.fn();
const { container, getByRole } = render(<WithGreyWidget onBackClick={onBackClick} />);
expect(container).toMatchSnapshot();
const button = getByRole("button", { name: "Back" });
await userEvent.click(button);
expect(onBackClick).toHaveBeenCalled();
});
it("detects double click triggers back", async () => {
const onBackClick = vi.fn();
const { container } = render(<WithGreyWidget onStartMoving={onBackClick} />);
expect(container).toMatchSnapshot();
const pipContainer = getByTestId(container, "widget-pip-container");
await userEvent.dblClick(pipContainer);
expect(onBackClick).toHaveBeenCalled();
});
it("detects on mouse down for drag", async () => {
const onStartMoving = vi.fn();
const { container } = render(<WithGreyWidget onStartMoving={onStartMoving} />);
expect(container).toMatchSnapshot();
const pipContainer = getByTestId(container, "widget-pip-container");
await userEvent.click(pipContainer);
expect(onStartMoving).toHaveBeenCalled();
});
});