[#166] Fixed triggering a full screen screenshot in the test will not resize the window back to the original size.#170
Conversation
… resize the window back to the original size.
📝 WalkthroughWalkthroughUpdates fullscreen screenshot resizing logic to default and probe window dimensions, add a stabilization delay, and always attempt to restore the original size. Unit tests are revised to simulate sequential JS evaluations, verify resize sequencing and values, and cover invalid-dimension scenarios. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant Test as Behat Test
participant Ctx as ScreenshotContext
participant Sess as Mink Session
participant Drv as WebDriver (JS Eval)
Test->>Ctx: getScreenshotFullscreenWithResize()
activate Ctx
note over Ctx: Initialize default original size 1440x900
Ctx->>Sess: evaluateScript(window.outerWidth/outerHeight)
alt JS ok
Sess-->>Ctx: numeric width/height
note over Ctx: Set original size from JS
else JS fails or non-numeric
Sess-->>Ctx: error/invalid
note over Ctx: Keep defaults
end
Ctx->>Sess: evaluateScript(document dimensions)
Sess-->>Ctx: page width/height
alt valid dimensions
Ctx->>Sess: resizeWindow(pageWidth, pageHeight)
note over Ctx: Short delay (usleep)
Ctx->>Sess: capture screenshot
Ctx-->>Test: screenshot data
note over Ctx: Best-effort restore
Ctx->>Sess: resizeWindow(originalWidth, originalHeight)
Sess-->>Ctx: (ignored on error)
else invalid dimensions
Ctx->>Sess: capture screenshot (no resize)
Ctx-->>Test: screenshot data
end
deactivate Ctx
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: ASSERTIVE Plan: Pro 📒 Files selected for processing (2)
🧰 Additional context used📓 Path-based instructions (2)**/*.php📄 CodeRabbit inference engine (CLAUDE.md)
Files:
{phpunit.xml,tests/**/*.php}📄 CodeRabbit inference engine (CLAUDE.md)
Files:
🧬 Code graph analysis (1)src/DrevOps/BehatScreenshotExtension/Context/ScreenshotContext.php (1)
🪛 PHPMD (2.15.0)tests/phpunit/Unit/ScreenshotContextResizeTest.php56-56: The variable $call_count is not named in camelCase. (undefined) (CamelCaseVariableName) src/DrevOps/BehatScreenshotExtension/Context/ScreenshotContext.php441-441: The variable $original_width is not named in camelCase. (undefined) (CamelCaseVariableName) 442-442: The variable $original_height is not named in camelCase. (undefined) (CamelCaseVariableName) 446-446: The variable $original_dimensions is not named in camelCase. (undefined) (CamelCaseVariableName) Comment |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #170 +/- ##
==========================================
+ Coverage 68.24% 69.35% +1.10%
==========================================
Files 4 4
Lines 381 385 +4
==========================================
+ Hits 260 267 +7
+ Misses 121 118 -3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Summary by CodeRabbit
Bug Fixes
Tests