From 4c01e42ad532ed80d95cef3b1e577faba5045740 Mon Sep 17 00:00:00 2001 From: prklm10 Date: Wed, 27 Mar 2024 15:49:45 +0530 Subject: [PATCH 1/2] adding testcase and execution id --- Percy.Tests/lib/ScreenshotOptionsTest.cs | 2 ++ Percy.Tests/providers/AppAutomateTest.cs | 2 +- Percy/lib/CliWrapper.cs | 6 ++++-- Percy/lib/ScreenshotOptions.cs | 2 ++ Percy/providers/GenericProvider.cs | 2 +- 5 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Percy.Tests/lib/ScreenshotOptionsTest.cs b/Percy.Tests/lib/ScreenshotOptionsTest.cs index d55f6c1..b5294b4 100644 --- a/Percy.Tests/lib/ScreenshotOptionsTest.cs +++ b/Percy.Tests/lib/ScreenshotOptionsTest.cs @@ -37,6 +37,8 @@ public void TestGetAndSet() Assert.Equal(screenshotOptions.ConsiderRegionXpaths.Count, 0); Assert.Equal(screenshotOptions.CustomConsiderRegions.Count, 0); Assert.Equal(screenshotOptions.Sync, null); + Assert.Equal(screenshotOptions.TestCase, null); + Assert.Equal(screenshotOptions.ThTestCaseExecutionId, null); } } } diff --git a/Percy.Tests/providers/AppAutomateTest.cs b/Percy.Tests/providers/AppAutomateTest.cs index 2559e8d..dda3d7e 100644 --- a/Percy.Tests/providers/AppAutomateTest.cs +++ b/Percy.Tests/providers/AppAutomateTest.cs @@ -120,7 +120,7 @@ public void TestScreenshot_WhenPercyScreenshotBeginReturnsNull() // Act var actual = appAutomate.Screenshot("temp", options); // Assert - Assert.Equal(true, actual["success"]); + Assert.Equal(null, actual); Environment.SetEnvironmentVariable("PERCY_DISABLE_REMOTE_UPLOADS", "false"); } diff --git a/Percy/lib/CliWrapper.cs b/Percy/lib/CliWrapper.cs index 055f920..59b11cc 100644 --- a/Percy/lib/CliWrapper.cs +++ b/Percy/lib/CliWrapper.cs @@ -88,7 +88,7 @@ private static dynamic Request(string endpoint, JObject? payload = null) } }; - internal static JObject PostScreenshot(string name, JObject tag, List tiles, String externalDebugUrl, JObject ignoredElementsData, JObject consideredElementsData, Boolean? sync) + internal static JObject PostScreenshot(string name, JObject tag, List tiles, String externalDebugUrl, JObject ignoredElementsData, JObject consideredElementsData, Boolean? sync, String? testCase, String? thTestCaseExecutionId) { try { @@ -102,7 +102,9 @@ internal static JObject PostScreenshot(string name, JObject tag, List tile name = name, ignoredElementsData = ignoredElementsData, consideredElementsData = consideredElementsData, - sync = sync + sync = sync, + testCase = testCase, + thTestCaseExecutionId = thTestCaseExecutionId }; dynamic res = Request("/percy/comparison", JObject.FromObject(screenshotOptions)); dynamic data = DeserializeJson(res.content); diff --git a/Percy/lib/ScreenshotOptions.cs b/Percy/lib/ScreenshotOptions.cs index 15cff04..920abe7 100644 --- a/Percy/lib/ScreenshotOptions.cs +++ b/Percy/lib/ScreenshotOptions.cs @@ -17,6 +17,8 @@ public class ScreenshotOptions public bool FullPage { get; set; } = false; public int? ScreenLengths { get; set; } public Boolean? Sync { get; set; } + public String? TestCase { get; set; } + public String? ThTestCaseExecutionId { get; set; } public List IgnoreRegionXpaths { get; set; } = new List(); public List IgnoreRegionAccessibilityIds { get; set; } = new List(); public List IgnoreRegionAppiumElements { get; set; } = new List(); diff --git a/Percy/providers/GenericProvider.cs b/Percy/providers/GenericProvider.cs index 1974525..c72066f 100644 --- a/Percy/providers/GenericProvider.cs +++ b/Percy/providers/GenericProvider.cs @@ -109,7 +109,7 @@ public virtual JObject Screenshot(String name, ScreenshotOptions options, String considerElementsData = consideredRegions }); var tiles = CaptureTiles(options); - return CliWrapper.PostScreenshot(name, tag, tiles, debugUrl, ignoredElementsData, consideredElementsData, options.Sync); + return CliWrapper.PostScreenshot(name, tag, tiles, debugUrl, ignoredElementsData, consideredElementsData, options.Sync, options.TestCase, options.ThTestCaseExecutionId); } public JArray FindRegions(List Xpaths, List AccessibilityIds, List Elements, List Locations) From 6206fa0884087cb5a35355dcf9f4eb0cca94c5cc Mon Sep 17 00:00:00 2001 From: prklm10 Date: Wed, 27 Mar 2024 16:24:48 +0530 Subject: [PATCH 2/2] test fux --- Percy.Tests/providers/AppAutomateTest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Percy.Tests/providers/AppAutomateTest.cs b/Percy.Tests/providers/AppAutomateTest.cs index dda3d7e..2559e8d 100644 --- a/Percy.Tests/providers/AppAutomateTest.cs +++ b/Percy.Tests/providers/AppAutomateTest.cs @@ -120,7 +120,7 @@ public void TestScreenshot_WhenPercyScreenshotBeginReturnsNull() // Act var actual = appAutomate.Screenshot("temp", options); // Assert - Assert.Equal(null, actual); + Assert.Equal(true, actual["success"]); Environment.SetEnvironmentVariable("PERCY_DISABLE_REMOTE_UPLOADS", "false"); }