Add login via GraphQL to cypress commands
This commit is contained in:
parent
53ce39c887
commit
9ee3dc48b5
|
|
@ -24,6 +24,27 @@
|
||||||
// -- This is will overwrite an existing command --
|
// -- This is will overwrite an existing command --
|
||||||
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })
|
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })
|
||||||
|
|
||||||
|
Cypress.Commands.add('apolloLogin', (username, password) => {
|
||||||
|
const payload = {
|
||||||
|
'operationName': 'Login',
|
||||||
|
'variables': {
|
||||||
|
'input': {
|
||||||
|
'usernameInput': username,
|
||||||
|
'passwordInput': password
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'query': 'mutation Login($input: LoginInput!) {\n login(input: $input) {\n success\n errors {\n field\n __typename\n }\n __typename\n }\n}\n'
|
||||||
|
};
|
||||||
|
|
||||||
|
cy.request({
|
||||||
|
method: 'POST',
|
||||||
|
url: '/api/graphql-public/',
|
||||||
|
body: payload
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
// todo: replace with apollo call
|
// todo: replace with apollo call
|
||||||
Cypress.Commands.add("login", (username, password, visitLogin=false) => {
|
Cypress.Commands.add("login", (username, password, visitLogin=false) => {
|
||||||
if (visitLogin) {
|
if (visitLogin) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue