[#657] [#659] Fixed accessibility report directory and report URL display.#660
Conversation
…play. Captured the working directory at @BeforeSuite so the default report directory stays anchored to the run base path instead of the docroot that the 'drupal' driver chdir()s into during '@api' bootstrap. The test FeatureContext derives the base from the Mink 'files_path'. Added 'accessibilityFormatUrl()' to strip the configured Mink 'base_url' prefix from URLs shown in HTML and JUnit reports, gate messages, and console output, while keeping genuinely cross-origin URLs absolute.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
Walkthrough
ChangesAccessibilityTrait stability and URL formatting
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/AccessibilityTrait.php`:
- Around line 119-121: When `getcwd()` returns FALSE in the AccessibilityTrait
class initialization block, the code currently sets
`self::$accessibilityBaseDir` to an empty string, which prevents the fallback
logic at line 319-321 from retrying `getcwd()` later since that fallback checks
for NULL. To preserve the fallback semantics, keep `self::$accessibilityBaseDir`
as NULL when `getcwd()` fails instead of assigning an empty string, allowing the
fallback mechanism to properly retry `getcwd()` and resolve reports to the
correct run-local path.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 7e9c77a9-70df-4e51-b3a5-29d13488077a
📒 Files selected for processing (4)
src/AccessibilityTrait.phptests/behat/bootstrap/FeatureContext.phptests/behat/features/accessibility.featuretests/phpunit/src/AccessibilityTraitTest.php
…ls so the fallback retries.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #660 +/- ##
==========================================
+ Coverage 96.59% 96.60% +0.01%
==========================================
Files 46 46
Lines 3523 3537 +14
==========================================
+ Hits 3403 3417 +14
Misses 120 120 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Closes #657
Closes #659
Summary
AccessibilityTraitbuilt its report directory from a livegetcwd()call, but the Drupal Extension@apibootstrap callschdir()to the docroot before the first scenario runs, silently moving reports intoweb/.logs/...instead of the project-root.logs/tree. A new#[BeforeSuite]hook captures the launch directory into a static$accessibilityBaseDironce before any scenario can alter it, anchoring the default report path to that stable base. Per-scenario reports and console/gate messages also printed the full internal URL including host and port (e.g.http://nginx:8080/contact), which is noise and non-portable across environments. A newaccessibilityFormatUrl()method strips the configured Minkbase_urlprefix so display paths show as/contact; the base URL itself maps to/, query strings are preserved, and genuinely cross-origin URLs remain absolute.Changes
src/AccessibilityTrait.php$accessibilityBaseDirstatic property to hold the captured launch directory.#[BeforeSuite]hookaccessibilityCaptureBaseDir()that sets$accessibilityBaseDirfromgetcwd()once before any scenario runs.accessibilityGetReportDir()to anchor the default.logs/test_results/accessibilitypath to$accessibilityBaseDir, falling back to the livegetcwd()when the hook has not run.accessibilityFormatUrl(string $url): stringthat strips thebase_urlprefix for display, mapping the base root to/and preserving query strings; cross-origin URLs are left absolute.accessibilityFormatUrl()at all five rendering sites: auto-mode gate violation lines, auto-mode gate incomplete lines, console output line, explicit gate message header, HTML<h2>heading, and JUnittestsuite name+URL:detail line.tests/behat/bootstrap/FeatureContext.phpaccessibilityGetReportDir()override that derives the base from the Minkfiles_pathparameter, keeping accessibility reports in the same.logstree as coverage and screenshots when Behat is launched frombuild/with a project-rootbehat.yml.tests/behat/features/accessibility.feature@traitscenario assertions to verify that the stripped page path (/sites/default/files/accessibility_violations.html) appears in gate output rather than just checking the gate prefix.tests/phpunit/src/AccessibilityTraitTest.php(new)accessibilityFormatUrl()covering path stripping, root mapping, query-string preservation, cross-origin safety, similar-prefix safety, and empty base URL passthrough.accessibilityGetReportDir()verifying it anchors to the captured base dir and falls back to the live cwd when unset.accessibilityCaptureBaseDir()verifying it sets the property when unset and does not overwrite an existing value.Before / After
Report directory (with
@apibootstrap)Gate / console output URL display
Summary
This PR fixes two issues in
AccessibilityTraitoutput stability and portability:Report directory placement after Drupal
@apibootstrapdrupalAPI driver callschdir()to the docroot during bootstrap, shiftinggetcwd()away from the project root.web/.logs/test_results/accessibility/instead of the expected project-root.logs/test_results/accessibility/.#[BeforeSuite]hookaccessibilityCaptureBaseDir()that captures the initial working directory into a static$accessibilityBaseDirbefore scenarios can change it.accessibilityGetReportDir()now builds paths from this captured base (falling back to livegetcwd()for backward compatibility). If base capture encounters a transient failure, the captured base is left unset so the fallback can still retry rather than persisting stale state.Environment-specific absolute URLs in reports and console output
http://nginx:8080/contact, polluting output and breaking portability.accessibilityFormatUrl()normalizes displayed URLs by stripping the Minkbase_urlprefix (mapping the base itself to/, preserving query strings, and keeping genuinely cross-origin absolute URLs unchanged).Changes
src/AccessibilityTrait.php$accessibilityBaseDirand#[BeforeSuite] accessibilityCaptureBaseDir()capture logic.accessibilityGetReportDir()to anchor to$accessibilityBaseDir(with fallback togetcwd()).accessibilityFormatUrl()and updated five output/rendering sites to use it.tests/behat/bootstrap/FeatureContext.phpaccessibilityGetReportDir()to derive the base directory from the Minkfiles_path, keeping accessibility reports in the same.logstree as other Behat artifacts.tests/behat/features/accessibility.feature/sites/default/files/accessibility_violations.htmland including it in auto/explicit gate failure lines).tests/phpunit/src/AccessibilityTraitTest.phpStep definition / CONTRIBUTING.md compliance