package cz.moneta.test.dsl.newib.payments;

import cz.moneta.test.dsl.newib.NewIbPageFlow;
import cz.moneta.test.dsl.newib.accounts.CurrentAccountPage;
import cz.moneta.test.dsl.newib.components.HorizontalMainMenu;
import cz.moneta.test.dsl.newib.components.VerticalMainMenu;
import cz.moneta.test.harness.support.web.CheckElementPresent;
import cz.moneta.test.harness.support.web.Click;
import cz.moneta.test.harness.support.web.Wait;

import static cz.moneta.test.dsl.newib.payments.PaymentOrderSentPage.*;

@Wait(value = {PAYMENT_SENT_TITLE_XPATH, NEXT_PAYMENT_BUTTON_XPATH, OVERVIEW_TRANSACTIONS_BUTTON_XPATH, STANDING_ORDER_SAVE_BUTTON, CATEGORY_FIELD_XPATH}, waitSecondsForElement = 60)
public interface PaymentOrderSentPage extends NewIbPageFlow<PaymentOrderSentPage>, HorizontalMainMenu, VerticalMainMenu {
    String PAYMENT_SENT_TITLE_XPATH = "//h1[@class='t-title t-title--h3'][text()='Platební příkaz byl odeslán']";
    String NEXT_PAYMENT_BUTTON_XPATH = "//button[@data-testid='back']";
    String OVERVIEW_TRANSACTIONS_BUTTON_XPATH = "//button[@data-testid='submit']";
    String STANDING_ORDER_SAVE_BUTTON = "//button[@data-testid='standingOrderSaveButton']";
    String CATEGORY_FIELD_XPATH = "//input[@data-testid='categoryId'] | //div[@data-testid='categoryId']";
    String CHECK_ENVELOPE_TEXT_XPATH = "//div[normalize-space(.)='Uložte si platbu jako šablonu pro rychlejší odesílání']";
    String CHECK_STANDING_ORDER_TEXT_XPATH = "//div[@class='col col-12 col-md-8' and normalize-space(text())='Platíte příjemci často? Vytvořte si trvalý příkaz']";
    String SELECTED_CATEGORY_XPATH = "//span[@class='f-control2__valueTitle' and normalize-space(text())='%s']";

    @Click(OVERVIEW_TRANSACTIONS_BUTTON_XPATH)
    CurrentAccountPage clickOverviewTransactions();

    @CheckElementPresent(PAYMENT_SENT_TITLE_XPATH)
    PaymentOrderSentPage checkPaymentOrderSentTitle();

    @CheckElementPresent(CHECK_ENVELOPE_TEXT_XPATH)
    PaymentOrderSentPage checkEnvelopeText();

    @CheckElementPresent(CHECK_STANDING_ORDER_TEXT_XPATH)
    PaymentOrderSentPage checkStandingOrderText();

    @CheckElementPresent(value = SELECTED_CATEGORY_XPATH, isStringDynamicXpath = true)
    PaymentOrderSentPage checkCategoryField(String category);

    @Click(NEXT_PAYMENT_BUTTON_XPATH)
    NewPaymentDomesticPage clickNextPaymentButton();
}
