@bigbinary/neeto-playwright-commons 4.1.11 → 4.1.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.js +29 -15
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -116561,6 +116561,11 @@ class ColorPickerUtils {
116561
116561
  }
116562
116562
 
116563
116563
  const STATIC_ASSET_PATTERN = /\.(js|css|woff2?|ttf|eot|png|svg|ico|gif|webp)(\?.*)?$/;
116564
+ const EXCLUDED_RESPONSE_HEADERS = [
116565
+ "content-encoding",
116566
+ "content-length",
116567
+ "transfer-encoding",
116568
+ ];
116564
116569
  const assetCache = new Map();
116565
116570
  const commands = {
116566
116571
  context: async ({ context }, use) => {
@@ -116571,14 +116576,26 @@ const commands = {
116571
116576
  if (hit)
116572
116577
  return route.fulfill(hit);
116573
116578
  try {
116574
- const response = await route.fetch();
116575
- const body = await response.body();
116576
- const entry = {
116577
- body,
116578
- status: response.status(),
116579
- headers: response.headers(),
116580
- };
116581
- if (response.ok())
116579
+ // Use Node's native fetch instead of route.fetch() to keep these
116580
+ // requests out of the Playwright trace's Actions tab. Forward the
116581
+ // browser's request headers so cookie/session-scoped assets still
116582
+ // resolve; drop accept-encoding so we only get encodings Node can
116583
+ // decode, and HTTP/2 pseudo-headers which fetch rejects.
116584
+ const requestHeaders = Object.entries(await route.request().allHeaders()).filter(([name]) => name !== "accept-encoding" && !name.startsWith(":"));
116585
+ const response = await fetch(url, {
116586
+ headers: Object.fromEntries(requestHeaders),
116587
+ });
116588
+ const body = Buffer.from(await response.arrayBuffer());
116589
+ // Node's fetch decompresses the body but keeps the original
116590
+ // content-encoding/content-length headers; drop them so the
116591
+ // browser doesn't try to decode the already-decoded body.
116592
+ const headers = {};
116593
+ response.headers.forEach((value, key) => {
116594
+ if (!EXCLUDED_RESPONSE_HEADERS.includes(key))
116595
+ headers[key] = value;
116596
+ });
116597
+ const entry = { body, status: response.status, headers };
116598
+ if (response.ok)
116582
116599
  assetCache.set(url, entry);
116583
116600
  return route.fulfill(entry);
116584
116601
  }
@@ -116722,7 +116739,8 @@ const i18nFixture = {
116722
116739
  i18n: [
116723
116740
  async ({}, use) => {
116724
116741
  const translation = readTranslations();
116725
- const page = await (await chromium.launch()).newPage();
116742
+ const browser = await chromium.launch();
116743
+ const page = await browser.newPage();
116726
116744
  const taxonomies = await mergeTaxonomies(translation, page);
116727
116745
  const options = {
116728
116746
  debug: false,
@@ -116755,16 +116773,12 @@ const i18nFixture = {
116755
116773
  cache: true,
116756
116774
  });
116757
116775
  await page.close();
116776
+ await browser.close();
116758
116777
  await use(i18nInitialized);
116759
116778
  },
116760
116779
  { auto: true, scope: "worker" },
116761
116780
  ],
116762
- t: [
116763
- async ({ i18n }, use) => {
116764
- await use(i18n.t);
116765
- },
116766
- { scope: "worker" },
116767
- ],
116781
+ t: [({ i18n }, use) => use(i18n.t), { scope: "worker" }],
116768
116782
  };
116769
116783
 
116770
116784
  class ThankYouPage {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bigbinary/neeto-playwright-commons",
3
- "version": "4.1.11",
3
+ "version": "4.1.13",
4
4
  "description": "A package encapsulating common playwright code across neeto projects.",
5
5
  "repository": "git@github.com:bigbinary/neeto-playwright-commons.git",
6
6
  "license": "apache-2.0",