package cz.moneta.test.dsl.auto.smartauto;

import cz.moneta.test.dsl.auto.smartauto.shared.CalendarAccessor;
import cz.moneta.test.dsl.auto.smartauto.shared.Day;
import cz.moneta.test.dsl.auto.smartauto.shared.Month;
import cz.moneta.test.dsl.auto.smartauto.shared.Year;
import cz.moneta.test.harness.context.StoreAccessor;
import cz.moneta.test.harness.support.web.*;

import static cz.moneta.test.dsl.auto.smartauto.QueuePage.*;

@Wait(value = {DATE_FROM, DATE_TO},
        waitSecondsForElement = 40)
public interface QueuePage extends SmartAutoFlow<QueuePage>, StoreAccessor, CalendarAccessor {

    String HEADING_SEND_APPLICATIONS = "//h1[contains(text(), 'Odeslané žádosti')]";
    String FIRST_APPLICATION = "//div/div/div/button/i";
    String DATE_FROM = "//label[contains(., 'Datum od')]/following-sibling::div/button";
    String DATE_TO = "//label[contains(., 'Datum do')]/following-sibling::div/button";
    String SEARCH_BUTTON = "//button[@testid='bbutton' and span[text()='Zobrazit']]";
    String QUEUE_ITEM = "(//div[contains(@class, 'queue-item-hVy1h')])[1]";

    @CheckElementPresent(HEADING_SEND_APPLICATIONS)
    QueuePage checkHeadingSendApplication();

    @Click(FIRST_APPLICATION)
    OthersPage clickOpenApplication();

    @Click(DATE_FROM)
    QueuePage clickDateFrom();

    @Click(DATE_TO)
    QueuePage clickDateTo();

    @Click(DATE_FROM_MONTH)
    QueuePage clickDateFromMonth();

    @Click(DATE_TO_MONTH)
    QueuePage clickDateToMonth();

    @Click(value = DATE_FROM_MONTH_DEFAULT, andWait = @Wait(explicitWaitSeconds = 1))
    QueuePage setDateFromMonthValue(Month month);

    @Click(value = DATE_TO_MONTH_DEFAULT, andWait = @Wait(explicitWaitSeconds = 1))
    QueuePage setDateToMonthValue(Month month);

    @Click(value = DATE_FROM_DAY_DEFAULT, andWait = @Wait(explicitWaitSeconds = 1))
    QueuePage setDateFromDayValue(Day day);

    @Click(value = DATE_TO_DAY_DEFAULT, andWait = @Wait(explicitWaitSeconds = 1))
    QueuePage setDateToDayValue(Day day);

    @TypeInto(value = FROM_DATE_YEAR_FIELD, clear = true)
    QueuePage setDateFromYear(Year year);

    @Click(SEARCH_BUTTON)
    QueuePage clickSearch();

    @Wait(value = QUEUE_ITEM, explicitWaitSeconds = 1)
    @CheckElementPresent(QUEUE_ITEM)
    QueuePage checkQueueItem();

}