Is there a way to automate the bypassing of the JHipster login screen?
This is my goal:
let jwt_token
before(function fetchUser() {
cy.request('POST', '/api/authenticate', {
username: 'user',
password: 'user',
})
.its('body')
.then((res) => {
jwt_token = res.id_token
})
})
beforeEach(function setUser() {
cy.visit('/', {
onBeforeLoad(win) {
win.sessionStorage.setItem('jhi-authenticationtoken', jwt_token);
win.localStorage.setItem('jhi-authenticationtoken', jwt_token);
}
})
})
describe('test', () => {
it('verify programmatically if login works', () => {
cy.log(jwt_token);
cy.visit('/');
cy.get('.lead').should('have.text', 'Here is microservices catalog');
cy.get('#home-logged-message').should('have.text', 'You are logged in as user "user".');
})
})
Although jwt_token appears to have the correct value, the login process is still not successful and the 'test' fails.
Has anyone had success with this before?