* feat(storybook): add Storybook setup and Button component stories - Add Storybook configuration files (.storybook/main.ts, preview.ts, css.d.ts) - Add Button component stories with interaction testing - Add Storybook dependencies and scripts to package.json - Support dark mode in stories via decorator - Include play functions for automated interaction testing * ci(storybook): add GitHub Pages deployment workflow - Add automated deployment workflow for Storybook - Deploy on push to main when Storybook files change - Support manual trigger via workflow_dispatch - Use official GitHub Actions for Pages deployment * fix(storybook): align Storybook versions and fix TypeScript issues - Update all @storybook/* packages from ^8.4.7 to ^8.6.14 to match main storybook version - Fix CSS type declarations in css.d.ts (Record<string, string> instead of Record<string, never>) - Remove @ts-ignore comments from preview.ts (CSS imports now properly typed) - Fix darkMode type issue in button.stories.tsx with proper ArgTypes type assertion * feat(storybook): replace Button stories with Dropdown component stories - Remove Button stories (shadcn already has documentation) - Add comprehensive Dropdown component stories showcasing: - Default, with value, combobox mode - With metadata, disabled, loading states - Many options, searchable filtering - Dark mode support - Add store initialization decorator for Storybook - Include interaction testing with play functions * feat(storybook): add SettingsPage stories and remove dropdown stories - Remove dropdown component stories - Add SettingsPage stories with router, store, and dark mode decorators - Include variants: default, with general settings, and dark mode * feat(storybook): fix SettingsPage stories to show full page and add play functions - Fix router setup to properly render SettingsPage with nested routes - Add Routes configuration for all settings sub-pages (General, MCP Servers, Global Variables, Shortcuts, Messages) - Add play functions to test page visibility and navigation - Add stories for different routes: Default, WithGeneralSettings, NavigateToShortcuts, NavigateToGlobalVariables, DarkMode * revert(storybook): restore SettingsPage stories to original working version - Revert to simpler router setup without Routes configuration - Remove play functions and complex routing - Restore original three stories: Default, WithGeneralSettings, DarkMode * feat(storybook): add stories for ShortcutsPage and GlobalVariablesPage with tables - Add ShortcutsPage stories showing the shortcuts table - Add GlobalVariablesPage stories showing the global variables table - Include store setup for shortcuts data - Add play functions to verify table visibility - Support dark mode for both pages * fix(storybook): add QueryClientProvider to GlobalVariablesPage stories - Add QueryClientProvider decorator to support React Query hooks - Configure QueryClient with retry disabled for Storybook * fix(storybook): remove WithGeneralSettings story to fix nested router error - Remove WithGeneralSettings story that was causing nested Router error - Keep Default and DarkMode stories only * feat(storybook): enhance SettingsPage stories with multiple states and logic variations - Add stories showcasing different store configurations (autoLogin, hasStore) - Demonstrate conditional General settings visibility logic - Add interactive sidebar navigation story - Show full configuration with all features - Include play functions to verify state-based behavior - Showcase how page adapts to different user/auth states * fix(storybook): initialize Zustand stores synchronously in SettingsPage stories - Set store state before component render instead of in useEffect - Ensures stores are accessible when SettingsPage component mounts - Fixes state access errors in Storybook * feat(storybook): add story to verify store state accessibility - Add VerifyStoreState story that demonstrates accessing Zustand store state - Verify store values match expected configuration - Show that state is accessible from play functions * fix(storybook): remove router from SettingsPage stories to fix errors - Remove MemoryRouter decorator that was causing errors - Keep store setup and dark mode decorators - Stories now work without router dependency * fix(storybook): add router back to SettingsPage stories for useNavigate support - Add MemoryRouter back to support useCustomNavigate hook in PageLayout - Router is needed for navigation hooks to work properly - Keep router at decorator level to avoid nested router errors * fix(storybook): fix router decorator order in SettingsPage stories - Move router decorator to be outermost (last in array) - Decorators run bottom-to-top, so router should wrap everything - Ensures useNavigate context is available to all components * feat(storybook): add PlaygroundPage story as example for complex page stories - Add PlaygroundPage story demonstrating how to create stories for complex pages - Include darkMode toggle control as example for interactive story controls - Set up decorators for query client, router, and theme switching - Hide publish elements (Theme buttons, Built with Langflow) in story view - Center chat title header in story view - Configure Storybook preview and CSS types This story serves as a reference for creating stories for full page components rather than simple UI components, which are already documented in shadcn docs. * chore(storybook): remove SettingsPage stories Keep only PlaygroundPage story as the example for complex page stories. * chore: restore pyproject.toml to match main branch * chore: restore pyproject.toml to match main branch * Revert "chore: restore pyproject.toml to match main branch" This reverts commit a2b75a4028f1f046bc84a8d7999d53a2cb720fc9. * chore: remove src/frontend/pyproject.toml as it doesn't exist in main * fix gitignore and add make commands * update package-json * chore(storybook): migrate from v8.6.14 to v10.1.0 - Update all Storybook packages to v10.1.0 - Replace @storybook/addon-essentials with @storybook/addon-docs - Remove @storybook/addon-interactions (moved to core) - Remove @storybook/blocks and @storybook/test (consolidated) - Fix import in PlaygroundPage.stories.tsx to use @storybook/react - Update tsconfig.json moduleResolution to 'bundler' for better compatibility - Add explicit types configuration for @storybook/react * fix: update package-lock.json to sync with package.json * fix: regenerate package-lock.json with all optional dependencies --------- Co-authored-by: Olfa Maslah <olfamaslah@Olfas-MacBook-Pro.local> Co-authored-by: Cristhian Zanforlin <criszl@MacBook-Pro-di-Cristhian.local> Co-authored-by: Olfa Maslah <olfamaslah@macbookpro.war.can.ibm.com>
238 lines
10 KiB
Makefile
238 lines
10 KiB
Makefile
# Frontend-specific Makefile for Langflow
|
|
# This file contains all frontend-related targets
|
|
|
|
# Variables
|
|
FRONTEND_DIR = src/frontend
|
|
NPM = npm
|
|
|
|
.PHONY: install_frontend install_frontendci install_frontendc frontend_deps_check build_frontend run_frontend frontend frontendc format_frontend tests_frontend test_frontend test_frontend_watch test_frontend_coverage test_frontend_verbose test_frontend_ci test_frontend_clean test_frontend_file test_frontend_pattern test_frontend_snapshots test_frontend_config test_frontend_bail test_frontend_silent test_frontend_coverage_open help_frontend storybook storybook_build storybook_network
|
|
|
|
######################
|
|
# FRONTEND DEPENDENCIES
|
|
######################
|
|
|
|
install_frontend: ## install the frontend dependencies
|
|
@echo 'Installing frontend dependencies'
|
|
@cd $(FRONTEND_DIR) && npm install > /dev/null 2>&1
|
|
|
|
install_frontendci:
|
|
@cd $(FRONTEND_DIR) && npm ci > /dev/null 2>&1
|
|
|
|
install_frontendc:
|
|
@cd $(FRONTEND_DIR) && $(call CLEAR_DIRS,node_modules) && rm -f package-lock.json && npm install > /dev/null 2>&1
|
|
|
|
# Check if frontend dependencies are installed
|
|
frontend_deps_check:
|
|
@if [ ! -d "$(FRONTEND_DIR)/node_modules" ]; then \
|
|
echo "Frontend dependencies not found. Installing..."; \
|
|
$(MAKE) install_frontend; \
|
|
fi
|
|
|
|
######################
|
|
# FRONTEND BUILD
|
|
######################
|
|
|
|
build_frontend: ## build the frontend static files
|
|
@echo '==== Starting frontend build ===='
|
|
@echo 'Current directory: $$(pwd)'
|
|
@echo 'Checking if $(FRONTEND_DIR) exists...'
|
|
@ls -la $(FRONTEND_DIR) || true
|
|
@echo 'Building frontend static files...'
|
|
@cd $(FRONTEND_DIR) && 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 $(FRONTEND_DIR)/build/. src/backend/base/langflow/frontend
|
|
@echo '==== Frontend build complete ===='
|
|
|
|
######################
|
|
# FRONTEND DEVELOPMENT
|
|
######################
|
|
|
|
run_frontend: ## run the frontend
|
|
@-kill -9 `lsof -t -i:3000`
|
|
@cd $(FRONTEND_DIR) && npm start $(if $(FRONTEND_START_FLAGS),-- $(FRONTEND_START_FLAGS))
|
|
|
|
frontend: install_frontend ## run the frontend in development mode
|
|
make run_frontend
|
|
|
|
frontendc: install_frontendc
|
|
make run_frontend
|
|
|
|
######################
|
|
# FRONTEND CODE QUALITY
|
|
######################
|
|
|
|
format_frontend: ## frontend code formatters
|
|
@cd $(FRONTEND_DIR) && npm run format
|
|
|
|
######################
|
|
# FRONTEND E2E TESTS (PLAYWRIGHT)
|
|
######################
|
|
|
|
tests_frontend: ## run frontend tests
|
|
ifeq ($(UI), true)
|
|
@cd $(FRONTEND_DIR) && npx playwright test --ui --project=chromium
|
|
else
|
|
@cd $(FRONTEND_DIR) && npx playwright test --project=chromium
|
|
endif
|
|
|
|
######################
|
|
# FRONTEND UNIT TESTS (JEST)
|
|
######################
|
|
|
|
# Run all frontend Jest unit tests
|
|
test_frontend: frontend_deps_check ## run all frontend Jest unit tests
|
|
@echo "Running all frontend Jest unit tests..."
|
|
@cd $(FRONTEND_DIR) && $(NPM) test
|
|
|
|
# Run frontend tests in watch mode
|
|
test_frontend_watch: frontend_deps_check ## run frontend tests in watch mode
|
|
@echo "Running frontend tests in watch mode..."
|
|
@cd $(FRONTEND_DIR) && $(NPM) run test:watch
|
|
|
|
# Run frontend tests with coverage report
|
|
test_frontend_coverage: frontend_deps_check ## run frontend tests with coverage report
|
|
@echo "Running frontend tests with coverage report..."
|
|
@cd $(FRONTEND_DIR) && npx jest --coverage
|
|
|
|
# Run frontend tests with verbose output
|
|
test_frontend_verbose: frontend_deps_check ## run frontend tests with verbose output
|
|
@echo "Running frontend tests with verbose output..."
|
|
@cd $(FRONTEND_DIR) && npx jest --verbose
|
|
|
|
# Run frontend tests in CI mode (no watch, with coverage)
|
|
test_frontend_ci: frontend_deps_check ## run frontend tests in CI mode
|
|
@echo "Running frontend tests in CI mode..."
|
|
@cd $(FRONTEND_DIR) && CI=true npx jest --ci --coverage --watchAll=false
|
|
|
|
# Clean test cache and run tests
|
|
test_frontend_clean: frontend_deps_check ## clean test cache and run tests
|
|
@echo "Cleaning Jest cache and running tests..."
|
|
@cd $(FRONTEND_DIR) && npx jest --clearCache && npx jest
|
|
|
|
# Run tests for a specific file
|
|
test_frontend_file: frontend_deps_check ## run tests for a specific file (usage: make test_frontend_file path/to/test.ts)
|
|
$(eval file := $(word 2,$(MAKECMDGOALS)))
|
|
@if [ -z "$(file)" ]; then \
|
|
echo "Usage: make test_frontend_file path/to/test.ts"; \
|
|
exit 1; \
|
|
fi
|
|
@echo "Running tests for file: $(file)"
|
|
@cd $(FRONTEND_DIR) && npx jest $(file)
|
|
|
|
# Prevent make from treating the file argument as another target
|
|
%:
|
|
@:
|
|
|
|
# Run tests matching a pattern
|
|
test_frontend_pattern: frontend_deps_check ## run tests matching a pattern (usage: make test_frontend_pattern pattern)
|
|
$(eval pattern := $(word 2,$(MAKECMDGOALS)))
|
|
@if [ -z "$(pattern)" ]; then \
|
|
echo "Usage: make test_frontend_pattern pattern"; \
|
|
exit 1; \
|
|
fi
|
|
@echo "Running tests matching pattern: $(pattern)"
|
|
@cd $(FRONTEND_DIR) && npx jest --testNamePattern="$(pattern)"
|
|
|
|
# Update test snapshots
|
|
test_frontend_snapshots: frontend_deps_check ## update Jest snapshots
|
|
@echo "Updating Jest snapshots..."
|
|
@cd $(FRONTEND_DIR) && npx jest --updateSnapshot
|
|
|
|
# Show test configuration
|
|
test_frontend_config: ## show Jest configuration
|
|
@echo "Jest configuration:"
|
|
@cd $(FRONTEND_DIR) && npx jest --showConfig
|
|
|
|
# Run Jest tests with bail (stop on first failure)
|
|
test_frontend_bail: frontend_deps_check ## run tests with bail (stop on first failure)
|
|
@echo "Running Jest tests with bail (stop on first failure)..."
|
|
@cd $(FRONTEND_DIR) && npx jest --bail
|
|
|
|
# Run Jest tests silently (minimal output)
|
|
test_frontend_silent: frontend_deps_check ## run tests silently (minimal output)
|
|
@echo "Running Jest tests silently..."
|
|
@cd $(FRONTEND_DIR) && npx jest --silent
|
|
|
|
# Run Jest tests and open coverage report in browser
|
|
test_frontend_coverage_open: test_frontend_coverage ## run tests with coverage and open report in browser
|
|
@echo "Opening coverage report in browser..."
|
|
@if command -v open >/dev/null 2>&1; then \
|
|
open $(FRONTEND_DIR)/coverage/lcov-report/index.html; \
|
|
elif command -v xdg-open >/dev/null 2>&1; then \
|
|
xdg-open $(FRONTEND_DIR)/coverage/lcov-report/index.html; \
|
|
else \
|
|
echo "Coverage report generated at: $(FRONTEND_DIR)/coverage/lcov-report/index.html"; \
|
|
fi
|
|
|
|
######################
|
|
# STORYBOOK
|
|
######################
|
|
|
|
storybook: frontend_deps_check ## run Storybook development server and open in browser
|
|
@echo "Starting Storybook development server on http://localhost:6006..."
|
|
@cd $(FRONTEND_DIR) && $(NPM) run storybook
|
|
|
|
storybook_build: frontend_deps_check ## build static Storybook
|
|
@echo "Building static Storybook..."
|
|
@cd $(FRONTEND_DIR) && $(NPM) run build-storybook
|
|
@echo "Storybook built to $(FRONTEND_DIR)/storybook-static"
|
|
|
|
storybook_network: frontend_deps_check ## run Storybook accessible on network (0.0.0.0:6006)
|
|
@echo "Starting Storybook development server accessible on network..."
|
|
@cd $(FRONTEND_DIR) && $(NPM) run storybook:network
|
|
|
|
######################
|
|
# FRONTEND HELP
|
|
######################
|
|
|
|
help_frontend: ## show frontend help
|
|
@echo ''
|
|
@echo "$(GREEN)═══════════════════════════════════════════════════════════════════$(NC)"
|
|
@echo "$(GREEN) FRONTEND COMMANDS $(NC)"
|
|
@echo "$(GREEN)═══════════════════════════════════════════════════════════════════$(NC)"
|
|
@echo ''
|
|
@echo "$(GREEN)Dependencies:$(NC)"
|
|
@echo " $(GREEN)make install_frontend$(NC) - Install frontend dependencies"
|
|
@echo " $(GREEN)make install_frontendci$(NC) - Install frontend dependencies with npm ci"
|
|
@echo " $(GREEN)make install_frontendc$(NC) - Clean install frontend dependencies"
|
|
@echo ''
|
|
@echo "$(GREEN)Build & Development:$(NC)"
|
|
@echo " $(GREEN)make build_frontend$(NC) - Build frontend static files"
|
|
@echo " $(GREEN)make run_frontend$(NC) - Run the frontend development server"
|
|
@echo " $(GREEN)make frontend$(NC) - Install dependencies and run frontend in dev mode"
|
|
@echo " $(GREEN)make frontendc$(NC) - Clean install dependencies and run frontend"
|
|
@echo ''
|
|
@echo "$(GREEN)Code Quality:$(NC)"
|
|
@echo " $(GREEN)make format_frontend$(NC) - Format frontend code"
|
|
@echo " $(GREEN)make format_frontend_check$(NC) - Check frontend formatting (biome)"
|
|
@echo ''
|
|
@echo "$(GREEN)E2E Testing (Playwright):$(NC)"
|
|
@echo " $(GREEN)make tests_frontend$(NC) - Run Playwright e2e tests"
|
|
@echo " $(GREEN)make tests_frontend UI=true$(NC) - Run Playwright e2e tests with UI"
|
|
@echo ''
|
|
@echo "$(GREEN)Unit Testing (Jest):$(NC)"
|
|
@echo " $(GREEN)make test_frontend$(NC) - Run Jest unit tests"
|
|
@echo " $(GREEN)make test_frontend_watch$(NC) - Run unit tests in watch mode"
|
|
@echo " $(GREEN)make test_frontend_coverage$(NC) - Run unit tests with coverage"
|
|
@echo " $(GREEN)make test_frontend_coverage_open$(NC) - Run coverage and open report"
|
|
@echo " $(GREEN)make test_frontend_verbose$(NC) - Run unit tests with verbose output"
|
|
@echo " $(GREEN)make test_frontend_ci$(NC) - Run unit tests in CI mode"
|
|
@echo " $(GREEN)make test_frontend_clean$(NC) - Clean cache and run unit tests"
|
|
@echo " $(GREEN)make test_frontend_bail$(NC) - Run unit tests with bail"
|
|
@echo " $(GREEN)make test_frontend_silent$(NC) - Run unit tests silently"
|
|
@echo ''
|
|
@echo "$(GREEN)Targeted Testing:$(NC)"
|
|
@echo " $(GREEN)make test_frontend_file path$(NC) - Run tests for specific file"
|
|
@echo " $(GREEN)make test_frontend_pattern pattern$(NC) - Run tests matching pattern"
|
|
@echo " $(GREEN)make test_frontend_snapshots$(NC) - Update Jest snapshots"
|
|
@echo " $(GREEN)make test_frontend_config$(NC) - Show Jest configuration"
|
|
@echo ''
|
|
@echo "$(GREEN)Storybook:$(NC)"
|
|
@echo " $(GREEN)make storybook$(NC) - Run Storybook dev server and open in browser"
|
|
@echo " $(GREEN)make storybook_build$(NC) - Build static Storybook"
|
|
@echo " $(GREEN)make storybook_network$(NC) - Run Storybook accessible on network"
|
|
@echo ''
|
|
@echo "$(GREEN)═══════════════════════════════════════════════════════════════════$(NC)"
|
|
@echo ''
|