diff --git a/cypress/integration/checkout/clickAndCollect.js b/cypress/integration/checkout/clickAndCollect.js
new file mode 100644
index 000000000..e32f47fc0
--- /dev/null
+++ b/cypress/integration/checkout/clickAndCollect.js
@@ -0,0 +1,233 @@
+///
+///
+
+import faker from "faker";
+
+import { WAREHOUSES_DETAILS } from "../../elements/warehouses/warehouse-details";
+import {
+ completeCheckout,
+ createCheckout,
+ deliveryMethodUpdate
+} from "../../support/api/requests/Checkout";
+import { getOrder } from "../../support/api/requests/Order";
+import { updateWarehouse } from "../../support/api/requests/Warehouse";
+import { getDefaultChannel } from "../../support/api/utils/channelsUtils";
+import { addPayment } from "../../support/api/utils/ordersUtils";
+import {
+ createProductInChannel,
+ createTypeAttributeAndCategoryForProduct,
+ deleteProductsStartsWith
+} from "../../support/api/utils/products/productsUtils";
+import {
+ createShipping,
+ deleteShippingStartsWith
+} from "../../support/api/utils/shippingUtils";
+import filterTests from "../../support/filterTests";
+import {
+ createWarehouse,
+ pickupOptions,
+ visitAndEnablePickup,
+ visitSetPublicStockAndEnablePickup
+} from "../../support/pages/warehousePage";
+
+filterTests({ definedTags: ["all"], version: "3.1.0" }, () => {
+ describe("Warehouses in checkout", () => {
+ const startsWith = `CyWarehouseCheckout`;
+ let defaultChannel;
+ let usAddress;
+ let secondUsAddress;
+ let plAddress;
+ let productData;
+ let checkoutData;
+ let variantsInOtherWarehouse;
+
+ before(() => {
+ cy.clearSessionData().loginUserViaRequest();
+ deleteShippingStartsWith(startsWith);
+ deleteProductsStartsWith(startsWith);
+ cy.fixture("addresses")
+ .then(addresses => {
+ usAddress = addresses.usAddress;
+ secondUsAddress = addresses.secondUsAddress;
+ plAddress = addresses.plAddress;
+ getDefaultChannel();
+ })
+ .then(channelResp => {
+ defaultChannel = channelResp;
+ createTypeAttributeAndCategoryForProduct({ name: startsWith });
+ })
+ .then(({ attribute, productType, category }) => {
+ productData = {
+ attributeId: attribute.id,
+ categoryId: category.id,
+ channelId: defaultChannel.id,
+ productTypeId: productType.id,
+ quantityInWarehouse: 100
+ };
+ checkoutData = {
+ returnAvailableCollectionPoints: true,
+ channelSlug: defaultChannel.slug,
+ email: "example@example.com",
+ address: secondUsAddress
+ };
+ createShipping({
+ channelId: defaultChannel.id,
+ name: startsWith,
+ address: secondUsAddress
+ });
+ })
+ .then(({ warehouse: warehouseResp }) => {
+ productData.name = startsWith;
+ productData.warehouseId = warehouseResp.id;
+ updateWarehouse({ id: productData.warehouseId, isPrivate: false });
+ createProductInChannel(productData);
+ })
+ .then(({ variantsList }) => {
+ variantsInOtherWarehouse = variantsList;
+ });
+ });
+
+ beforeEach(() => {
+ cy.clearSessionData().loginUserViaRequest();
+ });
+
+ it("should create warehouse with all warehouses pickup and private stock", () => {
+ const name = `${startsWith}${faker.datatype.number()}`;
+ let warehouse;
+
+ createShipping({
+ channelId: defaultChannel.id,
+ name,
+ address: secondUsAddress
+ })
+ .then(({ warehouse: warehouseResp }) => {
+ warehouse = warehouseResp;
+ visitAndEnablePickup(warehouse.id);
+ productData.name = name;
+ productData.warehouseId = warehouse.id;
+ createProductInChannel(productData);
+ })
+ .then(({ variantsList }) => {
+ checkoutData.variantsList = variantsList.concat(
+ variantsInOtherWarehouse
+ );
+ createCheckout(checkoutData);
+ })
+ .then(({ checkout }) => {
+ const clickAndCollectOption = checkout.availableCollectionPoints.find(
+ element => element.id === warehouse.id
+ );
+ expect(clickAndCollectOption.clickAndCollectOption).to.eq("ALL");
+ expect(clickAndCollectOption.id).to.eq(warehouse.id);
+ expect(clickAndCollectOption.isPrivate).to.eq(true);
+ expect(clickAndCollectOption.name).to.eq(warehouse.name);
+ });
+ });
+
+ it("should create warehouse with all warehouses pickup and public stock", () => {
+ const name = `${startsWith}${faker.datatype.number()}`;
+ let warehouse;
+
+ createShipping({
+ channelId: defaultChannel.id,
+ name,
+ address: secondUsAddress
+ })
+ .then(({ warehouse: warehouseResp }) => {
+ warehouse = warehouseResp;
+ visitSetPublicStockAndEnablePickup(warehouse.id);
+ productData.name = name;
+ productData.warehouseId = warehouse.id;
+ createProductInChannel(productData);
+ })
+ .then(({ variantsList }) => {
+ checkoutData.variantsList = variantsList.concat(
+ variantsInOtherWarehouse
+ );
+ createCheckout(checkoutData);
+ })
+ .then(({ checkout }) => {
+ const clickAndCollectOption = checkout.availableCollectionPoints.find(
+ element => element.id === warehouse.id
+ );
+ expect(clickAndCollectOption.clickAndCollectOption).to.eq("ALL");
+ expect(clickAndCollectOption.id).to.eq(warehouse.id);
+ expect(clickAndCollectOption.isPrivate).to.eq(false);
+ expect(clickAndCollectOption.name).to.eq(warehouse.name);
+ });
+ });
+
+ it("should create warehouse with local stock only pickup and public stock", () => {
+ const name = `${startsWith}${faker.datatype.number()}`;
+ let warehouse;
+ let variantsInLocalStock;
+
+ createShipping({
+ channelId: defaultChannel.id,
+ name,
+ address: secondUsAddress
+ })
+ .then(({ warehouse: warehouseResp }) => {
+ warehouse = warehouseResp;
+ visitSetPublicStockAndEnablePickup(warehouse.id, pickupOptions.local);
+ productData.name = name;
+ productData.warehouseId = warehouse.id;
+ createProductInChannel(productData);
+ })
+ .then(({ variantsList }) => {
+ variantsInLocalStock = variantsList;
+ checkoutData.variantsList = variantsInLocalStock.concat(
+ variantsInOtherWarehouse
+ );
+ createCheckout(checkoutData);
+ })
+ .then(({ checkout }) => {
+ expect(checkout.availableCollectionPoints).to.have.length(
+ 1,
+ "there should be no available collection point for local stock"
+ );
+ checkoutData.variantsList = variantsInLocalStock;
+ createCheckout(checkoutData);
+ })
+ .then(({ checkout }) => {
+ const clickAndCollectOption = checkout.availableCollectionPoints[0];
+ expect(clickAndCollectOption.clickAndCollectOption).to.eq("LOCAL");
+ expect(clickAndCollectOption.id).to.eq(warehouse.id);
+ expect(clickAndCollectOption.isPrivate).to.eq(false);
+ expect(clickAndCollectOption.name).to.eq(warehouse.name);
+ });
+ });
+
+ it("should not be possible to set local pickup when private stock", () => {
+ const name = `${startsWith}${faker.datatype.number()}`;
+ createWarehouse({ name, address: usAddress });
+ cy.get(WAREHOUSES_DETAILS.clickAndCollectLocalStockRadioButton).should(
+ "not.exist"
+ );
+ });
+
+ it("should create order with warehouse address", () => {
+ let checkout;
+ checkoutData.variantsList = variantsInOtherWarehouse;
+ createCheckout(checkoutData)
+ .then(({ checkout: checkoutResp }) => {
+ checkout = checkoutResp;
+ const clickAndCollectOption = checkout.availableCollectionPoints[0];
+ deliveryMethodUpdate(clickAndCollectOption.id, checkout.token);
+ })
+ .then(() => {
+ addPayment(checkout.id);
+ })
+ .then(() => {
+ completeCheckout(checkout.id);
+ })
+ .then(({ order }) => {
+ getOrder(order.id);
+ })
+ .then(order => {
+ cy.expectCorrectBasicAddress(order.shippingAddress, secondUsAddress);
+ cy.expectCorrectBasicAddress(order.billingAddress, usAddress);
+ });
+ });
+ });
+});
diff --git a/cypress/integration/checkout/warehouses.js b/cypress/integration/checkout/warehouses.js
index 8e2bcb7d3..f6a89ae20 100644
--- a/cypress/integration/checkout/warehouses.js
+++ b/cypress/integration/checkout/warehouses.js
@@ -3,16 +3,8 @@
import faker from "faker";
-import { WAREHOUSES_DETAILS } from "../../elements/warehouses/warehouse-details";
-import {
- completeCheckout,
- createCheckout,
- deliveryMethodUpdate
-} from "../../support/api/requests/Checkout";
-import { getOrder } from "../../support/api/requests/Order";
-import { updateWarehouse } from "../../support/api/requests/Warehouse";
+import { createCheckout } from "../../support/api/requests/Checkout";
import { getDefaultChannel } from "../../support/api/utils/channelsUtils";
-import { addPayment } from "../../support/api/utils/ordersUtils";
import {
createProductInChannel,
createTypeAttributeAndCategoryForProduct,
@@ -23,232 +15,56 @@ import {
deleteShippingStartsWith
} from "../../support/api/utils/shippingUtils";
import filterTests from "../../support/filterTests";
-import {
- createWarehouse,
- pickupOptions,
- visitAndEnablePickup,
- visitSetPublicStockAndEnablePickup
-} from "../../support/pages/warehousePage";
filterTests({ definedTags: ["all"] }, () => {
describe("Warehouses in checkout", () => {
const startsWith = `CyWarehouseCheckout`;
let defaultChannel;
let usAddress;
- let secondUsAddress;
let plAddress;
- let productData;
- let checkoutData;
- let variantsInOtherWarehouse;
+ let warehouse;
- before(() => {
+ it("should not be possible to buy product for country not listed in warehouse", () => {
cy.clearSessionData().loginUserViaRequest();
deleteShippingStartsWith(startsWith);
deleteProductsStartsWith(startsWith);
+ const name = `${startsWith}${faker.datatype.number()}`;
cy.fixture("addresses")
.then(addresses => {
usAddress = addresses.usAddress;
- secondUsAddress = addresses.secondUsAddress;
plAddress = addresses.plAddress;
getDefaultChannel();
})
.then(channelResp => {
defaultChannel = channelResp;
- createTypeAttributeAndCategoryForProduct({ name: startsWith });
+ createShipping({
+ channelId: defaultChannel.id,
+ name,
+ address: usAddress
+ });
+ })
+ .then(({ warehouse: warehouseResp }) => {
+ warehouse = warehouseResp;
+ createTypeAttributeAndCategoryForProduct({ name });
})
.then(({ attribute, productType, category }) => {
- productData = {
+ createProductInChannel({
+ name,
attributeId: attribute.id,
categoryId: category.id,
channelId: defaultChannel.id,
productTypeId: productType.id,
+ warehouseId: warehouse.id,
quantityInWarehouse: 100
- };
- checkoutData = {
- returnAvailableCollectionPoints: true,
- channelSlug: defaultChannel.slug,
- email: "example@example.com",
- address: secondUsAddress
- };
- createShipping({
- channelId: defaultChannel.id,
- name: startsWith,
- address: secondUsAddress
});
})
- .then(({ warehouse: warehouseResp }) => {
- productData.name = startsWith;
- productData.warehouseId = warehouseResp.id;
- updateWarehouse({ id: productData.warehouseId, isPrivate: false });
- createProductInChannel(productData);
- })
.then(({ variantsList }) => {
- variantsInOtherWarehouse = variantsList;
- });
- });
-
- beforeEach(() => {
- cy.clearSessionData().loginUserViaRequest();
- });
-
- it("should create warehouse with all warehouses pickup and private stock", () => {
- const name = `${startsWith}${faker.datatype.number()}`;
- let warehouse;
-
- createShipping({
- channelId: defaultChannel.id,
- name,
- address: secondUsAddress
- })
- .then(({ warehouse: warehouseResp }) => {
- warehouse = warehouseResp;
- visitAndEnablePickup(warehouse.id);
- productData.name = name;
- productData.warehouseId = warehouse.id;
- createProductInChannel(productData);
- })
- .then(({ variantsList }) => {
- checkoutData.variantsList = variantsList.concat(
- variantsInOtherWarehouse
- );
- createCheckout(checkoutData);
- })
- .then(({ checkout }) => {
- const clickAndCollectOption = checkout.availableCollectionPoints.find(
- element => element.id === warehouse.id
- );
- expect(clickAndCollectOption.clickAndCollectOption).to.eq("ALL");
- expect(clickAndCollectOption.id).to.eq(warehouse.id);
- expect(clickAndCollectOption.isPrivate).to.eq(true);
- expect(clickAndCollectOption.name).to.eq(warehouse.name);
- });
- });
-
- it("should create warehouse with all warehouses pickup and public stock", () => {
- const name = `${startsWith}${faker.datatype.number()}`;
- let warehouse;
-
- createShipping({
- channelId: defaultChannel.id,
- name,
- address: secondUsAddress
- })
- .then(({ warehouse: warehouseResp }) => {
- warehouse = warehouseResp;
- visitSetPublicStockAndEnablePickup(warehouse.id);
- productData.name = name;
- productData.warehouseId = warehouse.id;
- createProductInChannel(productData);
- })
- .then(({ variantsList }) => {
- checkoutData.variantsList = variantsList.concat(
- variantsInOtherWarehouse
- );
- createCheckout(checkoutData);
- })
- .then(({ checkout }) => {
- const clickAndCollectOption = checkout.availableCollectionPoints.find(
- element => element.id === warehouse.id
- );
- expect(clickAndCollectOption.clickAndCollectOption).to.eq("ALL");
- expect(clickAndCollectOption.id).to.eq(warehouse.id);
- expect(clickAndCollectOption.isPrivate).to.eq(false);
- expect(clickAndCollectOption.name).to.eq(warehouse.name);
- });
- });
-
- it("should create warehouse with local stock only pickup and public stock", () => {
- const name = `${startsWith}${faker.datatype.number()}`;
- let warehouse;
- let variantsInLocalStock;
-
- createShipping({
- channelId: defaultChannel.id,
- name,
- address: secondUsAddress
- })
- .then(({ warehouse: warehouseResp }) => {
- warehouse = warehouseResp;
- visitSetPublicStockAndEnablePickup(warehouse.id, pickupOptions.local);
- productData.name = name;
- productData.warehouseId = warehouse.id;
- createProductInChannel(productData);
- })
- .then(({ variantsList }) => {
- variantsInLocalStock = variantsList;
- checkoutData.variantsList = variantsInLocalStock.concat(
- variantsInOtherWarehouse
- );
- createCheckout(checkoutData);
- })
- .then(({ checkout }) => {
- expect(checkout.availableCollectionPoints).to.have.length(
- 1,
- "there should be no available collection point for local stock"
- );
- checkoutData.variantsList = variantsInLocalStock;
- createCheckout(checkoutData);
- })
- .then(({ checkout }) => {
- const clickAndCollectOption = checkout.availableCollectionPoints[0];
- expect(clickAndCollectOption.clickAndCollectOption).to.eq("LOCAL");
- expect(clickAndCollectOption.id).to.eq(warehouse.id);
- expect(clickAndCollectOption.isPrivate).to.eq(false);
- expect(clickAndCollectOption.name).to.eq(warehouse.name);
- });
- });
-
- it("should not be possible to set local pickup when private stock", () => {
- const name = `${startsWith}${faker.datatype.number()}`;
- createWarehouse({ name, address: usAddress });
- cy.get(WAREHOUSES_DETAILS.clickAndCollectLocalStockRadioButton).should(
- "not.exist"
- );
- });
-
- it("should create order with warehouse address", () => {
- const name = `${startsWith}${faker.datatype.number()}`;
- let checkout;
- checkoutData.variantsList = variantsInOtherWarehouse;
- createCheckout(checkoutData)
- .then(({ checkout: checkoutResp }) => {
- checkout = checkoutResp;
- const clickAndCollectOption = checkout.availableCollectionPoints[0];
- deliveryMethodUpdate(clickAndCollectOption.id, checkout.token);
- })
- .then(() => {
- addPayment(checkout.id);
- })
- .then(() => {
- completeCheckout(checkout.id);
- })
- .then(({ order }) => {
- getOrder(order.id);
- })
- .then(order => {
- cy.expectCorrectBasicAddress(order.shippingAddress, secondUsAddress);
- cy.expectCorrectBasicAddress(order.billingAddress, usAddress);
- });
- });
-
- it("should not be possible to buy product for country not listed in warehouse", () => {
- const name = `${startsWith}${faker.datatype.number()}`;
- let warehouse;
-
- createShipping({
- channelId: defaultChannel.id,
- name,
- address: plAddress
- })
- .then(({ warehouse: warehouseResp }) => {
- warehouse = warehouseResp;
- productData.name = name;
- productData.warehouseId = warehouse.id;
- createProductInChannel(productData);
- })
- .then(({ variantsList }) => {
- checkoutData.variantsList = variantsList;
- createCheckout(checkoutData);
+ createCheckout({
+ channelSlug: defaultChannel.slug,
+ email: "example@example.com",
+ variantsList,
+ address: plAddress
+ });
})
.then(({ errors }) => {
expect(errors[0]).to.have.property("field", "quantity");
diff --git a/cypress/integration/products/productsVariants.js b/cypress/integration/products/productsVariants.js
index 41dd15eb6..026420b97 100644
--- a/cypress/integration/products/productsVariants.js
+++ b/cypress/integration/products/productsVariants.js
@@ -58,7 +58,7 @@ filterTests({ definedTags: ["all", "critical"] }, () => {
)
.then(({ warehouse: warehouseResp }) => {
warehouse = warehouseResp;
- createChannel({ isActive: true, name, currencyCode: "PLN" });
+ createChannel({ isActive: true, name, currencyCode: "USD" });
})
.then(resp => (newChannel = resp));
diff --git a/cypress/integration/staffMembers.js b/cypress/integration/staffMembers.js
index 8002167cf..37164c436 100644
--- a/cypress/integration/staffMembers.js
+++ b/cypress/integration/staffMembers.js
@@ -81,7 +81,7 @@ filterTests({ definedTags: ["stagedOnly"] }, () => {
tokenCreate.errors[0].code,
"logging in should return error"
)
- .to.be.eq("INVALID_CREDENTIALS");
+ .to.be.eq("INACTIVE");
expect(tokenCreate.token).to.be.not.ok;
});
});
diff --git a/cypress/support/api/requests/ProductType.js b/cypress/support/api/requests/ProductType.js
index 009c8d43c..5432a0139 100644
--- a/cypress/support/api/requests/ProductType.js
+++ b/cypress/support/api/requests/ProductType.js
@@ -43,6 +43,23 @@ export function createTypeProduct({
.its("body.data.productTypeCreate.productType");
}
+export function productAttributeAssignmentUpdate({
+ productTypeId,
+ attributeId,
+ variantSelection = true
+}) {
+ const mutation = `mutation {
+ productAttributeAssignmentUpdate(
+ operations: {id: "${attributeId}", variantSelection: ${variantSelection}} productTypeId:"${productTypeId}") {
+ errors {
+ field
+ message
+ }
+ }
+ }`;
+ return cy.sendRequestWithQuery(mutation);
+}
+
export function getProductTypes(first, search) {
const query = `query{
productTypes(first:${first}, filter:{
diff --git a/cypress/support/api/utils/products/productsUtils.js b/cypress/support/api/utils/products/productsUtils.js
index a591a39b1..c9e1e205c 100644
--- a/cypress/support/api/utils/products/productsUtils.js
+++ b/cypress/support/api/utils/products/productsUtils.js
@@ -1,3 +1,4 @@
+import { returnValueDependsOnShopVersion } from "../../../formatData/dataDependingOnVersion";
import * as attributeRequest from "../../requests/Attribute";
import * as categoryRequest from "../../requests/Category";
import { createCollection } from "../../requests/Collections";
@@ -5,7 +6,8 @@ import * as productRequest from "../../requests/Product";
import {
createTypeProduct,
deleteProductType,
- getProductTypes
+ getProductTypes,
+ productAttributeAssignmentUpdate
} from "../../requests/ProductType";
import { deleteAttributesStartsWith } from "../attributes/attributeUtils";
import { deleteCollectionsStartsWith } from "../catalog/collectionsUtils";
@@ -85,6 +87,13 @@ export function createTypeAttributeAndCategoryForProduct({
})
.then(productTypeResp => {
productType = productTypeResp;
+ const updateAssign = returnValueDependsOnShopVersion("3.1", true, false);
+ if (updateAssign) {
+ productAttributeAssignmentUpdate({
+ productTypeId: productType.id,
+ attributeId: attribute.id
+ });
+ }
categoryRequest.createCategory(name);
})
.then(categoryResp => {
diff --git a/cypress/support/pages/catalog/products/VariantsPage.js b/cypress/support/pages/catalog/products/VariantsPage.js
index 3c57ac59e..4363f956e 100644
--- a/cypress/support/pages/catalog/products/VariantsPage.js
+++ b/cypress/support/pages/catalog/products/VariantsPage.js
@@ -62,9 +62,12 @@ export function createVariant({
cy.get(VARIANTS_SELECTORS.saveButton)
.click()
.get(BUTTON_SELECTORS.back)
- .click();
+ .click()
+ .addAliasToGraphRequest("ProductChannelListingUpdate");
selectChannelVariantInDetailsPage(channelName, attributeName);
- cy.get(BUTTON_SELECTORS.confirm).click();
+ cy.get(BUTTON_SELECTORS.confirm)
+ .click()
+ .waitForRequestAndCheckIfNoErrors("@ProductChannelListingUpdate");
cy.contains(PRODUCT_DETAILS.variantRow, attributeName)
.click()
.get(PRICE_LIST.priceInput)
diff --git a/cypress/support/pages/channelsPage.js b/cypress/support/pages/channelsPage.js
index 0e070d4b0..d7fb17964 100644
--- a/cypress/support/pages/channelsPage.js
+++ b/cypress/support/pages/channelsPage.js
@@ -99,7 +99,7 @@ export function selectChannelVariantInDetailsPage(channelName, attributeName) {
.click();
cy.get(SELECT_CHANNELS_TO_ASSIGN.selectChannelsForm)
.find(BUTTON_SELECTORS.submit)
- .click();
+ .click({ force: true });
}
export function enterHomePageAndChangeChannel(channelName) {