From 6fd36413baef1e8166b1e3815f081bbe913d8eb1 Mon Sep 17 00:00:00 2001 From: Chinmay Maheshwari Date: Fri, 27 Sep 2024 17:16:15 +0530 Subject: [PATCH] Added defer uploads option in test config endpoint --- packages/core/src/api.js | 3 ++- packages/core/test/api.test.js | 10 ++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/packages/core/src/api.js b/packages/core/src/api.js index 506ddc09c..dd9a3e3ed 100644 --- a/packages/core/src/api.js +++ b/packages/core/src/api.js @@ -193,10 +193,11 @@ export function createPercyServer(percy, port) { } else if (cmd === 'version') { // the version command will update the api version header for testing percy.testing.version = body; - } else if (cmd === 'widths') { + } else if (cmd === 'config') { percy.config.snapshot.widths = body.config; percy.deviceDetails = body.mobile?.map((w) => { return { width: w }; }); percy.config.snapshot.responsiveSnapshotCapture = !!body.responsive; + percy.config.percy.deferUploads = !!body.deferUploads; } else if (cmd === 'error' || cmd === 'disconnect') { // the error or disconnect commands will cause specific endpoints to fail (percy.testing.api ||= {})[body] = cmd; diff --git a/packages/core/test/api.test.js b/packages/core/test/api.test.js index 52ddb71b2..7cc581a3e 100644 --- a/packages/core/test/api.test.js +++ b/packages/core/test/api.test.js @@ -731,20 +731,22 @@ describe('API Server', () => { expect(headers['x-percy-core-version']).toEqual('0.0.1'); }); - it('can manipulate the config widths via /test/api/widths', async () => { + it('can manipulate the config widths via /test/api/config', async () => { let { widths, config } = await get('/percy/healthcheck'); expect(widths.config).toEqual([375, 1280]); expect(widths.mobile).toEqual([]); - await post('/test/api/widths', { config: [390] }); - ({ widths } = await get('/percy/healthcheck')); + await post('/test/api/config', { config: [390], deferUploads: true }); + ({ widths, config } = await get('/percy/healthcheck')); expect(widths.config).toEqual([390]); expect(config.snapshot.responsiveSnapshotCapture).toEqual(false); + expect(config.percy.deferUploads).toEqual(true); - await post('/test/api/widths', { config: [375, 1280], mobile: [456], responsive: true }); + await post('/test/api/config', { config: [375, 1280], mobile: [456], responsive: true }); ({ widths, config } = await get('/percy/healthcheck')); expect(widths.mobile).toEqual([456]); expect(config.snapshot.responsiveSnapshotCapture).toEqual(true); + expect(config.percy.deferUploads).toEqual(false); }); it('can make endpoints return server errors via /test/api/error', async () => {