2021-04-01 12:33:36 +00:00
|
|
|
const { softExpect } = chai;
|
|
|
|
export function expectCorrectProductInformation(productResp, productData) {
|
|
|
|
expectCorrectGeneralInformation(productResp, productData.generalInfo);
|
|
|
|
expectCorrectSeoInfo(productResp, productData.seo);
|
|
|
|
expectCorrectMetadataInfo(productResp.metadata, productData.metadata.public);
|
|
|
|
expectCorrectMetadataInfo(
|
|
|
|
productResp.privateMetadata,
|
|
|
|
productData.metadata.private
|
|
|
|
);
|
|
|
|
expectCorrectProductOrgInfo(productResp, productData.productOrganization);
|
|
|
|
expectCorrectAttribute(productResp.attributes, productData.attribute);
|
|
|
|
}
|
|
|
|
export function expectCorrectProductVariantInformation(
|
|
|
|
variantsResp,
|
|
|
|
variantName,
|
|
|
|
prices
|
|
|
|
) {
|
|
|
|
softExpect(
|
|
|
|
expect(variantsResp).to.have.length(1),
|
|
|
|
softExpect(variantsResp[0].sku).to.be.eq(variantName),
|
|
|
|
softExpect(variantsResp[0].channelListings[0].costPrice.amount).to.be.eq(
|
|
|
|
prices.costPrice
|
|
|
|
),
|
|
|
|
softExpect(variantsResp[0].channelListings[0].price.amount).to.be.eq(
|
|
|
|
prices.sellingPrice
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
function expectCorrectGeneralInformation(productResp, generalInfo) {
|
2021-04-21 08:02:48 +00:00
|
|
|
softExpect(productResp.name, "Check product name").to.be.eq(generalInfo.name);
|
|
|
|
softExpect(productResp.description, "Check product description").includes(
|
|
|
|
generalInfo.description
|
|
|
|
);
|
|
|
|
softExpect(productResp.rating, "Check product rate").to.be.eq(
|
|
|
|
generalInfo.rating
|
|
|
|
);
|
2021-04-01 12:33:36 +00:00
|
|
|
}
|
|
|
|
function expectCorrectSeoInfo(productResp, seo) {
|
2021-04-21 08:02:48 +00:00
|
|
|
softExpect(productResp.slug, "Check product slug").to.be.eq(seo.slug);
|
|
|
|
softExpect(productResp.seoTitle, "Check product seo title").to.be.eq(
|
|
|
|
seo.title
|
|
|
|
);
|
|
|
|
softExpect(
|
|
|
|
productResp.seoDescription,
|
|
|
|
"Check product seo description"
|
|
|
|
).to.be.eq(seo.description);
|
2021-04-01 12:33:36 +00:00
|
|
|
}
|
|
|
|
function expectCorrectMetadataInfo(metadataResp, expectedMetadata) {
|
|
|
|
softExpect(
|
2021-04-21 08:02:48 +00:00
|
|
|
expect(metadataResp, "Check metadata fields length").to.have.length(1),
|
|
|
|
softExpect(metadataResp[0].key, "Check product metadata key").to.be.eq(
|
|
|
|
expectedMetadata.name
|
|
|
|
),
|
|
|
|
softExpect(metadataResp[0].value, "Check product metadata value").to.be.eq(
|
|
|
|
expectedMetadata.value
|
|
|
|
)
|
2021-04-01 12:33:36 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
function expectCorrectProductOrgInfo(productResp, productOrganization) {
|
2021-04-21 08:02:48 +00:00
|
|
|
softExpect(productResp.productType.name, "Check product type name").to.be.eq(
|
2021-04-01 12:33:36 +00:00
|
|
|
productOrganization.productType
|
|
|
|
);
|
2021-04-21 08:02:48 +00:00
|
|
|
softExpect(productResp.category.name, "Check category name").to.be.eq(
|
|
|
|
productOrganization.category
|
|
|
|
);
|
2021-04-01 12:33:36 +00:00
|
|
|
softExpect(
|
2021-04-21 08:02:48 +00:00
|
|
|
expect(
|
|
|
|
productResp.collections,
|
|
|
|
"Check length of assigned collections"
|
|
|
|
).to.have.length(1),
|
|
|
|
softExpect(
|
|
|
|
productResp.collections[0].name,
|
|
|
|
"Check collection name"
|
|
|
|
).to.be.eq(productOrganization.collection)
|
2021-04-01 12:33:36 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
function expectCorrectAttribute(attributes, attribute) {
|
|
|
|
softExpect(
|
|
|
|
expect(attributes).to.have.length(1),
|
2021-04-21 08:02:48 +00:00
|
|
|
softExpect(attributes[0].attribute.name, "Check attribute name").to.be.eq(
|
|
|
|
attribute.name
|
|
|
|
)
|
2021-04-01 12:33:36 +00:00
|
|
|
);
|
|
|
|
}
|