Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding support for testcase base grouping #265

Merged
merged 3 commits into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ module.exports = async function percyScreenshot(driver, name, options = {}) {
topScrollviewOffset,
bottomScrollviewOffset,
scrollableId,
sync
sync,
testCase
} = options;
// allow working with or without standalone mode for wdio
if (!driver || typeof driver === 'string') {
Expand Down Expand Up @@ -56,6 +57,7 @@ module.exports = async function percyScreenshot(driver, name, options = {}) {
bottomScrollviewOffset = name.bottomScrollviewOffset;
scrollableId = name.scrollableId;
sync = name.sync;
testCase = name.testCase;
options = name;
}
try {
Expand Down Expand Up @@ -84,6 +86,9 @@ module.exports = async function percyScreenshot(driver, name, options = {}) {
return percyOnAutomateResponse?.body?.data;
}
const provider = ProviderResolver.resolve(driver);
// Only added for browserstack sdk.
let thTestCaseExecutionId = options.thTestCaseExecutionId;

const response = await provider.screenshot(name, {
fullscreen,
deviceName,
Expand All @@ -104,7 +109,9 @@ module.exports = async function percyScreenshot(driver, name, options = {}) {
topScrollviewOffset,
bottomScrollviewOffset,
scrollableId,
sync
sync,
testCase,
thTestCaseExecutionId
});
log.debug(`[${name}] -> end`);
return response?.body?.data;
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@
"test:types": "tsd"
},
"dependencies": {
"@percy/sdk-utils": "^1.28.0",
"@percy/sdk-utils": "^1.28.2",
"tmp": "^0.2.1"
},
"devDependencies": {
"@percy/cli": "^1.28.0",
"@percy/cli": "^1.28.2",
"cross-env": "^7.0.2",
"eslint": "^8.27.0",
"eslint-plugin-n": "^15.5.1",
Expand Down
8 changes: 6 additions & 2 deletions percy/providers/appAutomateProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ class AppAutomateProvider extends GenericProvider {
topScrollviewOffset,
bottomScrollviewOffset,
scrollableId,
sync
sync,
testCase,
thTestCaseExecutionId
} = {}) {
let response = null;
let error;
Expand Down Expand Up @@ -63,7 +65,9 @@ class AppAutomateProvider extends GenericProvider {
topScrollviewOffset,
bottomScrollviewOffset,
scrollableId,
sync
sync,
testCase,
thTestCaseExecutionId
});
} catch (e) {
error = e;
Expand Down
8 changes: 6 additions & 2 deletions percy/providers/genericProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ class GenericProvider {
customConsiderRegions,
scrollableXpath,
scrollableId,
sync
sync,
testCase,
thTestCaseExecutionId
}) {
fullscreen = fullscreen || false;
sync = sync || null;
Expand Down Expand Up @@ -92,7 +94,9 @@ class GenericProvider {
},
environmentInfo: ENV_INFO,
clientInfo: CLIENT_INFO,
sync
sync,
testCase,
thTestCaseExecutionId
});
}

Expand Down
12 changes: 8 additions & 4 deletions test/index.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -264,28 +264,32 @@ describe('percyScreenshot', () => {
spyOn(percyOnAutomate, 'request').and.callFake(() => {});

await percyScreenshot(driver, 'Screenshot 2', {
ignore_region_appium_elements: [element], consider_region_appium_elements: [element]
ignore_region_appium_elements: [element], consider_region_appium_elements: [element], testCase: 'test-case-1', thTestCaseExecutionId: 'ID123'
});
expect(percyOnAutomate.request).toHaveBeenCalledWith(jasmine.objectContaining({
sessionId: 'sessionID',
commandExecutorUrl: 'https://localhost/wd/hub',
snapshotName: 'Screenshot 2',
options: {
ignore_region_elements: ['123'],
consider_region_elements: ['123']
consider_region_elements: ['123'],
testCase: 'test-case-1',
thTestCaseExecutionId: 'ID123'
}
}));

await percyScreenshot(driver, 'Screenshot 3', {
ignoreRegionAppiumElements: [element2], considerRegionAppiumElements: [element2]
ignoreRegionAppiumElements: [element2], considerRegionAppiumElements: [element2], testCase: 'test-case-2', thTestCaseExecutionId: 'ID123'
});
expect(percyOnAutomate.request).toHaveBeenCalledWith(jasmine.objectContaining({
sessionId: 'sessionID',
commandExecutorUrl: 'https://localhost/wd/hub',
snapshotName: 'Screenshot 3',
options: {
ignore_region_elements: ['456'],
consider_region_elements: ['456']
consider_region_elements: ['456'],
testCase: 'test-case-2',
thTestCaseExecutionId: 'ID123'
}
}));
});
Expand Down
203 changes: 99 additions & 104 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/cli-app@1.27.7":
version "1.27.7"
resolved "https://registry.npmjs.org/@percy/cli-app/-/cli-app-1.27.7.tgz"
integrity sha512-IQuTC5X5JM65cqOluFM9lnydkw3hvkUdf6LTsBRtzmS7/qURyiBDvuxkKt37XUCfXm2XFP8J6B6ADBQL4YShPA==
"@percy/cli-app@1.28.2":
version "1.28.2"
resolved "https://registry.yarnpkg.com/@percy/cli-app/-/cli-app-1.28.2.tgz#425f7480e7ecd393bdf7480e666333ccb0c299b0"
integrity sha512-UhuxmBRcgeyBnzV7ixiSqUlMdcBg7LyrTtDJWEjQ36SH0jJOAVu020cGcPLNDDTmqXDU7DsDoNifxtPzXT+d5w==
dependencies:
"@percy/cli-command" "1.27.7"
"@percy/cli-exec" "1.27.7"
"@percy/cli-command" "1.28.2"
"@percy/cli-exec" "1.28.2"

"@percy/cli-build@1.27.7":
version "1.27.7"
resolved "https://registry.npmjs.org/@percy/cli-build/-/cli-build-1.27.7.tgz"
integrity sha512-UmWaUFQAomlL4GpU/KPTq3hmJtXCMWQELwDnaQ1vnUf2rk17qSy5keSvCb/Ta8oPuObuRNoOHGrtUFPh1b7l2g==
"@percy/cli-build@1.28.2":
version "1.28.2"
resolved "https://registry.yarnpkg.com/@percy/cli-build/-/cli-build-1.28.2.tgz#fcbda1e6566d5353c87e3d78c6e500a14c0a01ae"
integrity sha512-VWfrgcOaN6rxSCwifQ5aJuGQDU2Nmq3lvvqZsVVSj3lBbE4KsEaxyoH2Hmm2pCOXi1DzOQ0+zHv+Ra+m4CyBvA==
dependencies:
"@percy/cli-command" "1.27.7"
"@percy/cli-command" "1.28.2"

"@percy/cli-command@1.27.7":
version "1.27.7"
resolved "https://registry.npmjs.org/@percy/cli-command/-/cli-command-1.27.7.tgz"
integrity sha512-nVHspbcTStwZOVYmcCowcFJsOLLJrhLfJbj2Rkvm3upf/E98x4+S9H+Tq9K4XcgznjFfLLRAHkkVFGnCdbO5qQ==
"@percy/cli-command@1.28.2":
version "1.28.2"
resolved "https://registry.yarnpkg.com/@percy/cli-command/-/cli-command-1.28.2.tgz#18d04d268dc2543f5d57e0dafda255badea1786a"
integrity sha512-UUa+dSpzTcXVjzvElL4wD315QYDuGrbnXObgaztyGWdufEbvLWflU4AiQZrxC5abDXQdNWQUAAizorA5dGhaCg==
dependencies:
"@percy/config" "1.27.7"
"@percy/core" "1.27.7"
"@percy/logger" "1.27.7"
"@percy/config" "1.28.2"
"@percy/core" "1.28.2"
"@percy/logger" "1.28.2"

"@percy/cli-config@1.27.7":
version "1.27.7"
resolved "https://registry.npmjs.org/@percy/cli-config/-/cli-config-1.27.7.tgz"
integrity sha512-SppI7w9xQAUk4nCqXq0KE3HoKZ+IwgkJ6biAQuzv3BJ8GWz42hUGnH1fLEoK92MZMLiOHByiEFUoBzUKXPscZw==
"@percy/cli-config@1.28.2":
version "1.28.2"
resolved "https://registry.yarnpkg.com/@percy/cli-config/-/cli-config-1.28.2.tgz#72cad828d7364cfa3de12b8c907a9c5b9d054a13"
integrity sha512-O1O2n16jOm6HCzGM207/NbX+IR7ezUaQGnExi4G5SbOYqZeBIrsKpbEi/SERBfg4Kexv16LrF6NLOs75N2oaSw==
dependencies:
"@percy/cli-command" "1.27.7"
"@percy/cli-command" "1.28.2"

"@percy/cli-exec@1.27.7":
version "1.27.7"
resolved "https://registry.npmjs.org/@percy/cli-exec/-/cli-exec-1.27.7.tgz"
integrity sha512-ZYSuQYu7hMbl/KbGwS/bEdAEXEY7MygheCJrmM43AGUIj8LSHnVTi09/z7ZpcStLibPmsraJ8Cm7GXhTNdhuAQ==
"@percy/cli-exec@1.28.2":
version "1.28.2"
resolved "https://registry.yarnpkg.com/@percy/cli-exec/-/cli-exec-1.28.2.tgz#561e555d05035cf9e7fd1bc9a261c8d2ffea5515"
integrity sha512-tRvmoDJMb94XjA60a0lmN2XphzC/r70ruic+VfhFwEqDVoLY/6LxqjSXjehiSD5huXYDyPtaMeJo7oU1FxJyZg==
dependencies:
"@percy/cli-command" "1.27.7"
"@percy/cli-command" "1.28.2"
cross-spawn "^7.0.3"
which "^2.0.2"

"@percy/cli-snapshot@1.27.7":
version "1.27.7"
resolved "https://registry.npmjs.org/@percy/cli-snapshot/-/cli-snapshot-1.27.7.tgz"
integrity sha512-FGmNhXfOvW2RkcdEzeWWXo2fUp8UoRIb8bT0Bg6xcw5UGPUAoDVaFA8i4M5Qvi/K54Ed5VYfBX3y5sLcg2XRaw==
"@percy/cli-snapshot@1.28.2":
version "1.28.2"
resolved "https://registry.yarnpkg.com/@percy/cli-snapshot/-/cli-snapshot-1.28.2.tgz#a6c75a35f78845fb80ec08f57bff356b59f220e1"
integrity sha512-Qda4MKjKxoM/TEBjl54lCXMJAmQB6ZZheE96pJzEJzlPQtlj9r/moM3etCV+res0qaSOgx9BL0DncruvAwM/4g==
dependencies:
"@percy/cli-command" "1.27.7"
"@percy/cli-command" "1.28.2"
yaml "^2.0.0"

"@percy/cli-upload@1.27.7":
version "1.27.7"
resolved "https://registry.npmjs.org/@percy/cli-upload/-/cli-upload-1.27.7.tgz"
integrity sha512-kC9wfZ6TBnOTlB2ge32IlEQlxGh+fLXUIlmelCXCTDL6zutn8mI117XOHaJDtsI7qtovM0cTBxoSySaBY4XNqg==
"@percy/cli-upload@1.28.2":
version "1.28.2"
resolved "https://registry.yarnpkg.com/@percy/cli-upload/-/cli-upload-1.28.2.tgz#3a89f977eb235dc3fb3e1b4af9ad409d71cb5761"
integrity sha512-vzH4wRdAFGvktNlh57p4s9Qq+rT0MsiQ/kh7pDvzQ1lJ6glpCBXSiiahMtkR8AP8gMMzxYONAuV/htB/t8sFUw==
dependencies:
"@percy/cli-command" "1.27.7"
"@percy/cli-command" "1.28.2"
fast-glob "^3.2.11"
image-size "^1.0.0"

"@percy/cli@^1.27.2":
version "1.27.7"
resolved "https://registry.npmjs.org/@percy/cli/-/cli-1.27.7.tgz"
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/client@1.27.7":
version "1.27.7"
resolved "https://registry.npmjs.org/@percy/client/-/client-1.27.7.tgz"
integrity sha512-pMaimVhfJEWyta40PyanH/Sv8mp+CBeO4HuJ72zadDrJVAwNNBfaNE8OzT298y8u/DrMz/AlNSA6OhVojDVAuQ==
dependencies:
"@percy/env" "1.27.7"
"@percy/logger" "1.27.7"

"@percy/config@1.27.7":
version "1.27.7"
resolved "https://registry.npmjs.org/@percy/config/-/config-1.27.7.tgz"
integrity sha512-7XbnrVWgvMgYAIngyWt0nd/l5lQiioOzIkqm9iH+nbfH/ka9pE8U/AWsCuiWGz2Z/1p03gBDFc01cyM+ORjglQ==
dependencies:
"@percy/logger" "1.27.7"
"@percy/cli@^1.28.2":
version "1.28.2"
resolved "https://registry.yarnpkg.com/@percy/cli/-/cli-1.28.2.tgz#94ee5237247a2ca2490188c930d998c2f251d254"
integrity sha512-hwibBu6zsjfWXIe8WFgrKizGjxkTzYcGQ4eOPcMQXfgK3yUZ24N5v8sqCOobRA/SbdD117zp2WUEkBRWCJ85gg==
dependencies:
"@percy/cli-app" "1.28.2"
"@percy/cli-build" "1.28.2"
"@percy/cli-command" "1.28.2"
"@percy/cli-config" "1.28.2"
"@percy/cli-exec" "1.28.2"
"@percy/cli-snapshot" "1.28.2"
"@percy/cli-upload" "1.28.2"
"@percy/client" "1.28.2"
"@percy/logger" "1.28.2"

"@percy/client@1.28.2":
version "1.28.2"
resolved "https://registry.yarnpkg.com/@percy/client/-/client-1.28.2.tgz#9b2debea1279ecb464a918c1a41aca1c8a18e244"
integrity sha512-UoQ4WY8zJhwv/7vKJS+1vbeu/T7YckSmOp/moCoAnHY6QOIXYs7EGkNyeEw5iXoQYzMw6KkkLYPC7YC0rt5pSg==
dependencies:
"@percy/env" "1.28.2"
"@percy/logger" "1.28.2"

"@percy/config@1.28.2":
version "1.28.2"
resolved "https://registry.yarnpkg.com/@percy/config/-/config-1.28.2.tgz#8ac1210f3d0b8da6be1012bd85a3c1c25b9ada92"
integrity sha512-Q9NoenDuhRiY+eBGrw8FJmmU8hErTsjBxccUOvrfn0A4JXRvcFHitvrh85rXG/HhyT4bcoB9O93QhV6F9KTq7A==
dependencies:
"@percy/logger" "1.28.2"
ajv "^8.6.2"
cosmiconfig "^8.0.0"
yaml "^2.0.0"

"@percy/core@1.27.7":
version "1.27.7"
resolved "https://registry.npmjs.org/@percy/core/-/core-1.27.7.tgz"
integrity sha512-lwweKGLbjsCWcAvaeHSK47IkaioBPKKjKd8fhhXFfv713aNL5CcokO9uUNMyBwrgqLY8jmPR/McMtROidUSowQ==
"@percy/core@1.28.2":
version "1.28.2"
resolved "https://registry.yarnpkg.com/@percy/core/-/core-1.28.2.tgz#66431adece2ca64ae9fa3dd95c7b39b1baffad05"
integrity sha512-7JkZrsLoHDD2bkhN4u5T/+0sC0UT73Lv1qF3lIMLu+Qjt1BhyKdnitbOnjFlrVOwqC5uNgr7/gvcULLVbJga8Q==
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"
"@percy/client" "1.28.2"
"@percy/config" "1.28.2"
"@percy/dom" "1.28.2"
"@percy/logger" "1.28.2"
"@percy/webdriver-utils" "1.28.2"
content-disposition "^0.5.4"
cross-spawn "^7.0.3"
extract-zip "^2.0.1"
Expand All @@ -432,40 +432,35 @@
rimraf "^3.0.2"
ws "^8.0.0"

"@percy/dom@1.27.7":
version "1.27.7"
resolved "https://registry.npmjs.org/@percy/dom/-/dom-1.27.7.tgz"
integrity sha512-FLMaAp7LByGFqvTEV1UwiQd+Ww1SHU2UuGOvgMPBwPgAKt2BB+FfZEYgaeORt5YXLfDJsIVk/lfvhJXzmb5k8Q==
"@percy/dom@1.28.2":
version "1.28.2"
resolved "https://registry.yarnpkg.com/@percy/dom/-/dom-1.28.2.tgz#7908313141299bcf22862ba235c724ce19e4d66e"
integrity sha512-bUU38EMowO+y+pnLzl0naikv0pVQvcrkrBm7K7eVGUt6orRTqr5Tr8bMV7Ooac4mlMwaZvCkAH7gPhiDAONUmw==

"@percy/env@1.27.7":
version "1.27.7"
resolved "https://registry.npmjs.org/@percy/env/-/env-1.27.7.tgz"
integrity sha512-TWgcxmRrcxwObc+kXfoh2eAywmB+6OGm9jxmf6wgdTf49zF70iS8mG6mJ7+r+PLz4MEmRCUTJ2S5I83iU6rLeQ==
"@percy/env@1.28.2":
version "1.28.2"
resolved "https://registry.yarnpkg.com/@percy/env/-/env-1.28.2.tgz#25f58cc2a395cb0268658e74a84496714bd1de8a"
integrity sha512-40UhiL5MylFN39pzzoyDKgult2ZmSbuc3ADrNGBx9zyMdFEoTLZg5BcFZoSUHHjPboe2jYZFYrRqoXxix++OfA==
dependencies:
"@percy/logger" "1.27.7"
"@percy/logger" "1.28.2"

"@percy/logger@1.27.7":
version "1.27.7"
resolved "https://registry.npmjs.org/@percy/logger/-/logger-1.27.7.tgz"
integrity sha512-w+r9tJPEUSflCPVajx15yfFtdaxjiqiWIu6i4sHKGwg0B24ivVb+6e1J5R2ry19F/YPjBi6llz5BRB9vasu+Iw==
"@percy/logger@1.28.2":
version "1.28.2"
resolved "https://registry.yarnpkg.com/@percy/logger/-/logger-1.28.2.tgz#5ba2b55328acd3459a98806db01115d00587d71a"
integrity sha512-ZF1iDjY9oBL+4WEqGuJ4JJaUdyUqGhdJtS+qDV8iqrQ6VngWBpO3lg0Uhy8RIkqUSLGKbwVbnxkfvA5kXx+yAw==

"@percy/sdk-utils@1.27.7":
version "1.27.7"
resolved "https://registry.npmjs.org/@percy/sdk-utils/-/sdk-utils-1.27.7.tgz"
integrity sha512-E21dIEQ9wwGDno41FdMDYf6jJow5scbWGClqKE/ptB+950W4UF5C4hxhVVQoEJxDdLE/Gy/8ZJR7upvPHShWDg==
"@percy/sdk-utils@1.28.2", "@percy/sdk-utils@^1.28.2":
version "1.28.2"
resolved "https://registry.yarnpkg.com/@percy/sdk-utils/-/sdk-utils-1.28.2.tgz#22d48ab0a281bbf39add303fcb1687ccac0e91a1"
integrity sha512-cMFz8AjZ2KunN0dVwzA+Wosk4B+6G9dUkh2YPhYvqs0KLcCyYs3s91IzOQmtBOYwAUVja/W/u6XmBHw0jaxg0A==

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

"@percy/[email protected]":
version "1.27.7"
resolved "https://registry.npmjs.org/@percy/webdriver-utils/-/webdriver-utils-1.27.7.tgz"
integrity sha512-8nAQJOhphTsaTAqKfcDC/MDf/yJvJ0Hf8Owc90pisXakooEMNnAW4HzQlZIh4kyJQbw4iX9OFl6gVl+POTWhHQ==
"@percy/[email protected]":
version "1.28.2"
resolved "https://registry.yarnpkg.com/@percy/webdriver-utils/-/webdriver-utils-1.28.2.tgz#96b8433dcc16672d0d883c70b4c1842475995e82"
integrity sha512-bD0UoR1/69xcsL2mhvZ4xQKhWJYbqUJUFMiNr8xqR55Z4dArbeN9S2ZYU6aMVRemuKyn7ki0ttNFHq0z2GFvGg==
dependencies:
"@percy/config" "1.27.7"
"@percy/sdk-utils" "1.27.7"
"@percy/config" "1.28.2"
"@percy/sdk-utils" "1.28.2"

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