<?xml version="1.0" encoding="UTF-8" ?>
<!--
 /**
  * @copyright  Vertex. All rights reserved.  https://www.vertexinc.com/
  * @author     Mediotype                     https://www.mediotype.com/
  */
-->
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
    <test name="AdminTrustedIdLengthValidation">
        <annotations>
            <features value="Vertex"/>
            <group value="Vertex"/>

            <stories value="As an administrator, I want the admin panel to prevent me from inputting an incorrect Trusted ID"/>
            <title value="Trusted ID Validation"/>
            <description value="Validate the length of the Vertex Trusted ID in the admin"/>

            <severity value="MINOR"/>
        </annotations>
        <before>
            <actionGroup ref="LoginAsAdmin" stepKey="loginAsAdminForSetup"/>
            <actionGroup ref="VertexTaxDefaultConfig" stepKey="setupDefaultVertexTestConfiguration"/>
            <actionGroup ref="logout" stepKey="logoutOfAdminFromSetup"/>
        </before>

        <actionGroup ref="LoginAsAdmin" stepKey="loginAsAdminBefore"/>
        <amOnPage url="{{AdminTaxConfigPage.url('vertex_settings')}}" stepKey="viewConfigBefore"/>
        <waitForPageLoad stepKey="waitForPageLoadBefore"/>
        
        <conditionalClick selector="{{AdminVertexSettingsConfigSection.vertexSettingsHeader}}" dependentSelector="{{AdminVertexSettingsConfigSection.enableVertex}}" visible="false" stepKey="openVertexConfiguration"/>
        
        <grabValueFrom selector="{{AdminVertexSettingsConfigSection.trustedId}}" stepKey="backupTrustedId"/>

        <seeElement selector="{{AdminVertexSettingsConfigSection.trustedId}}" stepKey="seeTrustedId"/>
        <fillField selector="{{AdminVertexSettingsConfigSection.trustedId}}" userInput="123"
                   stepKey="enterShortString"/>
        <click selector="#save" stepKey="clickSaveShort"/>

        <see selector="{{AdminVertexSettingsConfigSection.trustedIdError}}"
             stepKey="seeShortError" userInput="Please enter more or equal than 6 symbols."/>

        <fillField selector="{{AdminVertexSettingsConfigSection.trustedId}}" userInput="12345678901234567890"
                   stepKey="enterLongString"/>
        <click selector="#save" stepKey="clickSaveLong"/>

        <see selector="{{AdminVertexSettingsConfigSection.trustedIdError}}"
             stepKey="seeLongError" userInput="Please enter less or equal than 16 symbols."/>

        <fillField selector="{{AdminVertexSettingsConfigSection.trustedId}}" userInput="{$backupTrustedId}"
                   stepKey="enterBackedUpId"/>
        <click selector="#save" stepKey="clickSaveAfter"/>
        <waitForPageLoad stepKey="waitForPageLoadAfter"/>

        <dontSeeElement selector="{{AdminVertexSettingsConfigSection.trustedIdError}}" stepKey="seeNoError"/>
    </test>
</tests>
