2023-07-05 10:30:22 +03:00
|
|
|
import { render } from "@testing-library/react";
|
|
|
|
import { describe, expect, it, vi } from "vitest";
|
|
|
|
|
|
|
|
import {
|
|
|
|
BrainContextMock,
|
|
|
|
BrainProviderMock,
|
|
|
|
} from "@/lib/context/BrainProvider/mocks/BrainProviderMock";
|
|
|
|
import {
|
|
|
|
ChatContextMock,
|
|
|
|
ChatProviderMock,
|
|
|
|
} from "@/lib/context/ChatProvider/mocks/ChatProviderMock";
|
|
|
|
import {
|
|
|
|
SupabaseContextMock,
|
|
|
|
SupabaseProviderMock,
|
|
|
|
} from "@/lib/context/SupabaseProvider/mocks/SupabaseProviderMock";
|
|
|
|
|
2023-07-05 19:33:18 +03:00
|
|
|
import SelectedChatPage from "../page";
|
2023-07-05 10:30:22 +03:00
|
|
|
|
|
|
|
vi.mock("@/lib/context/ChatProvider/ChatProvider", () => ({
|
|
|
|
ChatContext: ChatContextMock,
|
|
|
|
ChatProvider: ChatProviderMock,
|
|
|
|
}));
|
|
|
|
|
2023-08-30 10:45:11 +03:00
|
|
|
vi.mock("next/navigation", () => ({
|
|
|
|
useRouter: () => ({ replace: vi.fn() }),
|
|
|
|
useParams: () => ({ chatId: "1" }),
|
|
|
|
}));
|
|
|
|
|
2023-07-05 10:30:22 +03:00
|
|
|
vi.mock("@/lib/context/SupabaseProvider/supabase-provider", () => ({
|
|
|
|
SupabaseContext: SupabaseContextMock,
|
|
|
|
}));
|
|
|
|
|
|
|
|
vi.mock("@/lib/context/BrainProvider/brain-provider", () => ({
|
|
|
|
BrainContext: BrainContextMock,
|
|
|
|
}));
|
|
|
|
|
2023-09-08 10:57:21 +03:00
|
|
|
vi.mock("@/lib/api/chat/useChatApi", () => ({
|
|
|
|
useChatApi: () => ({
|
|
|
|
getHistory: () => [],
|
|
|
|
}),
|
|
|
|
}));
|
2023-09-13 14:47:12 +03:00
|
|
|
vi.mock("@tanstack/react-query", async () => {
|
|
|
|
const actual = await vi.importActual<typeof import("@tanstack/react-query")>(
|
|
|
|
"@tanstack/react-query"
|
|
|
|
);
|
|
|
|
|
|
|
|
return {
|
|
|
|
...actual,
|
|
|
|
useQuery: () => ({
|
|
|
|
data: {},
|
|
|
|
}),
|
|
|
|
};
|
|
|
|
});
|
2023-09-08 10:57:21 +03:00
|
|
|
|
2023-07-05 10:30:22 +03:00
|
|
|
describe("Chat page", () => {
|
|
|
|
it("should render chat page correctly", () => {
|
2023-08-07 15:13:41 +03:00
|
|
|
const { getByTestId } = render(
|
2023-08-11 11:06:20 +03:00
|
|
|
<ChatProviderMock>
|
|
|
|
<SupabaseProviderMock>
|
2023-09-12 19:04:35 +03:00
|
|
|
<BrainProviderMock>
|
|
|
|
<SelectedChatPage />,
|
|
|
|
</BrainProviderMock>
|
2023-08-11 11:06:20 +03:00
|
|
|
</SupabaseProviderMock>
|
|
|
|
</ChatProviderMock>
|
2023-07-05 10:30:22 +03:00
|
|
|
);
|
|
|
|
|
|
|
|
expect(getByTestId("chat-page")).toBeDefined();
|
|
|
|
expect(getByTestId("chat-input")).toBeDefined();
|
|
|
|
});
|
|
|
|
});
|