<?xml version="1.0" encoding="UTF-8"?>
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
    <actionGroup name="CheckOrdersSync">
        <amOnPage url="admin/admin/system_config/edit/section/yotpo/store/1/" stepKey="navigateToYotpoConfigurationOnDefaultStoreView"/>
        <generateDate date="now" format="Y-m-d" stepKey="currentDate"/>
        <fillField userInput="{$currentDate}" selector="{{AdminLoginToYotpo.OrdersSyncFromDate}}" stepKey="setTodayDate" />
        <uncheckOption selector="{{AdminLoginToYotpo.OrderSyncCustomStatusesCheckbox}}" stepKey="ClickOnCustomStatusesEnabledCheckbox"/>
        <selectOption userInput="pending" selector="{{AdminLoginToYotpo.OrdersSyncStatuses}}" stepKey="setOrdersSyncStatuses"/>
        <click selector="{{AdminLoginToYotpo.SaveConfiguration}}" stepKey="ClickOnSaveConfig"/>
        <waitForPageLoad stepKey="waitForSaveConfig"/>
        <seeElement selector="{{AdminLoginToYotpo.SavedConfiguration}}" stepKey="checkConfigurationSaved"/>

        <magentoCLI command="yotpo:sync" stepKey="runSyncScript"/>
        <grabTextFrom selector="//tr[@id='row_yotpo_sync_settings_sync_status']//td[@class='value']//div[contains(text(), 'Total orders synced with Yotpo:')]" stepKey="syncStatus"/>
        <assertContains stepKey="assertSyncResult" expected="SUCCESS" expectedType="string" actual="$runSyncScript"/>
    </actionGroup>
</actionGroups>
