This directory contains all tests for the TourGuideAI application.
The tests are organized into the following directories:
tests/
├── config/ # Test configuration files (see below)
├── cross-browser/ # Cross-browser compatibility tests
├── load/ # Load and performance tests
├── security/ # Security testing
├── smoke/ # Smoke tests for quick verification
├── stability/ # Stability and regression tests
└── user-journey/ # End-to-end user journey tests
The following scripts are available to run tests:
tests/
├── run-frontend-tests.ps1 # PowerShell script for running all frontend tests
All test configurations have been reorganized for better maintainability. The new structure is:
tests/config/
├── jest/ # Jest configurations
│ ├── backend.config.js # Configuration for backend tests
│ ├── frontend.config.js # Configuration for frontend tests
│ └── integration.config.js # Configuration for integration tests
│
├── playwright/ # Playwright configurations
│ ├── base.config.js # Base configuration that others extend
│ └── cross-browser.config.js # Cross-browser specific configuration
│
├── browserstack/ # BrowserStack configurations
│ ├── base.config.js # Base BrowserStack configuration
│ └── cross-browser.config.js # Cross-browser BrowserStack configuration
│
├── mocks/ # Mock files for testing
└── integration-setup.js # Setup for integration tests
For backward compatibility, the original configuration files now import from the new structure. You might see references to:
tests/config/playwright.config.js→ usetests/config/playwright/cross-browser.config.jsinsteadtests/config/jest.frontend.config.js→ usetests/config/jest/frontend.config.jsinsteadtests/config/jest.backend.config.js→ usetests/config/jest/backend.config.jsinsteadtests/config/jest.integration.config.js→ usetests/config/jest/integration.config.jsinsteadtests/config/browserstack.config.js→ usetests/config/browserstack/cross-browser.config.jsinstead
To update references in scripts to use the new configuration paths, run:
node scripts/update-config-references.js
See the scripts section in package.json for available test commands:
# Run frontend tests
npm run test:frontend
# Run backend tests
npm run test:backend
# Run integration tests
npm run test:integration
# Run cross-browser tests
npm run test:cross-browser
# Run load tests
npm run test:load
# Run security tests
npm run test:security
# Run user journey tests
npm run test:user-journeysYou can also use the PowerShell scripts for running tests on Windows:
# Run all frontend tests
.\tests\run-frontend-tests.ps1
# Run all backend tests
.\server\tests\run-server-tests.ps1
# Run all tests (both frontend and backend)
.\scripts\run-all-tests.ps1tests/
├── config/ # Test configuration files
│ ├── browserstack.config.js # BrowserStack configuration
│ ├── playwright.config.js # Playwright configuration
│ └── README.md # Configuration documentation
├── cross-browser/ # Cross-browser compatibility tests
│ ├── specs/ # Test specifications
│ │ └── cross-browser.test.js # General cross-browser tests
│ ├── browser-test-matrix.js # Browser configuration matrix
│ ├── browserstack.config.js # BrowserStack-specific configuration
│ ├── playwright.config.js # Playwright-specific configuration
│ ├── README.md # Cross-browser testing documentation
│ └── travel-planning.spec.js # Travel planning feature tests
├── load/ # Load and performance tests
│ ├── scenarios/ # Load test scenarios
│ ├── k6.config.js # k6 configuration
│ ├── load-test.js # Main load tests
│ ├── README.md # Load testing documentation
│ └── route-generation-load.js # Route generation load tests
├── security/ # Security tests and audits
│ ├── security-audit.js # Security auditing script
│ └── README.md # Security testing documentation
├── smoke/ # Smoke tests for critical paths
│ ├── smoke.test.js # Smoke test suite
│ └── README.md # Smoke testing documentation
├── stability/ # Stability and reliability tests
│ ├── frontend-stability.test.js # Frontend stability tests
│ └── README.md # Stability testing documentation
├── user-journey/ # User journey tests with Playwright
│ ├── sarah-casual-tourist.spec.ts # Casual tourist persona tests
│ ├── michael-history-enthusiast.spec.ts # History enthusiast persona tests
│ ├── elena-family-traveler.spec.ts # Family traveler persona tests
│ ├── james-business-traveler.spec.ts # Business traveler persona tests
│ └── tanya-adventure-seeker.spec.ts # Adventure seeker persona tests
├── run-frontend-tests.ps1 # PowerShell script for running all frontend tests
└── README.md # This file
Quick tests that verify the most critical functionality of the application is working. These are run frequently and should be fast.
Tests that ensure the application works correctly across different browsers and platforms. These use Playwright and BrowserStack for automation.
Performance and scalability tests to verify the application can handle expected load. These use k6 for load testing.
Security auditing and penetration testing scripts that identify potential vulnerabilities in the application.
Long-running tests that verify the application's reliability and stability under continuous use.
The user-journey directory contains Playwright tests that simulate various user personas interacting with the TourGuideAI application. These tests cover realistic user scenarios and help ensure that the application meets the needs of different user types.
The following user personas are simulated in the tests:
- Sarah (Casual Tourist) - Weekend city exploration in Barcelona
- Michael (History Enthusiast) - Historical deep dive in Rome
- Elena (Family Traveler) - Family-friendly London exploration
- James (Business Traveler) - Business trip to Tokyo with limited free time
- Tanya (Adventure Seeker) - Active exploration of Costa Rica
User journey tests have been recently fixed to address several issues:
- Selector Specificity: Added data-testid attributes to elements in
test-helpers.tsto improve selector specificity in strict mode. - Template String Syntax: Corrected template string syntax in test files where template literals were missing proper backtick formatting.
- Duplicate Element Resolution: Resolved issues with duplicate elements by using more specific selectors.
- URL Handling: Fixed integration test files to use proper baseUrl format.
All user journey tests are now passing successfully. See docs/project_lifecycle/all_tests/results/user-journey/README.md for more details.
When adding new tests:
- Place tests in the appropriate directory based on test type
- Follow the existing naming conventions
- Update this documentation if you create new test categories
- Ensure all tests have proper assertions and error handling
- Include descriptive comments explaining the test purpose
This document provides instructions on how to set up and run the test scripts for TourGuideAI.
Before running the test scripts, ensure you have the following:
- Node.js and npm installed
- All project dependencies installed (
npm install) - Appropriate permissions to run scripts on your system
PowerShell scripts may be blocked from running due to execution policies. To enable running the scripts:
- Open PowerShell as Administrator
- Set the execution policy to allow running the scripts:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
- Alternatively, run the scripts with the
-ExecutionPolicy Bypassparameter:powershell -ExecutionPolicy Bypass -File .\scripts\run-all-tests.ps1
Batch files should work without additional configuration, but ensure they have the correct line endings (CRLF for Windows).
To run a batch file:
cmd /c scripts\run-all-tests.batBefore running bash scripts, you need to make them executable:
chmod +x scripts/run-all-tests.sh
chmod +x tests/*.sh # If you have any other scripts in the tests directoryThen you can run them:
./scripts/run-all-tests.shIf you receive "file not found" errors when trying to run scripts:
- Check that you are in the project root directory
- Verify that the scripts exist in the specified paths
- Use the full path to the script:
C:\full\path\to\TourGuideAI\scripts\run-all-tests.bat
If you receive "permission denied" errors:
Windows:
- Right-click on the script file
- Select Properties
- Click the "Unblock" button if it's available
- Click Apply and OK
Unix/Linux/macOS:
chmod +x <script_file>If scripts fail to run properly:
- Check for syntax errors in the script
- Ensure you have the required environment variables set
- Verify that Node.js and npm are in your PATH
- Try running with administrator privileges
- The test scripts will create a
test-resultsdirectory in the project root to store test reports - If you customize the scripts, ensure you maintain proper paths and error handling
- For CI/CD integration, use the appropriate script for your platform in your CI pipeline