mirror of
https://github.com/QuivrHQ/quivr.git
synced 2024-09-20 02:48:04 +03:00
fix(frontend): double file upload on drag and drop (#2284)
# Description Please include a summary of the changes and the related issue. Please also include relevant motivation and context. ## Checklist before requesting a review Please delete options that are not relevant. - [ ] My code follows the style guidelines of this project - [ ] I have performed a self-review of my code - [ ] I have commented hard-to-understand areas - [ ] I have ideally added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] Any dependent changes have been merged ## Screenshots (if appropriate):
This commit is contained in:
parent
ecc8eb6366
commit
ff914b9d0f
@ -1,120 +0,0 @@
|
||||
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 { MenuProvider } from "@/lib/context/MenuProvider/Menu-provider";
|
||||
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("@/lib/context/ChatsProvider/hooks/useChatsContext", () => ({
|
||||
useChatsContext: () => ({
|
||||
allChats: [
|
||||
{
|
||||
chat_id: 1,
|
||||
name: "Chat 1",
|
||||
creation_time: new Date().toISOString(),
|
||||
},
|
||||
{
|
||||
chat_id: 2,
|
||||
name: "Chat 2",
|
||||
creation_time: new Date().toISOString(),
|
||||
},
|
||||
],
|
||||
deleteChat: vi.fn(),
|
||||
setAllChats: vi.fn(),
|
||||
setIsLoading: vi.fn(),
|
||||
}),
|
||||
}));
|
||||
vi.mock("next/navigation", () => ({
|
||||
useRouter: () => ({ replace: vi.fn() }),
|
||||
useParams: () => ({ chatId: "1" }),
|
||||
usePathname: () => "/chat/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: {},
|
||||
}),
|
||||
};
|
||||
});
|
||||
vi.mock(
|
||||
"../components/ActionsBar/components/ChatInput/components/ChatEditor/ChatEditor",
|
||||
() => ({
|
||||
ChatEditor: () => <div data-testid="chat-input" />,
|
||||
})
|
||||
);
|
||||
|
||||
vi.mock("../hooks/useChatNotificationsSync", () => ({
|
||||
useChatNotificationsSync: vi.fn(),
|
||||
}));
|
||||
describe("Chat page", () => {
|
||||
it("should render chat page correctly", () => {
|
||||
const { getByTestId } = render(
|
||||
<KnowledgeToFeedProvider>
|
||||
<QueryClientProvider client={queryClient}>
|
||||
<ChatProviderMock>
|
||||
<SupabaseProviderMock>
|
||||
<BrainProviderMock>
|
||||
<MenuProvider>
|
||||
<SelectedChatPage />,
|
||||
</MenuProvider>
|
||||
</BrainProviderMock>
|
||||
</SupabaseProviderMock>
|
||||
</ChatProviderMock>
|
||||
</QueryClientProvider>
|
||||
</KnowledgeToFeedProvider>
|
||||
);
|
||||
|
||||
expect(getByTestId("chat-page")).toBeDefined();
|
||||
expect(getByTestId("chat-input")).toBeDefined();
|
||||
});
|
||||
});
|
@ -25,7 +25,8 @@ const SelectedChatPage = (): JSX.Element => {
|
||||
const { getRootProps } = useCustomDropzone();
|
||||
const { isMobile } = useDevice();
|
||||
|
||||
const { setShouldDisplayFeedCard } = useKnowledgeToFeedContext();
|
||||
const { setShouldDisplayFeedCard, shouldDisplayFeedCard } =
|
||||
useKnowledgeToFeedContext();
|
||||
const { setIsBrainCreationModalOpened } = useBrainCreationContext();
|
||||
|
||||
const { currentBrain, setCurrentBrainId } = useBrainContext();
|
||||
@ -81,8 +82,7 @@ const SelectedChatPage = (): JSX.Element => {
|
||||
</div>
|
||||
<div
|
||||
className={styles.chat_page_container}
|
||||
data-testid="chat-page"
|
||||
{...getRootProps()}
|
||||
{...(shouldDisplayFeedCard ? {} : getRootProps())}
|
||||
>
|
||||
<div
|
||||
className={cn(
|
||||
|
Loading…
Reference in New Issue
Block a user