fixing tests: 2505 2506 - should update product to be visible or not in listings (#3648)
* fix tests should update product to be visible in listings, should update product to not be visible in listings * lock conflict fixes * update tests: products published or not to new implementation
This commit is contained in:
parent
50c8e93534
commit
192be719fe
4 changed files with 20 additions and 16 deletions
|
@ -73,7 +73,8 @@ describe("Published products", () => {
|
||||||
.then(({ product: productResp }) => {
|
.then(({ product: productResp }) => {
|
||||||
const product = productResp;
|
const product = productResp;
|
||||||
const productUrl = productDetailsUrl(product.id);
|
const productUrl = productDetailsUrl(product.id);
|
||||||
updateProductPublish(productUrl, true);
|
cy.visit(productUrl);
|
||||||
|
updateProductPublish(true);
|
||||||
getProductDetails(product.id, defaultChannel.slug);
|
getProductDetails(product.id, defaultChannel.slug);
|
||||||
})
|
})
|
||||||
.then(resp => {
|
.then(resp => {
|
||||||
|
@ -101,7 +102,8 @@ describe("Published products", () => {
|
||||||
.then(({ product: productResp }) => {
|
.then(({ product: productResp }) => {
|
||||||
product = productResp;
|
product = productResp;
|
||||||
const productUrl = productDetailsUrl(product.id);
|
const productUrl = productDetailsUrl(product.id);
|
||||||
updateProductPublish(productUrl, false);
|
cy.visit(productUrl);
|
||||||
|
updateProductPublish(false);
|
||||||
getProductDetails(product.id, defaultChannel.slug);
|
getProductDetails(product.id, defaultChannel.slug);
|
||||||
})
|
})
|
||||||
.then(resp => {
|
.then(resp => {
|
||||||
|
|
|
@ -72,7 +72,8 @@ describe("Products displayed in listings", () => {
|
||||||
.then(({ product: productResp }) => {
|
.then(({ product: productResp }) => {
|
||||||
const product = productResp;
|
const product = productResp;
|
||||||
const productUrl = productDetailsUrl(product.id);
|
const productUrl = productDetailsUrl(product.id);
|
||||||
updateProductVisibleInListings(productUrl);
|
cy.visit(productUrl);
|
||||||
|
updateProductVisibleInListings();
|
||||||
searchInShop(productName);
|
searchInShop(productName);
|
||||||
})
|
})
|
||||||
.then(resp => {
|
.then(resp => {
|
||||||
|
@ -103,7 +104,8 @@ describe("Products displayed in listings", () => {
|
||||||
.then(({ product: productResp }) => {
|
.then(({ product: productResp }) => {
|
||||||
const product = productResp;
|
const product = productResp;
|
||||||
const productUrl = productDetailsUrl(product.id);
|
const productUrl = productDetailsUrl(product.id);
|
||||||
updateProductVisibleInListings(productUrl);
|
cy.visit(productUrl);
|
||||||
|
updateProductVisibleInListings();
|
||||||
|
|
||||||
searchInShop(productName).then(resp => {
|
searchInShop(productName).then(resp => {
|
||||||
const isProductVisible = isProductVisibleInSearchResult(
|
const isProductVisible = isProductVisibleInSearchResult(
|
||||||
|
|
|
@ -5,6 +5,6 @@ export const AVAILABLE_CHANNELS_FORM = {
|
||||||
availableForPurchaseRadioButtons: "[name*='isAvailableForPurchase']",
|
availableForPurchaseRadioButtons: "[name*='isAvailableForPurchase']",
|
||||||
radioButtonsValueTrue: "[value='true']",
|
radioButtonsValueTrue: "[value='true']",
|
||||||
radioButtonsValueFalse: "[value='false']",
|
radioButtonsValueFalse: "[value='false']",
|
||||||
visibleInListingsButton: "[name*='visibleInListings']",
|
visibleInListingsButton: "[id*='visibleInListings']",
|
||||||
availableChannel: "[data-test-id*='channel-availability-item']",
|
availableChannel: "[data-test-id*='channel-availability-item']",
|
||||||
};
|
};
|
||||||
|
|
|
@ -16,33 +16,33 @@ export function updateProductIsAvailableForPurchase(
|
||||||
? valueTrue
|
? valueTrue
|
||||||
: valueFalse;
|
: valueFalse;
|
||||||
const availableForPurchaseSelector = `${AVAILABLE_CHANNELS_FORM.availableForPurchaseRadioButtons}${isAvailableForPurchaseSelector}`;
|
const availableForPurchaseSelector = `${AVAILABLE_CHANNELS_FORM.availableForPurchaseRadioButtons}${isAvailableForPurchaseSelector}`;
|
||||||
updateProductManageInChannel(productUrl, availableForPurchaseSelector);
|
updateProductManageInChannel(availableForPurchaseSelector);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function updateProductPublish(productUrl, isPublished) {
|
export function updateProductPublish(isPublished) {
|
||||||
const isPublishedSelector = isPublished ? valueTrue : valueFalse;
|
const isPublishedSelector = isPublished ? valueTrue : valueFalse;
|
||||||
const publishedSelector = `${AVAILABLE_CHANNELS_FORM.publishedRadioButtons}${isPublishedSelector}`;
|
const publishedSelector = `${AVAILABLE_CHANNELS_FORM.publishedRadioButtons}${isPublishedSelector}`;
|
||||||
updateProductManageInChannel(productUrl, publishedSelector);
|
updateProductManageInChannel(publishedSelector);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function updateProductVisibleInListings(productUrl) {
|
export function updateProductVisibleInListings() {
|
||||||
updateProductManageInChannel(
|
updateProductManageInChannel(AVAILABLE_CHANNELS_FORM.visibleInListingsButton);
|
||||||
productUrl,
|
|
||||||
AVAILABLE_CHANNELS_FORM.visibleInListingsButton,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateProductManageInChannel(productUrl, manageSelector) {
|
function updateProductManageInChannel(manageSelector) {
|
||||||
cy.visit(productUrl)
|
cy.get(AVAILABLE_CHANNELS_FORM.assignedChannels)
|
||||||
.get(AVAILABLE_CHANNELS_FORM.assignedChannels)
|
|
||||||
.click()
|
.click()
|
||||||
.get(manageSelector)
|
.get(manageSelector)
|
||||||
.first()
|
.first()
|
||||||
|
.scrollIntoView()
|
||||||
.click()
|
.click()
|
||||||
|
// cypress click is to fast - our app is nor ready to handle new event when click occurs - solution could be disabling save button until app is ready to handle new event
|
||||||
|
.wait(1000)
|
||||||
.waitForProgressBarToNotBeVisible()
|
.waitForProgressBarToNotBeVisible()
|
||||||
.addAliasToGraphRequest("ProductChannelListingUpdate")
|
.addAliasToGraphRequest("ProductChannelListingUpdate")
|
||||||
.get(BUTTON_SELECTORS.confirm)
|
.get(BUTTON_SELECTORS.confirm)
|
||||||
.click()
|
.click()
|
||||||
|
.confirmationMessageShouldAppear()
|
||||||
.wait("@ProductChannelListingUpdate");
|
.wait("@ProductChannelListingUpdate");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue