From 988581cb056c686c0cb4c3175183dfdd6c484f54 Mon Sep 17 00:00:00 2001 From: WenjiaoYue Date: Thu, 16 May 2024 10:47:43 +0800 Subject: [PATCH] Add UI test for ChatQnA (#134) Signed-off-by: Yue, Wenjiao --- .gitignore | 1 + ChatQnA/ui/svelte/playwright.config.ts | 2 +- .../components/upload/PasteKnowledge.svelte | 3 + .../components/upload/upload-knowledge.svelte | 1 + ChatQnA/ui/svelte/src/routes/+page.svelte | 3 +- ChatQnA/ui/svelte/tests/chatQnA.spec.ts | 63 +++++++++-- ChatQnA/ui/svelte/tests/test_file.txt | 104 ++++++++++++++++++ 7 files changed, 166 insertions(+), 11 deletions(-) create mode 100644 ChatQnA/ui/svelte/tests/test_file.txt diff --git a/.gitignore b/.gitignore index d4f57bcc..3a5650d2 100644 --- a/.gitignore +++ b/.gitignore @@ -3,5 +3,6 @@ **/package-lock.json **/playwright-report/ **/playwright/.cache/ +**/test-results/ __pycache__/ \ No newline at end of file diff --git a/ChatQnA/ui/svelte/playwright.config.ts b/ChatQnA/ui/svelte/playwright.config.ts index b574e3b4..49d09fa8 100644 --- a/ChatQnA/ui/svelte/playwright.config.ts +++ b/ChatQnA/ui/svelte/playwright.config.ts @@ -38,7 +38,7 @@ export default defineConfig({ /* Maximum time each action such as `click()` can take. Defaults to 0 (no limit). */ actionTimeout: 0, /* Base URL to use in actions like `await page.goto('/')`. */ - baseURL: "http://localhost:80", + baseURL: "http://localhost:5173", /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ trace: "on-first-retry", diff --git a/ChatQnA/ui/svelte/src/lib/shared/components/upload/PasteKnowledge.svelte b/ChatQnA/ui/svelte/src/lib/shared/components/upload/PasteKnowledge.svelte index c4a55aa4..d0758e77 100644 --- a/ChatQnA/ui/svelte/src/lib/shared/components/upload/PasteKnowledge.svelte +++ b/ChatQnA/ui/svelte/src/lib/shared/components/upload/PasteKnowledge.svelte @@ -37,10 +37,13 @@ name="text" placeholder="URL" bind:value={urlValue} + data-testid="paste-link" /> diff --git a/ChatQnA/ui/svelte/src/lib/shared/components/upload/upload-knowledge.svelte b/ChatQnA/ui/svelte/src/lib/shared/components/upload/upload-knowledge.svelte index d1eb1356..b1be9770 100644 --- a/ChatQnA/ui/svelte/src/lib/shared/components/upload/upload-knowledge.svelte +++ b/ChatQnA/ui/svelte/src/lib/shared/components/upload/upload-knowledge.svelte @@ -42,6 +42,7 @@ bind:value on:change={handleInput} class="focus:border-blue-700 focus:ring-0" + data-testid="file-upload" /> diff --git a/ChatQnA/ui/svelte/src/routes/+page.svelte b/ChatQnA/ui/svelte/src/routes/+page.svelte index 77c37a9b..e66871e5 100644 --- a/ChatQnA/ui/svelte/src/routes/+page.svelte +++ b/ChatQnA/ui/svelte/src/routes/+page.svelte @@ -177,7 +177,7 @@ class="text-md block w-full border-0 border-b-2 border-gray-300 px-1 py-4 text-gray-900 focus:border-gray-300 focus:ring-0 dark:border-gray-600 dark:bg-gray-700 dark:text-white dark:placeholder-gray-400 dark:focus:border-blue-500 dark:focus:ring-blue-500" type="text" - id="chat-input" + data-testid="chat-input" placeholder="Enter prompt here" disabled={loading} maxlength="1200" @@ -211,6 +211,7 @@