fixed all tests (#1253)
* fixed all tests * fix shipping weight tests * fix create product * delete users created in previous tests * merge
This commit is contained in:
parent
db5ad19827
commit
5e7dc8e2a5
22 changed files with 281 additions and 219 deletions
|
@ -33,6 +33,7 @@ export function createCheckout({
|
||||||
field
|
field
|
||||||
message
|
message
|
||||||
}
|
}
|
||||||
|
|
||||||
created
|
created
|
||||||
checkout{
|
checkout{
|
||||||
id
|
id
|
||||||
|
@ -56,6 +57,10 @@ export function addShippingMethod(checkoutId, shippingMethodId) {
|
||||||
field
|
field
|
||||||
}
|
}
|
||||||
checkout{
|
checkout{
|
||||||
|
shippingMethod{
|
||||||
|
id
|
||||||
|
name
|
||||||
|
}
|
||||||
totalPrice{
|
totalPrice{
|
||||||
gross{
|
gross{
|
||||||
amount
|
amount
|
||||||
|
|
|
@ -61,6 +61,7 @@ export function createShippingZone(name, country, channelId) {
|
||||||
.sendRequestWithQuery(mutation)
|
.sendRequestWithQuery(mutation)
|
||||||
.its("body.data.shippingZoneCreate.shippingZone");
|
.its("body.data.shippingZoneCreate.shippingZone");
|
||||||
}
|
}
|
||||||
|
|
||||||
export function addChannelToShippingZone(shippingZoneId, channelId) {
|
export function addChannelToShippingZone(shippingZoneId, channelId) {
|
||||||
const mutation = `mutation addCh{
|
const mutation = `mutation addCh{
|
||||||
shippingZoneUpdate(id:"${shippingZoneId}", input:{
|
shippingZoneUpdate(id:"${shippingZoneId}", input:{
|
||||||
|
@ -74,6 +75,7 @@ export function addChannelToShippingZone(shippingZoneId, channelId) {
|
||||||
}`;
|
}`;
|
||||||
return cy.sendRequestWithQuery(mutation);
|
return cy.sendRequestWithQuery(mutation);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function addChannelToShippingMethod(
|
export function addChannelToShippingMethod(
|
||||||
shippingRateId,
|
shippingRateId,
|
||||||
channelId,
|
channelId,
|
||||||
|
@ -138,8 +140,12 @@ export function getShippingZone(shippingZoneId) {
|
||||||
name
|
name
|
||||||
id
|
id
|
||||||
}
|
}
|
||||||
|
shippingMethods{
|
||||||
|
id
|
||||||
|
name
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} `;
|
}`;
|
||||||
return cy
|
return cy
|
||||||
.sendRequestWithQuery(query)
|
.sendRequestWithQuery(query)
|
||||||
.then(resp => resp.body.data.shippingZone);
|
.then(resp => resp.body.data.shippingZone);
|
||||||
|
|
|
@ -14,7 +14,10 @@ export function updateShopWeightUnit(weightUnit) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}`;
|
}`;
|
||||||
return cy.sendRequestWithQuery(mutation).its("body.data.shopSettingsUpdate");
|
return cy
|
||||||
|
.sendRequestWithQuery(mutation)
|
||||||
|
.wait(1000)
|
||||||
|
.its("body.data.shopSettingsUpdate");
|
||||||
}
|
}
|
||||||
|
|
||||||
export function updateShopAddress(address) {
|
export function updateShopAddress(address) {
|
||||||
|
|
|
@ -5,6 +5,7 @@ export function getProductDetails(productId, channelId, auth = "token") {
|
||||||
auth === "auth",
|
auth === "auth",
|
||||||
`privateMetadata{key value}`
|
`privateMetadata{key value}`
|
||||||
);
|
);
|
||||||
|
|
||||||
const query = `fragment BasicProductFields on Product {
|
const query = `fragment BasicProductFields on Product {
|
||||||
id
|
id
|
||||||
name
|
name
|
||||||
|
@ -49,6 +50,10 @@ export function getProductDetails(productId, channelId, auth = "token") {
|
||||||
id
|
id
|
||||||
sku
|
sku
|
||||||
name
|
name
|
||||||
|
weight{
|
||||||
|
unit
|
||||||
|
value
|
||||||
|
}
|
||||||
pricing {
|
pricing {
|
||||||
price {
|
price {
|
||||||
...Price
|
...Price
|
||||||
|
|
|
@ -6,7 +6,7 @@ import { APP_DETAILS } from "../elements/apps/appDetails";
|
||||||
import { APPS_LIST } from "../elements/apps/appsList";
|
import { APPS_LIST } from "../elements/apps/appsList";
|
||||||
import { WEBHOOK_DETAILS } from "../elements/apps/webhookDetails";
|
import { WEBHOOK_DETAILS } from "../elements/apps/webhookDetails";
|
||||||
import { BUTTON_SELECTORS } from "../elements/shared/button-selectors";
|
import { BUTTON_SELECTORS } from "../elements/shared/button-selectors";
|
||||||
import { confirmationMessageShouldDisappear } from "../steps/shared/confirmationMessage";
|
import { confirmationMessageShouldDisappear } from "../steps/shared/confirmationMessages";
|
||||||
import filterTests from "../support/filterTests";
|
import filterTests from "../support/filterTests";
|
||||||
import { appDetailsUrl, urlList } from "../url/urlList";
|
import { appDetailsUrl, urlList } from "../url/urlList";
|
||||||
import { deleteAppsStartsWith } from "../utils/appUtils";
|
import { deleteAppsStartsWith } from "../utils/appUtils";
|
||||||
|
|
|
@ -7,7 +7,7 @@ import { CUSTOMERS_LIST } from "../../elements/customer/customers-list";
|
||||||
import { BUTTON_SELECTORS } from "../../elements/shared/button-selectors";
|
import { BUTTON_SELECTORS } from "../../elements/shared/button-selectors";
|
||||||
import { SHARED_ELEMENTS } from "../../elements/shared/sharedElements";
|
import { SHARED_ELEMENTS } from "../../elements/shared/sharedElements";
|
||||||
import { fillUpAddressForm } from "../../steps/shared/addressForm";
|
import { fillUpAddressForm } from "../../steps/shared/addressForm";
|
||||||
import { confirmationMessageShouldDisappear } from "../../steps/shared/confirmationMessage";
|
import { confirmationMessageShouldDisappear } from "../../steps/shared/confirmationMessages";
|
||||||
import filterTests from "../../support/filterTests";
|
import filterTests from "../../support/filterTests";
|
||||||
import { urlList } from "../../url/urlList";
|
import { urlList } from "../../url/urlList";
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ import {
|
||||||
import { PRODUCT_TYPE_DETAILS } from "../../elements/productTypes/productTypeDetails";
|
import { PRODUCT_TYPE_DETAILS } from "../../elements/productTypes/productTypeDetails";
|
||||||
import { createProductType } from "../../steps/productTypeSteps";
|
import { createProductType } from "../../steps/productTypeSteps";
|
||||||
import { assignElements } from "../../steps/shared/assignElements";
|
import { assignElements } from "../../steps/shared/assignElements";
|
||||||
import { confirmationMessageShouldDisappear } from "../../steps/shared/confirmationMessage";
|
import { confirmationMessageShouldDisappear } from "../../steps/shared/confirmationMessages";
|
||||||
import { visitAndWaitForProgressBarToDisappear } from "../../steps/shared/progressBar";
|
import { visitAndWaitForProgressBarToDisappear } from "../../steps/shared/progressBar";
|
||||||
import filterTests from "../../support/filterTests";
|
import filterTests from "../../support/filterTests";
|
||||||
import { productTypeDetailsUrl, urlList } from "../../url/urlList";
|
import { productTypeDetailsUrl, urlList } from "../../url/urlList";
|
||||||
|
|
|
@ -1,190 +0,0 @@
|
||||||
// <reference types="cypress" />
|
|
||||||
import faker from "faker";
|
|
||||||
|
|
||||||
import { createCheckout } from "../../../apiRequests/Checkout";
|
|
||||||
import {
|
|
||||||
createShippingRate as createShippingRateViaApi,
|
|
||||||
createShippingZone
|
|
||||||
} from "../../../apiRequests/ShippingMethod";
|
|
||||||
import { updateShopWeightUnit } from "../../../apiRequests/shopSettings";
|
|
||||||
import { createWarehouse } from "../../../apiRequests/Warehouse";
|
|
||||||
import { ONE_PERMISSION_USERS } from "../../../Data/users";
|
|
||||||
import { SHARED_ELEMENTS } from "../../../elements/shared/sharedElements";
|
|
||||||
import { SHIPPING_RATE_DETAILS } from "../../../elements/shipping/shipping-rate-details";
|
|
||||||
import {
|
|
||||||
changeWeightUnit,
|
|
||||||
createShippingRate,
|
|
||||||
rateOptions
|
|
||||||
} from "../../../steps/shippingMethodSteps";
|
|
||||||
import filterTests from "../../../support/filterTests";
|
|
||||||
import {
|
|
||||||
shippingZoneDetailsUrl,
|
|
||||||
urlList,
|
|
||||||
weightRateUrl
|
|
||||||
} from "../../../url/urlList";
|
|
||||||
import { getDefaultChannel } from "../../../utils/channelsUtils";
|
|
||||||
import {
|
|
||||||
createProductInChannel,
|
|
||||||
createTypeAttributeAndCategoryForProduct,
|
|
||||||
deleteProductsStartsWith
|
|
||||||
} from "../../../utils/products/productsUtils";
|
|
||||||
import { deleteShippingStartsWith } from "../../../utils/shippingUtils";
|
|
||||||
import { isShippingAvailableInCheckout } from "../../../utils/storeFront/checkoutUtils";
|
|
||||||
|
|
||||||
filterTests(["all"], () => {
|
|
||||||
describe("Shipping weight limits", () => {
|
|
||||||
const startsWith = "CyWeightRates-";
|
|
||||||
const name = `${startsWith}${faker.datatype.number()}`;
|
|
||||||
|
|
||||||
const price = 10;
|
|
||||||
|
|
||||||
let defaultChannel;
|
|
||||||
let usAddress;
|
|
||||||
let shippingZone;
|
|
||||||
let warehouse;
|
|
||||||
let variantsList;
|
|
||||||
|
|
||||||
before(() => {
|
|
||||||
cy.clearSessionData().loginUserViaRequest();
|
|
||||||
deleteShippingStartsWith(startsWith);
|
|
||||||
deleteProductsStartsWith(startsWith);
|
|
||||||
|
|
||||||
updateShopWeightUnit("KG");
|
|
||||||
getDefaultChannel()
|
|
||||||
.then(channel => {
|
|
||||||
defaultChannel = channel;
|
|
||||||
cy.fixture("addresses");
|
|
||||||
})
|
|
||||||
.then(({ usAddress: usAddressResp }) => {
|
|
||||||
usAddress = usAddressResp;
|
|
||||||
createShippingZone(name, "US", defaultChannel.id);
|
|
||||||
})
|
|
||||||
.then(shippingZoneResp => {
|
|
||||||
shippingZone = shippingZoneResp;
|
|
||||||
createWarehouse({
|
|
||||||
name,
|
|
||||||
shippingZone: shippingZone.id,
|
|
||||||
address: usAddress
|
|
||||||
});
|
|
||||||
})
|
|
||||||
.then(warehouseResp => {
|
|
||||||
warehouse = warehouseResp;
|
|
||||||
createTypeAttributeAndCategoryForProduct(name);
|
|
||||||
})
|
|
||||||
.then(({ attribute, productType, category }) => {
|
|
||||||
createProductInChannel({
|
|
||||||
name,
|
|
||||||
channelId: defaultChannel.id,
|
|
||||||
warehouseId: warehouse.id,
|
|
||||||
attributeId: attribute.id,
|
|
||||||
categoryId: category.id,
|
|
||||||
productTypeId: productType.id,
|
|
||||||
weight: 10
|
|
||||||
});
|
|
||||||
})
|
|
||||||
.then(({ variantsList: variantsListResp }) => {
|
|
||||||
variantsList = variantsListResp;
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
cy.clearSessionData()
|
|
||||||
.loginUserViaRequest("auth", ONE_PERMISSION_USERS.shipping)
|
|
||||||
.visit(shippingZoneDetailsUrl(shippingZone.id));
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should be possible to buy product in a shipping weight limits", () => {
|
|
||||||
const rateName = `${startsWith}${faker.datatype.number()}`;
|
|
||||||
createShippingRate({
|
|
||||||
rateName,
|
|
||||||
price,
|
|
||||||
rateOption: rateOptions.WEIGHT_OPTION,
|
|
||||||
weightLimits: {
|
|
||||||
max: 11,
|
|
||||||
min: 10
|
|
||||||
}
|
|
||||||
});
|
|
||||||
createCheckout({
|
|
||||||
address: usAddress,
|
|
||||||
channelSlug: defaultChannel.slug,
|
|
||||||
email: "example@example.com",
|
|
||||||
variantsList
|
|
||||||
}).then(({ checkout }) => {
|
|
||||||
expect(isShippingAvailableInCheckout(checkout, rateName)).to.be.true;
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should not be possible to buy product not in a shipping weight limits", () => {
|
|
||||||
const rateName = `${startsWith}${faker.datatype.number()}`;
|
|
||||||
createShippingRate({
|
|
||||||
rateName,
|
|
||||||
price,
|
|
||||||
rateOption: rateOptions.WEIGHT_OPTION,
|
|
||||||
weightLimits: {
|
|
||||||
max: 101,
|
|
||||||
min: 100
|
|
||||||
}
|
|
||||||
});
|
|
||||||
createCheckout({
|
|
||||||
address: usAddress,
|
|
||||||
channelSlug: defaultChannel.slug,
|
|
||||||
email: "example@example.com",
|
|
||||||
variantsList
|
|
||||||
}).then(({ checkout }) => {
|
|
||||||
expect(isShippingAvailableInCheckout(checkout, rateName)).to.be.false;
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
// Log in as user with shipping permissions after resolving SALEOR-3407 bug
|
|
||||||
it("should recalculate weight after changing shipping weight unit", () => {
|
|
||||||
const rateName = `${startsWith}${faker.datatype.number()}`;
|
|
||||||
const minWeightInKg = 1;
|
|
||||||
const maxWeightInKg = 10;
|
|
||||||
const minWeightInG = minWeightInKg * 1000;
|
|
||||||
const maxWeightInG = maxWeightInKg * 1000;
|
|
||||||
let shippingMethod;
|
|
||||||
|
|
||||||
cy.clearSessionData().loginUserViaRequest();
|
|
||||||
|
|
||||||
createShippingRateViaApi({
|
|
||||||
name: rateName,
|
|
||||||
shippingZone: shippingZone.id,
|
|
||||||
type: "WEIGHT",
|
|
||||||
maxWeight: maxWeightInKg,
|
|
||||||
minWeight: minWeightInKg
|
|
||||||
})
|
|
||||||
.then(({ shippingMethod: shippingMethodResp }) => {
|
|
||||||
shippingMethod = shippingMethodResp;
|
|
||||||
cy.visit(urlList.shippingMethods)
|
|
||||||
.get(SHARED_ELEMENTS.progressBar)
|
|
||||||
.should("not.exist");
|
|
||||||
changeWeightUnit("G");
|
|
||||||
|
|
||||||
cy.addAliasToGraphRequest("ShippingZone");
|
|
||||||
cy.visit(weightRateUrl(shippingZone.id, shippingMethod.id))
|
|
||||||
.wait("@ShippingZone")
|
|
||||||
.its("response.body");
|
|
||||||
})
|
|
||||||
.then(responseArray => {
|
|
||||||
const shippingMethods = responseArray.find(
|
|
||||||
element => element.data.shippingZone
|
|
||||||
).data.shippingZone.shippingMethods;
|
|
||||||
const rate = shippingMethods.find(
|
|
||||||
element => element.id === shippingMethod.id
|
|
||||||
);
|
|
||||||
expect(rate.minimumOrderWeight.unit).to.eq("G");
|
|
||||||
cy.get(SHARED_ELEMENTS.progressBar)
|
|
||||||
.should("not.be.visible")
|
|
||||||
.get(SHIPPING_RATE_DETAILS.minWeightInput)
|
|
||||||
.invoke("val");
|
|
||||||
})
|
|
||||||
.then(actualMinWeight => {
|
|
||||||
expect(parseInt(actualMinWeight, 10)).to.eq(minWeightInG);
|
|
||||||
cy.get(SHIPPING_RATE_DETAILS.maxWeightInput).invoke("val");
|
|
||||||
})
|
|
||||||
.then(actualMaxWeight => {
|
|
||||||
expect(parseInt(actualMaxWeight, 10)).to.eq(maxWeightInG);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -0,0 +1,134 @@
|
||||||
|
// <reference types="cypress" />
|
||||||
|
import faker from "faker";
|
||||||
|
|
||||||
|
import { createCheckout } from "../../../../apiRequests/Checkout";
|
||||||
|
import { createShippingZone } from "../../../../apiRequests/ShippingMethod";
|
||||||
|
import { createWarehouse } from "../../../../apiRequests/Warehouse";
|
||||||
|
import { ONE_PERMISSION_USERS } from "../../../../Data/users";
|
||||||
|
import {
|
||||||
|
createShippingRate,
|
||||||
|
rateOptions
|
||||||
|
} from "../../../../steps/shippingMethodSteps";
|
||||||
|
import filterTests from "../../../../support/filterTests";
|
||||||
|
import { shippingZoneDetailsUrl } from "../../../../url/urlList";
|
||||||
|
import { getDefaultChannel } from "../../../../utils/channelsUtils";
|
||||||
|
import {
|
||||||
|
createProductInChannel,
|
||||||
|
createTypeAttributeAndCategoryForProduct,
|
||||||
|
deleteProductsStartsWith
|
||||||
|
} from "../../../../utils/products/productsUtils";
|
||||||
|
import { deleteShippingStartsWith } from "../../../../utils/shippingUtils";
|
||||||
|
import { isShippingAvailableInCheckout } from "../../../../utils/storeFront/checkoutUtils";
|
||||||
|
|
||||||
|
filterTests(["all"], () => {
|
||||||
|
describe("Shipping weight limits", () => {
|
||||||
|
const startsWith = "CyWeightRates-";
|
||||||
|
const name = `${startsWith}${faker.datatype.number()}`;
|
||||||
|
|
||||||
|
const price = 10;
|
||||||
|
|
||||||
|
let defaultChannel;
|
||||||
|
let usAddress;
|
||||||
|
let shippingZone;
|
||||||
|
let warehouse;
|
||||||
|
let variantsList;
|
||||||
|
|
||||||
|
before(() => {
|
||||||
|
cy.clearSessionData().loginUserViaRequest();
|
||||||
|
deleteShippingStartsWith(startsWith);
|
||||||
|
deleteProductsStartsWith(startsWith);
|
||||||
|
|
||||||
|
getDefaultChannel()
|
||||||
|
.then(channel => {
|
||||||
|
defaultChannel = channel;
|
||||||
|
cy.fixture("addresses");
|
||||||
|
})
|
||||||
|
.then(({ usAddress: usAddressResp }) => {
|
||||||
|
usAddress = usAddressResp;
|
||||||
|
createShippingZone(name, "US", defaultChannel.id);
|
||||||
|
})
|
||||||
|
.then(shippingZoneResp => {
|
||||||
|
shippingZone = shippingZoneResp;
|
||||||
|
createWarehouse({
|
||||||
|
name,
|
||||||
|
shippingZone: shippingZone.id,
|
||||||
|
address: usAddress
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.then(warehouseResp => {
|
||||||
|
warehouse = warehouseResp;
|
||||||
|
createTypeAttributeAndCategoryForProduct(name);
|
||||||
|
})
|
||||||
|
.then(({ attribute, productType, category }) => {
|
||||||
|
createProductInChannel({
|
||||||
|
name,
|
||||||
|
channelId: defaultChannel.id,
|
||||||
|
warehouseId: warehouse.id,
|
||||||
|
attributeId: attribute.id,
|
||||||
|
categoryId: category.id,
|
||||||
|
productTypeId: productType.id,
|
||||||
|
weight: 10
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.then(({ variantsList: variantsListResp }) => {
|
||||||
|
variantsList = variantsListResp;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
cy.clearSessionData()
|
||||||
|
.loginUserViaRequest("auth", ONE_PERMISSION_USERS.shipping)
|
||||||
|
.visit(shippingZoneDetailsUrl(shippingZone.id));
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should be possible to buy product in a shipping weight limits", () => {
|
||||||
|
const rateName = `${startsWith}${faker.datatype.number()}`;
|
||||||
|
|
||||||
|
createShippingRate({
|
||||||
|
rateName,
|
||||||
|
price,
|
||||||
|
rateOption: rateOptions.WEIGHT_OPTION,
|
||||||
|
weightLimits: {
|
||||||
|
max: 11,
|
||||||
|
min: 10
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
createCheckout({
|
||||||
|
address: usAddress,
|
||||||
|
channelSlug: defaultChannel.slug,
|
||||||
|
email: "example@example.com",
|
||||||
|
variantsList
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.then(({ checkout }) => {
|
||||||
|
expect(isShippingAvailableInCheckout(checkout, rateName)).to.be.true;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should not be possible to buy product not in a shipping weight limits", () => {
|
||||||
|
const rateName = `${startsWith}${faker.datatype.number()}`;
|
||||||
|
|
||||||
|
createShippingRate({
|
||||||
|
rateName,
|
||||||
|
price,
|
||||||
|
rateOption: rateOptions.WEIGHT_OPTION,
|
||||||
|
weightLimits: {
|
||||||
|
max: 101,
|
||||||
|
min: 100
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
createCheckout({
|
||||||
|
address: usAddress,
|
||||||
|
channelSlug: defaultChannel.slug,
|
||||||
|
email: "example@example.com",
|
||||||
|
variantsList
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.then(({ checkout }) => {
|
||||||
|
expect(isShippingAvailableInCheckout(checkout, rateName)).to.be.false;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
|
@ -0,0 +1,99 @@
|
||||||
|
// <reference types="cypress" />
|
||||||
|
import faker from "faker";
|
||||||
|
|
||||||
|
import {
|
||||||
|
createShippingRate as createShippingRateViaApi,
|
||||||
|
createShippingZone
|
||||||
|
} from "../../../../apiRequests/ShippingMethod";
|
||||||
|
import { updateShopWeightUnit } from "../../../../apiRequests/shopSettings";
|
||||||
|
import { SHARED_ELEMENTS } from "../../../../elements/shared/sharedElements";
|
||||||
|
import { SHIPPING_RATE_DETAILS } from "../../../../elements/shipping/shipping-rate-details";
|
||||||
|
import { waitForProgressBarToNotBeVisible } from "../../../../steps/shared/progressBar";
|
||||||
|
import { changeWeightUnit } from "../../../../steps/shippingMethodSteps";
|
||||||
|
import filterTests from "../../../../support/filterTests";
|
||||||
|
import { urlList, weightRateUrl } from "../../../../url/urlList";
|
||||||
|
import { getDefaultChannel } from "../../../../utils/channelsUtils";
|
||||||
|
import { deleteProductsStartsWith } from "../../../../utils/products/productsUtils";
|
||||||
|
import { deleteShippingStartsWith } from "../../../../utils/shippingUtils";
|
||||||
|
|
||||||
|
filterTests(["all"], () => {
|
||||||
|
describe("Recalculate weights", () => {
|
||||||
|
const startsWith = "RecalculateWeight";
|
||||||
|
const name = `${startsWith}${faker.datatype.number()}`;
|
||||||
|
|
||||||
|
let defaultChannel;
|
||||||
|
let usAddress;
|
||||||
|
let shippingZone;
|
||||||
|
|
||||||
|
before(() => {
|
||||||
|
cy.clearSessionData().loginUserViaRequest();
|
||||||
|
deleteShippingStartsWith(startsWith);
|
||||||
|
deleteProductsStartsWith(startsWith);
|
||||||
|
|
||||||
|
updateShopWeightUnit("KG")
|
||||||
|
.then(() => {
|
||||||
|
getDefaultChannel().then(channel => {
|
||||||
|
defaultChannel = channel;
|
||||||
|
cy.fixture("addresses");
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.then(({ usAddress: usAddressResp }) => {
|
||||||
|
usAddress = usAddressResp;
|
||||||
|
createShippingZone(name, "US", defaultChannel.id);
|
||||||
|
})
|
||||||
|
.then(shippingZoneResp => {
|
||||||
|
shippingZone = shippingZoneResp;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// Log in as user with shipping permissions after resolving SALEOR-3407 bug
|
||||||
|
it("should recalculate weight after changing shipping weight unit", () => {
|
||||||
|
const rateName = `${startsWith}${faker.datatype.number()}`;
|
||||||
|
const minWeightInKg = 1;
|
||||||
|
const maxWeightInKg = 10;
|
||||||
|
const minWeightInG = minWeightInKg * 1000;
|
||||||
|
const maxWeightInG = maxWeightInKg * 1000;
|
||||||
|
let shippingMethod;
|
||||||
|
|
||||||
|
cy.clearSessionData().loginUserViaRequest();
|
||||||
|
|
||||||
|
createShippingRateViaApi({
|
||||||
|
name: rateName,
|
||||||
|
shippingZone: shippingZone.id,
|
||||||
|
type: "WEIGHT",
|
||||||
|
maxWeight: maxWeightInKg,
|
||||||
|
minWeight: minWeightInKg
|
||||||
|
})
|
||||||
|
.then(({ shippingMethod: shippingMethodResp }) => {
|
||||||
|
shippingMethod = shippingMethodResp;
|
||||||
|
cy.visit(urlList.shippingMethods)
|
||||||
|
.get(SHARED_ELEMENTS.progressBar)
|
||||||
|
.should("not.exist");
|
||||||
|
changeWeightUnit("G");
|
||||||
|
|
||||||
|
cy.addAliasToGraphRequest("ShippingZone");
|
||||||
|
cy.visit(weightRateUrl(shippingZone.id, shippingMethod.id))
|
||||||
|
.wait("@ShippingZone")
|
||||||
|
.its("response.body");
|
||||||
|
})
|
||||||
|
.then(responseArray => {
|
||||||
|
const shippingMethods = responseArray.find(
|
||||||
|
element => element.data.shippingZone
|
||||||
|
).data.shippingZone.shippingMethods;
|
||||||
|
const rate = shippingMethods.find(
|
||||||
|
element => element.id === shippingMethod.id
|
||||||
|
);
|
||||||
|
waitForProgressBarToNotBeVisible();
|
||||||
|
expect(rate.minimumOrderWeight.unit).to.eq("G");
|
||||||
|
cy.get(SHIPPING_RATE_DETAILS.minWeightInput).invoke("val");
|
||||||
|
})
|
||||||
|
.then(actualMinWeight => {
|
||||||
|
expect(parseInt(actualMinWeight, 10)).to.eq(minWeightInG);
|
||||||
|
cy.get(SHIPPING_RATE_DETAILS.maxWeightInput).invoke("val");
|
||||||
|
})
|
||||||
|
.then(actualMaxWeight => {
|
||||||
|
expect(parseInt(actualMaxWeight, 10)).to.eq(maxWeightInG);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
|
@ -4,7 +4,7 @@ import { getShopInfo, updateShopAddress } from "../../apiRequests/shopSettings";
|
||||||
import { BUTTON_SELECTORS } from "../../elements/shared/button-selectors";
|
import { BUTTON_SELECTORS } from "../../elements/shared/button-selectors";
|
||||||
import { SITE_SETTINGS_DETAILS } from "../../elements/siteSettings/site-settings-details";
|
import { SITE_SETTINGS_DETAILS } from "../../elements/siteSettings/site-settings-details";
|
||||||
import { fillUpBasicAddress } from "../../steps/shared/addressForm";
|
import { fillUpBasicAddress } from "../../steps/shared/addressForm";
|
||||||
import { confirmationMessageShouldDisappear } from "../../steps/shared/confirmationMessage";
|
import { confirmationMessageShouldDisappear } from "../../steps/shared/confirmationMessages";
|
||||||
import filterTests from "../../support/filterTests";
|
import filterTests from "../../support/filterTests";
|
||||||
import { urlList } from "../../url/urlList";
|
import { urlList } from "../../url/urlList";
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,13 @@
|
||||||
import faker from "faker";
|
import faker from "faker";
|
||||||
|
|
||||||
import { confirmAccount, customerRegistration } from "../apiRequests/Customer";
|
import {
|
||||||
|
confirmAccount,
|
||||||
|
customerRegistration,
|
||||||
|
deleteCustomersStartsWith
|
||||||
|
} from "../apiRequests/Customer";
|
||||||
import { CUSTOMER_DETAILS } from "../elements/customers/customer-details";
|
import { CUSTOMER_DETAILS } from "../elements/customers/customer-details";
|
||||||
import { BUTTON_SELECTORS } from "../elements/shared/button-selectors";
|
import { BUTTON_SELECTORS } from "../elements/shared/button-selectors";
|
||||||
import { confirmationMessageShouldDisappear } from "../steps/shared/confirmationMessage";
|
import { confirmationMessageShouldDisappear } from "../steps/shared/confirmationMessages";
|
||||||
import filterTests from "../support/filterTests";
|
import filterTests from "../support/filterTests";
|
||||||
import { customerDetailsUrl } from "../url/urlList";
|
import { customerDetailsUrl } from "../url/urlList";
|
||||||
import { getDefaultChannel } from "../utils/channelsUtils";
|
import { getDefaultChannel } from "../utils/channelsUtils";
|
||||||
|
@ -17,6 +21,7 @@ describe("Tests for customer registration", () => {
|
||||||
|
|
||||||
before(() => {
|
before(() => {
|
||||||
cy.clearSessionData().loginUserViaRequest();
|
cy.clearSessionData().loginUserViaRequest();
|
||||||
|
deleteCustomersStartsWith(startsWith);
|
||||||
getDefaultChannel().then(channel => {
|
getDefaultChannel().then(channel => {
|
||||||
defaultChannel = channel;
|
defaultChannel = channel;
|
||||||
});
|
});
|
||||||
|
|
|
@ -7,7 +7,7 @@ import { PAGE_TYPES_LIST } from "../../elements/pageTypes/pageTypesList";
|
||||||
import { BUTTON_SELECTORS } from "../../elements/shared/button-selectors";
|
import { BUTTON_SELECTORS } from "../../elements/shared/button-selectors";
|
||||||
import { SHARED_ELEMENTS } from "../../elements/shared/sharedElements";
|
import { SHARED_ELEMENTS } from "../../elements/shared/sharedElements";
|
||||||
import { assignElements } from "../../steps/shared/assignElements";
|
import { assignElements } from "../../steps/shared/assignElements";
|
||||||
import { confirmationMessageShouldDisappear } from "../../steps/shared/confirmationMessage";
|
import { confirmationMessageShouldDisappear } from "../../steps/shared/confirmationMessages";
|
||||||
import filterTests from "../../support/filterTests";
|
import filterTests from "../../support/filterTests";
|
||||||
import { pageTypeDetailsUrl, urlList } from "../../url/urlList";
|
import { pageTypeDetailsUrl, urlList } from "../../url/urlList";
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ import {
|
||||||
} from "../../steps/catalog/products/priceList";
|
} from "../../steps/catalog/products/priceList";
|
||||||
import { fillUpCommonFieldsForAllProductTypes } from "../../steps/catalog/products/productSteps";
|
import { fillUpCommonFieldsForAllProductTypes } from "../../steps/catalog/products/productSteps";
|
||||||
import { selectChannelInDetailsPages } from "../../steps/channelsSteps";
|
import { selectChannelInDetailsPages } from "../../steps/channelsSteps";
|
||||||
import { confirmationMessageShouldDisappear } from "../../steps/shared/confirmationMessage";
|
import { confirmationMessageShouldDisappear } from "../../steps/shared/confirmationMessages";
|
||||||
import filterTests from "../../support/filterTests";
|
import filterTests from "../../support/filterTests";
|
||||||
import { urlList } from "../../url/urlList";
|
import { urlList } from "../../url/urlList";
|
||||||
import {
|
import {
|
||||||
|
|
|
@ -9,7 +9,7 @@ import { BUTTON_SELECTORS } from "../../elements/shared/button-selectors";
|
||||||
import { SHARED_ELEMENTS } from "../../elements/shared/sharedElements";
|
import { SHARED_ELEMENTS } from "../../elements/shared/sharedElements";
|
||||||
import { metadataForms } from "../../steps/catalog/metadataSteps";
|
import { metadataForms } from "../../steps/catalog/metadataSteps";
|
||||||
import { fillUpCommonFieldsForAllProductTypes } from "../../steps/catalog/products/productSteps";
|
import { fillUpCommonFieldsForAllProductTypes } from "../../steps/catalog/products/productSteps";
|
||||||
import { confirmationMessageShouldDisappear } from "../../steps/shared/confirmationMessage";
|
import { confirmationMessageShouldDisappear } from "../../steps/shared/confirmationMessages";
|
||||||
import filterTests from "../../support/filterTests";
|
import filterTests from "../../support/filterTests";
|
||||||
import { productDetailsUrl } from "../../url/urlList";
|
import { productDetailsUrl } from "../../url/urlList";
|
||||||
import { getDefaultChannel } from "../../utils/channelsUtils";
|
import { getDefaultChannel } from "../../utils/channelsUtils";
|
||||||
|
|
|
@ -3,8 +3,7 @@ import { AVAILABLE_CHANNELS_FORM } from "../elements/channels/available-channels
|
||||||
import { SELECT_CHANNELS_TO_ASSIGN } from "../elements/channels/select-channels-to-assign";
|
import { SELECT_CHANNELS_TO_ASSIGN } from "../elements/channels/select-channels-to-assign";
|
||||||
import { ASSIGN_ELEMENTS_SELECTORS } from "../elements/shared/assign-elements-selectors";
|
import { ASSIGN_ELEMENTS_SELECTORS } from "../elements/shared/assign-elements-selectors";
|
||||||
import { BUTTON_SELECTORS } from "../elements/shared/button-selectors";
|
import { BUTTON_SELECTORS } from "../elements/shared/button-selectors";
|
||||||
import { SHARED_ELEMENTS } from "../elements/shared/sharedElements";
|
import { confirmationMessageShouldDisappear } from "./shared/confirmationMessages";
|
||||||
import { confirmationMessageShouldDisappear } from "./shared/confirmationMessage";
|
|
||||||
|
|
||||||
export function createCollection(collectionName, isPublished, channel) {
|
export function createCollection(collectionName, isPublished, channel) {
|
||||||
const publishedSelector = isPublished
|
const publishedSelector = isPublished
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { ASSIGN_ELEMENTS_SELECTORS } from "../../elements/shared/assign-elements
|
||||||
import { BUTTON_SELECTORS } from "../../elements/shared/button-selectors";
|
import { BUTTON_SELECTORS } from "../../elements/shared/button-selectors";
|
||||||
import { formatDate } from "../../support/format/formatDate";
|
import { formatDate } from "../../support/format/formatDate";
|
||||||
import { selectChannelInDetailsPages } from "../channelsSteps";
|
import { selectChannelInDetailsPages } from "../channelsSteps";
|
||||||
import { confirmationMessageShouldDisappear } from "../shared/confirmationMessage";
|
import { confirmationMessageShouldDisappear } from "../shared/confirmationMessages";
|
||||||
import { waitForProgressBarToNotBeVisible } from "../shared/progressBar";
|
import { waitForProgressBarToNotBeVisible } from "../shared/progressBar";
|
||||||
|
|
||||||
export const discountOptions = {
|
export const discountOptions = {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { VOUCHERS_SELECTORS } from "../../elements/discounts/vouchers";
|
import { VOUCHERS_SELECTORS } from "../../elements/discounts/vouchers";
|
||||||
import { BUTTON_SELECTORS } from "../../elements/shared/button-selectors";
|
import { BUTTON_SELECTORS } from "../../elements/shared/button-selectors";
|
||||||
import { selectChannelInDetailsPages } from "../channelsSteps";
|
import { selectChannelInDetailsPages } from "../channelsSteps";
|
||||||
import { confirmationMessageShouldDisappear } from "../shared/confirmationMessage";
|
import { confirmationMessageShouldDisappear } from "../shared/confirmationMessages";
|
||||||
|
|
||||||
export const discountOptions = {
|
export const discountOptions = {
|
||||||
PERCENTAGE: VOUCHERS_SELECTORS.percentageDiscountRadioButton,
|
PERCENTAGE: VOUCHERS_SELECTORS.percentageDiscountRadioButton,
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { MENU_LIST } from "../elements/navigation/menu-list";
|
||||||
import { BUTTON_SELECTORS } from "../elements/shared/button-selectors";
|
import { BUTTON_SELECTORS } from "../elements/shared/button-selectors";
|
||||||
import { SHARED_ELEMENTS } from "../elements/shared/sharedElements";
|
import { SHARED_ELEMENTS } from "../elements/shared/sharedElements";
|
||||||
import { menuDetailsUrl, urlList } from "../url/urlList";
|
import { menuDetailsUrl, urlList } from "../url/urlList";
|
||||||
import { confirmationMessageShouldDisappear } from "./shared/confirmationMessage";
|
import { confirmationMessageShouldDisappear } from "./shared/confirmationMessages";
|
||||||
|
|
||||||
export function createMenu(name) {
|
export function createMenu(name) {
|
||||||
cy.visit(urlList.navigation)
|
cy.visit(urlList.navigation)
|
||||||
|
|
|
@ -1,8 +0,0 @@
|
||||||
import { SHARED_ELEMENTS } from "../../elements/shared/sharedElements";
|
|
||||||
|
|
||||||
export function confirmationMessageShouldDisappear() {
|
|
||||||
cy.get(SHARED_ELEMENTS.notificationSuccess)
|
|
||||||
.should("be.visible")
|
|
||||||
.get(SHARED_ELEMENTS.notificationSuccess)
|
|
||||||
.should("not.exist");
|
|
||||||
}
|
|
|
@ -3,7 +3,7 @@ import { SHARED_ELEMENTS } from "../elements/shared/sharedElements";
|
||||||
import { SHIPPING_RATE_DETAILS } from "../elements/shipping/shipping-rate-details";
|
import { SHIPPING_RATE_DETAILS } from "../elements/shipping/shipping-rate-details";
|
||||||
import { SHIPPING_ZONE_DETAILS } from "../elements/shipping/shipping-zone-details";
|
import { SHIPPING_ZONE_DETAILS } from "../elements/shipping/shipping-zone-details";
|
||||||
import { SHIPPING_ZONES_LIST } from "../elements/shipping/shipping-zones-list";
|
import { SHIPPING_ZONES_LIST } from "../elements/shipping/shipping-zones-list";
|
||||||
import { confirmationMessageShouldDisappear } from "./shared/confirmationMessage";
|
import { confirmationMessageShouldDisappear } from "./shared/confirmationMessages";
|
||||||
import { waitForProgressBarToNotBeVisible } from "./shared/progressBar";
|
import { waitForProgressBarToNotBeVisible } from "./shared/progressBar";
|
||||||
import { fillBaseSelect } from "./shared/selects";
|
import { fillBaseSelect } from "./shared/selects";
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ export function changeWeightUnit(weightUnit) {
|
||||||
cy.addAliasToGraphRequest("UpdateDefaultWeightUnit");
|
cy.addAliasToGraphRequest("UpdateDefaultWeightUnit");
|
||||||
cy.get(SHIPPING_ZONES_LIST.saveUnit).click();
|
cy.get(SHIPPING_ZONES_LIST.saveUnit).click();
|
||||||
confirmationMessageShouldDisappear();
|
confirmationMessageShouldDisappear();
|
||||||
cy.wait("@UpdateDefaultWeightUnit");
|
cy.wait("@UpdateDefaultWeightUnit").wait(1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function createShippingRate({
|
export function createShippingRate({
|
||||||
|
@ -75,7 +75,7 @@ export function createShippingRate({
|
||||||
weightLimits,
|
weightLimits,
|
||||||
deliveryTime
|
deliveryTime
|
||||||
});
|
});
|
||||||
saveRate();
|
return saveRate();
|
||||||
}
|
}
|
||||||
|
|
||||||
export function enterAndFillUpShippingRate({
|
export function enterAndFillUpShippingRate({
|
||||||
|
@ -121,7 +121,7 @@ export function createRateWithPostalCode({
|
||||||
.type(maxPostalCode)
|
.type(maxPostalCode)
|
||||||
.get(BUTTON_SELECTORS.submit)
|
.get(BUTTON_SELECTORS.submit)
|
||||||
.click();
|
.click();
|
||||||
saveRate();
|
return saveRate();
|
||||||
}
|
}
|
||||||
|
|
||||||
export function saveRate() {
|
export function saveRate() {
|
||||||
|
@ -130,7 +130,10 @@ export function saveRate() {
|
||||||
.get(BUTTON_SELECTORS.confirm)
|
.get(BUTTON_SELECTORS.confirm)
|
||||||
.click();
|
.click();
|
||||||
confirmationMessageShouldDisappear();
|
confirmationMessageShouldDisappear();
|
||||||
cy.wait(`@ShippingMethodChannelListingUpdate`).wait(`@ShippingZone`);
|
return cy
|
||||||
|
.wait(`@ShippingMethodChannelListingUpdate`)
|
||||||
|
.wait(`@ShippingZone`)
|
||||||
|
.its("response.body.0.data.shippingZone");
|
||||||
}
|
}
|
||||||
|
|
||||||
export function fillUpWeightLimits({ max, min }) {
|
export function fillUpWeightLimits({ max, min }) {
|
||||||
|
|
|
@ -28,6 +28,7 @@ export function getMailActivationLinkForUser(email, i = 0) {
|
||||||
}
|
}
|
||||||
return cy.mhGetMailsByRecipient(email).should(mails => {
|
return cy.mhGetMailsByRecipient(email).should(mails => {
|
||||||
if (!mails.length) {
|
if (!mails.length) {
|
||||||
|
cy.wait(10000);
|
||||||
getMailActivationLinkForUser(email, i + 1);
|
getMailActivationLinkForUser(email, i + 1);
|
||||||
} else {
|
} else {
|
||||||
cy.wrap(mails)
|
cy.wrap(mails)
|
||||||
|
|
Loading…
Reference in a new issue