Skip to content

test(e2e): Add viewport text hiding for screenshot comparisons#6142

Open
GhadeerAlbattarni wants to merge 2 commits into
OHIF:masterfrom
GhadeerAlbattarni:test/viewport-hide-text
Open

test(e2e): Add viewport text hiding for screenshot comparisons#6142
GhadeerAlbattarni wants to merge 2 commits into
OHIF:masterfrom
GhadeerAlbattarni:test/viewport-hide-text

Conversation

@GhadeerAlbattarni

@GhadeerAlbattarni GhadeerAlbattarni commented Jul 13, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Add hide-text methods to ViewportPageObject so tests can hide viewport overlay, annotation, orientation marker, demographic, and laterality text before taking screenshots.

  • Add checkForViewportScreenshot, a viewport-scoped wrapper around checkForScreenshot that accepts a hideText option ('all', 'overlay', 'demographic', 'annotation', 'laterality', 'orientationMarker', or an array of those).

  • Extend checkForScreenshot with an optional beforeAttempt callback, invoked at the start of each screenshot retry to guard against React re-renders clearing the hidden class during retry cycles.

  • CheckForScreenshotProps is now exported to allow derived types like checkForViewportScreenshot to build on it without duplicating the prop definitions.

Usage

import { checkForViewportScreenshot, screenShotPaths, test } from './utils';
const activeViewport = await viewportPageObject.active;
// Hide overlay text only (keep measurement annotations visible)
await checkForViewportScreenshot({
  page,
  viewport: activeViewport,
  locator: viewportPageObject.grid,
  screenshotPath: screenShotPaths.somePath,
  hideText: 'overlay',
});

Testing

Checklist

PR

  • My Pull Request title is descriptive, accurate and follows the
    semantic-release format and guidelines.

Code

  • My code has been well-documented (function documentation, inline comments,
    etc.)

Public Documentation Updates

  • The documentation page has been updated as necessary for any public API
    additions or removals.

Tested Environment

  • OS: macOS 10.15.4
  • Node version: v24.18.0
  • Browser: Chrome 83.0.4103.116

Summary by CodeRabbit

  • New Features
    • Added viewport screenshot comparisons with options to hide overlay, demographic, annotation, laterality, orientation marker, or all text.
    • Added configurable pre-screenshot actions that run before each comparison attempt.
    • Expanded viewport testing controls for selectively hiding text and markers.
  • Tests
    • Improved screenshot test reliability by supporting text-free viewport comparisons and retry-aware setup actions.

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@netlify

netlify Bot commented Jul 13, 2026

Copy link
Copy Markdown

Deploy Preview for ohif-dev ready!

Name Link
🔨 Latest commit 514fa6b
🔍 Latest deploy log https://app.netlify.com/projects/ohif-dev/deploys/6a5510226e373e0008375f35
😎 Deploy Preview https://deploy-preview-6142--ohif-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 1bbfe589-c245-4af6-9570-c65adeb8f05c

📥 Commits

Reviewing files that changed from the base of the PR and between 110b293 and 514fa6b.

📒 Files selected for processing (4)
  • tests/pages/ViewportPageObject.ts
  • tests/utils/checkForScreenshot.ts
  • tests/utils/checkForViewportScreenshot.ts
  • tests/utils/index.ts

📝 Walkthrough

Walkthrough

Adds viewport page-object methods for hiding overlay text and a viewport screenshot utility that applies those methods before each screenshot comparison attempt.

Changes

Viewport screenshot text hiding

Layer / File(s) Summary
Viewport text-hiding methods
tests/pages/ViewportPageObject.ts
Adds category-specific and aggregate hide methods, locator-based hidden-class application, and factory integration.
Screenshot attempt hook
tests/utils/checkForScreenshot.ts
Exports the screenshot props type and invokes an optional beforeAttempt callback before every attempt.
Viewport screenshot orchestration
tests/utils/checkForViewportScreenshot.ts, tests/utils/index.ts
Adds typed hide-text options, applies selected methods before captures, defaults to hiding all text, and exports the new utility.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Suggested reviewers: wayfarer3130

Sequence Diagram(s)

sequenceDiagram
  participant checkForViewportScreenshot
  participant IViewportPageObject
  participant checkForScreenshot
  checkForViewportScreenshot->>IViewportPageObject: Apply selected hide-text methods
  checkForViewportScreenshot->>checkForScreenshot: Provide beforeAttempt callback
  checkForScreenshot->>checkForViewportScreenshot: Invoke before each attempt
  checkForScreenshot-->>checkForViewportScreenshot: Complete screenshot comparison
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise, semantic-release formatted, and accurately describes the main change.
Description check ✅ Passed The description covers the change summary, usage, checklist, and testing environment, so it mostly matches the template.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@GhadeerAlbattarni
GhadeerAlbattarni requested a review from jbocce July 13, 2026 16:33
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.

1 participant