I'm trying to test that the application redirects the user away from the authenticated route since they are not an admin.
But I need a way to wait for all redirects to finish before I call getCurrentUrl()
it('should not allow regular user access', async (test) => {
await test.remote
.then(e2e.impersonate('[email protected]'))
.get('/protected-route')
//.waitForAllRedirects()
.getCurrentUrl()
.then(url => {
console.log('url', url);
expect(url.indexOf('/landing-page')).not.toBe(-1);
return true;
});
});
Probably the simplest thing to do is to look for content that should be on the non-protected page rather than the protected page. Once you've found the expected content, check the URL to verify you're where you should be.