Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions internal/site/components/chat-message-input.test.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
// Load the core package first so Bun initializes Lexical's shared exports before @lexical/react.
import "lexical";
import { afterAll, beforeAll, expect, test } from "bun:test";
import { render, waitFor } from "@testing-library/react";
import { Window } from "happy-dom";
import {
ChatMessageInput,
type ChatMessageInputRef,
} from "./chat-message-input";
import type { ChatMessageInputRef } from "./chat-message-input";

beforeAll(() => {
let ChatMessageInput: typeof import("./chat-message-input").ChatMessageInput;

beforeAll(async () => {
globalThis.window = new Window() as any;
globalThis.document = window.document;
globalThis.MutationObserver = window.MutationObserver;
globalThis.getComputedStyle = window.getComputedStyle;
globalThis.Text = window.Text;

await import("lexical");
({ ChatMessageInput } = await import("./chat-message-input"));
});

afterAll(async () => {
Expand All @@ -24,6 +25,8 @@ afterAll(async () => {
delete globalThis.MutationObserver;
// @ts-expect-error
delete globalThis.getComputedStyle;
// @ts-expect-error
delete globalThis.Text;
});

test("has initial value", async () => {
Expand Down
19 changes: 12 additions & 7 deletions internal/site/components/chat-multimodal-input.test.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
// Load the core package first so Bun initializes Lexical's shared exports before @lexical/react.
import "lexical";
import { afterAll, beforeAll, expect, mock, test } from "bun:test";
import { fireEvent, render, waitFor } from "@testing-library/react";
import { Window } from "happy-dom";
import type { UIAttachment } from "@/hooks/use-attachments";
import type { ChatMessageInputRef } from "./chat-message-input";
import {
ChatMultimodalInput,
getInputLocalStorageKey,
} from "./chat-multimodal-input";
import { PreviewAttachment } from "./preview-attachment";

beforeAll(() => {
let ChatMultimodalInput: typeof import("./chat-multimodal-input").ChatMultimodalInput;
let getInputLocalStorageKey: typeof import("./chat-multimodal-input").getInputLocalStorageKey;

beforeAll(async () => {
globalThis.window = new Window() as any;
globalThis.document = window.document;
globalThis.MutationObserver = window.MutationObserver;
globalThis.getComputedStyle = window.getComputedStyle;
globalThis.Text = window.Text;

await import("lexical");
({ ChatMultimodalInput, getInputLocalStorageKey } = await import(
"./chat-multimodal-input"
));
});

afterAll(async () => {
Expand All @@ -27,6 +30,8 @@ afterAll(async () => {
delete globalThis.MutationObserver;
// @ts-expect-error
delete globalThis.getComputedStyle;
// @ts-expect-error
delete globalThis.Text;
});

test("loads input value from localStorage", async () => {
Expand Down
Loading