clear session data when needed (#2711)
This commit is contained in:
parent
17e3c4c8f2
commit
ea2cd5fe96
4 changed files with 27 additions and 37 deletions
|
@ -43,7 +43,6 @@ describe("As an unlogged customer I want to order physical and digital products"
|
|||
shippingMethod = resp.shippingMethod;
|
||||
digitalVariants = resp.digitalVariants;
|
||||
physicalVariants = resp.physicalVariants;
|
||||
cy.clearSessionData();
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -5,33 +5,24 @@ import { urlList } from "../../../../fixtures/urlList";
|
|||
Cypress.Commands.add(
|
||||
"sendRequestWithQuery",
|
||||
(query, authorization = "auth", variables = "") => {
|
||||
if (authorization.length !== 30) {
|
||||
cy.request({
|
||||
body: {
|
||||
variables,
|
||||
query,
|
||||
},
|
||||
headers: {
|
||||
let headers;
|
||||
|
||||
if (authorization && authorization.length !== 30) {
|
||||
headers = {
|
||||
Authorization: `JWT ${window.sessionStorage.getItem(authorization)}`,
|
||||
},
|
||||
method: "POST",
|
||||
url: urlList.apiUri,
|
||||
log: true,
|
||||
}).then(response => {
|
||||
const respInSting = JSON.stringify(response.body);
|
||||
if (respInSting.includes(`"errors":[{`)) {
|
||||
cy.log(query).log(JSON.stringify(response.body));
|
||||
}
|
||||
});
|
||||
};
|
||||
} else if (authorization) {
|
||||
headers = { Authorization: `Bearer ${authorization}` };
|
||||
} else {
|
||||
headers = {};
|
||||
}
|
||||
|
||||
cy.request({
|
||||
body: {
|
||||
variables,
|
||||
query,
|
||||
},
|
||||
headers: {
|
||||
Authorization: `Bearer ${authorization}`,
|
||||
},
|
||||
headers,
|
||||
method: "POST",
|
||||
url: urlList.apiUri,
|
||||
log: true,
|
||||
|
@ -41,6 +32,5 @@ Cypress.Commands.add(
|
|||
cy.log(query).log(JSON.stringify(response.body));
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
);
|
||||
|
|
|
@ -35,7 +35,7 @@ Cypress.Commands.add(
|
|||
}
|
||||
}
|
||||
}`;
|
||||
return cy.sendRequestWithQuery(mutation, authorization).then(resp => {
|
||||
return cy.sendRequestWithQuery(mutation, null).then(resp => {
|
||||
window.localStorage.setItem(
|
||||
"_saleorCSRFToken",
|
||||
resp.body.data.tokenCreate.csrfToken,
|
||||
|
|
|
@ -27,6 +27,7 @@ cypressGrep();
|
|||
Cypress.Commands.add("clearSessionData", () => {
|
||||
cy.clearCookies();
|
||||
cy.clearLocalStorage();
|
||||
window.sessionStorage.clear();
|
||||
});
|
||||
|
||||
Cypress.Commands.add("addAliasToGraphRequest", operationName => {
|
||||
|
|
Loading…
Reference in a new issue