OpenRAG is a comprehensive, single package Retrieval-Augmented Generation platform built on Langflow, Docling, and Opensearch.
Python
feat: add playwright testing to frontend for end to end tests (#1001)
Lucas Oliveira9fe641a5c356
diff --git a/.github/workflows/test-e2e.yml b/.github/workflows/test-e2e.ymlnew file mode 100644index 000000000..f73f89bb7--- /dev/null+++ b/.github/workflows/test-e2e.yml@@ -0,0 +1,181 @@+name: E2E Tests++on:+ pull_request:+ paths:+ - 'src/**'+ - 'frontend/**'+ - 'tests/**'+ - 'scripts/**'+ - 'flows/**'+ - 'docker-compose.yml'+ - 'Dockerfile*'+ - 'Makefile'+ - '.github/workflows/test-e2e.yml'+ workflow_dispatch:++env:+ NODE_VERSION: "22"+ PYTHON_VERSION: "3.13"+ # Define the directory where Playwright browsers will be installed.+ # This path is used for caching across workflows+ PLAYWRIGHT_BROWSERS_PATH: "ms-playwright"+ PLAYWRIGHT_VERSION: "1.57.0"++jobs:+ e2e:+ runs-on: ubuntu-latest+ env:+ LANGFLOW_AUTO_LOGIN: "True"+ LANGFLOW_NEW_USER_IS_ACTIVE: "True"+ LANGFLOW_ENABLE_SUPERUSER_CLI: "True"++ steps:+ - name: Cleanup Docker cache+ run: |+ docker system prune -af || true+ docker builder prune -af || true+ docker compose -f docker-compose.yml down -v --remove-orphans || true++ - name: Cleanup root-owned files (OpenSearch data, config)+ run: |+ for i in 1 2 3; do+ docker run --rm -v $(pwd):/work alpine sh -c "rm -rf /work/opensearch-data /work/config" && break+ echo "Attempt $i failed, retrying in 5s..."+ sleep 5+ done || true++ - name: Checkout+ uses: actions/checkout@v4++ - name: Set up UV+ uses: astral-sh/setup-uv@v3+ with:+ version: latest++ - name: Set up Node.js+ uses: actions/setup-node@v4+ with:+ node-version: '20'++ - name: Install Python+ run: uv python install 3.13++ - name: Install backend dependencies+ run: uv sync++ - name: Install frontend dependencies+ working-directory: frontend+ run: npm ci++ - name: Cache Docker Images+ id: cache-docker+ uses: actions/cache@v5+ with:+ path: ${{ runner.temp }}/docker-cache+ key: docker-images-v1-${{ runner.os }}-${{ hashFiles('pyproject.toml') }}+ restore-keys: |+ docker-images-v1-${{ runner.os }}-++ - name: Validate Docker Cache+ id: validate-docker-cache+ if: steps.cache-docker.outputs.cache-hit == 'true'+ run: |+ TAR="${{ runner.temp }}/docker-cache/images.tar"+ # Require at least 100 MB to consider the cache valid+ MIN_SIZE=$((100 * 1024 * 1024))+ if [ -f "$TAR" ] && [ "$(stat -c%s "$TAR")" -ge "$MIN_SIZE" ]; then+ echo "Docker cache is valid ($(du -sh "$TAR" | cut -f1))"+ echo "valid=true" >> $GITHUB_OUTPUT+ else+ echo "Docker cache is invalid or too small, deleting..."+ rm -f "$TAR"+ echo "valid=false" >> $GITHUB_OUTPUT+ fi++ - name: Load Cached Docker Images+ if: steps.cache-docker.outputs.cache-hit == 'true' && steps.validate-docker-cache.outputs.valid == 'true'+ run: |+ echo "Loading cached Docker images..."+ docker load -i ${{ runner.temp }}/docker-cache/images.tar++ # Cache Playwright browsers using a composite key+ - name: Cache Playwright Browsers+ id: cache-playwright+ uses: actions/cache@v5+ with:+ path: ${{ env.PLAYWRIGHT_BROWSERS_PATH }}+ key: playwright-${{ env.PLAYWRIGHT_VERSION }}-chromium-${{ runner.os }}+ restore-keys: |+ playwright-${{ env.PLAYWRIGHT_VERSION }}-chromium-${{ runner.os }}++ - name: Install Playwright Browsers+ working-directory: frontend+ if: steps.cache-playwright.outputs.cache-hit != 'true'+ run: |+ npx playwright install --with-deps chromium++ - name: Setup E2E infrastructure+ run: |+ chmod +x scripts/setup-e2e.sh+ ./scripts/setup-e2e.sh++ - name: Save Docker Images for Caching+ if: steps.cache-docker.outputs.cache-hit != 'true' || steps.validate-docker-cache.outputs.valid == 'false'+ run: |+ echo "Saving Docker images to cache..."+ rm -rf ${{ runner.temp }}/docker-cache+ mkdir -p ${{ runner.temp }}/docker-cache+ docker save -o ${{ runner.temp }}/docker-cache/images.tar \+ langflowai/openrag-opensearch:latest \+ langflowai/openrag-backend:latest \+ langflowai/openrag-langflow:latest \+ opensearchproject/opensearch-dashboards:3.0.0 || true++ - name: Ensure JWT keys for local backend+ run: |+ # Keys created by Docker are root-owned and unreadable by the runner.+ # Remove via Docker (handles root ownership), then regenerate as runner user.+ docker run --rm -v $(pwd):/work alpine sh -c "rm -f /work/keys/private_key.pem /work/keys/public_key.pem" || true+ uv run python -c "from src.main import generate_jwt_keys; generate_jwt_keys()"+ chmod 600 keys/private_key.pem+ chmod 644 keys/public_key.pem++ - name: Start docling-serve+ run: make docling++ - name: Run Playwright tests+ working-directory: frontend+ env:+ CI: "true"+ OPENSEARCH_HOST: localhost+ OPENSEARCH_PORT: "9200"+ OPENSEARCH_USERNAME: admin+ GOOGLE_OAUTH_CLIENT_ID: ""+ GOOGLE_OAUTH_CLIENT_SECRET: ""+ run: npx playwright test++ - name: Upload Playwright report+ uses: actions/upload-artifact@v4+ if: ${{ !cancelled() }}+ with:+ name: playwright-report+ path: frontend/playwright-report/+ retention-days: 14++ - name: Upload test results+ uses: actions/upload-artifact@v4+ if: ${{ !cancelled() }}+ with:+ name: playwright-test-results+ path: frontend/test-results/+ retention-days: 7++ - name: Teardown infrastructure+ if: always()+ run: |+ make docling-stop || true+ ENV_FILE="frontend/.env.test"+ if [ ! -f "$ENV_FILE" ]; then ENV_FILE="frontend/.env.test.example"; fi+ docker compose --env-file "$ENV_FILE" down -v --remove-orphans || true+ docker system prune -f || truediff --git a/Makefile b/Makefileindex c79c68877..20d611226 100644--- a/Makefile+++ b/Makefile@@ -1,13 +1,13 @@-# OpenRAG Development Makefile-# Provides easy commands for development workflow+# Environment file location (can be overridden via command line)+ENV_FILE ?= .env-# Load variables from .env if present so `make` commands pick them up+# Load variables from $(ENV_FILE) if present so `make` commands pick them up# Strip quotes from values to avoid issues with tools that don't handle them like python-dotenv does-ifneq (,$(wildcard .env))- include .env- export $(shell sed -n 's/^\([A-Za-z_][A-Za-z0-9_]*\)=.*/\1/p' .env)+ifneq (,$(wildcard $(ENV_FILE)))+ include $(ENV_FILE)+ export $(shell sed -n 's/^\([A-Za-z_][A-Za-z0-9_]*\)=.*/\1/p' $(ENV_FILE))# Strip single quotes from all exported variables- $(foreach var,$(shell sed -n 's/^\([A-Za-z_][A-Za-z0-9_]*\)=.*/\1/p' .env),$(eval $(var):=$(shell echo $($(var)) | sed "s/^'//;s/'$$//")))+ $(foreach var,$(shell sed -n 's/^\([A-Za-z_][A-Za-z0-9_]*\)=.*/\1/p' $(ENV_FILE)),$(eval $(var):=$(shell echo $($(var)) | sed "s/^'//;s/'$$//")))endifhostname ?= 0.0.0.0@@ -19,7 +19,12 @@ REPO ?= https://github.com/langflow-ai/langflow.git# Auto-detect container runtime: prefer docker, fall back to podmanCONTAINER_RUNTIME := $(shell command -v docker >/dev/null 2>&1 && echo "docker" || echo "podman")-COMPOSE_CMD := $(CONTAINER_RUNTIME) compose+# Only pass --env-file if the file actually exists+ifneq (,$(wildcard $(ENV_FILE)))+ COMPOSE_CMD := $(CONTAINER_RUNTIME) compose --env-file $(ENV_FILE)+else+ COMPOSE_CMD := $(CONTAINER_RUNTIME) compose+endif####################### COLOR DEFINITIONS@@ -458,10 +463,13 @@ factory-reset: ## Complete reset (stop, remove volumes, clear data, remove imageecho " - Delete JWT keys (private_key.pem, public_key.pem)"; \echo " - Remove local OpenRAG images"; \echo ""; \- read -p "Are you sure? Type 'yes' to continue: " confirm; \- if [ "$$confirm" != "yes" ]; then \- echo "$(CYAN)Factory reset cancelled.$(NC)"; \- exit 0; \+ echo ""; \+ if [ "$(FORCE)" != "true" ]; then \+ read -p "Are you sure? Type 'yes' to continue: " confirm; \+ if [ "$$confirm" != "yes" ]; then \+ echo "$(CYAN)Factory reset cancelled.$(NC)"; \+ exit 0; \+ fi; \fi; \echo ""; \echo "$(YELLOW)Stopping all services and removing volumes...$(NC)"; \@@ -472,7 +480,6 @@ factory-reset: ## Complete reset (stop, remove volumes, clear data, remove imageuv run python scripts/clear_opensearch_data.py 2>/dev/null || \$(CONTAINER_RUNTIME) run --rm -v "$$(pwd)/opensearch-data:/data" alpine sh -c "rm -rf /data/*" 2>/dev/null || \rm -rf opensearch-data/* 2>/dev/null || true; \- rm -rf opensearch-data 2>/dev/null || true; \echo "$(PURPLE)opensearch-data removed$(NC)"; \fi; \if [ -d "config" ]; then \@@ -497,7 +504,7 @@ factory-reset: ## Complete reset (stop, remove volumes, clear data, remove imagebackend: ## Run backend locally@echo "$(YELLOW)Starting backend locally...$(NC)"- @if [ ! -f .env ]; then echo "$(RED).env file not found. Copy .env.example to .env first$(NC)"; exit 1; fi+ @if [ ! -f $(ENV_FILE) ]; then echo "$(RED)$(ENV_FILE) file not found. Copy .env.example to it first$(NC)"; exit 1; fiuv run python src/main.pyfrontend: ## Run frontend locally@@ -671,16 +678,20 @@ test-ci: ## Start infra, run integration + SDK tests, tear down (uses DockerHubsleep 2; \done; \echo "$(YELLOW)Verifying OIDC authenticator is active in OpenSearch...$(NC)"; \- AUTHC_CONFIG=$$(curl -k -s -u admin:$${OPENSEARCH_PASSWORD} https://localhost:9200/_opendistro/_security/api/securityconfig 2>/dev/null); \- if echo "$$AUTHC_CONFIG" | grep -q "openid_auth_domain"; then \- echo "$(PURPLE)OIDC authenticator configured$(NC)"; \- echo "$$AUTHC_CONFIG" | grep -A 5 "openid_auth_domain"; \- else \- echo "$(RED)OIDC authenticator NOT found in security config!$(NC)"; \- echo "Security config:"; \- echo "$$AUTHC_CONFIG" | head -50; \- exit 1; \- fi; \+ for i in $$(seq 1 30); do \+ AUTHC_CONFIG=$$(curl -k -s -u admin:$${OPENSEARCH_PASSWORD} https://localhost:9200/_opendistro/_security/api/securityconfig 2>/dev/null || true); \+ if echo "$$AUTHC_CONFIG" | grep -q "openid_auth_domain"; then \+ echo "$(PURPLE)OIDC authenticator configured$(NC)"; \+ echo "$$AUTHC_CONFIG" | grep -A 5 "openid_auth_domain"; \+ break; \+ fi; \+ if [ $$i -eq 30 ]; then \+ echo "$(RED)OIDC authenticator NOT found or unreachable in time!$(NC)"; \+ echo "Security config output: $$AUTHC_CONFIG"; \+ exit 1; \+ fi; \+ sleep 2; \+ done; \echo "$(YELLOW)Waiting for Langflow...$(NC)"; \for i in $$(seq 1 60); do \curl -s http://localhost:7860/ >/dev/null 2>&1 && break || sleep 2; \@@ -783,16 +794,20 @@ test-ci-local: ## Same as test-ci but builds all images locallysleep 2; \done; \echo "$(YELLOW)Verifying OIDC authenticator is active in OpenSearch...$(NC)"; \- AUTHC_CONFIG=$$(curl -k -s -u admin:$${OPENSEARCH_PASSWORD} https://localhost:9200/_opendistro/_security/api/securityconfig 2>/dev/null); \- if echo "$$AUTHC_CONFIG" | grep -q "openid_auth_domain"; then \- echo "$(PURPLE)OIDC authenticator configured$(NC)"; \- echo "$$AUTHC_CONFIG" | grep -A 5 "openid_auth_domain"; \- else \- echo "$(RED)OIDC authenticator NOT found in security config!$(NC)"; \- echo "Security config:"; \- echo "$$AUTHC_CONFIG" | head -50; \- exit 1; \- fi; \+ for i in $$(seq 1 30); do \+ AUTHC_CONFIG=$$(curl -k -s -u admin:$${OPENSEARCH_PASSWORD} https://localhost:9200/_opendistro/_security/api/securityconfig 2>/dev/null || true); \+ if echo "$$AUTHC_CONFIG" | grep -q "openid_auth_domain"; then \+ echo "$(PURPLE)OIDC authenticator configured$(NC)"; \+ echo "$$AUTHC_CONFIG" | grep -A 5 "openid_auth_domain"; \+ break; \+ fi; \+ if [ $$i -eq 30 ]; then \+ echo "$(RED)OIDC authenticator NOT found or unreachable in time!$(NC)"; \+ echo "Security config output: $$AUTHC_CONFIG"; \+ exit 1; \+ fi; \+ sleep 2; \+ done; \echo "$(YELLOW)Waiting for Langflow...$(NC)"; \for i in $$(seq 1 60); do \curl -s http://localhost:7860/ >/dev/null 2>&1 && break || sleep 2; \diff --git a/frontend/.env.test.example b/frontend/.env.test.examplenew file mode 100644index 000000000..f53600840--- /dev/null+++ b/frontend/.env.test.example@@ -0,0 +1,35 @@+# Ingestion Configuration+DISABLE_INGEST_WITH_LANGFLOW=false+INGEST_SAMPLE_DATA=true++# Auth+OPENSEARCH_PASSWORD=++# Paths+OPENSEARCH_DATA_PATH=./opensearch-data+OPENSEARCH_INDEX_NAME=documents++# Model Providers+OPENAI_API_KEY=+ANTHROPIC_API_KEY=+GOOGLE_OAUTH_CLIENT_ID=+GOOGLE_OAUTH_CLIENT_SECRET=++# Ports+FRONTEND_PORT=3000+LANGFLOW_PORT=7860+OPENSEARCH_PORT=9200+OPENSEARCH_HOST=localhost++# Langflow+LANGFLOW_AUTO_LOGIN=True+LANGFLOW_NO_LOGIN=True+LANGFLOW_DEACTIVATE_TRACING=true+LANGFLOW_LOG_LEVEL=ERROR+DO_NOT_TRACK=true+LANGFLOW_ENABLE_SUPERUSER_CLI=false+LANGFLOW_NEW_USER_IS_ACTIVE=false++# App Specific+# VITE_PROXY_TARGET is used by frontend to proxy requests to backend+VITE_PROXY_TARGET=http://127.0.0.1:8000diff --git a/frontend/.gitignore b/frontend/.gitignoreindex 5ef6a5207..1c9fcaafc 100644--- a/frontend/.gitignore+++ b/frontend/.gitignore@@ -32,6 +32,7 @@ yarn-error.log*# env files (can opt-in for committing if needed).env*+!.env.test.example# vercel.vercel@@ -39,3 +40,6 @@ yarn-error.log*# typescript*.tsbuildinfonext-env.d.ts++playwright-report+test-resultsdiff --git a/frontend/app/onboarding/_components/onboarding-content.tsx b/frontend/app/onboarding/_components/onboarding-content.tsxindex 094c540bb..e98dc2294 100644--- a/frontend/app/onboarding/_components/onboarding-content.tsx+++ b/frontend/app/onboarding/_components/onboarding-content.tsx@@ -188,7 +188,7 @@ export function OnboardingContent({mass={1}><StickToBottom.Content className="flex flex-col min-h-full overflow-x-hidden px-8 py-6">- <div className="flex flex-col place-self-center w-full space-y-6">+ <div className="flex flex-col place-self-center w-full space-y-6" data-testid="onboarding-content">{/* Step 1 - LLM Provider */}<OnboardingStepisVisible={currentStep >= 0}diff --git a/frontend/components/icons/aws-logo.tsx b/frontend/components/icons/aws-logo.tsxindex bdfbaeb4b..221eea0a9 100644--- a/frontend/components/icons/aws-logo.tsx+++ b/frontend/components/icons/aws-logo.tsx@@ -14,14 +14,14 @@ const AwsLogo = ({ className }: { className?: string }) => {fill="currentColor"/><path- fill-rule="evenodd"- clip-rule="evenodd"+ fillRule="evenodd"+ clipRule="evenodd"d="M14.4654 10.9487C12.7146 12.2464 10.171 12.9353 7.98385 12.9353C4.91871 12.9353 2.15688 11.7978 0.0708824 9.90731C-0.094082 9.75778 0.0549181 9.55484 0.251811 9.67233C2.5081 10.9861 5.29121 11.7818 8.1701 11.7818C10.1124 11.7818 12.2463 11.3759 14.2099 10.5428C14.5026 10.4093 14.7527 10.7351 14.4654 10.9487Z"fill="#FF9900"/><path- fill-rule="evenodd"- clip-rule="evenodd"+ fillRule="evenodd"+ clipRule="evenodd"d="M15.1944 10.1156C14.9709 9.82721 13.715 9.97674 13.1457 10.0462C12.9754 10.0675 12.9488 9.91799 13.1031 9.80584C14.1035 9.10092 15.7478 9.30385 15.9394 9.53883C16.131 9.77914 15.8862 11.4293 14.9496 12.2197C14.8059 12.3425 14.6676 12.2784 14.7314 12.1182C14.9443 11.5895 15.4179 10.3986 15.1944 10.1156Z"fill="#FF9900"/>diff --git a/frontend/components/knowledge-dropdown.tsx b/frontend/components/knowledge-dropdown.tsxindex 8f8fffb6e..1c8ab1845 100644--- a/frontend/components/knowledge-dropdown.tsx+++ b/frontend/components/knowledge-dropdown.tsx@@ -66,11 +66,20 @@ export const SUPPORTED_FILE_TYPES = {export const SUPPORTED_EXTENSIONS = Object.values(SUPPORTED_FILE_TYPES).flat();+const FileIconWithColor = ({ className }: { className?: string }) => (+ <FileIcon className={cn(className, "text-muted-foreground")} />+);++const FolderIconWithColor = ({ className }: { className?: string }) => (+ <Folder className={cn(className, "text-muted-foreground")} />+);+export function KnowledgeDropdown() {const { addTask } = useTask();const { refetch: refetchTasks } = useGetTasksQuery();const queryClient = useQueryClient();const router = useRouter();+ const [mounted, setMounted] = useState(false);const [isMenuOpen, setIsMenuOpen] = useState(false);const [showFolderDialog, setShowFolderDialog] = useState(false);const [showS3Dialog, setShowS3Dialog] = useState(false);@@ -186,6 +195,10 @@ export function KnowledgeDropdown() {checkAvailability();}, []);+ useEffect(() => {+ setMounted(true);+ }, []);+const handleFileUpload = () => {fileInputRef.current?.click();};@@ -517,16 +530,12 @@ export function KnowledgeDropdown() {const menuItems = [{label: "File",- icon: ({ className }: { className?: string }) => (- <FileIcon className={cn(className, "text-muted-foreground")} />- ),+ icon: FileIconWithColor,onClick: handleFileUpload,},{label: "Folder",- icon: ({ className }: { className?: string }) => (- <Folder className={cn(className, "text-muted-foreground")} />- ),+ icon: FolderIconWithColor,onClick: () => folderInputRef.current?.click(),},...(awsEnabled@@ -545,6 +554,15 @@ export function KnowledgeDropdown() {const isLoading =fileUploading || folderLoading || s3Loading || isNavigatingToCloud;+ if (!mounted) {+ return (+ <Button disabled variant="outline" className="opacity-50">+ <span>Add Knowledge</span>+ <ChevronDown className="h-4 w-4 ml-2" />+ </Button>+ );+ }+return (<><DropdownMenu onOpenChange={setIsMenuOpen}>@@ -601,6 +619,7 @@ export function KnowledgeDropdown() {type="file"// @ts-ignore - webkitdirectory is not in TypeScript types but is widely supportedwebkitdirectory=""+ // @ts-ignoredirectory=""multipleonChange={handleFolderSelect}diff --git a/frontend/package-lock.json b/frontend/package-lock.jsonindex bf0787c3e..bdb24b680 100644--- a/frontend/package-lock.json+++ b/frontend/package-lock.json@@ -55,6 +55,7 @@"devDependencies": {"@biomejs/biome": "2.3.5","@eslint/eslintrc": "^3",+ "@playwright/test": "^1.57.0","@types/node": "^20","@types/react": "^19","@types/react-dom": "^19",@@ -1294,6 +1295,23 @@"node": ">=14"}},+ "node_modules/@playwright/test": {+ "version": "1.57.0",+ "resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.57.0.tgz",+ "integrity": "sha512-6TyEnHgd6SArQO8UO2OMTxshln3QMWBtPGrOCgs3wVEmQmwyuNtB10IZMfmYDE0riwNR1cu4q+pPcxMVtaG3TA==",+ "devOptional": true,+ "license": "Apache-2.0",+ "peer": true,+ "dependencies": {+ "playwright": "1.57.0"+ },+ "bin": {+ "playwright": "cli.js"+ },+ "engines": {+ "node": ">=18"+ }+ },"node_modules/@radix-ui/number": {"version": "1.1.1","resolved": "https://registry.npmjs.org/@radix-ui/number/-/number-1.1.1.tgz",@@ -2535,6 +2553,7 @@"integrity": "sha512-yCAeZl7a0DxgNVteXFHt9+uyFbqXGy/ShC4BlcHkoE0AfGXYv/BUiplV72DjMYXHDBXFjhvr6DD1NiRVfB4j8g==","dev": true,"license": "MIT",+ "peer": true,"dependencies": {"undici-types": "~6.21.0"}@@ -2550,6 +2569,7 @@"resolved": "https://registry.npmjs.org/@types/react/-/react-19.1.12.tgz","integrity": "sha512-cMoR+FoAf/Jyq6+Df2/Z41jISvGZZ2eTlnsaJRptmZ76Caldwy1odD4xTr/gNV9VLj0AWgg/nmkevIyUfIIq5w==","license": "MIT",+ "peer": true,"dependencies": {"csstype": "^3.0.2"}@@ -2560,6 +2580,7 @@"integrity": "sha512-qXRuZaOsAdXKFyOhRBg6Lqqc0yay13vN7KrIg4L7N4aaHN68ma9OK3NE1BoDFgFOTfM7zg+3/8+2n8rLUH3OKQ==","devOptional": true,"license": "MIT",+ "peer": true,"peerDependencies": {"@types/react": "^19.0.0"}@@ -2599,6 +2620,7 @@"integrity": "sha512-NZyJarBfL7nWwIq+FDL6Zp/yHEhePMNnnJ0y3qfieCrmNvYct8uvtiV41UvlSe6apAfk0fY1FbWx+NwfmpvtTg==","dev": true,"license": "MIT",+ "peer": true,"bin": {"acorn": "bin/acorn"},@@ -2847,6 +2869,7 @@}],"license": "MIT",+ "peer": true,"dependencies": {"caniuse-lite": "^1.0.30001737","electron-to-chromium": "^1.5.211",@@ -5487,6 +5510,53 @@"node": ">= 6"}},+ "node_modules/playwright": {+ "version": "1.57.0",+ "resolved": "https://registry.npmjs.org/playwright/-/playwright-1.57.0.tgz",+ "integrity": "sha512-ilYQj1s8sr2ppEJ2YVadYBN0Mb3mdo9J0wQ+UuDhzYqURwSoW4n1Xs5vs7ORwgDGmyEh33tRMeS8KhdkMoLXQw==",+ "devOptional": true,+ "license": "Apache-2.0",+ "dependencies": {+ "playwright-core": "1.57.0"+ },+ "bin": {+ "playwright": "cli.js"+ },+ "engines": {+ "node": ">=18"+ },+ "optionalDependencies": {+ "fsevents": "2.3.2"+ }+ },+ "node_modules/playwright-core": {+ "version": "1.57.0",+ "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.57.0.tgz",+ "integrity": "sha512-agTcKlMw/mjBWOnD6kFZttAAGHgi/Nw0CZ2o6JqWSbMlI219lAFLZZCyqByTsvVAJq5XA5H8cA6PrvBRpBWEuQ==",+ "devOptional": true,+ "license": "Apache-2.0",+ "bin": {+ "playwright-core": "cli.js"+ },+ "engines": {+ "node": ">=18"+ }+ },+ "node_modules/playwright/node_modules/fsevents": {+ "version": "2.3.2",+ "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz",+ "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==",+ "dev": true,+ "hasInstallScript": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "darwin"+ ],+ "engines": {+ "node": "^8.16.0 || ^10.6.0 || >=11.0.0"+ }+ },"node_modules/postcss": {"version": "8.5.6","resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.6.tgz",@@ -5506,6 +5576,7 @@}],"license": "MIT",+ "peer": true,"dependencies": {"nanoid": "^3.3.11","picocolors": "^1.1.1",@@ -5672,6 +5743,7 @@"resolved": "https://registry.npmjs.org/react/-/react-19.1.1.tgz","integrity": "sha512-w8nqGImo45dmMIfljjMwOGtbmC/mk4CMYhWIicdSflH91J9TyCyczcPFXJzrZ/ZXcgGRFeP6BU0BEJTw6tZdfQ==","license": "MIT",+ "peer": true,"engines": {"node": ">=0.10.0"}@@ -5681,6 +5753,7 @@"resolved": "https://registry.npmjs.org/react-dom/-/react-dom-19.1.1.tgz","integrity": "sha512-Dlq/5LAZgF0Gaz6yiqZCf6VCcZs1ghAJyrsu84Q/GT0gV+mCxbfmKNoGRKBYMJ8IEdGPqu49YWXD02GCknEDkw==","license": "MIT",+ "peer": true,"dependencies": {"scheduler": "^0.26.0"},@@ -6432,6 +6505,7 @@"resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-3.4.17.tgz","integrity": "sha512-w33E2aCvSDP0tW9RZuNXadXlkHXqFzSkQew/aIa2i/Sj8fThxwovwlXHSPXTbAHwEIhBFXAedUhP2tueAKP8Og==","license": "MIT",+ "peer": true,"dependencies": {"@alloc/quick-lru": "^5.2.0","arg": "^5.0.2",@@ -6619,6 +6693,7 @@"integrity": "sha512-CWBzXQrc/qOkhidw1OzBTQuYRbfyxDXJMVJ1XNwUHGROVmuaeiEm3OslpZ1RV96d7SKKjZKrSJu3+t/xlw3R9A==","dev": true,"license": "Apache-2.0",+ "peer": true,"bin": {"tsc": "bin/tsc","tsserver": "bin/tsserver"diff --git a/frontend/package.json b/frontend/package.jsonindex 8c679c5bc..226ca35a0 100644--- a/frontend/package.json+++ b/frontend/package.json@@ -62,6 +62,7 @@"devDependencies": {"@biomejs/biome": "2.3.5","@eslint/eslintrc": "^3",+ "@playwright/test": "^1.57.0","@types/node": "^20","@types/react": "^19","@types/react-dom": "^19",diff --git a/frontend/playwright.config.ts b/frontend/playwright.config.tsnew file mode 100644index 000000000..e6c8118fb--- /dev/null+++ b/frontend/playwright.config.ts@@ -0,0 +1,93 @@+import { defineConfig, devices } from "@playwright/test";+import * as dotenv from "dotenv";+import path from "path";++// Load test environment variables+dotenv.config({ path: path.resolve(__dirname, ".env.test") });++const PORT = process.env.FRONTEND_PORT || 3000;++export default defineConfig({+ testDir: "./tests",+ fullyParallel: true,+ forbidOnly: !!process.env.CI,+ retries: process.env.CI ? 2 : 1,+ workers: process.env.CI ? 1 : undefined,+ reporter: "html",+ timeout: 5 * 60 * 1000,++ // Setup hook to run before all tests++ use: {+ baseURL: `http://localhost:${PORT}`,+ actionTimeout: 30000,+ trace: "on-first-retry",+ },++ projects: [+ {+ name: "chromium",+ use: { ...devices["Desktop Chrome"] },+ },+ ],++ /* Infrastructure (OpenSearch, Langflow, etc.) is expected to be running already.+ * Only start the backend and frontend servers. */+ webServer: [+ {+ command: "make backend ENV_FILE=frontend/.env.test",+ cwd: path.resolve(__dirname, ".."),+ url: "http://127.0.0.1:8000/health",+ reuseExistingServer: !process.env.CI,+ stdout: "pipe",+ stderr: "pipe",+ timeout: 300 * 1000,+ env: {+ // Inherit PATH so make/uv/python are found+ PATH: process.env.PATH || "",+ HOME: process.env.HOME || "",++ // OpenSearch connection+ OPENSEARCH_HOST: process.env.OPENSEARCH_HOST || "localhost",+ OPENSEARCH_PORT: process.env.OPENSEARCH_PORT || "9200",+ OPENSEARCH_USERNAME: process.env.OPENSEARCH_USERNAME || "admin",+ OPENSEARCH_PASSWORD: process.env.OPENSEARCH_PASSWORD || "",+ OPENSEARCH_INDEX_NAME: process.env.OPENSEARCH_INDEX_NAME || "documents",++ // Langflow+ LANGFLOW_URL: process.env.LANGFLOW_URL || "http://localhost:7860",+ LANGFLOW_AUTO_LOGIN: process.env.LANGFLOW_AUTO_LOGIN || "True",+ LANGFLOW_SUPERUSER: process.env.LANGFLOW_SUPERUSER || "",+ LANGFLOW_SUPERUSER_PASSWORD: process.env.LANGFLOW_SUPERUSER_PASSWORD || "",+ LANGFLOW_CHAT_FLOW_ID: process.env.LANGFLOW_CHAT_FLOW_ID || "",+ LANGFLOW_INGEST_FLOW_ID: process.env.LANGFLOW_INGEST_FLOW_ID || "",++ // Auth — disable OAuth for E2E+ GOOGLE_OAUTH_CLIENT_ID: "",+ GOOGLE_OAUTH_CLIENT_SECRET: "",++ // Provider API keys+ OPENAI_API_KEY: process.env.OPENAI_API_KEY || "",+ ANTHROPIC_API_KEY: process.env.ANTHROPIC_API_KEY || "",+ WATSONX_API_KEY: process.env.WATSONX_API_KEY || "",+ WATSONX_ENDPOINT: process.env.WATSONX_ENDPOINT || "",+ WATSONX_PROJECT_ID: process.env.WATSONX_PROJECT_ID || "",+ OLLAMA_BASE_URL: process.env.OLLAMA_BASE_URL || "",++ // Ingestion+ DISABLE_INGEST_WITH_LANGFLOW: process.env.DISABLE_INGEST_WITH_LANGFLOW || "false",+ INGEST_SAMPLE_DATA: process.env.INGEST_SAMPLE_DATA || "true",+ }+ },+ {+ command: "npm run dev",+ port: Number(PORT),+ reuseExistingServer: !process.env.CI,+ env: {+ PORT: String(PORT),+ VITE_PROXY_TARGET: process.env.VITE_PROXY_TARGET || "http://127.0.0.1:8000",+ }+ }+ ],+});+diff --git a/frontend/tests/README.md b/frontend/tests/README.mdnew file mode 100644index 000000000..72e2e6647--- /dev/null+++ b/frontend/tests/README.md@@ -0,0 +1,51 @@+# Testing++This directory and its subdirectories generally contain tests for the application.++## End-to-End (E2E) Tests++The E2E tests for the frontend are written using Playwright and are located in the `frontend/tests` or configured to run from the `frontend` directory.++### Running E2E Tests Locally++To run the Playwright E2E tests locally, follow these steps:++#### 1. Setup Infrastructure+The E2E tests require the backend infrastructure (database, API, etc.) to be running.+We provide a setup script that automates the process of creating a test environment, managing environment variables, and starting the required containers:++```bash+./scripts/setup-e2e.sh+```++**What this script does:**+- Copies `frontend/.env.test.example` to `frontend/.env.test` if it doesn't already exist.+- Auto-generates any required missing secrets (e.g., `OPENSEARCH_PASSWORD`) in the `.env.test` file.+- Performs a factory reset to clear old data (using `make factory-reset`).+- Starts the infrastructure using `make dev-local-cpu` with the new `.env.test` file.+- Waits for services like OpenSearch and the Langflow backend to become healthy before proceeding.++**Alternative: Manual Setup**+If you prefer not to use the automated setup script, you can manually start the infrastructure:+1. Ensure that `frontend/.env.test` is created and configured correctly (e.g., `OPENSEARCH_PASSWORD` must be set).+2. Clean up old data by running: `make factory-reset ENV_FILE=frontend/.env.test`+3. Start the infrastructure by running: `make dev-local-cpu ENV_FILE=frontend/.env.test`++#### 2. Run Playwright Tests+Once the infrastructure is up and running, you can execute the Playwright tests.+Navigate to the `frontend` directory and run the tests:++```bash+cd frontend+npx playwright test+```++*Note: You may need to run `npx playwright install` first to download the required browsers if you haven't already.*++### Teardown++After running the tests, you can shut down and clean up the test infrastructure using Docker Compose. Ensure you use the same environment file:++```bash+docker compose --env-file frontend/.env.test down -v --remove-orphans+```diff --git a/frontend/tests/core/onboarding.spec.ts b/frontend/tests/core/onboarding.spec.tsnew file mode 100644index 000000000..9e7a5bc5e--- /dev/null+++ b/frontend/tests/core/onboarding.spec.ts@@ -0,0 +1,12 @@+import { test, expect } from "@playwright/test";++test("has onboarding content", async ({ page }) => {+ // Go to the base URL (frontend)+ await page.goto("/");++ // Expect a title "to contain" a substring.+ await expect(page).toHaveTitle(/OpenRAG/);++ // Expect the onboarding content to be visible using the test id.+ await expect(page.getByTestId("onboarding-content")).toBeVisible({ timeout: 30000 });+});diff --git a/scripts/setup-e2e.sh b/scripts/setup-e2e.shnew file mode 100755index 000000000..92e182588--- /dev/null+++ b/scripts/setup-e2e.sh@@ -0,0 +1,81 @@+#!/bin/bash+set -e++# Go to project root+cd "$(dirname "$0")/.."++# Environment file for E2E tests+E2E_ENV="frontend/.env.test"+E2E_ENV_EXAMPLE="frontend/.env.test.example"++# Create .env.test from the example template (never modify the tracked example file)+if [ ! -f "$E2E_ENV" ]; then+ cp "$E2E_ENV_EXAMPLE" "$E2E_ENV"+fi++# Auto-generate a strong OpenSearch password if not already set in the env file.+# OpenSearch requires: uppercase, lowercase, digit, special char, min 8 chars.+CURRENT_PASSWORD=$(grep -E '^OPENSEARCH_PASSWORD=' "$E2E_ENV" | cut -d'=' -f2-)+if [ -z "$CURRENT_PASSWORD" ]; then+ # Generate a random base (alphanumeric) and append required character classes+ RANDOM_BASE=$(LC_ALL=C tr -dc 'A-Za-z0-9' < /dev/urandom | head -c 12)+ GENERATED_PASSWORD="${RANDOM_BASE}Aa1@"+ echo "Auto-generated OpenSearch password for E2E tests."++ # Write the password into the env file+ if [[ "$OSTYPE" == "darwin"* ]]; then+ sed -i '' "s|^OPENSEARCH_PASSWORD=.*|OPENSEARCH_PASSWORD=${GENERATED_PASSWORD}|" "$E2E_ENV"+ else+ sed -i "s|^OPENSEARCH_PASSWORD=.*|OPENSEARCH_PASSWORD=${GENERATED_PASSWORD}|" "$E2E_ENV"+ fi++ export OPENSEARCH_PASSWORD="$GENERATED_PASSWORD"+else+ echo "Using existing OpenSearch password from $E2E_ENV."+ export OPENSEARCH_PASSWORD="$CURRENT_PASSWORD"+fi++# Detect container runtime+if command -v docker >/dev/null 2>&1; then+ CONTAINER_RUNTIME="docker"+else+ CONTAINER_RUNTIME="podman"+fi++echo "Using container runtime: $CONTAINER_RUNTIME"+echo "Starting E2E Setup using $E2E_ENV..."++# Clean up using make+echo "Cleaning up..."+make factory-reset FORCE=true ENV_FILE=$E2E_ENV++# Start infrastructure using make (this will use the new .env)+echo "Starting infrastructure..."+make dev-local-cpu ENV_FILE=$E2E_ENV++echo "Waiting for OpenSearch..."+TIMEOUT=300+ELAPSED=0+until curl -s -k https://localhost:9200 >/dev/null; do+ sleep 5+ ELAPSED=$((ELAPSED + 5))+ if [ $ELAPSED -ge $TIMEOUT ]; then+ echo "ERROR: OpenSearch did not become ready within ${TIMEOUT}s"+ exit 1+ fi+ echo "Waiting for OpenSearch... (${ELAPSED}s/${TIMEOUT}s)"+done++echo "Waiting for Langflow..."+ELAPSED=0+until curl -s http://localhost:7860/health >/dev/null; do+ sleep 5+ ELAPSED=$((ELAPSED + 5))+ if [ $ELAPSED -ge $TIMEOUT ]; then+ echo "ERROR: Langflow did not become ready within ${TIMEOUT}s"+ exit 1+ fi+ echo "Waiting for Langflow... (${ELAPSED}s/${TIMEOUT}s)"+done++echo "Infrastructure Ready!"diff --git a/src/main.py b/src/main.pyindex 86ea7f740..083a85e31 100644--- a/src/main.py+++ b/src/main.py@@ -11,7 +11,7 @@ from utils.container_utils import detect_container_environmentfrom utils.embeddings import create_dynamic_index_bodyfrom utils.logging_config import configure_from_env, get_loggerfrom utils.telemetry import TelemetryClient, Category, MessageId-from fastapi import FastAPI+from fastapi import FastAPI, Requestfrom fastapi.responses import JSONResponse@@ -426,7 +426,7 @@ async def _ingest_default_documents_langflow(file_count=len(file_paths),)-async def health_check(request):+async def health_check(request: Request):"""Simple liveness probe: Indicates that the OpenRAG Backend service is online and running."""return JSONResponse({"status": "ok"}, status_code=200)