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,
});
})
.then(({ variantsList: variants }) => (variantsList = variants));
.then(({ variantsList: variants }) => {
variantsList = variants
cy.checkIfDataAreNotNull({createdApp,defaultChannel,address,warehouse,shippingMethod,variantsList,checkout})
});
});
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(() => {

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(() => {

View file

@ -63,6 +63,7 @@ describe("As a admin I want to use enabled gift card in checkout", () => {
shippingMethodName: resp.shippingMethod.name,
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 }) => {
variants = variantsResp;
cy.checkIfDataAreNotNull({defaultChannel, productType, attribute, category, shippingMethod, variants, address})
});
});

View file

@ -83,6 +83,7 @@ describe("Warehouses in checkout", () => {
})
.then(({ 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,
warehouseId: warehouse.id,
}).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;
digitalVariants = resp.digitalVariants;
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(
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 category;
let product;
before(() => {
cy.clearSessionData().loginUserViaRequest();
@ -33,6 +32,7 @@ describe("As an admin I want to use attributes in variant selection", () => {
getDefaultChannel().then(defaultChannel => (channel = defaultChannel));
createCategory({ name: startsWith }).then(
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 attributeValues = ["1", "2"];
let productType;
let product;
createProductTypeWithNewVariantSelectionAttribute({
name,

View file

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

View file

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

View file

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

View file

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

View file

@ -25,7 +25,10 @@ describe("Tests for menu navigation", () => {
cy.clearSessionData().loginUserViaRequest();
deleteMenusStartsWith(startsWith);
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,
});
})
.then(({ variantsList: variants }) => (variantsList = variants));
.then(({ variantsList: variants }) => {
variantsList = variants
cy.checkIfDataAreNotNull({address,defaultChannel,warehouse,shippingMethod,variantsList,checkout,paymentCards,cardData})
});
});
beforeEach(() => {

View file

@ -50,6 +50,7 @@ describe("Stripe payments", () => {
defaultChannel = values.defaultChannel;
shippingMethod = values.shippingMethod;
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();
deleteProductsStartsWith(startsWith);
createAttribute({ name: startsWith }).then(resp => (attribute = resp));
cy.checkIfDataAreNotNull(attribute);
});
beforeEach(() => {

View file

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

View file

@ -95,6 +95,7 @@ describe("As a staff user I want to create shipping zone and rate", () => {
})
.then(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(
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;
updateChannelWarehouses(defaultChannel.id, warehouse.id);
cy.checkIfDataAreNotNull({defaultChannel, shippingZone, plAddress, warehouse})
});
});
});
beforeEach(() => {
const rateName = `${startsWith}${faker.datatype.number()}`;
cy.clearSessionData().loginUserViaRequest();
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 }) => {
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 }) => {
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 => {
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 }) => {
address = usAddress;
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 => {
usAddress = addresses.usAddress;
secondUsAddress = addresses.secondUsAddress;
cy.checkIfDataAreNotNull({usAddress,secondUsAddress})
});
});

View file

@ -25,6 +25,7 @@ describe("Tests for customer registration", () => {
deleteCustomersStartsWith(startsWith);
getDefaultChannel().then(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 }) => {
warehouse = warehouseResp;
cy.checkIfDataAreNotNull({productType,attribute,category,defaultChannel,warehouse})
});
});

View file

@ -71,6 +71,7 @@ describe("Sales discounts for variant", () => {
warehouseId: warehouse.id,
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,
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",
};
},
cy.checkIfDataAreNotNull({createdChannel, dataForCheckout, defaultChannel})
);
});

View file

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

View file

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

View file

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

View file

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

View file

@ -77,6 +77,7 @@ xdescribe("Draft orders", () => {
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;
},
);
cy.checkIfDataAreNotNull({defaultChannel,address,warehouse,attribute,category,productType,dataForCheckout})
});
});
});

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -37,6 +37,12 @@ describe("Products displayed in listings", () => {
)
.then(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 }) => {
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();
getDefaultChannel().then(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" });
})
.then(resp => (newChannel = resp));
.then(resp => {
newChannel = resp
cy.checkIfDataAreNotNull({defaultChannel,warehouse,attribute,productType,category,newChannel})
});
});
beforeEach(() => {

View file

@ -86,6 +86,16 @@ describe("Creating variants", () => {
)
.then(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,
});
})
.then(productResp => (product = productResp));
.then(productResp => {
product = productResp;
cy.checkIfDataAreNotNull({
defaultChannel,
address,
warehouse,
shippingMethod,
attribute,
category,
productTypeWithVariants,
productTypeWithoutVariants,
product,
});
});
});
beforeEach(() => {

View file

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

View file

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

View file

@ -21,7 +21,10 @@ describe("As an admin I want to manage translations", () => {
cy.clearSessionData().loginUserViaRequest();
deleteCategoriesStartsWith(startsWith);
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;
});
});
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)
})
}
})