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;
|
shippingMethod = resp.shippingMethod;
|
||||||
digitalVariants = resp.digitalVariants;
|
digitalVariants = resp.digitalVariants;
|
||||||
physicalVariants = resp.physicalVariants;
|
physicalVariants = resp.physicalVariants;
|
||||||
cy.clearSessionData();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -5,42 +5,32 @@ import { urlList } from "../../../../fixtures/urlList";
|
||||||
Cypress.Commands.add(
|
Cypress.Commands.add(
|
||||||
"sendRequestWithQuery",
|
"sendRequestWithQuery",
|
||||||
(query, authorization = "auth", variables = "") => {
|
(query, authorization = "auth", variables = "") => {
|
||||||
if (authorization.length !== 30) {
|
let headers;
|
||||||
cy.request({
|
|
||||||
body: {
|
if (authorization && authorization.length !== 30) {
|
||||||
variables,
|
headers = {
|
||||||
query,
|
Authorization: `JWT ${window.sessionStorage.getItem(authorization)}`,
|
||||||
},
|
};
|
||||||
headers: {
|
} else if (authorization) {
|
||||||
Authorization: `JWT ${window.sessionStorage.getItem(authorization)}`,
|
headers = { Authorization: `Bearer ${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 {
|
} else {
|
||||||
cy.request({
|
headers = {};
|
||||||
body: {
|
|
||||||
variables,
|
|
||||||
query,
|
|
||||||
},
|
|
||||||
headers: {
|
|
||||||
Authorization: `Bearer ${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));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cy.request({
|
||||||
|
body: {
|
||||||
|
variables,
|
||||||
|
query,
|
||||||
|
},
|
||||||
|
headers,
|
||||||
|
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));
|
||||||
|
}
|
||||||
|
});
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
|
@ -35,7 +35,7 @@ Cypress.Commands.add(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}`;
|
}`;
|
||||||
return cy.sendRequestWithQuery(mutation, authorization).then(resp => {
|
return cy.sendRequestWithQuery(mutation, null).then(resp => {
|
||||||
window.localStorage.setItem(
|
window.localStorage.setItem(
|
||||||
"_saleorCSRFToken",
|
"_saleorCSRFToken",
|
||||||
resp.body.data.tokenCreate.csrfToken,
|
resp.body.data.tokenCreate.csrfToken,
|
||||||
|
|
|
@ -27,6 +27,7 @@ cypressGrep();
|
||||||
Cypress.Commands.add("clearSessionData", () => {
|
Cypress.Commands.add("clearSessionData", () => {
|
||||||
cy.clearCookies();
|
cy.clearCookies();
|
||||||
cy.clearLocalStorage();
|
cy.clearLocalStorage();
|
||||||
|
window.sessionStorage.clear();
|
||||||
});
|
});
|
||||||
|
|
||||||
Cypress.Commands.add("addAliasToGraphRequest", operationName => {
|
Cypress.Commands.add("addAliasToGraphRequest", operationName => {
|
||||||
|
|
Loading…
Reference in a new issue