Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LPD-45736 Migrate test CanVerifyOrderItemsAreSplitUsingQuickAddToCart to playwright #5844

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -676,90 +676,6 @@ definition {
}
}

@description = "COMMERCE-12487. As a buyer, I can verify the order items are split on the Mini Cart by using quick add products to the cart when the 'Show Separate Order Items' toggle is enabled"
@priority = 3
test CanVerifyOrderItemsAreSplitUsingQuickAddToCart {
property portal.acceptance = "false";

task ("When the buyer logs in and clicks 2 times on the 'Add to cart' button for MIN55861") {
User.logoutPG();

CommerceLogin.miniumLogin(
password = PropsUtil.get("default.admin.password"),
urlAppend = "web/minium",
userEmailAddress = "[email protected]");

CommerceNavigator.gotoMiniCart();

for (var count : list "1,2") {
FrontStore.quickAddToCartSearchAndSelectItem(orderItemSku = "MIN55861");

Click(locator1 = "CommerceAccelerators#QUICK_ADD_TO_CART_BUTTON");
}
}

task ("Then the order items on the mini-cart are not split") {
FrontStore.viewMiniCartItem(
cartItemName = "U-Joint",
cartItemPriceValue = "24.00",
cartItemQuantity = 2,
cartItemSku = "MIN55861");
}

task ("When the admin enables the toggle 'Show Separate Order Items' for Minium Portal channel") {
User.logoutAndLoginPG();

CommerceChannels.openChannelsAdmin();

CommerceNavigator.gotoEntry(entryName = "Minium Portal");

Check.checkToggleSwitch(
key_toggleSwitchLabel = "Show Separate Order Items",
locator1 = "ToggleSwitch#ANY_TOGGLE_SWITCH");

Button.clickSave();
}

task ("And the buyer clicks the 'Add to cart' button for MIN55861") {
User.logoutPG();

CommerceLogin.miniumLogin(
password = PropsUtil.get("default.admin.password"),
urlAppend = "web/minium",
userEmailAddress = "[email protected]");

CommerceNavigator.gotoMiniCart();

FrontStore.quickAddToCartSearchAndSelectItem(orderItemSku = "MIN55861");

Click(locator1 = "CommerceAccelerators#QUICK_ADD_TO_CART_BUTTON");
}

task ("Then another order item shows up on the mini-cart, sharing the same SKU as the 2 added before") {
CommerceNavigator.gotoMiniCart();

FrontStore.viewMiniCartItem(
cartItemName = "U-Joint",
cartItemPriceValue = "24.00",
cartItemQuantity = 2,
cartItemSku = "MIN55861");

FrontStore.viewMiniCartItem(
cartItemName = "U-Joint",
cartItemPriceValue = "24.00",
cartItemQuantity = 1,
cartItemSku = "MIN55861",
index = 2);
}

task ("And all the information in summary table is correct") {
FrontStore.viewMiniCart(
cartSummaryQuantity = 3,
cartSummarySubtotal = "72.00",
cartSummaryTotal = "72.00");
}
}

@description = "COMMERCE-12491. As a buyer, I can verify the order items are split on the Mini Cart by adding multiple SKU products to the cart when the 'Show Separate Order Items' toggle is enabled"
@priority = 5
test CanVerifyOrderItemsAreSplitWithMultipleSKUProduct {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ import {loginTest} from '../../../fixtures/loginTest';
import {liferayConfig} from '../../../liferay.config';
import getRandomString from '../../../utils/getRandomString';
import performLogin, {performLogout} from '../../../utils/performLogin';
import {waitForAlert} from '../../../utils/waitForAlert';
import getFragmentDefinition from '../../layout-content-page-editor-web/utils/getFragmentDefinition';
import getPageDefinition from '../../layout-content-page-editor-web/utils/getPageDefinition';
import {miniumSetUp} from '../utils/commerce';

export const test = mergeTests(
applicationsMenuPageTest,
Expand Down Expand Up @@ -605,3 +607,70 @@ test('LPD-26906 Mini cart bundle quantity edit', async ({
page.getByText('$ 20.00', {exact: true}).first()
).toBeVisible();
});

test('LPD-45736 Order items are split on the mini cart with quick add to cart when order splitting is enabled', async ({
apiHelpers,
commerceAdminChannelsPage,
commerceMiniCartPage,
page,
}) => {
const account = await apiHelpers.headlessAdminUser.postAccount({
name: 'admin',
type: 'business',
});

apiHelpers.data.push({id: account.id, type: 'account'});

const {channel, site} = await miniumSetUp(apiHelpers);

await apiHelpers.headlessCommerceAdminAccount.postAddress(account.id, {
phoneNumber: '12345',
regionISOCode: 'LA',
});

const product = await apiHelpers.headlessCommerceAdminCatalog.getProducts(
new URLSearchParams({
filter: `name eq 'ABS Sensor'`,
})
);

const productName = product.items[0].name['en_US'];

await page.goto(`/web/${site.name}`);

await commerceMiniCartPage.miniCartButton.click();
await commerceMiniCartPage.searchProductsInput.fill(productName);
await commerceMiniCartPage.quickAddToCartSku(productName).click();
await commerceMiniCartPage.quickAddToCartButton.click();
await commerceMiniCartPage.searchProductsInput.fill(productName);
await commerceMiniCartPage.quickAddToCartSku(productName).click();
await commerceMiniCartPage.quickAddToCartButton.click();

await expect(
page.getByText('$ 100.00', {exact: true}).first()
).toBeVisible();
await expect(commerceMiniCartPage.miniCartItem(productName)).toHaveCount(1);

await commerceAdminChannelsPage.goto();
await (
await commerceAdminChannelsPage.channelsTableRowLink(channel.name)
).click();
await commerceAdminChannelsPage
.ordersTabToggle('Show Separate Order Items')
.click();
await commerceAdminChannelsPage.headerActionsSaveButton.click();

await waitForAlert(page);

await page.goto(`/web/${site.name}`);

await commerceMiniCartPage.miniCartButton.click();
await commerceMiniCartPage.searchProductsInput.fill(productName);
await commerceMiniCartPage.quickAddToCartSku(productName).click();
await commerceMiniCartPage.quickAddToCartButton.click();

await expect(
page.getByText('$ 150.00', {exact: true}).first()
).toBeVisible();
await expect(commerceMiniCartPage.miniCartItem(productName)).toHaveCount(2);
});