Skip to content

Commit

Permalink
Sending screenshotType to API (#1473)
Browse files Browse the repository at this point in the history
  • Loading branch information
rishigupta1599 authored Dec 20, 2023
1 parent 8764ada commit 8830836
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 8 deletions.
7 changes: 5 additions & 2 deletions packages/client/test/client.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -857,7 +857,8 @@ describe('PercyClient', () => {
consideredElementsData: consideredElementsData,
domInfoSha: 'abcd=',
metadata: {
windowHeight: 1947
windowHeight: 1947,
screenshotType: 'singlepage'
}
})).toBeResolved();

Expand All @@ -870,7 +871,8 @@ describe('PercyClient', () => {
'consider-elements-data': consideredElementsData,
'dom-info-sha': 'abcd=',
metadata: {
windowHeight: 1947
windowHeight: 1947,
screenshotType: 'singlepage'
}
},
relationships: {
Expand Down Expand Up @@ -1006,6 +1008,7 @@ describe('PercyClient', () => {
externalDebugUrl: 'https://automate.browserstack.com/builds/acs',
metadata: {
windowHeight: 1947,
screenshotType: 'fullpage',
abc: 123
}
};
Expand Down
3 changes: 2 additions & 1 deletion packages/core/src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,8 @@ export const comparisonSchema = {
minimum: 0
},
cliScreenshotStartTime: { type: 'integer', default: 0 },
cliScreenshotEndTime: { type: 'integer', default: 0 }
cliScreenshotEndTime: { type: 'integer', default: 0 },
screenshotType: { type: 'string', default: 'singlepage' }
}
},
tag: {
Expand Down
7 changes: 5 additions & 2 deletions packages/webdriver-utils/src/providers/automateProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,12 @@ export default class AutomateProvider extends GenericProvider {
if (!this.driver) throw new Error('Driver is null, please initialize driver with createDriver().');
log.debug('Starting actual screenshotting phase');
const dpr = await this.metaData.devicePixelRatio();
const screenshotType = this.options?.fullPage ? 'fullpage' : 'singlepage';
const response = await TimeIt.run('percyScreenshot:screenshot', async () => {
return await this.browserstackExecutor('percyScreenshot', {
state: 'screenshot',
percyBuildId: this.buildInfo.id,
screenshotType: this.options?.fullPage ? 'fullpage' : 'singlepage',
screenshotType: screenshotType,
scaleFactor: dpr,
options: this.options
});
Expand All @@ -156,7 +157,9 @@ export default class AutomateProvider extends GenericProvider {
sha: tileData.sha.split('-')[0] // drop build id
}));
}
const metadata = {};
const metadata = {
screenshotType: screenshotType
};
return { tiles: tiles, domInfoSha: tileResponse.dom_sha, metadata: metadata };
}

Expand Down
12 changes: 9 additions & 3 deletions packages/webdriver-utils/test/providers/automateProvider.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,9 @@ describe('AutomateProvider', () => {
})
],
domInfoSha: 'def',
metadata: {}
metadata: {
screenshotType: 'fullpage'
}
};
expect(browserstackExecutorSpy).toHaveBeenCalledTimes(1);
expect(executeScriptSpy).toHaveBeenCalledTimes(1);
Expand All @@ -321,7 +323,9 @@ describe('AutomateProvider', () => {
})
],
domInfoSha: 'def',
metadata: {}
metadata: {
screenshotType: 'fullpage'
}
};
expect(browserstackExecutorSpy).toHaveBeenCalledTimes(1);
expect(executeScriptSpy).toHaveBeenCalledTimes(1);
Expand Down Expand Up @@ -357,7 +361,9 @@ describe('AutomateProvider', () => {
})
],
domInfoSha: 'def',
metadata: {}
metadata: {
screenshotType: 'singlepage'
}
};
expect(browserstackExecutorSpy).toHaveBeenCalledTimes(1);
expect(executeScriptSpy).toHaveBeenCalledTimes(1);
Expand Down

0 comments on commit 8830836

Please sign in to comment.