test: add e2e for crawling (#1288)

* feat: update translations

* fix: update createBrain tests

* test: add crawl e2e test
This commit is contained in:
Mamadou DICKO 2023-09-29 13:15:37 +02:00 committed by GitHub
parent 36fd146fed
commit a1e6d400b2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 38 additions and 23 deletions

View File

@ -36,7 +36,7 @@ export const KnowledgeToFeed = ({
}); });
return ( return (
<div className="flex-col w-full relative"> <div className="flex-col w-full relative" data-testid="feed-card">
<div className="flex flex-1 justify-between"> <div className="flex flex-1 justify-between">
<AddBrainModal /> <AddBrainModal />
<Button <Button

View File

@ -1,4 +1,5 @@
import Link from "next/link"; import Link from "next/link";
import { useTranslation } from "react-i18next";
import { FaBrain } from "react-icons/fa"; import { FaBrain } from "react-icons/fa";
import { sidebarLinkStyle } from "@/app/chat/components/ChatsList/components/ChatsListItem/styles/SidebarLinkStyle"; import { sidebarLinkStyle } from "@/app/chat/components/ChatsList/components/ChatsListItem/styles/SidebarLinkStyle";
@ -6,14 +7,16 @@ import { useBrainContext } from "@/lib/context/BrainProvider/hooks/useBrainConte
export const BrainManagementButton = (): JSX.Element => { export const BrainManagementButton = (): JSX.Element => {
const { currentBrainId } = useBrainContext(); const { currentBrainId } = useBrainContext();
const { t } = useTranslation("brain");
return ( return (
<Link <Link
href={`/brains-management/${currentBrainId ?? ""}`} href={`/brains-management/${currentBrainId ?? ""}`}
className={sidebarLinkStyle} className={sidebarLinkStyle}
data-testid="brain-management-button"
> >
<FaBrain className="w-8 h-8" /> <FaBrain className="w-8 h-8" />
<span>My Brains</span> <span>{t("myBrains")}</span>
</Link> </Link>
); );
}; };

View File

@ -6,6 +6,6 @@ import { uploadTests } from "./tests/upload";
test.describe(createBrainTests); test.describe(createBrainTests);
test.describe.skip(uploadTests); test.describe(uploadTests);
test.describe.skip(chatTests); test.describe.skip(chatTests);

View File

@ -5,7 +5,7 @@ import { login } from "../utils/login";
export const createBrainTests = (): void => { export const createBrainTests = (): void => {
test("create brain", async ({ page }) => { test("create brain", async ({ page }) => {
await login(page); await login(page);
await page.getByTestId("brain-management-button").first().click(); await page.getByTestId("brain-management-button").click();
await page.getByTestId("add-brain-button").click(); await page.getByTestId("add-brain-button").click();
await page.getByTestId("brain-name").fill("Test brain"); await page.getByTestId("brain-name").fill("Test brain");
await page.getByTestId("create-brain-submit-button").click(); await page.getByTestId("create-brain-submit-button").click();

View File

@ -3,17 +3,16 @@ import { test } from "@playwright/test";
import { login } from "../utils/login"; import { login } from "../utils/login";
export const uploadTests = (): void => { export const uploadTests = (): void => {
test("upload", async ({ page }) => { test("it should be able to add url to crawl", async ({ page }) => {
await login(page); await login(page);
await page.goto("/chat");
await page.getByTestId("upload-button").click(); await page.getByTestId("upload-button").click();
await page await page.getByTestId("feed-card").isVisible();
.getByRole("button", { await page.getByTestId("urlToCrawlInput").click();
name: "Drag and drop files here, or click to browse", await page.getByTestId("urlToCrawlInput").fill("https://quivr.app");
}) await page.getByTestId("urlToCrawlInput").press("Enter");
.click(); await page.getByTestId("urlToCrawlInput").fill("https://google.fr");
await page.getByPlaceholder("Insert website URL").click(); await page.getByTestId("urlToCrawlInputSubmit").click();
await page.getByPlaceholder("Insert website URL").fill("https://quivr.app"); await page.getByTestId("submit-feed-button").click();
await page.getByPlaceholder("Insert website URL").press("Enter"); await page.getByTestId("feed-card").isHidden();
}); });
}; };

View File

@ -20,5 +20,5 @@ export const login = async (page: Page): Promise<void> => {
await page.getByPlaceholder("Email").fill(email); await page.getByPlaceholder("Email").fill(email);
await page.getByPlaceholder("Password").fill(password); await page.getByPlaceholder("Password").fill(password);
await page.getByTestId("submit-login").click(); await page.getByTestId("submit-login").click();
await page.waitForURL(/chat/); await page.getByTestId("chat-page").isVisible();
}; };

View File

@ -33,6 +33,7 @@ export const KnowledgeToFeedInput = ({
disabled={knowledgeToFeed.length === 0} disabled={knowledgeToFeed.length === 0}
className="rounded-xl bg-primary border-white" className="rounded-xl bg-primary border-white"
onClick={() => void feedBrain()} onClick={() => void feedBrain()}
data-testid="submit-feed-button"
> >
{t("feed_form_submit_button", { ns: "upload" })} {t("feed_form_submit_button", { ns: "upload" })}
</Button> </Button>

View File

@ -25,12 +25,13 @@ export const Crawler = (): JSX.Element => {
name="crawlurl" name="crawlurl"
ref={urlInputRef} ref={urlInputRef}
type="text" type="text"
data-testid="urlToCrawlInput"
placeholder={t("webSite", { ns: "upload" })} placeholder={t("webSite", { ns: "upload" })}
className="w-full" className="w-full"
value={urlToCrawl} value={urlToCrawl}
onChange={(e) => setUrlToCrawl(e.target.value)} onChange={(e) => setUrlToCrawl(e.target.value)}
icon={ icon={
<Button variant={"tertiary"}> <Button data-testid="urlToCrawlInputSubmit" variant={"tertiary"}>
<MdSend /> <MdSend />
</Button> </Button>
} }

View File

@ -3,7 +3,11 @@ import Link from "next/link";
export const Logo = (): JSX.Element => { export const Logo = (): JSX.Element => {
return ( return (
<Link href={"/chat"} className="flex items-center gap-4"> <Link
data-testid="app-logo"
href={"/chat"}
className="flex items-center gap-4"
>
<Image <Image
className="rounded-full" className="rounded-full"
src={"/logo.png"} src={"/logo.png"}

View File

@ -23,5 +23,6 @@ export default defineConfig({
process.env.NODE_ENV === "production" process.env.NODE_ENV === "production"
? "yarn run build && yarn run start -p 3003" ? "yarn run build && yarn run start -p 3003"
: "yarn run dev -p 3003", : "yarn run dev -p 3003",
url: process.env.NEXT_PUBLIC_E2E_URL,
}, },
}); });

View File

@ -45,5 +45,6 @@
"set_brain_status_to_private_modal_description":"Every Quivr users won't be able to use this brain anymore and they won't see it in the brain library.", "set_brain_status_to_private_modal_description":"Every Quivr users won't be able to use this brain anymore and they won't see it in the brain library.",
"confirm_set_brain_status_to_private":"Yes, set as private", "confirm_set_brain_status_to_private":"Yes, set as private",
"cancel_set_brain_status_to_private":"No, keep it public", "cancel_set_brain_status_to_private":"No, keep it public",
"empty_brain_description":"No description" "empty_brain_description":"No description",
"myBrains":"My Brains"
} }

View File

@ -45,5 +45,6 @@
"confirm_set_brain_status_to_private": "Sí, establecer como privado", "confirm_set_brain_status_to_private": "Sí, establecer como privado",
"cancel_set_brain_status_to_private": "No, mantenerlo público", "cancel_set_brain_status_to_private": "No, mantenerlo público",
"brain_management_button_label": "Gestionar cerebro", "brain_management_button_label": "Gestionar cerebro",
"empty_brain_description":"Sin descripción" "empty_brain_description":"Sin descripción",
"myBrains": "Mis cerebros"
} }

View File

@ -45,5 +45,6 @@
"confirm_set_brain_status_to_private": "Oui, définir comme privé", "confirm_set_brain_status_to_private": "Oui, définir comme privé",
"cancel_set_brain_status_to_private": "Non, le laisser public", "cancel_set_brain_status_to_private": "Non, le laisser public",
"brain_management_button_label": "Gestion des cerveaux", "brain_management_button_label": "Gestion des cerveaux",
"empty_brain_description":"Pas de description" "empty_brain_description":"Pas de description",
"myBrains": "Mes cerveaux"
} }

View File

@ -45,5 +45,6 @@
"confirm_set_brain_status_to_private": "Sim, definir como privado", "confirm_set_brain_status_to_private": "Sim, definir como privado",
"cancel_set_brain_status_to_private": "Não, mantê-lo público", "cancel_set_brain_status_to_private": "Não, mantê-lo público",
"brain_management_button_label": "Gerenciamento de cérebros", "brain_management_button_label": "Gerenciamento de cérebros",
"empty_brain_description":"Sem descrição" "empty_brain_description":"Sem descrição",
"myBrains": "Meus cérebros"
} }

View File

@ -45,5 +45,6 @@
"confirm_set_brain_status_to_private": "Да, установить как частное", "confirm_set_brain_status_to_private": "Да, установить как частное",
"cancel_set_brain_status_to_private": "Нет, оставить общедоступным", "cancel_set_brain_status_to_private": "Нет, оставить общедоступным",
"brain_management_button_label": "Управление мозгом", "brain_management_button_label": "Управление мозгом",
"empty_brain_description": "Нет описания" "empty_brain_description": "Нет описания",
"myBrains": "Мои мозги"
} }

View File

@ -45,5 +45,6 @@
"confirm_set_brain_status_to_private": "是的,设为私有", "confirm_set_brain_status_to_private": "是的,设为私有",
"cancel_set_brain_status_to_private": "不,保持为公开", "cancel_set_brain_status_to_private": "不,保持为公开",
"brain_management_button_label": "管理", "brain_management_button_label": "管理",
"empty_brain_description": "无描述" "empty_brain_description": "无描述",
"myBrains": "我的大脑"
} }