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

REDSHOP-6035 Codeception - Checkout with product in Manufacturer detail #5397

Merged
merged 10 commits into from
Jul 1, 2020
12 changes: 12 additions & 0 deletions tests/_pages/Joomla3/Administrator/AdminJ3Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -684,6 +684,18 @@ abstract class AdminJ3Page
*/
public static $select2Drop = "//div[@id='select2-drop']//ul[@class='select2-results']/li[1]/div";

/**
* @var string
* @since 3.0.2
*/
public static $tabOption = "//a[contains(text(),'Options')]";

/**
* @var string
* @since 3.0.2
*/
public static $labelSelectManufacturer = "Select Manufacturer";

/**
* @param $menuCategory
* @return array
Expand Down
18 changes: 18 additions & 0 deletions tests/_pages/Joomla3/Administrator/ManufacturerPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,24 @@ class ManufacturerPage extends AdminJ3Page
*/
public static $fieldEmail = "#jform_email";

/**
* @var string
* @since 3.0.2
*/
public static $templateID = "#s2id_jform_template_id";

/**
* @var string
* @since 3.0.2
*/
public static $templateSearch = "//input[@id='s2id_autogen1_search']";

/**
* @var array
* @since 3.0.2
*/
public static $fieldProductPerPage = '#jform_product_per_page';

/**
* @var string
* @since 1.4.0
Expand Down
12 changes: 12 additions & 0 deletions tests/_pages/Joomla3/Administrator/ProductManagerPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,18 @@ public function attributePreSelect($position)
*/
public static $productParentID = "#s2id_product_parent_id";

/**
* @var string
* @since 3.0.2
*/
public static $manufacturerID = "#s2id_manufacturer_id";

/**
* @var string
* @since 3.0.2
*/
public static $manufacturerSearch = "#s2id_autogen7_search";

/**
* @param $position
* @param $x
Expand Down
4 changes: 3 additions & 1 deletion tests/_support/Step/Traits/Delete.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ public function deleteItem($item = '')

$tester->searchItem($item);
$tester->see($item, $pageClass::$resultRow);
$tester->checkAllResults();
$tester->waitForElementVisible($pageClass::$checkAllXpath, 30);
$tester->click($pageClass::$checkAllXpath);
$tester->waitForText($pageClass::$buttonDelete, 30);
$tester->click($pageClass::$buttonDelete);
$tester->acceptPopup();
$tester->waitForElement($pageClass::$searchField, 30);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ public function filterListBySearchingProduct($text, $searchField = "#keyword")
{
$I = $this;
$I->executeJS('window.scrollTo(0,0)');
$I->wait(0.5);
$I->click(FrontEndProductManagerJoomla3Page::$buttonReset);
$I->fillField($searchField, $text);
$I->pressKey($searchField, \Facebook\WebDriver\WebDriverKeys::ENTER);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -561,4 +561,61 @@ public function checkOutWithoutAcceptTermsConditions($productName, $categoryName
$I->waitForText($subTotal, 30);
$I->waitForText($total, 30);
}

/**
* @param $productName
* @param $manufacturerMenuItem
* @param $price
* @param $addressDetail
* @throws Exception
* @since 3.0.2
*/
public function CheckoutProductInManufacturerDetail($productName, $manufacturerMenuItem, $price, $addressDetail)
{
$I = $this;
$I->amOnPage(ConfigurationPage::$URL);
$currencySymbol = $I->grabValueFrom(ConfigurationPage::$currencySymbol);
$decimalSeparator = $I->grabValueFrom(ConfigurationPage::$decimalSeparator);
$numberOfPriceDecimals = $I->grabValueFrom(ConfigurationPage::$numberOfPriceDecimals);
$numberOfPriceDecimals = (int)$numberOfPriceDecimals;
$NumberZero = null;

for($b = 1; $b <= $numberOfPriceDecimals; $b++)
{
$NumberZero = $NumberZero."0";
}

$total = $currencySymbol.$price.$decimalSeparator.$NumberZero;
$subTotal = $currencySymbol.$price.$decimalSeparator.$NumberZero;

$I->amOnPage(FrontEndProductManagerJoomla3Page::$URL);
$I->checkForPhpNoticesOrWarnings();
$productFrontEndManagerPage = new FrontEndProductManagerJoomla3Page;
$I->click($productFrontEndManagerPage->productCategory($manufacturerMenuItem));
$I->waitForElementVisible($productFrontEndManagerPage->product($productName),30);
$I->click($productFrontEndManagerPage->product($productName));
$I->click(FrontEndProductManagerJoomla3Page::$addToCart);
$I->waitForText(FrontEndProductManagerJoomla3Page::$alertSuccessMessage, 10, AdminJ3Page::$selectorSuccess);
$I->see(FrontEndProductManagerJoomla3Page::$alertSuccessMessage, AdminJ3Page::$selectorSuccess);
$I->amOnPage(FrontEndProductManagerJoomla3Page::$cartPageUrL);
$I->seeElement(['link' => $productName]);
$I->waitForElementVisible(FrontEndProductManagerJoomla3Page::$checkoutButton, 30);
$I->click(FrontEndProductManagerJoomla3Page::$checkoutButton);
$I->waitForText(FrontEndProductManagerJoomla3Page::$headBilling, 30);
$I->addressInformation($addressDetail);
$I->waitForElement($productFrontEndManagerPage->product($productName), 30);
$I->scrollTo($productFrontEndManagerPage->product($productName));
$I->seeElement($productFrontEndManagerPage->product($productName));
$I->waitForText($subTotal, 30);
$I->waitForText($total, 30);
$I->waitForElementVisible(FrontEndProductManagerJoomla3Page::$termAndConditions, 30);
$I->click(FrontEndProductManagerJoomla3Page::$termAndConditions);
$I->waitForElement(FrontEndProductManagerJoomla3Page::$checkoutFinalStep, 30);
$I->scrollTo(FrontEndProductManagerJoomla3Page::$checkoutFinalStep);
$I->click(FrontEndProductManagerJoomla3Page::$checkoutFinalStep);
$I->waitForText(FrontEndProductManagerJoomla3Page::$orderReceipt, 10, FrontEndProductManagerJoomla3Page::$orderReceiptTitle);
$I->seeElement($productFrontEndManagerPage->finalCheckout($productName));
$I->waitForText($subTotal, 30);
$I->waitForText($total, 30);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,17 @@ public function checkoutWithShippingGiaoHangNhanh($categoryName, $productName, $
$I->waitForJS("return window.jQuery && jQuery.active == 0;", 30);
$I->fillInformationPrivate($customerInformation);
$I->waitForElementVisible(FrontEndProductManagerJoomla3Page::$shippingMethod, 30);
$I->waitForElementVisible(FrontEndProductManagerJoomla3Page::$radioShippingRate, 30);
$I->waitForElementVisible(FrontEndProductManagerJoomla3Page::$iconShippingRate, 30);
$I->wait(0.5);
$I->selectOption(FrontEndProductManagerJoomla3Page::$radioShippingRate, $shipping['shippingName']);
$I->click(FrontEndProductManagerJoomla3Page::$iconShippingRate);

try
{
$I->canSeeCheckboxIsChecked(FrontEndProductManagerJoomla3Page::$iconShippingRate);
} catch (\Exception $e)
{
$I->click(FrontEndProductManagerJoomla3Page::$iconShippingRate);
$I->waitForElement(FrontEndProductManagerJoomla3Page::$radioShippingRate, 30);
$I->selectOption(FrontEndProductManagerJoomla3Page::$radioShippingRate, $shipping['shippingName']);
$I->canSeeCheckboxIsChecked(FrontEndProductManagerJoomla3Page::$iconShippingRate);
}

Expand All @@ -75,7 +76,7 @@ public function checkoutWithShippingGiaoHangNhanh($categoryName, $productName, $
$I->canSeeCheckboxIsChecked(FrontEndProductManagerJoomla3Page::$termAndConditions);
}

$I->waitForElement(FrontEndProductManagerJoomla3Page::$checkoutFinalStep, 30);
$I->waitForElementVisible(FrontEndProductManagerJoomla3Page::$checkoutFinalStep, 30);
$I->click(FrontEndProductManagerJoomla3Page::$checkoutFinalStep);
$I->waitForElementVisible(FrontEndProductManagerJoomla3Page::$orderReceiptTitle, 30);
$I->waitForText(FrontEndProductManagerJoomla3Page::$orderReceipt, 30, FrontEndProductManagerJoomla3Page::$h1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ public function checkoutProductWithEANTransferPayment($productName, $categoryNam
$I->click(FrontEndProductManagerJoomla3Page::$checkoutButton);
$I->fillInformationPrivate($customerInformation);
$I->wait(1);
$I->waitForElementVisible(FrontEndProductManagerJoomla3Page::$labelPayment, 30);
$I->scrollTo(FrontEndProductManagerJoomla3Page::$labelPayment);

try
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,27 @@ public function addManufacturerWrongEmail($name = '', $email = '')
$client->waitForElement(ManufacturerPage::$fieldName, 30);
$client->click(ManufacturerPage::$buttonCancel);
}

/**
* @param $manufacturer
* @throws Exception
* @since 3.0.2
*/
public function addManufacturer($manufacturer)
{
$client = $this;
$client->amOnPage(ManufacturerPage::$url);
$client->click(ManufacturerPage::$buttonNew);
$client->waitForElementVisible(ManufacturerPage::$fieldName, 30);
$client->fillField(ManufacturerPage::$fieldName, $manufacturer['name']);
$client->waitForElementVisible(ManufacturerPage::$templateID, 30);
$client->click(ManufacturerPage::$templateID);
$client->fillField(ManufacturerPage::$templateSearch, $manufacturer['template']);
$client->pressKey(ManufacturerPage::$templateSearch, Facebook\WebDriver\WebDriverKeys::ENTER);
$client->fillField(ManufacturerPage::$fieldEmail, $manufacturer['email']);
$client->waitForElementVisible(ManufacturerPage::$fieldProductPerPage,30);
$client->fillField(ManufacturerPage::$fieldProductPerPage, $manufacturer['productPerPage']);
$client->click(ManufacturerPage::$buttonSaveClose);
$client->waitForText(ManufacturerPage::$messageItemSaveSuccess, 60, ManufacturerPage::$selectorSuccess);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1444,4 +1444,35 @@ public function createProductChild($productName, $category, $productNumber, $pri
$I->click(ProductManagerPage::$buttonSaveClose);
$I->waitForText(ProductManagerPage::$messageSaveSuccess, 30, ProductManagerPage::$selectorSuccess);
}

/**
* @param $product
* @param $category
* @throws \Exception
* @since 3.0.2
*/
public function createProductHaveManufacturer($product, $category)
{
$I = $this;
$I->amOnPage(ProductManagerPage::$URL);
$I->click(ProductManagerPage::$buttonNew);
$I->waitForElementVisible(ProductManagerPage::$productName, 30);
$I->fillField(ProductManagerPage::$productName, $product['name']);
$I->fillField(ProductManagerPage::$productNumber, $product['number']);
$I->addValueForField(ProductManagerPage::$productPrice, $product['price'], 6);
$I->click(ProductManagerPage::$categoryId);
$I->fillField(ProductManagerPage::$categoryFile, $category);
$usePage = new ProductManagerPage();
$I->waitForElementVisible($usePage->returnChoice($category), 30);
$I->click($usePage->returnChoice($category));

$I->waitForElementVisible(ProductManagerPage::$manufacturerID, 30);
$I->click(ProductManagerPage::$manufacturerID);
$I->waitForElementVisible(ProductManagerPage::$manufacturerSearch, 30);
$I->fillField(ProductManagerPage::$manufacturerSearch, $product['manufacturer']);
$I->pressKey(ProductManagerPage::$manufacturerSearch, \WebDriverKeys::ENTER);
$I->waitForText(ProductManagerPage::$buttonSaveClose, 30);
$I->click(ProductManagerPage::$buttonSaveClose);
$I->waitForText(ProductManagerPage::$messageSaveSuccess, 30, ProductManagerPage::$selectorSuccess);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -136,4 +136,59 @@ public function checkProductUpdateQuantity($nameProduct,$quantity,$menuItem,$pri
$I->click(FrontEndProductManagerJoomla3Page::$checkoutFinalStep);
$I->waitForElement(FrontEndProductManagerJoomla3Page::$orderReceiptTitle, 30);
}

/**
* @param $menuTitle
* @param $menuCategory
* @param $menuItem
* @param $manufacturerName
* @param string $menu
* @throws \Exception
* @since 3.0.2
*/
public function createNewMenuItemManufacturer($menuTitle, $menuCategory, $menuItem, $manufacturerName, $menu = 'Main Menu')
{
$I = $this;
$I->wantTo("I open the menus page");
$I->amOnPage(AdminJ3Page::$menuItemURL);
$I->waitForText(AdminJ3Page::$menuTitle, 5, AdminJ3Page::$h1);
$I->checkForPhpNoticesOrWarnings();

$I->wantTo("I click in the menu: $menu");
$I->click(array('link' => $menu));
$I->waitForText(AdminJ3Page::$menuItemsTitle, 5, AdminJ3Page::$h1);
$I->checkForPhpNoticesOrWarnings();

$I->wantTo("I click new");
$I->click(AdminJ3Page::$buttonNew);
$I->waitForText(AdminJ3Page::$menuNewItemTitle, 5, AdminJ3Page::$h1);
$I->checkForPhpNoticesOrWarnings();
$I->fillField(AdminJ3Page::$menItemTitle, $menuTitle);

$I->wantTo("Open the menu types iframe");
$I->waitForElementVisible(AdminJ3Page::$buttonSelect, 30);
$I->click(AdminJ3Page::$buttonSelect);
$I->waitForElement(AdminJ3Page::$menuTypeModal, 5);
$I->executeJS(AdminJ3Page::jQueryIframeMenuType());
$I->wait(2);
$I->switchToIFrame(AdminJ3Page::$menuItemType);

$I->wantTo("Open the menu category: $menuCategory");
$I->waitForElementVisible(AdminJ3Page::getMenuCategory($menuCategory), 60);
$I->wait(0.5);
$I->click(AdminJ3Page::getMenuCategory($menuCategory));
$I->wantTo("Choose the menu item type: $menuItem");
$I->waitForElementVisible(AdminJ3Page::returnMenuItem($menuItem), 30);
$I->click(AdminJ3Page::returnMenuItem($menuItem));
$I->wantTo('I switch back to the main window');
$I->switchToIFrame();
$I->waitForElementVisible(AdminJ3Page::$tabOption, 30);
$I->wait(0.5);
$I->click(AdminJ3Page::$tabOption);
$I->waitForText(AdminJ3Page::$labelSelectManufacturer);
$I->selectOptionInChosen(AdminJ3Page::$labelSelectManufacturer, $manufacturerName);
$I->wantTo('I save the menu');
$I->click(AdminJ3Page::$buttonSave);
$I->waitForText(AdminJ3Page::$messageMenuItemSuccess, 10, AdminJ3Page::$idInstallSuccess);
}
}