mirror of
https://github.com/QuivrHQ/quivr.git
synced 2024-12-15 17:43:03 +03:00
b64fc044c4
* 🚧 🌐 knowledge traductions * 🔥 replace useKnowledge hook * ✨ AddKnowledge in knowledge tab * 🚧 extract feedBrain in chat hook * ♻️ use feedBrain method as a prop in KnowledgeToFeedInput * ✨ custom feedBrain for chat and brain management * ✨ add loader when deleting * 🚑 remove chat after auto creation for each feed action * 🚚 rename KnowledgeProvider into KnowledgeToFeedProvider
95 lines
2.3 KiB
TypeScript
95 lines
2.3 KiB
TypeScript
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
|
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 { KnowledgeToFeedProvider } from "@/lib/context/KnowledgeToFeedProvider";
|
|
import {
|
|
SupabaseContextMock,
|
|
SupabaseProviderMock,
|
|
} from "@/lib/context/SupabaseProvider/mocks/SupabaseProviderMock";
|
|
|
|
import SelectedChatPage from "../page";
|
|
|
|
const queryClient = new QueryClient();
|
|
|
|
vi.mock("@/lib/context/ChatProvider/ChatProvider", () => ({
|
|
ChatContext: ChatContextMock,
|
|
ChatProvider: ChatProviderMock,
|
|
}));
|
|
|
|
vi.mock("next/navigation", () => ({
|
|
useRouter: () => ({ replace: vi.fn() }),
|
|
useParams: () => ({ chatId: "1" }),
|
|
}));
|
|
|
|
vi.mock("@/lib/context/SupabaseProvider/supabase-provider", () => ({
|
|
SupabaseContext: SupabaseContextMock,
|
|
}));
|
|
|
|
vi.mock("@/lib/context/BrainProvider/brain-provider", () => ({
|
|
BrainContext: BrainContextMock,
|
|
}));
|
|
|
|
vi.mock("@/lib/api/chat/useChatApi", () => ({
|
|
useChatApi: () => ({
|
|
getHistory: () => [],
|
|
}),
|
|
}));
|
|
|
|
vi.mock("@/lib/hooks", async () => {
|
|
const actual = await vi.importActual<typeof import("@/lib/hooks")>(
|
|
"@/lib/hooks"
|
|
);
|
|
|
|
return {
|
|
...actual,
|
|
useAxios: () => ({
|
|
axiosInstance: {
|
|
get: vi.fn(() => ({ data: [] })),
|
|
},
|
|
}),
|
|
};
|
|
});
|
|
|
|
vi.mock("@tanstack/react-query", async () => {
|
|
const actual = await vi.importActual<typeof import("@tanstack/react-query")>(
|
|
"@tanstack/react-query"
|
|
);
|
|
|
|
return {
|
|
...actual,
|
|
useQuery: () => ({
|
|
data: {},
|
|
}),
|
|
};
|
|
});
|
|
|
|
describe("Chat page", () => {
|
|
it("should render chat page correctly", () => {
|
|
const { getByTestId } = render(
|
|
<KnowledgeToFeedProvider>
|
|
<QueryClientProvider client={queryClient}>
|
|
<ChatProviderMock>
|
|
<SupabaseProviderMock>
|
|
<BrainProviderMock>
|
|
<SelectedChatPage />,
|
|
</BrainProviderMock>
|
|
</SupabaseProviderMock>
|
|
</ChatProviderMock>
|
|
</QueryClientProvider>
|
|
</KnowledgeToFeedProvider>
|
|
);
|
|
|
|
expect(getByTestId("chat-page")).toBeDefined();
|
|
expect(getByTestId("chat-input")).toBeDefined();
|
|
});
|
|
});
|