Skip to content

Commit

Permalink
Add ScrollOption support for Java (#178)
Browse files Browse the repository at this point in the history
  • Loading branch information
FriggaHel authored Dec 18, 2024
1 parent acd1c20 commit e5c58b3
Show file tree
Hide file tree
Showing 2 changed files with 166 additions and 7 deletions.
120 changes: 114 additions & 6 deletions visual-java/src/main/graphql/visual/schema.graphqls
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ type Baseline implements Node {
appName: String
appVersion: String
branch: String
browser: Browser
browser: Browser!
browserVersion: String
createdAt: Datetime!
createdByOrgId: UUID!
Expand Down Expand Up @@ -90,10 +90,12 @@ type Baseline implements Node {
A globally unique identifier. Can be used in various places throughout the system to identify this single value.
"""
nodeId: ID!
operatingSystem: OperatingSystem
operatingSystem: OperatingSystem!
operatingSystemVersion: String
parentId: UUID
project: String
smartSuiteName: String!
smartTestName: String!

"""Reads a single `Snapshot` that is related to this `Baseline`."""
snapshot: Snapshot
Expand Down Expand Up @@ -787,6 +789,9 @@ input CreateSnapshotFromWebDriverIn {

"""The selenium ID of an element we should clip the screen to."""
clipElement: WebdriverElementID

"""@deprecated(reason: "clipElement should be used instead.")"""
clipSelector: String
diffingMethod: DiffingMethod
diffingOptions: DiffingOptionsIn

Expand Down Expand Up @@ -904,6 +909,7 @@ type Diff implements Node {

"""snapshot { uploadId } should be requested at the same moment"""
domDiffUrl: String
feedback: DiffFeedback!
hasDom: Boolean!
id: UUID!

Expand Down Expand Up @@ -964,6 +970,42 @@ input DiffCountIn {
withBaseline: Boolean
}

type DiffFeedback {
hasIrrelevantChanges: Boolean!
isBroken: Boolean!
}

"""A connection to a list of `DiffFeedback` values."""
type DiffFeedbacksConnection {
"""
A list of edges which contains the `DiffFeedback` and cursor to aid in pagination.
"""
edges: [DiffFeedbacksEdge!]!

"""A list of `DiffFeedback` objects."""
nodes: [DiffFeedback!]!

"""Information to aid in pagination."""
pageInfo: PageInfo!

"""The count of *all* `DiffFeedback` you could get from the connection."""
totalCount: Int!
}

"""A `DiffFeedback` edge in the connection."""
type DiffFeedbacksEdge {
"""A cursor for use in pagination."""
cursor: Cursor

"""The `DiffFeedback` at the end of the edge."""
node: DiffFeedback!
}

"""Methods to use when ordering `DiffFeedback`."""
enum DiffFeedbacksOrderBy {
NATURAL
}

"""
A filter to be used against `Diff` object types. All fields are combined with a logical ‘and.’
"""
Expand Down Expand Up @@ -1206,6 +1248,11 @@ input FullPageConfigIn {
Default and max value is 10
"""
scrollLimit: Int

"""
Change scroll behaviour before and after taking full page screenshot. Available only on native apps.
"""
scrollOption: ScrollOption
}

scalar FullText
Expand All @@ -1222,6 +1269,8 @@ enum GroupByOption {
Browser
Device
OperatingSystem_OperatingSystemVersion
SmartSuiteName
SmartTestName
SuiteName
TestName
}
Expand Down Expand Up @@ -1280,7 +1329,7 @@ type Mutation {
The exclusive input argument for this mutation. An object type, make sure to see documentation for this object’s fields.
"""
input: ApproveBuildIn!
): Build!
): Build! @deprecated(reason: "Use setDiffStatus")
createBuild(
"""
The exclusive input argument for this mutation. An object type, make sure to see documentation for this object’s fields.
Expand Down Expand Up @@ -1340,6 +1389,18 @@ type Mutation {
"""
input: MergeBaselinesInput!
): MergeBaselinesPayload!
setDiffFeedback(
"""
The exclusive input argument for this mutation. An object type, make sure to see documentation for this object’s fields.
"""
input: SetDiffFeedbackIn!
): Diff!
setDiffStatus(
"""
The exclusive input argument for this mutation. An object type, make sure to see documentation for this object’s fields.
"""
input: SetDiffStatusIn!
): [Diff!]!
updateComment(
"""
The exclusive input argument for this mutation. An object type, make sure to see documentation for this object’s fields.
Expand All @@ -1351,7 +1412,7 @@ type Mutation {
The exclusive input argument for this mutation. An object type, make sure to see documentation for this object’s fields.
"""
input: UpdateDiffIn!
): Diff!
): Diff! @deprecated(reason: "Use setDiffStatus")
}

"""An object with a globally unique `ID`."""
Expand All @@ -1367,6 +1428,7 @@ enum OperatingSystem {
IOS
LINUX
MACOS
UNKNOWN
WINDOWS
}

Expand Down Expand Up @@ -1804,6 +1866,30 @@ type Query implements Node {
nodeId: ID!
): Diff

"""Reads and enables pagination through a set of `DiffFeedback`."""
diffFeedbacks(
"""Read all values in the set after (below) this cursor."""
after: Cursor

"""Read all values in the set before (above) this cursor."""
before: Cursor

"""Only read the first `n` values of the set."""
first: Int

"""Only read the last `n` values of the set."""
last: Int

"""
Skip the first `n` values from our `after` cursor, an alternative to cursor
based pagination. May not be used with `last`.
"""
offset: Int

"""The method to use when ordering `DiffFeedback`."""
orderBy: [DiffFeedbacksOrderBy!] = [NATURAL]
): DiffFeedbacksConnection

"""Reads and enables pagination through a set of `Diff`."""
diffs(
"""Read all values in the set after (below) this cursor."""
Expand Down Expand Up @@ -2003,6 +2089,15 @@ input RegionIn {
y: Int!
}

"""
START_FROM_TOP - scroll before and after to top of the scrollElement
START_FROM_CURRENT_LOCATION - no scroll before and after
"""
enum ScrollOption {
START_FROM_CURRENT_LOCATION
START_FROM_TOP
}

input SelectorIn {
type: SelectorType!
value: String!
Expand All @@ -2012,6 +2107,17 @@ enum SelectorType {
XPATH
}

input SetDiffFeedbackIn {
diffId: UUID!
hasIrrelevantChanges: Boolean!
isBroken: Boolean!
}

input SetDiffStatusIn {
diffIds: [UUID!]!
status: UpdateDiffStatus!
}

type Snapshot implements Node {
appId: String
appName: String
Expand Down Expand Up @@ -2051,7 +2157,7 @@ type Snapshot implements Node {
orderBy: [BaselinesOrderBy!] = [PRIMARY_KEY_ASC]
): BaselinesConnection!
branch: String
browser: Browser
browser: Browser!
browserVersion: String

"""Reads a single `Build` that is related to this `Snapshot`."""
Expand Down Expand Up @@ -2134,8 +2240,10 @@ type Snapshot implements Node {
A globally unique identifier. Can be used in various places throughout the system to identify this single value.
"""
nodeId: ID!
operatingSystem: OperatingSystem
operatingSystem: OperatingSystem!
operatingSystemVersion: String
smartSuiteName: String!
smartTestName: String!
suiteName: String
testName: String
thumbnailUrl: String!
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.saucelabs.visual.model;

import com.saucelabs.visual.graphql.type.ScrollOption;
import com.saucelabs.visual.graphql.type.SelectorIn;
import java.util.Arrays;
import java.util.List;
Expand All @@ -15,6 +16,7 @@ public class FullPageScreenshotConfig {
private int scrollLimit;
private String scrollElement;
private SelectorIn nativeClipSelector;
private ScrollOption scrollOption;

public FullPageScreenshotConfig(
int delayAfterScrollMs,
Expand All @@ -30,6 +32,7 @@ public FullPageScreenshotConfig(
hideScrollBars,
scrollLimit,
scrollElement,
null,
null);
}

Expand All @@ -41,13 +44,34 @@ public FullPageScreenshotConfig(
int scrollLimit,
String scrollElement,
SelectorIn nativeClipSelector) {
this(
delayAfterScrollMs,
disableCSSAnimation,
hideAfterFirstScroll,
hideScrollBars,
scrollLimit,
scrollElement,
nativeClipSelector,
null);
}

private FullPageScreenshotConfig(
int delayAfterScrollMs,
Boolean disableCSSAnimation,
List<String> hideAfterFirstScroll,
Boolean hideScrollBars,
int scrollLimit,
String scrollElement,
SelectorIn nativeClipSelector,
ScrollOption scrollOption) {
this.delayAfterScrollMs = delayAfterScrollMs;
this.disableCSSAnimation = disableCSSAnimation;
this.hideAfterFirstScroll = hideAfterFirstScroll;
this.hideScrollBars = hideScrollBars;
this.scrollLimit = scrollLimit;
this.scrollElement = scrollElement;
this.nativeClipSelector = nativeClipSelector;
this.scrollOption = scrollOption;
}

public static class Builder {
Expand All @@ -58,6 +82,7 @@ public static class Builder {
private int scrollLimit;
private String scrollElement;
private SelectorIn nativeClipSelector;
private ScrollOption scrollOption;

public Builder withDelayAfterScrollMs(int delayAfterScrollMs) {
this.delayAfterScrollMs = delayAfterScrollMs;
Expand Down Expand Up @@ -106,6 +131,18 @@ public Builder withNativeClipSelector(SelectorIn nativeClipSelector) {
return this;
}

/**
* Only effective for native app testing
*
* @param scrollOption ScrollOption to select which scroll behavior Full-Page screenshot should
* have.
* @return Builder instance
*/
public Builder withScrollOption(ScrollOption scrollOption) {
this.scrollOption = scrollOption;
return this;
}

public FullPageScreenshotConfig build() {
return new FullPageScreenshotConfig(
delayAfterScrollMs,
Expand All @@ -114,7 +151,8 @@ public FullPageScreenshotConfig build() {
hideScrollBars,
scrollLimit,
scrollElement,
nativeClipSelector);
nativeClipSelector,
scrollOption);
}
}

Expand Down Expand Up @@ -183,4 +221,17 @@ public SelectorIn getNativeClipSelector() {
public void setNativeClipSelector(SelectorIn nativeClipSelector) {
this.nativeClipSelector = nativeClipSelector;
}

public ScrollOption getScrollOption() {
return scrollOption;
}

/**
* Only effective for native app testing
*
* @param scrollOption ScrollOption to use
*/
public void setScrollOption(ScrollOption scrollOption) {
this.scrollOption = scrollOption;
}
}

0 comments on commit e5c58b3

Please sign in to comment.