<?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="AddBundleOptionWithTwoProductsActionGroup">
        <annotations>
            <description>Requires Navigation to the Product Creation page. Adds Bundle Option with Two Products using the provided arguments. 'x' refers to Bundle option number. 'n' refers to the first number after x.</description>
        </annotations>
        <arguments>
            <argument name="x" type="string"/>
            <argument name="n" type="string"/>
            <argument name="prodOneSku" type="string"/>
            <argument name="prodTwoSku" type="string"/>
            <argument name="optionTitle" type="string"/>
            <argument name="inputType" type="string"/>
        </arguments>

        <conditionalClick selector="{{AdminProductFormBundleSection.bundleItemsToggle}}" dependentSelector="{{AdminProductFormBundleSection.bundleItemsToggle}}" visible="false" stepKey="conditionallyOpenSectionBundleItems"/>
        <scrollTo selector="{{AdminProductFormBundleSection.bundleItemsToggle}}" stepKey="scrollUpABit"/>
        <click selector="{{AdminProductFormBundleSection.addOption}}" stepKey="clickAddOption"/>
        <waitForElementVisible selector="{{AdminProductFormBundleSection.bundleOptionXTitle(x)}}" stepKey="waitForOptions"/>
        <fillField selector="{{AdminProductFormBundleSection.bundleOptionXTitle(x)}}" userInput="{{optionTitle}}" stepKey="fillTitle"/>
        <selectOption selector="{{AdminProductFormBundleSection.bundleOptionXInputType(x)}}" userInput="{{inputType}}" stepKey="selectType"/>
        <waitForElementVisible selector="{{AdminProductFormBundleSection.nthAddProductsToOption(n)}}" stepKey="waitForAddBtn"/>
        <click selector="{{AdminProductFormBundleSection.nthAddProductsToOption(n)}}" stepKey="clickAdd"/>
        <conditionalClick selector="{{AdminProductGridFilterSection.clearFilters}}" dependentSelector="{{AdminProductGridFilterSection.clearFilters}}" visible="true" stepKey="clickClearFilters1"/>
        <click selector="{{AdminProductGridFilterSection.filters}}" stepKey="openProductFilters1"/>
        <fillField selector="{{AdminProductGridFilterSection.skuFilter}}" userInput="{{prodOneSku}}" stepKey="fillProductSkuFilter1"/>
        <click selector="{{AdminProductGridFilterSection.applyFilters}}" stepKey="clickApplyFilters1"/>
        <waitForElementNotVisible selector="{{AdminProductGridSection.loadingMask}}" stepKey="waitForFilteredGridLoad1" time="30"/>
        <checkOption selector="{{AdminAddProductsToOptionPanel.firstCheckbox}}" stepKey="selectProduct1"/>
        <conditionalClick selector="{{AdminProductGridFilterSection.clearFilters}}" dependentSelector="{{AdminProductGridFilterSection.clearFilters}}" visible="true" stepKey="clickClearFilters2"/>
        <click selector="{{AdminProductGridFilterSection.filters}}" stepKey="openProductFilters2"/>
        <fillField selector="{{AdminProductGridFilterSection.skuFilter}}" userInput="{{prodTwoSku}}" stepKey="fillProductSkuFilter2"/>
        <click selector="{{AdminProductGridFilterSection.applyFilters}}" stepKey="clickApplyFilters2"/>
        <waitForElementNotVisible selector="{{AdminProductGridSection.loadingMask}}" stepKey="waitForFilteredGridLoad2" time="30"/>
        <checkOption selector="{{AdminAddProductsToOptionPanel.firstCheckbox}}" stepKey="selectProduct2"/>
        <click selector="{{AdminAddProductsToOptionPanel.addSelectedProducts}}" stepKey="clickAddButton1"/>
        <fillField selector="{{AdminProductFormBundleSection.bundleOptionXProductYQuantity(x, '0')}}" userInput="50" stepKey="fillQuantity1"/>
        <fillField selector="{{AdminProductFormBundleSection.bundleOptionXProductYQuantity(x, '1')}}" userInput="50" stepKey="fillQuantity2"/>
    </actionGroup>
</actionGroups>
