31 lines
1.1 KiB
JavaScript
31 lines
1.1 KiB
JavaScript
import { LOGIN_SELECTORS } from "../../elements/account/login-selectors";
|
|
|
|
Cypress.Commands.add("loginUser", () =>
|
|
cy
|
|
.get(LOGIN_SELECTORS.emailAddressInput)
|
|
.type(Cypress.env("USER_NAME"))
|
|
.get(LOGIN_SELECTORS.emailPasswordInput)
|
|
.type(Cypress.env("USER_PASSWORD"), { log: false })
|
|
.get(LOGIN_SELECTORS.signInButton)
|
|
.click()
|
|
);
|
|
|
|
Cypress.Commands.add("loginUserViaRequest", () =>
|
|
cy
|
|
.request({
|
|
method: "POST",
|
|
url: Cypress.env("API_URI"),
|
|
body: {
|
|
operationName: "TokenAuth",
|
|
variables: {
|
|
email: Cypress.env("USER_NAME"),
|
|
password: Cypress.env("USER_PASSWORD")
|
|
},
|
|
query:
|
|
"mutation TokenAuth($email: String!, $password: String!) {\n tokenCreate(email: $email, password: $password) {\n token\n errors: accountErrors {\n code\n field\n message\n __typename\n }\n user {\n id\n __typename\n }\n __typename\n }\n}\n"
|
|
}
|
|
})
|
|
.then(resp => {
|
|
window.sessionStorage.setItem("auth", resp.body.data.tokenCreate.token);
|
|
})
|
|
);
|