From 70207b4b39c82a7268bf6b75f5f2ab38c375596c Mon Sep 17 00:00:00 2001 From: rkuo-danswer Date: Wed, 20 Nov 2024 20:01:15 -0800 Subject: [PATCH] improve web testing (#3162) * shared admin level test dependency * change to on - push (recommended by chromatic) * change playwright reporter to list, name test jobs * use test tags ... much cleaner * test vs prod * try copying templates * run with localhost? * revert to dev * new tests and a bit of refactoring * add additional checks so that page snapshots reflect loaded state * more admin tests * User Management tests * remaining admin pages * test search and chat * await fix and exclude UI that changes with dates. --- .github/workflows/pr-chromatic-tests.yml | 14 ++++---- deployment/docker_compose/README.md | 2 +- web/.gitignore | 4 +++ web/playwright.config.ts | 30 ++++++++++++++-- web/src/app/admin/api-key/page.tsx | 4 +-- web/tests/e2e/admin_add_connector.spec.ts | 14 ++++++++ web/tests/e2e/admin_api_key.spec.ts | 19 ++++++++++ web/tests/e2e/admin_assistants.spec.ts | 16 +++++++++ web/tests/e2e/admin_auth.setup.ts | 24 +++++++++++++ web/tests/e2e/admin_bots.spec.ts | 16 +++++++++ ..._configuration_document_processing.spec.ts | 18 ++++++++++ web/tests/e2e/admin_configuration_llm.spec.ts | 16 +++++++++ .../e2e/admin_configuration_search.spec.ts | 16 +++++++++ .../e2e/admin_documents_explorer.spec.ts | 16 +++++++++ .../e2e/admin_documents_feedback.spec.ts | 19 ++++++++++ web/tests/e2e/admin_documents_sets.spec.ts | 16 +++++++++ web/tests/e2e/admin_groups.spec.ts | 16 +++++++++ web/tests/e2e/admin_indexing_status.spec.ts | 16 +++++++++ ...admin_performance_custom_analytics.spec.ts | 16 +++++++++ .../admin_performance_query_history.spec.ts | 14 ++++++++ web/tests/e2e/admin_performance_usage.spec.ts | 19 ++++++++++ web/tests/e2e/admin_prompt_library.spec.ts | 16 +++++++++ web/tests/e2e/admin_settings.spec.ts | 19 ++++++++++ web/tests/e2e/admin_standard_answer.spec.ts | 16 +++++++++ web/tests/e2e/admin_token_rate_limits.spec.ts | 22 ++++++++++++ web/tests/e2e/admin_tools.spec.ts | 16 +++++++++ web/tests/e2e/admin_users.spec.ts | 19 ++++++++++ web/tests/e2e/admin_whitelabeling.spec.ts | 18 ++++++++++ web/tests/e2e/chat.spec.ts | 19 ++++++++++ web/tests/e2e/constants.js | 5 +++ web/tests/e2e/home.spec.ts | 36 ++++++++++--------- web/tests/e2e/search.spec.ts | 19 ++++++++++ 32 files changed, 500 insertions(+), 30 deletions(-) create mode 100644 web/tests/e2e/admin_add_connector.spec.ts create mode 100644 web/tests/e2e/admin_api_key.spec.ts create mode 100644 web/tests/e2e/admin_assistants.spec.ts create mode 100644 web/tests/e2e/admin_auth.setup.ts create mode 100644 web/tests/e2e/admin_bots.spec.ts create mode 100644 web/tests/e2e/admin_configuration_document_processing.spec.ts create mode 100644 web/tests/e2e/admin_configuration_llm.spec.ts create mode 100644 web/tests/e2e/admin_configuration_search.spec.ts create mode 100644 web/tests/e2e/admin_documents_explorer.spec.ts create mode 100644 web/tests/e2e/admin_documents_feedback.spec.ts create mode 100644 web/tests/e2e/admin_documents_sets.spec.ts create mode 100644 web/tests/e2e/admin_groups.spec.ts create mode 100644 web/tests/e2e/admin_indexing_status.spec.ts create mode 100644 web/tests/e2e/admin_performance_custom_analytics.spec.ts create mode 100644 web/tests/e2e/admin_performance_query_history.spec.ts create mode 100644 web/tests/e2e/admin_performance_usage.spec.ts create mode 100644 web/tests/e2e/admin_prompt_library.spec.ts create mode 100644 web/tests/e2e/admin_settings.spec.ts create mode 100644 web/tests/e2e/admin_standard_answer.spec.ts create mode 100644 web/tests/e2e/admin_token_rate_limits.spec.ts create mode 100644 web/tests/e2e/admin_tools.spec.ts create mode 100644 web/tests/e2e/admin_users.spec.ts create mode 100644 web/tests/e2e/admin_whitelabeling.spec.ts create mode 100644 web/tests/e2e/chat.spec.ts create mode 100644 web/tests/e2e/constants.js create mode 100644 web/tests/e2e/search.spec.ts diff --git a/.github/workflows/pr-chromatic-tests.yml b/.github/workflows/pr-chromatic-tests.yml index 4bbab9522b0..5d8b29ed572 100644 --- a/.github/workflows/pr-chromatic-tests.yml +++ b/.github/workflows/pr-chromatic-tests.yml @@ -3,12 +3,7 @@ concurrency: group: Run-Chromatic-Tests-${{ github.workflow }}-${{ github.head_ref || github.event.workflow_run.head_branch || github.run_id }} cancel-in-progress: true -on: - merge_group: - pull_request: - branches: - - main - - 'release/**' +on: push env: OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} @@ -16,6 +11,8 @@ env: jobs: playwright-tests: + name: Playwright Tests + # See https://runs-on.com/runners/linux/ runs-on: [runs-on,runner=8cpu-linux-x64,ram=16,"run-id=${{ github.run_id }}"] steps: @@ -108,7 +105,7 @@ jobs: cache-from: type=s3,prefix=cache/${{ github.repository }}/integration-tests/model-server/,region=${{ env.RUNS_ON_AWS_REGION }},bucket=${{ env.RUNS_ON_S3_BUCKET_CACHE }} cache-to: type=s3,prefix=cache/${{ github.repository }}/integration-tests/model-server/,region=${{ env.RUNS_ON_AWS_REGION }},bucket=${{ env.RUNS_ON_S3_BUCKET_CACHE }},mode=max - - name: Start Docker containers + - name: Start Docker containers run: | cd deployment/docker_compose ENABLE_PAID_ENTERPRISE_EDITION_FEATURES=true \ @@ -193,7 +190,8 @@ jobs: docker compose -f docker-compose.dev.yml -p danswer-stack down -v chromatic-tests: - name: Run Chromatic + name: Chromatic Tests + needs: playwright-tests runs-on: [runs-on,runner=8cpu-linux-x64,ram=16,"run-id=${{ github.run_id }}"] steps: diff --git a/deployment/docker_compose/README.md b/deployment/docker_compose/README.md index a5f650b5303..60d8824ca51 100644 --- a/deployment/docker_compose/README.md +++ b/deployment/docker_compose/README.md @@ -5,7 +5,7 @@ For general information, please read the instructions in this [README](https://github.com/danswer-ai/danswer/blob/main/deployment/README.md). ## Deploy in a system without GPU support -This part is elaborated precisely in in this [README](https://github.com/danswer-ai/danswer/blob/main/deployment/README.md) in section *Docker Compose*. If you have any questions, please feel free to open an issue or get in touch in slack for support. +This part is elaborated precisely in this [README](https://github.com/danswer-ai/danswer/blob/main/deployment/README.md) in section *Docker Compose*. If you have any questions, please feel free to open an issue or get in touch in slack for support. ## Deploy in a system with GPU support Running Model servers with GPU support while indexing and querying can result in significant improvements in performance. This is highly recommended if you have access to resources. Currently, Danswer offloads embedding model and tokenizers to the GPU VRAM and the size needed depends on chosen embedding model. For example, the embedding model `nomic-ai/nomic-embed-text-v1` takes up about 1GB of VRAM. That means running this model for inference and embedding pipeline would require roughly 2GB of VRAM. diff --git a/web/.gitignore b/web/.gitignore index e2a2a775c3b..c72b98d4429 100644 --- a/web/.gitignore +++ b/web/.gitignore @@ -34,3 +34,7 @@ yarn-error.log* # typescript *.tsbuildinfo next-env.d.ts + +/admin_auth.json +/build-archive.log + diff --git a/web/playwright.config.ts b/web/playwright.config.ts index ccb4d5640c2..76101a65e1e 100644 --- a/web/playwright.config.ts +++ b/web/playwright.config.ts @@ -1,8 +1,8 @@ -import { defineConfig } from "@playwright/test"; +import { defineConfig, devices } from "@playwright/test"; export default defineConfig({ - // Other Playwright config options testDir: "./tests/e2e", // Folder for test files + reporter: "list", // Configure paths for screenshots // expect: { // toMatchSnapshot: { @@ -11,4 +11,30 @@ export default defineConfig({ // }, // reporter: [["html", { outputFolder: "test-results/output/report" }]], // HTML report location // outputDir: "test-results/output/screenshots", // Set output folder for test artifacts + projects: [ + { + // dependency for admin workflows + name: "admin_setup", + testMatch: /.*\admin_auth.setup\.ts/, + }, + { + // tests admin workflows + name: "chromium-admin", + grep: /@admin/, + use: { + ...devices["Desktop Chrome"], + // Use prepared auth state. + storageState: "admin_auth.json", + }, + dependencies: ["admin_setup"], + }, + { + // tests logged out / guest workflows + name: "chromium-guest", + grep: /@guest/, + use: { + ...devices["Desktop Chrome"], + }, + }, + ], }); diff --git a/web/src/app/admin/api-key/page.tsx b/web/src/app/admin/api-key/page.tsx index 1420a1c518b..c0d16bc850a 100644 --- a/web/src/app/admin/api-key/page.tsx +++ b/web/src/app/admin/api-key/page.tsx @@ -29,9 +29,7 @@ import { deleteApiKey, regenerateApiKey } from "./lib"; import { DanswerApiKeyForm } from "./DanswerApiKeyForm"; import { APIKey } from "./types"; -const API_KEY_TEXT = ` -API Keys allow you to access Danswer APIs programmatically. Click the button below to generate a new API Key. -`; +const API_KEY_TEXT = `API Keys allow you to access Danswer APIs programmatically. Click the button below to generate a new API Key.`; function NewApiKeyModal({ apiKey, diff --git a/web/tests/e2e/admin_add_connector.spec.ts b/web/tests/e2e/admin_add_connector.spec.ts new file mode 100644 index 00000000000..2385aed327e --- /dev/null +++ b/web/tests/e2e/admin_add_connector.spec.ts @@ -0,0 +1,14 @@ +import { test, expect } from "@chromatic-com/playwright"; + +test( + "Admin - Connectors - Add Connector", + { + tag: "@admin", + }, + async ({ page }, testInfo) => { + // Test simple loading + await page.goto("http://localhost:3000/admin/add-connector"); + await expect(page.locator("h1.text-3xl")).toHaveText("Add Connector"); + await expect(page.locator("h1.text-lg").nth(0)).toHaveText(/^Storage/); + } +); diff --git a/web/tests/e2e/admin_api_key.spec.ts b/web/tests/e2e/admin_api_key.spec.ts new file mode 100644 index 00000000000..46ada8d6464 --- /dev/null +++ b/web/tests/e2e/admin_api_key.spec.ts @@ -0,0 +1,19 @@ +import { test, expect } from "@chromatic-com/playwright"; + +test( + "Admin - User Management - API Keys", + { + tag: "@admin", + }, + async ({ page }, testInfo) => { + // Test simple loading + await page.goto("http://localhost:3000/admin/api-key"); + await expect(page.locator("h1.text-3xl")).toHaveText("API Keys"); + await expect(page.locator("p.text-sm")).toHaveText( + /^API Keys allow you to access Danswer APIs programmatically/ + ); + await expect( + page.getByRole("button", { name: "Create API Key" }) + ).toHaveCount(1); + } +); diff --git a/web/tests/e2e/admin_assistants.spec.ts b/web/tests/e2e/admin_assistants.spec.ts new file mode 100644 index 00000000000..308d0975e36 --- /dev/null +++ b/web/tests/e2e/admin_assistants.spec.ts @@ -0,0 +1,16 @@ +import { test, expect } from "@chromatic-com/playwright"; + +test( + "Admin - Custom Assistants - Assistants", + { + tag: "@admin", + }, + async ({ page }, testInfo) => { + // Test simple loading + await page.goto("http://localhost:3000/admin/assistants"); + await expect(page.locator("h1.text-3xl")).toHaveText("Assistants"); + await expect(page.locator("p.text-sm").nth(0)).toHaveText( + /^Assistants are a way to build/ + ); + } +); diff --git a/web/tests/e2e/admin_auth.setup.ts b/web/tests/e2e/admin_auth.setup.ts new file mode 100644 index 00000000000..6eb891eba92 --- /dev/null +++ b/web/tests/e2e/admin_auth.setup.ts @@ -0,0 +1,24 @@ +// dependency for all admin user tests + +import { test as setup, expect } from "@playwright/test"; +import { TEST_CREDENTIALS } from "./constants"; + +setup("authenticate", async ({ page }) => { + const { email, password } = TEST_CREDENTIALS; + + await page.goto("http://localhost:3000/search"); + + await page.waitForURL("http://localhost:3000/auth/login?next=%2Fsearch"); + + await expect(page).toHaveTitle("Danswer"); + + await page.fill("#email", email); + await page.fill("#password", password); + + // Click the login button + await page.click('button[type="submit"]'); + + await page.waitForURL("http://localhost:3000/search"); + + await page.context().storageState({ path: "admin_auth.json" }); +}); diff --git a/web/tests/e2e/admin_bots.spec.ts b/web/tests/e2e/admin_bots.spec.ts new file mode 100644 index 00000000000..e577696a546 --- /dev/null +++ b/web/tests/e2e/admin_bots.spec.ts @@ -0,0 +1,16 @@ +import { test, expect } from "@chromatic-com/playwright"; + +test( + "Admin - Custom Assistants - Slack Bots", + { + tag: "@admin", + }, + async ({ page }, testInfo) => { + // Test simple loading + await page.goto("http://localhost:3000/admin/bots"); + await expect(page.locator("h1.text-3xl")).toHaveText("Slack Bots"); + await expect(page.locator("p.text-sm").nth(0)).toHaveText( + /^Setup Slack bots that connect to Danswer./ + ); + } +); diff --git a/web/tests/e2e/admin_configuration_document_processing.spec.ts b/web/tests/e2e/admin_configuration_document_processing.spec.ts new file mode 100644 index 00000000000..3d9f6ce7a9b --- /dev/null +++ b/web/tests/e2e/admin_configuration_document_processing.spec.ts @@ -0,0 +1,18 @@ +import { test, expect } from "@chromatic-com/playwright"; + +test( + "Admin - Configuration - Document Processing", + { + tag: "@admin", + }, + async ({ page }, testInfo) => { + // Test simple loading + await page.goto( + "http://localhost:3000/admin/configuration/document-processing" + ); + await expect(page.locator("h1.text-3xl")).toHaveText("Document Processing"); + await expect(page.locator("h3.text-2xl")).toHaveText( + "Process with Unstructured API" + ); + } +); diff --git a/web/tests/e2e/admin_configuration_llm.spec.ts b/web/tests/e2e/admin_configuration_llm.spec.ts new file mode 100644 index 00000000000..aa5b3957179 --- /dev/null +++ b/web/tests/e2e/admin_configuration_llm.spec.ts @@ -0,0 +1,16 @@ +import { test, expect } from "@chromatic-com/playwright"; + +test( + "Admin - Configuration - LLM", + { + tag: "@admin", + }, + async ({ page }, testInfo) => { + // Test simple loading + await page.goto("http://localhost:3000/admin/configuration/llm"); + await expect(page.locator("h1.text-3xl")).toHaveText("LLM Setup"); + await expect(page.locator("h1.text-lg").nth(0)).toHaveText( + "Enabled LLM Providers" + ); + } +); diff --git a/web/tests/e2e/admin_configuration_search.spec.ts b/web/tests/e2e/admin_configuration_search.spec.ts new file mode 100644 index 00000000000..57309a71414 --- /dev/null +++ b/web/tests/e2e/admin_configuration_search.spec.ts @@ -0,0 +1,16 @@ +import { test, expect } from "@chromatic-com/playwright"; + +test( + "Admin - Configuration - Search Settings", + { + tag: "@admin", + }, + async ({ page }, testInfo) => { + // Test simple loading + await page.goto("http://localhost:3000/admin/configuration/search"); + await expect(page.locator("h1.text-3xl")).toHaveText("Search Settings"); + await expect(page.locator("h1.text-lg").nth(0)).toHaveText( + "Embedding Model" + ); + } +); diff --git a/web/tests/e2e/admin_documents_explorer.spec.ts b/web/tests/e2e/admin_documents_explorer.spec.ts new file mode 100644 index 00000000000..0b4d5ae93ae --- /dev/null +++ b/web/tests/e2e/admin_documents_explorer.spec.ts @@ -0,0 +1,16 @@ +import { test, expect } from "@chromatic-com/playwright"; + +test( + "Admin - Document Management - Feedback", + { + tag: "@admin", + }, + async ({ page }, testInfo) => { + // Test simple loading + await page.goto("http://localhost:3000/admin/documents/explorer"); + await expect(page.locator("h1.text-3xl")).toHaveText("Document Explorer"); + await expect(page.locator("div.flex.text-emphasis.mt-3")).toHaveText( + "Search for a document above to modify its boost or hide it from searches." + ); + } +); diff --git a/web/tests/e2e/admin_documents_feedback.spec.ts b/web/tests/e2e/admin_documents_feedback.spec.ts new file mode 100644 index 00000000000..4f19cea998e --- /dev/null +++ b/web/tests/e2e/admin_documents_feedback.spec.ts @@ -0,0 +1,19 @@ +import { test, expect } from "@chromatic-com/playwright"; + +test( + "Admin - Document Management - Feedback", + { + tag: "@admin", + }, + async ({ page }, testInfo) => { + // Test simple loading + await page.goto("http://localhost:3000/admin/documents/feedback"); + await expect(page.locator("h1.text-3xl")).toHaveText("Document Feedback"); + await expect(page.locator("h1.text-lg").nth(0)).toHaveText( + "Most Liked Documents" + ); + await expect(page.locator("h1.text-lg").nth(1)).toHaveText( + "Most Disliked Documents" + ); + } +); diff --git a/web/tests/e2e/admin_documents_sets.spec.ts b/web/tests/e2e/admin_documents_sets.spec.ts new file mode 100644 index 00000000000..ac7d718fb70 --- /dev/null +++ b/web/tests/e2e/admin_documents_sets.spec.ts @@ -0,0 +1,16 @@ +import { test, expect } from "@chromatic-com/playwright"; + +test( + "Admin - Document Management - Document Sets", + { + tag: "@admin", + }, + async ({ page }, testInfo) => { + // Test simple loading + await page.goto("http://localhost:3000/admin/documents/sets"); + await expect(page.locator("h1.text-3xl")).toHaveText("Document Sets"); + await expect(page.locator("p.text-sm")).toHaveText( + /^Document Sets allow you to group logically connected documents into a single bundle./ + ); + } +); diff --git a/web/tests/e2e/admin_groups.spec.ts b/web/tests/e2e/admin_groups.spec.ts new file mode 100644 index 00000000000..8e192bb8b43 --- /dev/null +++ b/web/tests/e2e/admin_groups.spec.ts @@ -0,0 +1,16 @@ +import { test, expect } from "@chromatic-com/playwright"; + +test( + "Admin - User Management - Groups", + { + tag: "@admin", + }, + async ({ page }, testInfo) => { + // Test simple loading + await page.goto("http://localhost:3000/admin/groups"); + await expect(page.locator("h1.text-3xl")).toHaveText("Manage User Groups"); + await expect( + page.getByRole("button", { name: "Create New User Group" }) + ).toHaveCount(1); + } +); diff --git a/web/tests/e2e/admin_indexing_status.spec.ts b/web/tests/e2e/admin_indexing_status.spec.ts new file mode 100644 index 00000000000..c5b6bacc2bd --- /dev/null +++ b/web/tests/e2e/admin_indexing_status.spec.ts @@ -0,0 +1,16 @@ +import { test, expect } from "@chromatic-com/playwright"; + +test( + "Admin - Connectors - Existing Connectors", + { + tag: "@admin", + }, + async ({ page }, testInfo) => { + // Test simple loading + await page.goto("http://localhost:3000/admin/indexing/status"); + await expect(page.locator("h1.text-3xl")).toHaveText("Existing Connectors"); + await expect(page.locator("p.text-sm")).toHaveText( + /^It looks like you don't have any connectors setup yet./ + ); + } +); diff --git a/web/tests/e2e/admin_performance_custom_analytics.spec.ts b/web/tests/e2e/admin_performance_custom_analytics.spec.ts new file mode 100644 index 00000000000..8f66ca6ac6d --- /dev/null +++ b/web/tests/e2e/admin_performance_custom_analytics.spec.ts @@ -0,0 +1,16 @@ +import { test, expect } from "@chromatic-com/playwright"; + +test( + "Admin - Performance - Custom Analytics", + { + tag: "@admin", + }, + async ({ page }, testInfo) => { + // Test simple loading + await page.goto("http://localhost:3000/admin/performance/custom-analytics"); + await expect(page.locator("h1.text-3xl")).toHaveText("Custom Analytics"); + await expect(page.locator("div.font-medium").nth(0)).toHaveText( + "Custom Analytics is not enabled." + ); + } +); diff --git a/web/tests/e2e/admin_performance_query_history.spec.ts b/web/tests/e2e/admin_performance_query_history.spec.ts new file mode 100644 index 00000000000..0362b1a57af --- /dev/null +++ b/web/tests/e2e/admin_performance_query_history.spec.ts @@ -0,0 +1,14 @@ +import { test, expect } from "@chromatic-com/playwright"; + +test( + "Admin - Performance - Query History", + { + tag: "@admin", + }, + async ({ page }, testInfo) => { + // Test simple loading + await page.goto("http://localhost:3000/admin/performance/query-history"); + await expect(page.locator("h1.text-3xl")).toHaveText("Query History"); + await expect(page.locator("p.text-sm").nth(0)).toHaveText("Feedback Type"); + } +); diff --git a/web/tests/e2e/admin_performance_usage.spec.ts b/web/tests/e2e/admin_performance_usage.spec.ts new file mode 100644 index 00000000000..f1eff8f3080 --- /dev/null +++ b/web/tests/e2e/admin_performance_usage.spec.ts @@ -0,0 +1,19 @@ +import { test, expect } from "@chromatic-com/playwright"; + +test.describe("Admin Performance Usage", () => { + // Ignores the diff for elements targeted by the specified list of selectors + test.use({ ignoreSelectors: ["button", "svg"] }); + + test( + "Admin - Performance - Usage Statistics", + { + tag: "@admin", + }, + async ({ page }, testInfo) => { + await page.goto("http://localhost:3000/admin/performance/usage"); + await expect(page.locator("h1.text-3xl")).toHaveText("Usage Statistics"); + await expect(page.locator("h1.text-lg").nth(0)).toHaveText("Usage"); + await expect(page.locator("h1.text-lg").nth(1)).toHaveText("Feedback"); + } + ); +}); diff --git a/web/tests/e2e/admin_prompt_library.spec.ts b/web/tests/e2e/admin_prompt_library.spec.ts new file mode 100644 index 00000000000..c5755bbdae4 --- /dev/null +++ b/web/tests/e2e/admin_prompt_library.spec.ts @@ -0,0 +1,16 @@ +import { test, expect } from "@chromatic-com/playwright"; + +test( + "Admin - Custom Assistants - Prompt Library", + { + tag: "@admin", + }, + async ({ page }, testInfo) => { + // Test simple loading + await page.goto("http://localhost:3000/admin/prompt-library"); + await expect(page.locator("h1.text-3xl")).toHaveText("Prompt Library"); + await expect(page.locator("p.text-sm")).toHaveText( + /^Create prompts that can be accessed/ + ); + } +); diff --git a/web/tests/e2e/admin_settings.spec.ts b/web/tests/e2e/admin_settings.spec.ts new file mode 100644 index 00000000000..79c8e0d1233 --- /dev/null +++ b/web/tests/e2e/admin_settings.spec.ts @@ -0,0 +1,19 @@ +import { test, expect } from "@chromatic-com/playwright"; + +test( + "Admin - Settings - Workspace Settings", + { + tag: "@admin", + }, + async ({ page }, testInfo) => { + // Test simple loading + await page.goto("http://localhost:3000/admin/settings"); + await expect(page.locator("h1.text-3xl")).toHaveText("Workspace Settings"); + await expect(page.locator("p.text-sm").nth(0)).toHaveText( + /^Manage general Danswer settings applicable to all users in the workspace./ + ); + await expect( + page.getByRole("button", { name: "Set Retention Limit" }) + ).toHaveCount(1); + } +); diff --git a/web/tests/e2e/admin_standard_answer.spec.ts b/web/tests/e2e/admin_standard_answer.spec.ts new file mode 100644 index 00000000000..3a265f1b72a --- /dev/null +++ b/web/tests/e2e/admin_standard_answer.spec.ts @@ -0,0 +1,16 @@ +import { test, expect } from "@chromatic-com/playwright"; + +test( + "Admin - Custom Assistants - Standard Answers", + { + tag: "@admin", + }, + async ({ page }, testInfo) => { + // Test simple loading + await page.goto("http://localhost:3000/admin/standard-answer"); + await expect(page.locator("h1.text-3xl")).toHaveText("Standard Answers"); + await expect(page.locator("p.text-sm").nth(0)).toHaveText( + /^Manage the standard answers for pre-defined questions./ + ); + } +); diff --git a/web/tests/e2e/admin_token_rate_limits.spec.ts b/web/tests/e2e/admin_token_rate_limits.spec.ts new file mode 100644 index 00000000000..359673c4e47 --- /dev/null +++ b/web/tests/e2e/admin_token_rate_limits.spec.ts @@ -0,0 +1,22 @@ +import { test, expect } from "@chromatic-com/playwright"; + +test( + "Admin - User Management - Token Rate Limits", + { + tag: "@admin", + }, + async ({ page }, testInfo) => { + // Test simple loading + await page.goto("http://localhost:3000/admin/token-rate-limits"); + await expect(page.locator("h1.text-3xl")).toHaveText("Token Rate Limits"); + await expect(page.locator("p.text-sm").nth(0)).toHaveText( + /^Token rate limits enable you control how many tokens can be spent in a given time period./ + ); + await expect( + page.getByRole("button", { name: "Create a Token Rate Limit" }) + ).toHaveCount(1); + await expect(page.locator("h1.text-lg")).toHaveText( + "Global Token Rate Limits" + ); + } +); diff --git a/web/tests/e2e/admin_tools.spec.ts b/web/tests/e2e/admin_tools.spec.ts new file mode 100644 index 00000000000..87152b9836b --- /dev/null +++ b/web/tests/e2e/admin_tools.spec.ts @@ -0,0 +1,16 @@ +import { test, expect } from "@chromatic-com/playwright"; + +test( + "Admin - Custom Assistants - Tools", + { + tag: "@admin", + }, + async ({ page }, testInfo) => { + // Test simple loading + await page.goto("http://localhost:3000/admin/tools"); + await expect(page.locator("h1.text-3xl")).toHaveText("Tools"); + await expect(page.locator("p.text-sm")).toHaveText( + "Tools allow assistants to retrieve information or take actions." + ); + } +); diff --git a/web/tests/e2e/admin_users.spec.ts b/web/tests/e2e/admin_users.spec.ts new file mode 100644 index 00000000000..6ec4c803c8d --- /dev/null +++ b/web/tests/e2e/admin_users.spec.ts @@ -0,0 +1,19 @@ +import { test, expect } from "@chromatic-com/playwright"; + +test( + "Admin - User Management - Groups", + { + tag: "@admin", + }, + async ({ page }, testInfo) => { + // Test simple loading + await page.goto("http://localhost:3000/admin/users"); + await expect(page.locator("h1.text-3xl")).toHaveText("Manage Users"); + await expect(page.locator("div.font-bold").nth(0)).toHaveText( + "Invited Users" + ); + await expect(page.locator("div.font-bold").nth(1)).toHaveText( + "Current Users" + ); + } +); diff --git a/web/tests/e2e/admin_whitelabeling.spec.ts b/web/tests/e2e/admin_whitelabeling.spec.ts new file mode 100644 index 00000000000..2e49e52d145 --- /dev/null +++ b/web/tests/e2e/admin_whitelabeling.spec.ts @@ -0,0 +1,18 @@ +import { test, expect } from "@chromatic-com/playwright"; + +test( + "Admin - Performance - Whitelabeling", + { + tag: "@admin", + }, + async ({ page }, testInfo) => { + // Test simple loading + await page.goto("http://localhost:3000/admin/whitelabeling"); + await expect(page.locator("h1.text-3xl")).toHaveText("Whitelabeling"); + await expect(page.locator("div.block").nth(0)).toHaveText( + "Application Name" + ); + await expect(page.locator("div.block").nth(1)).toHaveText("Custom Logo"); + await expect(page.getByRole("button", { name: "Update" })).toHaveCount(1); + } +); diff --git a/web/tests/e2e/chat.spec.ts b/web/tests/e2e/chat.spec.ts new file mode 100644 index 00000000000..e1e720f3dfd --- /dev/null +++ b/web/tests/e2e/chat.spec.ts @@ -0,0 +1,19 @@ +import { test, expect } from "@chromatic-com/playwright"; + +test( + "Chat", + { + tag: "@admin", + }, + async ({ page }, testInfo) => { + // Test simple loading + await page.goto("http://localhost:3000/chat"); + await expect(page.locator("div.text-2xl").nth(0)).toHaveText("General"); + await expect(page.getByRole("button", { name: "Search S" })).toHaveClass( + /text-text-application-untoggled/ + ); + await expect(page.getByRole("button", { name: "Chat D" })).toHaveClass( + /text-text-application-toggled/ + ); + } +); diff --git a/web/tests/e2e/constants.js b/web/tests/e2e/constants.js new file mode 100644 index 00000000000..d6f5f457c3b --- /dev/null +++ b/web/tests/e2e/constants.js @@ -0,0 +1,5 @@ +// constants.js +export const TEST_CREDENTIALS = { + email: "admin_user@test.com", + password: "test", +}; diff --git a/web/tests/e2e/home.spec.ts b/web/tests/e2e/home.spec.ts index a0adf7bc5dc..d2f87a2d21d 100644 --- a/web/tests/e2e/home.spec.ts +++ b/web/tests/e2e/home.spec.ts @@ -1,27 +1,31 @@ // ➕ Add this line import { test, expect, takeSnapshot } from "@chromatic-com/playwright"; +import { TEST_CREDENTIALS } from "./constants"; // Then use as normal 👇 -test("Homepage", async ({ page }, testInfo) => { - // Test redirect to login, and redirect to search after login +test( + "Homepage", + { + tag: "@guest", + }, + async ({ page }, testInfo) => { + // Test redirect to login, and redirect to search after login + const { email, password } = TEST_CREDENTIALS; - // move these into a constants file or test fixture soon - let email = "admin_user@test.com"; - let password = "test"; + await page.goto("http://localhost:3000/search"); - await page.goto("http://localhost:3000/search"); + await page.waitForURL("http://localhost:3000/auth/login?next=%2Fsearch"); - await page.waitForURL("http://localhost:3000/auth/login?next=%2Fsearch"); + await expect(page).toHaveTitle("Danswer"); - await expect(page).toHaveTitle("Danswer"); + await takeSnapshot(page, "Before login", testInfo); - await takeSnapshot(page, "Before login", testInfo); + await page.fill("#email", email); + await page.fill("#password", password); - await page.fill("#email", email); - await page.fill("#password", password); + // Click the login button + await page.click('button[type="submit"]'); - // Click the login button - await page.click('button[type="submit"]'); - - await page.waitForURL("http://localhost:3000/search"); -}); + await page.waitForURL("http://localhost:3000/search"); + } +); diff --git a/web/tests/e2e/search.spec.ts b/web/tests/e2e/search.spec.ts new file mode 100644 index 00000000000..2b4a212479e --- /dev/null +++ b/web/tests/e2e/search.spec.ts @@ -0,0 +1,19 @@ +import { test, expect } from "@chromatic-com/playwright"; + +test( + "Search", + { + tag: "@admin", + }, + async ({ page }, testInfo) => { + // Test simple loading + await page.goto("http://localhost:3000/search"); + await expect(page.locator("div.text-3xl")).toHaveText("Unlock Knowledge"); + await expect(page.getByRole("button", { name: "Search S" })).toHaveClass( + /text-text-application-toggled/ + ); + await expect(page.getByRole("button", { name: "Chat D" })).toHaveClass( + /text-text-application-untoggled/ + ); + } +);