fix: improves table formatting in the playground and adds Jest tests (#8743)

* feat(tests): add Jest configuration and setup for testing environment

- Introduced Jest configuration file to set up testing environment with TypeScript support and JSDOM.
- Added setupTests.ts for global test configurations, including mocks for ResizeObserver and IntersectionObserver.
- Updated package.json and package-lock.json to include Jest and related dependencies.
- Implemented utility functions for processing markdown content, including handling tables and <think> tags.
- Added comprehensive tests for markdown utility functions to ensure proper functionality.

* refactor(makefile): separate frontend commands into a dedicated Makefile

- Removed frontend-related targets from the main Makefile and created a new Makefile.frontend to manage frontend-specific commands.
- Updated the main Makefile to include a reference to the new frontend Makefile and added a help message for frontend commands.
- This restructuring improves organization and clarity for managing backend and frontend build processes.
This commit is contained in:
Deon Sanchez 2025-06-30 15:13:04 -06:00 • committed by GitHub
commit ff00eb582f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 5004 additions and 73 deletions

View file

@ -1,4 +1,4 @@
.PHONY: all init format_backend format_frontend format lint build build_frontend install_frontend run_frontend run_backend dev help tests coverage clean_python_cache clean_npm_cache clean_all
.PHONY: all init format_backend format lint build run_backend dev help tests coverage clean_python_cache clean_npm_cache clean_all
# Configurations
VERSION=$(shell grep "^version" pyproject.toml | sed 's/.*\"\(.*\)\"$$/\1/')
@ -45,6 +45,7 @@ help: ## show this help message
awk -F ':.*##' '{printf "\033[36mmake %s\033[0m: %s\n", $$1, $$2}' | \
column -c2 -t -s :
@echo '----'
@echo 'For frontend commands, run: make help_frontend'
######################
# INSTALL PROJECT
@ -58,22 +59,7 @@ install_backend: ## install the backend dependencies
@echo 'Installing backend dependencies'
@uv sync --frozen --extra "postgresql" $(EXTRA_ARGS)
install_frontend: ## install the frontend dependencies
@echo 'Installing frontend dependencies'
@cd src/frontend && npm install > /dev/null 2>&1
build_frontend: ## build the frontend static files
@echo '==== Starting frontend build ===='
@echo 'Current directory: $$(pwd)'
@echo 'Checking if src/frontend exists...'
@ls -la src/frontend || true
@echo 'Building frontend static files...'
@cd src/frontend && CI='' npm run build 2>&1 || { echo "\nBuild failed! Error output above ☝️"; exit 1; }
@echo 'Clearing destination directory...'
$(call CLEAR_DIRS,src/backend/base/langflow/frontend)
@echo 'Copying build files...'
@cp -r src/frontend/build/. src/backend/base/langflow/frontend
@echo '==== Frontend build complete ===='
init: check_tools ## initialize the project
@make install_backend
@ -189,9 +175,6 @@ format_backend: ## backend code formatters
@uv run ruff check . --fix
@uv run ruff format . --config pyproject.toml
format_frontend: ## frontend code formatters
@cd src/frontend && npm run format
format: format_backend format_frontend ## run code formatters
unsafe_fix:
@ -200,22 +183,7 @@ unsafe_fix:
lint: install_backend ## run linters
@uv run mypy --namespace-packages -p "langflow"
install_frontendci:
@cd src/frontend && npm ci > /dev/null 2>&1
install_frontendc:
@cd src/frontend && $(call CLEAR_DIRS,node_modules) && rm -f package-lock.json && npm install > /dev/null 2>&1
run_frontend: ## run the frontend
@-kill -9 `lsof -t -i:3000`
@cd src/frontend && npm start $(if $(FRONTEND_START_FLAGS),-- $(FRONTEND_START_FLAGS))
tests_frontend: ## run frontend tests
ifeq ($(UI), true)
@cd src/frontend && npx playwright test --ui --project=chromium
else
@cd src/frontend && npx playwright test --project=chromium
endif
run_cli: install_frontend install_backend build_frontend ## run the CLI
@echo 'Running the CLI'
@ -250,11 +218,7 @@ setup_devcontainer: ## set up the development container
setup_env: ## set up the environment
@sh ./scripts/setup/setup_env.sh
frontend: install_frontend ## run the frontend in development mode
make run_frontend
frontendc: install_frontendc
make run_frontend
backend: setup_env install_backend ## run the backend in development mode
@ -551,3 +515,10 @@ locust: ## run locust load tests (options: locust_users=10 locust_spawn_rate=1 l
--host $(locust_host) \
-f $$(basename "$(locust_file)"); \
fi
######################
# INCLUDE FRONTEND MAKEFILE
######################
# Include frontend-specific Makefile
include Makefile.frontend