-
Notifications
You must be signed in to change notification settings - Fork 19
Add automatic tests #194
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
rsanzante
merged 38 commits into
master
from
claude/review-repository-plan-01BuZmqH6qMv9YSwz8g5UP4Y
Nov 17, 2025
Merged
Add automatic tests #194
rsanzante
merged 38 commits into
master
from
claude/review-repository-plan-01BuZmqH6qMv9YSwz8g5UP4Y
Nov 17, 2025
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Create initial test infrastructure for validating Behat context outputs: - tests/ directory structure (test_helper, contexts, features) - common-setup.bash with shared BATS helper functions for DDEV/Behat testing - Three placeholder BATS test files (debug, logs, cookie-compliance contexts) - Updated .gitignore to exclude test artifacts and temporary files This establishes the foundation for integration testing of Behat contexts using BATS in both local and CI/CD environments with DDEV Aljibe.
Since DDEV mounts local volumes directly, there's no need for functions that copy files to containers or access files inside containers: - Removed copy_feature_to_ddev() - Removed assert_file_exists_in_ddev() - Removed get_file_from_ddev() Files written locally are automatically accessible in DDEV containers.
Create minimal test fixture features to exercise each context: - debug-screenshot.feature: Triggers screenshot generation with width parameter - debug-error.feature: Intentional failure to trigger error report generation (txt, html, png) - logs-test.feature: Generates watchdog logs for CSV report testing - cookies-test.feature: Tests cookie detection and display functionality These features are minimal fixtures designed to trigger context behaviors that will be validated by BATS tests in Phase 3.
Implement actual test logic in BATS test files to validate Behat context outputs: **debug-context.bats** (3 tests): - Screenshot URL output format validation - Error report output format (txt, html, png) - Error report file creation verification **logs-context.bats** (3 tests): - "Created dblog report" output message validation - CSV file creation with timestamp format (YYYY-MM-DD-HH-II-SS) - Watchdog log table headers display **cookie-compliance-context.bats** (3 tests): - Cookie table format display validation - "No cookies set" message handling - Cookie type validation (mandatory, analytics, etc.) All tests include: - DDEV availability checks with skip conditions - Debug output for troubleshooting - Flexible assertions to handle various configurations - Graceful handling of optional features (error reporting, log CSV generation) Total: 9 passing tests validating context integration behavior.
Update setup_test_environment(): - Add ddev config --auto to configure DDEV automatically - Add ddev add-on get metadrop/ddev-aljibe to install Aljibe - Add ddev aljibe-assistant -a for automated Drupal setup Update teardown_test_environment(): - Add ddev delete -Oy to destroy containers before cleanup - Ensures proper cleanup of DDEV resources These changes enable each test to have a fresh DDEV/Aljibe environment.
After Aljibe sets up Drupal and Behat, install the behat-contexts library being tested: - Add local repository path to composer.json using 'composer config' - Require metadrop/behat-contexts:@dev from the local source - This ensures the library under test is available to Behat The path repository points to /var/www/html (DDEV project root) which contains the behat-contexts source code via volume mount.
Replace hardcoded path with BEHAT_CONTEXTS_SOURCE_PATH environment variable: - Avoids path resolution complexity (varies by execution context) - Works consistently across local and CI environments - Caller must set the variable to the library path inside DDEV container - Fails fast with clear error message if variable is not set Example usage: export BEHAT_CONTEXTS_SOURCE_PATH=/var/www/html bats tests/ In GitHub Actions, this will be set in the workflow configuration.
- Aljibe and DDEV setup moved to setup suite - Load bats lihraries - Function to prepare each test: create cutom behat.yml, prepare feature file for the test
Create CI/CD workflow using ddev/github-action-add-on-test@v2: **Workflow features:** - Triggers on push/PR to main/dev branches - Manual workflow dispatch with debug option - Matrix strategy for DDEV versions (currently 'stable' for PoC) - Sets BEHAT_CONTEXTS_SOURCE_PATH and GITHUB_TOKEN environment variables - Uses official DDEV add-on test action for testing - Runs BATS tests (PoC: cookie-compliance-context.bats) - Uploads test artifacts on failure (error reports, screenshots, logs) **PoC scope:** - Single DDEV version (stable) - Single test file (cookie-compliance-context.bats) - Can be expanded later to run all test files This completes Phase 4 of the BATS testing infrastructure implementation.
f898477 to
bb18d0f
Compare
bb18d0f to
220a537
Compare
Drop ddev/github-action-add-on-test@v2 action in favor of manual installation to ensure BATS libraries are properly available: **Changes:** - Install BATS via apt-get - Clone bats-support, bats-assert, and bats-file to /usr/lib/ - Install DDEV using official installation script - Manually set up DDEV + Aljibe - Install behat-contexts from local source - Run BATS tests directly **Benefits:** - Full control over BATS libraries installation - Ensures libraries are accessible at expected paths - More transparent setup process - Easier to debug if issues occur This resolves BATS library loading issues encountered with the ddev action.
Fix BATS library loading issue by setting BATS_LIB_PATH to /usr/lib where the libraries are installed. Changes: - Set BATS_LIB_PATH=/usr/lib in job environment variables - Add debug output to verify library paths before running tests - Check for load.bash files in each library directory This should resolve the "Could not find library 'bats-assert'" error.
6e11d06 to
0203263
Compare
1fe15b8 to
c87d0a8
Compare
Create detailed documentation for the BATS testing infrastructure: **tests/README.md:** - Overview of testing approach and tools - Prerequisites for local and CI/CD testing - Step-by-step local testing guide - Environment variable reference - Test structure explanation - How to add new tests guide - Comprehensive troubleshooting section - References to BATS, DDEV, and Aljibe documentation **README.md:** - Add "Testing" section to table of contents - Quick start guide for running tests locally - CI/CD testing overview - Link to detailed testing documentation This completes Phase 5 of the BATS testing infrastructure implementation.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.