<?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="AdminAssertProductAttributeOnProductEditPageActionGroup">
        <annotations>
            <description>Assert if product attribute present on the product Create/Edit page</description>
        </annotations>
        <arguments>
            <argument name="attributeCode" defaultValue="{{newProductAttribute.attribute_code}}" type="string"/>
            <argument name="attributeLabel" defaultValue="{{ProductAttributeFrontendLabel.label}}" type="string"/>
        </arguments>
        <!--Scroll to element to avoid test order flakiness-->
        <waitForElement selector="{{AdminProductFormSection.attributeTab}}" stepKey="waitForSection"/>
        <executeJS function="return document.evaluate(&quot;{{AdminProductFormSection.attributeTab}}&quot;, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.getBoundingClientRect().y" stepKey="sectionPosition"/>
        <executeJS function="return document.querySelector(&quot;{{AdminHeaderSection.pageMainActions}}&quot;).getBoundingClientRect().height" stepKey="floatingHeaderHeight"/>
        <executeJS function="window.scrollTo({top: {$sectionPosition}-{$floatingHeaderHeight}})" stepKey="scrollToAttributesTab"/>
        <conditionalClick selector="{{AdminProductFormSection.attributeTab}}" dependentSelector="{{AdminProductFormSection.attributeTabOpened}}" visible="false" stepKey="clickToOpen"/>
        <comment userInput="BIC workaround" stepKey="scrollToAttributeTab"/>
        <seeElement selector="{{AdminProductFormSection.attributeLabelByText(attributeLabel)}}" stepKey="seeAttributeLabelInProductForm"/>
        <seeElement selector="{{AdminProductFormSection.newAddedAttribute(attributeCode)}}" stepKey="seeProductAttributeIsAdded"/>
    </actionGroup>
</actionGroups>
