package cz.moneta.test.dsl.forte.pages.branches;

import cz.moneta.test.dsl.forte.FortePageFlow;
import cz.moneta.test.dsl.forte.components.BranchesMenu;
import cz.moneta.test.harness.support.web.*;

import static cz.moneta.test.dsl.forte.pages.branches.MmbFindBranchesPage.PAGE_TITLE;
import static cz.moneta.test.dsl.forte.pages.branches.MmbFindBranchesPage.SEARCH_BUTTON;

@Wait({PAGE_TITLE, SEARCH_BUTTON})
public interface MmbFindBranchesPage extends FortePageFlow<MmbFindBranchesPage>, BranchesMenu {

    String PAGE_TITLE = CONTENT_DIV + "//h3[text()='Vyhledávání poboček']";
    String SEARCH_FORM = CONTENT_DIV + "//form[@id='frm-findForm-findForm']";
    String BRANCH_NAME_INPUT = SEARCH_FORM + "//input[@name='branch']";
    String SEARCH_BUTTON = SEARCH_FORM + "//input[@name='_submit']";
    String FOUND_BRANCHES_DIV = CONTENT_DIV + "//div[@id='snippet--results']";
    String FOUND_BRANCHES_TITLE = FOUND_BRANCHES_DIV + "//h4[text()='Nalezené pobočky']";
    String FOUND_BRANCHES_RESULT_TABLE = FOUND_BRANCHES_DIV + "//a[starts-with(text(), '%s')]";

    @TypeInto(value = BRANCH_NAME_INPUT, clear = true)
    MmbFindBranchesPage fillBranchName(String branchName);

    @Click(value = SEARCH_BUTTON, andWait = @Wait(value = SPINNER, until = Until.GONE, by = Lookup.ID))
    MmbFindBranchesPage clickSearch();

    @CheckElementPresent(FOUND_BRANCHES_TITLE)
    MmbFindBranchesPage checkFoundBranchesTitle();

    @CheckElementPresent(value = FOUND_BRANCHES_RESULT_TABLE, isStringDynamicXpath = true)
    MmbFindBranchesPage checkFoundBranchesElements(String expectedLinkString);

}