From 005a9d633dee6debb591b378bde699ed45e499d9 Mon Sep 17 00:00:00 2001 From: Jayant Goel Date: Mon, 27 Jun 2022 02:41:05 +0530 Subject: [PATCH] fix(plugins/pagespeed): add placeholder for PWA (#1113) [skip ci] --- source/app/metrics/utils.mjs | 4 ++-- source/app/web/statics/app.placeholder.js | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/source/app/metrics/utils.mjs b/source/app/metrics/utils.mjs index 6953bb15..9cbd26fa 100644 --- a/source/app/metrics/utils.mjs +++ b/source/app/metrics/utils.mjs @@ -331,8 +331,8 @@ export async function imgb64(image, {width, height, fallback = true} = {}) { return fallback ? "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mOcOnfpfwAGfgLYttYINwAAAABJRU5ErkJggg==" : null //Load image try { - //Fix: redirections are not properly supported by jimp (https://github.com/oliver-moran/jimp/issues/909) - if (typeof image === "string") { + //Fix: redirections are not properly supported by jimp (https://github.com/oliver-moran/jimp/issues/909), seems to occur only when in jest environment + if ((typeof image === "string")&&(process.env.JEST_WORKER_ID)) { image = (await axios.get(image)).then(response => response.request.responseURL).catch(() => null) console.debug(`metrics/svg/imgb64 > redirected image link to ${image}`) } diff --git a/source/app/web/statics/app.placeholder.js b/source/app/web/statics/app.placeholder.js index 5caccca3..0670c136 100644 --- a/source/app/web/statics/app.placeholder.js +++ b/source/app/web/statics/app.placeholder.js @@ -653,6 +653,7 @@ {score: faker.datatype.float({max: 1}), title: "Accessibility"}, {score: faker.datatype.float({max: 1}), title: "Best Practices"}, {score: faker.datatype.float({max: 1}), title: "SEO"}, + ... options["pagespeed.pwa"] ? [{score : faker.datatype.number({max: 1}), title: "PWA"}] : [] ], metrics: { observedFirstContentfulPaint: faker.datatype.number(500),