organize fe tests

This commit is contained in:
pablodanswer 2024-12-13 12:05:10 -08:00
parent 40719eb542
commit a6ab8a8da4
35 changed files with 209 additions and 395 deletions

View File

@ -111,6 +111,7 @@ jobs:
cd deployment/docker_compose
ENABLE_PAID_ENTERPRISE_EDITION_FEATURES=true \
AUTH_TYPE=basic \
GEN_AI_API_KEY=${{ secrets.OPENAI_API_KEY }} \
REQUIRE_EMAIL_VERIFICATION=false \
DISABLE_TELEMETRY=true \
IMAGE_TAG=test \

View File

@ -47,6 +47,7 @@ services:
- LITELLM_EXTRA_HEADERS=${LITELLM_EXTRA_HEADERS:-}
- BING_API_KEY=${BING_API_KEY:-}
- DISABLE_LLM_DOC_RELEVANCE=${DISABLE_LLM_DOC_RELEVANCE:-}
- GEN_AI_API_KEY=${GEN_AI_API_KEY:-}
# if set, allows for the use of the token budget system
- TOKEN_BUDGET_GLOBALLY_ENABLED=${TOKEN_BUDGET_GLOBALLY_ENABLED:-}
# Enables the use of bedrock models
@ -141,6 +142,7 @@ services:
- GENERATIVE_MODEL_ACCESS_CHECK_FREQ=${GENERATIVE_MODEL_ACCESS_CHECK_FREQ:-}
- DISABLE_LITELLM_STREAMING=${DISABLE_LITELLM_STREAMING:-}
- LITELLM_EXTRA_HEADERS=${LITELLM_EXTRA_HEADERS:-}
- GEN_AI_API_KEY=${GEN_AI_API_KEY:-}
- BING_API_KEY=${BING_API_KEY:-}
# Query Options
- DOC_TIME_DECAY=${DOC_TIME_DECAY:-} # Recency Bias for search results, decay at 1 / (1 + DOC_TIME_DECAY * x years)

View File

@ -16,7 +16,7 @@ export default defineConfig({
{
// dependency for admin workflows
name: "admin_setup",
testMatch: /.*\admin_auth.setup\.ts/,
testMatch: /.*\admin_auth\.setup\.ts/,
},
{
// tests admin workflows

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 51 KiB

View File

@ -595,6 +595,7 @@ export function AssistantEditor({
tooltip="Used to identify the Assistant in the UI."
label="Name"
placeholder="e.g. 'Email Assistant'"
aria-label="assistant-name-input"
/>
<TextFormField
@ -602,6 +603,7 @@ export function AssistantEditor({
name="description"
label="Description"
placeholder="e.g. 'Use this Assistant to help draft professional emails'"
data-testid="assistant-description-input"
/>
<TextFormField
@ -610,9 +612,7 @@ export function AssistantEditor({
label="Instructions"
isTextArea={true}
placeholder="e.g. 'You are a professional email writing assistant that always uses a polite enthusiastic tone, emphasizes action items, and leaves blanks for the human to fill in when you have unknowns'"
onChange={(e) => {
setFieldValue("system_prompt", e.target.value);
}}
data-testid="assistant-instructions-input"
/>
<div>

View File

@ -241,6 +241,7 @@ export function TextFormField({
as={isTextArea ? "textarea" : "input"}
type={type}
defaultValue={value}
data-testid={name}
name={name}
id={name}
className={`

View File

@ -1,14 +0,0 @@
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/);
}
);

View File

@ -1,19 +0,0 @@
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 Onyx APIs programmatically/
);
await expect(
page.getByRole("button", { name: "Create API Key" })
).toHaveCount(1);
}
);

View File

@ -1,19 +0,0 @@
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/
);
const generalTextLocator = page.locator("tr.border-b td").nth(1);
await expect(generalTextLocator.locator("p.text")).toHaveText("General");
}
);

View File

@ -1,16 +0,0 @@
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 Onyx./
);
}
);

View File

@ -0,0 +1,33 @@
import { test, expect } from "@playwright/test";
test(
`test - admin chat`,
{
tag: "@admin",
},
async ({ page }) => {
await page.goto("http://localhost:3000/assistants/new");
await expect(page).toHaveURL("http://localhost:3000/assistants/new");
await page.screenshot({
path: `screenshots/create_assistant_page.png`,
});
await page.getByTestId("name").click();
await page.getByTestId("name").fill("Test");
await page.getByTestId("description").click();
await page.getByTestId("description").fill("Test");
await page.getByTestId("system_prompt").click();
await page.getByTestId("system_prompt").fill("Test");
await page
.getByRole("button", { name: "Logo GPT 4o", exact: true })
.click();
await page.getByRole("button", { name: "Create!" }).click();
// Wait for the page URL to change to the chat page
await page.waitForURL(/^http:\/\/localhost:3000\/chat(\?.*)?$/);
await expect(page.url()).toContain("http://localhost:3000/chat");
await page.screenshot({
path: `screenshots/chat_page_after_create.png`,
});
await page.getByPlaceholder("Send a message or try using").fill("Hello");
await page.keyboard.press("Enter");
await page.waitForSelector("#danswer-ai-message", { state: "visible" });
}
);

View File

@ -1,18 +0,0 @@
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"
);
}
);

View File

@ -1,16 +0,0 @@
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"
);
}
);

View File

@ -1,16 +0,0 @@
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"
);
}
);

View File

@ -1,16 +0,0 @@
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."
);
}
);

View File

@ -1,19 +0,0 @@
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"
);
}
);

View File

@ -1,16 +0,0 @@
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./
);
}
);

View File

@ -1,16 +0,0 @@
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);
}
);

View File

@ -1,16 +0,0 @@
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./
);
}
);

View File

@ -0,0 +1,52 @@
import { test, expect } from "@playwright/test";
import chromaticSnpashots from "./chromaticSnpashots.json";
import type { Page } from "@playwright/test";
async function verifyAdminPageNavigation(
page: Page,
path: string,
pageTitle: string,
options?: {
paragraphText?: string | RegExp;
buttonName?: string;
subHeaderText?: string;
}
) {
await page.goto(`http://localhost:3000/admin/${path}`);
await expect(page.locator("h1.text-3xl")).toHaveText(pageTitle);
if (options?.paragraphText) {
await expect(page.locator("p.text-sm").nth(0)).toHaveText(
options.paragraphText
);
}
if (options?.buttonName) {
await expect(
page.getByRole("button", { name: options.buttonName })
).toHaveCount(1);
}
if (options?.subHeaderText) {
await expect(page.locator("h1.text-lg").nth(0)).toHaveText(
options.subHeaderText
);
}
}
for (const chromaticSnapshot of chromaticSnpashots) {
test(
`Admin - ${chromaticSnapshot.name}`,
{
tag: "@admin",
},
async ({ page }) => {
await verifyAdminPageNavigation(
page,
chromaticSnapshot.path,
chromaticSnapshot.pageTitle,
chromaticSnapshot.options
);
}
);
}

View File

@ -1,16 +0,0 @@
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."
);
}
);

View File

@ -1,22 +0,0 @@
import { test, expect } from "@chromatic-com/playwright";
test.describe("Admin Performance Query History", () => {
// Ignores the diff for elements targeted by the specified list of selectors
// exclude button since they change based on the date
test.use({ ignoreSelectors: ["button"] });
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"
);
}
);
});

View File

@ -1,20 +0,0 @@
import { test, expect } from "@chromatic-com/playwright";
test.describe("Admin Performance Usage", () => {
// Ignores the diff for elements targeted by the specified list of selectors
// exclude button and svg since they change based on the date
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");
}
);
});

View File

@ -1,19 +0,0 @@
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 Onyx settings applicable to all users in the workspace./
);
await expect(
page.getByRole("button", { name: "Set Retention Limit" })
).toHaveCount(1);
}
);

View File

@ -1,16 +0,0 @@
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./
);
}
);

View File

@ -1,22 +0,0 @@
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"
);
}
);

View File

@ -1,16 +0,0 @@
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."
);
}
);

View File

@ -1,13 +0,0 @@
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");
}
);

View File

@ -1,18 +0,0 @@
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);
}
);

View File

@ -1,27 +0,0 @@
import { test, expect } from "@chromatic-com/playwright";
test(
"Chat",
{
tag: "@admin",
},
async ({ page }, testInfo) => {
// Test simple loading
await page.goto("http://localhost:3000/chat");
// Check for the "General" text in the new UI element
await expect(
page.locator("div.flex.items-center span.font-bold")
).toHaveText("General");
// Check for the presence of the new UI element
await expect(
page.locator("div.flex.justify-center div.bg-black.rounded-full")
).toBeVisible();
// Check for the SVG icon
await expect(
page.locator("div.flex.justify-center svg.w-5.h-5")
).toBeVisible();
}
);

View File

@ -0,0 +1,116 @@
[
{
"name": "Document Management - Explorer",
"path": "documents/explorer",
"pageTitle": "Document Explorer"
},
{
"name": "Connectors - Add Connector",
"path": "add-connector",
"pageTitle": "Add Connector",
"options": {
"subHeaderText": "Storage"
}
},
{
"name": "Custom Assistants - Assistants",
"path": "assistants",
"pageTitle": "Assistants",
"options": {
"paragraphText": "Assistants are a way to build custom search/question-answering experiences for different use cases."
}
},
{
"name": "Configuration - Document Processing",
"path": "configuration/document-processing",
"pageTitle": "Document Processing"
},
{
"name": "Document Management - Document Sets",
"path": "documents/sets",
"pageTitle": "Document Sets",
"options": {
"paragraphText": "Document Sets allow you to group logically connected documents into a single bundle. These can then be used as a filter when performing searches to control the scope of information Danswer searches over."
}
},
{
"name": "Custom Assistants - Slack Bots",
"path": "bots",
"pageTitle": "Slack Bots",
"options": {
"paragraphText": "Setup Slack bots that connect to Danswer. Once setup, you will be able to ask questions to Danswer directly from Slack. Additionally, you can:"
}
},
{
"name": "Custom Assistants - Standard Answers",
"path": "standard-answer",
"pageTitle": "Standard Answers"
},
{
"name": "Performance - Usage Statistics",
"path": "performance/usage",
"pageTitle": "Usage Statistics"
},
{
"name": "Document Management - Feedback",
"path": "documents/feedback",
"pageTitle": "Document Feedback",
"options": {
"subHeaderText": "Most Liked Documents"
}
},
{
"name": "Configuration - LLM",
"path": "configuration/llm",
"pageTitle": "LLM Setup"
},
{
"name": "Connectors - Existing Connectors",
"path": "indexing/status",
"pageTitle": "Existing Connectors"
},
{
"name": "Custom Assistants - Prompt Library",
"path": "prompt-library",
"pageTitle": "Prompt Library",
"options": {
"paragraphText": "Create prompts that can be accessed with the `/` shortcut in Danswer Chat. Prompts created here will be accessible to all users."
}
},
{
"name": "User Management - Groups",
"path": "groups",
"pageTitle": "Manage User Groups"
},
{
"name": "Performance - Whitelabeling",
"path": "whitelabeling",
"pageTitle": "Whitelabeling"
},
{
"name": "Configuration - Search Settings",
"path": "configuration/search",
"pageTitle": "Search Settings",
"options": {
"subHeaderText": "Embedding Model"
}
},
{
"name": "Custom Assistants - Tools",
"path": "tools",
"pageTitle": "Tools",
"options": {
"paragraphText": "Tools allow assistants to retrieve information or take actions."
}
},
{
"name": "User Management - Token Rate Limits",
"path": "token-rate-limits",
"pageTitle": "Token Rate Limits",
"options": {
"paragraphText": "Token rate limits enable you control how many tokens can be spent in a given time period. With token rate limits, you can:",
"buttonName": "Create a Token Rate Limit",
"subHeaderText": "Global Token Rate Limits"
}
}
]

View File

@ -1,4 +1,3 @@
// constants.js
export const TEST_CREDENTIALS = {
email: "admin_user@test.com",
password: "test",