Fix cypress tests (#1541)
* fix tests * fix base url * fix varinats tests
This commit is contained in:
parent
b0369bf5ca
commit
80809a078a
8 changed files with 290 additions and 212 deletions
233
cypress/integration/checkout/clickAndCollect.js
Normal file
233
cypress/integration/checkout/clickAndCollect.js
Normal file
|
@ -0,0 +1,233 @@
|
||||||
|
/// <reference types="cypress"/>
|
||||||
|
/// <reference types="../../support"/>
|
||||||
|
|
||||||
|
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);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
|
@ -3,16 +3,8 @@
|
||||||
|
|
||||||
import faker from "faker";
|
import faker from "faker";
|
||||||
|
|
||||||
import { WAREHOUSES_DETAILS } from "../../elements/warehouses/warehouse-details";
|
import { createCheckout } from "../../support/api/requests/Checkout";
|
||||||
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 { getDefaultChannel } from "../../support/api/utils/channelsUtils";
|
||||||
import { addPayment } from "../../support/api/utils/ordersUtils";
|
|
||||||
import {
|
import {
|
||||||
createProductInChannel,
|
createProductInChannel,
|
||||||
createTypeAttributeAndCategoryForProduct,
|
createTypeAttributeAndCategoryForProduct,
|
||||||
|
@ -23,232 +15,56 @@ import {
|
||||||
deleteShippingStartsWith
|
deleteShippingStartsWith
|
||||||
} from "../../support/api/utils/shippingUtils";
|
} from "../../support/api/utils/shippingUtils";
|
||||||
import filterTests from "../../support/filterTests";
|
import filterTests from "../../support/filterTests";
|
||||||
import {
|
|
||||||
createWarehouse,
|
|
||||||
pickupOptions,
|
|
||||||
visitAndEnablePickup,
|
|
||||||
visitSetPublicStockAndEnablePickup
|
|
||||||
} from "../../support/pages/warehousePage";
|
|
||||||
|
|
||||||
filterTests({ definedTags: ["all"] }, () => {
|
filterTests({ definedTags: ["all"] }, () => {
|
||||||
describe("Warehouses in checkout", () => {
|
describe("Warehouses in checkout", () => {
|
||||||
const startsWith = `CyWarehouseCheckout`;
|
const startsWith = `CyWarehouseCheckout`;
|
||||||
let defaultChannel;
|
let defaultChannel;
|
||||||
let usAddress;
|
let usAddress;
|
||||||
let secondUsAddress;
|
|
||||||
let plAddress;
|
let plAddress;
|
||||||
let productData;
|
let warehouse;
|
||||||
let checkoutData;
|
|
||||||
let variantsInOtherWarehouse;
|
|
||||||
|
|
||||||
before(() => {
|
it("should not be possible to buy product for country not listed in warehouse", () => {
|
||||||
cy.clearSessionData().loginUserViaRequest();
|
cy.clearSessionData().loginUserViaRequest();
|
||||||
deleteShippingStartsWith(startsWith);
|
deleteShippingStartsWith(startsWith);
|
||||||
deleteProductsStartsWith(startsWith);
|
deleteProductsStartsWith(startsWith);
|
||||||
|
const name = `${startsWith}${faker.datatype.number()}`;
|
||||||
cy.fixture("addresses")
|
cy.fixture("addresses")
|
||||||
.then(addresses => {
|
.then(addresses => {
|
||||||
usAddress = addresses.usAddress;
|
usAddress = addresses.usAddress;
|
||||||
secondUsAddress = addresses.secondUsAddress;
|
|
||||||
plAddress = addresses.plAddress;
|
plAddress = addresses.plAddress;
|
||||||
getDefaultChannel();
|
getDefaultChannel();
|
||||||
})
|
})
|
||||||
.then(channelResp => {
|
.then(channelResp => {
|
||||||
defaultChannel = channelResp;
|
defaultChannel = channelResp;
|
||||||
createTypeAttributeAndCategoryForProduct({ name: startsWith });
|
createShipping({
|
||||||
|
channelId: defaultChannel.id,
|
||||||
|
name,
|
||||||
|
address: usAddress
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.then(({ warehouse: warehouseResp }) => {
|
||||||
|
warehouse = warehouseResp;
|
||||||
|
createTypeAttributeAndCategoryForProduct({ name });
|
||||||
})
|
})
|
||||||
.then(({ attribute, productType, category }) => {
|
.then(({ attribute, productType, category }) => {
|
||||||
productData = {
|
createProductInChannel({
|
||||||
|
name,
|
||||||
attributeId: attribute.id,
|
attributeId: attribute.id,
|
||||||
categoryId: category.id,
|
categoryId: category.id,
|
||||||
channelId: defaultChannel.id,
|
channelId: defaultChannel.id,
|
||||||
productTypeId: productType.id,
|
productTypeId: productType.id,
|
||||||
|
warehouseId: warehouse.id,
|
||||||
quantityInWarehouse: 100
|
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 }) => {
|
.then(({ variantsList }) => {
|
||||||
variantsInOtherWarehouse = variantsList;
|
createCheckout({
|
||||||
});
|
channelSlug: defaultChannel.slug,
|
||||||
});
|
email: "example@example.com",
|
||||||
|
variantsList,
|
||||||
beforeEach(() => {
|
address: plAddress
|
||||||
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);
|
|
||||||
})
|
})
|
||||||
.then(({ errors }) => {
|
.then(({ errors }) => {
|
||||||
expect(errors[0]).to.have.property("field", "quantity");
|
expect(errors[0]).to.have.property("field", "quantity");
|
||||||
|
|
|
@ -58,7 +58,7 @@ filterTests({ definedTags: ["all", "critical"] }, () => {
|
||||||
)
|
)
|
||||||
.then(({ warehouse: warehouseResp }) => {
|
.then(({ warehouse: warehouseResp }) => {
|
||||||
warehouse = warehouseResp;
|
warehouse = warehouseResp;
|
||||||
createChannel({ isActive: true, name, currencyCode: "PLN" });
|
createChannel({ isActive: true, name, currencyCode: "USD" });
|
||||||
})
|
})
|
||||||
.then(resp => (newChannel = resp));
|
.then(resp => (newChannel = resp));
|
||||||
|
|
||||||
|
|
|
@ -81,7 +81,7 @@ filterTests({ definedTags: ["stagedOnly"] }, () => {
|
||||||
tokenCreate.errors[0].code,
|
tokenCreate.errors[0].code,
|
||||||
"logging in should return error"
|
"logging in should return error"
|
||||||
)
|
)
|
||||||
.to.be.eq("INVALID_CREDENTIALS");
|
.to.be.eq("INACTIVE");
|
||||||
expect(tokenCreate.token).to.be.not.ok;
|
expect(tokenCreate.token).to.be.not.ok;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -43,6 +43,23 @@ export function createTypeProduct({
|
||||||
.its("body.data.productTypeCreate.productType");
|
.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) {
|
export function getProductTypes(first, search) {
|
||||||
const query = `query{
|
const query = `query{
|
||||||
productTypes(first:${first}, filter:{
|
productTypes(first:${first}, filter:{
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { returnValueDependsOnShopVersion } from "../../../formatData/dataDependingOnVersion";
|
||||||
import * as attributeRequest from "../../requests/Attribute";
|
import * as attributeRequest from "../../requests/Attribute";
|
||||||
import * as categoryRequest from "../../requests/Category";
|
import * as categoryRequest from "../../requests/Category";
|
||||||
import { createCollection } from "../../requests/Collections";
|
import { createCollection } from "../../requests/Collections";
|
||||||
|
@ -5,7 +6,8 @@ import * as productRequest from "../../requests/Product";
|
||||||
import {
|
import {
|
||||||
createTypeProduct,
|
createTypeProduct,
|
||||||
deleteProductType,
|
deleteProductType,
|
||||||
getProductTypes
|
getProductTypes,
|
||||||
|
productAttributeAssignmentUpdate
|
||||||
} from "../../requests/ProductType";
|
} from "../../requests/ProductType";
|
||||||
import { deleteAttributesStartsWith } from "../attributes/attributeUtils";
|
import { deleteAttributesStartsWith } from "../attributes/attributeUtils";
|
||||||
import { deleteCollectionsStartsWith } from "../catalog/collectionsUtils";
|
import { deleteCollectionsStartsWith } from "../catalog/collectionsUtils";
|
||||||
|
@ -85,6 +87,13 @@ export function createTypeAttributeAndCategoryForProduct({
|
||||||
})
|
})
|
||||||
.then(productTypeResp => {
|
.then(productTypeResp => {
|
||||||
productType = productTypeResp;
|
productType = productTypeResp;
|
||||||
|
const updateAssign = returnValueDependsOnShopVersion("3.1", true, false);
|
||||||
|
if (updateAssign) {
|
||||||
|
productAttributeAssignmentUpdate({
|
||||||
|
productTypeId: productType.id,
|
||||||
|
attributeId: attribute.id
|
||||||
|
});
|
||||||
|
}
|
||||||
categoryRequest.createCategory(name);
|
categoryRequest.createCategory(name);
|
||||||
})
|
})
|
||||||
.then(categoryResp => {
|
.then(categoryResp => {
|
||||||
|
|
|
@ -62,9 +62,12 @@ export function createVariant({
|
||||||
cy.get(VARIANTS_SELECTORS.saveButton)
|
cy.get(VARIANTS_SELECTORS.saveButton)
|
||||||
.click()
|
.click()
|
||||||
.get(BUTTON_SELECTORS.back)
|
.get(BUTTON_SELECTORS.back)
|
||||||
.click();
|
.click()
|
||||||
|
.addAliasToGraphRequest("ProductChannelListingUpdate");
|
||||||
selectChannelVariantInDetailsPage(channelName, attributeName);
|
selectChannelVariantInDetailsPage(channelName, attributeName);
|
||||||
cy.get(BUTTON_SELECTORS.confirm).click();
|
cy.get(BUTTON_SELECTORS.confirm)
|
||||||
|
.click()
|
||||||
|
.waitForRequestAndCheckIfNoErrors("@ProductChannelListingUpdate");
|
||||||
cy.contains(PRODUCT_DETAILS.variantRow, attributeName)
|
cy.contains(PRODUCT_DETAILS.variantRow, attributeName)
|
||||||
.click()
|
.click()
|
||||||
.get(PRICE_LIST.priceInput)
|
.get(PRICE_LIST.priceInput)
|
||||||
|
|
|
@ -99,7 +99,7 @@ export function selectChannelVariantInDetailsPage(channelName, attributeName) {
|
||||||
.click();
|
.click();
|
||||||
cy.get(SELECT_CHANNELS_TO_ASSIGN.selectChannelsForm)
|
cy.get(SELECT_CHANNELS_TO_ASSIGN.selectChannelsForm)
|
||||||
.find(BUTTON_SELECTORS.submit)
|
.find(BUTTON_SELECTORS.submit)
|
||||||
.click();
|
.click({ force: true });
|
||||||
}
|
}
|
||||||
|
|
||||||
export function enterHomePageAndChangeChannel(channelName) {
|
export function enterHomePageAndChangeChannel(channelName) {
|
||||||
|
|
Loading…
Reference in a new issue