I know this topic is discussed quite a bit but I have a unique situation.
In order to test our acceptance environment, we need to hit https://authentication-example.com, which runs a script to add a session cookie thus authenticating us. Then we navigate to https://acceptance-site.com to run the tests.
After trying many options, the closest I can get to a solution, is to use a Role such as
const a3 = Role('https://acceptance-site.com', async testController => {
await testController.navigateTo('https://authentication-example.com');
await testController.navigateTo('https://acceptance-site.com');
}, { preserveUrl: true });
fixture('Testing acceptance')
.beforeEach(async testController => {
await testController.useRole(authenticate);
});
test('example1', async testController => {
await testController.debug();
}).disablePageReloads;
test('example2', async testController => {
await testController.debug();
}).disablePageReloads;
test('example3', async testController => {
await testController.debug();
}).disablePageReloads;
That solution prevents me from being able to load any new pages that are different from what the Role ends at.
If I remove { preserveUrl: true } from the role, example2 and example3 load blank pages. If I remove .disablePageReloads from the tests, the authentication fails for the escond and third tests, and I get an error "Failed to find a DNS-record for the resource at..." Also If I have the role as
const a3 = Role('https://authentication-example.com', async testController => {
await testController.navigateTo('https://acceptance-site.com');
}, { preserveUrl: true });
the authentication fails for all test.
I noticed that when working successfully, the cookie I should be getting is actually saved in the session under application when debugging, and it is changed by this hammerhead storage wrapper. The base url when testing is the ip and port for the testCafe server preceded by random letters, for example 172.0.0.1:8080/hoi23hh/https://acceptance-site.com which results in my cookie being saved in the session (not under cookies as normally occurs when not using test cafe) as hammerhead|storage-wrapper|hoi23hh|acceptance-site.com
When I remove the .disablePageReloads, but keep the preserveUrl: true on the role, the 'cookie' stays the same but the base url changes to something like 172.0.0.1:8080/ohgbo223/https://acceptance-site.com
so the "hoi23hh" changes to "ohgbo223" in the url and the cookie/session key no longer matches the url and authentication fails.
What are your suggestions for persisting the authentication, while still being able to change pages and such