remove tests for preorders (#2699)
This commit is contained in:
parent
ab268dec0b
commit
7933ecf482
6 changed files with 0 additions and 365 deletions
|
@ -1,147 +0,0 @@
|
|||
/// <reference types="cypress"/>
|
||||
/// <reference types="../../support"/>
|
||||
|
||||
import faker from "faker";
|
||||
|
||||
import { PRODUCT_DETAILS } from "../../elements/catalog/products/product-details";
|
||||
import { BUTTON_SELECTORS } from "../../elements/shared/button-selectors";
|
||||
import { SHARED_ELEMENTS } from "../../elements/shared/sharedElements";
|
||||
import { productDetailsUrl, variantDetailsUrl } from "../../fixtures/urlList";
|
||||
import {
|
||||
activatePreorderOnVariant,
|
||||
deactivatePreorderOnVariant,
|
||||
getVariant,
|
||||
} from "../../support/api/requests/Product";
|
||||
import { createWaitingForCaptureOrder } from "../../support/api/utils/ordersUtils";
|
||||
import { createProductWithShipping } from "../../support/api/utils/products/productsUtils";
|
||||
import { formatDate, formatTime } from "../../support/formatData/formatDate";
|
||||
import {
|
||||
enablePreorderWithThreshold,
|
||||
fillUpVariantAttributeAndSku,
|
||||
saveVariant,
|
||||
selectChannelForVariantAndFillUpPrices,
|
||||
setUpPreorderEndDate,
|
||||
} from "../../support/pages/catalog/products/VariantsPage";
|
||||
|
||||
describe("Creating variants in preorder", () => {
|
||||
const name = `CreatePreOrder${faker.datatype.number()}`;
|
||||
const attributeValues = ["value1", "value2", "value3"];
|
||||
const threshold = 100;
|
||||
const futureDate = new Date().setDate(new Date().getDate() + 14);
|
||||
const endDate = formatDate(futureDate);
|
||||
const endTime = formatTime(futureDate);
|
||||
|
||||
let defaultChannel;
|
||||
let product;
|
||||
let variantsList;
|
||||
let checkoutData;
|
||||
|
||||
before(() => {
|
||||
cy.clearSessionData().loginUserViaRequest();
|
||||
createProductWithShipping({ name, attributeValues }).then(resp => {
|
||||
checkoutData = {
|
||||
address: resp.address,
|
||||
channelSlug: resp.defaultChannel.slug,
|
||||
email: "example@example.com",
|
||||
shippingMethodName: resp.shippingMethod.name,
|
||||
};
|
||||
defaultChannel = resp.defaultChannel;
|
||||
product = resp.product;
|
||||
variantsList = resp.variantsList;
|
||||
});
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
cy.clearSessionData().loginUserViaRequest();
|
||||
});
|
||||
|
||||
xit(
|
||||
"should create variant in preorder",
|
||||
{ tags: ["@preorders", "@allEnv"] },
|
||||
() => {
|
||||
let variant;
|
||||
|
||||
cy.visit(productDetailsUrl(product.id))
|
||||
.get(PRODUCT_DETAILS.addVariantsButton)
|
||||
.click();
|
||||
fillUpVariantAttributeAndSku({
|
||||
attributeName: attributeValues[1],
|
||||
sku: attributeValues[1],
|
||||
});
|
||||
enablePreorderWithThreshold(threshold);
|
||||
setUpPreorderEndDate(endDate, endTime);
|
||||
saveVariant()
|
||||
.then(({ response }) => {
|
||||
variant = response.body.data.productVariantCreate.productVariant;
|
||||
cy.get(SHARED_ELEMENTS.progressBar)
|
||||
.should("be.visible")
|
||||
.waitForProgressBarToNotBeVisible()
|
||||
.get(BUTTON_SELECTORS.back)
|
||||
.click();
|
||||
selectChannelForVariantAndFillUpPrices({
|
||||
channelName: defaultChannel.name,
|
||||
attributeName: attributeValues[1],
|
||||
price: 10,
|
||||
});
|
||||
})
|
||||
.then(() => {
|
||||
checkoutData.variantsList = [variant];
|
||||
createWaitingForCaptureOrder(checkoutData);
|
||||
})
|
||||
.then(({ order }) => {
|
||||
expect(order.id).to.be.ok;
|
||||
getVariant(variant.id, defaultChannel.slug);
|
||||
})
|
||||
.then(({ preorder }) => {
|
||||
const respEndDate = new Date(preorder.endDate);
|
||||
|
||||
expect(preorder.globalThreshold).to.eq(threshold);
|
||||
expect(preorder.globalSoldUnits).to.eq(1);
|
||||
expect(endDate).to.eq(formatDate(respEndDate));
|
||||
expect(endTime).to.eq(formatTime(respEndDate));
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
it(
|
||||
"should enable preorder on active variant",
|
||||
{ tags: ["@preorders", "@allEnv"] },
|
||||
() => {
|
||||
const variant = variantsList[0];
|
||||
checkoutData.variantsList = [variant];
|
||||
|
||||
deactivatePreorderOnVariant(variant.id);
|
||||
cy.visit(variantDetailsUrl(product.id, variant.id));
|
||||
enablePreorderWithThreshold(threshold);
|
||||
saveVariant("VariantUpdate");
|
||||
createWaitingForCaptureOrder(checkoutData)
|
||||
.then(({ order }) => {
|
||||
expect(order.id).to.be.ok;
|
||||
getVariant(variant.id, defaultChannel.slug);
|
||||
})
|
||||
.then(({ preorder }) => {
|
||||
expect(preorder.globalThreshold).to.eq(threshold);
|
||||
expect(preorder.globalSoldUnits).to.eq(1);
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
it(
|
||||
"should set end date on preorder variant",
|
||||
{ tags: ["@preorders", "@allEnv"] },
|
||||
() => {
|
||||
const variant = variantsList[0];
|
||||
checkoutData.variantsList = [variant];
|
||||
|
||||
activatePreorderOnVariant({ variantId: variant.id });
|
||||
cy.visit(variantDetailsUrl(product.id, variant.id));
|
||||
setUpPreorderEndDate(endDate, endTime);
|
||||
saveVariant("VariantUpdate");
|
||||
getVariant(variant.id, defaultChannel.slug).then(({ preorder }) => {
|
||||
const respEndDate = new Date(preorder.endDate);
|
||||
expect(endDate).to.eq(formatDate(respEndDate));
|
||||
expect(endTime).to.eq(formatTime(respEndDate));
|
||||
});
|
||||
},
|
||||
);
|
||||
});
|
|
@ -1,134 +0,0 @@
|
|||
/// <reference types="cypress"/>
|
||||
/// <reference types="../../support"/>
|
||||
|
||||
import { VARIANTS_SELECTORS } from "../../elements/catalog/products/variants-selectors";
|
||||
import { BUTTON_SELECTORS } from "../../elements/shared/button-selectors";
|
||||
import { variantDetailsUrl } from "../../fixtures/urlList";
|
||||
import { createCheckout } from "../../support/api/requests/Checkout";
|
||||
import { fulfillOrder } from "../../support/api/requests/Order";
|
||||
import { getVariant } from "../../support/api/requests/Product";
|
||||
import { deleteCollectionsStartsWith } from "../../support/api/utils/catalog/collectionsUtils";
|
||||
import { createWaitingForCaptureOrder } from "../../support/api/utils/ordersUtils";
|
||||
import {
|
||||
createProductWithShipping,
|
||||
deleteProductsStartsWith,
|
||||
} from "../../support/api/utils/products/productsUtils";
|
||||
import { deleteShippingStartsWith } from "../../support/api/utils/shippingUtils";
|
||||
import { saveVariant } from "../../support/pages/catalog/products/VariantsPage";
|
||||
|
||||
describe("Stocks and threshold in preorder variants", () => {
|
||||
const startsWith = "StocksThreshold";
|
||||
const attributeValues = ["value1", "value2"];
|
||||
const preorder = {
|
||||
globalThreshold: 15,
|
||||
};
|
||||
|
||||
let defaultChannel;
|
||||
let product;
|
||||
let variantsList;
|
||||
let warehouse;
|
||||
let checkoutData;
|
||||
|
||||
before(() => {
|
||||
cy.clearSessionData().loginUserViaRequest();
|
||||
deleteShippingStartsWith(startsWith);
|
||||
deleteProductsStartsWith(startsWith);
|
||||
deleteCollectionsStartsWith(startsWith);
|
||||
createProductWithShipping({
|
||||
name: startsWith,
|
||||
attributeValues,
|
||||
preorder,
|
||||
}).then(resp => {
|
||||
checkoutData = {
|
||||
address: resp.address,
|
||||
channelSlug: resp.defaultChannel.slug,
|
||||
email: "example@example.com",
|
||||
shippingMethodName: resp.shippingMethod.name,
|
||||
variantsList: resp.variantsList,
|
||||
};
|
||||
warehouse = resp.warehouse;
|
||||
defaultChannel = resp.defaultChannel;
|
||||
product = resp.product;
|
||||
variantsList = resp.variantsList;
|
||||
});
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
cy.clearSessionData().loginUserViaRequest();
|
||||
});
|
||||
|
||||
xit(
|
||||
"should not be able to order more products then channel threshold",
|
||||
{ tags: ["@preorders", "@allEnv"] },
|
||||
() => {
|
||||
cy.visit(variantDetailsUrl(product.id, variantsList[0].id))
|
||||
.get(VARIANTS_SELECTORS.channelThresholdInput)
|
||||
.type(5)
|
||||
.addAliasToGraphRequest("ProductVariantChannelListingUpdate");
|
||||
saveVariant("VariantUpdate");
|
||||
cy.wait("@ProductVariantChannelListingUpdate");
|
||||
checkoutData.productQuantity = 7;
|
||||
createCheckout(checkoutData).then(({ errors }) => {
|
||||
expect(errors[0].field).to.eq("quantity");
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
it(
|
||||
"should not be able to order more products then threshold even if channel is not exceeded",
|
||||
{ tags: ["@preorders", "@allEnv"] },
|
||||
() => {
|
||||
cy.visit(variantDetailsUrl(product.id, variantsList[0].id))
|
||||
.get(VARIANTS_SELECTORS.channelThresholdInput)
|
||||
.type(40);
|
||||
saveVariant("VariantUpdate");
|
||||
checkoutData.productQuantity = 20;
|
||||
createCheckout(checkoutData).then(({ errors }) => {
|
||||
expect(errors[0].field).to.eq("quantity");
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
it(
|
||||
"should allocate variants bought in preorder to correct warehouses",
|
||||
{ tags: ["@preorders", "@allEnv"] },
|
||||
() => {
|
||||
let order;
|
||||
createWaitingForCaptureOrder(checkoutData)
|
||||
.then(({ order: orderResp }) => {
|
||||
order = orderResp;
|
||||
cy.visit(variantDetailsUrl(product.id, variantsList[0].id))
|
||||
.get(VARIANTS_SELECTORS.preorderCheckbox)
|
||||
.click()
|
||||
.addAliasToGraphRequest("ProductVariantPreorderDeactivate")
|
||||
.get(BUTTON_SELECTORS.submit)
|
||||
.click()
|
||||
.waitForRequestAndCheckIfNoErrors(
|
||||
"@ProductVariantPreorderDeactivate",
|
||||
);
|
||||
getVariant(variantsList[0].id, defaultChannel.slug);
|
||||
})
|
||||
.then(variantResp => {
|
||||
expect(
|
||||
variantResp.stocks[0].quantityAllocated,
|
||||
"product is allocated with correct quantity",
|
||||
).to.eq(1);
|
||||
expect(
|
||||
variantResp.stocks[0].warehouse.id,
|
||||
"product is allocated to correct warehouse",
|
||||
).to.eq(warehouse.id);
|
||||
})
|
||||
.then(() => {
|
||||
fulfillOrder({
|
||||
orderId: order.id,
|
||||
warehouse: warehouse.id,
|
||||
quantity: 1,
|
||||
linesId: order.lines,
|
||||
});
|
||||
})
|
||||
.then(({ errors }) => {
|
||||
expect(errors, "no errors when fulfilling order").to.be.empty;
|
||||
});
|
||||
},
|
||||
);
|
||||
});
|
|
@ -9,13 +9,6 @@ export const VARIANTS_SELECTORS = {
|
|||
skuInputInAddVariant: "[name='sku']",
|
||||
stockInput: "[data-test-id='stock-input']",
|
||||
booleanAttributeCheckbox: "[name*='attribute'][type='checkbox']",
|
||||
preorderCheckbox: "[name='isPreorder']",
|
||||
channelThresholdInput: "[name='channel-threshold']",
|
||||
setUpEndDateButton: "[name='hasPreorderEndDate']",
|
||||
preorderEndDateInput: "[name='preorderEndDateTime:date']",
|
||||
preorderEndTimeInput: "[name='preorderEndDateTime:time']",
|
||||
globalThresholdInput: "[name='globalThreshold']",
|
||||
stockInput: "[data-test-id='stock-input']",
|
||||
selectOption: "[data-test-id='multi-autocomplete-select-option']",
|
||||
manageChannels: "[data-testid='manage-channels-button']",
|
||||
allChannels: "[name='allChannels']",
|
||||
|
|
|
@ -158,12 +158,7 @@ export function createVariant({
|
|||
trackInventory = true,
|
||||
weight = 1,
|
||||
attributeName = "value",
|
||||
preorder,
|
||||
}) {
|
||||
const preorderLines = getValueWithDefault(
|
||||
preorder,
|
||||
`preorder:${stringify(preorder)}`,
|
||||
);
|
||||
const skuLines = getValueWithDefault(sku, `sku: "${sku}"`);
|
||||
|
||||
const attributeLines = getValueWithDefault(
|
||||
|
@ -194,7 +189,6 @@ export function createVariant({
|
|||
|
||||
const mutation = `mutation{
|
||||
productVariantBulkCreate(product: "${productId}", variants: {
|
||||
${preorderLines}
|
||||
${attributeLines}
|
||||
weight: ${weight}
|
||||
${skuLines}
|
||||
|
@ -250,12 +244,6 @@ export function getVariants(variantsList) {
|
|||
}
|
||||
|
||||
export function getVariant(id, channelSlug, auth = "auth") {
|
||||
const preorder = `preorder{
|
||||
globalThreshold
|
||||
globalSoldUnits
|
||||
endDate
|
||||
}`;
|
||||
|
||||
const query = `query{
|
||||
productVariant(id:"${id}" channel:"${channelSlug}"){
|
||||
id
|
||||
|
@ -266,7 +254,6 @@ export function getVariant(id, channelSlug, auth = "auth") {
|
|||
}
|
||||
quantityAllocated
|
||||
}
|
||||
${preorder}
|
||||
sku
|
||||
attributes{
|
||||
attribute{
|
||||
|
@ -299,46 +286,6 @@ export function getVariant(id, channelSlug, auth = "auth") {
|
|||
return cy.sendRequestWithQuery(query, auth).its("body.data.productVariant");
|
||||
}
|
||||
|
||||
export function deactivatePreorderOnVariant(variantId) {
|
||||
const mutation = `mutation{
|
||||
productVariantPreorderDeactivate(id:"${variantId}"){
|
||||
errors{
|
||||
field
|
||||
message
|
||||
}
|
||||
}
|
||||
}`;
|
||||
return cy
|
||||
.sendRequestWithQuery(mutation)
|
||||
.its("body.data.productVariantPreorderDeactivate");
|
||||
}
|
||||
|
||||
export function activatePreorderOnVariant({
|
||||
variantId,
|
||||
threshold = 50,
|
||||
endDate,
|
||||
}) {
|
||||
const thresholdLine = getValueWithDefault(
|
||||
threshold,
|
||||
`globalThreshold:${threshold}`,
|
||||
);
|
||||
const endDateLine = getValueWithDefault(endDate, `endDate:${endDate}`);
|
||||
const mutation = `mutation{
|
||||
productVariantUpdate(id:"${variantId}", input:{
|
||||
preorder:{
|
||||
${thresholdLine}
|
||||
${endDateLine}
|
||||
}
|
||||
}){
|
||||
errors{
|
||||
field
|
||||
message
|
||||
}
|
||||
}
|
||||
}`;
|
||||
return cy.sendRequestWithQuery(mutation);
|
||||
}
|
||||
|
||||
export function updateVariantPrice({ variantId, channelId, price }) {
|
||||
const mutation = `mutation {
|
||||
productVariantChannelListingUpdate(id:"${variantId}", input:{
|
||||
|
|
|
@ -34,7 +34,6 @@ export function createProductInChannel({
|
|||
description = null,
|
||||
trackInventory = true,
|
||||
weight = 1,
|
||||
preorder,
|
||||
sku = name,
|
||||
}) {
|
||||
let product;
|
||||
|
@ -63,7 +62,6 @@ export function createProductInChannel({
|
|||
price,
|
||||
trackInventory,
|
||||
weight,
|
||||
preorder,
|
||||
});
|
||||
})
|
||||
.then(variantsResp => {
|
||||
|
@ -120,7 +118,6 @@ export function createNewProductWithNewDataAndDefaultChannel({
|
|||
name,
|
||||
description = name,
|
||||
warehouseId,
|
||||
preorder,
|
||||
attributeValues = ["value"],
|
||||
sku = name,
|
||||
productPrice = 10,
|
||||
|
@ -130,7 +127,6 @@ export function createNewProductWithNewDataAndDefaultChannel({
|
|||
name,
|
||||
description,
|
||||
warehouseId,
|
||||
preorder,
|
||||
attributeValues,
|
||||
sku,
|
||||
productPrice,
|
||||
|
@ -143,7 +139,6 @@ export function createNewProductWithNewDataAndChannel({
|
|||
name,
|
||||
description = name,
|
||||
warehouseId,
|
||||
preorder,
|
||||
attributeValues = ["value"],
|
||||
sku = name,
|
||||
productPrice = 10,
|
||||
|
@ -178,7 +173,6 @@ export function createNewProductWithNewDataAndChannel({
|
|||
description,
|
||||
warehouseId,
|
||||
price: productPrice,
|
||||
preorder,
|
||||
sku,
|
||||
});
|
||||
},
|
||||
|
@ -198,7 +192,6 @@ export function createProductWithShipping({
|
|||
sku = name,
|
||||
productPrice = 10,
|
||||
shippingPrice = 10,
|
||||
preorder,
|
||||
newChannel = false,
|
||||
}) {
|
||||
let address;
|
||||
|
@ -239,7 +232,6 @@ export function createProductWithShipping({
|
|||
name,
|
||||
warehouseId: warehouse.id,
|
||||
productPrice,
|
||||
preorder,
|
||||
attributeValues,
|
||||
sku,
|
||||
defaultChannel,
|
||||
|
|
|
@ -177,22 +177,6 @@ export function selectAttributeWithType({ attributeType, attributeName }) {
|
|||
}
|
||||
}
|
||||
|
||||
export function enablePreorderWithThreshold(threshold) {
|
||||
cy.get(VARIANTS_SELECTORS.preorderCheckbox)
|
||||
.click()
|
||||
.get(VARIANTS_SELECTORS.globalThresholdInput)
|
||||
.type(threshold);
|
||||
}
|
||||
|
||||
export function setUpPreorderEndDate(endDate, endTime) {
|
||||
cy.get(VARIANTS_SELECTORS.setUpEndDateButton)
|
||||
.click()
|
||||
.get(VARIANTS_SELECTORS.preorderEndDateInput)
|
||||
.type(endDate)
|
||||
.get(VARIANTS_SELECTORS.preorderEndTimeInput)
|
||||
.type(endTime);
|
||||
}
|
||||
|
||||
export function saveVariant(waitForAlias = "VariantCreate") {
|
||||
return cy
|
||||
.addAliasToGraphRequest(waitForAlias)
|
||||
|
|
Loading…
Reference in a new issue