✨ Add comparisons API for future SDK usage#1087
Merged
Merged
Conversation
wwilsman
force-pushed
the
ww/upload-comparisons
branch
4 times, most recently
from
September 29, 2022 16:17
2b2b33b to
a0b2c14
Compare
wwilsman
marked this pull request as ready for review
October 3, 2022 15:25
wwilsman
force-pushed
the
ww/upload-comparisons
branch
from
October 3, 2022 15:35
a0b2c14 to
c7502d1
Compare
wwilsman
force-pushed
the
ww/upload-comparisons
branch
2 times, most recently
from
October 5, 2022 18:07
04ab633 to
4360c7d
Compare
wwilsman
force-pushed
the
ww/upload-comparisons
branch
from
October 6, 2022 15:42
4360c7d to
2954a62
Compare
wwilsman
force-pushed
the
ww/upload-comparisons
branch
from
October 6, 2022 16:18
2954a62 to
875f7ce
Compare
wwilsman
force-pushed
the
ww/upload-comparisons
branch
from
October 6, 2022 16:42
875f7ce to
cee7065
Compare
4 tasks
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.
What is this?
Soon, the Percy API will be able to accept specific snapshot comparisons to upload and associate with a build. This PR adds methods to
@percy/clientand@percy/coreto enable SDKs to communicate with this upcoming API.Client
Comparison methods added to client mirror other snapshot methods already present, with a few changes. For example, comparison creation and finalization is similar to snapshot creation and finalization, but with different endpoints and payloads. Likewise for snapshot resources and comparison tiles. The only major difference between the two APIs, is the comparisons flow includes creating a parent snapshot first, but not finalizing it.
Other small changes were made such as repurposing the build ID validation function to validate any type of ID, and using
fs.promisesto read resources and tiles from the filesystem.Core queue
With recent work refactoring and isolating the internal queue responsibilities, adding comparison uploads to the existing queue was actually a very small change. When a snapshot payload includes a
tagit is assumed to be a comparison andclient.sendComparison()is used in place ofclient.sendSnapshot()Core API
Also with the recent refactor work came the addition of the core
percy.upload()method used by the upload command. Thanks to this method, a new/percy/comparisonsendpoint can utilize it to facilitate comparison uploads. Now when the method detects the presence of atagortilesproperty, it will validate all options against a newly added comparison schema, and throw an error when missing the required snapshot name or comparison tag name. This new endpoint also returns a generated link to the comparison redirect API which will redirect to the comparison's web-url when available.SDK utils
A new comparison posting utility function was added to mirror the snapshot posting utility function. These two functions, including their tests, are nearly identical with the only differences being the endpoint used by the function and payload used for the tests. Any JavaScript SDKs that would use the new comparison API should use this new utility function.