Skip to content

Commit

Permalink
Adding sync params
Browse files Browse the repository at this point in the history
  • Loading branch information
prklm10 committed Jan 23, 2024
1 parent f6e6123 commit 6beda7a
Show file tree
Hide file tree
Showing 5 changed files with 126 additions and 109 deletions.
7 changes: 5 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ module.exports = async function percyScreenshot(driver, name, options = {}) {
scrollableXpath,
topScrollviewOffset,
bottomScrollviewOffset,
scrollableId
scrollableId,
sync
} = options;
// allow working with or without standalone mode for wdio
if (!driver || typeof driver === 'string') {
Expand All @@ -54,6 +55,7 @@ module.exports = async function percyScreenshot(driver, name, options = {}) {
topScrollviewOffset = name.topScrollviewOffset;
bottomScrollviewOffset = name.bottomScrollviewOffset;
scrollableId = name.scrollableId;
sync = name.sync;
options = name;
}
try {
Expand Down Expand Up @@ -100,7 +102,8 @@ module.exports = async function percyScreenshot(driver, name, options = {}) {
scrollableXpath,
topScrollviewOffset,
bottomScrollviewOffset,
scrollableId
scrollableId,
sync
});
log.debug(`[${name}] -> end`);
return response;
Expand Down
17 changes: 11 additions & 6 deletions percy/providers/appAutomateProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,12 @@ class AppAutomateProvider extends GenericProvider {
scrollableXpath,
topScrollviewOffset,
bottomScrollviewOffset,
scrollableId
scrollableId,
sync
} = {}) {
let response = null;
let error;
sync = sync || false;
try {
let result = await this.percyScreenshotBegin(name);
this.setDebugUrl(result);
Expand All @@ -60,13 +62,14 @@ class AppAutomateProvider extends GenericProvider {
scrollableXpath,
topScrollviewOffset,
bottomScrollviewOffset,
scrollableId
scrollableId,
sync
});
} catch (e) {
error = e;
throw e;
} finally {
await this.percyScreenshotEnd(name, response?.body?.link, `${error}`);
await this.percyScreenshotEnd(name, response?.body?.link, sync, `${error}`);
}
return response;
}
Expand All @@ -84,19 +87,21 @@ class AppAutomateProvider extends GenericProvider {
return result;
} catch (e) {
log.debug(`[${name}] Could not mark App Automate session as percy`);
log.debug(`[${name}] ${e}`);
return null;
}
});
}

async percyScreenshotEnd(name, percyScreenshotUrl, statusMessage = null) {
async percyScreenshotEnd(name, percyScreenshotUrl, sync, statusMessage = null) {
return await TimeIt.run('percyScreenshotEnd', async () => {
try {
await this.browserstackExecutor('percyScreenshot', {
name,
percyScreenshotUrl,
status: percyScreenshotUrl ? 'success' : 'failure',
statusMessage,
sync,
state: 'end'
});
} catch (e) {
Expand Down Expand Up @@ -155,8 +160,8 @@ class AppAutomateProvider extends GenericProvider {
JSON.parse(response.result).forEach(tileData => {
tiles.push(new Tile({
statusBarHeight: statBarHeight,
navBarHeight: navBarHeight,
fullscreen: fullscreen,
navBarHeight,
fullscreen,
headerHeight: tileData.header_height,
footerHeight: tileData.footer_height,
sha: tileData.sha.split('-')[0] // drop build id
Expand Down
8 changes: 6 additions & 2 deletions percy/providers/genericProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,11 @@ class GenericProvider {
considerRegionAppiumElements,
customConsiderRegions,
scrollableXpath,
scrollableId
scrollableId,
sync
}) {
fullscreen = fullscreen || false;
sync = sync || false;

this.metadata = await MetadataResolver.resolve(this.driver, {
deviceName,
Expand All @@ -76,6 +78,7 @@ class GenericProvider {
log.debug(`${name} : Tag ${JSON.stringify(tag)}`);
log.debug(`${name} : Tiles ${JSON.stringify(tiles)}`);
log.debug(`${name} : Debug url ${this.debugUrl}`);
log.debug(`${name} : sync ${sync}`);
return await utils.postComparison({
name,
tag,
Expand All @@ -88,7 +91,8 @@ class GenericProvider {
considerElementsData: considerRegions
},
environmentInfo: ENV_INFO,
clientInfo: CLIENT_INFO
clientInfo: CLIENT_INFO,
sync
});
}

Expand Down
4 changes: 2 additions & 2 deletions test/percy/providers/appAutomateProvider.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ describe('AppAutomateProvider', () => {

expect(percyScreenshotBeginSpy).toHaveBeenCalledWith('abc');
expect(superScreenshotSpy).toHaveBeenCalledWith('abc', jasmine.any(Object));
expect(percyScreenshotEndSpy).toHaveBeenCalledWith('abc', 'link to screenshot', 'undefined');
expect(percyScreenshotEndSpy).toHaveBeenCalledWith('abc', 'link to screenshot', false, 'undefined');
});

it('passes exception message to percyScreenshotEnd in case of exception', async () => {
Expand All @@ -47,7 +47,7 @@ describe('AppAutomateProvider', () => {
expect(percyScreenshotBeginSpy).toHaveBeenCalledWith('abc');

expect(percyScreenshotEndSpy).toHaveBeenCalledWith(
'abc', undefined, `Error: ${errorMessage}`);
'abc', undefined, false, `Error: ${errorMessage}`);
});
});

Expand Down
199 changes: 102 additions & 97 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -322,106 +322,106 @@
"@nodelib/fs.scandir" "2.1.5"
fastq "^1.6.0"

"@percy/[email protected].0-beta.0":
version "1.27.0-beta.0"
resolved "https://registry.yarnpkg.com/@percy/cli-app/-/cli-app-1.27.0-beta.0.tgz#83080d7d011ae10d204e2f0bcc53fb560f959c3d"
integrity sha512-i80q+Yu+h8vUwbAELzGferrG9mDZJdAG0YHI3lL8zpK7sTOI6lFlbMMeBIDnHio3xy3r6xAyTuXUt2kFgXwTEA==
"@percy/[email protected].7":
version "1.27.7"
resolved "https://registry.yarnpkg.com/@percy/cli-app/-/cli-app-1.27.7.tgz#7ee373674ab8e0a5aec33f624390097a76c53ad6"
integrity sha512-IQuTC5X5JM65cqOluFM9lnydkw3hvkUdf6LTsBRtzmS7/qURyiBDvuxkKt37XUCfXm2XFP8J6B6ADBQL4YShPA==
dependencies:
"@percy/cli-command" "1.27.0-beta.0"
"@percy/cli-exec" "1.27.0-beta.0"
"@percy/cli-command" "1.27.7"
"@percy/cli-exec" "1.27.7"

"@percy/[email protected].0-beta.0":
version "1.27.0-beta.0"
resolved "https://registry.yarnpkg.com/@percy/cli-build/-/cli-build-1.27.0-beta.0.tgz#4a511d22f676f1ec238f3af712d5ac22c0d3bf9f"
integrity sha512-GuwoP492tP8X85cXu530dDitQnry/F48bWLhSWTtxR4rO6xXcc3RC41Ppoz5kzy/IMqHHA/l1GhTpluhbA18NQ==
"@percy/[email protected].7":
version "1.27.7"
resolved "https://registry.yarnpkg.com/@percy/cli-build/-/cli-build-1.27.7.tgz#7d8a200353ec7a3ec32131631e2e5145e53b357d"
integrity sha512-UmWaUFQAomlL4GpU/KPTq3hmJtXCMWQELwDnaQ1vnUf2rk17qSy5keSvCb/Ta8oPuObuRNoOHGrtUFPh1b7l2g==
dependencies:
"@percy/cli-command" "1.27.0-beta.0"
"@percy/cli-command" "1.27.7"

"@percy/[email protected].0-beta.0":
version "1.27.0-beta.0"
resolved "https://registry.yarnpkg.com/@percy/cli-command/-/cli-command-1.27.0-beta.0.tgz#7293f59f0d99740cd0ec0e3e6a0df067dae87d02"
integrity sha512-p6vbRFnjvgJcsC/mgoPYRWrMH9BjZbRQVHb49R+dwUSdVPfM4xBpM0Q5Qjzst85rd0k08nsfDDCetRLAoNDcIg==
"@percy/[email protected].7":
version "1.27.7"
resolved "https://registry.yarnpkg.com/@percy/cli-command/-/cli-command-1.27.7.tgz#2341db97a7ddebda9587ba2e3efbcb21e0b06a43"
integrity sha512-nVHspbcTStwZOVYmcCowcFJsOLLJrhLfJbj2Rkvm3upf/E98x4+S9H+Tq9K4XcgznjFfLLRAHkkVFGnCdbO5qQ==
dependencies:
"@percy/config" "1.27.0-beta.0"
"@percy/core" "1.27.0-beta.0"
"@percy/logger" "1.27.0-beta.0"
"@percy/config" "1.27.7"
"@percy/core" "1.27.7"
"@percy/logger" "1.27.7"

"@percy/[email protected].0-beta.0":
version "1.27.0-beta.0"
resolved "https://registry.yarnpkg.com/@percy/cli-config/-/cli-config-1.27.0-beta.0.tgz#bad6fc692d0863fac34ae637d2fd34ab57faff2f"
integrity sha512-yVpSxCusOxOwduHppXal5xGj2Hd22Jc2798QNu4zUuTsZx1zhCVKaqa3wJxgBHhyaX+yECwENxywiDziMWlyWw==
"@percy/[email protected].7":
version "1.27.7"
resolved "https://registry.yarnpkg.com/@percy/cli-config/-/cli-config-1.27.7.tgz#55f1046807849925e8fc94dc94c08afae103a99e"
integrity sha512-SppI7w9xQAUk4nCqXq0KE3HoKZ+IwgkJ6biAQuzv3BJ8GWz42hUGnH1fLEoK92MZMLiOHByiEFUoBzUKXPscZw==
dependencies:
"@percy/cli-command" "1.27.0-beta.0"
"@percy/cli-command" "1.27.7"

"@percy/[email protected].0-beta.0":
version "1.27.0-beta.0"
resolved "https://registry.yarnpkg.com/@percy/cli-exec/-/cli-exec-1.27.0-beta.0.tgz#ddf71937964c71393bb19b05d5684a82bde66baf"
integrity sha512-gFd0lk752fni+/RWcK7T+FkDymlNUKSn+z+/HpastIC/XSHjtsswuwODuHA1D3T/TpUZVUIVP8A2zJZE/sb+bg==
"@percy/[email protected].7":
version "1.27.7"
resolved "https://registry.yarnpkg.com/@percy/cli-exec/-/cli-exec-1.27.7.tgz#6122111a59f888e37e3f0b465cb1f7f80f217b1b"
integrity sha512-ZYSuQYu7hMbl/KbGwS/bEdAEXEY7MygheCJrmM43AGUIj8LSHnVTi09/z7ZpcStLibPmsraJ8Cm7GXhTNdhuAQ==
dependencies:
"@percy/cli-command" "1.27.0-beta.0"
"@percy/cli-command" "1.27.7"
cross-spawn "^7.0.3"
which "^2.0.2"

"@percy/[email protected].0-beta.0":
version "1.27.0-beta.0"
resolved "https://registry.yarnpkg.com/@percy/cli-snapshot/-/cli-snapshot-1.27.0-beta.0.tgz#09638f42341daade5bf9e01a867b0aff49b885d1"
integrity sha512-oXBrYH7uM19B5BC3f8zkwWDOMvoZwJHapdwIzOTEiB1pXI1oM6d9vg1ieO8l3DZvw3jyAsi5dmmU4zcAVzrUYQ==
"@percy/[email protected].7":
version "1.27.7"
resolved "https://registry.yarnpkg.com/@percy/cli-snapshot/-/cli-snapshot-1.27.7.tgz#ac64af3b02bade251a0efc6e79663a7d3af245c7"
integrity sha512-FGmNhXfOvW2RkcdEzeWWXo2fUp8UoRIb8bT0Bg6xcw5UGPUAoDVaFA8i4M5Qvi/K54Ed5VYfBX3y5sLcg2XRaw==
dependencies:
"@percy/cli-command" "1.27.0-beta.0"
"@percy/cli-command" "1.27.7"
yaml "^2.0.0"

"@percy/[email protected].0-beta.0":
version "1.27.0-beta.0"
resolved "https://registry.yarnpkg.com/@percy/cli-upload/-/cli-upload-1.27.0-beta.0.tgz#6e0f8b3cd292ca4cb0673f85721d0762b372dba2"
integrity sha512-nxdwQ8+UB3xXRz0YBruI57hWkMSvkzR5DyKQ/jmLVj+3CcUMh0lFN/Oj6mIJjrkr9+B8cWZjWl6AYKH5C+XbNA==
"@percy/[email protected].7":
version "1.27.7"
resolved "https://registry.yarnpkg.com/@percy/cli-upload/-/cli-upload-1.27.7.tgz#9ef454e81e3a286a147c7841bd521c8459e99cff"
integrity sha512-kC9wfZ6TBnOTlB2ge32IlEQlxGh+fLXUIlmelCXCTDL6zutn8mI117XOHaJDtsI7qtovM0cTBxoSySaBY4XNqg==
dependencies:
"@percy/cli-command" "1.27.0-beta.0"
"@percy/cli-command" "1.27.7"
fast-glob "^3.2.11"
image-size "^1.0.0"

"@percy/cli@^1.27.0-beta.0":
version "1.27.0-beta.0"
resolved "https://registry.yarnpkg.com/@percy/cli/-/cli-1.27.0-beta.0.tgz#775f2510f505dd66f45bc0727d5b7e030fa293b7"
integrity sha512-X5mGNXCOPMnbhaVDOqtd33xK6BkQUgzMS0hwcMH8xwQgd248emsODqHIkhWgBodt+ERJt0hnf4rgkidndMWQvQ==
dependencies:
"@percy/cli-app" "1.27.0-beta.0"
"@percy/cli-build" "1.27.0-beta.0"
"@percy/cli-command" "1.27.0-beta.0"
"@percy/cli-config" "1.27.0-beta.0"
"@percy/cli-exec" "1.27.0-beta.0"
"@percy/cli-snapshot" "1.27.0-beta.0"
"@percy/cli-upload" "1.27.0-beta.0"
"@percy/client" "1.27.0-beta.0"
"@percy/logger" "1.27.0-beta.0"

"@percy/[email protected].0-beta.0":
version "1.27.0-beta.0"
resolved "https://registry.yarnpkg.com/@percy/client/-/client-1.27.0-beta.0.tgz#c41953b5641975297cf15332f6a3cdde80c9cd51"
integrity sha512-yH+FoCEkpSx0MO5cqL489q9HIQcWCj4ZCPhY1cBh5J7MJuwDv0jRc7HB5xlqVUSj17l7Wqn6bT/ieLrY/dv0MA==
dependencies:
"@percy/env" "1.27.0-beta.0"
"@percy/logger" "1.27.0-beta.0"

"@percy/[email protected].0-beta.0":
version "1.27.0-beta.0"
resolved "https://registry.yarnpkg.com/@percy/config/-/config-1.27.0-beta.0.tgz#a3ff367acf1001ba31792f65ae9700c2c6ede6c6"
integrity sha512-AvR5mnhm5lUVw3fOhFeVDshz53Vlgl8UzSb+cgRguRow72PSibgKUoS9b0JA1n3b7CSeaoWGycGOQ4jUOsFl+A==
dependencies:
"@percy/logger" "1.27.0-beta.0"
"@percy/cli@^1.27.2":
version "1.27.7"
resolved "https://registry.yarnpkg.com/@percy/cli/-/cli-1.27.7.tgz#004de5827790c827eac9195dae6914e9868736b3"
integrity sha512-FKt032Of8IhzA/ZLGAWgox5y5N534lTXW+W6AEeeMPHDm06eHCPgbMuMjajuhD0nGFRtSO6rJIPw+gFzIgJU7g==
dependencies:
"@percy/cli-app" "1.27.7"
"@percy/cli-build" "1.27.7"
"@percy/cli-command" "1.27.7"
"@percy/cli-config" "1.27.7"
"@percy/cli-exec" "1.27.7"
"@percy/cli-snapshot" "1.27.7"
"@percy/cli-upload" "1.27.7"
"@percy/client" "1.27.7"
"@percy/logger" "1.27.7"

"@percy/[email protected].7":
version "1.27.7"
resolved "https://registry.yarnpkg.com/@percy/client/-/client-1.27.7.tgz#79513a55f56b2693b601f8cb55f6850f7dadfcf8"
integrity sha512-pMaimVhfJEWyta40PyanH/Sv8mp+CBeO4HuJ72zadDrJVAwNNBfaNE8OzT298y8u/DrMz/AlNSA6OhVojDVAuQ==
dependencies:
"@percy/env" "1.27.7"
"@percy/logger" "1.27.7"

"@percy/[email protected].7":
version "1.27.7"
resolved "https://registry.yarnpkg.com/@percy/config/-/config-1.27.7.tgz#1185344d00a4bcfc8f61eb5fa2ecc05e667b9667"
integrity sha512-7XbnrVWgvMgYAIngyWt0nd/l5lQiioOzIkqm9iH+nbfH/ka9pE8U/AWsCuiWGz2Z/1p03gBDFc01cyM+ORjglQ==
dependencies:
"@percy/logger" "1.27.7"
ajv "^8.6.2"
cosmiconfig "^8.0.0"
yaml "^2.0.0"

"@percy/[email protected].0-beta.0":
version "1.27.0-beta.0"
resolved "https://registry.yarnpkg.com/@percy/core/-/core-1.27.0-beta.0.tgz#3d1b6100ad78d9ce583ef7c0425df2d84ca921b3"
integrity sha512-U0x3VHbxfo8Ho9j/JlHYstV/MUsTB9uAQYMgsI0WAnq67TbyGY6u/g8mqi9DeXnafk3YOM2YQ7RaLaUo8/re0Q==
dependencies:
"@percy/client" "1.27.0-beta.0"
"@percy/config" "1.27.0-beta.0"
"@percy/dom" "1.27.0-beta.0"
"@percy/logger" "1.27.0-beta.0"
"@percy/webdriver-utils" "1.27.0-beta.0"
"@percy/[email protected].7":
version "1.27.7"
resolved "https://registry.yarnpkg.com/@percy/core/-/core-1.27.7.tgz#daef80d280f117f8122264fae33be41ca8d62caa"
integrity sha512-lwweKGLbjsCWcAvaeHSK47IkaioBPKKjKd8fhhXFfv713aNL5CcokO9uUNMyBwrgqLY8jmPR/McMtROidUSowQ==
dependencies:
"@percy/client" "1.27.7"
"@percy/config" "1.27.7"
"@percy/dom" "1.27.7"
"@percy/logger" "1.27.7"
"@percy/webdriver-utils" "1.27.7"
content-disposition "^0.5.4"
cross-spawn "^7.0.3"
extract-zip "^2.0.1"
Expand All @@ -432,35 +432,40 @@
rimraf "^3.0.2"
ws "^8.0.0"

"@percy/[email protected].0-beta.0":
version "1.27.0-beta.0"
resolved "https://registry.yarnpkg.com/@percy/dom/-/dom-1.27.0-beta.0.tgz#db768db620da48dd667ac0e8d927948bef3f1042"
integrity sha512-qmZfuAoVstQ8pXvdbS86uaK9NKbtnOYv5xOyvSMgT3kdoSrvdbtqK9FtmTh3g6kUDD7XrQAYdiuyTr7veu/7rQ==
"@percy/[email protected].7":
version "1.27.7"
resolved "https://registry.yarnpkg.com/@percy/dom/-/dom-1.27.7.tgz#ea4b790e72a86ae5b8ba0cc8ebc66adee2d04ee1"
integrity sha512-FLMaAp7LByGFqvTEV1UwiQd+Ww1SHU2UuGOvgMPBwPgAKt2BB+FfZEYgaeORt5YXLfDJsIVk/lfvhJXzmb5k8Q==

"@percy/[email protected].0-beta.0":
version "1.27.0-beta.0"
resolved "https://registry.yarnpkg.com/@percy/env/-/env-1.27.0-beta.0.tgz#89307084f525c21d9451f8b73082060b8d549f35"
integrity sha512-aB4sJKNmEf6/JClW206kTzSKUzkibq026CXGBtll8UH9TyxhNuX1La4img9kndaILnUKylFG9fb3JIl4jby8ng==
"@percy/[email protected].7":
version "1.27.7"
resolved "https://registry.yarnpkg.com/@percy/env/-/env-1.27.7.tgz#bc465c2ea64661ab0f2731cb351595c99a296c42"
integrity sha512-TWgcxmRrcxwObc+kXfoh2eAywmB+6OGm9jxmf6wgdTf49zF70iS8mG6mJ7+r+PLz4MEmRCUTJ2S5I83iU6rLeQ==
dependencies:
"@percy/logger" "1.27.0-beta.0"
"@percy/logger" "1.27.7"

"@percy/[email protected].0-beta.0":
version "1.27.0-beta.0"
resolved "https://registry.yarnpkg.com/@percy/logger/-/logger-1.27.0-beta.0.tgz#03ab52c8199071d677ed855596738048b686ae39"
integrity sha512-aVlXQ1agKiR0NJipEMz27JXWrtxEuT+QwtoWVFxz1SHLxOxNWlWXL9whOuj8X6jIDKFR9vZ2PttQrhyWKZFw5g==
"@percy/[email protected].7":
version "1.27.7"
resolved "https://registry.yarnpkg.com/@percy/logger/-/logger-1.27.7.tgz#7d094c0a67defaeec5b0257cf6930e8a7a9adb04"
integrity sha512-w+r9tJPEUSflCPVajx15yfFtdaxjiqiWIu6i4sHKGwg0B24ivVb+6e1J5R2ry19F/YPjBi6llz5BRB9vasu+Iw==

"@percy/[email protected]", "@percy/sdk-utils@^1.27.0-beta.0":
"@percy/[email protected]":
version "1.27.7"
resolved "https://registry.yarnpkg.com/@percy/sdk-utils/-/sdk-utils-1.27.7.tgz#b376c1ad653f3c70fea08a3db11eb63622ca6b53"
integrity sha512-E21dIEQ9wwGDno41FdMDYf6jJow5scbWGClqKE/ptB+950W4UF5C4hxhVVQoEJxDdLE/Gy/8ZJR7upvPHShWDg==

"@percy/sdk-utils@^1.27.0-beta.0":
version "1.27.0-beta.0"
resolved "https://registry.yarnpkg.com/@percy/sdk-utils/-/sdk-utils-1.27.0-beta.0.tgz#b6be92d6aeaf4876a042fd9833742d229573ea95"
integrity sha512-WsKtSNkSSbqjj+9KZ+7dG7RFApS7VkdgQxYeyTN/DwwqI627JgZZk7OKnJ99OHpL90gj33KJc01Uhft73HtMYA==

"@percy/[email protected].0-beta.0":
version "1.27.0-beta.0"
resolved "https://registry.yarnpkg.com/@percy/webdriver-utils/-/webdriver-utils-1.27.0-beta.0.tgz#0943deb560786be34e5f333d9949b4677548e600"
integrity sha512-Ij5vuTm7PH8YSE+h+Sw7dqZ0lQsc5mEqnQ7bjLntLtdH1wcQOSUlF2w9aL+ZgCo/Jrsl+QI+sTfU0K8HAdbeug==
"@percy/[email protected].7":
version "1.27.7"
resolved "https://registry.yarnpkg.com/@percy/webdriver-utils/-/webdriver-utils-1.27.7.tgz#5c74452f6763b90aee4b713f21da2672bae1d28d"
integrity sha512-8nAQJOhphTsaTAqKfcDC/MDf/yJvJ0Hf8Owc90pisXakooEMNnAW4HzQlZIh4kyJQbw4iX9OFl6gVl+POTWhHQ==
dependencies:
"@percy/config" "1.27.0-beta.0"
"@percy/sdk-utils" "1.27.0-beta.0"
"@percy/config" "1.27.7"
"@percy/sdk-utils" "1.27.7"

"@sindresorhus/is@^4.0.0":
version "4.6.0"
Expand Down

0 comments on commit 6beda7a

Please sign in to comment.