Skip to content

Conversation

@ManojTestsigma
Copy link
Contributor

@ManojTestsigma ManojTestsigma commented Aug 6, 2025

JIra

https://testsigma.atlassian.net/browse/TE-29059

Addon name: Image Visual Testing
Addon account: [email protected]
Jarvis Link: https://jarvis.testsigma.com/ui/tenants/2817/users

fix

added Nlps to check if two images are dissimilar.

Summary by CodeRabbit

  • New Features

    • Introduced actions to verify if two images are visually dissimilar for Android, iOS, and Web platforms.
    • Added support for comparing images with or without a similarity threshold and reporting results with screenshots.
  • Chores

    • Updated the project version to 1.0.5.

@coderabbitai
Copy link

coderabbitai bot commented Aug 6, 2025

Walkthrough

This update introduces new "dissimilar image verification" actions for Android, iOS, and Web platforms, each implemented as a new Java class. These classes compare two images using an external visual testing API and determine if they are dissimilar, with some variants supporting a similarity threshold. The Maven project version is incremented.

Changes

Cohort / File(s) Change Summary
Maven Version Update
image_visual_testing/pom.xml
Updated the Maven project version from 1.0.4 to 1.0.5.
Android Dissimilar Image Action
image_visual_testing/src/main/java/com/testsigma/addons/android/VerifyIfImagesAreDissimilar.java
Added a new public class for Android that compares two images for dissimilarity using an external API, handles image file conversion, API interaction, screenshot uploading, and result reporting.
iOS Dissimilar Image Action
image_visual_testing/src/main/java/com/testsigma/addons/ios/VerifyIfImagesAreDissimilar.java
Added a new public class for iOS that compares two images for dissimilarity, manages file conversion, API calls, screenshot uploads, and result reporting, with robust error handling.
Web Dissimilar Image Actions
image_visual_testing/src/main/java/com/testsigma/addons/web/VerifyIfImagesAreDissimilar.java,
image_visual_testing/src/main/java/com/testsigma/addons/web/VerifyIfTwoImagesAreDissimilar.java
Introduced two new public classes for Web: one compares two images for dissimilarity without a threshold, the other allows specifying a similarity threshold. Both handle image conversion, API interaction, screenshot management, and result reporting, with detailed logging and error handling.

Sequence Diagram(s)

sequenceDiagram
    participant TestStep
    participant VerifyIfImagesAreDissimilar
    participant VisualTestingAPI
    participant S3Uploader

    TestStep->>VerifyIfImagesAreDissimilar: execute()
    VerifyIfImagesAreDissimilar->>VerifyIfImagesAreDissimilar: Convert image inputs to files
    VerifyIfImagesAreDissimilar->>VisualTestingAPI: POST images for comparison
    VisualTestingAPI-->>VerifyIfImagesAreDissimilar: similarity %, diff coordinates
    alt Images are dissimilar
        VerifyIfImagesAreDissimilar->>S3Uploader: Upload actual image screenshot
        VerifyIfImagesAreDissimilar-->>TestStep: Success with similarity %
    else Images are identical (or above threshold)
        VerifyIfImagesAreDissimilar->>VerifyIfImagesAreDissimilar: Generate combined diff image
        VerifyIfImagesAreDissimilar->>S3Uploader: Upload combined image
        VerifyIfImagesAreDissimilar-->>TestStep: Failure with error message
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~40 minutes

Suggested reviewers

  • vigneshtestsigma
  • Ganesh-Testsigma

Poem

A rabbit hopped through code anew,
Comparing images—one, then two!
Android, iOS, and Web all in play,
Dissimilar checks now lead the way.
Version bumped, new actions here—
Visual testing’s future is crystal clear!
🐇✨

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch TE-29059

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 7

🔭 Outside diff range comments (1)
image_visual_testing/pom.xml (1)

79-79: Critical: Upgrade jackson-databind to 2.19.2

The project currently pins jackson-databind at 2.12.3, which is affected by several high-severity vulnerabilities (CVE-2022-42003, CVE-2022-42004, PRISMA-2021-0213). While the 2.12 branch is no longer maintained beyond 2.12.17.1, you should move to the latest stable release (2.19.2 as of August 2025) to ensure all known issues are resolved.

File: image_visual_testing/pom.xml
Line: 79
Action: Update the <version> element

Suggested change:

-            <version>2.12.3</version> <!-- Make sure to use the latest version -->
+            <version>2.19.2</version> <!-- Upgraded to address CVE-2022-42003, CVE-2022-42004 & PRISMA-2021-0213 -->
♻️ Duplicate comments (1)
image_visual_testing/src/main/java/com/testsigma/addons/web/VerifyIfImagesAreDissimilar.java (1)

1-248: Significant code duplication across platform implementations.

This class is nearly identical to the Android and iOS versions. As mentioned in the iOS review, extracting common logic into a shared base class or utility would significantly improve maintainability.

🧹 Nitpick comments (6)
image_visual_testing/src/main/java/com/testsigma/addons/android/VerifyIfImagesAreDissimilar.java (4)

100-101: Remove unnecessary null initialization.

The variable is immediately assigned a value, so the null initialization is redundant.

-File combinedImage = null;
-combinedImage = File.createTempFile("combined", ".png");
+File combinedImage = File.createTempFile("combined", ".png");

168-168: Fix typo in error message.

There's a double space in the error message.

-setErrorMessage("Visual testing failed  error occurred internally");
+setErrorMessage("Visual testing failed, error occurred internally");

180-180: Rename misleading parameter.

The parameter name actualDirImage suggests it's a directory, but it's actually a File representing an image.

-private Result uploadScreenshot(boolean compareResult, File actualDirImage, BufferedImage combined,
+private Result uploadScreenshot(boolean compareResult, File actualImageFile, BufferedImage combined,

202-204: Remove commented code.

Dead code should be removed rather than commented out.

-//                String message = "Comparison failed because visual testing detected identical images," +
-//                        " check step screenshot for visual results";
-//                errorMessageBuilder.append(message);
image_visual_testing/src/main/java/com/testsigma/addons/web/VerifyIfTwoImagesAreDissimilar.java (1)

207-209: Remove commented code.

Dead code should be removed rather than commented out.

-//                String message = "Comparison failed because visual testing detected too much similarity," +
-//                        " check step screenshot for visual results";
-//                errorMessageBuilder.append(message);
image_visual_testing/src/main/java/com/testsigma/addons/web/VerifyIfImagesAreDissimilar.java (1)

201-203: Remove commented code.

Dead code should be removed.

-//                String message = "Comparison failed because visual testing detected identical images," +
-//                        " check step screenshot for visual results";
-//                errorMessageBuilder.append(message);
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 76b27f9 and e257e43.

📒 Files selected for processing (5)
  • image_visual_testing/pom.xml (1 hunks)
  • image_visual_testing/src/main/java/com/testsigma/addons/android/VerifyIfImagesAreDissimilar.java (1 hunks)
  • image_visual_testing/src/main/java/com/testsigma/addons/ios/VerifyIfImagesAreDissimilar.java (1 hunks)
  • image_visual_testing/src/main/java/com/testsigma/addons/web/VerifyIfImagesAreDissimilar.java (1 hunks)
  • image_visual_testing/src/main/java/com/testsigma/addons/web/VerifyIfTwoImagesAreDissimilar.java (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: ManojTestsigma
PR: testsigmahq/testsigma-addons#202
File: mailbox_actions/src/main/java/com/testsigma/addons/web/test/GetMailBoxContentBasedOnFilter.java:57-66
Timestamp: 2025-08-05T09:16:20.370Z
Learning: In the GetMailBoxContentBasedOnFilter addon, the logging of email subjects, content, and sender information is intentionally kept for debugging purposes, particularly to handle cases with empty subjects. The user ManojTestsigma prefers this approach for debugging the mailbox filtering functionality.
🔇 Additional comments (1)
image_visual_testing/pom.xml (1)

9-9: Version bump looks good.

The version increment from 1.0.4 to 1.0.5 appropriately reflects the addition of new visual testing actions.

@ManojTestsigma ManojTestsigma merged commit 9b313c5 into dev Aug 11, 2025
2 checks passed
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.

3 participants