<?xml version="1.0" encoding="UTF-8"?>
<!--
 /**
 * Copyright 2025 Adobe
 * All Rights Reserved.
 */
-->

<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
    <actionGroup name="AdminCreateCartPriceRuleWithProductSubselectionActionGroup" extends="AdminCreateCartPriceRuleActionGroup">
        <annotations>
            <description>Create a complete cart price rule with product subselection quantity condition and save it.</description>
        </annotations>
        <arguments>
            <argument name="condition1" type="string" defaultValue="Products subselection"/>
            <argument name="ruleToChange1" type="string" defaultValue="is"/>
            <argument name="rule1" type="string" defaultValue="equals or greater than"/>
            <argument name="ruleToChange2" type="string" defaultValue="..."/>
            <argument name="rule2" type="string" defaultValue="1"/>
        </arguments>
        <!--Go to Conditions section-->
        <waitForElementClickable selector="{{AdminCartPriceRulesFormSection.conditionsHeader}}" stepKey="waitForOpenConditionsSection" after="selectActionType"/>
        <click selector="{{AdminCartPriceRulesFormSection.conditionsHeader}}" stepKey="openConditionsSection" after="waitForOpenConditionsSection"/>
        <waitForElementClickable selector="{{AdminCartPriceRulesFormSection.addCondition('1')}}" stepKey="waitForAddFirstCondition" after="openConditionsSection"/>
        <click selector="{{AdminCartPriceRulesFormSection.addCondition('1')}}" stepKey="addFirstCondition" after="waitForAddFirstCondition"/>
        <selectOption selector="{{AdminCartPriceRulesFormSection.ruleCondition('1')}}" userInput="{{condition1}}" stepKey="selectRule" after="addFirstCondition"/>
        <waitForElementClickable selector="{{AdminCartPriceRulesFormSection.ruleParameter(ruleToChange1)}}" stepKey="waitForFirstRuleElement" after="selectRule"/>
        <click selector="{{AdminCartPriceRulesFormSection.ruleParameter(ruleToChange1)}}" stepKey="clickToChangeRule" after="waitForFirstRuleElement"/>
        <selectOption selector="{{AdminCartPriceRulesFormSection.ruleParameterSelect('1--1')}}" userInput="{{rule1}}" stepKey="selectRule1" after="clickToChangeRule"/>
        <waitForElementClickable selector="{{AdminCartPriceRulesFormSection.ruleParameter(ruleToChange2)}}" stepKey="waitForSecondRuleElement" after="selectRule1"/>
        <click selector="{{AdminCartPriceRulesFormSection.ruleParameter(ruleToChange2)}}" stepKey="clickToChangeRule1" after="waitForSecondRuleElement"/>
        <fillField selector="{{AdminCartPriceRulesFormSection.ruleParameterInput('1--1')}}" userInput="{{rule2}}" stepKey="fillRule" after="clickToChangeRule1"/>
    </actionGroup>
</actionGroups>
