NoamGaash / playwright-advanced-har

MIT License
27 stars 0 forks source link

Referencing external json-file from HAR-file does not work #4

Closed andreasflinck closed 11 months ago

andreasflinck commented 11 months ago

Hi!

First of all - great timing introducing this tool just when I needed it :) I needed to remove a uuid search param and was struggling with all kinds of bad workarounds before I found your repo.

I just have one issue and that is that I do not get the response content when it is referenced from an external json-file.

Does not work:

          "content": {
            "size": -1,
            "mimeType": "application/json; charset=utf-8",
            "_file": "24634189ca062af1d89f1ed15ac3ae60ca869596.json"
          },

Works:

          "content": {
            "size": -1,
            "mimeType": "application/json; charset=utf-8",
            "text": "{\"key\" : \"value\"}"
          },

This is kind of a blocker since the advancedRouteFromHAR("./file.har", {update: true}) generates a bunch of json files referenced inside the har-file.

I really would appreciate your help with this!

NoamGaash commented 11 months ago

Thanks! you're right, we should fix that ASAP.

As a workaround, would you consider using advancedRouteFromHAR("./file.har", {update: true, updateContent: "embed"})? I believe it can solve this specific use case

andreasflinck commented 11 months ago

Oh my god, I totally missed that option. It works perfectly! Thanks! 🥇

NoamGaash commented 11 months ago

@andreasflinck would you like to review the test for the solution I made? I want to release this fix :)

NoamGaash commented 11 months ago

solved in version 1.2.1

andreasflinck commented 11 months ago

@NoamGaash Sorry, I was a bit late on the review.. its strange, even though I don't see any changes on the update: true logic, in 1.2.1 it ignores the url option and instead records all requests. It works in 1.2.0. Do you have any idea what is going on there?

NoamGaash commented 11 months ago

if the file was recorded with embed mode, it should work with both versions. the fix is regarding files recorded with the "attached" mode

andreasflinck commented 11 months ago

Yeah, but strangely even recording with embed mode differs between 1.2.0 and 1.2.1

1.2.0 -> In my case, results in a har-file with 700 rows, only with requests matching the url option 1.2.1 -> In my case, results in a har-file with 10 000 rows, covering ALL requests like local js-files, fonts etc

I created a repo that you can use for repro https://github.com/andreasflinck/advanced-har-bug-repro

  1. pnpm install
  2. run test
  3. observe the recorded har file, contains every single request although should be filtered by url: 'https://www.example.com/**',
  4. downgrade playwright-advanced-har -> 1.2.0 (pnpm install playwright-advanced-har@1.2.0)
  5. run test
  6. observe that the url filter now works, no requests has been recorded!
NoamGaash commented 7 months ago

@andreasflinck I've found the issue! Solved on version 1.3.2 :)