<?xml version="1.0" encoding="UTF-8"?>
<!--
 /**
  * Copyright © Magento, Inc. All rights reserved.
  * See COPYING.txt for license details.
  */
-->

<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
    <actionGroup name="AncillaryPrepBundleProduct">
        <!--Prereq: go to bundle product creation page-->
        <fillField selector="{{AdminProductFormBundleSection.productName}}" userInput="{{BundleProduct.name}}" stepKey="fillProductName"/>
        <fillField selector="{{AdminProductFormBundleSection.productSku}}" userInput="{{BundleProduct.sku}}" stepKey="fillProductSku"/>

        <!--Trigger SEO drop down-->
        <scrollTo selector="{{AdminProductFormBundleSection.seoDropdown}}" stepKey="moveToSEOSection"/>
        <conditionalClick selector="{{AdminProductFormBundleSection.seoDropdown}}" dependentSelector="{{AdminProductFormBundleSection.urlKey}}" visible="false" stepKey="openDropDownIfClosed"/>
        <waitForPageLoad stepKey="WaitForDropDownSEO"/>

        <!--Fill URL input-->
        <fillField userInput="{{BundleProduct.urlKey}}" selector="{{AdminProductFormBundleSection.urlKey}}" stepKey="FillsinSEOlinkExtension"/>
    </actionGroup>

    <!--Edit existing product by searching in product catalog-->
    <actionGroup name="FindProductToEdit">
        <amOnPage url="{{ProductCatalogPage.url}}" stepKey="GoToProductCatalog"/>
        <waitForPageLoad stepKey="WaitForCatalogProductPageToLoad"/>
        <conditionalClick selector="{{AdminProductGridFilterSection.clearFilters}}" dependentSelector="{{AdminProductGridFilterSection.clearFilters}}" visible="true" stepKey="clickClearFiltersInitial"/>
        <fillField userInput="{{BundleProduct.name}}" selector="#fulltext" stepKey="EnterProductNameInSearch"/>
        <click stepKey="ClickSearch" selector="{{AdminProductFormBundleSection.searchButton}}"/>
        <click stepKey="ClickOnProduct" selector="{{AdminProductFormBundleSection.firstCatalogProduct}}"/>
        <waitForPageLoad stepKey="WaitForProductEditPageToLoad"/>
    </actionGroup>
</actionGroups>
