Tests are not working for app with service worker used for intercepting requests #8054
Labels
FREQUENCY: level 1
SYSTEM: native automation
TYPE: bug
The described behavior is considered as wrong (bug).
What is your Scenario?
I'm using @axa-fr/oidc-client authentication package. Library offers Service Worker to store auth data and intercepts http requests to inject access tokens which is more secure than sessionStorage . We have e2e tests written in Testcafe which stopped working after switching to SW (going back to sessionStorage is not an option for us).
What is the Current behavior?
Test runs with
nativeAutomation
enabled stopped working at all. There is only blank page displayed without any errors in console - test fails on first selector timeout.With
nativeAutomation
disabled is a bit better. Tests are able open initial page, successfully login but fails on going back to the app. I did some investigation and looks like override forfetch
event in hammerhead src/client/worker/fetch-event.ts#L93 is cancelling the original request. I noticed that for some requestsReferrer Policy
header is not overriden by hammerhead withunsafe-url
and defaultstrict-origin-when-cross-origin
is used - it truncates path and params from url inReferer
header. Because of that condition which pass through the request is not met.What is the Expected behavior?
Tests should pass (at least for old solution with hammerhead).
What is your public website URL? (or attach your complete example)
I've created sample repo with reproduction steps : https://github.com/radk0s/testcafe-sw-issue
Also deployed sample app to https://radk0s.github.io/testcafe-sw-issue/
What is your TestCafe test code?
Your complete configuration file
No response
Your complete test report
Screenshots
No response
Steps to Reproduce
All reproduction steps are described in example repo: https://github.com/radk0s/testcafe-sw-issue
Can be also reproduced with
http-playground
from https://github.com/DevExpress/testcafe-hammerhead:TestCafe version
3.3.0
Node.js version
18.14.2
Command-line arguments
testcafe chrome ./e2e --disable-native-automation --hostname localhost
Browser name(s) and version(s)
No response
Platform(s) and version(s)
Mac OS ventura 13.6
Other
No response
The text was updated successfully, but these errors were encountered: