Skip to content

Commit 574fdaf

Browse files
committed
Merge branch 'main' into env-var-tests
2 parents f517368 + 9ffe814 commit 574fdaf

File tree

166 files changed

+28089
-127
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

166 files changed

+28089
-127
lines changed

Diff for: .github/workflows/js-build.yml

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: JS (build)
2+
3+
on:
4+
push:
5+
paths:
6+
- 'visual-js/**'
7+
- .github/workflows/js-build.yml
8+
pull_request:
9+
paths:
10+
- 'visual-js/**'
11+
- .github/workflows/js-build.yml
12+
13+
defaults:
14+
run:
15+
working-directory: visual-js
16+
17+
jobs:
18+
build:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v4
22+
- name: Setup Node 18
23+
uses: actions/setup-node@v4
24+
with:
25+
node-version: 18.x
26+
- name: Build with lerna
27+
run: |
28+
corepack enable
29+
yarn install
30+
npm run lint --workspaces --if-present
31+
npm run build --workspaces --if-present
32+
npm run test --workspaces --if-present
33+
env:
34+
SAUCE_USERNAME: ${{ secrets.SAUCE_USERNAME }}
35+
SAUCE_ACCESS_KEY: ${{ secrets.SAUCE_ACCESS_KEY }}

Diff for: .github/workflows/js-release.yml

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: JS (release)
2+
3+
on:
4+
workflow_dispatch: {}
5+
6+
defaults:
7+
run:
8+
working-directory: visual-js
9+
10+
jobs:
11+
release:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v4
15+
- name: Setup Node 18
16+
uses: actions/setup-node@v4
17+
with:
18+
node-version: 18.x
19+
registry-url: https://registry.npmjs.org
20+
- name: Setup Git
21+
if: ${{ steps.prep.outputs.tag_name == '' }}
22+
run: |
23+
git config --global user.name "sauce-visual-bot"
24+
git config --global user.email "[email protected]"
25+
- name: Build
26+
run: |
27+
corepack enable
28+
yarn install
29+
npm run build --workspaces --if-present
30+
- name: upgrade & publish version(s)
31+
run: |
32+
npx changeset version
33+
npx changeset publish
34+
env:
35+
NODE_AUTH_TOKEN: ${{ secrets.NPM_REGISTRY_TOKEN }}
36+
- name: Push to git
37+
run: git push --follow-tags

Diff for: .github/workflows/python-build.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ jobs:
2323
with:
2424
python-version: '3.10'
2525
- name: Install Python build utilities
26-
run: pip install -r requirements/build.txt
26+
run: pip install -r requirements/dev.txt
2727
- name: Build
2828
run: python -m build
29+
- name: Test
30+
run: python -m pytest

Diff for: .github/workflows/python-release.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,11 @@ jobs:
2626
with:
2727
python-version: '3.10'
2828
- name: Install Python build utilities
29-
run: pip install -r requirements/build.txt
29+
run: pip install -r requirements/dev.txt
3030
- name: Build
3131
run: python -m build
32+
- name: Test
33+
run: python -m pytest
3234

3335
pypi-publish:
3436
runs-on: ubuntu-latest

Diff for: README.md

+1
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ This repository contains the SDKs for Sauce Labs Visual.
66

77
- [C#](./visual-dotnet)
88
- [Java](./visual-java)
9+
- [Python](./visual-python)

Diff for: visual-dotnet/SauceLabs.Visual/BuildFactory.cs

+14-4
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,11 @@ private static async Task<VisualBuild> FindBuildById(VisualApi api, string build
9393
try
9494
{
9595
var build = (await api.Build(buildId)).EnsureValidResponse().Result;
96+
if (build == null)
97+
{
98+
throw new VisualClientException($@"build {buildId} was not found");
99+
}
100+
96101
return new VisualBuild(build.Id, build.Url, build.Mode);
97102
}
98103
catch (VisualClientException)
@@ -113,6 +118,11 @@ private static async Task<VisualBuild> FindBuildById(VisualApi api, string build
113118
try
114119
{
115120
var build = (await api.BuildByCustomId(customId)).EnsureValidResponse().Result;
121+
if (build == null)
122+
{
123+
throw new VisualClientException($@"build identified by {customId} was not found");
124+
}
125+
116126
return new VisualBuild(build.Id, build.Url, build.Mode);
117127
}
118128
catch (VisualClientException)
@@ -144,10 +154,10 @@ private static async Task<VisualBuild> Create(VisualApi api, CreateBuildOptions
144154
options.CustomId ??= EnvVars.CustomId;
145155
var result = (await api.CreateBuild(new CreateBuildIn
146156
{
147-
Name = StringUtils.ValueOrDefault(EnvVars.BuildName, options.Name),
148-
Project = StringUtils.ValueOrDefault(EnvVars.Project, options.Project),
149-
Branch = StringUtils.ValueOrDefault(EnvVars.Branch, options.Branch),
150-
DefaultBranch = StringUtils.ValueOrDefault(EnvVars.DefaultBranch, options.DefaultBranch),
157+
Name = StringUtils.ValueOrDefault(options.Name, EnvVars.BuildName),
158+
Project = StringUtils.ValueOrDefault(options.Project, EnvVars.Project),
159+
Branch = StringUtils.ValueOrDefault(options.Branch, EnvVars.Branch),
160+
DefaultBranch = StringUtils.ValueOrDefault(options.DefaultBranch, EnvVars.DefaultBranch),
151161
CustomId = options.CustomId,
152162
})).EnsureValidResponse();
153163

Diff for: visual-dotnet/SauceLabs.Visual/FullPageConfig.cs

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System;
12
using System.Collections.Generic;
23
using SauceLabs.Visual.GraphQL;
34

@@ -6,15 +7,21 @@ namespace SauceLabs.Visual
67
public class FullPageConfig
78
{
89
public int? DelayAfterScrollMs { get; set; }
10+
public bool? DisableCSSAnimation { get; set; }
911
public IEnumerable<string>? HideAfterFirstScroll { get; set; }
12+
public bool? HideScrollBars { get; set; }
13+
public int? ScrollLimit { get; set; }
1014

1115
internal FullPageConfigIn ToFullPageConfigIn()
1216
{
1317
return new FullPageConfigIn()
1418
{
1519
DelayAfterScrollMs = DelayAfterScrollMs,
16-
HideAfterFirstScroll = HideAfterFirstScroll
20+
DisableCSSAnimation = DisableCSSAnimation,
21+
HideAfterFirstScroll = HideAfterFirstScroll,
22+
HideScrollBars = HideScrollBars,
23+
ScrollLimit = ScrollLimit
1724
};
1825
}
1926
}
20-
}
27+
}

Diff for: visual-dotnet/SauceLabs.Visual/GraphQL/CreateSnapshotFromWebDriverIn.cs

+5-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ internal class CreateSnapshotFromWebDriverIn
99
public string BuildUuid { get; }
1010
[JsonProperty("diffingMethod")]
1111
public DiffingMethod DiffingMethod { get; }
12+
[JsonProperty("diffingOptions")]
13+
public DiffingOptionsIn? DiffingOptions { get; set; }
1214
[JsonProperty("ignoreRegions")]
1315
public RegionIn[] IgnoreRegions { get; }
1416
[JsonProperty("jobId")]
@@ -43,7 +45,8 @@ public CreateSnapshotFromWebDriverIn(
4345
string? clipSelector,
4446
string? suiteName,
4547
string? testName,
46-
FullPageConfigIn? fullPageConfig
48+
FullPageConfigIn? fullPageConfig,
49+
DiffingOptionsIn? diffingOptions
4750
)
4851
{
4952
BuildUuid = buildUuid;
@@ -58,6 +61,7 @@ public CreateSnapshotFromWebDriverIn(
5861
SuiteName = suiteName;
5962
TestName = testName;
6063
FullPageConfig = fullPageConfig;
64+
DiffingOptions = diffingOptions;
6165
}
6266
}
6367
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
using Newtonsoft.Json;
2+
3+
namespace SauceLabs.Visual.GraphQL
4+
{
5+
public class DiffingOptionsIn
6+
{
7+
[JsonProperty("content")]
8+
public bool Content { get; set; }
9+
[JsonProperty("dimensions")]
10+
public bool Dimensions { get; set; }
11+
[JsonProperty("position")]
12+
public bool Position { get; set; }
13+
[JsonProperty("structure")]
14+
public bool Structure { get; set; }
15+
[JsonProperty("style")]
16+
public bool Style { get; set; }
17+
[JsonProperty("visual")]
18+
public bool Visual { get; set; }
19+
20+
public DiffingOptionsIn(bool defaultValue)
21+
{
22+
Content = defaultValue;
23+
Dimensions = defaultValue;
24+
Position = defaultValue;
25+
Structure = defaultValue;
26+
Style = defaultValue;
27+
Visual = defaultValue;
28+
}
29+
}
30+
}

Diff for: visual-dotnet/SauceLabs.Visual/GraphQL/FullPageConfigIn.cs

+6
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,13 @@ internal class FullPageConfigIn
77
{
88
[JsonProperty("delayAfterScrollMs")]
99
public int? DelayAfterScrollMs { get; set; }
10+
[JsonProperty("disableCSSAnimation")]
11+
public bool? DisableCSSAnimation { get; set; }
1012
[JsonProperty("hideAfterFirstScroll")]
1113
public IEnumerable<string>? HideAfterFirstScroll { get; set; }
14+
[JsonProperty("hideScrollBars")]
15+
public bool? HideScrollBars { get; set; }
16+
[JsonProperty("scrollLimit")]
17+
public int? ScrollLimit { get; set; }
1218
}
1319
}

Diff for: visual-dotnet/SauceLabs.Visual/GraphQL/RegionIn.cs

+19
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using Newtonsoft.Json;
22
using OpenQA.Selenium;
33
using SauceLabs.Visual.Models;
4+
using SauceLabs.Visual.Utils;
45

56
namespace SauceLabs.Visual.GraphQL
67
{
@@ -16,6 +17,8 @@ internal class RegionIn
1617
public int Width { get; }
1718
[JsonProperty("height")]
1819
public int Height { get; }
20+
[JsonProperty("diffingOptions")]
21+
public DiffingOptionsIn? DiffingOptions { get; }
1922

2023
public RegionIn(int x, int y, int width, int height)
2124
{
@@ -29,10 +32,26 @@ public RegionIn(string name, int x, int y, int width, int height) : this(x, y, w
2932
Name = name;
3033
}
3134

35+
public RegionIn(int x, int y, int width, int height, DiffingOptionsIn diffingOptions) : this(x, y, width, height)
36+
{
37+
DiffingOptions = diffingOptions;
38+
}
3239
public RegionIn(IWebElement input) : this(input.Location.X, input.Location.Y, input.Size.Width, input.Size.Height)
3340
{ }
3441

42+
public RegionIn(IWebElement input, DiffingOptionsIn? options) : this(input.Location.X, input.Location.Y,
43+
input.Size.Width, input.Size.Height)
44+
{
45+
DiffingOptions = options;
46+
}
47+
3548
public RegionIn(IgnoreRegion input) : this(input.X, input.Y, input.Width, input.Height)
3649
{ }
50+
51+
public RegionIn(SauceLabs.Visual.Models.Region input, DiffingOptionsIn? options) : this(input.X, input.Y, input.Width,
52+
input.Height)
53+
{
54+
DiffingOptions = options;
55+
}
3756
}
3857
}

Diff for: visual-dotnet/SauceLabs.Visual/Models/DiffingMethod.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ namespace SauceLabs.Visual.Models
33
public enum DiffingMethod
44
{
55
Simple,
6-
Experimental
6+
Experimental,
7+
Balanced,
78
}
89
}
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using System;
2+
3+
namespace SauceLabs.Visual.Models
4+
{
5+
[Flags]
6+
public enum DiffingOption
7+
{
8+
None = 0,
9+
Content = 1 << 0,
10+
Dimensions = 1 << 1,
11+
Position = 1 << 2,
12+
Structure = 1 << 3,
13+
Style = 1 << 4,
14+
Visual = 1 << 5,
15+
}
16+
}

Diff for: visual-dotnet/SauceLabs.Visual/Models/Region.cs

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
namespace SauceLabs.Visual.Models
2+
{
3+
public class Region
4+
{
5+
public int X { get; }
6+
public int Y { get; }
7+
public int Width { get; }
8+
public int Height { get; }
9+
10+
public Region(int x, int y, int width, int height)
11+
{
12+
X = x;
13+
Y = y;
14+
Width = width;
15+
Height = height;
16+
}
17+
}
18+
}

0 commit comments

Comments
 (0)