tests for collections
This commit is contained in:
parent
dfdf43fed5
commit
af059da41b
3 changed files with 44 additions and 42 deletions
|
@ -15,7 +15,7 @@ class Collections {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}`;
|
}`;
|
||||||
return cy.sendFrontShopRequestWithQuery(query);
|
return cy.sendRequestWithQuery(query, "token");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
export default Collections;
|
export default Collections;
|
||||||
|
|
|
@ -8,16 +8,17 @@ import ChannelsUtils from "../utils/channelsUtils";
|
||||||
import CollectionsUtils from "../utils/collectionsUtils";
|
import CollectionsUtils from "../utils/collectionsUtils";
|
||||||
import ProductsUtils from "../utils/productsUtils";
|
import ProductsUtils from "../utils/productsUtils";
|
||||||
import ShippingUtils from "../utils/shippingUtils";
|
import ShippingUtils from "../utils/shippingUtils";
|
||||||
import StoreFrontCollectionUtils from "../utils/storeFront/collectionsUtils";
|
import {
|
||||||
import StoreFrontProductUtils from "../utils/storeFront/storeFrontProductUtils";
|
isCollectionVisible,
|
||||||
|
isProductInCollectionVisible
|
||||||
|
} from "../utils/storeFront/collectionsUtils";
|
||||||
|
import { isProductVisibleInSearchResult } from "../utils/storeFront/storeFrontProductUtils";
|
||||||
|
|
||||||
describe("Collections", () => {
|
describe("Collections", () => {
|
||||||
const productRequest = new Product();
|
const productRequest = new Product();
|
||||||
const channelsUtils = new ChannelsUtils();
|
const channelsUtils = new ChannelsUtils();
|
||||||
const productsUtils = new ProductsUtils();
|
const productsUtils = new ProductsUtils();
|
||||||
const storeFrontProductUtils = new StoreFrontProductUtils();
|
|
||||||
const collectionsUtils = new CollectionsUtils();
|
const collectionsUtils = new CollectionsUtils();
|
||||||
const storeFrontCollectionUtils = new StoreFrontCollectionUtils();
|
|
||||||
const shippingUtils = new ShippingUtils();
|
const shippingUtils = new ShippingUtils();
|
||||||
const collectionsSteps = new CollectionsSteps();
|
const collectionsSteps = new CollectionsSteps();
|
||||||
|
|
||||||
|
@ -63,15 +64,16 @@ describe("Collections", () => {
|
||||||
it("should not display hidden collections", () => {
|
it("should not display hidden collections", () => {
|
||||||
const collectionName = `${startsWith}${faker.random.number()}`;
|
const collectionName = `${startsWith}${faker.random.number()}`;
|
||||||
cy.visit(urlList.collections);
|
cy.visit(urlList.collections);
|
||||||
|
let collection;
|
||||||
|
|
||||||
collectionsSteps
|
collectionsSteps
|
||||||
.createCollection(collectionName, false, defaultChannel)
|
.createCollection(collectionName, false, defaultChannel)
|
||||||
.then(collection => {
|
.then(collectionResp => {
|
||||||
|
collection = collectionResp;
|
||||||
collectionsSteps.assignProductsToCollection(name);
|
collectionsSteps.assignProductsToCollection(name);
|
||||||
storeFrontCollectionUtils.isCollectionVisible(
|
})
|
||||||
collection.id,
|
.then(() => {
|
||||||
defaultChannel.slug
|
isCollectionVisible(collection.id, defaultChannel.slug);
|
||||||
);
|
|
||||||
})
|
})
|
||||||
.then(isVisible => expect(isVisible).to.equal(false));
|
.then(isVisible => expect(isVisible).to.equal(false));
|
||||||
});
|
});
|
||||||
|
@ -84,10 +86,7 @@ describe("Collections", () => {
|
||||||
.createCollection(collectionName, true, defaultChannel)
|
.createCollection(collectionName, true, defaultChannel)
|
||||||
.then(collection => {
|
.then(collection => {
|
||||||
collectionsSteps.assignProductsToCollection(name);
|
collectionsSteps.assignProductsToCollection(name);
|
||||||
storeFrontCollectionUtils.isCollectionVisible(
|
isCollectionVisible(collection.id, defaultChannel.slug);
|
||||||
collection.id,
|
|
||||||
defaultChannel.slug
|
|
||||||
);
|
|
||||||
})
|
})
|
||||||
.then(isVisible => expect(isVisible).to.equal(true));
|
.then(isVisible => expect(isVisible).to.equal(true));
|
||||||
});
|
});
|
||||||
|
@ -111,16 +110,15 @@ describe("Collections", () => {
|
||||||
})
|
})
|
||||||
.then(collection => {
|
.then(collection => {
|
||||||
collectionsSteps.assignProductsToCollection(name);
|
collectionsSteps.assignProductsToCollection(name);
|
||||||
storeFrontCollectionUtils.isCollectionVisible(
|
isCollectionVisible(collection.id, defaultChannel.slug);
|
||||||
collection.id,
|
|
||||||
defaultChannel.slug
|
|
||||||
);
|
|
||||||
})
|
})
|
||||||
.then(isVisible => expect(isVisible).to.equal(false));
|
.then(isVisible => expect(isVisible).to.equal(false));
|
||||||
});
|
});
|
||||||
it("should display products hidden in listing, only in collection", () => {
|
it("should display products hidden in listing, only in collection", () => {
|
||||||
const randomName = `${startsWith}${faker.random.number()}`;
|
const randomName = `${startsWith}${faker.random.number()}`;
|
||||||
const hiddenProductUtils = new ProductsUtils();
|
const hiddenProductUtils = new ProductsUtils();
|
||||||
|
let collection;
|
||||||
|
|
||||||
hiddenProductUtils.createProductInChannel({
|
hiddenProductUtils.createProductInChannel({
|
||||||
name: randomName,
|
name: randomName,
|
||||||
channelId: defaultChannel.id,
|
channelId: defaultChannel.id,
|
||||||
|
@ -132,9 +130,12 @@ describe("Collections", () => {
|
||||||
cy.visit(urlList.collections);
|
cy.visit(urlList.collections);
|
||||||
collectionsSteps
|
collectionsSteps
|
||||||
.createCollection(randomName, true, defaultChannel)
|
.createCollection(randomName, true, defaultChannel)
|
||||||
.then(collection => {
|
.then(collectionResp => {
|
||||||
|
collection = collectionResp;
|
||||||
collectionsSteps.assignProductsToCollection(randomName);
|
collectionsSteps.assignProductsToCollection(randomName);
|
||||||
storeFrontCollectionUtils.isProductInCollectionVisible(
|
})
|
||||||
|
.then(() => {
|
||||||
|
isProductInCollectionVisible(
|
||||||
collection.id,
|
collection.id,
|
||||||
defaultChannel.slug,
|
defaultChannel.slug,
|
||||||
hiddenProductUtils.getCreatedProduct().id
|
hiddenProductUtils.getCreatedProduct().id
|
||||||
|
@ -142,7 +143,7 @@ describe("Collections", () => {
|
||||||
})
|
})
|
||||||
.then(isVisible => {
|
.then(isVisible => {
|
||||||
expect(isVisible).to.equal(true);
|
expect(isVisible).to.equal(true);
|
||||||
storeFrontProductUtils.isProductVisibleInSearchResult(
|
isProductVisibleInSearchResult(
|
||||||
hiddenProductUtils.getCreatedProduct().name,
|
hiddenProductUtils.getCreatedProduct().name,
|
||||||
defaultChannel.slug
|
defaultChannel.slug
|
||||||
);
|
);
|
||||||
|
|
|
@ -1,23 +1,24 @@
|
||||||
import Collections from "../../apiRequests/storeFront/Collections";
|
import Collections from "../../apiRequests/storeFront/Collections";
|
||||||
|
|
||||||
class CollectionsUtils {
|
export const isCollectionVisible = (collectionId, channelSlug) => {
|
||||||
collectionsRequest = new Collections();
|
const collectionsRequest = new Collections();
|
||||||
|
return collectionsRequest
|
||||||
isCollectionVisible(collectionId, channelSlug) {
|
.getCollection(collectionId, channelSlug)
|
||||||
return this.collectionsRequest
|
.then(resp => {
|
||||||
.getCollection(collectionId, channelSlug)
|
const collection = resp.body.data.collection;
|
||||||
.then(resp => {
|
return collection !== null && collection.id === collectionId;
|
||||||
const collection = resp.body.data.collection;
|
});
|
||||||
return collection !== null && collection.id === collectionId;
|
};
|
||||||
});
|
export const isProductInCollectionVisible = (
|
||||||
}
|
collectionId,
|
||||||
isProductInCollectionVisible(collectionId, channelSlug, productId) {
|
channelSlug,
|
||||||
return this.collectionsRequest
|
productId
|
||||||
.getCollection(collectionId, channelSlug)
|
) => {
|
||||||
.then(resp => {
|
const collectionsRequest = new Collections();
|
||||||
const product = resp.body.data.collection.products.edges[0].node;
|
return collectionsRequest
|
||||||
return product !== null && product.id === productId;
|
.getCollection(collectionId, channelSlug)
|
||||||
});
|
.then(resp => {
|
||||||
}
|
const product = resp.body.data.collection.products.edges[0].node;
|
||||||
}
|
return product !== null && product.id === productId;
|
||||||
export default CollectionsUtils;
|
});
|
||||||
|
};
|
||||||
|
|
Loading…
Reference in a new issue