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

Added support for capturing asset in multiple dpr and width combination #1536

Merged
merged 22 commits into from Mar 6, 2024

Conversation

chinmay-browserstack
Copy link
Contributor

Added new flag captureResponsiveAssets which will capture assets in all dpr, width combination supported by current project

@chinmay-browserstack chinmay-browserstack requested a review from a team as a code owner February 28, 2024 12:40
@chinmay-browserstack chinmay-browserstack changed the base branch from master to capture_srcset_support February 28, 2024 12:41
@@ -118,6 +118,7 @@ function getSnapshotOptions(options, { config, meta }) {
disableCache: config.discovery.disableCache,
captureMockedServiceWorker: config.discovery.captureMockedServiceWorker,
captureSrcset: config.discovery.captureSrcset,
captureResponsiveAssets: config.discovery.captureResponsiveAssets,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should not be needed, we should call this explicitly again if there is enableJS true. If we want to keep it then we need confirmation from product.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally we should do this automatically.

@@ -138,11 +139,24 @@ function processSnapshotResources({ domSnapshot, resources, ...snapshot }) {
return { ...snapshot, resources };
}

async function responsiveDomParams(snapshot, client) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not something we want to call per snapshot, move it to the snapshot config validation and cache the response in percy.js so that it can be applied to all snapshots in current build

});

it('gets device details', async () => {
api.reply('/device-details', () => [200, { data: '<<device-data-without-build-id>>' }]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
api.reply('/device-details', () => [200, { data: '<<device-data-without-build-id>>' }]);
api.reply('/device-details', () => [200, { data: ['<<device-data-without-build-id>>' ]}]);

@@ -317,7 +324,8 @@ export function createDiscoveryQueue(percy) {
try {
yield* captureSnapshotResources(page, snapshot, {
captureWidths: !snapshot.domSnapshot && percy.deferUploads,
capture: callback
capture: callback,
captureResponsiveDom: percy.deviceDetails || []
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

captureForDevices

@@ -198,6 +198,16 @@ async function* captureSnapshotResources(page, snapshot, options) {
}
}

if (captureResponsiveDom) {
for (const device of captureResponsiveDom) {
yield waitForDiscoveryNetworkIdle(page, discovery);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
yield waitForDiscoveryNetworkIdle(page, discovery);
// We are not adding these widths and pixels ratios in loop above because we want to explicitly reload the page after resize which we dont do above
yield waitForDiscoveryNetworkIdle(page, discovery);

});
if (discovery.devicePixelRatio) {
const log = logger('core:discovery');
log.warn('discovery.devicePixelRatio is deprecated percy will now auto capture resource in all devicePixelRatio, Ignoring configuration');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
log.warn('discovery.devicePixelRatio is deprecated percy will now auto capture resource in all devicePixelRatio, Ignoring configuration');
log.deprecate('discovery.devicePixelRatio is deprecated percy will now auto capture resource in all devicePixelRatio, Ignoring configuration');

try {
let url = 'device-details';
if (buildId) url += `?build_id=${buildId}`;
const { data } = await this.get(url);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This returns list only correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

Base automatically changed from capture_srcset_support to master March 4, 2024 14:02
@chinmay-browserstack chinmay-browserstack merged commit 9009452 into master Mar 6, 2024
36 checks passed
@chinmay-browserstack chinmay-browserstack deleted the multi_dpr_width_capture branch March 6, 2024 15:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants