conversationShareSelectionReopenTab.test.ts 1.1 KB

1234567891011121314151617181920212223242526272829
  1. // @vitest-environment jsdom
  2. import { createElement } from "react";
  3. import { cleanup, fireEvent, render, screen } from "@testing-library/react";
  4. import { afterEach, describe, expect, it, vi } from "vitest";
  5. import { ConversationShareSelectionReopenTab } from "@/v4/ConversationShareSelectionReopenTab.js";
  6. vi.mock("@/i18n/IntlProvider.js", () => ({
  7. useZCodeIntl: () => ({
  8. intl: { formatMessage: ({ id }: { id: string }) => id },
  9. }),
  10. }));
  11. afterEach(() => cleanup());
  12. describe("ConversationShareSelectionReopenTab", () => {
  13. it("renders an accessible left navigation action and reopens the panel", () => {
  14. const onOpen = vi.fn();
  15. render(createElement(ConversationShareSelectionReopenTab, { onOpen }));
  16. const button = screen.getByRole("button", {
  17. name: "conversationShare.selection.reopen",
  18. });
  19. expect(button.getAttribute("data-conversation-share-left-navigation")).toBe("true");
  20. expect(button.getAttribute("data-testid")).toBe("conversation-share-selection-reopen");
  21. fireEvent.click(button);
  22. expect(onOpen).toHaveBeenCalledTimes(1);
  23. });
  24. });