From feb07222bef5fc2df5b44270b48846b85adaeb7e Mon Sep 17 00:00:00 2001 From: Pradum Kumar Date: Mon, 28 Oct 2024 09:14:59 +0530 Subject: [PATCH] adding support for label (#242) --- src/main/java/io/percy/appium/lib/CliWrapper.java | 3 ++- src/main/java/io/percy/appium/lib/ScreenshotOptions.java | 9 +++++++++ .../java/io/percy/appium/providers/GenericProvider.java | 1 + .../java/io/percy/appium/lib/ScreenshotOptionsTest.java | 9 +++++++++ 4 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/main/java/io/percy/appium/lib/CliWrapper.java b/src/main/java/io/percy/appium/lib/CliWrapper.java index 2acadb6..8b4631a 100644 --- a/src/main/java/io/percy/appium/lib/CliWrapper.java +++ b/src/main/java/io/percy/appium/lib/CliWrapper.java @@ -89,7 +89,7 @@ public boolean healthcheck() { */ public JSONObject postScreenshot(String name, JSONObject tag, List tiles, String externalDebugUrl, JSONObject ignoredElementsData, JSONObject consideredElementsData, Boolean sync, String testCase, - String thTestCaseExecutionId) { + String labels, String thTestCaseExecutionId) { // Build a JSON object to POST back to the cli node process JSONObject data = new JSONObject(); data.put("name", name); @@ -102,6 +102,7 @@ public JSONObject postScreenshot(String name, JSONObject tag, List tiles, data.put("environmentInfo", env.getEnvironmentInfo()); data.put("sync", sync); data.put("testCase", testCase); + data.put("labels", labels); data.put("thTestCaseExecutionId", thTestCaseExecutionId); int timeout = 600000; // 600 seconds = 600,000 milliseconds diff --git a/src/main/java/io/percy/appium/lib/ScreenshotOptions.java b/src/main/java/io/percy/appium/lib/ScreenshotOptions.java index 1ceb5c5..1ab2337 100644 --- a/src/main/java/io/percy/appium/lib/ScreenshotOptions.java +++ b/src/main/java/io/percy/appium/lib/ScreenshotOptions.java @@ -18,6 +18,7 @@ public class ScreenshotOptions { private Integer screenLengths = 4; private @Nullable Boolean sync = null; private String testCase = null; + private String labels = null; private String thTestCaseExecutionId = null; private List ignoreRegionXpaths = new ArrayList(); private List ignoreRegionAccessibilityIds = new ArrayList(); @@ -62,6 +63,10 @@ public String getTestCase() { return testCase; } + public String getLabels() { + return labels; + } + public String getThTestCaseExecutionId() { return thTestCaseExecutionId; } @@ -126,6 +131,10 @@ public void setTestCase(String testCase) { this.testCase = testCase; } + public void setLabels(String labels) { + this.labels = labels; + } + public void setThTestCaseExecutionId(String thTestCaseExecutionId) { this.thTestCaseExecutionId = thTestCaseExecutionId; } diff --git a/src/main/java/io/percy/appium/providers/GenericProvider.java b/src/main/java/io/percy/appium/providers/GenericProvider.java index 625bf49..1974226 100644 --- a/src/main/java/io/percy/appium/providers/GenericProvider.java +++ b/src/main/java/io/percy/appium/providers/GenericProvider.java @@ -138,6 +138,7 @@ public JSONObject screenshot(String name, ScreenshotOptions options, getObjectForArray("considerElementsData", considerRegions), options.getSync(), options.getTestCase(), + options.getLabels(), options.getThTestCaseExecutionId()); } diff --git a/src/test/java/io/percy/appium/lib/ScreenshotOptionsTest.java b/src/test/java/io/percy/appium/lib/ScreenshotOptionsTest.java index d2e21ea..a56a33a 100644 --- a/src/test/java/io/percy/appium/lib/ScreenshotOptionsTest.java +++ b/src/test/java/io/percy/appium/lib/ScreenshotOptionsTest.java @@ -83,4 +83,13 @@ public void testThTestCaseExecutionId() { assertEquals(options.getThTestCaseExecutionId(), null); } + + @Test + public void testLabelsExecutionId() { + ScreenshotOptions options = new ScreenshotOptions(); + + assertEquals(options.getLabels(), null); + options.setLabels("app;testing"); + assertEquals(options.getLabels(), "app;testing"); + } }