Ocelot-Social/cypress/integration/common/I_am_logged_in_as_{string}.js
Ulf Gebhardt 39fb4b98d3
User.ChangePassword.feature
unified user creation and logging in
2021-04-14 20:36:13 +02:00

18 lines
533 B
JavaScript

import { Given } from "cypress-cucumber-preprocessor/steps";
import encode from '../../../backend/src/jwt/encode'
Given("I am logged in as {string}", slug => {
cy.neode()
.first("User", { slug })
.then(user => {
return new Cypress.Promise((resolve, reject) => {
if(!user) {
return reject(`User ${email} not found in database`)
}
return user.toJson().then((user) => resolve(user))
})
})
.then(user => {
cy.setCookie('ocelot-social-token', encode(user))
})
});