Saleor 7780 fix for collection tests (#2227)
* fix fox tests in collection * removing then() in tests * fixing failing collection tests and add stable tag to run will all tests
This commit is contained in:
parent
2c57de07e4
commit
29c7f785c0
6 changed files with 370 additions and 354 deletions
|
@ -8,6 +8,7 @@ import { BUTTON_SELECTORS } from "../../elements/shared/button-selectors";
|
||||||
import { collectionDetailsUrl, urlList } from "../../fixtures/urlList";
|
import { collectionDetailsUrl, urlList } from "../../fixtures/urlList";
|
||||||
import { createChannel } from "../../support/api/requests/Channels";
|
import { createChannel } from "../../support/api/requests/Channels";
|
||||||
import {
|
import {
|
||||||
|
addChannelToCollection,
|
||||||
addProductToCollection,
|
addProductToCollection,
|
||||||
createCollection as createCollectionRequest,
|
createCollection as createCollectionRequest,
|
||||||
} from "../../support/api/requests/Collections";
|
} from "../../support/api/requests/Collections";
|
||||||
|
@ -19,12 +20,6 @@ import { deleteCollectionsStartsWith } from "../../support/api/utils/catalog/col
|
||||||
import * as channelsUtils from "../../support/api/utils/channelsUtils";
|
import * as channelsUtils from "../../support/api/utils/channelsUtils";
|
||||||
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 {
|
|
||||||
isCollectionVisible,
|
|
||||||
isProductInCollectionVisible,
|
|
||||||
} from "../../support/api/utils/storeFront/collectionsUtils";
|
|
||||||
import { isProductVisibleInSearchResult } from "../../support/api/utils/storeFront/storeFrontProductUtils";
|
|
||||||
import filterTests from "../../support/filterTests";
|
|
||||||
import {
|
import {
|
||||||
assignProductsToCollection,
|
assignProductsToCollection,
|
||||||
createCollection,
|
createCollection,
|
||||||
|
@ -32,16 +27,14 @@ import {
|
||||||
updateCollection,
|
updateCollection,
|
||||||
} from "../../support/pages/catalog/collectionsPage";
|
} from "../../support/pages/catalog/collectionsPage";
|
||||||
|
|
||||||
filterTests({ definedTags: ["all"] }, () => {
|
describe("As an admin I want to manage collections.", () => {
|
||||||
describe("As an admin I want to manage collections.", () => {
|
|
||||||
const startsWith = "CyCollections-";
|
const startsWith = "CyCollections-";
|
||||||
const name = `${startsWith}${faker.datatype.number()}`;
|
const productName = `${startsWith}${faker.datatype.number()}`;
|
||||||
|
|
||||||
let attribute;
|
let attribute;
|
||||||
let productType;
|
let productType;
|
||||||
let category;
|
let category;
|
||||||
let product;
|
let product;
|
||||||
|
|
||||||
let defaultChannel;
|
let defaultChannel;
|
||||||
|
|
||||||
before(() => {
|
before(() => {
|
||||||
|
@ -55,7 +48,9 @@ filterTests({ definedTags: ["all"] }, () => {
|
||||||
.getDefaultChannel()
|
.getDefaultChannel()
|
||||||
.then(channel => {
|
.then(channel => {
|
||||||
defaultChannel = channel;
|
defaultChannel = channel;
|
||||||
productsUtils.createTypeAttributeAndCategoryForProduct({ name });
|
productsUtils.createTypeAttributeAndCategoryForProduct({
|
||||||
|
name: productName,
|
||||||
|
});
|
||||||
})
|
})
|
||||||
.then(
|
.then(
|
||||||
({
|
({
|
||||||
|
@ -67,7 +62,7 @@ filterTests({ definedTags: ["all"] }, () => {
|
||||||
productType = productTypeResp;
|
productType = productTypeResp;
|
||||||
category = categoryResp;
|
category = categoryResp;
|
||||||
productsUtils.createProductInChannel({
|
productsUtils.createProductInChannel({
|
||||||
name,
|
name: productName,
|
||||||
channelId: defaultChannel.id,
|
channelId: defaultChannel.id,
|
||||||
productTypeId: productType.id,
|
productTypeId: productType.id,
|
||||||
attributeId: attribute.id,
|
attributeId: attribute.id,
|
||||||
|
@ -82,31 +77,27 @@ filterTests({ definedTags: ["all"] }, () => {
|
||||||
cy.clearSessionData().loginUserViaRequest();
|
cy.clearSessionData().loginUserViaRequest();
|
||||||
});
|
});
|
||||||
|
|
||||||
xit(
|
it(
|
||||||
"should create hidden collection. TC: SALEOR_0301",
|
"should create hidden collection. TC: SALEOR_0301",
|
||||||
{ tags: ["@collection", "@allEnv"] },
|
{ tags: ["@collection", "@allEnv", "@stable"] },
|
||||||
() => {
|
() => {
|
||||||
const collectionName = `${startsWith}${faker.datatype.number()}`;
|
const collectionName = `${startsWith}${faker.datatype.number()}`;
|
||||||
let collection;
|
let collection;
|
||||||
|
|
||||||
cy.visit(urlList.collections);
|
cy.visit(urlList.collections).expectSkeletonIsVisible();
|
||||||
cy.expectSkeletonIsVisible();
|
createCollection(collectionName, false, defaultChannel).then(
|
||||||
|
collectionResp => {
|
||||||
createCollection(collectionName, false, defaultChannel)
|
|
||||||
.then(collectionResp => {
|
|
||||||
collection = collectionResp;
|
collection = collectionResp;
|
||||||
assignProductsToCollection(name);
|
|
||||||
})
|
assignProductsToCollection(productName);
|
||||||
.then(() => {
|
|
||||||
getCollection({
|
getCollection({
|
||||||
collectionId: collection.id,
|
collectionId: collection.id,
|
||||||
channelSlug: defaultChannel.slug,
|
channelSlug: defaultChannel.slug,
|
||||||
});
|
|
||||||
})
|
})
|
||||||
.then(({ collection: resp }) => {
|
.its("collection.channelListings.0.isPublished")
|
||||||
const isVisible = isCollectionVisible(resp, collection.id);
|
.should("eq", false);
|
||||||
expect(isVisible).to.equal(false);
|
},
|
||||||
});
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -117,60 +108,55 @@ filterTests({ definedTags: ["all"] }, () => {
|
||||||
const collectionName = `${startsWith}${faker.datatype.number()}`;
|
const collectionName = `${startsWith}${faker.datatype.number()}`;
|
||||||
let collection;
|
let collection;
|
||||||
|
|
||||||
cy.visit(urlList.collections);
|
cy.visit(urlList.collections).expectSkeletonIsVisible();
|
||||||
cy.expectSkeletonIsVisible();
|
createCollection(collectionName, true, defaultChannel).then(
|
||||||
|
collectionResp => {
|
||||||
createCollection(collectionName, true, defaultChannel)
|
|
||||||
.then(collectionResp => {
|
|
||||||
collection = collectionResp;
|
collection = collectionResp;
|
||||||
assignProductsToCollection(name);
|
|
||||||
|
assignProductsToCollection(productName);
|
||||||
getCollection({
|
getCollection({
|
||||||
collectionId: collection.id,
|
collectionId: collection.id,
|
||||||
channelSlug: defaultChannel.slug,
|
channelSlug: defaultChannel.slug,
|
||||||
});
|
|
||||||
})
|
})
|
||||||
.then(({ collection: resp }) => {
|
.its("collection.channelListings.0.isPublished")
|
||||||
const isVisible = isCollectionVisible(resp, collection.id);
|
.should("eq", true);
|
||||||
expect(isVisible).to.equal(true);
|
},
|
||||||
});
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
it(
|
it(
|
||||||
"create collection not available for channel. TC: SALEOR_0303",
|
"should create collection not available for channel. TC: SALEOR_0303",
|
||||||
{ tags: ["@collection", "@allEnv", "@stable"] },
|
{ tags: ["@collection", "@allEnv", "@stable"] },
|
||||||
() => {
|
() => {
|
||||||
const collectionName = `${startsWith}${faker.datatype.number()}`;
|
const collectionName = `${startsWith}${faker.datatype.number()}`;
|
||||||
let collection;
|
let collection;
|
||||||
let channel;
|
let channel;
|
||||||
|
|
||||||
createChannel({ name: collectionName })
|
createChannel({ name: collectionName }).then(channelResp => {
|
||||||
.then(channelResp => {
|
|
||||||
channel = channelResp;
|
channel = channelResp;
|
||||||
|
|
||||||
updateChannelInProduct(product.id, channel.id);
|
updateChannelInProduct(product.id, channel.id);
|
||||||
})
|
cy.visit(urlList.collections).expectSkeletonIsVisible();
|
||||||
.then(() => {
|
createCollection(collectionName, false, channel).then(
|
||||||
cy.visit(urlList.collections);
|
collectionResp => {
|
||||||
cy.expectSkeletonIsVisible();
|
|
||||||
createCollection(collectionName, true, channel);
|
|
||||||
})
|
|
||||||
.then(collectionResp => {
|
|
||||||
collection = collectionResp;
|
collection = collectionResp;
|
||||||
assignProductsToCollection(name);
|
|
||||||
|
assignProductsToCollection(productName);
|
||||||
getCollection({
|
getCollection({
|
||||||
collectionId: collection.id,
|
collectionId: collection.id,
|
||||||
channelSlug: defaultChannel.slug,
|
channelSlug: defaultChannel.slug,
|
||||||
});
|
|
||||||
})
|
})
|
||||||
.then(({ collection: resp }) => {
|
.its("collection")
|
||||||
const isVisible = isCollectionVisible(resp, collection.id);
|
.should("be.null");
|
||||||
expect(isVisible).to.equal(false);
|
},
|
||||||
|
);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
it(
|
it(
|
||||||
"create published collection with products hidden in listings. TC: SALEOR_0304",
|
"should create published collection with products hidden in listings. TC: SALEOR_0304",
|
||||||
{ tags: ["@collection", "@allEnv", "@stable"] },
|
{ tags: ["@collection", "@allEnv", "@stable"] },
|
||||||
() => {
|
() => {
|
||||||
// Products "hidden in listings" are not displayed in Category listings or search results,
|
// Products "hidden in listings" are not displayed in Category listings or search results,
|
||||||
|
@ -189,36 +175,24 @@ filterTests({ definedTags: ["all"] }, () => {
|
||||||
visibleInListings: false,
|
visibleInListings: false,
|
||||||
})
|
})
|
||||||
.then(({ product: productResp }) => (createdProduct = productResp));
|
.then(({ product: productResp }) => (createdProduct = productResp));
|
||||||
cy.visit(urlList.collections);
|
|
||||||
cy.expectSkeletonIsVisible();
|
cy.visit(urlList.collections).expectSkeletonIsVisible();
|
||||||
createCollection(collectionName, true, defaultChannel)
|
createCollection(collectionName, true, defaultChannel).then(
|
||||||
.then(collectionResp => {
|
collectionResp => {
|
||||||
collection = collectionResp;
|
collection = collectionResp;
|
||||||
|
|
||||||
assignProductsToCollection(collectionName);
|
assignProductsToCollection(collectionName);
|
||||||
})
|
|
||||||
.then(() => {
|
|
||||||
getCollection({
|
getCollection({
|
||||||
collectionId: collection.id,
|
collectionId: collection.id,
|
||||||
channelSlug: defaultChannel.slug,
|
channelSlug: defaultChannel.slug,
|
||||||
});
|
|
||||||
})
|
})
|
||||||
.then(({ collection: resp }) => {
|
.its("collection.products.edges.0.node.id")
|
||||||
const isVisible = isProductInCollectionVisible(
|
.should("eq", createdProduct.id);
|
||||||
resp,
|
searchInShop(createdProduct.name)
|
||||||
createdProduct.id,
|
.its("body.data.products.edges")
|
||||||
|
.should("be.empty");
|
||||||
|
},
|
||||||
);
|
);
|
||||||
expect(isVisible).to.equal(true);
|
|
||||||
})
|
|
||||||
.then(() => {
|
|
||||||
searchInShop(createdProduct.name);
|
|
||||||
})
|
|
||||||
.then(resp => {
|
|
||||||
const isVisible = isProductVisibleInSearchResult(
|
|
||||||
resp,
|
|
||||||
createdProduct.name,
|
|
||||||
);
|
|
||||||
expect(isVisible).to.equal(false);
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -236,7 +210,7 @@ filterTests({ definedTags: ["all"] }, () => {
|
||||||
.get(BUTTON_SELECTORS.submit)
|
.get(BUTTON_SELECTORS.submit)
|
||||||
.click()
|
.click()
|
||||||
.waitForRequestAndCheckIfNoErrors("@RemoveCollection");
|
.waitForRequestAndCheckIfNoErrors("@RemoveCollection");
|
||||||
getCollection({ collectionId: collectionResp.id, auth: "auth" })
|
getCollection({ collectionId: collectionResp.id })
|
||||||
.its("collection")
|
.its("collection")
|
||||||
.should("be.null");
|
.should("be.null");
|
||||||
});
|
});
|
||||||
|
@ -244,49 +218,40 @@ filterTests({ definedTags: ["all"] }, () => {
|
||||||
);
|
);
|
||||||
|
|
||||||
it(
|
it(
|
||||||
"delete several collections on collections list page. TC: SALEOR_0309",
|
"should update collection. TC: SALEOR_0306",
|
||||||
{ tags: ["@collection", "@allEnv"] },
|
{ tags: ["@collection", "@allEnv", "@stable"] },
|
||||||
() => {
|
() => {
|
||||||
const deleteSeveral = "delete-several-";
|
const collectionName = `${startsWith}${faker.datatype.number()}`;
|
||||||
const firstCollectionName = `${deleteSeveral}${startsWith}${faker.datatype.number()}`;
|
const updatedName = `${startsWith}updatedCollection`;
|
||||||
const secondCollectionName = `${deleteSeveral}${startsWith}${faker.datatype.number()}`;
|
|
||||||
let firstCollection;
|
|
||||||
let secondCollection;
|
|
||||||
|
|
||||||
createCollectionRequest(firstCollectionName).then(collectionResp => {
|
let collection;
|
||||||
firstCollection = collectionResp;
|
|
||||||
|
createCollectionRequest(collectionName).then(collectionResp => {
|
||||||
|
collection = collectionResp;
|
||||||
|
|
||||||
|
cy.visitAndWaitForProgressBarToDisappear(
|
||||||
|
collectionDetailsUrl(collection.id),
|
||||||
|
);
|
||||||
|
addChannelToCollection({
|
||||||
|
collectionId: collection.id,
|
||||||
|
channelId: defaultChannel.id,
|
||||||
});
|
});
|
||||||
|
updateCollection({ name: updatedName, description: updatedName });
|
||||||
createCollectionRequest(secondCollectionName).then(collectionResp => {
|
getCollection({
|
||||||
secondCollection = collectionResp;
|
collectionId: collection.id,
|
||||||
cy.visit(urlList.collections)
|
channelSlug: defaultChannel.slug,
|
||||||
.searchInTable(deleteSeveral)
|
})
|
||||||
.get(collectionRow(firstCollection.id))
|
|
||||||
.find(BUTTON_SELECTORS.checkbox)
|
|
||||||
.click()
|
|
||||||
.get(collectionRow(secondCollection.id))
|
|
||||||
.find(BUTTON_SELECTORS.checkbox)
|
|
||||||
.click()
|
|
||||||
.get(BUTTON_SELECTORS.deleteIcon)
|
|
||||||
.click()
|
|
||||||
.addAliasToGraphRequest("CollectionBulkDelete")
|
|
||||||
.get(BUTTON_SELECTORS.submit)
|
|
||||||
.click()
|
|
||||||
.waitForRequestAndCheckIfNoErrors("@CollectionBulkDelete");
|
|
||||||
|
|
||||||
getCollection({ collectionId: firstCollection.id, auth: "auth" })
|
|
||||||
.its("collection")
|
.its("collection")
|
||||||
.should("be.null");
|
.should("include", { name: updatedName })
|
||||||
getCollection({ collectionId: secondCollection.id, auth: "auth" })
|
.its("description")
|
||||||
.its("collection")
|
.should("have.string", `{"text": "${updatedName}"}`);
|
||||||
.should("be.null");
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
xit(
|
it(
|
||||||
"should assign product to collection. TC: SALEOR_0307",
|
"should assign product to collection. TC: SALEOR_0307",
|
||||||
{ tags: ["@collection", "@allEnv"] },
|
{ tags: ["@collection", "@allEnv", "@stable"] },
|
||||||
() => {
|
() => {
|
||||||
const collectionName = `Assign-${startsWith}${faker.datatype.number()}`;
|
const collectionName = `Assign-${startsWith}${faker.datatype.number()}`;
|
||||||
const productName = `Product-To-Assign-${startsWith}${faker.datatype.number()}`;
|
const productName = `Product-To-Assign-${startsWith}${faker.datatype.number()}`;
|
||||||
|
@ -297,6 +262,10 @@ filterTests({ definedTags: ["all"] }, () => {
|
||||||
createCollectionRequest(collectionName).then(collectionResp => {
|
createCollectionRequest(collectionName).then(collectionResp => {
|
||||||
collection = collectionResp;
|
collection = collectionResp;
|
||||||
|
|
||||||
|
addChannelToCollection({
|
||||||
|
collectionId: collection.id,
|
||||||
|
channelId: defaultChannel.id,
|
||||||
|
});
|
||||||
productsUtils
|
productsUtils
|
||||||
.createProductInChannel({
|
.createProductInChannel({
|
||||||
name: productName,
|
name: productName,
|
||||||
|
@ -309,23 +278,25 @@ filterTests({ definedTags: ["all"] }, () => {
|
||||||
.then(({ product: productResp }) => {
|
.then(({ product: productResp }) => {
|
||||||
productToAssign = productResp;
|
productToAssign = productResp;
|
||||||
|
|
||||||
cy.visit(collectionDetailsUrl(collection.id));
|
cy.visitAndWaitForProgressBarToDisappear(
|
||||||
|
collectionDetailsUrl(collection.id),
|
||||||
|
);
|
||||||
|
cy.reload();
|
||||||
assignProductsToCollection(productToAssign.name);
|
assignProductsToCollection(productToAssign.name);
|
||||||
|
getCollection({
|
||||||
getCollection({ collectionId: collection.id, auth: "auth" })
|
collectionId: collection.id,
|
||||||
.its("collection.products.edges")
|
channelSlug: defaultChannel.slug,
|
||||||
.should("have.length", 1)
|
})
|
||||||
.then(productArray => {
|
.its("collection.products.edges.0.node.id")
|
||||||
expect(productArray[0].node.id).to.equal(productToAssign.id);
|
.should("include", productToAssign.id);
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
it(
|
it(
|
||||||
"remove product from collection. TC: SALEOR_0308",
|
"should remove product from collection. TC: SALEOR_0308",
|
||||||
{ tags: ["@collection", "@allEnv"] },
|
{ tags: ["@collection", "@allEnv", "@stable"] },
|
||||||
() => {
|
() => {
|
||||||
const collectionName = `Remove-With-Assigned-Product-${startsWith}${faker.datatype.number()}`;
|
const collectionName = `Remove-With-Assigned-Product-${startsWith}${faker.datatype.number()}`;
|
||||||
const productName = `Product-To-Assign-${startsWith}${faker.datatype.number()}`;
|
const productName = `Product-To-Assign-${startsWith}${faker.datatype.number()}`;
|
||||||
|
@ -335,6 +306,10 @@ filterTests({ definedTags: ["all"] }, () => {
|
||||||
createCollectionRequest(collectionName).then(collectionResp => {
|
createCollectionRequest(collectionName).then(collectionResp => {
|
||||||
collection = collectionResp;
|
collection = collectionResp;
|
||||||
|
|
||||||
|
addChannelToCollection({
|
||||||
|
collectionId: collection.id,
|
||||||
|
channelId: defaultChannel.id,
|
||||||
|
});
|
||||||
productsUtils
|
productsUtils
|
||||||
.createProductInChannel({
|
.createProductInChannel({
|
||||||
name: productName,
|
name: productName,
|
||||||
|
@ -351,20 +326,23 @@ filterTests({ definedTags: ["all"] }, () => {
|
||||||
collectionId: collection.id,
|
collectionId: collection.id,
|
||||||
productId: productToAssign.id,
|
productId: productToAssign.id,
|
||||||
});
|
});
|
||||||
|
cy.visitAndWaitForProgressBarToDisappear(
|
||||||
cy.visit(collectionDetailsUrl(collection.id));
|
collectionDetailsUrl(collection.id),
|
||||||
|
);
|
||||||
getProductDetails(productToAssign.id, defaultChannel.slug, "auth")
|
getProductDetails(productToAssign.id, defaultChannel.slug)
|
||||||
.its("body.data.product.collections")
|
.its("body.data.product.collections")
|
||||||
.should("have.length", 1);
|
.should("have.length", 1);
|
||||||
|
getCollection({
|
||||||
getCollection({ collectionId: collection.id, auth: "auth" })
|
collectionId: collection.id,
|
||||||
|
channelSlug: defaultChannel.slug,
|
||||||
|
})
|
||||||
.its("collection.products.edges")
|
.its("collection.products.edges")
|
||||||
.should("have.length", 1);
|
.should("have.length", 1);
|
||||||
|
|
||||||
removeProductsFromCollection(productToAssign.name);
|
removeProductsFromCollection(productToAssign.name);
|
||||||
|
getCollection({
|
||||||
getCollection({ collectionId: collection.id, auth: "auth" })
|
collectionId: collection.id,
|
||||||
|
channelSlug: defaultChannel.slug,
|
||||||
|
})
|
||||||
.its("collection.products.edges")
|
.its("collection.products.edges")
|
||||||
.should("be.empty");
|
.should("be.empty");
|
||||||
});
|
});
|
||||||
|
@ -373,27 +351,42 @@ filterTests({ definedTags: ["all"] }, () => {
|
||||||
);
|
);
|
||||||
|
|
||||||
it(
|
it(
|
||||||
"should update collection. TC: SALEOR_0306",
|
"delete several collections on collections list page. TC: SALEOR_0309",
|
||||||
{ tags: ["@collection", "@allEnv"] },
|
{ tags: ["@collection", "@allEnv", "@stable"] },
|
||||||
() => {
|
() => {
|
||||||
const collectionName = `${startsWith}${faker.datatype.number()}`;
|
const deleteSeveral = "delete-several-";
|
||||||
const updatedName = `${startsWith}updatedCollection`;
|
const firstCollectionName = `${deleteSeveral}${startsWith}${faker.datatype.number()}`;
|
||||||
|
const secondCollectionName = `${deleteSeveral}${startsWith}${faker.datatype.number()}`;
|
||||||
|
let firstCollection;
|
||||||
|
let secondCollection;
|
||||||
|
|
||||||
createCollectionRequest(collectionName)
|
createCollectionRequest(firstCollectionName).then(collectionResp => {
|
||||||
.then(collectionResp => {
|
firstCollection = collectionResp;
|
||||||
cy.visitAndWaitForProgressBarToDisappear(
|
});
|
||||||
collectionDetailsUrl(collectionResp.id),
|
createCollectionRequest(secondCollectionName).then(collectionResp => {
|
||||||
);
|
secondCollection = collectionResp;
|
||||||
updateCollection({ name: updatedName, description: updatedName });
|
|
||||||
getCollection({ collectionId: collectionResp.id, auth: "auth" });
|
cy.visit(urlList.collections)
|
||||||
})
|
.searchInTable(deleteSeveral)
|
||||||
.then(({ collection: collectionResp }) => {
|
.get(collectionRow(firstCollection.id))
|
||||||
expect(collectionResp.name).to.eq(updatedName);
|
.find(BUTTON_SELECTORS.checkbox)
|
||||||
const descriptionJson = JSON.parse(collectionResp.description);
|
.click()
|
||||||
const descriptionText = descriptionJson.blocks[0].data.text;
|
.get(collectionRow(secondCollection.id))
|
||||||
expect(descriptionText).to.eq(updatedName);
|
.find(BUTTON_SELECTORS.checkbox)
|
||||||
|
.click()
|
||||||
|
.get(BUTTON_SELECTORS.deleteIcon)
|
||||||
|
.click()
|
||||||
|
.addAliasToGraphRequest("CollectionBulkDelete")
|
||||||
|
.get(BUTTON_SELECTORS.submit)
|
||||||
|
.click()
|
||||||
|
.waitForRequestAndCheckIfNoErrors("@CollectionBulkDelete");
|
||||||
|
getCollection({ collectionId: firstCollection.id })
|
||||||
|
.its("collection")
|
||||||
|
.should("be.null");
|
||||||
|
getCollection({ collectionId: secondCollection.id })
|
||||||
|
.its("collection")
|
||||||
|
.should("be.null");
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -61,6 +61,17 @@ export function addProductToCollection({ collectionId, productId }) {
|
||||||
collectionId: "${collectionId}"
|
collectionId: "${collectionId}"
|
||||||
products: ["${productId}"]
|
products: ["${productId}"]
|
||||||
) {
|
) {
|
||||||
|
collection{
|
||||||
|
products(first:100){
|
||||||
|
totalCount
|
||||||
|
edges{
|
||||||
|
node{
|
||||||
|
id
|
||||||
|
name
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
errors {
|
errors {
|
||||||
message
|
message
|
||||||
}
|
}
|
||||||
|
@ -68,3 +79,26 @@ export function addProductToCollection({ collectionId, productId }) {
|
||||||
}`;
|
}`;
|
||||||
return cy.sendRequestWithQuery(mutation);
|
return cy.sendRequestWithQuery(mutation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function addChannelToCollection({
|
||||||
|
collectionId,
|
||||||
|
channelId,
|
||||||
|
isPublished = true,
|
||||||
|
}) {
|
||||||
|
const mutation = `mutation collectionChannelListingUpdate {
|
||||||
|
collectionChannelListingUpdate(
|
||||||
|
id: "${collectionId}",
|
||||||
|
input: {
|
||||||
|
addChannels: {
|
||||||
|
channelId: "${channelId}"
|
||||||
|
isPublished: ${isPublished}
|
||||||
|
}
|
||||||
|
}) {
|
||||||
|
errors {
|
||||||
|
field
|
||||||
|
message
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}`;
|
||||||
|
return cy.sendRequestWithQuery(mutation);
|
||||||
|
}
|
||||||
|
|
|
@ -1,16 +1,13 @@
|
||||||
import { getValueWithDefault } from "../utils/Utils";
|
export function getCollection({ collectionId, channelSlug, auth }) {
|
||||||
|
|
||||||
export function getCollection({ collectionId, channelSlug, auth = "token" }) {
|
|
||||||
const channelLine = getValueWithDefault(
|
|
||||||
channelSlug,
|
|
||||||
`channel: "${channelSlug}"`
|
|
||||||
);
|
|
||||||
const query = `query Collection{
|
const query = `query Collection{
|
||||||
collection(id: "${collectionId}" ${channelLine}) {
|
collection(id: "${collectionId}" channel: "${channelSlug}") {
|
||||||
id
|
id
|
||||||
slug
|
slug
|
||||||
name
|
name
|
||||||
description
|
description
|
||||||
|
channelListings{
|
||||||
|
isPublished
|
||||||
|
}
|
||||||
products(first:100){
|
products(first:100){
|
||||||
totalCount
|
totalCount
|
||||||
edges{
|
edges{
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { getValueWithDefault } from "../utils/Utils";
|
||||||
export function getProductDetails(productId, channelSlug, auth = "token") {
|
export function getProductDetails(productId, channelSlug, auth = "token") {
|
||||||
const privateMetadataLine = getValueWithDefault(
|
const privateMetadataLine = getValueWithDefault(
|
||||||
auth === "auth",
|
auth === "auth",
|
||||||
`privateMetadata{key value}`
|
`privateMetadata{key value}`,
|
||||||
);
|
);
|
||||||
|
|
||||||
const query = `fragment BasicProductFields on Product {
|
const query = `fragment BasicProductFields on Product {
|
||||||
|
@ -80,14 +80,14 @@ export function getProductMetadata({
|
||||||
productId,
|
productId,
|
||||||
channelSlug,
|
channelSlug,
|
||||||
auth,
|
auth,
|
||||||
withPrivateMetadata
|
withPrivateMetadata,
|
||||||
}) {
|
}) {
|
||||||
const privateMetadata = getValueWithDefault(
|
const privateMetadata = getValueWithDefault(
|
||||||
withPrivateMetadata,
|
withPrivateMetadata,
|
||||||
`privateMetadata{
|
`privateMetadata{
|
||||||
key
|
key
|
||||||
value
|
value
|
||||||
}`
|
}`,
|
||||||
);
|
);
|
||||||
|
|
||||||
const query = `query{
|
const query = `query{
|
||||||
|
|
|
@ -1,9 +0,0 @@
|
||||||
export const isCollectionVisible = (collection, collectionId) =>
|
|
||||||
collection !== null && collection.id === collectionId;
|
|
||||||
|
|
||||||
export const isProductInCollectionVisible = (collection, productId) => {
|
|
||||||
const productsList = collection.products;
|
|
||||||
return (
|
|
||||||
productsList.totalCount !== 0 && productsList.edges[0].node.id === productId
|
|
||||||
);
|
|
||||||
};
|
|
|
@ -50,7 +50,8 @@ export function updateCollection({ name, description }) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function assignProductsToCollection(productName) {
|
export function assignProductsToCollection(productName) {
|
||||||
cy.get(COLLECTION_SELECTORS.addProductButton)
|
cy.waitForProgressBarToNotBeVisible()
|
||||||
|
.get(COLLECTION_SELECTORS.addProductButton)
|
||||||
.click()
|
.click()
|
||||||
.addAliasToGraphRequest("SearchProducts")
|
.addAliasToGraphRequest("SearchProducts")
|
||||||
.get(ASSIGN_ELEMENTS_SELECTORS.searchInput)
|
.get(ASSIGN_ELEMENTS_SELECTORS.searchInput)
|
||||||
|
|
Loading…
Reference in a new issue