Fix failed night schedule tests (#3015)

* fix e2e tests

* update test tag

* update tax config in tests failing on v310

* updatet taxes for product variant tests

* move updateRaxConfiguration to beforeEach

* fix imports

* change retries in config

* update data-test-id and remove failing wait for request
This commit is contained in:
Anna Szczęch 2023-01-25 11:32:28 +01:00 committed by GitHub
parent 7593e6378a
commit 644b58a914
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 116 additions and 34 deletions

View file

@ -11,8 +11,8 @@ module.exports = defineConfig({
viewportWidth: 1400, viewportWidth: 1400,
viewportHeight: 660, viewportHeight: 660,
retries: { retries: {
runMode: 2, runMode: 1,
openMode: 1, openMode: 0,
}, },
e2e: { e2e: {
env: { env: {

View file

@ -20,6 +20,7 @@ import {
} from "../../../support/api/utils/ordersUtils"; } from "../../../support/api/utils/ordersUtils";
import * as productsUtils from "../../../support/api/utils/products/productsUtils"; import * as productsUtils from "../../../support/api/utils/products/productsUtils";
import { deleteShippingStartsWith } from "../../../support/api/utils/shippingUtils"; import { deleteShippingStartsWith } from "../../../support/api/utils/shippingUtils";
import { updateTaxConfigurationForChannel } from "../../../support/api/utils/taxesUtils";
import { import {
changeGiftCardActiveStatus, changeGiftCardActiveStatus,
enterAndSelectGiftCards, enterAndSelectGiftCards,
@ -69,6 +70,10 @@ describe("As a admin I want to use enabled gift card in checkout", () => {
beforeEach(() => { beforeEach(() => {
cy.clearSessionData().loginUserViaRequest(); cy.clearSessionData().loginUserViaRequest();
updateTaxConfigurationForChannel({
channelSlug: defaultChannel.slug,
pricesEnteredWithTax: true,
});
}); });
it( it(

View file

@ -32,8 +32,8 @@ describe("As an admin I want to use attributes in variant selection", () => {
getDefaultChannel().then(defaultChannel => (channel = defaultChannel)); getDefaultChannel().then(defaultChannel => (channel = defaultChannel));
createCategory({ name: startsWith }).then( createCategory({ name: startsWith }).then(
categoryResp => (category = categoryResp), categoryResp => (category = categoryResp),
cy.checkIfDataAreNotNull({ channel, category }),
); );
cy.checkIfDataAreNotNull({ channel, category });
}); });
beforeEach(() => { beforeEach(() => {

View file

@ -29,7 +29,7 @@ describe("Tests for customer registration", () => {
}); });
}); });
it("should register customer", { tags: ["@customer", "@stagedOnly"] }, () => { it("should register customer", { tags: ["@customer", "@allEnv"] }, () => {
const email = `${startsWith}${faker.datatype.number()}@example.com`; const email = `${startsWith}${faker.datatype.number()}@example.com`;
customerRegistration({ email, channel: defaultChannel.slug }); customerRegistration({ email, channel: defaultChannel.slug });
const registrationLinkRegex = /\[(\s*http[^\]]*)\]/; const registrationLinkRegex = /\[(\s*http[^\]]*)\]/;

View file

@ -14,6 +14,10 @@ import {
deleteShippingStartsWith, deleteShippingStartsWith,
} from "../../../support/api/utils/shippingUtils"; } from "../../../support/api/utils/shippingUtils";
import { getProductPrice } from "../../../support/api/utils/storeFront/storeFrontProductUtils"; import { getProductPrice } from "../../../support/api/utils/storeFront/storeFrontProductUtils";
import {
getDefaultTaxClass,
updateTaxConfigurationForChannel,
} from "../../../support/api/utils/taxesUtils";
import { import {
assignProducts, assignProducts,
createSale, createSale,
@ -31,6 +35,7 @@ describe("As an admin I want to create sale for products", () => {
let category; let category;
let defaultChannel; let defaultChannel;
let warehouse; let warehouse;
let taxClass;
before(() => { before(() => {
const name = `${startsWith}${faker.datatype.number()}`; const name = `${startsWith}${faker.datatype.number()}`;
@ -57,6 +62,10 @@ describe("As an admin I want to create sale for products", () => {
) )
.then(channel => { .then(channel => {
defaultChannel = channel; defaultChannel = channel;
getDefaultTaxClass();
})
.then(taxResp => {
taxClass = taxResp;
cy.fixture("addresses"); cy.fixture("addresses");
}) })
.then(addresses => { .then(addresses => {
@ -65,6 +74,7 @@ describe("As an admin I want to create sale for products", () => {
name, name,
address: addresses.plAddress, address: addresses.plAddress,
price: 100, price: 100,
taxClassId: taxClass.id,
}); });
}) })
.then(({ warehouse: warehouseResp }) => { .then(({ warehouse: warehouseResp }) => {
@ -81,6 +91,10 @@ describe("As an admin I want to create sale for products", () => {
beforeEach(() => { beforeEach(() => {
cy.clearSessionData().loginUserViaRequest(); cy.clearSessionData().loginUserViaRequest();
updateTaxConfigurationForChannel({
channelSlug: defaultChannel.slug,
pricesEnteredWithTax: true,
});
}); });
it( it(
@ -100,6 +114,7 @@ describe("As an admin I want to create sale for products", () => {
price: productPrice, price: productPrice,
discountOption: discountOptions.PERCENTAGE, discountOption: discountOptions.PERCENTAGE,
discountValue, discountValue,
taxClassId: taxClass.id,
}).should("eq", expectedPrice); }).should("eq", expectedPrice);
}, },
); );
@ -146,6 +161,7 @@ describe("As an admin I want to create sale for products", () => {
attributeId: attribute.id, attributeId: attribute.id,
categoryId: category.id, categoryId: category.id,
price: productPrice, price: productPrice,
taxClassId: taxClass.id,
}) })
.then(({ product: productResp }) => { .then(({ product: productResp }) => {
product = productResp; product = productResp;

View file

@ -16,6 +16,10 @@ import {
createShipping, createShipping,
deleteShippingStartsWith, deleteShippingStartsWith,
} from "../../../support/api/utils/shippingUtils"; } from "../../../support/api/utils/shippingUtils";
import {
getDefaultTaxClass,
updateTaxConfigurationForChannel,
} from "../../../support/api/utils/taxesUtils";
import { deleteWarehouseStartsWith } from "../../../support/api/utils/warehouseUtils"; import { deleteWarehouseStartsWith } from "../../../support/api/utils/warehouseUtils";
import { import {
createSaleWithNewVariant, createSaleWithNewVariant,
@ -31,6 +35,7 @@ describe("Sales discounts for variant", () => {
let warehouse; let warehouse;
let productData; let productData;
let address; let address;
let taxClass;
before(() => { before(() => {
const name = `${startsWith}${faker.datatype.number()}`; const name = `${startsWith}${faker.datatype.number()}`;
@ -40,9 +45,15 @@ describe("Sales discounts for variant", () => {
deleteShippingStartsWith(startsWith); deleteShippingStartsWith(startsWith);
deleteSalesStartsWith(startsWith); deleteSalesStartsWith(startsWith);
deleteWarehouseStartsWith(startsWith); deleteWarehouseStartsWith(startsWith);
channelsUtils.getDefaultChannel().then(channel => { channelsUtils
defaultChannel = channel; .getDefaultChannel()
}); .then(channel => {
defaultChannel = channel;
getDefaultTaxClass();
})
.then(taxResp => {
taxClass = taxResp;
});
cy.fixture("addresses") cy.fixture("addresses")
.then(addresses => { .then(addresses => {
address = addresses.usAddress; address = addresses.usAddress;
@ -51,6 +62,7 @@ describe("Sales discounts for variant", () => {
channelId: defaultChannel.id, channelId: defaultChannel.id,
address, address,
name, name,
taxClassId: taxClass.id,
}); });
}) })
.then(({ warehouse: warehouseResp }) => { .then(({ warehouse: warehouseResp }) => {
@ -70,6 +82,7 @@ describe("Sales discounts for variant", () => {
channelId: defaultChannel.id, channelId: defaultChannel.id,
warehouseId: warehouse.id, warehouseId: warehouse.id,
price: productPrice, price: productPrice,
taxClassId: taxClass.id,
}; };
cy.checkIfDataAreNotNull({ cy.checkIfDataAreNotNull({
productData, productData,
@ -82,6 +95,10 @@ describe("Sales discounts for variant", () => {
beforeEach(() => { beforeEach(() => {
cy.clearSessionData().loginUserViaRequest(); cy.clearSessionData().loginUserViaRequest();
updateTaxConfigurationForChannel({
channelSlug: defaultChannel.slug,
pricesEnteredWithTax: true,
});
}); });
it( it(
@ -158,6 +175,7 @@ describe("Sales discounts for variant", () => {
price: productPrice, price: productPrice,
discountOption: discountOptions.PERCENTAGE, discountOption: discountOptions.PERCENTAGE,
discountValue, discountValue,
taxClassId: taxClass.id,
}) })
.its("pricing.price.gross.amount") .its("pricing.price.gross.amount")
.should("eq", expectedPrice); .should("eq", expectedPrice);

View file

@ -24,6 +24,10 @@ import {
createShipping, createShipping,
deleteShippingStartsWith, deleteShippingStartsWith,
} from "../../../support/api/utils/shippingUtils"; } from "../../../support/api/utils/shippingUtils";
import {
getDefaultTaxClass,
updateTaxConfigurationForChannel,
} from "../../../support/api/utils/taxesUtils";
describe("As an admin I want to update sales", () => { describe("As an admin I want to update sales", () => {
const startsWith = "CySales"; const startsWith = "CySales";
@ -37,6 +41,7 @@ describe("As an admin I want to update sales", () => {
let address; let address;
let productData; let productData;
let variants; let variants;
let taxClass;
before(() => { before(() => {
const name = `${startsWith}${faker.datatype.number()}`; const name = `${startsWith}${faker.datatype.number()}`;
@ -48,7 +53,10 @@ describe("As an admin I want to update sales", () => {
getDefaultChannel() getDefaultChannel()
.then(channel => { .then(channel => {
defaultChannel = channel; defaultChannel = channel;
getDefaultTaxClass();
})
.then(taxResp => {
taxClass = taxResp;
createSaleInChannel({ createSaleInChannel({
name, name,
type: "FIXED", type: "FIXED",
@ -65,6 +73,7 @@ describe("As an admin I want to update sales", () => {
channelId: defaultChannel.id, channelId: defaultChannel.id,
address, address,
name: startsWith, name: startsWith,
taxClassId: taxClass.id,
}); });
}) })
.then(({ warehouse: warehouseResp }) => { .then(({ warehouse: warehouseResp }) => {
@ -81,6 +90,7 @@ describe("As an admin I want to update sales", () => {
channelId: defaultChannel.id, channelId: defaultChannel.id,
warehouseId: warehouse.id, warehouseId: warehouse.id,
price: productPrice, price: productPrice,
taxClassId: taxClass.id,
}; };
cy.checkIfDataAreNotNull({ cy.checkIfDataAreNotNull({
productData, productData,
@ -95,6 +105,10 @@ describe("As an admin I want to update sales", () => {
beforeEach(() => { beforeEach(() => {
cy.clearSessionData().loginUserViaRequest(); cy.clearSessionData().loginUserViaRequest();
updateTaxConfigurationForChannel({
channelSlug: defaultChannel.slug,
pricesEnteredWithTax: true,
});
}); });
it( it(

View file

@ -13,6 +13,7 @@ import {
createCheckoutWithVoucher, createCheckoutWithVoucher,
} from "../../../support/api/utils/ordersUtils"; } from "../../../support/api/utils/ordersUtils";
import * as productsUtils from "../../../support/api/utils/products/productsUtils"; import * as productsUtils from "../../../support/api/utils/products/productsUtils";
import { updateTaxConfigurationForChannel } from "../../../support/api/utils/taxesUtils";
import { import {
createVoucher, createVoucher,
discountOptions, discountOptions,
@ -53,14 +54,21 @@ describe("As an admin I want to create voucher", () => {
auth: "token", auth: "token",
}; };
}, },
cy.checkIfDataAreNotNull({
createdChannel,
dataForCheckout,
defaultChannel,
}),
); );
cy.checkIfDataAreNotNull({
createdChannel,
dataForCheckout,
defaultChannel,
});
}); });
beforeEach(() => {
cy.clearSessionData().loginUserViaRequest();
updateTaxConfigurationForChannel({
channelSlug: defaultChannel.slug,
pricesEnteredWithTax: true,
});
});
it( it(
"should be able to create fixed price voucher. TC: SALEOR_1901", "should be able to create fixed price voucher. TC: SALEOR_1901",
{ tags: ["@vouchers", "@allEnv", "@stable"] }, { tags: ["@vouchers", "@allEnv", "@stable"] },

View file

@ -12,6 +12,7 @@ import {
} from "../../../support/api/utils/discounts/vouchersUtils"; } from "../../../support/api/utils/discounts/vouchersUtils";
import { createCheckoutWithVoucher } from "../../../support/api/utils/ordersUtils"; import { createCheckoutWithVoucher } from "../../../support/api/utils/ordersUtils";
import * as productsUtils from "../../../support/api/utils/products/productsUtils"; import * as productsUtils from "../../../support/api/utils/products/productsUtils";
import { updateTaxConfigurationForChannel } from "../../../support/api/utils/taxesUtils";
import { formatDate, formatTime } from "../../../support/formatData/formatDate"; import { formatDate, formatTime } from "../../../support/formatData/formatDate";
import { setVoucherDate } from "../../../support/pages/discounts/vouchersPage"; import { setVoucherDate } from "../../../support/pages/discounts/vouchersPage";
@ -51,10 +52,17 @@ describe("As an admin I want to update vouchers", () => {
auth: "token", auth: "token",
}; };
}, },
cy.checkIfDataAreNotNull({ dataForCheckout, defaultChannel, product }),
); );
cy.checkIfDataAreNotNull({ dataForCheckout, defaultChannel, product });
}); });
beforeEach(() => {
cy.clearSessionData().loginUserViaRequest();
updateTaxConfigurationForChannel({
channelSlug: defaultChannel.slug,
pricesEnteredWithTax: true,
});
});
it( it(
"should delete voucher. TC: SALEOR_1905", "should delete voucher. TC: SALEOR_1905",
{ tags: ["@vouchers", "@allEnv", "@stable"] }, { tags: ["@vouchers", "@allEnv", "@stable"] },

View file

@ -13,6 +13,7 @@ import {
} from "../../support/api/requests/Product"; } from "../../support/api/requests/Product";
import * as productUtils from "../../support/api/utils/products/productsUtils"; import * as productUtils from "../../support/api/utils/products/productsUtils";
import { getProductVariants } from "../../support/api/utils/storeFront/storeFrontProductUtils"; import { getProductVariants } from "../../support/api/utils/storeFront/storeFrontProductUtils";
import { updateTaxConfigurationForChannel } from "../../support/api/utils/taxesUtils";
import { import {
addVariantToDataGrid, addVariantToDataGrid,
enterVariantEditPage, enterVariantEditPage,
@ -21,6 +22,7 @@ import {
createVariant, createVariant,
selectChannelsForVariant, selectChannelsForVariant,
} from "../../support/pages/catalog/products/VariantsPage"; } from "../../support/pages/catalog/products/VariantsPage";
describe("As an admin I should be able to create variant", () => { describe("As an admin I should be able to create variant", () => {
const startsWith = "CyCreateVariants-"; const startsWith = "CyCreateVariants-";
const attributeValues = ["value1", "value2"]; const attributeValues = ["value1", "value2"];
@ -37,6 +39,7 @@ describe("As an admin I should be able to create variant", () => {
cy.clearSessionData().loginUserViaRequest(); cy.clearSessionData().loginUserViaRequest();
updateTaxConfigurationForChannel({ pricesEnteredWithTax: true });
productUtils productUtils
.createShippingProductTypeAttributeAndCategory(name, attributeValues) .createShippingProductTypeAttributeAndCategory(name, attributeValues)
.then(resp => { .then(resp => {
@ -50,15 +53,19 @@ describe("As an admin I should be able to create variant", () => {
}) })
.then(resp => { .then(resp => {
newChannel = resp; newChannel = resp;
cy.checkIfDataAreNotNull({ updateTaxConfigurationForChannel({
defaultChannel, channelSlug: newChannel.slug,
warehouse, pricesEnteredWithTax: true,
attribute,
productType,
category,
newChannel,
}); });
}); });
cy.checkIfDataAreNotNull({
defaultChannel,
warehouse,
attribute,
productType,
category,
newChannel,
});
}); });
beforeEach(() => { beforeEach(() => {

View file

@ -15,6 +15,7 @@ import { createWaitingForCaptureOrder } from "../../../support/api/utils/ordersU
import * as productUtils from "../../../support/api/utils/products/productsUtils"; import * as productUtils from "../../../support/api/utils/products/productsUtils";
import * as shippingUtils from "../../../support/api/utils/shippingUtils"; import * as shippingUtils from "../../../support/api/utils/shippingUtils";
import { getProductVariants } from "../../../support/api/utils/storeFront/storeFrontProductUtils"; import { getProductVariants } from "../../../support/api/utils/storeFront/storeFrontProductUtils";
import { updateTaxConfigurationForChannel } from "../../../support/api/utils/taxesUtils";
import { deleteWarehouseStartsWith } from "../../../support/api/utils/warehouseUtils"; import { deleteWarehouseStartsWith } from "../../../support/api/utils/warehouseUtils";
import { import {
fillUpPriceList, fillUpPriceList,
@ -64,6 +65,11 @@ describe("Creating variants", () => {
defaultChannel = resp.defaultChannel; defaultChannel = resp.defaultChannel;
warehouse = resp.warehouse; warehouse = resp.warehouse;
shippingMethod = resp.shippingMethod; shippingMethod = resp.shippingMethod;
updateTaxConfigurationForChannel({
channelSlug: defaultChannel.slug,
pricesEnteredWithTax: true,
});
}); });
productUtils productUtils
@ -195,15 +201,15 @@ describe("Creating variants", () => {
}); });
}); });
enterVariantEditPage(); enterVariantEditPage();
cy.addAliasToGraphRequest("ProductVariantDetails"); cy.addAliasToGraphRequest("VariantUpdate");
selectChannelsForVariant(); selectChannelsForVariant();
cy.get(BUTTON_SELECTORS.confirm) cy.get(BUTTON_SELECTORS.confirm)
.click() .click()
.confirmationMessageShouldDisappear() .confirmationMessageShouldDisappear()
.wait("@ProductVariantDetails") .wait("@VariantUpdate")
.then(({ response }) => { .then(({ response }) => {
const variants = [ const variants = [
response.body.data.productVariant.product.variants[0], response.body.data.productVariantUpdate.productVariant,
]; ];
createWaitingForCaptureOrder({ createWaitingForCaptureOrder({
channelSlug: defaultChannel.slug, channelSlug: defaultChannel.slug,

View file

@ -1,6 +1,6 @@
export const VARIANTS_SELECTORS = { export const VARIANTS_SELECTORS = {
variantNameInput: '[data-test-id="variant-name"]', variantNameInput: '[data-test-id="variant-name"]',
skuTextField: '[data-test-id="sku"]', skuTextField: '[data-test-id="sku"] input',
attributeOption: attributeOption:
"[data-test-type='option'], [data-test-id='multi-autocomplete-select-option']", "[data-test-type='option'], [data-test-id='multi-autocomplete-select-option']",
attributeSelector: "[data-test-id='attribute-value']", attributeSelector: "[data-test-id='attribute-value']",

View file

@ -22,12 +22,13 @@ export function updateTaxes({
id, id,
chargeTaxes = true, chargeTaxes = true,
taxCalculationStrategy = "FLAT_RATES", taxCalculationStrategy = "FLAT_RATES",
pricesEnteredWithTax = "false",
}) { }) {
const mutation = `mutation{ const mutation = `mutation{
taxConfigurationUpdate(id:"${id}", input:{ taxConfigurationUpdate(id:"${id}", input:{
chargeTaxes:${chargeTaxes} chargeTaxes:${chargeTaxes}
displayGrossPrices:true displayGrossPrices:true
pricesEnteredWithTax:false pricesEnteredWithTax:${pricesEnteredWithTax}
removeCountriesConfiguration: [] removeCountriesConfiguration: []
taxCalculationStrategy:${taxCalculationStrategy} taxCalculationStrategy:${taxCalculationStrategy}
updateCountriesConfiguration: [] updateCountriesConfiguration: []

View file

@ -5,9 +5,10 @@ import {
} from "../requests/Taxes"; } from "../requests/Taxes";
export function updateTaxConfigurationForChannel({ export function updateTaxConfigurationForChannel({
channelSlug, channelSlug = "default-channel",
chargeTaxes = true, chargeTaxes = true,
taxCalculationStrategy = "FLAT_RATES", taxCalculationStrategy = "FLAT_RATES",
pricesEnteredWithTax = "false",
}) { }) {
getTaxConfigurationList().then(taxConfigurationList => { getTaxConfigurationList().then(taxConfigurationList => {
const taxConfigurationForChannel = taxConfigurationList.find( const taxConfigurationForChannel = taxConfigurationList.find(
@ -17,6 +18,7 @@ export function updateTaxConfigurationForChannel({
id: taxConfigurationForChannel.node.id, id: taxConfigurationForChannel.node.id,
chargeTaxes, chargeTaxes,
taxCalculationStrategy, taxCalculationStrategy,
pricesEnteredWithTax,
}); });
}); });
} }

View file

@ -32,12 +32,9 @@ export function createVariant({
price, price,
variantName, variantName,
}); });
cy.addAliasToGraphRequest("WarehouseList") cy.get(VARIANTS_SELECTORS.saveButton)
.get(VARIANTS_SELECTORS.saveButton)
.click() .click()
.wait("@WarehouseList")
.get(VARIANTS_SELECTORS.skuTextField) .get(VARIANTS_SELECTORS.skuTextField)
.find("input")
.and("be.enabled") .and("be.enabled")
.get(BUTTON_SELECTORS.back) .get(BUTTON_SELECTORS.back)
.click() .click()
@ -58,9 +55,7 @@ export function fillUpGeneralVariantInputs({
force: true, force: true,
}); });
} else { } else {
cy.get(VARIANTS_SELECTORS.warehouseOption) cy.get(VARIANTS_SELECTORS.warehouseOption).first().click({ force: true });
.first()
.click({ force: true });
} }
cy.get(VARIANTS_SELECTORS.stockInput).type(quantity); cy.get(VARIANTS_SELECTORS.stockInput).type(quantity);
} }

View file

@ -84,6 +84,7 @@ export function createSaleWithNewProduct({
price, price,
discountOption, discountOption,
discountValue, discountValue,
taxClassId,
}) { }) {
return createProductInChannel({ return createProductInChannel({
name, name,
@ -93,6 +94,7 @@ export function createSaleWithNewProduct({
attributeId, attributeId,
categoryId, categoryId,
price, price,
taxClassId,
}).then(({ product: productResp }) => { }).then(({ product: productResp }) => {
const product = productResp; const product = productResp;
/* Uncomment after fixing SALEOR-3367 bug /* Uncomment after fixing SALEOR-3367 bug