-
Notifications
You must be signed in to change notification settings - Fork 48
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
Conversation
…ti_dpr_width_capture
packages/core/src/snapshot.js
Outdated
@@ -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, |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
packages/core/src/discovery.js
Outdated
@@ -138,11 +139,24 @@ function processSnapshotResources({ domSnapshot, resources, ...snapshot }) { | |||
return { ...snapshot, resources }; | |||
} | |||
|
|||
async function responsiveDomParams(snapshot, client) { |
There was a problem hiding this comment.
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
packages/client/test/client.test.js
Outdated
}); | ||
|
||
it('gets device details', async () => { | ||
api.reply('/device-details', () => [200, { data: '<<device-data-without-build-id>>' }]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
api.reply('/device-details', () => [200, { data: '<<device-data-without-build-id>>' }]); | |
api.reply('/device-details', () => [200, { data: ['<<device-data-without-build-id>>' ]}]); |
packages/core/src/discovery.js
Outdated
@@ -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 || [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
captureForDevices
packages/core/src/discovery.js
Outdated
@@ -198,6 +198,16 @@ async function* captureSnapshotResources(page, snapshot, options) { | |||
} | |||
} | |||
|
|||
if (captureResponsiveDom) { | |||
for (const device of captureResponsiveDom) { | |||
yield waitForDiscoveryNetworkIdle(page, discovery); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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); |
packages/core/src/discovery.js
Outdated
}); | ||
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'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes
Added new flag
captureResponsiveAssets
which will capture assets in all dpr, width combination supported by current project