hasadna / open-bus-map-search

open-bus-map-search
https://open-bus-map-search.hasadna.org.il/dashboard
MIT License
56 stars 90 forks source link

test | block google analytics when running tests #829

Open NoamGaash opened 5 months ago

NoamGaash commented 5 months ago

When running playwright test, let's use page.route to abort all requests to google analytics

YaelChen commented 6 days ago

Does it only mean to add this line await page.route('**/*google-analytics*', route => route.abort()); to every test file under "beforeEach"?

I'd like to assign myself if so.

NoamGaash commented 6 days ago

@YaelChen I think there are some domains that we would like to block, while avoid blocking unrelated urls Using the Chrome DevTool can help determine which URLs should be blocked: image And the test you've added that clicks this link is expected to pass despite of this change: image

Thank you! :pray:

YaelChen commented 6 days ago

I see the logic 😅 Thanks! I'll need to investigate some more for this, So I'm not assigning yet so that someone else will be able to take it :)

LeoBonjo commented 5 days ago

Does it only mean to add this line await page.route('**/*google-analytics*', route => route.abort()); to every test file under "beforeEach"?

I'd like to assign myself if so.

@YaelChen Hello, I had the same idea! However, when I open local host, it looks like the requests are still being sent. They return 204 No Content, regardless of whether I put in the await page.route('**/*google-analytics*', route => route.abort());.

Screenshot 2024-11-21 at 11 16 28 AM

I also tried creating a global-setup for playwright, but same thing. I am somewhat baffled. If you make any progress I'd be very excited to see :)

NoamGaash commented 5 days ago

I believe that the command await page.route('**/*google-analytics*', route => route.abort()); use a wrong pattern. something like:

page.route(/google-analytics\.com|googletagmanager\.com/, route => route.abort());

or

page.route(/^https?:\/\/(google-analytics|googletagmanager).com/, route => route.abort());

would probably do the trick