Skip to content

Add responsive capture and cross iframe features#26

Open
yashmahamulkar-bs wants to merge 2 commits intomainfrom
PPLT-5036
Open

Add responsive capture and cross iframe features#26
yashmahamulkar-bs wants to merge 2 commits intomainfrom
PPLT-5036

Conversation

@yashmahamulkar-bs
Copy link

This pull request introduces significant improvements to the Percy Ruby SDK, focusing on enhancing cross-origin iframe handling, adding Percy Automate support, and improving caching and configuration. The changes introduce a new caching system with tests, robust cross-origin iframe serialization, new environment/configuration options, and a dedicated API for Percy Automate screenshots. Additionally, the Percy CLI dependency is updated.

Major enhancements and new features:

Cross-origin iframe support and responsive snapshot improvements:

  • Enhanced the get_serialized_dom method in percy.rb to process cross-origin iframes, including logic to switch frames, handle errors, and serialize their DOMs. Added helper methods like unsupported_iframe_src?, get_origin, and process_frame for robust iframe handling.
  • Improved responsive snapshot capture by introducing environment/configuration options for minimum height and page reload, and by making window resizing more robust and informative. [1] [2]

Percy Automate support:

  • Added a new percy_screenshot API for Percy Automate sessions, with input validation and error handling. Introduced a DriverMetaData class to extract and cache session metadata, and updated the cache management logic. [1] [2] [3]
  • Updated the percy_enabled? method to detect session type (automate or not) and enforce correct API usage for snapshot vs. screenshot. [1] [2]

Caching and configuration improvements:

Caching system:

  • Introduced a new Cache class for session-based caching of metadata, with automatic timeout and cleanup. Added a comprehensive test suite for the cache. [1] [2]
  • Integrated the cache into driver metadata extraction, reducing redundant calls and improving performance.

Configuration and environment options:

  • Added support for PERCY_RESPONSIVE_CAPTURE_RELOAD_PAGE and PERCY_RESPONSIVE_CAPTURE_MIN_HEIGHT environment variables to control responsive snapshot behavior. [1] [2]

Dependency update:

  • Updated the Percy CLI dependency from version 1.30.9 to 1.31.10 in package.json.

Summary of most important changes:

Cross-origin iframe and responsive snapshot improvements

  • Enhanced DOM serialization to handle cross-origin iframes robustly, including switching frames, error handling, and associating snapshots with data-percy-element-id.
  • Improved responsive snapshot logic with options for minimum height and page reload, and made window resizing more reliable. [1] [2]

Percy Automate support

  • Added percy_screenshot API for Automate sessions, with strict validation and error reporting, and a new DriverMetaData class for session metadata extraction and caching. [1] [2]
  • Updated API usage enforcement: percy_snapshot is now disallowed on Automate sessions and vice versa, with clear error messages. [1] [2]

Caching system and tests

  • Introduced a new Cache class for metadata caching, with timeout and cleanup logic, and comprehensive RSpec tests for all cache functionality. [1] [2]

Configuration and environment improvements

  • Added new environment variables and config options for responsive snapshot behavior: PERCY_RESPONSIVE_CAPTURE_RELOAD_PAGE and PERCY_RESPONSIVE_CAPTURE_MIN_HEIGHT. [1] [2]

Dependency update

  • Upgraded @percy/cli from version 1.30.9 to 1.31.10 in package.json.

@yashmahamulkar-bs yashmahamulkar-bs requested a review from a team as a code owner March 20, 2026 16:26
@yashmahamulkar-bs
Copy link
Author

@copilot

Copy link

Copilot AI commented Mar 20, 2026

@yashmahamulkar-bs I've opened a new pull request, #27, to work on those changes. Once the pull request is ready, I'll request review from you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants