Update tests check if all data created in before are correct (#2917)

* add commend to check if data are correct

* Add command for checking created data
This commit is contained in:
Karolina Rakoczy 2023-01-16 10:43:13 +01:00 committed by GitHub
parent 92539ae968
commit 39ce183583
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
53 changed files with 168 additions and 19 deletions

View file

@ -84,7 +84,10 @@ describe("As a staff user I want to manage apps", () => {
categoryId: category.id, categoryId: category.id,
}); });
}) })
.then(({ variantsList: variants }) => (variantsList = variants)); .then(({ variantsList: variants }) => {
variantsList = variants
cy.checkIfDataAreNotNull({createdApp,defaultChannel,address,warehouse,shippingMethod,variantsList,checkout})
});
}); });
beforeEach(() => { beforeEach(() => {

View file

@ -66,7 +66,16 @@ describe("As an admin I want to manage categories", () => {
}); });
}, },
) )
.then(({ product: productResp }) => (product = productResp)); .then(({ product: productResp }) => {
product = productResp;
cy.checkIfDataAreNotNull({
attribute,
category,
productType,
product,
defaultChannel,
});
});
}); });
beforeEach(() => { beforeEach(() => {

View file

@ -70,7 +70,10 @@ describe("As an admin I want to manage collections.", () => {
}); });
}, },
) )
.then(({ product: productResp }) => (product = productResp)); .then(({ product: productResp }) => {
product = productResp
cy.checkIfDataAreNotNull({attribute, category, productType, product, defaultChannel})
});
}); });
beforeEach(() => { beforeEach(() => {

View file

@ -63,6 +63,7 @@ describe("As a admin I want to use enabled gift card in checkout", () => {
shippingMethodName: resp.shippingMethod.name, shippingMethodName: resp.shippingMethod.name,
variantsList: resp.variantsList, variantsList: resp.variantsList,
}; };
cy.checkIfDataAreNotNull(dataForCheckout);
}); });
}); });

View file

@ -79,6 +79,7 @@ describe("As a customer I should be able to purchase gift card as a product", ()
}) })
.then(({ variantsList: variantsResp }) => { .then(({ variantsList: variantsResp }) => {
variants = variantsResp; variants = variantsResp;
cy.checkIfDataAreNotNull({defaultChannel, productType, attribute, category, shippingMethod, variants, address})
}); });
}); });

View file

@ -83,6 +83,7 @@ describe("Warehouses in checkout", () => {
}) })
.then(({ variantsList }) => { .then(({ variantsList }) => {
variantsInOtherWarehouse = variantsList; variantsInOtherWarehouse = variantsList;
cy.checkIfDataAreNotNull({defaultChannel, usAddress, secondUsAddress, productData, checkoutData, variantsInOtherWarehouse})
}); });
}); });

View file

@ -84,7 +84,10 @@ describe("Products without shipment option", () => {
productTypeId: productTypeResp.id, productTypeId: productTypeResp.id,
warehouseId: warehouse.id, warehouseId: warehouse.id,
}).then( }).then(
({ variantsList }) => (productWithoutShipping = variantsList), ({ variantsList }) => {
productWithoutShipping = variantsList
cy.checkIfDataAreNotNull({channel, address, warehouse, shippingMethod, productWithShipping, productWithoutShipping})
}
); );
}, },
); );

View file

@ -43,6 +43,13 @@ describe("As an unlogged customer I want to order physical and digital products"
shippingMethod = resp.shippingMethod; shippingMethod = resp.shippingMethod;
digitalVariants = resp.digitalVariants; digitalVariants = resp.digitalVariants;
physicalVariants = resp.physicalVariants; physicalVariants = resp.physicalVariants;
cy.checkIfDataAreNotNull({
defaultChannel,
address,
shippingMethod,
digitalVariants,
physicalVariants,
});
}); });
}); });

View file

@ -56,6 +56,7 @@ describe("Manage products stocks in checkout", () => {
lastVariantInStock = resp.createdVariants.find( lastVariantInStock = resp.createdVariants.find(
variant => variant.name === "lastVariantInStock", variant => variant.name === "lastVariantInStock",
); );
cy.checkIfDataAreNotNull({defaultChannel, address,shippingMethod, variantsWithLowStock, variantsWithoutTrackInventory, lastVariantInStock})
}); });
}); });

View file

@ -25,7 +25,6 @@ describe("As an admin I want to use attributes in variant selection", () => {
]; ];
let channel; let channel;
let category; let category;
let product;
before(() => { before(() => {
cy.clearSessionData().loginUserViaRequest(); cy.clearSessionData().loginUserViaRequest();
@ -33,6 +32,7 @@ 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})
); );
}); });
@ -51,6 +51,7 @@ describe("As an admin I want to use attributes in variant selection", () => {
const inputType = attributeType.key; const inputType = attributeType.key;
const attributeValues = ["1", "2"]; const attributeValues = ["1", "2"];
let productType; let productType;
let product;
createProductTypeWithNewVariantSelectionAttribute({ createProductTypeWithNewVariantSelectionAttribute({
name, name,

View file

@ -29,6 +29,7 @@ describe("As an admin I want to delete and update content attribute", () => {
}).then(attributeResp => { }).then(attributeResp => {
attribute = attributeResp; attribute = attributeResp;
}); });
cy.checkIfDataAreNotNull(attribute)
}); });
it( it(

View file

@ -39,13 +39,17 @@ describe("Channels", () => {
shippingZone = shippingZoneResp; shippingZone = shippingZoneResp;
}, },
); );
cy.fixture("addresses").then(addresses => { cy.fixture("addresses")
usAddress = addresses.usAddress; .then(addresses => {
createWarehouseViaApi({ usAddress = addresses.usAddress;
name: randomName, createWarehouseViaApi({
address: usAddress, name: randomName,
address: usAddress,
});
})
.then(warehouse => {
cy.checkIfDataAreNotNull({ shippingZone, usAddress, warehouse });
}); });
});
}); });
beforeEach(() => { beforeEach(() => {

View file

@ -48,6 +48,7 @@ describe("Tests on inactive channel", () => {
currencyCode: currency, currencyCode: currency,
}).then(channel => { }).then(channel => {
newChannel = channel; newChannel = channel;
cy.checkIfDataAreNotNull({ address, defaultChannel, newChannel });
}); });
}); });

View file

@ -27,6 +27,7 @@ describe("Tests for customer", () => {
address = usAddress; address = usAddress;
secondAddress = secondUsAddress; secondAddress = secondUsAddress;
}); });
cy.checkIfDataAreNotNull({ address, secondAddress });
}); });
beforeEach(() => { beforeEach(() => {

View file

@ -25,7 +25,10 @@ describe("Tests for menu navigation", () => {
cy.clearSessionData().loginUserViaRequest(); cy.clearSessionData().loginUserViaRequest();
deleteMenusStartsWith(startsWith); deleteMenusStartsWith(startsWith);
createMenuViaApi(randomName).then( createMenuViaApi(randomName).then(
({ menu: menuResp }) => (menu = menuResp), ({ menu: menuResp }) => {
menu = menuResp
cy.checkIfDataAreNotNull(menu)
},
); );
}); });

View file

@ -91,7 +91,10 @@ describe("Adyen payments", () => {
categoryId: category.id, categoryId: category.id,
}); });
}) })
.then(({ variantsList: variants }) => (variantsList = variants)); .then(({ variantsList: variants }) => {
variantsList = variants
cy.checkIfDataAreNotNull({address,defaultChannel,warehouse,shippingMethod,variantsList,checkout,paymentCards,cardData})
});
}); });
beforeEach(() => { beforeEach(() => {

View file

@ -50,6 +50,7 @@ describe("Stripe payments", () => {
defaultChannel = values.defaultChannel; defaultChannel = values.defaultChannel;
shippingMethod = values.shippingMethod; shippingMethod = values.shippingMethod;
variantsList = values.variantsList; variantsList = values.variantsList;
cy.checkIfDataAreNotNull({address,defaultChannel,shippingMethod,variantsList,checkout,paymentCards,cardData})
}); });
}); });

View file

@ -22,6 +22,7 @@ describe("As an admin I want to manage attributes in product types", () => {
cy.clearSessionData().loginUserViaRequest(); cy.clearSessionData().loginUserViaRequest();
deleteProductsStartsWith(startsWith); deleteProductsStartsWith(startsWith);
createAttribute({ name: startsWith }).then(resp => (attribute = resp)); createAttribute({ name: startsWith }).then(resp => (attribute = resp));
cy.checkIfDataAreNotNull(attribute);
}); });
beforeEach(() => { beforeEach(() => {

View file

@ -29,7 +29,10 @@ describe("As an admin I want to manage product types", () => {
deleteProductsStartsWith(startsWith); deleteProductsStartsWith(startsWith);
createAttribute({ name: startsWith }).then(resp => (attribute = resp)); createAttribute({ name: startsWith }).then(resp => (attribute = resp));
createCategory({ name: startsWith }).then(resp => (category = resp)); createCategory({ name: startsWith }).then(resp => (category = resp));
getDefaultChannel().then(resp => (channel = resp)); getDefaultChannel().then(resp => {
channel = resp
cy.checkIfDataAreNotNull({attribute, channel, category})
});
}); });
beforeEach(() => { beforeEach(() => {

View file

@ -95,6 +95,7 @@ describe("As a staff user I want to create shipping zone and rate", () => {
}) })
.then(variantsListResp => { .then(variantsListResp => {
secondVariantsList = variantsListResp; secondVariantsList = variantsListResp;
cy.checkIfDataAreNotNull({defaultChannel,address,warehouse,variantsList, secondVariantsList, attribute})
}); });
}); });

View file

@ -50,6 +50,7 @@ describe("As a user I should be able to update and delete shipping method", () =
createShippingZone(name, "US", defaultChannel.id, warehouse.id).then( createShippingZone(name, "US", defaultChannel.id, warehouse.id).then(
shippingZoneResp => { shippingZoneResp => {
shippingZone = shippingZoneResp; shippingZone = shippingZoneResp;
cy.checkIfDataAreNotNull({defaultChannel, shippingZone, shippingMethod, warehouse, usAddress})
}, },
); );
}); });

View file

@ -40,12 +40,12 @@ describe("As a user I should be able to update and delete shipping zone", () =>
warehouse = warehouseResp; warehouse = warehouseResp;
updateChannelWarehouses(defaultChannel.id, warehouse.id); updateChannelWarehouses(defaultChannel.id, warehouse.id);
cy.checkIfDataAreNotNull({defaultChannel, shippingZone, plAddress, warehouse})
}); });
}); });
}); });
beforeEach(() => { beforeEach(() => {
const rateName = `${startsWith}${faker.datatype.number()}`;
cy.clearSessionData().loginUserViaRequest(); cy.clearSessionData().loginUserViaRequest();
createShippingZone(name, "US", defaultChannel.id, warehouse.id).then( createShippingZone(name, "US", defaultChannel.id, warehouse.id).then(

View file

@ -83,6 +83,7 @@ describe("As a user I want to create shipping method with postal codes", () => {
}) })
.then(({ variantsList: variantsListResp }) => { .then(({ variantsList: variantsListResp }) => {
variantsList = variantsListResp; variantsList = variantsListResp;
cy.checkIfDataAreNotNull({defaultChannel,usAddress,secondUsAddress,shippingZone,warehouse,variantsList})
}); });
}); });

View file

@ -74,6 +74,7 @@ describe("As a staff user I want to manage shipping weights", () => {
}) })
.then(({ variantsList: variantsListResp }) => { .then(({ variantsList: variantsListResp }) => {
variantsList = variantsListResp; variantsList = variantsListResp;
cy.checkIfDataAreNotNull({defaultChannel,usAddress,shippingZone,warehouse,variantsList})
}); });
}); });

View file

@ -51,6 +51,7 @@ describe("As a staff user I want to change shop default weight unit", () => {
}) })
.then(shippingZoneResp => { .then(shippingZoneResp => {
shippingZone = shippingZoneResp; shippingZone = shippingZoneResp;
cy.checkIfDataAreNotNull({defaultChannel,usAddress,shippingZone,warehouse})
}); });
}); });

View file

@ -17,6 +17,7 @@ describe("Tests for site settings", () => {
cy.fixture("addresses").then(({ usAddress, plAddress }) => { cy.fixture("addresses").then(({ usAddress, plAddress }) => {
address = usAddress; address = usAddress;
updateShopAddress(plAddress); updateShopAddress(plAddress);
cy.checkIfDataAreNotNull(address)
}); });
}); });

View file

@ -35,6 +35,7 @@ describe("As an admin I want to manage warehouses", () => {
cy.fixture("addresses").then(addresses => { cy.fixture("addresses").then(addresses => {
usAddress = addresses.usAddress; usAddress = addresses.usAddress;
secondUsAddress = addresses.secondUsAddress; secondUsAddress = addresses.secondUsAddress;
cy.checkIfDataAreNotNull({usAddress,secondUsAddress})
}); });
}); });

View file

@ -25,6 +25,7 @@ describe("Tests for customer registration", () => {
deleteCustomersStartsWith(startsWith); deleteCustomersStartsWith(startsWith);
getDefaultChannel().then(channel => { getDefaultChannel().then(channel => {
defaultChannel = channel; defaultChannel = channel;
cy.checkIfDataAreNotNull({defaultChannel})
}); });
}); });

View file

@ -69,6 +69,7 @@ describe("As an admin I want to create sale for products", () => {
}) })
.then(({ warehouse: warehouseResp }) => { .then(({ warehouse: warehouseResp }) => {
warehouse = warehouseResp; warehouse = warehouseResp;
cy.checkIfDataAreNotNull({productType,attribute,category,defaultChannel,warehouse})
}); });
}); });

View file

@ -71,6 +71,7 @@ describe("Sales discounts for variant", () => {
warehouseId: warehouse.id, warehouseId: warehouse.id,
price: productPrice, price: productPrice,
}; };
cy.checkIfDataAreNotNull({productData, defaultChannel, warehouse, address})
}); });
}); });

View file

@ -82,6 +82,7 @@ describe("As an admin I want to update sales", () => {
warehouseId: warehouse.id, warehouseId: warehouse.id,
price: productPrice, price: productPrice,
}; };
cy.checkIfDataAreNotNull({productData, defaultChannel, warehouse, address, sale, variants})
}); });
}); });

View file

@ -53,6 +53,7 @@ describe("As an admin I want to create voucher", () => {
auth: "token", auth: "token",
}; };
}, },
cy.checkIfDataAreNotNull({createdChannel, dataForCheckout, defaultChannel})
); );
}); });

View file

@ -49,6 +49,7 @@ describe("As an admin I want to create voucher", () => {
shippingMethodName: shippingMethodResp.name, shippingMethodName: shippingMethodResp.name,
auth: "token", auth: "token",
}; };
cy.checkIfDataAreNotNull({dataForCheckout, defaultChannel})
cy.clearSessionData(); cy.clearSessionData();
}, },
); );

View file

@ -51,6 +51,7 @@ describe("As an admin I want to update vouchers", () => {
auth: "token", auth: "token",
}; };
}, },
cy.checkIfDataAreNotNull({dataForCheckout, defaultChannel, product})
); );
}); });

View file

@ -41,6 +41,7 @@ describe("Test for metadata", () => {
}) })
.then(({ product: productResp }) => { .then(({ product: productResp }) => {
product = productResp; product = productResp;
cy.checkIfDataAreNotNull({channel, product})
}); });
}); });

View file

@ -33,6 +33,7 @@ xdescribe("Channels in draft orders", () => {
}) })
.then(channelResp => { .then(channelResp => {
otherChannel = channelResp; otherChannel = channelResp;
cy.checkIfDataAreNotNull({ defaultChannel, otherChannel });
}); });
}); });

View file

@ -77,6 +77,7 @@ xdescribe("Draft orders", () => {
categoryId: categoryResp.id, categoryId: categoryResp.id,
}); });
}, },
cy.checkIfDataAreNotNull({ defaultChannel, warehouse, address }),
); );
}); });

View file

@ -67,6 +67,7 @@ describe("As an admin I want to manage stock reservation", () => {
productType = productTypeResp; productType = productTypeResp;
}, },
); );
cy.checkIfDataAreNotNull({defaultChannel,address,warehouse,attribute,category,productType,dataForCheckout})
}); });
}); });
}); });

View file

@ -105,6 +105,7 @@ describe("Orders", () => {
) )
.then(({ variantsList: variantsResp }) => { .then(({ variantsList: variantsResp }) => {
variantsList = variantsResp; variantsList = variantsResp;
cy.checkIfDataAreNotNull({customer,defaultChannel,warehouse,shippingMethod,variantsList,address})
}); });
}); });

View file

@ -40,7 +40,10 @@ describe("Tests for pages", () => {
attribute = attributeResp; attribute = attributeResp;
createPageType({ name, attributeId: attribute.id }); createPageType({ name, attributeId: attribute.id });
}) })
.then(({ pageType: pageTypeResp }) => (pageType = pageTypeResp)); .then(({ pageType: pageTypeResp }) => {
pageType = pageTypeResp;
cy.checkIfDataAreNotNull({ attribute, pageType });
});
}); });
beforeEach(() => { beforeEach(() => {

View file

@ -55,6 +55,7 @@ describe("As an admin I should be able to create product", () => {
cy.clearSessionData().loginUserViaRequest(); cy.clearSessionData().loginUserViaRequest();
createAttribute({ name }).then(attributeResp => { createAttribute({ name }).then(attributeResp => {
attribute = attributeResp; attribute = attributeResp;
cy.checkIfDataAreNotNull({attribute})
}); });
}); });
beforeEach(() => { beforeEach(() => {

View file

@ -53,6 +53,13 @@ describe("Products available in listings", () => {
productType = productTypeResp; productType = productTypeResp;
attribute = attributeResp; attribute = attributeResp;
category = categoryResp; category = categoryResp;
cy.checkIfDataAreNotNull({
productType,
attribute,
category,
defaultChannel,
warehouse,
});
}, },
); );
}); });

View file

@ -38,6 +38,12 @@ describe("Published products", () => {
) )
.then(channel => { .then(channel => {
defaultChannel = channel; defaultChannel = channel;
cy.checkIfDataAreNotNull({
productType,
attribute,
category,
defaultChannel,
});
}); });
}); });

View file

@ -37,6 +37,12 @@ describe("Products displayed in listings", () => {
) )
.then(channel => { .then(channel => {
defaultChannel = channel; defaultChannel = channel;
cy.checkIfDataAreNotNull({
productType,
attribute,
category,
defaultChannel,
});
}); });
}); });

View file

@ -80,6 +80,14 @@ describe("As an admin I should be able to filter products", () => {
}) })
.then(({ product: product }) => { .then(({ product: product }) => {
updateProduct(product.id, { collections: [collection.id] }); updateProduct(product.id, { collections: [collection.id] });
cy.checkIfDataAreNotNull({
attribute,
productType,
category,
warehouse,
channel,
collection,
});
}); });
}); });

View file

@ -27,6 +27,7 @@ describe("As an admin I should be able to sort products", () => {
cy.clearSessionData().loginUserViaRequest(); cy.clearSessionData().loginUserViaRequest();
getDefaultChannel().then(channel => { getDefaultChannel().then(channel => {
defaultChannel = channel; defaultChannel = channel;
cy.checkIfDataAreNotNull({defaultChannel})
}); });
}); });

View file

@ -48,7 +48,10 @@ describe("As an admin I should be able to create variant", () => {
createChannel({ isActive: true, name, currencyCode: "PLN" }); createChannel({ isActive: true, name, currencyCode: "PLN" });
}) })
.then(resp => (newChannel = resp)); .then(resp => {
newChannel = resp
cy.checkIfDataAreNotNull({defaultChannel,warehouse,attribute,productType,category,newChannel})
});
}); });
beforeEach(() => { beforeEach(() => {

View file

@ -86,6 +86,16 @@ describe("Creating variants", () => {
) )
.then(type => { .then(type => {
simpleProductType = type; simpleProductType = type;
cy.checkIfDataAreNotNull({
defaultChannel,
warehouse,
attribute,
productType,
simpleProductType,
category,
shippingMethod,
address,
});
}); });
}); });

View file

@ -73,7 +73,20 @@ describe("Updating products without sku", () => {
categoryId: category.id, categoryId: category.id,
}); });
}) })
.then(productResp => (product = productResp)); .then(productResp => {
product = productResp;
cy.checkIfDataAreNotNull({
defaultChannel,
address,
warehouse,
shippingMethod,
attribute,
category,
productTypeWithVariants,
productTypeWithoutVariants,
product,
});
});
}); });
beforeEach(() => { beforeEach(() => {

View file

@ -58,6 +58,12 @@ describe("Update products", () => {
}) })
.then(({ product: productResp }) => { .then(({ product: productResp }) => {
product = productResp; product = productResp;
cy.checkIfDataAreNotNull({
defaultChannel,
collection,
product,
attribute,
});
}); });
}); });

View file

@ -52,6 +52,7 @@ describe("Staff members", () => {
cy.clearSessionData().visit(urlLink); cy.clearSessionData().visit(urlLink);
fillUpSetPassword(password); fillUpSetPassword(password);
cy.clearSessionData(); cy.clearSessionData();
cy.checkIfDataAreNotNull({user})
}); });
}); });

View file

@ -21,7 +21,10 @@ describe("As an admin I want to manage translations", () => {
cy.clearSessionData().loginUserViaRequest(); cy.clearSessionData().loginUserViaRequest();
deleteCategoriesStartsWith(startsWith); deleteCategoriesStartsWith(startsWith);
createCategory({ name: startsWith }).then( createCategory({ name: startsWith }).then(
categoryResp => (category = categoryResp), categoryResp => {
category = categoryResp
cy.checkIfDataAreNotNull({category})
},
); );
}); });

View file

@ -17,3 +17,17 @@ Cypress.Commands.add("waitForRequestAndCheckIfNoErrors", alias => {
return resp; return resp;
}); });
}); });
Cypress.Commands.add("checkIfDataAreNotNull", (data) => {
expect(data, "Created data should not be null").to.be.not.null;
if(typeof data === "object"){
Object.keys(data).forEach(key => {
cy.checkIfDataAreNotNull(data[key])
})
}else if(Array.isArray(data)){
expect(data).not.to.be.empty;
data.forEach(singleData => {
cy.checkIfDataAreNotNull(singleData)
})
}
})