<?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="navigateToCreatedCMSPage">
        <arguments>
            <argument name="CMSPage" defaultValue=""/>
        </arguments>
        <amOnPage url="{{CmsPagesPage.url}}" stepKey="navigateToCMSPagesGrid"/>
        <waitForPageLoad stepKey="waitForPageLoad1"/>
        <conditionalClick selector="{{CmsPagesPageActionsSection.clearAllButton}}" dependentSelector="{{CmsPagesPageActionsSection.activeFilters}}" stepKey="clickToResetFilter" visible="true"/>
        <waitForPageLoad stepKey="waitForPageLoad2"/>
        <conditionalClick selector="//div[contains(@data-role, 'grid-wrapper')]/table/thead/tr/th/span[contains(text(), 'ID')]" dependentSelector="//span[contains(text(), 'ID')]/parent::th[not(contains(@class, '_descend'))]/parent::tr/parent::thead/parent::table/parent::div[contains(@data-role, 'grid-wrapper')]" stepKey="clickToAttemptSortByIdDescending" visible="true"/>
        <waitForLoadingMaskToDisappear stepKey="waitForFirstIdSortDescendingToFinish" />
        <!-- Conditional Click again in case it goes from default state to ascending on first click -->
        <conditionalClick selector="//div[contains(@data-role, 'grid-wrapper')]/table/thead/tr/th/span[contains(text(), 'ID')]" dependentSelector="//span[contains(text(), 'ID')]/parent::th[not(contains(@class, '_descend'))]/parent::tr/parent::thead/parent::table/parent::div[contains(@data-role, 'grid-wrapper')]" stepKey="secondClickToAttemptSortByIdDescending" visible="true"/>
        <waitForLoadingMaskToDisappear stepKey="waitForSecondIdSortDescendingToFinish" />
        <click selector="{{CmsPagesPageActionsSection.select(CMSPage.identifier)}}" stepKey="clickSelectCreatedCMSPage" />
        <click selector="{{CmsPagesPageActionsSection.edit(CMSPage.identifier)}}" stepKey="navigateToCreatedCMSPage" />
        <waitForPageLoad stepKey="waitForPageLoad3"/>
        <click selector="{{CmsNewPagePageContentSection.header}}" stepKey="clickExpandContentTabForPage"/>
        <waitForLoadingMaskToDisappear stepKey="waitForLoadingMaskOfStagingSection" />
    </actionGroup>
    <actionGroup name="navigateToCreatedCMSBlockPage">
        <arguments>
            <argument name="CMSBlockPage" defaultValue=""/>
        </arguments>
        <amOnPage url="{{CmsBlocksPage.url}}" stepKey="navigateToCMSBlocksGrid"/>
        <waitForPageLoad stepKey="waitForPageLoad1"/>
        <conditionalClick selector="{{CmsPagesPageActionsSection.clearAllButton}}" dependentSelector="{{CmsPagesPageActionsSection.activeFilters}}" stepKey="clickToResetFilter" visible="true"/>
        <waitForPageLoad stepKey="waitForPageLoad2"/>
        <conditionalClick selector="{{BlockPageActionsSection.idColumn}}" dependentSelector="//span[contains(text(), 'ID')]/parent::th[not(contains(@class, '_descend'))]/parent::tr/parent::thead/parent::table/parent::div[contains(@data-role, 'grid-wrapper')]" stepKey="clickToAttemptSortByIdDescending" visible="true"/>
        <waitForLoadingMaskToDisappear stepKey="waitForFirstIdSortDescendingToFinish" />
        <!-- Conditional Click again in case it goes from default state to ascending on first click  -->
        <conditionalClick selector="{{BlockPageActionsSection.idColumn}}" dependentSelector="//span[contains(text(), 'ID')]/parent::th[not(contains(@class, '_descend'))]/parent::tr/parent::thead/parent::table/parent::div[contains(@data-role, 'grid-wrapper')]" stepKey="secondClickToAttemptSortByIdDescending" visible="true"/>
        <waitForLoadingMaskToDisappear stepKey="waitForSecondIdSortDescendingToFinish" />
        <click selector="{{BlockPageActionsSection.select(CMSBlockPage.identifier)}}" stepKey="clickSelectCreatedCMSBlock" />
        <click selector="{{BlockPageActionsSection.edit(CMSBlockPage.identifier)}}" stepKey="navigateToCreatedCMSBlock" />
        <waitForPageLoad stepKey="waitForPageLoad3"/>
        <waitForLoadingMaskToDisappear stepKey="waitForLoadingMaskOfStagingSection" />
    </actionGroup>
</actionGroups>
