fix: respect alwaysSaveActualImage: false for checkScreen methods (#1115)#1116
Open
wswebcreation wants to merge 10 commits intomainfrom
Open
fix: respect alwaysSaveActualImage: false for checkScreen methods (#1115)#1116wswebcreation wants to merge 10 commits intomainfrom
wswebcreation wants to merge 10 commits intomainfrom
Conversation
🦋 Changeset detectedLatest commit: 8ad8d62 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
This fixes the TypeScript error that occurred after removing saveAboveTolerance from DEFAULT_COMPARE_OPTIONS. Co-authored-by: Cursor <cursoragent@cursor.com>
The test now: 1. Saves a baseline with enableLayoutTesting: true (no visible text) 2. Checks against it with enableLayoutTesting: false (text visible) 3. Verifies there's a mismatch but within threshold 4. Verifies actual image was NOT saved (the fix) Co-authored-by: Cursor <cursoragent@cursor.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #1115
When using
browser.checkScreen()directly withalwaysSaveActualImage: false, actual images were still being saved when there was any mismatch > 0%, even if the user's assertion considered it acceptable.Root Cause
The
saveAboveToleranceoption defaulted to0inDEFAULT_COMPARE_OPTIONS. This meant any mismatch > 0% would trigger saving the actual image, regardless of the user's threshold expectation.The matchers (
toMatchScreenSnapshot, etc.) worked correctly because they explicitly passsaveAboveToleranceto the core based on the threshold provided.The Fix
saveAboveTolerance: 0fromDEFAULT_COMPARE_OPTIONSso it remainsundefinedunless explicitly setexecuteImageCompareto only save actual images whensaveAboveToleranceis explicitly providedNew Behavior
alwaysSaveActualImage: truealwaysSaveActualImage: false(nosaveAboveTolerance)alwaysSaveActualImage: false+saveAboveTolerance: XtoMatchScreenSnapshot, etc.)saveAboveToleranceinternally)Test plan
desktop.spec.tsto verify actual images are not saved whenalwaysSaveActualImage: false